geoproject-app/public/site/plugins/map-editor/index.js
isUnknown 9193ac8900 feat: implement automatic static map image generation
- Add html-to-image for capturing map container with markers
- Auto-generate map image on page/marker save via hooks
- Use flag system (.regenerate-map-image) to trigger generation on Panel reload
- Create file using Kirby API for proper indexing
- Add mapStaticImage field in blueprint to display generated image
- Wait for map to be fully loaded before capture
- Capture entire container (map + custom markers)
- Filter MapLibre controls from capture

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 11:48:20 +01:00

612 lines
822 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 Rd(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var jo={exports:{}},Fd=jo.exports,zu;function Bd(){return zu||(zu=1,(function(c,x){(function(T,k){c.exports=k()})(Fd,(function(){var T,k,P;function O(o,te){if(!T)T=te;else if(!k)k=te;else{var H="var sharedChunk = {}; ("+T+")(sharedChunk); ("+k+")(sharedChunk);",ve={};T(ve),P=te(ve),typeof window<"u"&&(P.workerUrl=window.URL.createObjectURL(new Blob([H],{type:"text/javascript"})))}}O(["exports"],(function(o){function te(i,e,r,a){return new(r||(r=Promise))((function(l,d){function f(b){try{y(a.next(b))}catch(S){d(S)}}function m(b){try{y(a.throw(b))}catch(S){d(S)}}function y(b){var S;b.done?l(b.value):(S=b.value,S instanceof r?S:new r((function(C){C(S)}))).then(f,m)}y((a=a.apply(i,e||[])).next())}))}function H(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var ve=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),l=e.y+a*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-a*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},de.convert=function(i){return i instanceof de?i:Array.isArray(i)?new de(i[0],i[1]):i};var ge=H(ve),Ue=rt;function rt(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}rt.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<e)return r;var d=this.sampleCurveDerivativeX(r);if(Math.abs(d)<1e-6)break;r-=l/d}var f=0,m=1;for(r=i,a=0;a<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<e));a++)i>l?f=r:m=r,r=.5*(m-f)+f;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Te=H(Ue);let Be,Ze;function He(){return Be==null&&(Be=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Be}function Et(){if(Ze==null&&(Ze=!1,He())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let a=0;a<25;a++){const l=4*a;e.fillStyle=`rgb(${l},${l+1},${l+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){Ze=!0;break}}}return Ze||!1}function Di(i,e,r,a){const l=new Te(i,e,r,a);return function(d){return l.solve(d)}}const Kr=Di(.25,.1,.25,1);function ar(i,e,r){return Math.min(r,Math.max(e,i))}function mn(i,e,r){const a=r-e,l=((i-e)%a+a)%a+e;return l===e?r:l}function ii(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let Vn=1;function Mt(i,e,r){const a={};for(const l in i)a[l]=e.call(r||this,i[l],l,i);return a}function Yr(i,e,r){const a={};for(const l in i)e.call(r||this,i[l],l,i)&&(a[l]=i[l]);return a}function Gi(i){return Array.isArray(i)?i.map(Gi):typeof i=="object"&&i?Mt(i,Gi):i}const wr={};function Le(i){wr[i]||(typeof console<"u"&&console.warn(i),wr[i]=!0)}function qe(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function pt(i){let e=0;for(let r,a,l=0,d=i.length,f=d-1;l<d;f=l++)r=i[l],a=i[f],e+=(a.x-r.x)*(r.y+a.y);return e}function $t(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}let Rt=null;function Sr(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const Li="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function da(i,e,r,a,l){return te(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*l*4);if(yield d.copyTo(y,(function(b,S,C,M,L){const R=4*Math.max(-S,0),V=(Math.max(0,C)-C)*M*4+R,G=4*M,K=Math.max(0,S),ne=Math.max(0,C);return{rect:{x:K,y:ne,width:Math.min(b.width,S+M)-K,height:Math.min(b.height,C+L)-ne},layout:[{offset:V,stride:G}]}})(i,e,r,a,l)),m)for(let b=0;b<y.length;b+=4){const S=y[b];y[b]=y[b+2],y[b+2]=S}return y}finally{d.close()}}))}let Tr,Pt,Ri,gn;const Un={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=>(Ri||(Ri=document.createElement("a")),Ri.href=i,Ri.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(gn==null&&(gn=matchMedia("(prefers-reduced-motion: reduce)")),gn.matches)}},$n={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};class Jr extends Error{constructor(e,r,a,l){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=l}}const _r=$t()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href,sr=i=>$n.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))];function fa(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:_r(),signal:r.signal});let l=!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||(l=!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 Jr(f.status,f.statusText,i.url,m)))))).catch((f=>{f.code!==20&&e(new Error(f.message))})),{cancel:()=>{d=!0,l||r.abort()}}}const Qr=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if($t()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!$t())return(sr(i.url)||fa)(i,e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(_r())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return fa(i,e);if($t()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return(function(a,l){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=()=>{l(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 l(m)}l(null,f,d.getResponseHeader("Cache-Control"),d.getResponseHeader("Expires"))}else{const f=new Blob([d.response],{type:d.getResponseHeader("Content-Type")});l(new Jr(d.status,d.statusText,a.url,f))}},d.send(a.body),{cancel:()=>d.abort()}})(i,e)},ma=function(i,e){return Qr(ii(i,{type:"arrayBuffer"}),e)};function Fr(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 jn(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function _n(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class en{constructor(e,r={}){ii(this,r),this.type=e}}class tn extends en{constructor(e,r={}){super("error",ii({error:e},r))}}class yn{on(e,r){return this._listeners=this._listeners||{},jn(e,r,this._listeners),this}off(e,r){return _n(e,r,this._listeners),_n(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},jn(e,r,this._oneTimeListeners),this):new Promise((a=>this.once(e,a)))}fire(e,r){typeof e=="string"&&(e=new en(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const l=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const m of l)m.call(this,e);const d=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const m of d)_n(a,m,this._oneTimeListeners),m.call(this,e);const f=this._eventedParent;f&&(ii(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),f.fire(e))}else e instanceof tn&&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 Fi=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function or(i,e){const r={};for(const a in i)a!=="ref"&&(r[a]=i[a]);return Fi.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 Ir(i,e,r){r.push({command:_t.addSource,args:[i,e[i]]})}function qn(i,e,r){e.push({command:_t.removeSource,args:[i]}),r[i]=!0}function Br(i,e,r,a){qn(i,r,a),Ir(i,e,r)}function qa(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 Zn(i,e,r,a,l,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],l]}));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],l]}))}function rn(i){return i.id}function xn(i,e){return i[e.id]=e,i}class Ae{constructor(e,r,a,l){this.message=(e?`${e}: `:"")+a,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function Ar(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}class jt extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class vn{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,l]of r)this.bindings[a]=l}concat(e){return new vn(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 Or={kind:"null"},ke={kind:"number"},st={kind:"string"},tt={kind:"boolean"},Ii={kind:"color"},Cr={kind:"object"},nt={kind:"value"},Nr={kind:"collator"},j={kind:"formatted"},E={kind:"padding"},z={kind:"resolvedImage"},F={kind:"variableAnchorOffsetCollection"};function Z(i,e){return{kind:"array",itemType:i,N:e}}function W(i){if(i.kind==="array"){const e=W(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const ae=[Or,ke,st,tt,Ii,j,Cr,Z(nt),E,z,F];function Q(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Q(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 ae)if(!Q(r,e))return null}}return`Expected ${W(i)} but found ${W(e)} instead.`}function Y(i,e){return e.some((r=>r.kind===i.kind))}function re(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,We=4/29,et=6/29,Oe=3*et*et,Ke=et*et*et,it=Math.PI/180,bt=180/Math.PI;function Tt(i){return(i%=360)<0&&(i+=360),i}function gt([i,e,r,a]){let l,d;const f=yi((.2225045*(i=mt(i))+.7168786*(e=mt(e))+.0606169*(r=mt(r)))/1);i===e&&e===r?l=d=f:(l=yi((.4360747*i+.3850649*e+.1430804*r)/fe),d=yi((.0139322*i+.0971045*e+.7141733*r)/ye));const m=116*f-16;return[m<0?0:m,500*(l-f),200*(f-d),a]}function mt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function yi(i){return i>Ke?Math.pow(i,1/3):i/Oe+We}function Ct([i,e,r,a]){let l=(i+16)/116,d=isNaN(e)?l:l+e/500,f=isNaN(r)?l:l-r/200;return l=1*di(l),d=fe*di(d),f=ye*di(f),[Qt(3.1338561*d-1.6168667*l-.4906146*f),Qt(-.9787684*d+1.9161415*l+.033454*f),Qt(.0719453*d-.2289914*l+1.4052427*f),a]}function Qt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function di(i){return i>et?i*i*i:Oe*(i-We)}function lr(i){return parseInt(i.padEnd(2,i),16)/255}function el(i,e){return Gn(e?i/100:i,0,1)}function Gn(i,e,r){return Math.min(Math.max(e,i),r)}function Hn(i){return!i.some(Number.isNaN)}const Ic={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,l=1,d=!0){this.r=e,this.g=r,this.b=a,this.a=l,d||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,a,l]))}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 l=Ic[a];if(l){const[f,m,y]=l;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[lr(a.slice(m,m+=f)),lr(a.slice(m,m+=f)),lr(a.slice(m,m+=f)),lr(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,b,S,C,M,L,R,V,G,K,ne]=f,J=[S||" ",L||" ",G].join("");if(J===" "||J===" /"||J===",,"||J===",,,"){const se=[b,M,V].join(""),le=se==="%%%"?100:se===""?255:0;if(le){const _e=[Gn(+y/le,0,1),Gn(+C/le,0,1),Gn(+R/le,0,1),K?el(+K,ne):1];if(Hn(_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,b,S,C,M,L,R]=d,V=[y||" ",S||" ",M].join("");if(V===" "||V===" /"||V===",,"||V===",,,"){const G=[+m,Gn(+b,0,100),Gn(+C,0,100),L?el(+L,R):1];if(Hn(G))return(function([K,ne,J,se]){function le(_e){const De=(_e+K/30)%12,Ve=ne*Math.min(J,1-J);return J-Ve*Math.max(-1,Math.min(De-3,9-De,1))}return K=Tt(K),ne/=100,J/=100,[le(0),le(8),le(4),se]})(G)}}})(e);return r?new wt(...r,!1):void 0}get rgb(){const{r:e,g:r,b:a,a:l}=this,d=l||1/0;return this.overwriteGetter("rgb",[e/d,r/d,a/d,l])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,a,l,d]=gt(e),f=Math.sqrt(a*a+l*l);return[Math.round(1e4*f)?Tt(Math.atan2(l,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,l]=this.rgb;return`rgba(${[e,r,a].map((d=>Math.round(255*d))).join(",")},${l})`}}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 Fs{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 Za{constructor(e,r,a,l,d){this.text=e,this.image=r,this.scale=a,this.fontStack=l,this.textColor=d}}class xi{constructor(e){this.sections=e}static fromString(e){return new xi([new Za(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 xi?e:xi.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class Hi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Hi)return e;if(typeof e=="number")return new Hi([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 Hi(e)}}toString(){return JSON.stringify(this.values)}}const Ac=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class cr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof cr)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const a=e[r],l=e[r+1];if(typeof a!="string"||!Ac.has(a)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new cr(e)}}toString(){return JSON.stringify(this.values)}}class fi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new fi({name:e,available:!1}):null}}function Ga(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 Wn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof wt||i instanceof Fs||i instanceof xi||i instanceof Hi||i instanceof cr||i instanceof fi)return!0;if(Array.isArray(i)){for(const e of i)if(!Wn(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Wn(i[e]))return!1;return!0}return!1}function Ot(i){if(i===null)return Or;if(typeof i=="string")return st;if(typeof i=="boolean")return tt;if(typeof i=="number")return ke;if(i instanceof wt)return Ii;if(i instanceof Fs)return Nr;if(i instanceof xi)return j;if(i instanceof Hi)return E;if(i instanceof cr)return F;if(i instanceof fi)return z;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const l=Ot(a);if(r){if(r===l)continue;r=nt;break}r=l}return Z(r||nt,e)}return Cr}function yt(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof wt||i instanceof xi||i instanceof Hi||i instanceof cr||i instanceof fi?i.toString():JSON.stringify(i)}class bn{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(!Wn(e[1]))return r.error("invalid value");const a=e[1];let l=Ot(a);const d=r.expectedType;return l.kind!=="array"||l.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(l=d),new bn(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class qt{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Ha={string:st,number:ke,boolean:tt,object:Cr};class ur{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,l=1;const d=e[0];if(d==="array"){let m,y;if(e.length>2){const b=e[1];if(typeof b!="string"||!(b in Ha)||b==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);m=Ha[b],l++}else m=nt;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],l++}a=Z(m,y)}else{if(!Ha[d])throw new Error(`Types doesn't contain name = ${d}`);a=Ha[d]}const f=[];for(;l<e.length;l++){const m=r.parse(e[l],l,nt);if(!m)return null;f.push(m)}return new ur(a,f)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!Q(this.type,Ot(a)))return a;if(r===this.args.length-1)throw new qt(`Expected value to be of type ${W(this.type)}, but found ${W(Ot(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Bs={"to-boolean":tt,"to-color":Ii,"to-number":ke,"to-string":st};class nn{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(!Bs[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Bs[a],d=[];for(let f=1;f<e.length;f++){const m=r.parse(e[f],f,nt);if(!m)return null;d.push(m)}return new nn(l,d)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,a;for(const l of this.args){if(r=l.evaluate(e),a=null,r instanceof 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.`:Ga(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 qt(a||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const a of this.args){r=a.evaluate(e);const l=Hi.parse(r);if(l)return l}throw new qt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const a of this.args){r=a.evaluate(e);const l=cr.parse(r);if(l)return l}throw new qt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const a of this.args){if(r=a.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new qt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return xi.fromString(yt(this.args[0].evaluate(e)));case"resolvedImage":return fi.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 tl=["Unknown","Point","LineString","Polygon"];class Os{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"?tl[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 Wa{constructor(e,r,a=[],l,d=new vn,f=[]){this.registry=e,this.path=a,this.key=a.map((m=>`[${m}]`)).join(""),this.scope=d,this.errors=f,this.expectedType=l,this._isConstant=r}parse(e,r,a,l,d={}){return r?this.concat(r,a,l)._parse(e,d):this._parse(e,d)}_parse(e,r){function a(l,d,f){return f==="assert"?new ur(d,[l]):f==="coerce"?new nn(d,[l]):l}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[l];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 bn)&&f.type.kind!=="resolvedImage"&&this._isConstant(f)){const m=new Os;try{f=new bn(f.type,f.evaluate(m))}catch(y){return this.error(y.message),null}}return f}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const l=typeof e=="number"?this.path.concat(e):this.path,d=a?this.scope.concat(a):this.scope;return new Wa(this.registry,this._isConstant,l,r||null,d,this.errors)}error(e,...r){const a=`${this.key}${r.map((l=>`[${l}]`)).join("")}`;this.errors.push(new jt(a,e))}checkSubtype(e,r){const a=Q(e,r);return a&&this.error(a),a}}class Xa{constructor(e,r,a){this.type=Nr,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const a=e[1];if(typeof a!="object"||Array.isArray(a))return r.error("Collator options argument must be an object.");const l=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,tt);if(!l)return null;const d=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,tt);if(!d)return null;let f=null;return a.locale&&(f=r.parse(a.locale,1,st),!f)?null:new Xa(l,d,f)}evaluate(e){return new Fs(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 an=8192;function Ns(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 ga(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function il(i,e){const r=(180+i[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*an),Math.round(a*l*an)]}function Cc(i,e,r){const a=i[0]-e[0],l=i[1]-e[1],d=i[0]-r[0],f=i[1]-r[1];return a*f-d*l==0&&a*d<=0&&l*f<=0}function Vs(i,e){let r=!1;for(let f=0,m=e.length;f<m;f++){const y=e[f];for(let b=0,S=y.length;b<S-1;b++){if(Cc(i,y[b],y[b+1]))return!1;(l=y[b])[1]>(a=i)[1]!=(d=y[b+1])[1]>a[1]&&a[0]<(d[0]-l[0])*(a[1]-l[1])/(d[1]-l[1])+l[0]&&(r=!r)}}var a,l,d;return r}function Us(i,e){for(let r=0;r<e.length;r++)if(Vs(i,e[r]))return!0;return!1}function rl(i,e,r,a){const l=a[0]-r[0],d=a[1]-r[1],f=(i[0]-r[0])*d-l*(i[1]-r[1]),m=(e[0]-r[0])*d-l*(e[1]-r[1]);return f>0&&m<0||f<0&&m>0}function kc(i,e,r){for(const b of r)for(let S=0;S<b.length-1;++S)if((m=[(f=b[S+1])[0]-(d=b[S])[0],f[1]-d[1]])[0]*(y=[(l=e)[0]-(a=i)[0],l[1]-a[1]])[1]-m[1]*y[0]!=0&&rl(a,l,d,f)&&rl(d,f,a,l))return!0;var a,l,d,f,m,y;return!1}function nl(i,e){for(let r=0;r<i.length;++r)if(!Vs(i[r],e))return!1;for(let r=0;r<i.length-1;++r)if(kc(i[r],i[r+1],e))return!1;return!0}function al(i,e){for(let r=0;r<e.length;r++)if(nl(i,e[r]))return!0;return!1}function Ka(i,e,r){const a=[];for(let l=0;l<i.length;l++){const d=[];for(let f=0;f<i[l].length;f++){const m=il(i[l][f],r);Ns(e,m),d.push(m)}a.push(d)}return a}function sl(i,e,r){const a=[];for(let l=0;l<i.length;l++){const d=Ka(i[l],e,r);a.push(d)}return a}function ol(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const l=.5*a;let d=i[0]-r[0]>l?-a:r[0]-i[0]>l?a:0;d===0&&(d=i[0]-r[2]>l?-a:r[2]-i[0]>l?a:0),i[0]+=d}Ns(e,i)}function $s(i,e,r,a){const l=Math.pow(2,a.z)*an,d=[a.x*an,a.y*an],f=[];for(const m of i)for(const y of m){const b=[y.x+d[0],y.y+d[1]];ol(b,e,r,l),f.push(b)}return f}function js(i,e,r,a){const l=Math.pow(2,a.z)*an,d=[a.x*an,a.y*an],f=[];for(const y of i){const b=[];for(const S of y){const C=[S.x+d[0],S.y+d[1]];Ns(e,C),b.push(C)}f.push(b)}if(e[2]-e[0]<=l/2){(m=e)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const y of f)for(const b of y)ol(b,e,r,l)}var m;return f}class wn{constructor(e,r){this.type=tt,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(Wn(e[1])){const a=e[1];if(a.type==="FeatureCollection")for(let l=0;l<a.features.length;++l){const d=a.features[l].geometry.type;if(d==="Polygon"||d==="MultiPolygon")return new wn(a,a.features[l].geometry)}else if(a.type==="Feature"){const l=a.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new wn(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new wn(a,a)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],f=r.canonicalID();if(a.type==="Polygon"){const m=Ka(a.coordinates,d,f),y=$s(r.geometry(),l,d,f);if(!ga(l,d))return!1;for(const b of y)if(!Vs(b,m))return!1}if(a.type==="MultiPolygon"){const m=sl(a.coordinates,d,f),y=$s(r.geometry(),l,d,f);if(!ga(l,d))return!1;for(const b of y)if(!Us(b,m))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],f=r.canonicalID();if(a.type==="Polygon"){const m=Ka(a.coordinates,d,f),y=js(r.geometry(),l,d,f);if(!ga(l,d))return!1;for(const b of y)if(!nl(b,m))return!1}if(a.type==="MultiPolygon"){const m=sl(a.coordinates,d,f),y=js(r.geometry(),l,d,f);if(!ga(l,d))return!1;for(const b of y)if(!al(b,m))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class Ya{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 Ya(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 hr{constructor(e,r,a,l){this.name=e,this.type=r,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],l=hr.definitions[a];if(!l)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(l)?l[0]:l.type,f=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,m=f.filter((([b])=>!Array.isArray(b)||b.length===e.length-1));let y=null;for(const[b,S]of m){y=new Wa(r.registry,Ja,r.path,null,r.scope);const C=[];let M=!1;for(let L=1;L<e.length;L++){const R=e[L],V=Array.isArray(b)?b[L-1]:b.type,G=y.parse(R,1+C.length,V);if(!G){M=!0;break}C.push(G)}if(!M)if(Array.isArray(b)&&b.length!==C.length)y.error(`Expected ${b.length} arguments, but found ${C.length} instead.`);else{for(let L=0;L<C.length;L++){const R=Array.isArray(b)?b[L]:b.type,V=C[L];y.concat(L+1).checkSubtype(R,V.type)}if(y.errors.length===0)return new hr(a,d,S,C)}}if(m.length===1)r.errors.push(...y.errors);else{const b=(m.length?m:f).map((([C])=>{return M=C,Array.isArray(M)?`(${M.map(W).join(", ")})`:`(${W(M.type)}...)`;var M})).join(" | "),S=[];for(let C=1;C<e.length;C++){const M=r.parse(e[C],1+S.length);if(!M)return null;S.push(W(M.type))}r.error(`Expected arguments of type ${b}, but found (${S.join(", ")}) instead.`)}return null}static register(e,r){hr.definitions=r;for(const a in r)e[a]=hr}}function Ja(i){if(i instanceof Ya)return Ja(i.boundExpression);if(i instanceof hr&&i.name==="error"||i instanceof Xa||i instanceof wn)return!1;const e=i instanceof nn||i instanceof ur;let r=!0;return i.eachChild((a=>{r=e?r&&Ja(a):r&&a instanceof bn})),!!r&&Qa(i)&&es(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Qa(i){if(i instanceof hr&&(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 wn)return!1;let e=!0;return i.eachChild((r=>{e&&!Qa(r)&&(e=!1)})),e}function _a(i){if(i instanceof hr&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!_a(r)&&(e=!1)})),e}function es(i,e){if(i instanceof hr&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((a=>{r&&!es(a,e)&&(r=!1)})),r}function Xn(i,e){const r=i.length-1;let a,l,d=0,f=r,m=0;for(;d<=f;)if(m=Math.floor((d+f)/2),a=i[m],l=i[m+1],a<=e){if(m===r||e<l)return m;d=m+1}else{if(!(a>e))throw new qt("Input is not a number.");f=m-1}return 0}class sn{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,d]of a)this.labels.push(l),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,ke);if(!a)return null;const l=[];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],b=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.',b);if(l.length&&l[l.length-1][0]>=m)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',b);const C=r.parse(y,S,d);if(!C)return null;d=d||C.type,l.push([m,C])}return new sn(d,a,l)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const d=r.length;return l>=r[d-1]?a[d-1].evaluate(e):a[Xn(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function dt(i,e,r){return i+r*(e-i)}function ts(i,e,r){return i.map(((a,l)=>dt(a,e[l],r)))}const Wi={number:dt,color:function(i,e,r,a="rgb"){switch(a){case"rgb":{const[l,d,f,m]=ts(i.rgb,e.rgb,r);return new wt(l,d,f,m,!1)}case"hcl":{const[l,d,f,m]=i.hcl,[y,b,S,C]=e.hcl;let M,L;if(isNaN(l)||isNaN(y))isNaN(l)?isNaN(y)?M=NaN:(M=y,f!==1&&f!==0||(L=b)):(M=l,S!==1&&S!==0||(L=d));else{let ne=y-l;y>l&&ne>180?ne-=360:y<l&&l-y>180&&(ne+=360),M=l+r*ne}const[R,V,G,K]=(function([ne,J,se,le]){return ne=isNaN(ne)?0:ne*it,Ct([se,Math.cos(ne)*J,Math.sin(ne)*J,le])})([M,L??dt(d,b,r),dt(f,S,r),dt(m,C,r)]);return new wt(R,V,G,K,!1)}case"lab":{const[l,d,f,m]=Ct(ts(i.lab,e.lab,r));return new wt(l,d,f,m,!1)}}},array:ts,padding:function(i,e,r){return new Hi(ts(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const a=i.values,l=e.values;if(a.length!==l.length)throw new qt(`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]!==l[f])throw new qt(`Cannot interpolate values containing mismatched anchors. from[${f}]: ${a[f]}, to[${f}]: ${l[f]}`);d.push(a[f]);const[m,y]=a[f+1],[b,S]=l[f+1];d.push([dt(m,b,r),dt(y,S,r)])}return new cr(d)}};class Xi{constructor(e,r,a,l,d){this.type=e,this.operator=r,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[f,m]of d)this.labels.push(f),this.outputs.push(m)}static interpolationFactor(e,r,a,l){let d=0;if(e.name==="exponential")d=qs(r,e.base,a,l);else if(e.name==="linear")d=qs(r,1,a,l);else if(e.name==="cubic-bezier"){const f=e.controlPoints;d=new Te(f[0],f[1],f[2],f[3]).solve(qs(r,1,a,l))}return d}static parse(e,r){let[a,l,d,...f]=e;if(!Array.isArray(l)||l.length===0)return r.error("Expected an interpolation type expression.",1);if(l[0]==="linear")l={name:"linear"};else if(l[0]==="exponential"){const b=l[1];if(typeof b!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:b}}else{if(l[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const b=l.slice(1);if(b.length!==4||b.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);l={name:"cubic-bezier",controlPoints:b}}}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,ke),!d)return null;const m=[];let y=null;a==="interpolate-hcl"||a==="interpolate-lab"?y=Ii:r.expectedType&&r.expectedType.kind!=="value"&&(y=r.expectedType);for(let b=0;b<f.length;b+=2){const S=f[b],C=f[b+1],M=b+3,L=b+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.',M);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.',M);const R=r.parse(C,L,y);if(!R)return null;y=y||R.type,m.push([S,R])}return pe(y,ke)||pe(y,Ii)||pe(y,E)||pe(y,F)||pe(y,Z(ke))?new Xi(y,a,l,d,m):r.error(`Type ${W(y)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const d=r.length;if(l>=r[d-1])return a[d-1].evaluate(e);const f=Xn(r,l),m=Xi.interpolationFactor(this.interpolation,l,r[f],r[f+1]),y=a[f].evaluate(e),b=a[f+1].evaluate(e);switch(this.operator){case"interpolate":return Wi[this.type.kind](y,b,m);case"interpolate-hcl":return Wi.color(y,b,m,"hcl");case"interpolate-lab":return Wi.color(y,b,m,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function qs(i,e,r,a){const l=a-r,d=i-r;return l===0?0:e===1?d/l:(Math.pow(e,d)-1)/(Math.pow(e,l)-1)}class is{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let a=null;const l=r.expectedType;l&&l.kind!=="value"&&(a=l);const 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=l&&d.some((m=>Q(l,m.type)));return new is(f?nt:a,d)}evaluate(e){let r,a=null,l=0;for(const d of this.args)if(l++,a=d.evaluate(e),a&&a instanceof fi&&!a.available&&(r||(r=a.name),a=null,l===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}class rs{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 l=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return l?new rs(a,l):null}outputDefined(){return this.result.outputDefined()}}class Zs{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,ke),l=r.parse(e[2],2,Z(r.expectedType||nt));return a&&l?new Zs(l.type.itemType,a,l):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new qt(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new qt(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new qt(`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 Gs{constructor(e,r){this.type=tt,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,nt),l=r.parse(e[2],2,nt);return a&&l?Y(a.type,[tt,st,ke,Or,nt])?new Gs(a,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${W(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!re(r,["boolean","string","number","null"]))throw new qt(`Expected first argument to be of type boolean, string, number or null, but found ${W(Ot(r))} instead.`);if(!re(a,["string","array"]))throw new qt(`Expected second argument to be of type array or string, but found ${W(Ot(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ns{constructor(e,r,a){this.type=ke,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,nt),l=r.parse(e[2],2,nt);if(!a||!l)return null;if(!Y(a.type,[tt,st,ke,Or,nt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${W(a.type)} instead`);if(e.length===4){const d=r.parse(e[3],3,ke);return d?new ns(a,l,d):null}return new ns(a,l)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!re(r,["boolean","string","number","null"]))throw new qt(`Expected first argument to be of type boolean, string, number or null, but found ${W(Ot(r))} instead.`);if(!re(a,["string","array"]))throw new qt(`Expected second argument to be of type array or string, but found ${W(Ot(a))} instead.`);if(this.fromIndex){const l=this.fromIndex.evaluate(e);return a.indexOf(r,l)}return a.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Hs{constructor(e,r,a,l,d,f){this.inputType=e,this.type=r,this.input=a,this.cases=l,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,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const d={},f=[];for(let b=2;b<e.length-1;b+=2){let S=e[b];const C=e[b+1];Array.isArray(S)||(S=[S]);const M=r.concat(b);if(S.length===0)return M.error("Expected at least one branch label.");for(const R of S){if(typeof R!="number"&&typeof R!="string")return M.error("Branch labels must be numbers or strings.");if(typeof R=="number"&&Math.abs(R)>Number.MAX_SAFE_INTEGER)return M.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof R=="number"&&Math.floor(R)!==R)return M.error("Numeric branch labels must be integer values.");if(a){if(M.checkSubtype(a,Ot(R)))return null}else a=Ot(R);if(d[String(R)]!==void 0)return M.error("Branch labels must be unique.");d[String(R)]=f.length}const L=r.parse(C,b,l);if(!L)return null;l=l||L.type,f.push(L)}const m=r.parse(e[1],1,nt);if(!m)return null;const y=r.parse(e[e.length-1],e.length-1,l);return y?m.type.kind!=="value"&&r.concat(1).checkSubtype(a,m.type)?null:new Hs(a,l,m,d,f,y):null}evaluate(e){const r=this.input.evaluate(e);return(Ot(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 Ws{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const l=[];for(let f=1;f<e.length-1;f+=2){const m=r.parse(e[f],f,tt);if(!m)return null;const y=r.parse(e[f+1],f+1,a);if(!y)return null;l.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 Ws(a,l,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 as{constructor(e,r,a,l){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,nt),l=r.parse(e[2],2,ke);if(!a||!l)return null;if(!Y(a.type,[Z(nt),st,nt]))return r.error(`Expected first argument to be of type array or string, but found ${W(a.type)} instead`);if(e.length===4){const d=r.parse(e[3],3,ke);return d?new as(a.type,a,l,d):null}return new as(a.type,a,l)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);if(!re(r,["string","array"]))throw new qt(`Expected first argument to be of type array or string, but found ${W(Ot(r))} instead.`);if(this.endIndex){const l=this.endIndex.evaluate(e);return r.slice(a,l)}return r.slice(a)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function ll(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 cl(i,e,r,a){return a.compare(e,r)===0}function Kn(i,e,r){const a=i!=="=="&&i!=="!=";return class Ld{constructor(d,f,m){this.type=tt,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,nt);if(!y)return null;if(!ll(m,y.type))return f.concat(1).error(`"${m}" comparisons are not supported for type '${W(y.type)}'.`);let b=f.parse(d[2],2,nt);if(!b)return null;if(!ll(m,b.type))return f.concat(2).error(`"${m}" comparisons are not supported for type '${W(b.type)}'.`);if(y.type.kind!==b.type.kind&&y.type.kind!=="value"&&b.type.kind!=="value")return f.error(`Cannot compare types '${W(y.type)}' and '${W(b.type)}'.`);a&&(y.type.kind==="value"&&b.type.kind!=="value"?y=new ur(b.type,[y]):y.type.kind!=="value"&&b.type.kind==="value"&&(b=new ur(y.type,[b])));let S=null;if(d.length===4){if(y.type.kind!=="string"&&b.type.kind!=="string"&&y.type.kind!=="value"&&b.type.kind!=="value")return f.error("Cannot use collator to compare non-string types.");if(S=f.parse(d[3],3,Nr),!S)return null}return new Ld(y,b,S)}evaluate(d){const f=this.lhs.evaluate(d),m=this.rhs.evaluate(d);if(a&&this.hasUntypedArgument){const y=Ot(f),b=Ot(m);if(y.kind!==b.kind||y.kind!=="string"&&y.kind!=="number")throw new qt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${y.kind}, ${b.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const y=Ot(f),b=Ot(m);if(y.kind!=="string"||b.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 Ec=Kn("==",(function(i,e,r){return e===r}),cl),Mc=Kn("!=",(function(i,e,r){return e!==r}),(function(i,e,r,a){return!cl(0,e,r,a)})),Pc=Kn("<",(function(i,e,r){return e<r}),(function(i,e,r,a){return a.compare(e,r)<0})),zc=Kn(">",(function(i,e,r){return e>r}),(function(i,e,r,a){return a.compare(e,r)>0})),Dc=Kn("<=",(function(i,e,r){return e<=r}),(function(i,e,r,a){return a.compare(e,r)<=0})),Lc=Kn(">=",(function(i,e,r){return e>=r}),(function(i,e,r,a){return a.compare(e,r)>=0}));class Xs{constructor(e,r,a,l,d){this.type=st,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=d}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,ke);if(!a)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let d=null;if(l.locale&&(d=r.parse(l.locale,1,st),!d))return null;let f=null;if(l.currency&&(f=r.parse(l.currency,1,st),!f))return null;let m=null;if(l["min-fraction-digits"]&&(m=r.parse(l["min-fraction-digits"],1,ke),!m))return null;let y=null;return l["max-fraction-digits"]&&(y=r.parse(l["max-fraction-digits"],1,ke),!y)?null:new Xs(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 ss{constructor(e){this.type=j,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&typeof a=="object")return r.error("First argument must be an image or text section.");const l=[];let 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,ke),!y))return null;let b=null;if(m["text-font"]&&(b=r.parse(m["text-font"],1,Z(st)),!b))return null;let S=null;if(m["text-color"]&&(S=r.parse(m["text-color"],1,Ii),!S))return null;const C=l[l.length-1];C.scale=y,C.font=b,C.textColor=S}else{const y=r.parse(e[f],1,nt);if(!y)return null;const b=y.type.kind;if(b!=="string"&&b!=="value"&&b!=="null"&&b!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,l.push({content:y,scale:null,font:null,textColor:null})}}return new ss(l)}evaluate(e){return new xi(this.sections.map((r=>{const a=r.content.evaluate(e);return Ot(a)===z?new Za("",a,null,null,null):new Za(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 Ks{constructor(e){this.type=z,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,st);return a?new Ks(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=fi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ys{constructor(e){this.type=ke,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 ${W(a.type)} instead.`):new Ys(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new qt(`Expected value to be of type string or array, but found ${W(Ot(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Yn={"==":Ec,"!=":Mc,">":zc,"<":Pc,">=":Lc,"<=":Dc,array:ur,at:Zs,boolean:ur,case:Ws,coalesce:is,collator:Xa,format:ss,image:Ks,in:Gs,"index-of":ns,interpolate:Xi,"interpolate-hcl":Xi,"interpolate-lab":Xi,length:Ys,let:rs,literal:bn,match:Hs,number:ur,"number-format":Xs,object:ur,slice:as,step:sn,string:ur,"to-boolean":nn,"to-color":nn,"to-number":nn,"to-string":nn,var:Ya,within:wn};function ul(i,[e,r,a,l]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const d=l?l.evaluate(i):1,f=Ga(e,r,a,d);if(f)throw new qt(f);return new wt(e/255,r/255,a/255,d,!1)}function hl(i,e){return i in e}function Js(i,e){const r=e[i];return r===void 0?null:r}function Sn(i){return{type:i}}function pl(i){return{result:"success",value:i}}function on(i){return{result:"error",value:i}}function Jn(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function dl(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Qs(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 Nt(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Rc(i){return i}function ft(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",l=a||!(a||i.property!==void 0),d=i.type||(Qs(e)?"exponential":"interval");if(r||e.type==="padding"){const S=r?wt.parse:Hi.parse;(i=Ar({},i)).stops&&(i.stops=i.stops.map((C=>[C[0],S(C[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,b;if(d==="exponential")m=ya;else if(d==="interval")m=Ft;else if(d==="categorical"){m=Vt,y=Object.create(null);for(const S of i.stops)y[S[0]]=S[1];b=typeof i.stops[0][0]}else{if(d!=="identity")throw new Error(`Unknown function type "${d}"`);m=fl}if(a){const S={},C=[];for(let R=0;R<i.stops.length;R++){const V=i.stops[R],G=V[0].zoom;S[G]===void 0&&(S[G]={zoom:G,type:i.type,property:i.property,default:i.default,stops:[]},C.push(G)),S[G].stops.push([V[0].value,V[1]])}const M=[];for(const R of C)M.push([S[R].zoom,ft(S[R],e)]);const L={name:"linear"};return{kind:"composite",interpolationType:L,interpolationFactor:Xi.interpolationFactor.bind(void 0,L),zoomStops:M.map((R=>R[0])),evaluate:({zoom:R},V)=>ya({stops:M,base:i.base},e,R).evaluate(R,V)}}if(l){const S=d==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:S,interpolationFactor:Xi.interpolationFactor.bind(void 0,S),zoomStops:i.stops.map((C=>C[0])),evaluate:({zoom:C})=>m(i,e,C,y,b)}}return{kind:"source",evaluate(S,C){const M=C&&C.properties?C.properties[i.property]:void 0;return M===void 0?Tn(i.default,e.default):m(i,e,M,y,b)}}}function Tn(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function Vt(i,e,r,a,l){return Tn(typeof r===l?a[r]:void 0,i.default,e.default)}function Ft(i,e,r){if(xt(r)!=="number")return Tn(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const l=Xn(i.stops.map((d=>d[0])),r);return i.stops[l][1]}function ya(i,e,r){const a=i.base!==void 0?i.base:1;if(xt(r)!=="number")return Tn(i.default,e.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const d=Xn(i.stops.map((S=>S[0])),r),f=(function(S,C,M,L){const R=L-M,V=S-M;return R===0?0:C===1?V/R:(Math.pow(C,V)-1)/(Math.pow(C,R)-1)})(r,a,i.stops[d][0],i.stops[d+1][0]),m=i.stops[d][1],y=i.stops[d+1][1],b=Wi[e.type]||Rc;return typeof m.evaluate=="function"?{evaluate(...S){const C=m.evaluate.apply(void 0,S),M=y.evaluate.apply(void 0,S);if(C!==void 0&&M!==void 0)return b(C,M,f,i.colorSpace)}}:b(m,y,f,i.colorSpace)}function fl(i,e,r){switch(e.type){case"color":r=wt.parse(r);break;case"formatted":r=xi.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=Hi.parse(r);break;default:xt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Tn(r,i.default,e.default)}hr.register(Yn,{error:[{kind:"error"},[st],(i,[e])=>{throw new qt(e.evaluate(i))}],typeof:[st,[nt],(i,[e])=>W(Ot(e.evaluate(i)))],"to-rgba":[Z(ke,4),[Ii],(i,[e])=>{const[r,a,l,d]=e.evaluate(i).rgb;return[255*r,255*a,255*l,d]}],rgb:[Ii,[ke,ke,ke],ul],rgba:[Ii,[ke,ke,ke,ke],ul],has:{type:tt,overloads:[[[st],(i,[e])=>hl(e.evaluate(i),i.properties())],[[st,Cr],(i,[e,r])=>hl(e.evaluate(i),r.evaluate(i))]]},get:{type:nt,overloads:[[[st],(i,[e])=>Js(e.evaluate(i),i.properties())],[[st,Cr],(i,[e,r])=>Js(e.evaluate(i),r.evaluate(i))]]},"feature-state":[nt,[st],(i,[e])=>Js(e.evaluate(i),i.featureState||{})],properties:[Cr,[],i=>i.properties()],"geometry-type":[st,[],i=>i.geometryType()],id:[nt,[],i=>i.id()],zoom:[ke,[],i=>i.globals.zoom],"heatmap-density":[ke,[],i=>i.globals.heatmapDensity||0],"line-progress":[ke,[],i=>i.globals.lineProgress||0],accumulated:[nt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[ke,Sn(ke),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[ke,Sn(ke),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:ke,overloads:[[[ke,ke],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[ke],(i,[e])=>-e.evaluate(i)]]},"/":[ke,[ke,ke],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[ke,[ke,ke],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[ke,[ke],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[ke,[ke],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[ke,[ke],(i,[e])=>Math.log(e.evaluate(i))],log2:[ke,[ke],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[ke,[ke],(i,[e])=>Math.sin(e.evaluate(i))],cos:[ke,[ke],(i,[e])=>Math.cos(e.evaluate(i))],tan:[ke,[ke],(i,[e])=>Math.tan(e.evaluate(i))],asin:[ke,[ke],(i,[e])=>Math.asin(e.evaluate(i))],acos:[ke,[ke],(i,[e])=>Math.acos(e.evaluate(i))],atan:[ke,[ke],(i,[e])=>Math.atan(e.evaluate(i))],min:[ke,Sn(ke),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[ke,Sn(ke),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[ke,[ke],(i,[e])=>Math.abs(e.evaluate(i))],round:[ke,[ke],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[ke,[ke],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[ke,[ke],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[tt,[st,nt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[tt,[nt],(i,[e])=>i.id()===e.value],"filter-type-==":[tt,[st],(i,[e])=>i.geometryType()===e.value],"filter-<":[tt,[st,nt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<l}],"filter-id-<":[tt,[nt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[tt,[st,nt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>l}],"filter-id->":[tt,[nt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[tt,[st,nt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<=l}],"filter-id-<=":[tt,[nt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[tt,[st,nt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>=l}],"filter-id->=":[tt,[nt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[tt,[nt],(i,[e])=>e.value in i.properties()],"filter-has-id":[tt,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[tt,[Z(st)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[tt,[Z(nt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[tt,[st,Z(nt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[tt,[st,Z(nt)],(i,[e,r])=>(function(a,l,d,f){for(;d<=f;){const m=d+f>>1;if(l[m]===a)return!0;l[m]>a?f=m-1:d=m+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:tt,overloads:[[[tt,tt],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Sn(tt),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:tt,overloads:[[[tt,tt],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Sn(tt),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[tt,[tt],(i,[e])=>!e.evaluate(i)],"is-supported-script":[tt,[st],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[st,[st],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[st,[st],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[st,Sn(nt),(i,e)=>e.map((r=>yt(r.evaluate(i)))).join("")],"resolved-locale":[st,[Nr],(i,[e])=>e.evaluate(i).resolvedLocale()]});class eo{constructor(e,r){var a;this.expression=e,this._warningHistory={},this._evaluator=new Os,this._defaultValue=r?(a=r).type==="color"&&Nt(a.default)?new wt(0,0,0,0):a.type==="color"?wt.parse(a.default)||null:a.type==="padding"?Hi.parse(a.default)||null:a.type==="variableAnchorOffsetCollection"?cr.parse(a.default)||null:a.default===void 0?null:a.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,a,l,d,f){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=f,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,l,d,f){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,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 qt(`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 os(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Yn}function ls(i,e){const r=new Wa(Yn,Ja,[],e?(function(l){const d={color:Ii,string:st,number:ke,enum:st,boolean:tt,formatted:j,padding:E,resolvedImage:z,variableAnchorOffsetCollection:F};return l.type==="array"?Z(d[l.value]||nt,l.length):d[l.type]})(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?pl(new eo(a,e)):on(r.errors)}class to{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!_a(r.expression)}evaluateWithoutErrorHandling(e,r,a,l,d,f){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,d,f)}evaluate(e,r,a,l,d,f){return this._styleExpression.evaluate(e,r,a,l,d,f)}}class cs{constructor(e,r,a,l){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!_a(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,a,l,d,f){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,d,f)}evaluate(e,r,a,l,d,f){return this._styleExpression.evaluate(e,r,a,l,d,f)}interpolationFactor(e,r,a){return this.interpolationType?Xi.interpolationFactor(this.interpolationType,e,r,a):0}}function io(i,e){const r=ls(i,e);if(r.result==="error")return r;const a=r.value.expression,l=Qa(a);if(!l&&!Jn(e))return on([new jt("","data expressions not supported")]);const d=es(a,["zoom"]);if(!d&&!dl(e))return on([new jt("","zoom expressions not supported")]);const f=va(a);return f||d?f instanceof jt?on([f]):f instanceof Xi&&!Qs(e)?on([new jt("",'"interpolate" expressions cannot be used with this property')]):pl(f?new cs(l?"camera":"composite",r.value,f.labels,f instanceof Xi?f.interpolation:void 0):new to(l?"constant":"source",r.value)):on([new jt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class xa{constructor(e,r){this._parameters=e,this._specification=r,Ar(this,ft(this._parameters,this._specification))}static deserialize(e){return new xa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function va(i){let e=null;if(i instanceof rs)e=va(i.result);else if(i instanceof is){for(const r of i.args)if(e=va(r),e)break}else(i instanceof sn||i instanceof Xi)&&i.input instanceof hr&&i.input.name==="zoom"&&(e=i);return e instanceof jt||i.eachChild((r=>{const a=va(r);a instanceof jt?e=a:!e&&a?e=new jt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new jt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function ba(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(!ba(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Fc={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ro(i){if(i==null)return{filter:()=>!0,needGeometry:!1};ba(i)||(i=us(i));const e=ls(i,Fc);if(e.result==="error")throw new Error(e.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,a,l)=>e.value.evaluate(r,a,{},l),needGeometry:ml(i)}}function Bc(i,e){return i<e?-1:i>e?1:0}function ml(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e<i.length;e++)if(ml(i[e]))return!0;return!1}function us(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?no(i[1],i[2],"=="):e==="!="?wa(no(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?no(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(us))):e==="all"?["all"].concat(i.slice(1).map(us)):e==="none"?["all"].concat(i.slice(1).map(us).map(wa)):e==="in"?gl(i[1],i.slice(2)):e==="!in"?wa(gl(i[1],i.slice(2))):e==="has"?_l(i[1]):e==="!has"?wa(_l(i[1])):e!=="within"||i;var r}function no(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 gl(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(Bc)]]:["filter-in-small",i,["literal",e]]}}function _l(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function wa(i){return["!",i]}function hs(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const d of i)l+=`${hs(d)},`;return`${l}]`}const r=Object.keys(i).sort();let a="{";for(let l=0;l<r.length;l++)a+=`${JSON.stringify(r[l])}:${hs(i[r[l]])},`;return`${a}}`}function ps(i){let e="";for(const r of Fi)e+=`/${hs(i[r])}`;return e}function yl(i){const e=i.value;return e?[new Ae(i.key,e,"constants have been deprecated as of v8")]:[]}function Zt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function In(i){if(Array.isArray(i))return i.map(In);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=In(i[r]);return e}return Zt(i)}function Bi(i){const e=i.key,r=i.value,a=i.valueSpec||{},l=i.objectElementValidators||{},d=i.style,f=i.styleSpec,m=i.validateSpec;let y=[];const b=xt(r);if(b!=="object")return[new Ae(e,r,`object expected, ${b} found`)];for(const S in r){const C=S.split(".")[0],M=a[C]||a["*"];let L;if(l[C])L=l[C];else if(a[C])L=m;else if(l["*"])L=l["*"];else{if(!a["*"]){y.push(new Ae(e,r[S],`unknown property "${S}"`));continue}L=m}y=y.concat(L({key:(e&&`${e}.`)+S,value:r[S],valueSpec:M,style:d,styleSpec:f,object:r,objectKey:S,validateSpec:m},r))}for(const S in a)l[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 Qn(i){const e=i.value,r=i.valueSpec,a=i.style,l=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};l.$version<7&&(m.function=r.function),xt(r.value)==="object"&&(m=r.value);let y=[];for(let b=0;b<e.length;b++)y=y.concat(f({array:e,arrayIndex:b,value:e[b],valueSpec:m,validateSpec:i.validateSpec,style:a,styleSpec:l,key:`${d}[${b}]`}));return y}function Sa(i){const e=i.key,r=i.value,a=i.valueSpec;let l=xt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new Ae(e,r,`number expected, ${l} 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 ds(i){const e=i.valueSpec,r=Zt(i.value.type);let a,l,d,f={};const m=r!=="categorical"&&i.value.property===void 0,y=!m,b=xt(i.value.stops)==="array"&&xt(i.value.stops[0])==="array"&&xt(i.value.stops[0][0])==="object",S=Bi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(L){if(r==="identity")return[new Ae(L.key,L.value,'identity function may not have a "stops" property')];let R=[];const V=L.value;return R=R.concat(Qn({key:L.key,value:V,valueSpec:L.valueSpec,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,arrayElementValidator:C})),xt(V)==="array"&&V.length===0&&R.push(new Ae(L.key,V,"array must have at least one stop")),R},default:function(L){return L.validateSpec({key:L.key,value:L.value,valueSpec:e,validateSpec:L.validateSpec,style:L.style,styleSpec:L.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&&!Qs(i.valueSpec)&&S.push(new Ae(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(y&&!Jn(i.valueSpec)?S.push(new Ae(i.key,i.value,"property functions not supported")):m&&!dl(i.valueSpec)&&S.push(new Ae(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!b||i.value.property!==void 0||S.push(new Ae(i.key,i.value,'"property" property is required')),S;function C(L){let R=[];const V=L.value,G=L.key;if(xt(V)!=="array")return[new Ae(G,V,`array expected, ${xt(V)} found`)];if(V.length!==2)return[new Ae(G,V,`array length 2 expected, length ${V.length} found`)];if(b){if(xt(V[0])!=="object")return[new Ae(G,V,`object expected, ${xt(V[0])} found`)];if(V[0].zoom===void 0)return[new Ae(G,V,"object stop key must have zoom")];if(V[0].value===void 0)return[new Ae(G,V,"object stop key must have value")];if(d&&d>Zt(V[0].zoom))return[new Ae(G,V[0].zoom,"stop zoom values must appear in ascending order")];Zt(V[0].zoom)!==d&&(d=Zt(V[0].zoom),l=void 0,f={}),R=R.concat(Bi({key:`${G}[0]`,value:V[0],valueSpec:{zoom:{}},validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,objectElementValidators:{zoom:Sa,value:M}}))}else R=R.concat(M({key:`${G}[0]`,value:V[0],validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec},V));return os(In(V[1]))?R.concat([new Ae(`${G}[1]`,V[1],"expressions are not allowed in function stops.")]):R.concat(L.validateSpec({key:`${G}[1]`,value:V[1],valueSpec:e,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec}))}function M(L,R){const V=xt(L.value),G=Zt(L.value),K=L.value!==null?L.value:R;if(a){if(V!==a)return[new Ae(L.key,K,`${V} stop domain type must match previous stop domain type ${a}`)]}else a=V;if(V!=="number"&&V!=="string"&&V!=="boolean")return[new Ae(L.key,K,"stop domain value must be a number, string, or boolean")];if(V!=="number"&&r!=="categorical"){let ne=`number expected, ${V} found`;return Jn(e)&&r===void 0&&(ne+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ae(L.key,K,ne)]}return r!=="categorical"||V!=="number"||isFinite(G)&&Math.floor(G)===G?r!=="categorical"&&V==="number"&&l!==void 0&&G<l?[new Ae(L.key,K,"stop domain values must appear in ascending order")]:(l=G,r==="categorical"&&G in f?[new Ae(L.key,K,"stop domain values must be unique")]:(f[G]=!0,[])):[new Ae(L.key,K,`integer expected, found ${G}`)]}}function An(i){const e=(i.expressionContext==="property"?io:ls)(In(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"&&!_a(r))return[new Ae(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!_a(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(!es(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"&&!Qa(r))return[new Ae(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ta(i){const e=i.key,r=i.value,a=i.valueSpec,l=[];return Array.isArray(a.values)?a.values.indexOf(Zt(r))===-1&&l.push(new Ae(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(Zt(r))===-1&&l.push(new Ae(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function ea(i){return ba(In(i.value))?An(Ar({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):xl(i)}function xl(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 l,d=[];if(e.length<1)return[new Ae(r,e,"filter array must have at least 1 element")];switch(d=d.concat(Ta({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),Zt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Zt(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&&(l=xt(e[1]),l!=="string"&&d.push(new Ae(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let f=2;f<e.length;f++)l=xt(e[f]),Zt(e[1])==="$type"?d=d.concat(Ta({key:`${r}[${f}]`,value:e[f],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&d.push(new Ae(`${r}[${f}]`,e[f],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let f=1;f<e.length;f++)d=d.concat(xl({key:`${r}[${f}]`,value:e[f],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":l=xt(e[1]),e.length!==2?d.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):l!=="string"&&d.push(new Ae(`${r}[1]`,e[1],`string expected, ${l} found`));break;case"within":l=xt(e[1]),e.length!==2?d.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):l!=="object"&&d.push(new Ae(`${r}[1]`,e[1],`object expected, ${l} found`))}return d}function vl(i,e){const r=i.key,a=i.validateSpec,l=i.style,d=i.styleSpec,f=i.value,m=i.objectKey,y=d[`${e}_${i.layerType}`];if(!y)return[];const b=m.match(/^(.*)-transition$/);if(e==="paint"&&b&&y[b[1]]&&y[b[1]].transition)return a({key:r,value:f,valueSpec:d.transition,style:l,styleSpec:d});const S=i.valueSpec||y[m];if(!S)return[new Ae(r,f,`unknown property "${m}"`)];let C;if(xt(f)==="string"&&Jn(S)&&!S.tokens&&(C=/^{([^}]+)}$/.exec(f)))return[new Ae(r,f,`"${m}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(C[1])} }\`.`)];const M=[];return i.layerType==="symbol"&&(m==="text-field"&&l&&!l.glyphs&&M.push(new Ae(r,f,'use of "text-field" requires a style "glyphs" property')),m==="text-font"&&Nt(In(f))&&Zt(f.type)==="identity"&&M.push(new Ae(r,f,'"text-font" does not support identity functions'))),M.concat(a({key:i.key,value:f,valueSpec:S,style:l,styleSpec:d,expressionContext:"property",propertyType:e,propertyKey:m}))}function bl(i){return vl(i,"paint")}function wl(i){return vl(i,"layout")}function Sl(i){let e=[];const r=i.value,a=i.key,l=i.style,d=i.styleSpec;r.type||r.ref||e.push(new Ae(a,r,'either "type" or "ref" is required'));let f=Zt(r.type);const m=Zt(r.ref);if(r.id){const y=Zt(r.id);for(let b=0;b<i.arrayIndex;b++){const S=l.layers[b];Zt(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((b=>{b in r&&e.push(new Ae(a,r[b],`"${b}" is prohibited for ref layers`))})),l.layers.forEach((b=>{Zt(b.id)===m&&(y=b)})),y?y.ref?e.push(new Ae(a,r.ref,"ref cannot reference another ref layer")):f=Zt(y.type):e.push(new Ae(a,r.ref,`ref layer "${m}" not found`))}else if(f!=="background")if(r.source){const y=l.sources&&l.sources[r.source],b=y&&Zt(y.type);y?b==="vector"&&f==="raster"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a raster source`)):b!=="raster-dem"&&f==="hillshade"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a raster-dem source`)):b==="raster"&&f!=="raster"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a vector source`)):b!=="vector"||r["source-layer"]?b==="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"]||b==="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(Bi({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:ea,layout:y=>Bi({layer:r,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":b=>wl(Ar({layerType:f},b))}}),paint:y=>Bi({layer:r,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":b=>bl(Ar({layerType:f},b))}})}})),e}function kr(i){const e=i.value,r=i.key,a=xt(e);return a!=="string"?[new Ae(r,e,`string expected, ${a} found`)]:[]}const Ia={promoteId:function({key:i,value:e}){if(xt(e)==="string")return kr({key:i,value:e});{const r=[];for(const a in e)r.push(...kr({key:`${i}.${a}`,value:e[a]}));return r}}};function Ki(i){const e=i.value,r=i.key,a=i.styleSpec,l=i.style,d=i.validateSpec;if(!e.type)return[new Ae(r,e,'"type" is required')];const f=Zt(e.type);let m;switch(f){case"vector":case"raster":return m=Bi({key:r,value:e,valueSpec:a[`source_${f.replace("-","_")}`],style:i.style,styleSpec:a,objectElementValidators:Ia,validateSpec:d}),m;case"raster-dem":return m=(function(y){var b;const S=(b=y.sourceName)!==null&&b!==void 0?b:"",C=y.value,M=y.styleSpec,L=M.source_raster_dem,R=y.style;let V=[];const G=xt(C);if(C===void 0)return V;if(G!=="object")return V.push(new Ae("source_raster_dem",C,`object expected, ${G} found`)),V;const K=Zt(C.encoding)==="custom",ne=["redFactor","greenFactor","blueFactor","baseShift"],J=y.value.encoding?`"${y.value.encoding}"`:"Default";for(const se in C)!K&&ne.includes(se)?V.push(new Ae(se,C[se],`In "${S}": "${se}" is only valid when "encoding" is set to "custom". ${J} encoding found`)):L[se]?V=V.concat(y.validateSpec({key:se,value:C[se],valueSpec:L[se],validateSpec:y.validateSpec,style:R,styleSpec:M})):V.push(new Ae(se,C[se],`unknown property "${se}"`));return V})({sourceName:r,value:e,style:i.style,styleSpec:a,validateSpec:d}),m;case"geojson":if(m=Bi({key:r,value:e,valueSpec:a.source_geojson,style:l,styleSpec:a,validateSpec:d,objectElementValidators:Ia}),e.cluster)for(const y in e.clusterProperties){const[b,S]=e.clusterProperties[y],C=typeof b=="string"?[b,["accumulated"],["get",y]]:b;m.push(...An({key:`${r}.${y}.map`,value:S,expressionContext:"cluster-map"})),m.push(...An({key:`${r}.${y}.reduce`,value:C,expressionContext:"cluster-reduce"}))}return m;case"video":return Bi({key:r,value:e,valueSpec:a.source_video,style:l,validateSpec:d,styleSpec:a});case"image":return Bi({key:r,value:e,valueSpec:a.source_image,style:l,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 Ta({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Aa(i){const e=i.value,r=i.styleSpec,a=r.light,l=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:l,styleSpec:r}):a[m]?i.validateSpec({key:m,value:e[m],valueSpec:a[m],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new Ae(m,e[m],`unknown property "${m}"`)])}return d}function Tl(i){const e=i.value,r=i.styleSpec,a=r.terrain,l=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:l,styleSpec:r}):[new Ae(m,e[m],`unknown property "${m}"`)]);return d}function Il(i){let e=[];const r=i.value,a=i.key;if(Array.isArray(r)){const l=[],d=[];for(const f in r)r[f].id&&l.includes(r[f].id)&&e.push(new Ae(a,r,`all the sprites' ids must be unique, but ${r[f].id} is duplicated`)),l.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(Bi({key:`${a}[${f}]`,value:r[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return kr({key:a,value:r})}const Al={"*":()=>[],array:Qn,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:Sa,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:yl,enum:Ta,filter:ea,function:ds,layer:Sl,object:Bi,source:Ki,light:Aa,terrain:Tl,string:kr,formatted:function(i){return kr(i).length===0?[]:An(i)},resolvedImage:function(i){return kr(i).length===0?[]:An(i)},padding:function(i){const e=i.key,r=i.value;if(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 l=[];for(let d=0;d<r.length;d++)l=l.concat(i.validateSpec({key:`${e}[${d}]`,value:r[d],validateSpec:i.validateSpec,valueSpec:a}));return l}return Sa({key:e,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,a=xt(r),l=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(Ta({key:`${e}[${f}]`,value:r[f],valueSpec:l.layout_symbol["text-anchor"]})),d=d.concat(Qn({key:`${e}[${f+1}]`,value:r[f+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:l}));return d},sprite:Il};function ln(i){const e=i.value,r=i.valueSpec,a=i.styleSpec;return i.validateSpec=ln,r.expression&&Nt(Zt(e))?ds(i):r.expression&&os(In(e))?An(i):r.type&&Al[r.type]?Al[r.type](i):Bi(Ar({},i,{valueSpec:r.type?a[r.type]:r}))}function Cl(i){const e=i.value,r=i.key,a=kr(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 pr(i,e=he){let r=[];return r=r.concat(ln({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:ln,objectElementValidators:{glyphs:Cl,"*":()=>[]}})),i.constants&&(r=r.concat(yl({key:"constants",value:i.constants}))),fs(r)}function Vr(i){return function(e){return i({...e,validateSpec:ln})}}function fs(i){return[].concat(i).sort(((e,r)=>e.line-r.line))}function Ur(i){return function(...e){return fs(i.apply(this,e))}}pr.source=Ur(Vr(Ki)),pr.sprite=Ur(Vr(Il)),pr.glyphs=Ur(Vr(Cl)),pr.light=Ur(Vr(Aa)),pr.terrain=Ur(Vr(Tl)),pr.layer=Ur(Vr(Sl)),pr.filter=Ur(Vr(ea)),pr.paintProperty=Ur(Vr(bl)),pr.layoutProperty=Ur(Vr(wl));const $r=pr,Oc=$r.light,ao=$r.paintProperty,kl=$r.layoutProperty;function ms(i,e){let r=!1;if(e&&e.length)for(const a of e)i.fire(new tn(new Error(a.message))),r=!0;return r}class ta{constructor(e,r,a){const l=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 b=f[3+y],S=f[3+y+1];l.push(b===S?null:f.subarray(b,S))}const m=f[3+l.length+1];this.keys=f.subarray(f[3+l.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++)l.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,l,d){this._forEachCell(r,a,l,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,a,l,d,f){this.cells[d].push(f)}query(e,r,a,l,d){const f=this.min,m=this.max;if(e<=f&&r<=f&&m<=a&&m<=l&&!d)return Array.prototype.slice.call(this.keys);{const y=[];return this._forEachCell(e,r,a,l,this._queryCell,y,{},d),y}}_queryCell(e,r,a,l,d,f,m,y){const b=this.cells[d];if(b!==null){const S=this.keys,C=this.bboxes;for(let M=0;M<b.length;M++){const L=b[M];if(m[L]===void 0){const R=4*L;(y?y(C[R+0],C[R+1],C[R+2],C[R+3]):e<=C[R+2]&&r<=C[R+3]&&a>=C[R+0]&&l>=C[R+1])?(m[L]=!0,f.push(S[L])):m[L]=!1}}}}_forEachCell(e,r,a,l,d,f,m,y){const b=this._convertToCellCoord(e),S=this._convertToCellCoord(r),C=this._convertToCellCoord(a),M=this._convertToCellCoord(l);for(let L=b;L<=C;L++)for(let R=S;R<=M;R++){const V=this.d*R+L;if((!y||y(this._convertFromCellCoord(L),this._convertFromCellCoord(R),this._convertFromCellCoord(L+1),this._convertFromCellCoord(R+1)))&&d.call(this,e,r,a,l,V,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 l=new Int32Array(r+a+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let d=r;for(let f=0;f<e.length;f++){const m=e[f];l[3+f]=d,l.set(m,d),d+=m.length}return l[3+e.length]=d,l.set(this.keys,d),d+=this.keys.length,l[3+e.length+1]=d,l.set(this.bboxes,d),d+=this.bboxes.length,l.buffer}static serialize(e,r){const a=e.toArrayBuffer();return r&&r.push(a),{buffer:a}}static deserialize(e){return new ta(e.buffer)}}const jr={};function Re(i,e,r={}){if(jr[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),jr[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Re("Object",Object),Re("TransferableGridIndex",ta),Re("Color",wt),Re("Error",Error),Re("AJAXError",Jr),Re("ResolvedImage",fi),Re("StylePropertyFunction",xa),Re("StyleExpression",eo,{omit:["_evaluator"]}),Re("ZoomDependentExpression",cs),Re("ZoomConstantExpression",to),Re("CompoundExpression",hr,{omit:["_evaluate"]});for(const i in Yn)Yn[i]._classRegistryKey||Re(`Expression_${i}`,Yn[i]);function gs(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function cn(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(gs(i)||Sr(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(cn(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(!jr[a])throw new Error(`${a} is not registered.`);const l=r.serialize?r.serialize(i,e):{};if(r.serialize){if(e&&l===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)||jr[a].omit.indexOf(d)>=0)continue;const f=i[d];l[d]=jr[a].shallow.indexOf(d)>=0?f:cn(f,e)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return a!=="Object"&&(l.$name=a),l}throw new Error("can't serialize object of type "+typeof i)}function ia(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||gs(i)||Sr(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(ia);if(typeof i=="object"){const e=i.$name||"Object";if(!jr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=jr[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 l of Object.keys(i)){if(l==="$name")continue;const d=i[l];a[l]=jr[e].shallow.indexOf(l)>=0?d:ia(d)}return a}throw new Error("can't deserialize object of type "+typeof i)}class El{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 so(i){for(const e of i)if(lo(e.charCodeAt(0)))return!0;return!1}function oo(i){for(const e of i)if(!Nc(e.charCodeAt(0)))return!1;return!0}function Nc(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 lo(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 Ml(i){return!(lo(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 Pl(i){return i>=1424&&i<=2303||ze["Arabic Presentation Forms-A"](i)||ze["Arabic Presentation Forms-B"](i)}function zl(i,e){return!(!e&&Pl(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||ze.Khmer(i))}function Vc(i){for(const e of i)if(Pl(e.charCodeAt(0)))return!0;return!1}const co="deferred",uo="loading",ho="loaded";let po=null,Oi="unavailable",un=null;const Ca=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(Oi="error"),po&&po(i)};function fo(){ka.fire(new en("pluginStateChange",{pluginStatus:Oi,pluginURL:un}))}const ka=new yn,mo=function(){return Oi},Dl=function(){if(Oi!==co||!un)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Oi=uo,fo(),un&&ma({url:un},(i=>{i?Ca(i):(Oi=ho,fo())}))},Yi={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Oi===ho||Yi.applyArabicShaping!=null,isLoading:()=>Oi===uo,setState(i){if(!$t())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Oi=i.pluginStatus,un=i.pluginURL},isParsed(){if(!$t())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Yi.applyArabicShaping!=null&&Yi.processBidirectionalText!=null&&Yi.processStyledBidirectionalText!=null},getPluginURL(){if(!$t())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return un}};class zt{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 El,this.transition={})}isSupportedScript(e){return(function(r,a){for(const l of r)if(!zl(l.charCodeAt(0),a))return!1;return!0})(e,Yi.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 _s{constructor(e,r){this.property=e,this.value=r,this.expression=(function(a,l){if(Nt(a))return new xa(a,l);if(os(a)){const d=io(a,l);if(d.result==="error")throw new Error(d.value.map((f=>`${f.key}: ${f.message}`)).join(", "));return d.value}{let d=a;return l.type==="color"&&typeof a=="string"?d=wt.parse(a):l.type!=="padding"||typeof a!="number"&&!Array.isArray(a)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(a)&&(d=cr.parse(a)):d=Hi.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 go{constructor(e){this.property=e,this.value=new _s(e,void 0)}transitioned(e,r){return new Rl(this.property,this.value,r,ii({},e.transition,this.transition),e.now)}untransitioned(){return new Rl(this.property,this.value,null,{},0)}}class Ll{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Gi(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new go(this._values[e].property)),this._values[e].value=new _s(this._values[e].property,r===null?void 0:Gi(r))}getTransition(e){return Gi(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new go(this._values[e].property)),this._values[e].transition=Gi(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 l=this.getTransition(r);l!==void 0&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const a=new Fl(this._properties);for(const l of Object.keys(this._values))a._values[l]=this._values[l].transitioned(e,r._values[l]);return a}untransitioned(){const e=new Fl(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Rl{constructor(e,r,a,l,d){this.property=e,this.value=r,this.begin=d+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const l=e.now||0,d=this.value.possiblyEvaluate(e,r,a),f=this.prior;if(f){if(l>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(l<this.begin)return f.possiblyEvaluate(e,r,a);{const m=(l-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 b=y*y,S=b*y;return 4*(y<.5?S:3*(y-b)+S-.75)})(m))}}return d}}class Fl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,a){const l=new ys(this._properties);for(const d of Object.keys(this._values))l._values[d]=this._values[d].possiblyEvaluate(e,r,a);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Uc{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Gi(this._values[e].value)}setValue(e,r){this._values[e]=new _s(this._values[e].property,r===null?void 0:Gi(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 l=new ys(this._properties);for(const d of Object.keys(this._values))l._values[d]=this._values[d].possiblyEvaluate(e,r,a);return l}}class Ai{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,l){return this.property.evaluate(this.value,this.parameters,e,r,a,l)}}class ys{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Ge{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 l=Wi[this.specification.type];return l?l(e,r,a):e}}class Ye{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,a,l){return new Ai(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},a,l)}: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 Ai(this,{kind:"constant",value:void 0},e.parameters);const l=Wi[this.specification.type];if(l){const d=l(e.value.value,r.value.value,a);return new Ai(this,{kind:"constant",value:d},e.parameters)}return e}evaluate(e,r,a,l,d,f){return e.kind==="constant"?e.value:e.evaluate(r,a,l,d,f)}}class Ea extends Ye{possiblyEvaluate(e,r,a,l){if(e.value===void 0)return new Ai(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const d=e.expression.evaluate(r,null,{},a,l),f=e.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,m=this._calculate(f,f,f,r);return new Ai(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 Ai(this,{kind:"constant",value:d},r)}return new Ai(this,e.expression,r)}evaluate(e,r,a,l,d,f){if(e.kind==="source"){const m=e.evaluate(r,a,l,d,f);return this._calculate(m,m,m,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},a,l),e.evaluate({zoom:Math.floor(r.zoom)},a,l),e.evaluate({zoom:Math.floor(r.zoom)+1},a,l),r):e.value}_calculate(e,r,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class _o{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){if(e.value!==void 0){if(e.expression.kind==="constant"){const d=e.expression.evaluate(r,null,{},a,l);return this._calculate(d,d,d,r)}return this._calculate(e.expression.evaluate(new zt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new zt(Math.floor(r.zoom),r)),e.expression.evaluate(new zt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class yo{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,l){return!!e.expression.evaluate(r,null,{},a,l)}interpolate(){return!1}}class Kt{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 l=this.defaultPropertyValues[r]=new _s(a,void 0),d=this.defaultTransitionablePropertyValues[r]=new go(a);this.defaultTransitioningPropertyValues[r]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}Re("DataDrivenProperty",Ye),Re("DataConstantProperty",Ge),Re("CrossFadedDataDrivenProperty",Ea),Re("CrossFadedProperty",_o),Re("ColorRampProperty",yo);const xo="-transition";class dr extends yn{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 Uc(r.layout)),r.paint)){this._transitionablePaint=new Ll(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 ys(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(kl,`layers.${this.id}.layout.${e}`,e,r,a)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(xo)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(r!=null&&this._validate(ao,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(xo))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[e],d=l.property.specification["property-type"]==="cross-faded-data-driven",f=l.value.isDataDriven(),m=l.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),Yr(e,((r,a)=>!(r===void 0||a==="layout"&&!Object.keys(r).length||a==="paint"&&!Object.keys(r).length)))}_validate(e,r,a,l,d={}){return(!d||d.validate!==!1)&&ms(this,e.call($r,{key:r,layerType:this.type,objectKey:a,value:l,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 Ai&&Jn(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const Bl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Cn{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 Gt{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 Ut(i,e=1){let r=0,a=0;return{members:i.map((l=>{const d=Bl[l.type].BYTES_PER_ELEMENT,f=r=ra(r,Math.max(e,d)),m=l.components||1;return a=Math.max(a,d),r+=d*m,{name:l.name,type:l.type,components:m,offset:f}})),size:ra(r,Math.max(a,e)),alignment:e}}function ra(i,e){return Math.ceil(i/e)*e}class Ma extends Gt{_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 l=2*e;return this.int16[l+0]=r,this.int16[l+1]=a,e}}Ma.prototype.bytesPerElement=4,Re("StructArrayLayout2i4",Ma);class Pa extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const d=3*e;return this.int16[d+0]=r,this.int16[d+1]=a,this.int16[d+2]=l,e}}Pa.prototype.bytesPerElement=6,Re("StructArrayLayout3i6",Pa);class kn extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,l)}emplace(e,r,a,l,d){const f=4*e;return this.int16[f+0]=r,this.int16[f+1]=a,this.int16[f+2]=l,this.int16[f+3]=d,e}}kn.prototype.bytesPerElement=8,Re("StructArrayLayout4i8",kn);class vo extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,l,d,f)}emplace(e,r,a,l,d,f,m){const y=6*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.int16[y+2]=l,this.int16[y+3]=d,this.int16[y+4]=f,this.int16[y+5]=m,e}}vo.prototype.bytesPerElement=12,Re("StructArrayLayout2i4i12",vo);class bo extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,l,d,f)}emplace(e,r,a,l,d,f,m){const y=4*e,b=8*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.uint8[b+4]=l,this.uint8[b+5]=d,this.uint8[b+6]=f,this.uint8[b+7]=m,e}}bo.prototype.bytesPerElement=8,Re("StructArrayLayout2i4ub8",bo);class na extends Gt{_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 l=2*e;return this.float32[l+0]=r,this.float32[l+1]=a,e}}na.prototype.bytesPerElement=8,Re("StructArrayLayout2f8",na);class wo extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d,f,m,y,b,S){const C=this.length;return this.resize(C+1),this.emplace(C,e,r,a,l,d,f,m,y,b,S)}emplace(e,r,a,l,d,f,m,y,b,S,C){const M=10*e;return this.uint16[M+0]=r,this.uint16[M+1]=a,this.uint16[M+2]=l,this.uint16[M+3]=d,this.uint16[M+4]=f,this.uint16[M+5]=m,this.uint16[M+6]=y,this.uint16[M+7]=b,this.uint16[M+8]=S,this.uint16[M+9]=C,e}}wo.prototype.bytesPerElement=20,Re("StructArrayLayout10ui20",wo);class So extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d,f,m,y,b,S,C,M){const L=this.length;return this.resize(L+1),this.emplace(L,e,r,a,l,d,f,m,y,b,S,C,M)}emplace(e,r,a,l,d,f,m,y,b,S,C,M,L){const R=12*e;return this.int16[R+0]=r,this.int16[R+1]=a,this.int16[R+2]=l,this.int16[R+3]=d,this.uint16[R+4]=f,this.uint16[R+5]=m,this.uint16[R+6]=y,this.uint16[R+7]=b,this.int16[R+8]=S,this.int16[R+9]=C,this.int16[R+10]=M,this.int16[R+11]=L,e}}So.prototype.bytesPerElement=24,Re("StructArrayLayout4i4ui4i24",So);class vt extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const d=3*e;return this.float32[d+0]=r,this.float32[d+1]=a,this.float32[d+2]=l,e}}vt.prototype.bytesPerElement=12,Re("StructArrayLayout3f12",vt);class h extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}h.prototype.bytesPerElement=4,Re("StructArrayLayout1ul4",h);class t extends Gt{_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,l,d,f,m,y,b){const S=this.length;return this.resize(S+1),this.emplace(S,e,r,a,l,d,f,m,y,b)}emplace(e,r,a,l,d,f,m,y,b,S){const C=10*e,M=5*e;return this.int16[C+0]=r,this.int16[C+1]=a,this.int16[C+2]=l,this.int16[C+3]=d,this.int16[C+4]=f,this.int16[C+5]=m,this.uint32[M+3]=y,this.uint16[C+8]=b,this.uint16[C+9]=S,e}}t.prototype.bytesPerElement=20,Re("StructArrayLayout6i1ul2ui20",t);class n extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,l,d,f)}emplace(e,r,a,l,d,f,m){const y=6*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.int16[y+2]=l,this.int16[y+3]=d,this.int16[y+4]=f,this.int16[y+5]=m,e}}n.prototype.bytesPerElement=12,Re("StructArrayLayout2i2i2i12",n);class s extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,l,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,l,d)}emplace(e,r,a,l,d,f){const m=4*e,y=8*e;return this.float32[m+0]=r,this.float32[m+1]=a,this.float32[m+2]=l,this.int16[y+6]=d,this.int16[y+7]=f,e}}s.prototype.bytesPerElement=16,Re("StructArrayLayout2f1f2i16",s);class u extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,l)}emplace(e,r,a,l,d){const f=12*e,m=3*e;return this.uint8[f+0]=r,this.uint8[f+1]=a,this.float32[m+1]=l,this.float32[m+2]=d,e}}u.prototype.bytesPerElement=12,Re("StructArrayLayout2ub2f12",u);class p extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const d=3*e;return this.uint16[d+0]=r,this.uint16[d+1]=a,this.uint16[d+2]=l,e}}p.prototype.bytesPerElement=6,Re("StructArrayLayout3ui6",p);class g extends Gt{_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,l,d,f,m,y,b,S,C,M,L,R,V,G,K){const ne=this.length;return this.resize(ne+1),this.emplace(ne,e,r,a,l,d,f,m,y,b,S,C,M,L,R,V,G,K)}emplace(e,r,a,l,d,f,m,y,b,S,C,M,L,R,V,G,K,ne){const J=24*e,se=12*e,le=48*e;return this.int16[J+0]=r,this.int16[J+1]=a,this.uint16[J+2]=l,this.uint16[J+3]=d,this.uint32[se+2]=f,this.uint32[se+3]=m,this.uint32[se+4]=y,this.uint16[J+10]=b,this.uint16[J+11]=S,this.uint16[J+12]=C,this.float32[se+7]=M,this.float32[se+8]=L,this.uint8[le+36]=R,this.uint8[le+37]=V,this.uint8[le+38]=G,this.uint32[se+10]=K,this.int16[J+22]=ne,e}}g.prototype.bytesPerElement=48,Re("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",g);class _ extends Gt{_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,l,d,f,m,y,b,S,C,M,L,R,V,G,K,ne,J,se,le,_e,De,Ve,Pe,Me,Ie,Fe){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,e,r,a,l,d,f,m,y,b,S,C,M,L,R,V,G,K,ne,J,se,le,_e,De,Ve,Pe,Me,Ie,Fe)}emplace(e,r,a,l,d,f,m,y,b,S,C,M,L,R,V,G,K,ne,J,se,le,_e,De,Ve,Pe,Me,Ie,Fe,Ce){const we=32*e,Xe=16*e;return this.int16[we+0]=r,this.int16[we+1]=a,this.int16[we+2]=l,this.int16[we+3]=d,this.int16[we+4]=f,this.int16[we+5]=m,this.int16[we+6]=y,this.int16[we+7]=b,this.uint16[we+8]=S,this.uint16[we+9]=C,this.uint16[we+10]=M,this.uint16[we+11]=L,this.uint16[we+12]=R,this.uint16[we+13]=V,this.uint16[we+14]=G,this.uint16[we+15]=K,this.uint16[we+16]=ne,this.uint16[we+17]=J,this.uint16[we+18]=se,this.uint16[we+19]=le,this.uint16[we+20]=_e,this.uint16[we+21]=De,this.uint16[we+22]=Ve,this.uint32[Xe+12]=Pe,this.float32[Xe+13]=Me,this.float32[Xe+14]=Ie,this.uint16[we+30]=Fe,this.uint16[we+31]=Ce,e}}_.prototype.bytesPerElement=64,Re("StructArrayLayout8i15ui1ul2f2ui64",_);class v extends Gt{_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}}v.prototype.bytesPerElement=4,Re("StructArrayLayout1f4",v);class w extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const d=3*e;return this.uint16[6*e+0]=r,this.float32[d+1]=a,this.float32[d+2]=l,e}}w.prototype.bytesPerElement=12,Re("StructArrayLayout1ui2f12",w);class I extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,a)}emplace(e,r,a,l){const d=4*e;return this.uint32[2*e+0]=r,this.uint16[d+2]=a,this.uint16[d+3]=l,e}}I.prototype.bytesPerElement=8,Re("StructArrayLayout1ul2ui8",I);class A extends Gt{_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 l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=a,e}}A.prototype.bytesPerElement=4,Re("StructArrayLayout2ui4",A);class D extends Gt{_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}}D.prototype.bytesPerElement=2,Re("StructArrayLayout1ui2",D);class $ extends Gt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,l){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,l)}emplace(e,r,a,l,d){const f=4*e;return this.float32[f+0]=r,this.float32[f+1]=a,this.float32[f+2]=l,this.float32[f+3]=d,e}}$.prototype.bytesPerElement=16,Re("StructArrayLayout4f16",$);class U extends Cn{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)}}U.prototype.size=20;class q extends t{get(e){return new U(this,e)}}Re("CollisionBoxArray",q);class N extends Cn{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]}}N.prototype.size=48;class ee extends g{get(e){return new N(this,e)}}Re("PlacedSymbolArray",ee);class oe extends Cn{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]}}oe.prototype.size=64;class X extends _{get(e){return new oe(this,e)}}Re("SymbolInstanceArray",X);class ie extends v{getoffsetX(e){return this.float32[1*e+0]}}Re("GlyphOffsetArray",ie);class ce extends Pa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Re("SymbolLineVertexArray",ce);class ue extends Cn{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 w{get(e){return new ue(this,e)}}Re("TextAnchorOffsetArray",me);class be extends Cn{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 I{get(e){return new be(this,e)}}Re("FeatureIndexArray",xe);class Se extends Ma{}class Ne extends Ma{}class ct extends Ma{}class Ee extends vo{}class Je extends bo{}class $e extends na{}class St extends wo{}class lt extends So{}class at extends vt{}class ut extends h{}class Ht extends n{}class kt extends u{}class mi extends p{}class ri extends A{}const Yt=Ut([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ji}=Yt;class Dt{constructor(e=[]){this.segments=e}prepareSegment(e,r,a,l){let d=this.segments[this.segments.length-1];return e>Dt.MAX_VERTEX_ARRAY_LENGTH&&Le(`Max vertices per segment is ${Dt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!d||d.vertexLength+e>Dt.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==l)&&(d={vertexOffset:r.length,primitiveOffset:a.length,vertexLength:0,primitiveLength:0},l!==void 0&&(d.sortKey=l),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,l){return new Dt([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function Er(i,e){return 256*(i=ar(Math.floor(i),0,255))+ar(Math.floor(e),0,255)}Dt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Re("SegmentVector",Dt);const Mr=Ut([{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 hn={exports:{}},En={exports:{}};En.exports=function(i,e){var r,a,l,d,f,m,y,b;for(a=i.length-(r=3&i.length),l=e,f=3432918353,m=461845907,b=0;b<a;)y=255&i.charCodeAt(b)|(255&i.charCodeAt(++b))<<8|(255&i.charCodeAt(++b))<<16|(255&i.charCodeAt(++b))<<24,++b,l=27492+(65535&(d=5*(65535&(l=(l^=y=(65535&(y=(y=(65535&y)*f+(((y>>>16)*f&65535)<<16)&4294967295)<<15|y>>>17))*m+(((y>>>16)*m&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(d>>>16)&65535)<<16);switch(y=0,r){case 3:y^=(255&i.charCodeAt(b+2))<<16;case 2:y^=(255&i.charCodeAt(b+1))<<8;case 1:l^=y=(65535&(y=(y=(65535&(y^=255&i.charCodeAt(b)))*f+(((y>>>16)*f&65535)<<16)&4294967295)<<15|y>>>17))*m+(((y>>>16)*m&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var aa=En.exports,vi={exports:{}};vi.exports=function(i,e){for(var r,a=i.length,l=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),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),a-=4,++d;switch(a){case 3:l^=(255&i.charCodeAt(d+2))<<16;case 2:l^=(255&i.charCodeAt(d+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(d)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var gi=aa,Ci=vi.exports;hn.exports=gi,hn.exports.murmur3=gi,hn.exports.murmur2=Ci;var Mn=H(hn.exports);class Wt{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,l){this.ids.push(ni(e)),this.positions.push(r,a,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=ni(e);let a=0,l=this.ids.length-1;for(;a<l;){const f=a+l>>1;this.ids[f]>=r?l=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),l=new Uint32Array(e.positions);return Ni(a,l,0,a.length-1),r&&r.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const r=new Wt;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function ni(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Mn(String(i))}function Ni(i,e,r,a){for(;r<a;){const l=i[r+a>>1];let d=r-1,f=a+1;for(;;){do d++;while(i[d]<l);do f--;while(i[f]>l);if(d>=f)break;Xt(i,d,f),Xt(e,3*d,3*f),Xt(e,3*d+1,3*f+1),Xt(e,3*d+2,3*f+2)}f-r<a-f?(Ni(i,e,r,f),r=f+1):(Ni(i,e,f+1,a),a=f)}}function Xt(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}Re("FeaturePositionMap",Wt);class Pn{constructor(e,r){this.gl=e.gl,this.location=r}}class xs extends Pn{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Ol extends Pn{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 Nl extends Pn{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 $c=new Float32Array(16);function To(i){return[Er(255*i.r,255*i.g),Er(255*i.b,255*i.a)]}class Pr{constructor(e,r,a){this.value=e,this.uniformNames=r.map((l=>`u_${l}`)),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return this.type==="color"?new Nl(e,r):new xs(e,r)}}class zn{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,l){const d=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;d&&e.set(d)}getBinding(e,r,a){return a.substr(0,9)==="u_pattern"?new Ol(e,r):new xs(e,r)}}class zr{constructor(e,r,a,l){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 l}populatePaintArray(e,r,a,l,d){const f=this.paintVertexArray.length,m=this.expression.evaluate(new zt(0),r,{},l,[],d);this.paintVertexArray.resize(e),this._setPaintValue(f,e,m)}updatePaintArray(e,r,a,l){const d=this.expression.evaluate({zoom:0},a,l);this._setPaintValue(e,r,d)}_setPaintValue(e,r,a){if(this.type==="color"){const l=To(a);for(let d=e;d<r;d++)this.paintVertexArray.emplace(d,l[0],l[1])}else{for(let l=e;l<r;l++)this.paintVertexArray.emplace(l,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 fr{constructor(e,r,a,l,d,f){this.expression=e,this.uniformNames=r.map((m=>`u_${m}_t`)),this.type=a,this.useIntegerZoom=l,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,l,d){const f=this.expression.evaluate(new zt(this.zoom),r,{},l,[],d),m=this.expression.evaluate(new zt(this.zoom+1),r,{},l,[],d),y=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(y,e,f,m)}updatePaintArray(e,r,a,l){const d=this.expression.evaluate({zoom:this.zoom},a,l),f=this.expression.evaluate({zoom:this.zoom+1},a,l);this._setPaintValue(e,r,d,f)}_setPaintValue(e,r,a,l){if(this.type==="color"){const d=To(a),f=To(l);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,l);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(l))}}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,l=ar(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(l)}getBinding(e,r,a){return new xs(e,r)}}class Dr{constructor(e,r,a,l,d,f){this.expression=e,this.type=r,this.useIntegerZoom=a,this.zoom=l,this.layerId=f,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(e,r,a){const l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(l,e,r.patterns&&r.patterns[this.layerId],a)}updatePaintArray(e,r,a,l,d){this._setPaintValues(e,r,a.patterns&&a.patterns[this.layerId],d)}_setPaintValues(e,r,a,l){if(!l||!a)return;const{min:d,mid:f,max:m}=a,y=l[d],b=l[f],S=l[m];if(y&&b&&S)for(let C=e;C<r;C++)this.zoomInPaintVertexArray.emplace(C,b.tl[0],b.tl[1],b.br[0],b.br[1],y.tl[0],y.tl[1],y.br[0],y.br[1],b.pixelRatio,y.pixelRatio),this.zoomOutPaintVertexArray.emplace(C,b.tl[0],b.tl[1],b.br[0],b.br[1],S.tl[0],S.tl[1],S.br[0],S.br[1],b.pixelRatio,S.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,Mr.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,Mr.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Io{constructor(e,r,a){this.binders={},this._buffers=[];const l=[];for(const d in e.paint._values){if(!a(d))continue;const f=e.paint.get(d);if(!(f instanceof Ai&&Jn(f.property.specification)))continue;const m=w_(d,e.type),y=f.value,b=f.property.specification.type,S=f.property.useIntegerZoom,C=f.property.specification["property-type"],M=C==="cross-faded"||C==="cross-faded-data-driven";if(y.kind==="constant")this.binders[d]=M?new zn(y.value,m):new Pr(y.value,m,b),l.push(`/u_${d}`);else if(y.kind==="source"||M){const L=ep(d,b,"source");this.binders[d]=M?new Dr(y,b,S,r,L,e.id):new zr(y,m,b,L),l.push(`/a_${d}`)}else{const L=ep(d,b,"composite");this.binders[d]=new fr(y,m,b,S,r,L),l.push(`/z_${d}`)}}this.cacheKey=l.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof zr||r instanceof fr?r.maxValue:0}populatePaintArrays(e,r,a,l,d){for(const f in this.binders){const m=this.binders[f];(m instanceof zr||m instanceof fr||m instanceof Dr)&&m.populatePaintArray(e,r,a,l,d)}}setConstantPatternPositions(e,r){for(const a in this.binders){const l=this.binders[a];l instanceof zn&&l.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,a,l,d){let f=!1;for(const m in e){const y=r.getPositions(m);for(const b of y){const S=a.feature(b.index);for(const C in this.binders){const M=this.binders[C];if((M instanceof zr||M instanceof fr||M instanceof Dr)&&M.expression.isStateDependent===!0){const L=l.paint.get(C);M.expression=L.value,M.updatePaintArray(b.start,b.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 Pr||a instanceof zn)&&e.push(...a.uniformNames.map((l=>`#define HAS_UNIFORM_${l}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof zr||a instanceof fr)for(let l=0;l<a.paintVertexAttributes.length;l++)e.push(a.paintVertexAttributes[l].name);else if(a instanceof Dr)for(let l=0;l<Mr.members.length;l++)e.push(Mr.members[l].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof Pr||a instanceof zn||a instanceof fr)for(const l of a.uniformNames)e.push(l)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const a=[];for(const l in this.binders){const d=this.binders[l];if(d instanceof Pr||d instanceof zn||d instanceof fr){for(const f of d.uniformNames)if(r[f]){const m=d.getBinding(e,r[f],f);a.push({name:f,property:l,binding:m})}}}return a}setUniforms(e,r,a,l){for(const{name:d,property:f,binding:m}of r)this.binders[f].setUniform(m,l,a.get(f),d)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const a=this.binders[r];if(e&&a instanceof Dr){const l=e.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(a instanceof zr||a instanceof fr)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const r in this.binders){const a=this.binders[r];(a instanceof zr||a instanceof fr||a instanceof Dr)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof zr||r instanceof fr||r instanceof Dr)&&r.destroy()}}}class qr{constructor(e,r,a=(()=>!0)){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new Io(l,r,a);this.needsUpload=!1,this._featureMap=new Wt,this._bufferOffset=0}populatePaintArrays(e,r,a,l,d,f){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,r,l,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,l){for(const d of a)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(e,this._featureMap,r,d,l)||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 w_(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 ep(i,e,r){const a={color:{source:na,composite:$},number:{source:v,composite:na}},l=(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 l&&l[r]||a[e][r]}Re("ConstantBinder",Pr),Re("CrossFadedConstantBinder",zn),Re("SourceExpressionBinder",zr),Re("CrossFadedCompositeBinder",Dr),Re("CompositeExpressionBinder",fr),Re("ProgramConfiguration",Io,{omit:["_buffers"]}),Re("ProgramConfigurationSet",qr);const ei=8192,jc=Math.pow(2,14)-1,tp=-jc-1;function za(i){const e=ei/i.extent,r=i.loadGeometry();for(let a=0;a<r.length;a++){const l=r[a];for(let d=0;d<l.length;d++){const f=l[d],m=Math.round(f.x*e),y=Math.round(f.y*e);f.x=ar(m,tp,jc),f.y=ar(y,tp,jc),(m<f.x||m>f.x+1||y<f.y||y>f.y+1)&&Le("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Da(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?za(i):[]}}function Vl(i,e,r,a,l){i.emplaceBack(2*e+(a+1)/2,2*r+(l+1)/2)}class qc{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 Ne,this.indexArray=new mi,this.segments=new Dt,this.programConfigurations=new qr(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){const l=this.layers[0],d=[];let f=null,m=!1;l.type==="circle"&&(f=l.layout.get("circle-sort-key"),m=!f.isConstant());for(const{feature:y,id:b,index:S,sourceLayerIndex:C}of e){const M=this.layers[0]._featureFilter.needGeometry,L=Da(y,M);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),L,a))continue;const R=m?f.evaluate(L,{},a):void 0,V={id:b,properties:y.properties,type:y.type,sourceLayerIndex:C,index:S,geometry:M?L.geometry:za(y),patterns:{},sortKey:R};d.push(V)}m&&d.sort(((y,b)=>y.sortKey-b.sortKey));for(const y of d){const{geometry:b,index:S,sourceLayerIndex:C}=y,M=e[S].feature;this.addFeature(y,b,S,a),r.featureIndex.insert(M,b,S,C,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,Ji),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,l){for(const d of r)for(const f of d){const m=f.x,y=f.y;if(m<0||m>=ei||y<0||y>=ei)continue;const b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),S=b.vertexLength;Vl(this.layoutVertexArray,m,y,-1,-1),Vl(this.layoutVertexArray,m,y,1,-1),Vl(this.layoutVertexArray,m,y,1,1),Vl(this.layoutVertexArray,m,y,-1,1),this.indexArray.emplaceBack(S,S+1,S+2),this.indexArray.emplaceBack(S,S+3,S+2),b.vertexLength+=4,b.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{},l)}}function ip(i,e){for(let r=0;r<i.length;r++)if(vs(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(vs(i,e[r]))return!0;return!!Zc(i,e)}function S_(i,e,r){return!!vs(i,e)||!!Gc(e,i,r)}function rp(i,e){if(i.length===1)return ap(e,i[0]);for(let r=0;r<e.length;r++){const a=e[r];for(let l=0;l<a.length;l++)if(vs(i,a[l]))return!0}for(let r=0;r<i.length;r++)if(ap(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Zc(i,e[r]))return!0;return!1}function T_(i,e,r){if(i.length>1){if(Zc(i,e))return!0;for(let a=0;a<e.length;a++)if(Gc(e[a],i,r))return!0}for(let a=0;a<i.length;a++)if(Gc(i[a],e,r))return!0;return!1}function Zc(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const a=i[r],l=i[r+1];for(let d=0;d<e.length-1;d++)if(I_(a,l,e[d],e[d+1]))return!0}return!1}function I_(i,e,r,a){return qe(i,r,a)!==qe(e,r,a)&&qe(i,e,r)!==qe(i,e,a)}function Gc(i,e,r){const a=r*r;if(e.length===1)return i.distSqr(e[0])<a;for(let l=1;l<e.length;l++)if(np(i,e[l-1],e[l])<a)return!0;return!1}function np(i,e,r){const a=e.distSqr(r);if(a===0)return i.distSqr(e);const l=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/a;return i.distSqr(l<0?e:l>1?r:r.sub(e)._mult(l)._add(e))}function ap(i,e){let r,a,l,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],l=r[y],a.y>e.y!=l.y>e.y&&e.x<(l.x-a.x)*(e.y-a.y)/(l.y-a.y)+a.x&&(d=!d)}return d}function vs(i,e){let r=!1;for(let a=0,l=i.length-1;a<i.length;l=a++){const d=i[a],f=i[l];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 A_(i,e,r){const a=r[0],l=r[2];if(i.x<a.x&&e.x<a.x||i.x>l.x&&e.x>l.x||i.y<a.y&&e.y<a.y||i.y>l.y&&e.y>l.y)return!1;const d=qe(i,e,r[0]);return d!==qe(i,e,r[1])||d!==qe(i,e,r[2])||d!==qe(i,e,r[3])}function Ao(i,e,r){const a=e.paint.get(i).value;return a.kind==="constant"?a.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Ul(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function $l(i,e,r,a,l){if(!e[0]&&!e[1])return i;const d=ge.convert(e)._mult(l);r==="viewport"&&d._rotate(-a);const f=[];for(let m=0;m<i.length;m++)f.push(i[m].sub(d));return f}let sp,op;Re("CircleBucket",qc,{omit:["layers"]});var C_={get paint(){return op=op||new Kt({"circle-radius":new Ye(he.paint_circle["circle-radius"]),"circle-color":new Ye(he.paint_circle["circle-color"]),"circle-blur":new Ye(he.paint_circle["circle-blur"]),"circle-opacity":new Ye(he.paint_circle["circle-opacity"]),"circle-translate":new Ge(he.paint_circle["circle-translate"]),"circle-translate-anchor":new Ge(he.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Ge(he.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Ge(he.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ye(he.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ye(he.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ye(he.paint_circle["circle-stroke-opacity"])})},get layout(){return sp=sp||new Kt({"circle-sort-key":new Ye(he.layout_circle["circle-sort-key"])})}},Vi=1e-6,bs=typeof Float32Array<"u"?Float32Array:Array;function Hc(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 lp(i,e,r){var a=e[0],l=e[1],d=e[2],f=e[3],m=e[4],y=e[5],b=e[6],S=e[7],C=e[8],M=e[9],L=e[10],R=e[11],V=e[12],G=e[13],K=e[14],ne=e[15],J=r[0],se=r[1],le=r[2],_e=r[3];return i[0]=J*a+se*m+le*C+_e*V,i[1]=J*l+se*y+le*M+_e*G,i[2]=J*d+se*b+le*L+_e*K,i[3]=J*f+se*S+le*R+_e*ne,i[4]=(J=r[4])*a+(se=r[5])*m+(le=r[6])*C+(_e=r[7])*V,i[5]=J*l+se*y+le*M+_e*G,i[6]=J*d+se*b+le*L+_e*K,i[7]=J*f+se*S+le*R+_e*ne,i[8]=(J=r[8])*a+(se=r[9])*m+(le=r[10])*C+(_e=r[11])*V,i[9]=J*l+se*y+le*M+_e*G,i[10]=J*d+se*b+le*L+_e*K,i[11]=J*f+se*S+le*R+_e*ne,i[12]=(J=r[12])*a+(se=r[13])*m+(le=r[14])*C+(_e=r[15])*V,i[13]=J*l+se*y+le*M+_e*G,i[14]=J*d+se*b+le*L+_e*K,i[15]=J*f+se*S+le*R+_e*ne,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var Co,k_=lp;function jl(i,e,r){var a=e[0],l=e[1],d=e[2],f=e[3];return i[0]=r[0]*a+r[4]*l+r[8]*d+r[12]*f,i[1]=r[1]*a+r[5]*l+r[9]*d+r[13]*f,i[2]=r[2]*a+r[6]*l+r[10]*d+r[14]*f,i[3]=r[3]*a+r[7]*l+r[11]*d+r[15]*f,i}Co=new bs(4),bs!=Float32Array&&(Co[0]=0,Co[1]=0,Co[2]=0,Co[3]=0);class E_ extends dr{constructor(e){super(e,C_)}createBucket(e){return new qc(e)}queryRadius(e){const r=e;return Ao("circle-radius",this,r)+Ao("circle-stroke-width",this,r)+Ul(this.paint.get("circle-translate"))}queryIntersectsFeature(e,r,a,l,d,f,m,y){const b=$l(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),C=this.paint.get("circle-pitch-alignment")==="map",M=C?b:(function(R,V){return R.map((G=>cp(G,V)))})(b,y),L=C?S*m:S;for(const R of l)for(const V of R){const G=C?V:cp(V,y);let K=L;const ne=jl([],[V.x,V.y,0,1],y);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?K*=ne[3]/f.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(K*=f.cameraToCenterDistance/ne[3]),S_(M,G,K))return!0}return!1}}function cp(i,e){const r=jl([],[i.x,i.y,0,1],e);return new ge(r[0]/r[3],r[1]/r[3])}class up extends qc{}let hp;Re("HeatmapBucket",up,{omit:["layers"]});var M_={get paint(){return hp=hp||new Kt({"heatmap-radius":new Ye(he.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ye(he.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ge(he.paint_heatmap["heatmap-intensity"]),"heatmap-color":new yo(he.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ge(he.paint_heatmap["heatmap-opacity"])})}};function Wc(i,{width:e,height:r},a,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==e*r*a)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${e*r*a}`)}else l=new Uint8Array(e*r*a);return i.width=e,i.height=r,i.data=l,i}function pp(i,{width:e,height:r},a){if(e===i.width&&r===i.height)return;const l=Wc({},{width:e,height:r},a);Xc(i,l,{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=l.data}function Xc(i,e,r,a,l,d){if(l.width===0||l.height===0)return e;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>e.width||l.height>e.height||a.x>e.width-l.width||a.y>e.height-l.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<l.height;y++){const b=((r.y+y)*i.width+r.x)*d,S=((a.y+y)*e.width+a.x)*d;for(let C=0;C<l.width*d;C++)m[S+C]=f[b+C]}return e}class ko{constructor(e,r){Wc(this,e,1,r)}resize(e){pp(this,e,1)}clone(){return new ko({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,l,d){Xc(e,r,a,l,d,1)}}class yr{constructor(e,r){Wc(this,e,4,r)}resize(e){pp(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new yr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,l,d){Xc(e,r,a,l,d,4)}}function dp(i){const e={},r=i.resolution||256,a=i.clips?i.clips.length:1,l=i.image||new yr({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 b=i.expression.evaluate(e);l.data[f+m+0]=Math.floor(255*b.r/b.a),l.data[f+m+1]=Math.floor(255*b.g/b.a),l.data[f+m+2]=Math.floor(255*b.b/b.a),l.data[f+m+3]=Math.floor(255*b.a)};if(i.clips)for(let f=0,m=0;f<a;++f,m+=4*r)for(let y=0,b=0;y<r;y++,b+=4){const S=y/(r-1),{start:C,end:M}=i.clips[f];d(m,b,C*(1-S)+M*S)}else for(let f=0,m=0;f<r;f++,m+=4)d(0,m,f/(r-1));return l}Re("AlphaImage",ko),Re("RGBAImage",yr);class P_ extends dr{createBucket(e){return new up(e)}constructor(e){super(e,M_),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=dp({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 fp;var z_={get paint(){return fp=fp||new Kt({"hillshade-illumination-direction":new Ge(he.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Ge(he.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Ge(he.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Ge(he.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Ge(he.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Ge(he.paint_hillshade["hillshade-accent-color"])})}};class D_ extends dr{constructor(e){super(e,z_)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const L_=Ut([{name:"a_pos",components:2,type:"Int16"}],4),{members:R_}=L_;var Kc={exports:{}};function ql(i,e,r){r=r||2;var a,l,d,f,m,y,b,S=e&&e.length,C=S?e[0]*r:i.length,M=mp(i,0,C,r,!0),L=[];if(!M||M.next===M.prev)return L;if(S&&(M=(function(V,G,K,ne){var J,se,le,_e=[];for(J=0,se=G.length;J<se;J++)(le=mp(V,G[J]*ne,J<se-1?G[J+1]*ne:V.length,ne,!1))===le.next&&(le.steiner=!0),_e.push(j_(le));for(_e.sort(V_),J=0;J<_e.length;J++)K=U_(_e[J],K);return K})(i,e,M,r)),i.length>80*r){a=d=i[0],l=f=i[1];for(var R=r;R<C;R+=r)(m=i[R])<a&&(a=m),(y=i[R+1])<l&&(l=y),m>d&&(d=m),y>f&&(f=y);b=(b=Math.max(d-a,f-l))!==0?32767/b:0}return Eo(M,L,r,a,l,b,0),L}function mp(i,e,r,a,l){var d,f;if(l===Qc(i,e,r,a)>0)for(d=e;d<r;d+=a)f=yp(d,i[d],i[d+1],f);else for(d=r-a;d>=e;d-=a)f=yp(d,i[d],i[d+1],f);return f&&Zl(f,f.next)&&(Po(f),f=f.next),f}function La(i,e){if(!i)return i;e||(e=i);var r,a=i;do if(r=!1,a.steiner||!Zl(a,a.next)&&Jt(a.prev,a,a.next)!==0)a=a.next;else{if(Po(a),(a=e=a.prev)===a.next)break;r=!0}while(r||a!==e);return e}function Eo(i,e,r,a,l,d,f){if(i){!f&&d&&(function(S,C,M,L){var R=S;do R.z===0&&(R.z=Yc(R.x,R.y,C,M,L)),R.prevZ=R.prev,R.nextZ=R.next,R=R.next;while(R!==S);R.prevZ.nextZ=null,R.prevZ=null,(function(V){var G,K,ne,J,se,le,_e,De,Ve=1;do{for(K=V,V=null,se=null,le=0;K;){for(le++,ne=K,_e=0,G=0;G<Ve&&(_e++,ne=ne.nextZ);G++);for(De=Ve;_e>0||De>0&&ne;)_e!==0&&(De===0||!ne||K.z<=ne.z)?(J=K,K=K.nextZ,_e--):(J=ne,ne=ne.nextZ,De--),se?se.nextZ=J:V=J,J.prevZ=se,se=J;K=ne}se.nextZ=null,Ve*=2}while(le>1)})(R)})(i,a,l,d);for(var m,y,b=i;i.prev!==i.next;)if(m=i.prev,y=i.next,d?B_(i,a,l,d):F_(i))e.push(m.i/r|0),e.push(i.i/r|0),e.push(y.i/r|0),Po(i),i=y.next,b=y.next;else if((i=y)===b){f?f===1?Eo(i=O_(La(i),e,r),e,r,a,l,d,2):f===2&&N_(i,e,r,a,l,d):Eo(La(i),e,r,a,l,d,1);break}}}function F_(i){var e=i.prev,r=i,a=i.next;if(Jt(e,r,a)>=0)return!1;for(var l=e.x,d=r.x,f=a.x,m=e.y,y=r.y,b=a.y,S=l<d?l<f?l:f:d<f?d:f,C=m<y?m<b?m:b:y<b?y:b,M=l>d?l>f?l:f:d>f?d:f,L=m>y?m>b?m:b:y>b?y:b,R=a.next;R!==e;){if(R.x>=S&&R.x<=M&&R.y>=C&&R.y<=L&&ws(l,m,d,y,f,b,R.x,R.y)&&Jt(R.prev,R,R.next)>=0)return!1;R=R.next}return!0}function B_(i,e,r,a){var l=i.prev,d=i,f=i.next;if(Jt(l,d,f)>=0)return!1;for(var m=l.x,y=d.x,b=f.x,S=l.y,C=d.y,M=f.y,L=m<y?m<b?m:b:y<b?y:b,R=S<C?S<M?S:M:C<M?C:M,V=m>y?m>b?m:b:y>b?y:b,G=S>C?S>M?S:M:C>M?C:M,K=Yc(L,R,e,r,a),ne=Yc(V,G,e,r,a),J=i.prevZ,se=i.nextZ;J&&J.z>=K&&se&&se.z<=ne;){if(J.x>=L&&J.x<=V&&J.y>=R&&J.y<=G&&J!==l&&J!==f&&ws(m,S,y,C,b,M,J.x,J.y)&&Jt(J.prev,J,J.next)>=0||(J=J.prevZ,se.x>=L&&se.x<=V&&se.y>=R&&se.y<=G&&se!==l&&se!==f&&ws(m,S,y,C,b,M,se.x,se.y)&&Jt(se.prev,se,se.next)>=0))return!1;se=se.nextZ}for(;J&&J.z>=K;){if(J.x>=L&&J.x<=V&&J.y>=R&&J.y<=G&&J!==l&&J!==f&&ws(m,S,y,C,b,M,J.x,J.y)&&Jt(J.prev,J,J.next)>=0)return!1;J=J.prevZ}for(;se&&se.z<=ne;){if(se.x>=L&&se.x<=V&&se.y>=R&&se.y<=G&&se!==l&&se!==f&&ws(m,S,y,C,b,M,se.x,se.y)&&Jt(se.prev,se,se.next)>=0)return!1;se=se.nextZ}return!0}function O_(i,e,r){var a=i;do{var l=a.prev,d=a.next.next;!Zl(l,d)&&gp(l,a,a.next,d)&&Mo(l,d)&&Mo(d,l)&&(e.push(l.i/r|0),e.push(a.i/r|0),e.push(d.i/r|0),Po(a),Po(a.next),a=i=d),a=a.next}while(a!==i);return La(a)}function N_(i,e,r,a,l,d){var f=i;do{for(var m=f.next.next;m!==f.prev;){if(f.i!==m.i&&q_(f,m)){var y=_p(f,m);return f=La(f,f.next),y=La(y,y.next),Eo(f,e,r,a,l,d,0),void Eo(y,e,r,a,l,d,0)}m=m.next}f=f.next}while(f!==i)}function V_(i,e){return i.x-e.x}function U_(i,e){var r=(function(l,d){var f,m=d,y=l.x,b=l.y,S=-1/0;do{if(b<=m.y&&b>=m.next.y&&m.next.y!==m.y){var C=m.x+(b-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(C<=y&&C>S&&(S=C,f=m.x<m.next.x?m:m.next,C===y))return f}m=m.next}while(m!==d);if(!f)return null;var M,L=f,R=f.x,V=f.y,G=1/0;m=f;do y>=m.x&&m.x>=R&&y!==m.x&&ws(b<V?y:S,b,R,V,b<V?S:y,b,m.x,m.y)&&(M=Math.abs(b-m.y)/(y-m.x),Mo(m,l)&&(M<G||M===G&&(m.x>f.x||m.x===f.x&&$_(f,m)))&&(f=m,G=M)),m=m.next;while(m!==L);return f})(i,e);if(!r)return e;var a=_p(r,i);return La(a,a.next),La(r,r.next)}function $_(i,e){return Jt(i.prev,i,e.prev)<0&&Jt(e.next,i,i.next)<0}function Yc(i,e,r,a,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*l|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function j_(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 ws(i,e,r,a,l,d,f,m){return(l-f)*(e-m)>=(i-f)*(d-m)&&(i-f)*(a-m)>=(r-f)*(e-m)&&(r-f)*(d-m)>=(l-f)*(a-m)}function q_(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!(function(r,a){var l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==a.i&&l.next.i!==a.i&&gp(l,l.next,r,a))return!0;l=l.next}while(l!==r);return!1})(i,e)&&(Mo(i,e)&&Mo(e,i)&&(function(r,a){var l=r,d=!1,f=(r.x+a.x)/2,m=(r.y+a.y)/2;do l.y>m!=l.next.y>m&&l.next.y!==l.y&&f<(l.next.x-l.x)*(m-l.y)/(l.next.y-l.y)+l.x&&(d=!d),l=l.next;while(l!==r);return d})(i,e)&&(Jt(i.prev,i,e.prev)||Jt(i,e.prev,e))||Zl(i,e)&&Jt(i.prev,i,i.next)>0&&Jt(e.prev,e,e.next)>0)}function Jt(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Zl(i,e){return i.x===e.x&&i.y===e.y}function gp(i,e,r,a){var l=Hl(Jt(i,e,r)),d=Hl(Jt(i,e,a)),f=Hl(Jt(r,a,i)),m=Hl(Jt(r,a,e));return l!==d&&f!==m||!(l!==0||!Gl(i,r,e))||!(d!==0||!Gl(i,a,e))||!(f!==0||!Gl(r,i,a))||!(m!==0||!Gl(r,e,a))}function Gl(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 Hl(i){return i>0?1:i<0?-1:0}function Mo(i,e){return Jt(i.prev,i,i.next)<0?Jt(i,e,i.next)>=0&&Jt(i,i.prev,e)>=0:Jt(i,e,i.prev)<0||Jt(i,i.next,e)<0}function _p(i,e){var r=new Jc(i.i,i.x,i.y),a=new Jc(e.i,e.x,e.y),l=i.next,d=e.prev;return i.next=e,e.prev=i,r.next=l,l.prev=r,a.next=r,r.prev=a,d.next=a,a.prev=d,a}function yp(i,e,r,a){var l=new Jc(i,e,r);return a?(l.next=a.next,l.prev=a,a.next.prev=l,a.next=l):(l.prev=l,l.next=l),l}function Po(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 Jc(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 Qc(i,e,r,a){for(var l=0,d=e,f=r-a;d<r;d+=a)l+=(i[f]-i[d])*(i[d+1]+i[f+1]),f=d;return l}Kc.exports=ql,Kc.exports.default=ql,ql.deviation=function(i,e,r,a){var l=e&&e.length,d=Math.abs(Qc(i,0,l?e[0]*r:i.length,r));if(l)for(var f=0,m=e.length;f<m;f++)d-=Math.abs(Qc(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 b=a[f]*r,S=a[f+1]*r,C=a[f+2]*r;y+=Math.abs((i[b]-i[C])*(i[S+1]-i[b+1])-(i[b]-i[S])*(i[C+1]-i[b+1]))}return d===0&&y===0?0:Math.abs((y-d)/d)},ql.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},a=0,l=0;l<i.length;l++){for(var d=0;d<i[l].length;d++)for(var f=0;f<e;f++)r.vertices.push(i[l][d][f]);l>0&&r.holes.push(a+=i[l-1].length)}return r};var xp=H(Kc.exports);function Z_(i,e,r,a,l){vp(i,e,r,a||i.length-1,l||G_)}function vp(i,e,r,a,l){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),b=.5*Math.sqrt(m*y*(d-y)/d)*(f-d/2<0?-1:1);vp(i,e,Math.max(r,Math.floor(e-f*y/d+b)),Math.min(a,Math.floor(e+(d-f)*y/d+b)),l)}var S=i[e],C=r,M=a;for(zo(i,r,e),l(i[a],S)>0&&zo(i,r,a);C<M;){for(zo(i,C,M),C++,M--;l(i[C],S)<0;)C++;for(;l(i[M],S)>0;)M--}l(i[r],S)===0?zo(i,r,M):zo(i,++M,a),M<=e&&(r=M+1),e<=M&&(a=M-1)}}function zo(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function G_(i,e){return i<e?-1:i>e?1:0}function eu(i,e){const r=i.length;if(r<=1)return[i];const a=[];let l,d;for(let f=0;f<r;f++){const m=pt(i[f]);m!==0&&(i[f].area=Math.abs(m),d===void 0&&(d=m<0),d===m<0?(l&&a.push(l),l=[i[f]]):l.push(i[f]))}if(l&&a.push(l),e>1)for(let f=0;f<a.length;f++)a[f].length<=e||(Z_(a[f],e,1,a[f].length-1,H_),a[f]=a[f].slice(0,e));return a}function H_(i,e){return e.area-i.area}function tu(i,e,r){const a=r.patternDependencies;let l=!1;for(const d of e){const f=d.paint.get(`${i}-pattern`);f.isConstant()||(l=!0);const m=f.constantOr(null);m&&(l=!0,a[m.to]=!0,a[m.from]=!0)}return l}function iu(i,e,r,a,l){const d=l.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,{},l.availableImages),b=m.evaluate({zoom:a},r,{},l.availableImages),S=m.evaluate({zoom:a+1},r,{},l.availableImages);y=y&&y.name?y.name:y,b=b&&b.name?b.name:b,S=S&&S.name?S.name:S,d[y]=!0,d[b]=!0,d[S]=!0,r.patterns[f.id]={min:y,mid:b,max:S}}}return r}class ru{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 ct,this.indexArray=new mi,this.indexArray2=new ri,this.programConfigurations=new qr(e.layers,e.zoom),this.segments=new Dt,this.segments2=new Dt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=tu("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),d=!l.isConstant(),f=[];for(const{feature:m,id:y,index:b,sourceLayerIndex:S}of e){const C=this.layers[0]._featureFilter.needGeometry,M=Da(m,C);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),M,a))continue;const L=d?l.evaluate(M,{},a,r.availableImages):void 0,R={id:y,properties:m.properties,type:m.type,sourceLayerIndex:S,index:b,geometry:C?M.geometry:za(m),patterns:{},sortKey:L};f.push(R)}d&&f.sort(((m,y)=>m.sortKey-y.sortKey));for(const m of f){const{geometry:y,index:b,sourceLayerIndex:S}=m;if(this.hasPattern){const C=iu("fill",this.layers,m,this.zoom,r);this.patternFeatures.push(C)}else this.addFeature(m,y,b,a,{});r.featureIndex.insert(e[b].feature,y,b,S,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.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,R_),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,l,d){for(const f of eu(r,500)){let m=0;for(const L of f)m+=L.length;const y=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),b=y.vertexLength,S=[],C=[];for(const L of f){if(L.length===0)continue;L!==f[0]&&C.push(S.length/2);const R=this.segments2.prepareSegment(L.length,this.layoutVertexArray,this.indexArray2),V=R.vertexLength;this.layoutVertexArray.emplaceBack(L[0].x,L[0].y),this.indexArray2.emplaceBack(V+L.length-1,V),S.push(L[0].x),S.push(L[0].y);for(let G=1;G<L.length;G++)this.layoutVertexArray.emplaceBack(L[G].x,L[G].y),this.indexArray2.emplaceBack(V+G-1,V+G),S.push(L[G].x),S.push(L[G].y);R.vertexLength+=L.length,R.primitiveLength+=L.length}const M=xp(S,C);for(let L=0;L<M.length;L+=3)this.indexArray.emplaceBack(b+M[L],b+M[L+1],b+M[L+2]);y.vertexLength+=m,y.primitiveLength+=M.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,d,l)}}let bp,wp;Re("FillBucket",ru,{omit:["layers","patternFeatures"]});var W_={get paint(){return wp=wp||new Kt({"fill-antialias":new Ge(he.paint_fill["fill-antialias"]),"fill-opacity":new Ye(he.paint_fill["fill-opacity"]),"fill-color":new Ye(he.paint_fill["fill-color"]),"fill-outline-color":new Ye(he.paint_fill["fill-outline-color"]),"fill-translate":new Ge(he.paint_fill["fill-translate"]),"fill-translate-anchor":new Ge(he.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ea(he.paint_fill["fill-pattern"])})},get layout(){return bp=bp||new Kt({"fill-sort-key":new Ye(he.layout_fill["fill-sort-key"])})}};class X_ extends dr{constructor(e){super(e,W_)}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 ru(e)}queryRadius(){return Ul(this.paint.get("fill-translate"))}queryIntersectsFeature(e,r,a,l,d,f,m){return rp($l(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),f.angle,m),l)}isTileClipped(){return!0}}const K_=Ut([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Y_=Ut([{name:"a_centroid",components:2,type:"Int16"}],4),{members:J_}=K_;var sa={},Q_=ve,Sp=Ss;function Ss(i,e,r,a,l){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=a,this._values=l,i.readFields(ey,this,e)}function ey(i,e,r){i==1?e.id=r.readVarint():i==2?(function(a,l){for(var d=a.readVarint()+a.pos;a.pos<d;){var f=l._keys[a.readVarint()],m=l._values[a.readVarint()];l.properties[f]=m}})(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function ty(i){for(var e,r,a=0,l=0,d=i.length,f=d-1;l<d;f=l++)a+=((r=i[f]).x-(e=i[l]).x)*(e.y+r.y);return a}Ss.types=["Unknown","Point","LineString","Polygon"],Ss.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,a=1,l=0,d=0,f=0,m=[];i.pos<r;){if(l<=0){var y=i.readVarint();a=7&y,l=y>>3}if(l--,a===1||a===2)d+=i.readSVarint(),f+=i.readSVarint(),a===1&&(e&&m.push(e),e=[]),e.push(new Q_(d,f));else{if(a!==7)throw new Error("unknown command "+a);e&&e.push(e[0].clone())}}return e&&m.push(e),m},Ss.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,a=0,l=0,d=0,f=1/0,m=-1/0,y=1/0,b=-1/0;i.pos<e;){if(a<=0){var S=i.readVarint();r=7&S,a=S>>3}if(a--,r===1||r===2)(l+=i.readSVarint())<f&&(f=l),l>m&&(m=l),(d+=i.readSVarint())<y&&(y=d),d>b&&(b=d);else if(r!==7)throw new Error("unknown command "+r)}return[f,y,m,b]},Ss.prototype.toGeoJSON=function(i,e,r){var a,l,d=this.extent*Math.pow(2,r),f=this.extent*i,m=this.extent*e,y=this.loadGeometry(),b=Ss.types[this.type];function S(L){for(var R=0;R<L.length;R++){var V=L[R];L[R]=[360*(V.x+f)/d-180,360/Math.PI*Math.atan(Math.exp((180-360*(V.y+m)/d)*Math.PI/180))-90]}}switch(this.type){case 1:var C=[];for(a=0;a<y.length;a++)C[a]=y[a][0];S(y=C);break;case 2:for(a=0;a<y.length;a++)S(y[a]);break;case 3:for(y=(function(L){var R=L.length;if(R<=1)return[L];for(var V,G,K=[],ne=0;ne<R;ne++){var J=ty(L[ne]);J!==0&&(G===void 0&&(G=J<0),G===J<0?(V&&K.push(V),V=[L[ne]]):V.push(L[ne]))}return V&&K.push(V),K})(y),a=0;a<y.length;a++)for(l=0;l<y[a].length;l++)S(y[a][l])}y.length===1?y=y[0]:b="Multi"+b;var M={type:"Feature",geometry:{type:b,coordinates:y},properties:this.properties};return"id"in this&&(M.id=this.id),M};var iy=Sp,Tp=Ip;function Ip(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(ry,this,e),this.length=this._features.length}function ry(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 l=null,d=a.readVarint()+a.pos;a.pos<d;){var f=a.readVarint()>>3;l=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 l})(r))}Ip.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 iy(this._pbf,e,this.extent,this._keys,this._values)};var ny=Tp;function ay(i,e,r){if(i===3){var a=new ny(r,r.readVarint()+r.pos);a.length&&(e[a.name]=a)}}sa.VectorTile=function(i,e){this.layers=i.readFields(ay,{},e)},sa.VectorTileFeature=Sp,sa.VectorTileLayer=Tp;const sy=sa.VectorTileFeature.types,nu=Math.pow(2,13);function Do(i,e,r,a,l,d,f,m){i.emplaceBack(e,r,2*Math.floor(a*nu)+f,l*nu*2,d*nu*2,Math.round(m))}class au{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 Se,this.indexArray=new mi,this.programConfigurations=new qr(e.layers,e.zoom),this.segments=new Dt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.features=[],this.hasPattern=tu("fill-extrusion",this.layers,r);for(const{feature:l,id:d,index:f,sourceLayerIndex:m}of e){const y=this.layers[0]._featureFilter.needGeometry,b=Da(l,y);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),b,a))continue;const S={id:d,sourceLayerIndex:m,index:f,geometry:y?b.geometry:za(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(iu("fill-extrusion",this.layers,S,this.zoom,r)):this.addFeature(S,S.geometry,f,a,{}),r.featureIndex.insert(l,S.geometry,f,m,this.index,!0)}}addFeatures(e,r,a){for(const l of this.features){const{geometry:d}=l;this.addFeature(l,d,l.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,J_),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Y_.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,l,d){const f={x:0,y:0,vertexCount:0};for(const m of eu(r,500)){let y=0;for(const R of m)y+=R.length;let b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const R of m){if(R.length===0||ly(R))continue;let V=0;for(let G=0;G<R.length;G++){const K=R[G];if(G>=1){const ne=R[G-1];if(!oy(K,ne)){b.vertexLength+4>Dt.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const J=K.sub(ne)._perp()._unit(),se=ne.dist(K);V+se>32768&&(V=0),Do(this.layoutVertexArray,K.x,K.y,J.x,J.y,0,0,V),Do(this.layoutVertexArray,K.x,K.y,J.x,J.y,0,1,V),f.x+=2*K.x,f.y+=2*K.y,f.vertexCount+=2,V+=se,Do(this.layoutVertexArray,ne.x,ne.y,J.x,J.y,0,0,V),Do(this.layoutVertexArray,ne.x,ne.y,J.x,J.y,0,1,V),f.x+=2*ne.x,f.y+=2*ne.y,f.vertexCount+=2;const le=b.vertexLength;this.indexArray.emplaceBack(le,le+2,le+1),this.indexArray.emplaceBack(le+1,le+2,le+3),b.vertexLength+=4,b.primitiveLength+=2}}}}if(b.vertexLength+y>Dt.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(y,this.layoutVertexArray,this.indexArray)),sy[e.type]!=="Polygon")continue;const S=[],C=[],M=b.vertexLength;for(const R of m)if(R.length!==0){R!==m[0]&&C.push(S.length/2);for(let V=0;V<R.length;V++){const G=R[V];Do(this.layoutVertexArray,G.x,G.y,0,0,1,1,0),f.x+=G.x,f.y+=G.y,f.vertexCount+=1,S.push(G.x),S.push(G.y)}}const L=xp(S,C);for(let R=0;R<L.length;R+=3)this.indexArray.emplaceBack(M+L[R],M+L[R+2],M+L[R+1]);b.primitiveLength+=L.length/3,b.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,l)}}function oy(i,e){return i.x===e.x&&(i.x<0||i.x>ei)||i.y===e.y&&(i.y<0||i.y>ei)}function ly(i){return i.every((e=>e.x<0))||i.every((e=>e.x>ei))||i.every((e=>e.y<0))||i.every((e=>e.y>ei))}let Ap;Re("FillExtrusionBucket",au,{omit:["layers","features"]});var cy={get paint(){return Ap=Ap||new Kt({"fill-extrusion-opacity":new Ge(he["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ye(he["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ge(he["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ge(he["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ea(he["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ye(he["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ye(he["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ge(he["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class uy extends dr{constructor(e){super(e,cy)}createBucket(e){return new au(e)}queryRadius(){return Ul(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,a,l,d,f,m,y){const b=$l(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),C=this.paint.get("fill-extrusion-base").evaluate(r,a),M=(function(R,V,G,K){const ne=[];for(const J of R){const se=[J.x,J.y,0,1];jl(se,se,V),ne.push(new ge(se[0]/se[3],se[1]/se[3]))}return ne})(b,y),L=(function(R,V,G,K){const ne=[],J=[],se=K[8]*V,le=K[9]*V,_e=K[10]*V,De=K[11]*V,Ve=K[8]*G,Pe=K[9]*G,Me=K[10]*G,Ie=K[11]*G;for(const Fe of R){const Ce=[],we=[];for(const Xe of Fe){const je=Xe.x,ot=Xe.y,Lt=K[0]*je+K[4]*ot+K[12],Bt=K[1]*je+K[5]*ot+K[13],si=K[2]*je+K[6]*ot+K[14],mr=K[3]*je+K[7]*ot+K[15],Ui=si+_e,ti=mr+De,_i=Lt+Ve,wi=Bt+Pe,$i=si+Me,ji=mr+Ie,oi=new ge((Lt+se)/ti,(Bt+le)/ti);oi.z=Ui/ti,Ce.push(oi);const li=new ge(_i/ji,wi/ji);li.z=$i/ji,we.push(li)}ne.push(Ce),J.push(we)}return[ne,J]})(l,C,S,y);return(function(R,V,G){let K=1/0;rp(G,V)&&(K=Cp(G,V[0]));for(let ne=0;ne<V.length;ne++){const J=V[ne],se=R[ne];for(let le=0;le<J.length-1;le++){const _e=J[le],De=[_e,J[le+1],se[le+1],se[le],_e];ip(G,De)&&(K=Math.min(K,Cp(G,De)))}}return K!==1/0&&K})(L[0],L[1],M)}}function Lo(i,e){return i.x*e.x+i.y*e.y}function Cp(i,e){if(i.length===1){let r=0;const a=e[r++];let l;for(;!l||a.equals(l);)if(l=e[r++],!l)return 1/0;for(;r<e.length;r++){const d=e[r],f=i[0],m=l.sub(a),y=d.sub(a),b=f.sub(a),S=Lo(m,m),C=Lo(m,y),M=Lo(y,y),L=Lo(b,m),R=Lo(b,y),V=S*M-C*C,G=(M*L-C*R)/V,K=(S*R-C*L)/V,ne=a.z*(1-G-K)+l.z*G+d.z*K;if(isFinite(ne))return ne}return 1/0}{let r=1/0;for(const a of e)r=Math.min(r,a.z);return r}}const hy=Ut([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:py}=hy,dy=Ut([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:fy}=dy,my=sa.VectorTileFeature.types,gy=Math.cos(Math.PI/180*37.5),kp=Math.pow(2,14)/.5;class su{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 Je,this.layoutVertexArray2=new $e,this.indexArray=new mi,this.programConfigurations=new qr(e.layers,e.zoom),this.segments=new Dt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=tu("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),d=!l.isConstant(),f=[];for(const{feature:m,id:y,index:b,sourceLayerIndex:S}of e){const C=this.layers[0]._featureFilter.needGeometry,M=Da(m,C);if(!this.layers[0]._featureFilter.filter(new zt(this.zoom),M,a))continue;const L=d?l.evaluate(M,{},a):void 0,R={id:y,properties:m.properties,type:m.type,sourceLayerIndex:S,index:b,geometry:C?M.geometry:za(m),patterns:{},sortKey:L};f.push(R)}d&&f.sort(((m,y)=>m.sortKey-y.sortKey));for(const m of f){const{geometry:y,index:b,sourceLayerIndex:S}=m;if(this.hasPattern){const C=iu("line",this.layers,m,this.zoom,r);this.patternFeatures.push(C)}else this.addFeature(m,y,b,a,{});r.featureIndex.insert(e[b].feature,y,b,S,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.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,fy)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,py),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,l,d){const f=this.layers[0].layout,m=f.get("line-join").evaluate(e,{}),y=f.get("line-cap"),b=f.get("line-miter-limit"),S=f.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const C of r)this.addLine(C,e,m,y,b,S);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,d,l)}addLine(e,r,a,l,d,f){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let K=0;K<e.length-1;K++)this.totalDistance+=e[K].dist(e[K+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const m=my[r.type]==="Polygon";let y=e.length;for(;y>=2&&e[y-1].equals(e[y-2]);)y--;let b=0;for(;b<y-1&&e[b].equals(e[b+1]);)b++;if(y<(m?3:2))return;a==="bevel"&&(d=1.05);const S=this.overscaling<=16?15*ei/(512*this.overscaling):0,C=this.segments.prepareSegment(10*y,this.layoutVertexArray,this.indexArray);let M,L,R,V,G;this.e1=this.e2=-1,m&&(M=e[y-2],G=e[b].sub(M)._unit()._perp());for(let K=b;K<y;K++){if(R=K===y-1?m?e[b+1]:void 0:e[K+1],R&&e[K].equals(R))continue;G&&(V=G),M&&(L=M),M=e[K],G=R?R.sub(M)._unit()._perp():V,V=V||G;let ne=V.add(G);ne.x===0&&ne.y===0||ne._unit();const J=V.x*G.x+V.y*G.y,se=ne.x*G.x+ne.y*G.y,le=se!==0?1/se:1/0,_e=2*Math.sqrt(2-2*se),De=se<gy&&L&&R,Ve=V.x*G.y-V.y*G.x>0;if(De&&K>b){const Ie=M.dist(L);if(Ie>2*S){const Fe=M.sub(M.sub(L)._mult(S/Ie)._round());this.updateDistance(L,Fe),this.addCurrentVertex(Fe,V,0,0,C),L=Fe}}const Pe=L&&R;let Me=Pe?a:m?"butt":l;if(Pe&&Me==="round"&&(le<f?Me="miter":le<=2&&(Me="fakeround")),Me==="miter"&&le>d&&(Me="bevel"),Me==="bevel"&&(le>2&&(Me="flipbevel"),le<d&&(Me="miter")),L&&this.updateDistance(L,M),Me==="miter")ne._mult(le),this.addCurrentVertex(M,ne,0,0,C);else if(Me==="flipbevel"){if(le>100)ne=G.mult(-1);else{const Ie=le*V.add(G).mag()/V.sub(G).mag();ne._perp()._mult(Ie*(Ve?-1:1))}this.addCurrentVertex(M,ne,0,0,C),this.addCurrentVertex(M,ne.mult(-1),0,0,C)}else if(Me==="bevel"||Me==="fakeround"){const Ie=-Math.sqrt(le*le-1),Fe=Ve?Ie:0,Ce=Ve?0:Ie;if(L&&this.addCurrentVertex(M,V,Fe,Ce,C),Me==="fakeround"){const we=Math.round(180*_e/Math.PI/20);for(let Xe=1;Xe<we;Xe++){let je=Xe/we;if(je!==.5){const Lt=je-.5;je+=je*Lt*(je-1)*((1.0904+J*(J*(3.55645-1.43519*J)-3.2452))*Lt*Lt+(.848013+J*(.215638*J-1.06021)))}const ot=G.sub(V)._mult(je)._add(V)._unit()._mult(Ve?-1:1);this.addHalfVertex(M,ot.x,ot.y,!1,Ve,0,C)}}R&&this.addCurrentVertex(M,G,-Fe,-Ce,C)}else if(Me==="butt")this.addCurrentVertex(M,ne,0,0,C);else if(Me==="square"){const Ie=L?1:-1;this.addCurrentVertex(M,ne,Ie,Ie,C)}else Me==="round"&&(L&&(this.addCurrentVertex(M,V,0,0,C),this.addCurrentVertex(M,V,1,1,C,!0)),R&&(this.addCurrentVertex(M,G,-1,-1,C,!0),this.addCurrentVertex(M,G,0,0,C)));if(De&&K<y-1){const Ie=M.dist(R);if(Ie>2*S){const Fe=M.add(R.sub(M)._mult(S/Ie)._round());this.updateDistance(M,Fe),this.addCurrentVertex(Fe,G,0,0,C),M=Fe}}}}addCurrentVertex(e,r,a,l,d,f=!1){const m=r.y*l-r.x,y=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,f,!1,a,d),this.addHalfVertex(e,m,y,f,!0,-l,d),this.distance>kp/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,a,l,d,f))}addHalfVertex({x:e,y:r},a,l,d,f,m,y){const b=.5*(this.lineClips?this.scaledDistance*(kp-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(d?1:0),(r<<1)+(f?1:0),Math.round(63*a)+128,Math.round(63*l)+128,1+(m===0?0:m<0?-1:1)|(63&b)<<2,b>>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 Ep,Mp;Re("LineBucket",su,{omit:["layers","patternFeatures"]});var Pp={get paint(){return Mp=Mp||new Kt({"line-opacity":new Ye(he.paint_line["line-opacity"]),"line-color":new Ye(he.paint_line["line-color"]),"line-translate":new Ge(he.paint_line["line-translate"]),"line-translate-anchor":new Ge(he.paint_line["line-translate-anchor"]),"line-width":new Ye(he.paint_line["line-width"]),"line-gap-width":new Ye(he.paint_line["line-gap-width"]),"line-offset":new Ye(he.paint_line["line-offset"]),"line-blur":new Ye(he.paint_line["line-blur"]),"line-dasharray":new _o(he.paint_line["line-dasharray"]),"line-pattern":new Ea(he.paint_line["line-pattern"]),"line-gradient":new yo(he.paint_line["line-gradient"])})},get layout(){return Ep=Ep||new Kt({"line-cap":new Ge(he.layout_line["line-cap"]),"line-join":new Ye(he.layout_line["line-join"]),"line-miter-limit":new Ge(he.layout_line["line-miter-limit"]),"line-round-limit":new Ge(he.layout_line["line-round-limit"]),"line-sort-key":new Ye(he.layout_line["line-sort-key"])})}};class _y extends Ye{possiblyEvaluate(e,r){return r=new zt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,a,l){return r=ii({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,a,l)}}let Wl;class yy extends dr{constructor(e){super(e,Pp),this.gradientVersion=0,Wl||(Wl=new _y(Pp.paint.properties["line-width"].specification),Wl.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 sn,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"]=Wl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new su(e)}queryRadius(e){const r=e,a=zp(Ao("line-width",this,r),Ao("line-gap-width",this,r)),l=Ao("line-offset",this,r);return a/2+Math.abs(l)+Ul(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,a,l,d,f,m){const y=$l(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),f.angle,m),b=m/2*zp(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&&(l=(function(C,M){const L=[];for(let R=0;R<C.length;R++){const V=C[R],G=[];for(let K=0;K<V.length;K++){const ne=V[K-1],J=V[K],se=V[K+1],le=K===0?new ge(0,0):J.sub(ne)._unit()._perp(),_e=K===V.length-1?new ge(0,0):se.sub(J)._unit()._perp(),De=le._add(_e)._unit(),Ve=De.x*_e.x+De.y*_e.y;Ve!==0&&De._mult(1/Ve),G.push(De._mult(M)._add(J))}L.push(G)}return L})(l,S*m)),(function(C,M,L){for(let R=0;R<M.length;R++){const V=M[R];if(C.length>=3){for(let G=0;G<V.length;G++)if(vs(C,V[G]))return!0}if(T_(C,V,L))return!0}return!1})(y,l,b)}isTileClipped(){return!0}}function zp(i,e){return e>0?e+2*i:i}const xy=Ut([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),vy=Ut([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ut([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const by=Ut([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Ut([{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 Dp=Ut([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),wy=Ut([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Sy(i,e,r){return i.sections.forEach((a=>{a.text=(function(l,d,f){const m=d.layout.get("text-transform").evaluate(f,{});return m==="uppercase"?l=l.toLocaleUpperCase():m==="lowercase"&&(l=l.toLocaleLowerCase()),Yi.applyArabicShaping&&(l=Yi.applyArabicShaping(l)),l})(a.text,e,r)})),i}Ut([{name:"triangle",components:3,type:"Uint16"}]),Ut([{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"}]),Ut([{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"}]),Ut([{type:"Float32",name:"offsetX"}]),Ut([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ut([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Ro={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ai=24,Lp=It,Rp=function(i,e,r,a,l){var d,f,m=8*l-a-1,y=(1<<m)-1,b=y>>1,S=-7,C=l-1,M=-1,L=i[e+C];for(C+=M,d=L&(1<<-S)-1,L>>=-S,S+=m;S>0;d=256*d+i[e+C],C+=M,S-=8);for(f=d&(1<<-S)-1,d>>=-S,S+=a;S>0;f=256*f+i[e+C],C+=M,S-=8);if(d===0)d=1-b;else{if(d===y)return f?NaN:1/0*(L?-1:1);f+=Math.pow(2,a),d-=b}return(L?-1:1)*f*Math.pow(2,d-a)},Fp=function(i,e,r,a,l,d){var f,m,y,b=8*d-l-1,S=(1<<b)-1,C=S>>1,M=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=0,R=1,V=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+C>=1?M/y:M*Math.pow(2,1-C))*y>=2&&(f++,y/=2),f+C>=S?(m=0,f=S):f+C>=1?(m=(e*y-1)*Math.pow(2,l),f+=C):(m=e*Math.pow(2,C-1)*Math.pow(2,l),f=0));l>=8;i[r+L]=255&m,L+=R,m/=256,l-=8);for(f=f<<l|m,b+=l;b>0;i[r+L]=255&f,L+=R,f/=256,b-=8);i[r+L-R]|=128*V};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 ou=4294967296,Bp=1/ou,Op=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Dn(i){return i.type===It.Bytes?i.readVarint()+i.pos:i.pos+1}function Ts(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function Np(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 l=r.pos-1;l>=i;l--)r.buf[l+a]=r.buf[l]}function Ty(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function Iy(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function Ay(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function Cy(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function ky(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function Ey(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function My(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function Py(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function zy(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function Xl(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function Is(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function Vp(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(),l=a>>3,d=this.pos;this.type=7&a,i(l,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=Xl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Vp(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Xl(this.buf,this.pos)+Xl(this.buf,this.pos+4)*ou;return this.pos+=8,i},readSFixed64:function(){var i=Xl(this.buf,this.pos)+Vp(this.buf,this.pos+4)*ou;return this.pos+=8,i},readFloat:function(){var i=Rp(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Rp(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(l,d,f){var m,y,b=f.buf;if(m=(112&(y=b[f.pos++]))>>4,y<128||(m|=(127&(y=b[f.pos++]))<<3,y<128)||(m|=(127&(y=b[f.pos++]))<<10,y<128)||(m|=(127&(y=b[f.pos++]))<<17,y<128)||(m|=(127&(y=b[f.pos++]))<<24,y<128)||(m|=(1&(y=b[f.pos++]))<<31,y<128))return Ts(l,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&&Op?(function(r,a,l){return Op.decode(r.subarray(a,l))})(this.buf,e,i):(function(r,a,l){for(var d="",f=a;f<l;){var m,y,b,S=r[f],C=null,M=S>239?4:S>223?3:S>191?2:1;if(f+M>l)break;M===1?S<128&&(C=S):M===2?(192&(m=r[f+1]))==128&&(C=(31&S)<<6|63&m)<=127&&(C=null):M===3?(y=r[f+2],(192&(m=r[f+1]))==128&&(192&y)==128&&((C=(15&S)<<12|(63&m)<<6|63&y)<=2047||C>=55296&&C<=57343)&&(C=null)):M===4&&(y=r[f+2],b=r[f+3],(192&(m=r[f+1]))==128&&(192&y)==128&&(192&b)==128&&((C=(15&S)<<18|(63&m)<<12|(63&y)<<6|63&b)<=65535||C>=1114112)&&(C=null)),C===null?(C=65533,M=1):C>65535&&(C-=65536,d+=String.fromCharCode(C>>>10&1023|55296),C=56320|1023&C),d+=String.fromCharCode(C),f+=M}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=Dn(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=Dn(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=Dn(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=Dn(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=Dn(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=Dn(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=Dn(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=Dn(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=Dn(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),Is(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),Is(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),Is(this.buf,-1&i,this.pos),Is(this.buf,Math.floor(i*Bp),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),Is(this.buf,-1&i,this.pos),Is(this.buf,Math.floor(i*Bp),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?(function(e,r){var a,l;if(e>=0?(a=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,l=l+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)))))})(l,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,l,d){for(var f,m,y=0;y<l.length;y++){if((f=l.charCodeAt(y))>55295&&f<57344){if(!m){f>56319||y+1===l.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&&Np(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Fp(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Fp(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&&Np(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,Ty,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,Iy,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,ky,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,Ay,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,Cy,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,Ey,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,My,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,Py,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,zy,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 lu=H(Lp);const cu=3;function Dy(i,e,r){i===1&&r.readMessage(Ly,e)}function Ly(i,e,r){if(i===3){const{id:a,bitmap:l,width:d,height:f,left:m,top:y,advance:b}=r.readMessage(Ry,{});e.push({id:a,bitmap:new ko({width:d+2*cu,height:f+2*cu},l),metrics:{width:d,height:f,left:m,top:y,advance:b}})}}function Ry(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 Up=cu;function $p(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 l=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),l=Math.max(l,f.x+f.w),f.w===y.w&&f.h===y.h){const b=a.pop();m<a.length&&(a[m]=b)}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:l,h:d,fill:e/(l*d)||0}}const Qi=1;class uu{constructor(e,{pixelRatio:r,version:a,stretchX:l,stretchY:d,content:f}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=l,this.stretchY=d,this.content=f,this.version=a}get tl(){return[this.paddedRect.x+Qi,this.paddedRect.y+Qi]}get br(){return[this.paddedRect.x+this.paddedRect.w-Qi,this.paddedRect.y+this.paddedRect.h-Qi]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*Qi)/this.pixelRatio,(this.paddedRect.h-2*Qi)/this.pixelRatio]}}class jp{constructor(e,r){const a={},l={};this.haveRenderCallbacks=[];const d=[];this.addImages(e,a,d),this.addImages(r,l,d);const{w:f,h:m}=$p(d),y=new yr({width:f||1,height:m||1});for(const b in e){const S=e[b],C=a[b].paddedRect;yr.copy(S.data,y,{x:0,y:0},{x:C.x+Qi,y:C.y+Qi},S.data)}for(const b in r){const S=r[b],C=l[b].paddedRect,M=C.x+Qi,L=C.y+Qi,R=S.data.width,V=S.data.height;yr.copy(S.data,y,{x:0,y:0},{x:M,y:L},S.data),yr.copy(S.data,y,{x:0,y:V-1},{x:M,y:L-1},{width:R,height:1}),yr.copy(S.data,y,{x:0,y:0},{x:M,y:L+V},{width:R,height:1}),yr.copy(S.data,y,{x:R-1,y:0},{x:M-1,y:L},{width:1,height:V}),yr.copy(S.data,y,{x:0,y:0},{x:M+R,y:L},{width:1,height:V})}this.image=y,this.iconPositions=a,this.patternPositions=l}addImages(e,r,a){for(const l in e){const d=e[l],f={x:0,y:0,w:d.data.width+2*Qi,h:d.data.height+2*Qi};a.push(f),r[l]=new uu(f,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}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[l,d]=e.tl;a.update(r.data,void 0,{x:l,y:d})}}var oa;Re("ImagePosition",uu),Re("ImageAtlas",jp),o.ai=void 0,(oa=o.ai||(o.ai={}))[oa.none=0]="none",oa[oa.horizontal=1]="horizontal",oa[oa.vertical=2]="vertical",oa[oa.horizontalOnly=3]="horizontalOnly";const Fo=-17;class Bo{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const a=new Bo;return a.scale=e||1,a.fontStack=r,a}static forImage(e){const r=new Bo;return r.imageName=e,r}}class As{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const a=new As;for(let l=0;l<e.sections.length;l++){const d=e.sections[l];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 l=e.charCodeAt(a+1)||null,d=e.charCodeAt(a-1)||null;r+=l&&Ml(l)&&!Ro[e[a+1]]||d&&Ml(d)&&!Ro[e[a-1]]||!Ro[e[a]]?e[a]:Ro[e[a]]}return r})(this.text)}trim(){let e=0;for(let a=0;a<this.text.length&&Yl[this.text.charCodeAt(a)];a++)e++;let r=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&Yl[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 As;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(Bo.forText(e.scale,e.fontStack||r));const a=this.sections.length-1;for(let l=0;l<e.text.length;++l)this.sectionIndex.push(a)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void Le("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(Bo.forImage(r)),this.sectionIndex.push(this.sections.length-1)):Le("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kl(i,e,r,a,l,d,f,m,y,b,S,C,M,L,R,V){const G=As.fromFeature(i,l);let K;C===o.ai.vertical&&G.verticalizePunctuation();const{processBidirectionalText:ne,processStyledBidirectionalText:J}=Yi;if(ne&&G.sections.length===1){K=[];const _e=ne(G.toString(),hu(G,b,d,e,a,L,R));for(const De of _e){const Ve=new As;Ve.text=De,Ve.sections=G.sections;for(let Pe=0;Pe<De.length;Pe++)Ve.sectionIndex.push(0);K.push(Ve)}}else if(J){K=[];const _e=J(G.text,G.sectionIndex,hu(G,b,d,e,a,L,R));for(const De of _e){const Ve=new As;Ve.text=De[0],Ve.sectionIndex=De[1],Ve.sections=G.sections,K.push(Ve)}}else K=(function(_e,De){const Ve=[],Pe=_e.text;let Me=0;for(const Ie of De)Ve.push(_e.substring(Me,Ie)),Me=Ie;return Me<Pe.length&&Ve.push(_e.substring(Me,Pe.length)),Ve})(G,hu(G,b,d,e,a,L,R));const se=[],le={positionedLines:se,text:G.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:C,iconsInText:!1,verticalizable:!1};return(function(_e,De,Ve,Pe,Me,Ie,Fe,Ce,we,Xe,je,ot){let Lt=0,Bt=Fo,si=0,mr=0;const Ui=Ce==="right"?1:Ce==="left"?0:.5;let ti=0;for(const oi of Me){oi.trim();const li=oi.getMaxScale(),ki=(li-1)*ai,qi={positionedGlyphs:[],lineOffset:0};_e.positionedLines[ti]=qi;const Ei=qi.positionedGlyphs;let er=0;if(!oi.length()){Bt+=Ie,++ti;continue}for(let ci=0;ci<oi.length();ci++){const ht=oi.getSection(ci),Mi=oi.getSectionIndex(ci),Si=oi.getCharCode(ci);let ui=0,Lr=null,Zr=null,Gr=null,Ln=ai;const Rr=!(we===o.ai.horizontal||!je&&!lo(Si)||je&&(Yl[Si]||(_i=Si,ze.Arabic(_i)||ze["Arabic Supplement"](_i)||ze["Arabic Extended-A"](_i)||ze["Arabic Presentation Forms-A"](_i)||ze["Arabic Presentation Forms-B"](_i))));if(ht.imageName){const vr=Pe[ht.imageName];if(!vr)continue;Gr=ht.imageName,_e.iconsInText=_e.iconsInText||!0,Zr=vr.paddedRect;const ir=vr.displaySize;ht.scale=ht.scale*ai/ot,Lr={width:ir[0],height:ir[1],left:Qi,top:-Up,advance:Rr?ir[1]:ir[0]},ui=ki+(ai-ir[1]*ht.scale),Ln=Lr.advance;const Rn=Rr?ir[0]*ht.scale-ai*li:ir[1]*ht.scale-ai*li;Rn>0&&Rn>er&&(er=Rn)}else{const vr=Ve[ht.fontStack],ir=vr&&vr[Si];if(ir&&ir.rect)Zr=ir.rect,Lr=ir.metrics;else{const Rn=De[ht.fontStack],$o=Rn&&Rn[Si];if(!$o)continue;Lr=$o.metrics}ui=(li-ht.scale)*ai}Rr?(_e.verticalizable=!0,Ei.push({glyph:Si,imageName:Gr,x:Lt,y:Bt+ui,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:Mi,metrics:Lr,rect:Zr}),Lt+=Ln*ht.scale+Xe):(Ei.push({glyph:Si,imageName:Gr,x:Lt,y:Bt+ui,vertical:Rr,scale:ht.scale,fontStack:ht.fontStack,sectionIndex:Mi,metrics:Lr,rect:Zr}),Lt+=Lr.advance*ht.scale+Xe)}Ei.length!==0&&(si=Math.max(Lt-Xe,si),Oy(Ei,0,Ei.length-1,Ui,er)),Lt=0;const tr=Ie*li+er;qi.lineOffset=Math.max(er,ki),Bt+=tr,mr=Math.max(tr,mr),++ti}var _i;const wi=Bt-Fo,{horizontalAlign:$i,verticalAlign:ji}=pu(Fe);(function(oi,li,ki,qi,Ei,er,tr,ci,ht){const Mi=(li-ki)*Ei;let Si=0;Si=er!==tr?-ci*qi-Fo:(-qi*ht+.5)*tr;for(const ui of oi)for(const Lr of ui.positionedGlyphs)Lr.x+=Mi,Lr.y+=Si})(_e.positionedLines,Ui,$i,ji,si,mr,Ie,wi,Me.length),_e.top+=-ji*wi,_e.bottom=_e.top+wi,_e.left+=-$i*si,_e.right=_e.left+si})(le,e,r,a,K,f,m,y,C,b,M,V),!(function(_e){for(const De of _e)if(De.positionedGlyphs.length!==0)return!1;return!0})(se)&&le}const Yl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Fy={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 qp(i,e,r,a,l,d){if(e.imageName){const f=a[e.imageName];return f?f.displaySize[0]*e.scale*ai/d+l:0}{const f=r[e.fontStack],m=f&&f[i];return m?m.metrics.advance*e.scale+l:0}}function Zp(i,e,r,a){const l=Math.pow(i-e,2);return a?i<e?l/2:2*l:l+Math.abs(r)*r}function By(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 Gp(i,e,r,a,l,d){let f=null,m=Zp(e,r,l,d);for(const y of a){const b=Zp(e-y.x,r,l,d)+y.badness;b<=m&&(f=y,m=b)}return{index:i,x:e,priorBreak:f,badness:m}}function Hp(i){return i?Hp(i.priorBreak).concat(i.index):[]}function hu(i,e,r,a,l,d,f){if(d!=="point")return[];if(!i)return[];const m=[],y=(function(M,L,R,V,G,K){let ne=0;for(let J=0;J<M.length();J++){const se=M.getSection(J);ne+=qp(M.getCharCode(J),se,V,G,L,K)}return ne/Math.max(1,Math.ceil(ne/R))})(i,e,r,a,l,f),b=i.text.indexOf("")>=0;let S=0;for(let M=0;M<i.length();M++){const L=i.getSection(M),R=i.getCharCode(M);if(Yl[R]||(S+=qp(R,L,a,l,e,f)),M<i.length()-1){const V=!((C=R)<11904||!(ze["Bopomofo Extended"](C)||ze.Bopomofo(C)||ze["CJK Compatibility Forms"](C)||ze["CJK Compatibility Ideographs"](C)||ze["CJK Compatibility"](C)||ze["CJK Radicals Supplement"](C)||ze["CJK Strokes"](C)||ze["CJK Symbols and Punctuation"](C)||ze["CJK Unified Ideographs Extension A"](C)||ze["CJK Unified Ideographs"](C)||ze["Enclosed CJK Letters and Months"](C)||ze["Halfwidth and Fullwidth Forms"](C)||ze.Hiragana(C)||ze["Ideographic Description Characters"](C)||ze["Kangxi Radicals"](C)||ze["Katakana Phonetic Extensions"](C)||ze.Katakana(C)||ze["Vertical Forms"](C)||ze["Yi Radicals"](C)||ze["Yi Syllables"](C)));(Fy[R]||V||L.imageName)&&m.push(Gp(M+1,S,y,m,By(R,i.getCharCode(M+1),V&&b),!1))}}var C;return Hp(Gp(i.length(),S,y,m,0,!0))}function pu(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 Oy(i,e,r,a,l){if(!a&&!l)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+=l}function Ny(i,e,r){const{horizontalAlign:a,verticalAlign:l}=pu(r),d=e[0]-i.displaySize[0]*a,f=e[1]-i.displaySize[1]*l;return{image:i,top:f,bottom:f+i.displaySize[1],left:d,right:d+i.displaySize[0]}}function Wp(i,e,r,a,l,d){const f=i.image;let m;if(f.content){const G=f.content,K=f.pixelRatio||1;m=[G[0]/K,G[1]/K,f.displaySize[0]-G[2]/K,f.displaySize[1]-G[3]/K]}const y=e.left*d,b=e.right*d;let S,C,M,L;r==="width"||r==="both"?(L=l[0]+y-a[3],C=l[0]+b+a[1]):(L=l[0]+(y+b-f.displaySize[0])/2,C=L+f.displaySize[0]);const R=e.top*d,V=e.bottom*d;return r==="height"||r==="both"?(S=l[1]+R-a[0],M=l[1]+V+a[2]):(S=l[1]+(R+V-f.displaySize[1])/2,M=S+f.displaySize[1]),{image:f,top:S,right:C,bottom:M,left:L,collisionPadding:m}}const Oo=255,pn=128,la=Oo*pn;function Xp(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new zt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:l}=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:l}:{kind:"camera",minZoom:m,maxZoom:y,minSize:r.evaluate(new zt(m)),maxSize:r.evaluate(new zt(y)),interpolationType:l}}}function du(i,e,r){let a="never";const l=i.get(e);return l?a=l:i.get(r)&&(a="always"),a}const Vy=sa.VectorTileFeature.types,Uy=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Jl(i,e,r,a,l,d,f,m,y,b,S,C,M){const L=m?Math.min(la,Math.round(m[0])):0,R=m?Math.min(la,Math.round(m[1])):0;i.emplaceBack(e,r,Math.round(32*a),Math.round(32*l),d,f,(L<<1)+(y?1:0),R,16*b,16*S,256*C,256*M)}function fu(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 $y(i){for(const e of i.sections)if(Vc(e.text))return!0;return!1}class mu{constructor(e){this.layoutVertexArray=new lt,this.indexArray=new mi,this.programConfigurations=e,this.segments=new Dt,this.dynamicLayoutVertexArray=new at,this.opacityVertexArray=new ut,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,l){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xy.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,vy.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Uy,!0),this.opacityVertexBuffer.itemSize=1),(a||l)&&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())}}Re("SymbolBuffers",mu);class gu{constructor(e,r,a){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new a,this.segments=new Dt,this.collisionVertexArray=new kt}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,by.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Re("CollisionBuffers",gu);class Cs{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=Hc([]),this.placementViewportMatrix=Hc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Xp(this.zoom,r["text-size"]),this.iconSizeData=Xp(this.zoom,r["icon-size"]);const a=this.layers[0].layout,l=a.get("symbol-sort-key"),d=a.get("symbol-z-order");this.canOverlap=du(a,"text-overlap","text-allow-overlap")!=="never"||du(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!l.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=>o.ai[f]))),this.stateDependentLayerIds=this.layers.filter((f=>f.isStateDependent())).map((f=>f.id)),this.sourceID=e.sourceID}createArrays(){this.text=new mu(new qr(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new mu(new qr(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new ie,this.lineVertexArray=new ce,this.symbolInstances=new X,this.textAnchorOffsets=new me}calculateGlyphDependencies(e,r,a,l,d){for(let f=0;f<e.length;f++)if(r[e.charCodeAt(f)]=!0,(a||l)&&d){const m=Ro[e.charAt(f)];m&&(r[m.charCodeAt(0)]=!0)}}populate(e,r,a){const l=this.layers[0],d=l.layout,f=d.get("text-font"),m=d.get("text-field"),y=d.get("icon-image"),b=(m.value.kind!=="constant"||m.value.value instanceof xi&&!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,C=d.get("symbol-sort-key");if(this.features=[],!b&&!S)return;const M=r.iconDependencies,L=r.glyphDependencies,R=r.availableImages,V=new zt(this.zoom);for(const{feature:G,id:K,index:ne,sourceLayerIndex:J}of e){const se=l._featureFilter.needGeometry,le=Da(G,se);if(!l._featureFilter.filter(V,le,a))continue;let _e,De;if(se||(le.geometry=za(G)),b){const Pe=l.getValueAndResolveTokens("text-field",le,a,R),Me=xi.factory(Pe);$y(Me)&&(this.hasRTLText=!0),(!this.hasRTLText||mo()==="unavailable"||this.hasRTLText&&Yi.isParsed())&&(_e=Sy(Me,l,le))}if(S){const Pe=l.getValueAndResolveTokens("icon-image",le,a,R);De=Pe instanceof fi?Pe:fi.fromString(Pe)}if(!_e&&!De)continue;const Ve=this.sortFeaturesByKey?C.evaluate(le,{},a):void 0;if(this.features.push({id:K,text:_e,icon:De,index:ne,sourceLayerIndex:J,geometry:le.geometry,properties:G.properties,type:Vy[G.type],sortKey:Ve}),De&&(M[De.name]=!0),_e){const Pe=f.evaluate(le,{},a).join(","),Me=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(o.ai.vertical)>=0;for(const Ie of _e.sections)if(Ie.image)M[Ie.image.name]=!0;else{const Fe=so(_e.toString()),Ce=Ie.fontStack||Pe,we=L[Ce]=L[Ce]||{};this.calculateGlyphDependencies(Ie.text,we,Me,this.allowVerticalPlacement,Fe)}}}d.get("symbol-placement")==="line"&&(this.features=(function(G){const K={},ne={},J=[];let se=0;function le(Pe){J.push(G[Pe]),se++}function _e(Pe,Me,Ie){const Fe=ne[Pe];return delete ne[Pe],ne[Me]=Fe,J[Fe].geometry[0].pop(),J[Fe].geometry[0]=J[Fe].geometry[0].concat(Ie[0]),Fe}function De(Pe,Me,Ie){const Fe=K[Me];return delete K[Me],K[Pe]=Fe,J[Fe].geometry[0].shift(),J[Fe].geometry[0]=Ie[0].concat(J[Fe].geometry[0]),Fe}function Ve(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<G.length;Pe++){const Me=G[Pe],Ie=Me.geometry,Fe=Me.text?Me.text.toString():null;if(!Fe){le(Pe);continue}const Ce=Ve(Fe,Ie),we=Ve(Fe,Ie,!0);if(Ce in ne&&we in K&&ne[Ce]!==K[we]){const Xe=De(Ce,we,Ie),je=_e(Ce,we,J[Xe].geometry);delete K[Ce],delete ne[we],ne[Ve(Fe,J[je].geometry,!0)]=je,J[Xe].geometry=null}else Ce in ne?_e(Ce,we,Ie):we in K?De(Ce,we,Ie):(le(Pe),K[Ce]=se-1,ne[we]=se-1)}return J.filter((Pe=>Pe.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((G,K)=>G.sortKey-K.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 l=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:l},m<r.length-1&&(l+=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,l,d,f,m,y,b,S,C,M){const L=e.indexArray,R=e.layoutVertexArray,V=e.segments.prepareSegment(4*r.length,R,L,this.canOverlap?f.sortKey:void 0),G=this.glyphOffsetArray.length,K=V.vertexLength,ne=this.allowVerticalPlacement&&m===o.ai.vertical?Math.PI/2:0,J=f.text&&f.text.sections;for(let se=0;se<r.length;se++){const{tl:le,tr:_e,bl:De,br:Ve,tex:Pe,pixelOffsetTL:Me,pixelOffsetBR:Ie,minFontScaleX:Fe,minFontScaleY:Ce,glyphOffset:we,isSDF:Xe,sectionIndex:je}=r[se],ot=V.vertexLength,Lt=we[1];Jl(R,y.x,y.y,le.x,Lt+le.y,Pe.x,Pe.y,a,Xe,Me.x,Me.y,Fe,Ce),Jl(R,y.x,y.y,_e.x,Lt+_e.y,Pe.x+Pe.w,Pe.y,a,Xe,Ie.x,Me.y,Fe,Ce),Jl(R,y.x,y.y,De.x,Lt+De.y,Pe.x,Pe.y+Pe.h,a,Xe,Me.x,Ie.y,Fe,Ce),Jl(R,y.x,y.y,Ve.x,Lt+Ve.y,Pe.x+Pe.w,Pe.y+Pe.h,a,Xe,Ie.x,Ie.y,Fe,Ce),fu(e.dynamicLayoutVertexArray,y,ne),L.emplaceBack(ot,ot+1,ot+2),L.emplaceBack(ot+1,ot+2,ot+3),V.vertexLength+=4,V.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(we[0]),se!==r.length-1&&je===r[se+1].sectionIndex||e.programConfigurations.populatePaintArrays(R.length,f,f.index,{},M,J&&J[je])}e.placedSymbolArray.emplaceBack(y.x,y.y,G,this.glyphOffsetArray.length-G,K,b,S,y.segment,a?a[0]:0,a?a[1]:0,l[0],l[1],m,0,!1,0,C)}_addCollisionDebugVertex(e,r,a,l,d,f){return r.emplaceBack(0,0),e.emplaceBack(a.x,a.y,l,d,Math.round(f.x),Math.round(f.y))}addCollisionDebugVertices(e,r,a,l,d,f,m){const y=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),b=y.vertexLength,S=d.layoutVertexArray,C=d.collisionVertexArray,M=m.anchorX,L=m.anchorY;this._addCollisionDebugVertex(S,C,f,M,L,new ge(e,r)),this._addCollisionDebugVertex(S,C,f,M,L,new ge(a,r)),this._addCollisionDebugVertex(S,C,f,M,L,new ge(a,l)),this._addCollisionDebugVertex(S,C,f,M,L,new ge(e,l)),y.vertexLength+=4;const R=d.indexArray;R.emplaceBack(b,b+1),R.emplaceBack(b+1,b+2),R.emplaceBack(b+2,b+3),R.emplaceBack(b+3,b),y.primitiveLength+=4}addDebugCollisionBoxes(e,r,a,l){for(let d=e;d<r;d++){const f=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(f.x1,f.y1,f.x2,f.y2,l?this.textCollisionBox:this.iconCollisionBox,f.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new gu(Ht,Dp.members,ri),this.iconCollisionBox=new gu(Ht,Dp.members,ri);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,l,d,f,m,y,b){const S={};for(let C=r;C<a;C++){const M=e.get(C);S.textBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},S.textFeatureIndex=M.featureIndex;break}for(let C=l;C<d;C++){const M=e.get(C);S.verticalTextBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},S.verticalTextFeatureIndex=M.featureIndex;break}for(let C=f;C<m;C++){const M=e.get(C);S.iconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},S.iconFeatureIndex=M.featureIndex;break}for(let C=y;C<b;C++){const M=e.get(C);S.verticalIconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},S.verticalIconFeatureIndex=M.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),l=a.vertexStartIndex+4*a.numGlyphs;for(let d=a.vertexStartIndex;d<l;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),l=[],d=[],f=[];for(let m=0;m<this.symbolInstances.length;++m){f.push(m);const y=this.symbolInstances.get(m);l.push(0|Math.round(r*y.anchorX+a*y.anchorY)),d.push(y.featureIndex)}return f.sort(((m,y)=>l[m]-l[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(((l,d,f)=>{l>=0&&f.indexOf(l)===d&&this.addIndicesForPlacedSymbol(this.text,l)})),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 Kp,Yp;Re("SymbolBucket",Cs,{omit:["layers","collisionBoxArray","features","compareText"]}),Cs.MAX_GLYPHS=65535,Cs.addDynamicAttributes=fu;var _u={get paint(){return Yp=Yp||new Kt({"icon-opacity":new Ye(he.paint_symbol["icon-opacity"]),"icon-color":new Ye(he.paint_symbol["icon-color"]),"icon-halo-color":new Ye(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ye(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ye(he.paint_symbol["icon-halo-blur"]),"icon-translate":new Ge(he.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ge(he.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ye(he.paint_symbol["text-opacity"]),"text-color":new Ye(he.paint_symbol["text-color"],{runtimeType:Ii,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Ye(he.paint_symbol["text-halo-color"]),"text-halo-width":new Ye(he.paint_symbol["text-halo-width"]),"text-halo-blur":new Ye(he.paint_symbol["text-halo-blur"]),"text-translate":new Ge(he.paint_symbol["text-translate"]),"text-translate-anchor":new Ge(he.paint_symbol["text-translate-anchor"])})},get layout(){return Kp=Kp||new Kt({"symbol-placement":new Ge(he.layout_symbol["symbol-placement"]),"symbol-spacing":new Ge(he.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ge(he.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ye(he.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ge(he.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ge(he.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ge(he.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ge(he.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ge(he.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ge(he.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ye(he.layout_symbol["icon-size"]),"icon-text-fit":new Ge(he.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ge(he.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ye(he.layout_symbol["icon-image"]),"icon-rotate":new Ye(he.layout_symbol["icon-rotate"]),"icon-padding":new Ye(he.layout_symbol["icon-padding"]),"icon-keep-upright":new Ge(he.layout_symbol["icon-keep-upright"]),"icon-offset":new Ye(he.layout_symbol["icon-offset"]),"icon-anchor":new Ye(he.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ge(he.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ge(he.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ge(he.layout_symbol["text-rotation-alignment"]),"text-field":new Ye(he.layout_symbol["text-field"]),"text-font":new Ye(he.layout_symbol["text-font"]),"text-size":new Ye(he.layout_symbol["text-size"]),"text-max-width":new Ye(he.layout_symbol["text-max-width"]),"text-line-height":new Ge(he.layout_symbol["text-line-height"]),"text-letter-spacing":new Ye(he.layout_symbol["text-letter-spacing"]),"text-justify":new Ye(he.layout_symbol["text-justify"]),"text-radial-offset":new Ye(he.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ge(he.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ye(he.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ye(he.layout_symbol["text-anchor"]),"text-max-angle":new Ge(he.layout_symbol["text-max-angle"]),"text-writing-mode":new Ge(he.layout_symbol["text-writing-mode"]),"text-rotate":new Ye(he.layout_symbol["text-rotate"]),"text-padding":new Ge(he.layout_symbol["text-padding"]),"text-keep-upright":new Ge(he.layout_symbol["text-keep-upright"]),"text-transform":new Ye(he.layout_symbol["text-transform"]),"text-offset":new Ye(he.layout_symbol["text-offset"]),"text-allow-overlap":new Ge(he.layout_symbol["text-allow-overlap"]),"text-overlap":new Ge(he.layout_symbol["text-overlap"]),"text-ignore-placement":new Ge(he.layout_symbol["text-ignore-placement"]),"text-optional":new Ge(he.layout_symbol["text-optional"])})}};class Jp{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:Or,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}}Re("FormatSectionOverride",Jp,{omit:["defaultValue"]});class Ql extends dr{constructor(e){super(e,_u)}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 l=[];for(const d of a)l.indexOf(d)<0&&l.push(d);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,l){const d=this.layout.get(e).evaluate(r,{},a,l),f=this._unevaluatedLayout._values[e];return f.isDataDriven()||os(f.value)||!d?d:(function(m,y){return y.replace(/{([^{}]+)}/g,((b,S)=>m&&S in m?String(m[S]):""))})(r.properties,d)}createBucket(e){return new Cs(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of _u.paint.overridableProperties){if(!Ql.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new Jp(r),l=new eo(a,r.property.specification);let d=null;d=r.value.kind==="constant"||r.value.kind==="source"?new to("source",l):new cs("composite",l,r.value.zoomStops),this.paint._values[e]=new Ai(r.property,d,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&Ql.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),l=_u.paint.properties[r];let d=!1;const f=m=>{for(const y of m)if(l.overrides&&l.overrides.hasOverride(y))return void(d=!0)};if(a.value.kind==="constant"&&a.value.value instanceof xi)f(a.value.value.sections);else if(a.value.kind==="source"){const m=b=>{d||(b instanceof bn&&Ot(b.value)===j?f(b.value.sections):b instanceof ss?f(b.sections):b.eachChild(m))},y=a.value;y._styleExpression&&m(y._styleExpression.expression)}return d}}let Qp;var jy={get paint(){return Qp=Qp||new Kt({"background-color":new Ge(he.paint_background["background-color"]),"background-pattern":new _o(he.paint_background["background-pattern"]),"background-opacity":new Ge(he.paint_background["background-opacity"])})}};class qy extends dr{constructor(e){super(e,jy)}}let ed;var Zy={get paint(){return ed=ed||new Kt({"raster-opacity":new Ge(he.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ge(he.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ge(he.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ge(he.paint_raster["raster-brightness-max"]),"raster-saturation":new Ge(he.paint_raster["raster-saturation"]),"raster-contrast":new Ge(he.paint_raster["raster-contrast"]),"raster-resampling":new Ge(he.paint_raster["raster-resampling"]),"raster-fade-duration":new Ge(he.paint_raster["raster-fade-duration"])})}};class Gy extends dr{constructor(e){super(e,Zy)}}class Hy extends dr{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 Wy{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 yu=63710088e-1;class ca{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 ca(mn(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,l=e.lat*r,d=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return yu*Math.acos(Math.min(d,1))}static convert(e){if(e instanceof ca)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new ca(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new ca(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 td=2*Math.PI*yu;function id(i){return td*Math.cos(i*Math.PI/180)}function rd(i){return(180+i)/360}function nd(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function ad(i,e){return i/id(e)}function sd(i){return 360*i-180}function xu(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class ec{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=ca.convert(e);return new ec(rd(a.lng),nd(a.lat),ad(r,a.lat))}toLngLat(){return new ca(sd(this.x),xu(this.y))}toAltitude(){return this.z*id(xu(this.y))}meterInMercatorCoordinateUnits(){return 1/td*(e=xu(this.y),1/Math.cos(e*Math.PI/180));var e}}function od(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 vu{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=No(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 l=(f=this.y,m=this.z,y=od(256*(d=this.x),256*(f=Math.pow(2,m)-f-1),m),b=od(256*(d+1),256*(f+1),m),y[0]+","+y[1]+","+b[0]+","+b[1]);var d,f,m,y,b;const S=(function(C,M,L){let R,V="";for(let G=C;G>0;G--)R=1<<G-1,V+=(M&R?1:0)+(L&R?2:0);return V})(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,l)}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)*ei,(e.y*r-this.y)*ei)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ld{constructor(e,r){this.wrap=e,this.canonical=r,this.key=No(e,r.z,r.z,r.x,r.y)}}class xr{constructor(e,r,a,l,d){if(e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new vu(a,+l,+d),this.key=No(r,e,a,l,d)}clone(){return new xr(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 xr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new xr(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?No(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):No(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 xr(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,l=2*this.canonical.y;return[new xr(r,this.wrap,r,a,l),new xr(r,this.wrap,r,a+1,l),new xr(r,this.wrap,r,a,l+1),new xr(r,this.wrap,r,a+1,l+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 xr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new xr(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 ld(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new ec(e.x-this.wrap,e.y))}}function No(i,e,r,a,l){(i*=2)<0&&(i=-1*i-1);const d=1<<r;return(d*d*i+d*l+a).toString(36)+r.toString(36)+e.toString(36)}Re("CanonicalTileID",vu),Re("OverscaledTileID",xr,{omit:["posMatrix"]});class cd{constructor(e,r,a,l=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 Le(`"${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=l,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 b=0;b<y;b++)this.data[this._idx(-1,b)]=this.data[this._idx(0,b)],this.data[this._idx(y,b)]=this.data[this._idx(y-1,b)],this.data[this._idx(b,-1)]=this.data[this._idx(b,0)],this.data[this._idx(b,y)]=this.data[this._idx(b,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 b=0;b<y;b++)for(let S=0;S<y;S++){const C=this.get(b,S);C>this.max&&(this.max=C),C<this.min&&(this.min=C)}}get(e,r){const a=new Uint8Array(this.data.buffer),l=4*this._idx(e,r);return this.unpack(a[l],a[l+1],a[l+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 yr({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 l=r*this.dim,d=r*this.dim+this.dim,f=a*this.dim,m=a*this.dim+this.dim;switch(r){case-1:l=d-1;break;case 1:d=l+1}switch(a){case-1:f=m-1;break;case 1:m=f+1}const y=-r*this.dim,b=-a*this.dim;for(let S=f;S<m;S++)for(let C=l;C<d;C++)this.data[this._idx(C,S)]=e.data[this._idx(C+y,S+b)]}}Re("DEMData",cd);class ud{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 hd{constructor(e,r,a,l,d){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=l,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 pd{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ta(ei,16,0),this.grid3D=new ta(ei,16,0),this.featureIndexArray=new xe,this.promoteId=r}insert(e,r,a,l,d,f){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,d);const y=f?this.grid3D:this.grid;for(let b=0;b<r.length;b++){const S=r[b],C=[1/0,1/0,-1/0,-1/0];for(let M=0;M<S.length;M++){const L=S[M];C[0]=Math.min(C[0],L.x),C[1]=Math.min(C[1],L.y),C[2]=Math.max(C[2],L.x),C[3]=Math.max(C[3],L.y)}C[0]<ei&&C[1]<ei&&C[2]>=0&&C[3]>=0&&y.insert(m,C[0],C[1],C[2],C[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new sa.VectorTile(new lu(this.rawTileData)).layers,this.sourceLayerCoder=new ud(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,l){this.loadVTLayers();const d=e.params||{},f=ei/e.tileSize/e.scale,m=ro(d.filter),y=e.queryGeometry,b=e.queryPadding*f,S=fd(y),C=this.grid.query(S.minX-b,S.minY-b,S.maxX+b,S.maxY+b),M=fd(e.cameraQueryGeometry),L=this.grid3D.query(M.minX-b,M.minY-b,M.maxX+b,M.maxY+b,((G,K,ne,J)=>(function(se,le,_e,De,Ve){for(const Me of se)if(le<=Me.x&&_e<=Me.y&&De>=Me.x&&Ve>=Me.y)return!0;const Pe=[new ge(le,_e),new ge(le,Ve),new ge(De,Ve),new ge(De,_e)];if(se.length>2){for(const Me of Pe)if(vs(se,Me))return!0}for(let Me=0;Me<se.length-1;Me++)if(A_(se[Me],se[Me+1],Pe))return!0;return!1})(e.cameraQueryGeometry,G-b,K-b,ne+b,J+b)));for(const G of L)C.push(G);C.sort(Xy);const R={};let V;for(let G=0;G<C.length;G++){const K=C[G];if(K===V)continue;V=K;const ne=this.featureIndexArray.get(K);let J=null;this.loadMatchingFeature(R,ne.bucketIndex,ne.sourceLayerIndex,ne.featureIndex,m,d.layers,d.availableImages,r,a,l,((se,le,_e)=>(J||(J=za(se)),le.queryIntersectsFeature(y,se,_e,J,this.z,e.transform,f,e.pixelPosMatrix))))}return R}loadMatchingFeature(e,r,a,l,d,f,m,y,b,S,C){const M=this.bucketLayerIDs[r];if(f&&!(function(G,K){for(let ne=0;ne<G.length;ne++)if(K.indexOf(G[ne])>=0)return!0;return!1})(f,M))return;const L=this.sourceLayerCoder.decode(a),R=this.vtLayers[L].feature(l);if(d.needGeometry){const G=Da(R,!0);if(!d.filter(new zt(this.tileID.overscaledZ),G,this.tileID.canonical))return}else if(!d.filter(new zt(this.tileID.overscaledZ),R))return;const V=this.getId(R,L);for(let G=0;G<M.length;G++){const K=M[G];if(f&&f.indexOf(K)<0)continue;const ne=y[K];if(!ne)continue;let J={};V&&S&&(J=S.getState(ne.sourceLayer||"_geojsonTileLayer",V));const se=ii({},b[K]);se.paint=dd(se.paint,ne.paint,R,J,m),se.layout=dd(se.layout,ne.layout,R,J,m);const le=!C||C(R,ne,J);if(!le)continue;const _e=new hd(R,this.z,this.x,this.y,V);_e.layer=se;let De=e[K];De===void 0&&(De=e[K]=[]),De.push({featureIndex:l,feature:_e,intersectionZ:le})}}lookupSymbolFeatures(e,r,a,l,d,f,m,y){const b={};this.loadVTLayers();const S=ro(d);for(const C of e)this.loadMatchingFeature(b,a,l,C,S,f,m,y,r);return b}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 dd(i,e,r,a,l){return Mt(i,((d,f)=>{const m=e instanceof ys?e.get(f):null;return m&&m.evaluate?m.evaluate(r,a,l):m}))}function fd(i){let e=1/0,r=1/0,a=-1/0,l=-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),l=Math.max(l,d.y);return{minX:e,minY:r,maxX:a,maxY:l}}function Xy(i,e){return e-i}function md(i,e,r,a,l){const d=[];for(let f=0;f<i.length;f++){const m=i[f];let y;for(let b=0;b<m.length-1;b++){let S=m[b],C=m[b+1];S.x<e&&C.x<e||(S.x<e?S=new ge(e,S.y+(e-S.x)/(C.x-S.x)*(C.y-S.y))._round():C.x<e&&(C=new ge(e,S.y+(e-S.x)/(C.x-S.x)*(C.y-S.y))._round()),S.y<r&&C.y<r||(S.y<r?S=new ge(S.x+(r-S.y)/(C.y-S.y)*(C.x-S.x),r)._round():C.y<r&&(C=new ge(S.x+(r-S.y)/(C.y-S.y)*(C.x-S.x),r)._round()),S.x>=a&&C.x>=a||(S.x>=a?S=new ge(a,S.y+(a-S.x)/(C.x-S.x)*(C.y-S.y))._round():C.x>=a&&(C=new ge(a,S.y+(a-S.x)/(C.x-S.x)*(C.y-S.y))._round()),S.y>=l&&C.y>=l||(S.y>=l?S=new ge(S.x+(l-S.y)/(C.y-S.y)*(C.x-S.x),l)._round():C.y>=l&&(C=new ge(S.x+(l-S.y)/(C.y-S.y)*(C.x-S.x),l)._round()),y&&S.equals(y[y.length-1])||(y=[S],d.push(y)),y.push(C)))))}}return d}Re("FeatureIndex",pd,{omit:["rawTileData","sourceLayerCoder"]});class ua extends ge{constructor(e,r,a,l){super(e,r),this.angle=a,l!==void 0&&(this.segment=l)}clone(){return new ua(this.x,this.y,this.angle,this.segment)}}function gd(i,e,r,a,l){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 b=0;for(;m<r/2;){const S=i[f],C=i[f+1];if(!C)return!1;let M=i[f-1].angleTo(S)-S.angleTo(C);for(M=Math.abs((M+3*Math.PI)%(2*Math.PI)-Math.PI),y.push({distance:m,angleDelta:M}),b+=M;m-y[0].distance>a;)b-=y.shift().angleDelta;if(b>l)return!1;f++,m+=S.dist(C)}return!0}function _d(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function yd(i,e,r){return i?.6*e*r:0}function xd(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function Ky(i,e,r,a,l,d){const f=yd(r,l,d),m=xd(r,a)*d;let y=0;const b=_d(i)/2;for(let S=0;S<i.length-1;S++){const C=i[S],M=i[S+1],L=C.dist(M);if(y+L>b){const R=(b-y)/L,V=Wi.number(C.x,M.x,R),G=Wi.number(C.y,M.y,R),K=new ua(V,G,M.angleTo(C),S);return K._round(),!f||gd(i,K,m,f,e)?K:void 0}y+=L}}function Yy(i,e,r,a,l,d,f,m,y){const b=yd(a,d,f),S=xd(a,l),C=S*f,M=i[0].x===0||i[0].x===y||i[0].y===0||i[0].y===y;return e-C<e/4&&(e=C+e/4),vd(i,M?e/2*m%e:(S/2+2*d)*f*m%e,e,b,r,C,M,!1,y)}function vd(i,e,r,a,l,d,f,m,y){const b=d/2,S=_d(i);let C=0,M=e-r,L=[];for(let R=0;R<i.length-1;R++){const V=i[R],G=i[R+1],K=V.dist(G),ne=G.angleTo(V);for(;M+r<C+K;){M+=r;const J=(M-C)/K,se=Wi.number(V.x,G.x,J),le=Wi.number(V.y,G.y,J);if(se>=0&&se<y&&le>=0&&le<y&&M-b>=0&&M+b<=S){const _e=new ua(se,le,ne,R);_e._round(),a&&!gd(i,_e,d,a,l)||L.push(_e)}}C+=K}return m||L.length||f||(L=vd(i,C/2,r,a,l,d,f,!0,y)),L}Re("Anchor",ua);const ks=Qi;function bd(i,e,r,a){const l=[],d=i.image,f=d.pixelRatio,m=d.paddedRect.w-2*ks,y=d.paddedRect.h-2*ks,b=i.right-i.left,S=i.bottom-i.top,C=d.stretchX||[[0,m]],M=d.stretchY||[[0,y]],L=(Ie,Fe)=>Ie+Fe[1]-Fe[0],R=C.reduce(L,0),V=M.reduce(L,0),G=m-R,K=y-V;let ne=0,J=R,se=0,le=V,_e=0,De=G,Ve=0,Pe=K;if(d.content&&a){const Ie=d.content;ne=tc(C,0,Ie[0]),se=tc(M,0,Ie[1]),J=tc(C,Ie[0],Ie[2]),le=tc(M,Ie[1],Ie[3]),_e=Ie[0]-ne,Ve=Ie[1]-se,De=Ie[2]-Ie[0]-J,Pe=Ie[3]-Ie[1]-le}const Me=(Ie,Fe,Ce,we)=>{const Xe=ic(Ie.stretch-ne,J,b,i.left),je=rc(Ie.fixed-_e,De,Ie.stretch,R),ot=ic(Fe.stretch-se,le,S,i.top),Lt=rc(Fe.fixed-Ve,Pe,Fe.stretch,V),Bt=ic(Ce.stretch-ne,J,b,i.left),si=rc(Ce.fixed-_e,De,Ce.stretch,R),mr=ic(we.stretch-se,le,S,i.top),Ui=rc(we.fixed-Ve,Pe,we.stretch,V),ti=new ge(Xe,ot),_i=new ge(Bt,ot),wi=new ge(Bt,mr),$i=new ge(Xe,mr),ji=new ge(je/f,Lt/f),oi=new ge(si/f,Ui/f),li=e*Math.PI/180;if(li){const Ei=Math.sin(li),er=Math.cos(li),tr=[er,-Ei,Ei,er];ti._matMult(tr),_i._matMult(tr),$i._matMult(tr),wi._matMult(tr)}const ki=Ie.stretch+Ie.fixed,qi=Fe.stretch+Fe.fixed;return{tl:ti,tr:_i,bl:$i,br:wi,tex:{x:d.paddedRect.x+ks+ki,y:d.paddedRect.y+ks+qi,w:Ce.stretch+Ce.fixed-ki,h:we.stretch+we.fixed-qi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ji,pixelOffsetBR:oi,minFontScaleX:De/f/b,minFontScaleY:Pe/f/S,isSDF:r}};if(a&&(d.stretchX||d.stretchY)){const Ie=wd(C,G,R),Fe=wd(M,K,V);for(let Ce=0;Ce<Ie.length-1;Ce++){const we=Ie[Ce],Xe=Ie[Ce+1];for(let je=0;je<Fe.length-1;je++)l.push(Me(we,Fe[je],Xe,Fe[je+1]))}}else l.push(Me({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:y+1}));return l}function tc(i,e,r){let a=0;for(const l of i)a+=Math.max(e,Math.min(r,l[1]))-Math.max(e,Math.min(r,l[0]));return a}function wd(i,e,r){const a=[{fixed:-ks,stretch:0}];for(const[l,d]of i){const f=a[a.length-1];a.push({fixed:l-f.stretch,stretch:f.stretch}),a.push({fixed:l-f.stretch,stretch:f.stretch+(d-l)})}return a.push({fixed:e+ks,stretch:r}),a}function ic(i,e,r,a){return i/e*r+a}function rc(i,e,r,a){return i-e*r/a}class nc{constructor(e,r,a,l,d,f,m,y,b,S){if(this.boxStartIndex=e.length,b){let C=f.top,M=f.bottom;const L=f.collisionPadding;L&&(C-=L[1],M+=L[3]);let R=M-C;R>0&&(R=Math.max(10,R),this.circleDiameter=R)}else{let C=f.top*m-y[0],M=f.bottom*m+y[2],L=f.left*m-y[3],R=f.right*m+y[1];const V=f.collisionPadding;if(V&&(L-=V[0]*m,C-=V[1]*m,R+=V[2]*m,M+=V[3]*m),S){const G=new ge(L,C),K=new ge(R,C),ne=new ge(L,M),J=new ge(R,M),se=S*Math.PI/180;G._rotate(se),K._rotate(se),ne._rotate(se),J._rotate(se),L=Math.min(G.x,K.x,ne.x,J.x),R=Math.max(G.x,K.x,ne.x,J.x),C=Math.min(G.y,K.y,ne.y,J.y),M=Math.max(G.y,K.y,ne.y,J.y)}e.emplaceBack(r.x,r.y,L,C,R,M,a,l,d)}this.boxEndIndex=e.length}}class Jy{constructor(e=[],r=Qy){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,l=r[e];for(;e>0;){const d=e-1>>1,f=r[d];if(a(l,f)>=0)break;r[e]=f,e=d}r[e]=l}_down(e){const{data:r,compare:a}=this,l=this.length>>1,d=r[e];for(;e<l;){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 Qy(i,e){return i<e?-1:i>e?1:0}function ex(i,e=1,r=!1){let a=1/0,l=1/0,d=-1/0,f=-1/0;const m=i[0];for(let L=0;L<m.length;L++){const R=m[L];(!L||R.x<a)&&(a=R.x),(!L||R.y<l)&&(l=R.y),(!L||R.x>d)&&(d=R.x),(!L||R.y>f)&&(f=R.y)}const y=Math.min(d-a,f-l);let b=y/2;const S=new Jy([],tx);if(y===0)return new ge(a,l);for(let L=a;L<d;L+=y)for(let R=l;R<f;R+=y)S.push(new Es(L+b,R+b,b,i));let C=(function(L){let R=0,V=0,G=0;const K=L[0];for(let ne=0,J=K.length,se=J-1;ne<J;se=ne++){const le=K[ne],_e=K[se],De=le.x*_e.y-_e.x*le.y;V+=(le.x+_e.x)*De,G+=(le.y+_e.y)*De,R+=3*De}return new Es(V/R,G/R,0,L)})(i),M=S.length;for(;S.length;){const L=S.pop();(L.d>C.d||!C.d)&&(C=L,r&&console.log("found best %d after %d probes",Math.round(1e4*L.d)/1e4,M)),L.max-C.d<=e||(b=L.h/2,S.push(new Es(L.p.x-b,L.p.y-b,b,i)),S.push(new Es(L.p.x+b,L.p.y-b,b,i)),S.push(new Es(L.p.x-b,L.p.y+b,b,i)),S.push(new Es(L.p.x+b,L.p.y+b,b,i)),M+=4)}return r&&(console.log(`num probes: ${M}`),console.log(`best distance: ${C.d}`)),C.p}function tx(i,e){return e.max-i.max}function Es(i,e,r,a){this.p=new ge(i,e),this.h=r,this.d=(function(l,d){let f=!1,m=1/0;for(let y=0;y<d.length;y++){const b=d[y];for(let S=0,C=b.length,M=C-1;S<C;M=S++){const L=b[S],R=b[M];L.y>l.y!=R.y>l.y&&l.x<(R.x-L.x)*(l.y-L.y)/(R.y-L.y)+L.x&&(f=!f),m=Math.min(m,np(l,L,R))}}return(f?1:-1)*Math.sqrt(m)})(this.p,a),this.max=this.d+this.h*Math.SQRT2}var bi;o.aq=void 0,(bi=o.aq||(o.aq={}))[bi.center=1]="center",bi[bi.left=2]="left",bi[bi.right=3]="right",bi[bi.top=4]="top",bi[bi.bottom=5]="bottom",bi[bi["top-left"]=6]="top-left",bi[bi["top-right"]=7]="top-right",bi[bi["bottom-left"]=8]="bottom-left",bi[bi["bottom-right"]=9]="bottom-right";const ha=7,bu=Number.POSITIVE_INFINITY;function Sd(i,e){return e[1]!==bu?(function(r,a,l){let d=0,f=0;switch(a=Math.abs(a),l=Math.abs(l),r){case"top-right":case"top-left":case"top":f=l-ha;break;case"bottom-right":case"bottom-left":case"bottom":f=-l+ha}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 l=0,d=0;a<0&&(a=0);const f=a/Math.SQRT2;switch(r){case"top-right":case"top-left":d=f-ha;break;case"bottom-right":case"bottom-left":d=-f+ha;break;case"bottom":d=-a+ha;break;case"top":d=a-ha}switch(r){case"top-right":case"bottom-right":l=-f;break;case"top-left":case"bottom-left":l=f;break;case"left":l=a;break;case"right":l=-a}return[l,d]})(i,e[0])}function Td(i,e,r){var a;const l=i.layout,d=(a=l.get("text-variable-anchor-offset"))===null||a===void 0?void 0:a.evaluate(e,{},r);if(d){const m=d.values,y=[];for(let b=0;b<m.length;b+=2){const S=y[b]=m[b],C=m[b+1].map((M=>M*ai));S.startsWith("top")?C[1]-=ha:S.startsWith("bottom")&&(C[1]+=ha),y[b+1]=C}return new cr(y)}const f=l.get("text-variable-anchor");if(f){let m;m=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(e,{},r)*ai,bu]:l.get("text-offset").evaluate(e,{},r).map((b=>b*ai));const y=[];for(const b of f)y.push(b,Sd(b,m));return new cr(y)}return null}function wu(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 ix(i,e,r,a,l,d,f,m,y,b,S){let C=d.textMaxSize.evaluate(e,{});C===void 0&&(C=f);const M=i.layers[0].layout,L=M.get("icon-offset").evaluate(e,{},S),R=Ad(r.horizontal),V=f/24,G=i.tilePixelRatio*V,K=i.tilePixelRatio*C/24,ne=i.tilePixelRatio*m,J=i.tilePixelRatio*M.get("symbol-spacing"),se=M.get("text-padding")*i.tilePixelRatio,le=(function(we,Xe,je,ot=1){const Lt=we.get("icon-padding").evaluate(Xe,{},je),Bt=Lt&&Lt.values;return[Bt[0]*ot,Bt[1]*ot,Bt[2]*ot,Bt[3]*ot]})(M,e,S,i.tilePixelRatio),_e=M.get("text-max-angle")/180*Math.PI,De=M.get("text-rotation-alignment")!=="viewport"&&M.get("symbol-placement")!=="point",Ve=M.get("icon-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",Pe=M.get("symbol-placement"),Me=J/2,Ie=M.get("icon-text-fit");let Fe;a&&Ie!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Fe=Wp(a,r.vertical,Ie,M.get("icon-text-fit-padding"),L,V)),R&&(a=Wp(a,R,Ie,M.get("icon-text-fit-padding"),L,V)));const Ce=(we,Xe)=>{Xe.x<0||Xe.x>=ei||Xe.y<0||Xe.y>=ei||(function(je,ot,Lt,Bt,si,mr,Ui,ti,_i,wi,$i,ji,oi,li,ki,qi,Ei,er,tr,ci,ht,Mi,Si,ui,Lr){const Zr=je.addToLineVertexArray(ot,Lt);let Gr,Ln,Rr,vr,ir=0,Rn=0,$o=0,Md=0,Mu=-1,Pu=-1;const Fn={};let Pd=Mn("");if(je.allowVerticalPlacement&&Bt.vertical){const Pi=ti.layout.get("text-rotate").evaluate(ht,{},ui)+90;Rr=new nc(_i,ot,wi,$i,ji,Bt.vertical,oi,li,ki,Pi),Ui&&(vr=new nc(_i,ot,wi,$i,ji,Ui,Ei,er,ki,Pi))}if(si){const Pi=ti.layout.get("icon-rotate").evaluate(ht,{}),br=ti.layout.get("icon-text-fit")!=="none",Ra=bd(si,Pi,Si,br),Wr=Ui?bd(Ui,Pi,Si,br):void 0;Ln=new nc(_i,ot,wi,$i,ji,si,Ei,er,!1,Pi),ir=4*Ra.length;const Fa=je.iconSizeData;let dn=null;Fa.kind==="source"?(dn=[pn*ti.layout.get("icon-size").evaluate(ht,{})],dn[0]>la&&Le(`${je.layerIds[0]}: Value for "icon-size" is >= ${Oo}. Reduce your "icon-size".`)):Fa.kind==="composite"&&(dn=[pn*Mi.compositeIconSizes[0].evaluate(ht,{},ui),pn*Mi.compositeIconSizes[1].evaluate(ht,{},ui)],(dn[0]>la||dn[1]>la)&&Le(`${je.layerIds[0]}: Value for "icon-size" is >= ${Oo}. Reduce your "icon-size".`)),je.addSymbols(je.icon,Ra,dn,ci,tr,ht,o.ai.none,ot,Zr.lineStartIndex,Zr.lineLength,-1,ui),Mu=je.icon.placedSymbolArray.length-1,Wr&&(Rn=4*Wr.length,je.addSymbols(je.icon,Wr,dn,ci,tr,ht,o.ai.vertical,ot,Zr.lineStartIndex,Zr.lineLength,-1,ui),Pu=je.icon.placedSymbolArray.length-1)}const zd=Object.keys(Bt.horizontal);for(const Pi of zd){const br=Bt.horizontal[Pi];if(!Gr){Pd=Mn(br.text);const Wr=ti.layout.get("text-rotate").evaluate(ht,{},ui);Gr=new nc(_i,ot,wi,$i,ji,br,oi,li,ki,Wr)}const Ra=br.positionedLines.length===1;if($o+=Id(je,ot,br,mr,ti,ki,ht,qi,Zr,Bt.vertical?o.ai.horizontal:o.ai.horizontalOnly,Ra?zd:[Pi],Fn,Mu,Mi,ui),Ra)break}Bt.vertical&&(Md+=Id(je,ot,Bt.vertical,mr,ti,ki,ht,qi,Zr,o.ai.vertical,["vertical"],Fn,Pu,Mi,ui));const ax=Gr?Gr.boxStartIndex:je.collisionBoxArray.length,sx=Gr?Gr.boxEndIndex:je.collisionBoxArray.length,ox=Rr?Rr.boxStartIndex:je.collisionBoxArray.length,lx=Rr?Rr.boxEndIndex:je.collisionBoxArray.length,cx=Ln?Ln.boxStartIndex:je.collisionBoxArray.length,ux=Ln?Ln.boxEndIndex:je.collisionBoxArray.length,hx=vr?vr.boxStartIndex:je.collisionBoxArray.length,px=vr?vr.boxEndIndex:je.collisionBoxArray.length;let Hr=-1;const sc=(Pi,br)=>Pi&&Pi.circleDiameter?Math.max(Pi.circleDiameter,br):br;Hr=sc(Gr,Hr),Hr=sc(Rr,Hr),Hr=sc(Ln,Hr),Hr=sc(vr,Hr);const Dd=Hr>-1?1:0;Dd&&(Hr*=Lr/ai),je.glyphOffsetArray.length>=Cs.MAX_GLYPHS&&Le("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),ht.sortKey!==void 0&&je.addToSortKeyRanges(je.symbolInstances.length,ht.sortKey);const dx=Td(ti,ht,ui),[fx,mx]=(function(Pi,br){const Ra=Pi.length,Wr=br==null?void 0:br.values;if((Wr==null?void 0:Wr.length)>0)for(let Fa=0;Fa<Wr.length;Fa+=2){const dn=Wr[Fa+1];Pi.emplaceBack(o.aq[Wr[Fa]],dn[0],dn[1])}return[Ra,Pi.length]})(je.textAnchorOffsets,dx);je.symbolInstances.emplaceBack(ot.x,ot.y,Fn.right>=0?Fn.right:-1,Fn.center>=0?Fn.center:-1,Fn.left>=0?Fn.left:-1,Fn.vertical||-1,Mu,Pu,Pd,ax,sx,ox,lx,cx,ux,hx,px,wi,$o,Md,ir,Rn,Dd,0,oi,Hr,fx,mx)})(i,Xe,we,r,a,l,Fe,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,G,[se,se,se,se],De,y,ne,le,Ve,L,e,d,b,S,f)};if(Pe==="line")for(const we of md(e.geometry,0,0,ei,ei)){const Xe=Yy(we,J,_e,r.vertical||R,a,24,K,i.overscaling,ei);for(const je of Xe)R&&rx(i,R.text,Me,je)||Ce(we,je)}else if(Pe==="line-center"){for(const we of e.geometry)if(we.length>1){const Xe=Ky(we,_e,r.vertical||R,a,24,K);Xe&&Ce(we,Xe)}}else if(e.type==="Polygon")for(const we of eu(e.geometry,0)){const Xe=ex(we,16);Ce(we[0],new ua(Xe.x,Xe.y,0))}else if(e.type==="LineString")for(const we of e.geometry)Ce(we,new ua(we[0].x,we[0].y,0));else if(e.type==="Point")for(const we of e.geometry)for(const Xe of we)Ce([Xe],new ua(Xe.x,Xe.y,0))}function Id(i,e,r,a,l,d,f,m,y,b,S,C,M,L,R){const V=(function(ne,J,se,le,_e,De,Ve,Pe){const Me=le.layout.get("text-rotate").evaluate(De,{})*Math.PI/180,Ie=[];for(const Fe of J.positionedLines)for(const Ce of Fe.positionedGlyphs){if(!Ce.rect)continue;const we=Ce.rect||{};let Xe=Up+1,je=!0,ot=1,Lt=0;const Bt=(_e||Pe)&&Ce.vertical,si=Ce.metrics.advance*Ce.scale/2;if(Pe&&J.verticalizable&&(Lt=Fe.lineOffset/2-(Ce.imageName?-(ai-Ce.metrics.width*Ce.scale)/2:(Ce.scale-1)*ai)),Ce.imageName){const ci=Ve[Ce.imageName];je=ci.sdf,ot=ci.pixelRatio,Xe=Qi/ot}const mr=_e?[Ce.x+si,Ce.y]:[0,0];let Ui=_e?[0,0]:[Ce.x+si+se[0],Ce.y+se[1]-Lt],ti=[0,0];Bt&&(ti=Ui,Ui=[0,0]);const _i=Ce.metrics.isDoubleResolution?2:1,wi=(Ce.metrics.left-Xe)*Ce.scale-si+Ui[0],$i=(-Ce.metrics.top-Xe)*Ce.scale+Ui[1],ji=wi+we.w/_i*Ce.scale/ot,oi=$i+we.h/_i*Ce.scale/ot,li=new ge(wi,$i),ki=new ge(ji,$i),qi=new ge(wi,oi),Ei=new ge(ji,oi);if(Bt){const ci=new ge(-si,si-Fo),ht=-Math.PI/2,Mi=ai/2-si,Si=new ge(5-Fo-Mi,-(Ce.imageName?Mi:0)),ui=new ge(...ti);li._rotateAround(ht,ci)._add(Si)._add(ui),ki._rotateAround(ht,ci)._add(Si)._add(ui),qi._rotateAround(ht,ci)._add(Si)._add(ui),Ei._rotateAround(ht,ci)._add(Si)._add(ui)}if(Me){const ci=Math.sin(Me),ht=Math.cos(Me),Mi=[ht,-ci,ci,ht];li._matMult(Mi),ki._matMult(Mi),qi._matMult(Mi),Ei._matMult(Mi)}const er=new ge(0,0),tr=new ge(0,0);Ie.push({tl:li,tr:ki,bl:qi,br:Ei,tex:we,writingMode:J.writingMode,glyphOffset:mr,sectionIndex:Ce.sectionIndex,isSDF:je,pixelOffsetTL:er,pixelOffsetBR:tr,minFontScaleX:0,minFontScaleY:0})}return Ie})(0,r,m,l,d,f,a,i.allowVerticalPlacement),G=i.textSizeData;let K=null;G.kind==="source"?(K=[pn*l.layout.get("text-size").evaluate(f,{})],K[0]>la&&Le(`${i.layerIds[0]}: Value for "text-size" is >= ${Oo}. Reduce your "text-size".`)):G.kind==="composite"&&(K=[pn*L.compositeTextSizes[0].evaluate(f,{},R),pn*L.compositeTextSizes[1].evaluate(f,{},R)],(K[0]>la||K[1]>la)&&Le(`${i.layerIds[0]}: Value for "text-size" is >= ${Oo}. Reduce your "text-size".`)),i.addSymbols(i.text,V,K,m,d,f,b,e,y.lineStartIndex,y.lineLength,M,R);for(const ne of S)C[ne]=i.text.placedSymbolArray.length-1;return 4*V.length}function Ad(i){for(const e in i)return i[e];return null}function rx(i,e,r,a){const l=i.compareText;if(e in l){const d=l[e];for(let f=d.length-1;f>=0;f--)if(a.dist(d[f])<r)return!0}else l[e]=[];return l[e].push(a),!1}const Cd=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Su{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 l=a>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const d=Cd[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 Su(m,f,d,e)}constructor(e,r=64,a=Float64Array,l){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=Cd.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}.`);l&&l instanceof ArrayBuffer?(this.data=l,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 Tu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,a,l){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],b=[];for(;y.length;){const S=y.pop()||0,C=y.pop()||0,M=y.pop()||0;if(C-M<=m){for(let G=M;G<=C;G++){const K=f[2*G],ne=f[2*G+1];K>=e&&K<=a&&ne>=r&&ne<=l&&b.push(d[G])}continue}const L=M+C>>1,R=f[2*L],V=f[2*L+1];R>=e&&R<=a&&V>=r&&V<=l&&b.push(d[L]),(S===0?e<=R:r<=V)&&(y.push(M),y.push(L-1),y.push(1-S)),(S===0?a>=R:l>=V)&&(y.push(L+1),y.push(C),y.push(1-S))}return b}within(e,r,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:d,nodeSize:f}=this,m=[0,l.length-1,0],y=[],b=a*a;for(;m.length;){const S=m.pop()||0,C=m.pop()||0,M=m.pop()||0;if(C-M<=f){for(let G=M;G<=C;G++)Ed(d[2*G],d[2*G+1],e,r)<=b&&y.push(l[G]);continue}const L=M+C>>1,R=d[2*L],V=d[2*L+1];Ed(R,V,e,r)<=b&&y.push(l[L]),(S===0?e-a<=R:r-a<=V)&&(m.push(M),m.push(L-1),m.push(1-S)),(S===0?e+a>=R:r+a>=V)&&(m.push(L+1),m.push(C),m.push(1-S))}return y}}function Tu(i,e,r,a,l,d){if(l-a<=r)return;const f=a+l>>1;kd(i,e,f,a,l,d),Tu(i,e,r,a,f-1,1-d),Tu(i,e,r,f+1,l,1-d)}function kd(i,e,r,a,l,d){for(;l>a;){if(l-a>600){const b=l-a+1,S=r-a+1,C=Math.log(b),M=.5*Math.exp(2*C/3),L=.5*Math.sqrt(C*M*(b-M)/b)*(S-b/2<0?-1:1);kd(i,e,r,Math.max(a,Math.floor(r-S*M/b+L)),Math.min(l,Math.floor(r+(b-S)*M/b+L)),d)}const f=e[2*r+d];let m=a,y=l;for(Vo(i,e,a,r),e[2*l+d]>f&&Vo(i,e,a,l);m<y;){for(Vo(i,e,m,y),m++,y--;e[2*m+d]<f;)m++;for(;e[2*y+d]>f;)y--}e[2*a+d]===f?Vo(i,e,a,y):(y++,Vo(i,e,y,l)),y<=r&&(a=y+1),r<=y&&(l=y-1)}}function Vo(i,e,r,a){Iu(i,r,a),Iu(e,2*r,2*a),Iu(e,2*r+1,2*a+1)}function Iu(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}function Ed(i,e,r,a){const l=i-r,d=e-a;return l*l+d*d}var Au;o.bh=void 0,(Au=o.bh||(o.bh={})).create="create",Au.load="load",Au.fullLoad="fullLoad";let ac=null,Uo=[];const Cu=1e3/60,ku="loadTime",Eu="fullLoadTime",nx={mark(i){performance.mark(i)},frame(i){const e=i;ac!=null&&Uo.push(e-ac),ac=e},clearMetrics(){ac=null,Uo=[],performance.clearMeasures(ku),performance.clearMeasures(Eu);for(const i in o.bh)performance.clearMarks(o.bh[i])},getPerformanceMetrics(){performance.measure(ku,o.bh.create,o.bh.load),performance.measure(Eu,o.bh.create,o.bh.fullLoad);const i=performance.getEntriesByName(ku)[0].duration,e=performance.getEntriesByName(Eu)[0].duration,r=Uo.length,a=1/(Uo.reduce(((d,f)=>d+f),0)/r/1e3),l=Uo.filter((d=>d>Cu)).reduce(((d,f)=>d+(f-Cu)/Cu),0);return{loadTime:i,fullLoadTime:e,fps:a,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};o.$=function(i,e,r){var a,l,d,f,m,y,b,S,C,M,L,R,V=r[0],G=r[1],K=r[2];return e===i?(i[12]=e[0]*V+e[4]*G+e[8]*K+e[12],i[13]=e[1]*V+e[5]*G+e[9]*K+e[13],i[14]=e[2]*V+e[6]*G+e[10]*K+e[14],i[15]=e[3]*V+e[7]*G+e[11]*K+e[15]):(l=e[1],d=e[2],f=e[3],m=e[4],y=e[5],b=e[6],S=e[7],C=e[8],M=e[9],L=e[10],R=e[11],i[0]=a=e[0],i[1]=l,i[2]=d,i[3]=f,i[4]=m,i[5]=y,i[6]=b,i[7]=S,i[8]=C,i[9]=M,i[10]=L,i[11]=R,i[12]=a*V+m*G+C*K+e[12],i[13]=l*V+y*G+M*K+e[13],i[14]=d*V+b*G+L*K+e[14],i[15]=f*V+S*G+R*K+e[15]),i},o.A=bs,o.B=Wi,o.C=class{constructor(i,e,r){this.receive=a=>{const l=a.data,d=l.id;if(d&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type==="<cancel>"){delete this.tasks[d];const f=this.cancelCallbacks[d];delete this.cancelCallbacks[d],f&&f()}else $t()||l.mustQueue?(this.tasks[d]=l,this.taskQueue.push(d),this.invoker.trigger()):this.processTask(d,l)},this.process=()=>{if(!this.taskQueue.length)return;const a=this.taskQueue.shift(),l=this.tasks[a];delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),l&&this.processTask(a,l)},this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new Wy(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=$t()?i:window}send(i,e,r,a,l=!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:l,sourceMapId:this.mapId,data:cn(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(ia(e.error)):r(null,ia(e.data)))}else{let r=!1;const a=[],l=e.hasCallback?(m,y)=>{r=!0,delete this.cancelCallbacks[i];const b={id:i,type:"<response>",sourceMapId:this.mapId,error:m?cn(m):null,data:cn(y,a)};this.target.postMessage(b,{transfer:a})}:m=>{r=!0};let d=null;const f=ia(e.data);if(this.parent[e.type])d=this.parent[e.type](e.sourceMapId,f,l);else if("getWorkerSource"in this.parent){const m=e.type.split(".");d=this.parent.getWorkerSource(e.sourceMapId,m[0],f.source)[m[1]](f,l)}else l(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)}},o.D=Ge,o.E=yn,o.F=function(i,e){const r={};for(let a=0;a<e.length;a++){const l=e[a];l in i&&(r[l]=i[l])}return r},o.G=rd,o.H=nd,o.I=uu,o.J=He,o.K=Et,o.L=ca,o.M=da,o.N=ei,o.O=xr,o.P=ge,o.Q=Ut,o.R=yr,o.S=Dt,o.T=Ll,o.U=ec,o.V=class extends kn{},o.W=vu,o.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 l=window.document.createElement("source");Fr(i[a])||(r.crossOrigin="Anonymous"),l.src=i[a],r.appendChild(l)}return{cancel:()=>{}}},o.Y=Ae,o.Z=function(){var i=new bs(16);return bs!=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},o._=te,o.a=Sr,o.a$=class extends D{},o.a0=function(i,e,r){var a=r[0],l=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]*l,i[5]=e[5]*l,i[6]=e[6]*l,i[7]=e[7]*l,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},o.a1=lp,o.a2=function(){return Vn++},o.a3=q,o.a4=Cs,o.a5=function(){Yi.isLoading()||Yi.isLoaded()||mo()!=="deferred"||Dl()},o.a6=ro,o.a7=Da,o.a8=zt,o.a9=hd,o.aA=Ca,o.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]=or(i[r],e[i[r].ref]));return i},o.aC=function(i){if(i.type==="custom")return new Hy(i);switch(i.type){case"background":return new qy(i);case"circle":return new E_(i);case"fill":return new X_(i);case"fill-extrusion":return new uy(i);case"heatmap":return new P_(i);case"hillshade":return new D_(i);case"line":return new yy(i);case"raster":return new Gy(i);case"symbol":return new Ql(i)}},o.aD=Gi,o.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={},l=[];(function(f,m,y,b){let S;for(S in m=m||{},f=f||{})Object.prototype.hasOwnProperty.call(f,S)&&(Object.prototype.hasOwnProperty.call(m,S)||qn(S,y,b));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"&&qa(f,m,S)?y.push({command:_t.setGeoJSONSourceData,args:[S,m[S].data]}):Br(S,m,y,b)):Ir(S,m,y))})(i.sources,e.sources,l,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(l),(function(f,m,y){m=m||[];const b=(f=f||[]).map(rn),S=m.map(rn),C=f.reduce(xn,{}),M=m.reduce(xn,{}),L=b.slice(),R=Object.create(null);let V,G,K,ne,J,se,le;for(V=0,G=0;V<b.length;V++)K=b[V],Object.prototype.hasOwnProperty.call(M,K)?G++:(y.push({command:_t.removeLayer,args:[K]}),L.splice(L.indexOf(K,G),1));for(V=0,G=0;V<S.length;V++)K=S[S.length-1-V],L[L.length-1-V]!==K&&(Object.prototype.hasOwnProperty.call(C,K)?(y.push({command:_t.removeLayer,args:[K]}),L.splice(L.lastIndexOf(K,L.length-G),1)):G++,se=L[L.length-V],y.push({command:_t.addLayer,args:[M[K],se]}),L.splice(L.length-V,0,K),R[K]=!0);for(V=0;V<S.length;V++)if(K=S[V],ne=C[K],J=M[K],!R[K]&&!At(ne,J))if(At(ne.source,J.source)&&At(ne["source-layer"],J["source-layer"])&&At(ne.type,J.type)){for(le in Zn(ne.layout,J.layout,y,K,null,_t.setLayoutProperty),Zn(ne.paint,J.paint,y,K,null,_t.setPaintProperty),At(ne.filter,J.filter)||y.push({command:_t.setFilter,args:[K,J.filter]}),At(ne.minzoom,J.minzoom)&&At(ne.maxzoom,J.maxzoom)||y.push({command:_t.setLayerZoomRange,args:[K,J.minzoom,J.maxzoom]}),ne)Object.prototype.hasOwnProperty.call(ne,le)&&le!=="layout"&&le!=="paint"&&le!=="filter"&&le!=="metadata"&&le!=="minzoom"&&le!=="maxzoom"&&(le.indexOf("paint.")===0?Zn(ne[le],J[le],y,K,le.slice(6),_t.setPaintProperty):At(ne[le],J[le])||y.push({command:_t.setLayerProperty,args:[K,le,J[le]]}));for(le in J)Object.prototype.hasOwnProperty.call(J,le)&&!Object.prototype.hasOwnProperty.call(ne,le)&&le!=="layout"&&le!=="paint"&&le!=="filter"&&le!=="metadata"&&le!=="minzoom"&&le!=="maxzoom"&&(le.indexOf("paint.")===0?Zn(ne[le],J[le],y,K,le.slice(6),_t.setPaintProperty):At(ne[le],J[le])||y.push({command:_t.setLayerProperty,args:[K,le,J[le]]}))}else y.push({command:_t.removeLayer,args:[K]}),se=L[L.lastIndexOf(K)+1],y.push({command:_t.addLayer,args:[J,se]})})(d,e.layers,r)}catch(a){console.warn("Unable to compute style diff:",a),r=[{command:_t.setStyle,args:[e]}]}return r},o.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},o.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},o.aH=Mt,o.aI=Yr,o.aJ=ka,o.aK=function(i){return i({pluginStatus:Oi,pluginURL:un}),ka.on("pluginStateChange",i),i},o.aL=class extends Pn{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},o.aM=xs,o.aN=class extends Pn{constructor(i,e){super(i,e),this.current=$c}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}}},o.aO=Ol,o.aP=class extends Pn{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]))}},o.aQ=class extends Pn{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]))}},o.aR=Nl,o.aS=function(i,e,r,a,l,d,f){var m=1/(e-r),y=1/(a-l),b=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*b,i[11]=0,i[12]=(e+r)*m,i[13]=(l+a)*y,i[14]=(f+d)*b,i[15]=1,i},o.aT=wt,o.aU=k_,o.aV=class extends s{},o.aW=wy,o.aX=class extends p{},o.aY=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},o.aZ=dp,o.a_=Se,o.aa=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,a,l,d)=>{const f=l||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},o.ab=function(i,e){const r=[];for(const a in i)a in e||r.push(a);return r},o.ac=function(i){if(Rt==null){const e=i.navigator?i.navigator.userAgent:null;Rt=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Rt},o.ad=ar,o.ae=function(i,e,r){var a=Math.sin(r),l=Math.cos(r),d=e[0],f=e[1],m=e[2],y=e[3],b=e[4],S=e[5],C=e[6],M=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*l+b*a,i[1]=f*l+S*a,i[2]=m*l+C*a,i[3]=y*l+M*a,i[4]=b*l-d*a,i[5]=S*l-f*a,i[6]=C*l-m*a,i[7]=M*l-y*a,i},o.af=function(i){var e=new bs(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},o.ag=jl,o.ah=function(i,e){let r=0,a=0;if(i.kind==="constant")a=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:d,maxZoom:f}=i,m=l?ar(Xi.interpolationFactor(l,e,d,f),0,1):0;i.kind==="camera"?a=Wi.number(i.minSize,i.maxSize,m):r=m}return{uSizeT:r,uSize:a}},o.aj=function(i,{uSize:e,uSizeT:r},{lowerSize:a,upperSize:l}){return i.kind==="source"?a/pn:i.kind==="composite"?Wi.number(a/pn,l/pn,r):e},o.ak=fu,o.al=function(i,e,r,a){const l=e.y-i.y,d=e.x-i.x,f=a.y-r.y,m=a.x-r.x,y=f*d-m*l;if(y===0)return null;const b=(m*(i.y-r.y)-f*(i.x-r.x))/y;return new ge(i.x+b*d,i.y+b*l)},o.am=md,o.an=ip,o.ao=Hc,o.ap=ai,o.ar=du,o.as=function(i,e){var r=e[0],a=e[1],l=e[2],d=e[3],f=e[4],m=e[5],y=e[6],b=e[7],S=e[8],C=e[9],M=e[10],L=e[11],R=e[12],V=e[13],G=e[14],K=e[15],ne=r*m-a*f,J=r*y-l*f,se=r*b-d*f,le=a*y-l*m,_e=a*b-d*m,De=l*b-d*y,Ve=S*V-C*R,Pe=S*G-M*R,Me=S*K-L*R,Ie=C*G-M*V,Fe=C*K-L*V,Ce=M*K-L*G,we=ne*Ce-J*Fe+se*Ie+le*Me-_e*Pe+De*Ve;return we?(i[0]=(m*Ce-y*Fe+b*Ie)*(we=1/we),i[1]=(l*Fe-a*Ce-d*Ie)*we,i[2]=(V*De-G*_e+K*le)*we,i[3]=(M*_e-C*De-L*le)*we,i[4]=(y*Me-f*Ce-b*Pe)*we,i[5]=(r*Ce-l*Me+d*Pe)*we,i[6]=(G*se-R*De-K*J)*we,i[7]=(S*De-M*se+L*J)*we,i[8]=(f*Fe-m*Me+b*Ve)*we,i[9]=(a*Me-r*Fe-d*Ve)*we,i[10]=(R*_e-V*se+K*ne)*we,i[11]=(C*se-S*_e-L*ne)*we,i[12]=(m*Pe-f*Ie-y*Ve)*we,i[13]=(r*Ie-a*Pe+l*Ve)*we,i[14]=(V*J-R*le-G*ne)*we,i[15]=(S*le-C*J+M*ne)*we,i):null},o.at=wu,o.au=pu,o.av=Su,o.aw=function(){const i={},e=he.$version;for(const r in he.$root){const a=he.$root[r];if(a.required){let l=null;l=r==="version"?e:a.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},o.ax=_t,o.ay=El,o.az=_r,o.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.`))}))},o.b0=mi,o.b1=function(i,e){var r=i[0],a=i[1],l=i[2],d=i[3],f=i[4],m=i[5],y=i[6],b=i[7],S=i[8],C=i[9],M=i[10],L=i[11],R=i[12],V=i[13],G=i[14],K=i[15],ne=e[0],J=e[1],se=e[2],le=e[3],_e=e[4],De=e[5],Ve=e[6],Pe=e[7],Me=e[8],Ie=e[9],Fe=e[10],Ce=e[11],we=e[12],Xe=e[13],je=e[14],ot=e[15];return Math.abs(r-ne)<=Vi*Math.max(1,Math.abs(r),Math.abs(ne))&&Math.abs(a-J)<=Vi*Math.max(1,Math.abs(a),Math.abs(J))&&Math.abs(l-se)<=Vi*Math.max(1,Math.abs(l),Math.abs(se))&&Math.abs(d-le)<=Vi*Math.max(1,Math.abs(d),Math.abs(le))&&Math.abs(f-_e)<=Vi*Math.max(1,Math.abs(f),Math.abs(_e))&&Math.abs(m-De)<=Vi*Math.max(1,Math.abs(m),Math.abs(De))&&Math.abs(y-Ve)<=Vi*Math.max(1,Math.abs(y),Math.abs(Ve))&&Math.abs(b-Pe)<=Vi*Math.max(1,Math.abs(b),Math.abs(Pe))&&Math.abs(S-Me)<=Vi*Math.max(1,Math.abs(S),Math.abs(Me))&&Math.abs(C-Ie)<=Vi*Math.max(1,Math.abs(C),Math.abs(Ie))&&Math.abs(M-Fe)<=Vi*Math.max(1,Math.abs(M),Math.abs(Fe))&&Math.abs(L-Ce)<=Vi*Math.max(1,Math.abs(L),Math.abs(Ce))&&Math.abs(R-we)<=Vi*Math.max(1,Math.abs(R),Math.abs(we))&&Math.abs(V-Xe)<=Vi*Math.max(1,Math.abs(V),Math.abs(Xe))&&Math.abs(G-je)<=Vi*Math.max(1,Math.abs(G),Math.abs(je))&&Math.abs(K-ot)<=Vi*Math.max(1,Math.abs(K),Math.abs(ot))},o.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},o.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},o.b4=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},o.b5=mn,o.b6=ld,o.b7=ad,o.b8=function(i,e,r,a,l){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,l!=null&&l!==1/0?(i[10]=(l+a)*(d=1/(a-l)),i[14]=2*l*a*d):(i[10]=-1,i[14]=-2*a),i},o.b9=function(i,e,r){var a=Math.sin(r),l=Math.cos(r),d=e[4],f=e[5],m=e[6],y=e[7],b=e[8],S=e[9],C=e[10],M=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*l+b*a,i[5]=f*l+S*a,i[6]=m*l+C*a,i[7]=y*l+M*a,i[8]=b*l-d*a,i[9]=S*l-f*a,i[10]=C*l-m*a,i[11]=M*l-y*a,i},o.bA=ve,o.bB=Lp,o.bC=ls,o.bD=Yi,o.ba=Di,o.bb=Kr,o.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},o.bd=class extends Pa{},o.be=yu,o.bf=sd,o.bg=nx,o.bi=Jr,o.bj=function(i,e,r=!1){if(Oi===co||Oi===uo||Oi===ho)throw new Error("setRTLTextPlugin cannot be called multiple times.");un=Un.resolveURL(i),Oi=co,po=e,fo(),r||Dl()},o.bk=mo,o.bl=function(i,e){const r={};for(let l=0;l<i.length;l++){const d=e&&e[i[l].id]||ps(i[l]);e&&(e[i[l].id]=d);let f=r[d];f||(f=r[d]=[]),f.push(i[l])}const a=[];for(const l in r)a.push(r[l]);return a},o.bm=Re,o.bn=ud,o.bo=pd,o.bp=jp,o.bq=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=ei/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0],r=e.layout,a=e._unevaluatedLayout._values,l={layoutIconSize:a["icon-size"].possiblyEvaluate(new zt(i.bucket.zoom+1),i.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new zt(i.bucket.zoom+1),i.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new zt(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:b,maxZoom:S}=i.bucket.textSizeData;l.compositeTextSizes=[a["text-size"].possiblyEvaluate(new zt(b),i.canonical),a["text-size"].possiblyEvaluate(new zt(S),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:b,maxZoom:S}=i.bucket.iconSizeData;l.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new zt(b),i.canonical),a["icon-size"].possiblyEvaluate(new zt(S),i.canonical)]}const d=r.get("text-line-height")*ai,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 b of i.bucket.features){const S=r.get("text-font").evaluate(b,{},i.canonical).join(","),C=y.evaluate(b,{},i.canonical),M=l.layoutTextSize.evaluate(b,{},i.canonical),L=l.layoutIconSize.evaluate(b,{},i.canonical),R={horizontal:{},vertical:void 0},V=b.text;let G,K=[0,0];if(V){const se=V.toString(),le=r.get("text-letter-spacing").evaluate(b,{},i.canonical)*ai,_e=oo(se)?le:0,De=r.get("text-anchor").evaluate(b,{},i.canonical),Ve=Td(e,b,i.canonical);if(!Ve){const Ce=r.get("text-radial-offset").evaluate(b,{},i.canonical);K=Ce?Sd(De,[Ce*ai,bu]):r.get("text-offset").evaluate(b,{},i.canonical).map((we=>we*ai))}let Pe=f?"center":r.get("text-justify").evaluate(b,{},i.canonical);const Me=r.get("symbol-placement"),Ie=Me==="point"?r.get("text-max-width").evaluate(b,{},i.canonical)*ai:0,Fe=()=>{i.bucket.allowVerticalPlacement&&so(se)&&(R.vertical=Kl(V,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,"left",_e,K,o.ai.vertical,!0,Me,M,C))};if(!f&&Ve){const Ce=new Set;if(Pe==="auto")for(let Xe=0;Xe<Ve.values.length;Xe+=2)Ce.add(wu(Ve.values[Xe]));else Ce.add(Pe);let we=!1;for(const Xe of Ce)if(!R.horizontal[Xe])if(we)R.horizontal[Xe]=R.horizontal[0];else{const je=Kl(V,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,"center",Xe,_e,K,o.ai.horizontal,!1,Me,M,C);je&&(R.horizontal[Xe]=je,we=je.positionedLines.length===1)}Fe()}else{Pe==="auto"&&(Pe=wu(De));const Ce=Kl(V,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,Pe,_e,K,o.ai.horizontal,!1,Me,M,C);Ce&&(R.horizontal[Pe]=Ce),Fe(),so(se)&&f&&m&&(R.vertical=Kl(V,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,Pe,_e,K,o.ai.vertical,!1,Me,M,C))}}let ne=!1;if(b.icon&&b.icon.name){const se=i.imageMap[b.icon.name];se&&(G=Ny(i.imagePositions[b.icon.name],r.get("icon-offset").evaluate(b,{},i.canonical),r.get("icon-anchor").evaluate(b,{},i.canonical)),ne=!!se.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=ne:i.bucket.sdfIcons!==ne&&Le("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(se.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const J=Ad(R.horizontal)||R.vertical;i.bucket.iconsInText=!!J&&J.iconsInText,(J||G)&&ix(i.bucket,b,R,G,i.imageMap,l,M,L,K,ne,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},o.br=su,o.bs=ru,o.bt=au,o.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}},o.bv=lu,o.bw=sa,o.bx=function(i,e,r,a,l){return te(this,void 0,void 0,(function*(){if(Et())try{return yield da(i,e,r,a,l)}catch{}return(function(d,f,m,y,b){const S=d.width,C=d.height;Tr&&Pt||(Tr=new OffscreenCanvas(S,C),Pt=Tr.getContext("2d",{willReadFrequently:!0})),Tr.width=S,Tr.height=C,Pt.drawImage(d,0,0,S,C);const M=Pt.getImageData(f,m,y,b);return Pt.clearRect(0,0,S,C),M.data})(i,e,r,a,l)}))},o.by=cd,o.bz=H,o.c=$n,o.d=function(i,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=Li}))},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):Li},o.e=ii,o.f=function(i,e){return Qr(ii(i,{type:"json"}),e)},o.g=sr,o.h=Un,o.i=$t,o.j=tn,o.k=en,o.l=ma,o.m=Qr,o.n=function(i){return new lu(i).readFields(Dy,[])},o.o=function(i,e,r){if(!i.length)return r(null,[]);let a=i.length;const l=new Array(i.length);let d=null;i.forEach(((f,m)=>{e(f,((y,b)=>{y&&(d=y),l[m]=b,--a==0&&r(d,l)}))}))},o.p=$p,o.q=ko,o.r=Kt,o.s=Fr,o.t=Oc,o.u=ze,o.v=he,o.w=Le,o.x=ms,o.y=$r,o.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)}}})),O(["./shared"],(function(o){class te{constructor(E){this.keyCache={},E&&this.replace(E)}replace(E){this._layerConfigs={},this._layers={},this.update(E,[])}update(E,z){for(const Z of E){this._layerConfigs[Z.id]=Z;const W=this._layers[Z.id]=o.aC(Z);W._featureFilter=o.a6(W.filter),this.keyCache[Z.id]&&delete this.keyCache[Z.id]}for(const Z of z)delete this.keyCache[Z],delete this._layerConfigs[Z],delete this._layers[Z];this.familiesBySource={};const F=o.bl(Object.values(this._layerConfigs),this.keyCache);for(const Z of F){const W=Z.map((fe=>this._layers[fe.id])),ae=W[0];if(ae.visibility==="none")continue;const Q=ae.source||"";let Y=this.familiesBySource[Q];Y||(Y=this.familiesBySource[Q]={});const re=ae.sourceLayer||"_geojsonTileLayer";let pe=Y[re];pe||(pe=Y[re]=[]),pe.push(W)}}}class H{constructor(E){const z={},F=[];for(const Q in E){const Y=E[Q],re=z[Q]={};for(const pe in Y){const fe=Y[+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};F.push(ye),re[pe]={rect:ye,metrics:fe.metrics}}}const{w:Z,h:W}=o.p(F),ae=new o.q({width:Z||1,height:W||1});for(const Q in E){const Y=E[Q];for(const re in Y){const pe=Y[+re];if(!pe||pe.bitmap.width===0||pe.bitmap.height===0)continue;const fe=z[Q][re].rect;o.q.copy(pe.bitmap,ae,{x:0,y:0},{x:fe.x+1,y:fe.y+1},pe.bitmap)}}this.image=ae,this.positions=z}}o.bm("GlyphAtlas",H);class ve{constructor(E){this.tileID=new o.O(E.tileID.overscaledZ,E.tileID.wrap,E.tileID.canonical.z,E.tileID.canonical.x,E.tileID.canonical.y),this.uid=E.uid,this.zoom=E.zoom,this.pixelRatio=E.pixelRatio,this.tileSize=E.tileSize,this.source=E.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=E.showCollisionBoxes,this.collectResourceTiming=!!E.collectResourceTiming,this.returnDependencies=!!E.returnDependencies,this.promoteId=E.promoteId,this.inFlightDependencies=[],this.dependencySentinel=-1}parse(E,z,F,Z,W){this.status="parsing",this.data=E,this.collisionBoxArray=new o.a3;const ae=new o.bn(Object.keys(E.layers).sort()),Q=new o.bo(this.tileID,this.promoteId);Q.bucketLayerIDs=[];const Y={},re={featureIndex:Q,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:F},pe=z.familiesBySource[this.source];for(const gt in pe){const mt=E.layers[gt];if(!mt)continue;mt.version===1&&o.w(`Vector tile source "${this.source}" layer "${gt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const yi=ae.encode(gt),Ct=[];for(let Qt=0;Qt<mt.length;Qt++){const di=mt.feature(Qt),lr=Q.getId(di,gt);Ct.push({feature:di,id:lr,index:Qt,sourceLayerIndex:yi})}for(const Qt of pe[gt]){const di=Qt[0];di.source!==this.source&&o.w(`layer.source = ${di.source} does not equal this.source = ${this.source}`),di.minzoom&&this.zoom<Math.floor(di.minzoom)||di.maxzoom&&this.zoom>=di.maxzoom||di.visibility!=="none"&&(de(Qt,this.zoom,F),(Y[di.id]=di.createBucket({index:Q.bucketLayerIDs.length,layers:Qt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:yi,sourceID:this.source})).populate(Ct,re,this.tileID.canonical),Q.bucketLayerIDs.push(Qt.map((lr=>lr.id))))}}let fe,ye,We,et;const Oe=o.aH(re.glyphDependencies,(gt=>Object.keys(gt).map(Number)));this.inFlightDependencies.forEach((gt=>gt==null?void 0:gt.cancel())),this.inFlightDependencies=[];const Ke=++this.dependencySentinel;Object.keys(Oe).length?this.inFlightDependencies.push(Z.send("getGlyphs",{uid:this.uid,stacks:Oe,source:this.source,tileID:this.tileID,type:"glyphs"},((gt,mt)=>{Ke===this.dependencySentinel&&(fe||(fe=gt,ye=mt,Tt.call(this)))}))):ye={};const it=Object.keys(re.iconDependencies);it.length?this.inFlightDependencies.push(Z.send("getImages",{icons:it,source:this.source,tileID:this.tileID,type:"icons"},((gt,mt)=>{Ke===this.dependencySentinel&&(fe||(fe=gt,We=mt,Tt.call(this)))}))):We={};const bt=Object.keys(re.patternDependencies);function Tt(){if(fe)return W(fe);if(ye&&We&&et){const gt=new H(ye),mt=new o.bp(We,et);for(const yi in Y){const Ct=Y[yi];Ct instanceof o.a4?(de(Ct.layers,this.zoom,F),o.bq({bucket:Ct,glyphMap:ye,glyphPositions:gt.positions,imageMap:We,imagePositions:mt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Ct.hasPattern&&(Ct instanceof o.br||Ct instanceof o.bs||Ct instanceof o.bt)&&(de(Ct.layers,this.zoom,F),Ct.addFeatures(re,this.tileID.canonical,mt.patternPositions))}this.status="done",W(null,{buckets:Object.values(Y).filter((yi=>!yi.isEmpty())),featureIndex:Q,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:gt.image,imageAtlas:mt,glyphMap:this.returnDependencies?ye:null,iconMap:this.returnDependencies?We:null,glyphPositions:this.returnDependencies?gt.positions:null})}}bt.length?this.inFlightDependencies.push(Z.send("getImages",{icons:bt,source:this.source,tileID:this.tileID,type:"patterns"},((gt,mt)=>{Ke===this.dependencySentinel&&(fe||(fe=gt,et=mt,Tt.call(this)))}))):et={},Tt.call(this)}}function de(j,E,z){const F=new o.a8(E);for(const Z of j)Z.recalculate(F,z)}function ge(j,E){const z=o.l(j.request,((F,Z,W,ae)=>{if(F)E(F);else if(Z)try{const Q=new o.bw.VectorTile(new o.bv(Z));E(null,{vectorTile:Q,rawData:Z,cacheControl:W,expires:ae})}catch(Q){const Y=new Uint8Array(Z);let re=`Unable to parse the tile at ${j.request.url}, `;re+=Y[0]===31&&Y[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${Q.messge}`,E(new Error(re))}}));return()=>{z.cancel(),E()}}class Ue{constructor(E,z,F,Z){this.actor=E,this.layerIndex=z,this.availableImages=F,this.loadVectorData=Z||ge,this.fetching={},this.loading={},this.loaded={}}loadTile(E,z){const F=E.uid;this.loading||(this.loading={});const Z=!!(E&&E.request&&E.request.collectResourceTiming)&&new o.bu(E.request),W=this.loading[F]=new ve(E);W.abort=this.loadVectorData(E,((ae,Q)=>{if(delete this.loading[F],ae||!Q)return W.status="done",this.loaded[F]=W,z(ae);const Y=Q.rawData,re={};Q.expires&&(re.expires=Q.expires),Q.cacheControl&&(re.cacheControl=Q.cacheControl);const pe={};if(Z){const fe=Z.finish();fe&&(pe.resourceTiming=JSON.parse(JSON.stringify(fe)))}W.vectorTile=Q.vectorTile,W.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor,((fe,ye)=>{if(delete this.fetching[F],fe||!ye)return z(fe);z(null,o.e({rawTileData:Y.slice(0)},ye,re,pe))})),this.loaded=this.loaded||{},this.loaded[F]=W,this.fetching[F]={rawTileData:Y,cacheControl:re,resourceTiming:pe}}))}reloadTile(E,z){const F=this.loaded,Z=E.uid;if(F&&F[Z]){const W=F[Z];W.showCollisionBoxes=E.showCollisionBoxes,W.status==="parsing"?W.parse(W.vectorTile,this.layerIndex,this.availableImages,this.actor,((ae,Q)=>{if(ae||!Q)return z(ae,Q);let Y;if(this.fetching[Z]){const{rawTileData:re,cacheControl:pe,resourceTiming:fe}=this.fetching[Z];delete this.fetching[Z],Y=o.e({rawTileData:re.slice(0)},Q,pe,fe)}else Y=Q;z(null,Y)})):W.status==="done"&&(W.vectorTile?W.parse(W.vectorTile,this.layerIndex,this.availableImages,this.actor,z):z())}}abortTile(E,z){const F=this.loading,Z=E.uid;F&&F[Z]&&F[Z].abort&&(F[Z].abort(),delete F[Z]),z()}removeTile(E,z){const F=this.loaded,Z=E.uid;F&&F[Z]&&delete F[Z],z()}}class rt{constructor(){this.loaded={}}loadTile(E,z){return o._(this,void 0,void 0,(function*(){const{uid:F,encoding:Z,rawImageData:W,redFactor:ae,greenFactor:Q,blueFactor:Y,baseShift:re}=E,pe=W.width+2,fe=W.height+2,ye=o.a(W)?new o.R({width:pe,height:fe},yield o.bx(W,-1,-1,pe,fe)):W,We=new o.by(F,ye,Z,ae,Q,Y,re);this.loaded=this.loaded||{},this.loaded[F]=We,z(null,We)}))}removeTile(E){const z=this.loaded,F=E.uid;z&&z[F]&&delete z[F]}}function Te(j,E){if(j.length!==0){Be(j[0],E);for(var z=1;z<j.length;z++)Be(j[z],!E)}}function Be(j,E){for(var z=0,F=0,Z=0,W=j.length,ae=W-1;Z<W;ae=Z++){var Q=(j[Z][0]-j[ae][0])*(j[ae][1]+j[Z][1]),Y=z+Q;F+=Math.abs(z)>=Math.abs(Q)?z-Y+Q:Q-Y+z,z=Y}z+F>=0!=!!E&&j.reverse()}var Ze=o.bz((function j(E,z){var F,Z=E&&E.type;if(Z==="FeatureCollection")for(F=0;F<E.features.length;F++)j(E.features[F],z);else if(Z==="GeometryCollection")for(F=0;F<E.geometries.length;F++)j(E.geometries[F],z);else if(Z==="Feature")j(E.geometry,z);else if(Z==="Polygon")Te(E.coordinates,z);else if(Z==="MultiPolygon")for(F=0;F<E.coordinates.length;F++)Te(E.coordinates[F],z);return E}));const He=o.bw.VectorTileFeature.prototype.toGeoJSON;var Et={exports:{}},Di=o.bA,Kr=o.bw.VectorTileFeature,ar=mn;function mn(j,E){this.options=E||{},this.features=j,this.length=j.length}function ii(j,E){this.id=typeof j.id=="number"?j.id:void 0,this.type=j.type,this.rawGeometry=j.type===1?[j.geometry]:j.geometry,this.properties=j.tags,this.extent=E||4096}mn.prototype.feature=function(j){return new ii(this.features[j],this.options.extent)},ii.prototype.loadGeometry=function(){var j=this.rawGeometry;this.geometry=[];for(var E=0;E<j.length;E++){for(var z=j[E],F=[],Z=0;Z<z.length;Z++)F.push(new Di(z[Z][0],z[Z][1]));this.geometry.push(F)}return this.geometry},ii.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var j=this.geometry,E=1/0,z=-1/0,F=1/0,Z=-1/0,W=0;W<j.length;W++)for(var ae=j[W],Q=0;Q<ae.length;Q++){var Y=ae[Q];E=Math.min(E,Y.x),z=Math.max(z,Y.x),F=Math.min(F,Y.y),Z=Math.max(Z,Y.y)}return[E,F,z,Z]},ii.prototype.toGeoJSON=Kr.prototype.toGeoJSON;var Vn=o.bB,Mt=ar;function Yr(j){var E=new Vn;return(function(z,F){for(var Z in z.layers)F.writeMessage(3,Gi,z.layers[Z])})(j,E),E.finish()}function Gi(j,E){var z;E.writeVarintField(15,j.version||1),E.writeStringField(1,j.name||""),E.writeVarintField(5,j.extent||4096);var F={keys:[],values:[],keycache:{},valuecache:{}};for(z=0;z<j.length;z++)F.feature=j.feature(z),E.writeMessage(2,wr,F);var Z=F.keys;for(z=0;z<Z.length;z++)E.writeStringField(3,Z[z]);var W=F.values;for(z=0;z<W.length;z++)E.writeMessage(4,Rt,W[z])}function wr(j,E){var z=j.feature;z.id!==void 0&&E.writeVarintField(1,z.id),E.writeMessage(2,Le,j),E.writeVarintField(3,z.type),E.writeMessage(4,$t,z)}function Le(j,E){var z=j.feature,F=j.keys,Z=j.values,W=j.keycache,ae=j.valuecache;for(var Q in z.properties){var Y=z.properties[Q],re=W[Q];if(Y!==null){re===void 0&&(F.push(Q),W[Q]=re=F.length-1),E.writeVarint(re);var pe=typeof Y;pe!=="string"&&pe!=="boolean"&&pe!=="number"&&(Y=JSON.stringify(Y));var fe=pe+":"+Y,ye=ae[fe];ye===void 0&&(Z.push(Y),ae[fe]=ye=Z.length-1),E.writeVarint(ye)}}}function qe(j,E){return(E<<3)+(7&j)}function pt(j){return j<<1^j>>31}function $t(j,E){for(var z=j.loadGeometry(),F=j.type,Z=0,W=0,ae=z.length,Q=0;Q<ae;Q++){var Y=z[Q],re=1;F===1&&(re=Y.length),E.writeVarint(qe(1,re));for(var pe=F===3?Y.length-1:Y.length,fe=0;fe<pe;fe++){fe===1&&F!==1&&E.writeVarint(qe(2,pe-1));var ye=Y[fe].x-Z,We=Y[fe].y-W;E.writeVarint(pt(ye)),E.writeVarint(pt(We)),Z+=ye,W+=We}F===3&&E.writeVarint(qe(7,1))}}function Rt(j,E){var z=typeof j;z==="string"?E.writeStringField(1,j):z==="boolean"?E.writeBooleanField(7,j):z==="number"&&(j%1!=0?E.writeDoubleField(3,j):j<0?E.writeSVarintField(6,j):E.writeVarintField(5,j))}Et.exports=Yr,Et.exports.fromVectorTileJs=Yr,Et.exports.fromGeojsonVt=function(j,E){E=E||{};var z={};for(var F in j)z[F]=new Mt(j[F].features,E),z[F].name=F,z[F].version=E.version,z[F].extent=E.extent;return Yr({layers:z})},Et.exports.GeoJSONWrapper=Mt;var Sr=o.bz(Et.exports);const Li={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:j=>j},da=Math.fround||(Tr=new Float32Array(1),j=>(Tr[0]=+j,Tr[0]));var Tr;const Pt=3,Ri=5,gn=6;class Un{constructor(E){this.options=Object.assign(Object.create(Li),E),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(E){const{log:z,minZoom:F,maxZoom:Z}=this.options;z&&console.time("total time");const W=`prepare ${E.length} points`;z&&console.time(W),this.points=E;const ae=[];for(let Y=0;Y<E.length;Y++){const re=E[Y];if(!re.geometry)continue;const[pe,fe]=re.geometry.coordinates,ye=da(_r(pe)),We=da(sr(fe));ae.push(ye,We,1/0,Y,-1,1),this.options.reduce&&ae.push(0)}let Q=this.trees[Z+1]=this._createTree(ae);z&&console.timeEnd(W);for(let Y=Z;Y>=F;Y--){const re=+Date.now();Q=this.trees[Y]=this._createTree(this._cluster(Q,Y)),z&&console.log("z%d: %d clusters in %dms",Y,Q.numItems,+Date.now()-re)}return z&&console.timeEnd("total time"),this}getClusters(E,z){let F=((E[0]+180)%360+360)%360-180;const Z=Math.max(-90,Math.min(90,E[1]));let W=E[2]===180?180:((E[2]+180)%360+360)%360-180;const ae=Math.max(-90,Math.min(90,E[3]));if(E[2]-E[0]>=360)F=-180,W=180;else if(F>W){const fe=this.getClusters([F,Z,180,ae],z),ye=this.getClusters([-180,Z,W,ae],z);return fe.concat(ye)}const Q=this.trees[this._limitZoom(z)],Y=Q.range(_r(F),sr(ae),_r(W),sr(Z)),re=Q.data,pe=[];for(const fe of Y){const ye=this.stride*fe;pe.push(re[ye+Ri]>1?$n(re,ye,this.clusterProps):this.points[re[ye+Pt]])}return pe}getChildren(E){const z=this._getOriginId(E),F=this._getOriginZoom(E),Z="No cluster with the specified id.",W=this.trees[F];if(!W)throw new Error(Z);const ae=W.data;if(z*this.stride>=ae.length)throw new Error(Z);const Q=this.options.radius/(this.options.extent*Math.pow(2,F-1)),Y=W.within(ae[z*this.stride],ae[z*this.stride+1],Q),re=[];for(const pe of Y){const fe=pe*this.stride;ae[fe+4]===E&&re.push(ae[fe+Ri]>1?$n(ae,fe,this.clusterProps):this.points[ae[fe+Pt]])}if(re.length===0)throw new Error(Z);return re}getLeaves(E,z,F){const Z=[];return this._appendLeaves(Z,E,z=z||10,F=F||0,0),Z}getTile(E,z,F){const Z=this.trees[this._limitZoom(E)],W=Math.pow(2,E),{extent:ae,radius:Q}=this.options,Y=Q/ae,re=(F-Y)/W,pe=(F+1+Y)/W,fe={features:[]};return this._addTileFeatures(Z.range((z-Y)/W,re,(z+1+Y)/W,pe),Z.data,z,F,W,fe),z===0&&this._addTileFeatures(Z.range(1-Y/W,re,1,pe),Z.data,W,F,W,fe),z===W-1&&this._addTileFeatures(Z.range(0,re,Y/W,pe),Z.data,-1,F,W,fe),fe.features.length?fe:null}getClusterExpansionZoom(E){let z=this._getOriginZoom(E)-1;for(;z<=this.options.maxZoom;){const F=this.getChildren(E);if(z++,F.length!==1)break;E=F[0].properties.cluster_id}return z}_appendLeaves(E,z,F,Z,W){const ae=this.getChildren(z);for(const Q of ae){const Y=Q.properties;if(Y&&Y.cluster?W+Y.point_count<=Z?W+=Y.point_count:W=this._appendLeaves(E,Y.cluster_id,F,Z,W):W<Z?W++:E.push(Q),E.length===F)break}return W}_createTree(E){const z=new o.av(E.length/this.stride|0,this.options.nodeSize,Float32Array);for(let F=0;F<E.length;F+=this.stride)z.add(E[F],E[F+1]);return z.finish(),z.data=E,z}_addTileFeatures(E,z,F,Z,W,ae){for(const Q of E){const Y=Q*this.stride,re=z[Y+Ri]>1;let pe,fe,ye;if(re)pe=Jr(z,Y,this.clusterProps),fe=z[Y],ye=z[Y+1];else{const Oe=this.points[z[Y+Pt]];pe=Oe.properties;const[Ke,it]=Oe.geometry.coordinates;fe=_r(Ke),ye=sr(it)}const We={type:1,geometry:[[Math.round(this.options.extent*(fe*W-F)),Math.round(this.options.extent*(ye*W-Z))]],tags:pe};let et;et=re||this.options.generateId?z[Y+Pt]:this.points[z[Y+Pt]].id,et!==void 0&&(We.id=et),ae.features.push(We)}}_limitZoom(E){return Math.max(this.options.minZoom,Math.min(Math.floor(+E),this.options.maxZoom+1))}_cluster(E,z){const{radius:F,extent:Z,reduce:W,minPoints:ae}=this.options,Q=F/(Z*Math.pow(2,z)),Y=E.data,re=[],pe=this.stride;for(let fe=0;fe<Y.length;fe+=pe){if(Y[fe+2]<=z)continue;Y[fe+2]=z;const ye=Y[fe],We=Y[fe+1],et=E.within(Y[fe],Y[fe+1],Q),Oe=Y[fe+Ri];let Ke=Oe;for(const it of et){const bt=it*pe;Y[bt+2]>z&&(Ke+=Y[bt+Ri])}if(Ke>Oe&&Ke>=ae){let it,bt=ye*Oe,Tt=We*Oe,gt=-1;const mt=((fe/pe|0)<<5)+(z+1)+this.points.length;for(const yi of et){const Ct=yi*pe;if(Y[Ct+2]<=z)continue;Y[Ct+2]=z;const Qt=Y[Ct+Ri];bt+=Y[Ct]*Qt,Tt+=Y[Ct+1]*Qt,Y[Ct+4]=mt,W&&(it||(it=this._map(Y,fe,!0),gt=this.clusterProps.length,this.clusterProps.push(it)),W(it,this._map(Y,Ct)))}Y[fe+4]=mt,re.push(bt/Ke,Tt/Ke,1/0,mt,-1,Ke),W&&re.push(gt)}else{for(let it=0;it<pe;it++)re.push(Y[fe+it]);if(Ke>1)for(const it of et){const bt=it*pe;if(!(Y[bt+2]<=z)){Y[bt+2]=z;for(let Tt=0;Tt<pe;Tt++)re.push(Y[bt+Tt])}}}}return re}_getOriginId(E){return E-this.points.length>>5}_getOriginZoom(E){return(E-this.points.length)%32}_map(E,z,F){if(E[z+Ri]>1){const ae=this.clusterProps[E[z+gn]];return F?Object.assign({},ae):ae}const Z=this.points[E[z+Pt]].properties,W=this.options.map(Z);return F&&W===Z?Object.assign({},W):W}}function $n(j,E,z){return{type:"Feature",id:j[E+Pt],properties:Jr(j,E,z),geometry:{type:"Point",coordinates:[(F=j[E],360*(F-.5)),fa(j[E+1])]}};var F}function Jr(j,E,z){const F=j[E+Ri],Z=F>=1e4?`${Math.round(F/1e3)}k`:F>=1e3?Math.round(F/100)/10+"k":F,W=j[E+gn],ae=W===-1?{}:Object.assign({},z[W]);return Object.assign(ae,{cluster:!0,cluster_id:j[E+Pt],point_count:F,point_count_abbreviated:Z})}function _r(j){return j/360+.5}function sr(j){const E=Math.sin(j*Math.PI/180),z=.5-.25*Math.log((1+E)/(1-E))/Math.PI;return z<0?0:z>1?1:z}function fa(j){const E=(180-360*j)*Math.PI/180;return 360*Math.atan(Math.exp(E))/Math.PI-90}function Qr(j,E,z,F){for(var Z,W=F,ae=z-E>>1,Q=z-E,Y=j[E],re=j[E+1],pe=j[z],fe=j[z+1],ye=E+3;ye<z;ye+=3){var We=ma(j[ye],j[ye+1],Y,re,pe,fe);if(We>W)Z=ye,W=We;else if(We===W){var et=Math.abs(ye-ae);et<Q&&(Z=ye,Q=et)}}W>F&&(Z-E>3&&Qr(j,E,Z,F),j[Z+2]=W,z-Z>3&&Qr(j,Z,z,F))}function ma(j,E,z,F,Z,W){var ae=Z-z,Q=W-F;if(ae!==0||Q!==0){var Y=((j-z)*ae+(E-F)*Q)/(ae*ae+Q*Q);Y>1?(z=Z,F=W):Y>0&&(z+=ae*Y,F+=Q*Y)}return(ae=j-z)*ae+(Q=E-F)*Q}function Fr(j,E,z,F){var Z={id:j===void 0?null:j,type:E,geometry:z,tags:F,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return(function(W){var ae=W.geometry,Q=W.type;if(Q==="Point"||Q==="MultiPoint"||Q==="LineString")jn(W,ae);else if(Q==="Polygon"||Q==="MultiLineString")for(var Y=0;Y<ae.length;Y++)jn(W,ae[Y]);else if(Q==="MultiPolygon")for(Y=0;Y<ae.length;Y++)for(var re=0;re<ae[Y].length;re++)jn(W,ae[Y][re])})(Z),Z}function jn(j,E){for(var z=0;z<E.length;z+=3)j.minX=Math.min(j.minX,E[z]),j.minY=Math.min(j.minY,E[z+1]),j.maxX=Math.max(j.maxX,E[z]),j.maxY=Math.max(j.maxY,E[z+1])}function _n(j,E,z,F){if(E.geometry){var Z=E.geometry.coordinates,W=E.geometry.type,ae=Math.pow(z.tolerance/((1<<z.maxZoom)*z.extent),2),Q=[],Y=E.id;if(z.promoteId?Y=E.properties[z.promoteId]:z.generateId&&(Y=F||0),W==="Point")en(Z,Q);else if(W==="MultiPoint")for(var re=0;re<Z.length;re++)en(Z[re],Q);else if(W==="LineString")tn(Z,Q,ae,!1);else if(W==="MultiLineString"){if(z.lineMetrics){for(re=0;re<Z.length;re++)tn(Z[re],Q=[],ae,!1),j.push(Fr(Y,"LineString",Q,E.properties));return}yn(Z,Q,ae,!1)}else if(W==="Polygon")yn(Z,Q,ae,!0);else{if(W!=="MultiPolygon"){if(W==="GeometryCollection"){for(re=0;re<E.geometry.geometries.length;re++)_n(j,{id:Y,geometry:E.geometry.geometries[re],properties:E.properties},z,F);return}throw new Error("Input data is not a valid GeoJSON object.")}for(re=0;re<Z.length;re++){var pe=[];yn(Z[re],pe,ae,!0),Q.push(pe)}}j.push(Fr(Y,W,Q,E.properties))}}function en(j,E){E.push(he(j[0])),E.push(Fi(j[1])),E.push(0)}function tn(j,E,z,F){for(var Z,W,ae=0,Q=0;Q<j.length;Q++){var Y=he(j[Q][0]),re=Fi(j[Q][1]);E.push(Y),E.push(re),E.push(0),Q>0&&(ae+=F?(Z*re-Y*W)/2:Math.sqrt(Math.pow(Y-Z,2)+Math.pow(re-W,2))),Z=Y,W=re}var pe=E.length-3;E[2]=1,Qr(E,0,pe,z),E[pe+2]=1,E.size=Math.abs(ae),E.start=0,E.end=E.size}function yn(j,E,z,F){for(var Z=0;Z<j.length;Z++){var W=[];tn(j[Z],W,z,F),E.push(W)}}function he(j){return j/360+.5}function Fi(j){var E=Math.sin(j*Math.PI/180),z=.5-.25*Math.log((1+E)/(1-E))/Math.PI;return z<0?0:z>1?1:z}function or(j,E,z,F,Z,W,ae,Q){if(F/=E,W>=(z/=E)&&ae<F)return j;if(ae<z||W>=F)return null;for(var Y=[],re=0;re<j.length;re++){var pe=j[re],fe=pe.geometry,ye=pe.type,We=Z===0?pe.minX:pe.minY,et=Z===0?pe.maxX:pe.maxY;if(We>=z&&et<F)Y.push(pe);else if(!(et<z||We>=F)){var Oe=[];if(ye==="Point"||ye==="MultiPoint")At(fe,Oe,z,F,Z);else if(ye==="LineString")_t(fe,Oe,z,F,Z,!1,Q.lineMetrics);else if(ye==="MultiLineString")qn(fe,Oe,z,F,Z,!1);else if(ye==="Polygon")qn(fe,Oe,z,F,Z,!0);else if(ye==="MultiPolygon")for(var Ke=0;Ke<fe.length;Ke++){var it=[];qn(fe[Ke],it,z,F,Z,!0),it.length&&Oe.push(it)}if(Oe.length){if(Q.lineMetrics&&ye==="LineString"){for(Ke=0;Ke<Oe.length;Ke++)Y.push(Fr(pe.id,ye,Oe[Ke],pe.tags));continue}ye!=="LineString"&&ye!=="MultiLineString"||(Oe.length===1?(ye="LineString",Oe=Oe[0]):ye="MultiLineString"),ye!=="Point"&&ye!=="MultiPoint"||(ye=Oe.length===3?"Point":"MultiPoint"),Y.push(Fr(pe.id,ye,Oe,pe.tags))}}}return Y.length?Y:null}function At(j,E,z,F,Z){for(var W=0;W<j.length;W+=3){var ae=j[W+Z];ae>=z&&ae<=F&&(E.push(j[W]),E.push(j[W+1]),E.push(j[W+2]))}}function _t(j,E,z,F,Z,W,ae){for(var Q,Y,re=Ir(j),pe=Z===0?qa:Zn,fe=j.start,ye=0;ye<j.length-3;ye+=3){var We=j[ye],et=j[ye+1],Oe=j[ye+2],Ke=j[ye+3],it=j[ye+4],bt=Z===0?We:et,Tt=Z===0?Ke:it,gt=!1;ae&&(Q=Math.sqrt(Math.pow(We-Ke,2)+Math.pow(et-it,2))),bt<z?Tt>z&&(Y=pe(re,We,et,Ke,it,z),ae&&(re.start=fe+Q*Y)):bt>F?Tt<F&&(Y=pe(re,We,et,Ke,it,F),ae&&(re.start=fe+Q*Y)):Br(re,We,et,Oe),Tt<z&&bt>=z&&(Y=pe(re,We,et,Ke,it,z),gt=!0),Tt>F&&bt<=F&&(Y=pe(re,We,et,Ke,it,F),gt=!0),!W&&gt&&(ae&&(re.end=fe+Q*Y),E.push(re),re=Ir(j)),ae&&(fe+=Q)}var mt=j.length-3;We=j[mt],et=j[mt+1],Oe=j[mt+2],(bt=Z===0?We:et)>=z&&bt<=F&&Br(re,We,et,Oe),mt=re.length-3,W&&mt>=3&&(re[mt]!==re[0]||re[mt+1]!==re[1])&&Br(re,re[0],re[1],re[2]),re.length&&E.push(re)}function Ir(j){var E=[];return E.size=j.size,E.start=j.start,E.end=j.end,E}function qn(j,E,z,F,Z,W){for(var ae=0;ae<j.length;ae++)_t(j[ae],E,z,F,Z,W,!1)}function Br(j,E,z,F){j.push(E),j.push(z),j.push(F)}function qa(j,E,z,F,Z,W){var ae=(W-E)/(F-E);return j.push(W),j.push(z+(Z-z)*ae),j.push(1),ae}function Zn(j,E,z,F,Z,W){var ae=(W-z)/(Z-z);return j.push(E+(F-E)*ae),j.push(W),j.push(1),ae}function rn(j,E){for(var z=[],F=0;F<j.length;F++){var Z,W=j[F],ae=W.type;if(ae==="Point"||ae==="MultiPoint"||ae==="LineString")Z=xn(W.geometry,E);else if(ae==="MultiLineString"||ae==="Polygon"){Z=[];for(var Q=0;Q<W.geometry.length;Q++)Z.push(xn(W.geometry[Q],E))}else if(ae==="MultiPolygon")for(Z=[],Q=0;Q<W.geometry.length;Q++){for(var Y=[],re=0;re<W.geometry[Q].length;re++)Y.push(xn(W.geometry[Q][re],E));Z.push(Y)}z.push(Fr(W.id,ae,Z,W.tags))}return z}function xn(j,E){var z=[];z.size=j.size,j.start!==void 0&&(z.start=j.start,z.end=j.end);for(var F=0;F<j.length;F+=3)z.push(j[F]+E,j[F+1],j[F+2]);return z}function Ae(j,E){if(j.transformed)return j;var z,F,Z,W=1<<j.z,ae=j.x,Q=j.y;for(z=0;z<j.features.length;z++){var Y=j.features[z],re=Y.geometry,pe=Y.type;if(Y.geometry=[],pe===1)for(F=0;F<re.length;F+=2)Y.geometry.push(Ar(re[F],re[F+1],E,W,ae,Q));else for(F=0;F<re.length;F++){var fe=[];for(Z=0;Z<re[F].length;Z+=2)fe.push(Ar(re[F][Z],re[F][Z+1],E,W,ae,Q));Y.geometry.push(fe)}}return j.transformed=!0,j}function Ar(j,E,z,F,Z,W){return[Math.round(z*(j*F-Z)),Math.round(z*(E*F-W))]}function jt(j,E,z,F,Z){for(var W=E===Z.maxZoom?0:Z.tolerance/((1<<E)*Z.extent),ae={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:z,y:F,z:E,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Q=0;Q<j.length;Q++){ae.numFeatures++,vn(ae,j[Q],W,Z);var Y=j[Q].minX,re=j[Q].minY,pe=j[Q].maxX,fe=j[Q].maxY;Y<ae.minX&&(ae.minX=Y),re<ae.minY&&(ae.minY=re),pe>ae.maxX&&(ae.maxX=pe),fe>ae.maxY&&(ae.maxY=fe)}return ae}function vn(j,E,z,F){var Z=E.geometry,W=E.type,ae=[];if(W==="Point"||W==="MultiPoint")for(var Q=0;Q<Z.length;Q+=3)ae.push(Z[Q]),ae.push(Z[Q+1]),j.numPoints++,j.numSimplified++;else if(W==="LineString")Or(ae,Z,j,z,!1,!1);else if(W==="MultiLineString"||W==="Polygon")for(Q=0;Q<Z.length;Q++)Or(ae,Z[Q],j,z,W==="Polygon",Q===0);else if(W==="MultiPolygon")for(var Y=0;Y<Z.length;Y++){var re=Z[Y];for(Q=0;Q<re.length;Q++)Or(ae,re[Q],j,z,!0,Q===0)}if(ae.length){var pe=E.tags||null;if(W==="LineString"&&F.lineMetrics){for(var fe in pe={},E.tags)pe[fe]=E.tags[fe];pe.mapbox_clip_start=Z.start/Z.size,pe.mapbox_clip_end=Z.end/Z.size}var ye={geometry:ae,type:W==="Polygon"||W==="MultiPolygon"?3:W==="LineString"||W==="MultiLineString"?2:1,tags:pe};E.id!==null&&(ye.id=E.id),j.features.push(ye)}}function Or(j,E,z,F,Z,W){var ae=F*F;if(F>0&&E.size<(Z?ae:F))z.numPoints+=E.length/3;else{for(var Q=[],Y=0;Y<E.length;Y+=3)(F===0||E[Y+2]>ae)&&(z.numSimplified++,Q.push(E[Y]),Q.push(E[Y+1])),z.numPoints++;Z&&(function(re,pe){for(var fe=0,ye=0,We=re.length,et=We-2;ye<We;et=ye,ye+=2)fe+=(re[ye]-re[et])*(re[ye+1]+re[et+1]);if(fe>0===pe)for(ye=0,We=re.length;ye<We/2;ye+=2){var Oe=re[ye],Ke=re[ye+1];re[ye]=re[We-2-ye],re[ye+1]=re[We-1-ye],re[We-2-ye]=Oe,re[We-1-ye]=Ke}})(Q,W),j.push(Q)}}function ke(j,E){var z=(E=this.options=(function(Z,W){for(var ae in W)Z[ae]=W[ae];return Z})(Object.create(this.options),E)).debug;if(z&&console.time("preprocess data"),E.maxZoom<0||E.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(E.promoteId&&E.generateId)throw new Error("promoteId and generateId cannot be used together.");var F=(function(Z,W){var ae=[];if(Z.type==="FeatureCollection")for(var Q=0;Q<Z.features.length;Q++)_n(ae,Z.features[Q],W,Q);else _n(ae,Z.type==="Feature"?Z:{geometry:Z},W);return ae})(j,E);this.tiles={},this.tileCoords=[],z&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",E.indexMaxZoom,E.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),F=(function(Z,W){var ae=W.buffer/W.extent,Q=Z,Y=or(Z,1,-1-ae,ae,0,-1,2,W),re=or(Z,1,1-ae,2+ae,0,-1,2,W);return(Y||re)&&(Q=or(Z,1,-ae,1+ae,0,-1,2,W)||[],Y&&(Q=rn(Y,1).concat(Q)),re&&(Q=Q.concat(rn(re,-1)))),Q})(F,E),F.length&&this.splitTile(F,0,0,0),z&&(F.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 st(j,E,z){return 32*((1<<j)*z+E)+j}function tt(j,E){return E?j.properties[E]:j.id}function Ii(j,E){if(j==null)return!0;if(j.type==="Feature")return tt(j,E)!=null;if(j.type==="FeatureCollection"){const z=new Set;for(const F of j.features){const Z=tt(F,E);if(Z==null||z.has(Z))return!1;z.add(Z)}return!0}return!1}function Cr(j,E){const z=new Map;if(j!=null)if(j.type==="Feature")z.set(tt(j,E),j);else for(const F of j.features)z.set(tt(F,E),F);return z}ke.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ke.prototype.splitTile=function(j,E,z,F,Z,W,ae){for(var Q=[j,E,z,F],Y=this.options,re=Y.debug;Q.length;){F=Q.pop(),z=Q.pop(),E=Q.pop(),j=Q.pop();var pe=1<<E,fe=st(E,z,F),ye=this.tiles[fe];if(!ye&&(re>1&&console.time("creation"),ye=this.tiles[fe]=jt(j,E,z,F,Y),this.tileCoords.push({z:E,x:z,y:F}),re)){re>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",E,z,F,ye.numFeatures,ye.numPoints,ye.numSimplified),console.timeEnd("creation"));var We="z"+E;this.stats[We]=(this.stats[We]||0)+1,this.total++}if(ye.source=j,Z){if(E===Y.maxZoom||E===Z)continue;var et=1<<Z-E;if(z!==Math.floor(W/et)||F!==Math.floor(ae/et))continue}else if(E===Y.indexMaxZoom||ye.numPoints<=Y.indexMaxPoints)continue;if(ye.source=null,j.length!==0){re>1&&console.time("clipping");var Oe,Ke,it,bt,Tt,gt,mt=.5*Y.buffer/Y.extent,yi=.5-mt,Ct=.5+mt,Qt=1+mt;Oe=Ke=it=bt=null,Tt=or(j,pe,z-mt,z+Ct,0,ye.minX,ye.maxX,Y),gt=or(j,pe,z+yi,z+Qt,0,ye.minX,ye.maxX,Y),j=null,Tt&&(Oe=or(Tt,pe,F-mt,F+Ct,1,ye.minY,ye.maxY,Y),Ke=or(Tt,pe,F+yi,F+Qt,1,ye.minY,ye.maxY,Y),Tt=null),gt&&(it=or(gt,pe,F-mt,F+Ct,1,ye.minY,ye.maxY,Y),bt=or(gt,pe,F+yi,F+Qt,1,ye.minY,ye.maxY,Y),gt=null),re>1&&console.timeEnd("clipping"),Q.push(Oe||[],E+1,2*z,2*F),Q.push(Ke||[],E+1,2*z,2*F+1),Q.push(it||[],E+1,2*z+1,2*F),Q.push(bt||[],E+1,2*z+1,2*F+1)}}},ke.prototype.getTile=function(j,E,z){var F=this.options,Z=F.extent,W=F.debug;if(j<0||j>24)return null;var ae=1<<j,Q=st(j,E=(E%ae+ae)%ae,z);if(this.tiles[Q])return Ae(this.tiles[Q],Z);W>1&&console.log("drilling down to z%d-%d-%d",j,E,z);for(var Y,re=j,pe=E,fe=z;!Y&&re>0;)re--,pe=Math.floor(pe/2),fe=Math.floor(fe/2),Y=this.tiles[st(re,pe,fe)];return Y&&Y.source?(W>1&&console.log("found parent tile z%d-%d-%d",re,pe,fe),W>1&&console.time("drilling down"),this.splitTile(Y.source,re,pe,fe,j,E,z),W>1&&console.timeEnd("drilling down"),this.tiles[Q]?Ae(this.tiles[Q],Z):null):null};class nt extends Ue{constructor(E,z,F,Z){super(E,z,F),this._dataUpdateable=new Map,this.loadGeoJSON=(W,ae)=>{const{promoteId:Q}=W;if(W.request)return o.f(W.request,((Y,re,pe,fe)=>{this._dataUpdateable=Ii(re,Q)?Cr(re,Q):void 0,ae(Y,re,pe,fe)}));if(typeof W.data=="string")try{const Y=JSON.parse(W.data);this._dataUpdateable=Ii(Y,Q)?Cr(Y,Q):void 0,ae(null,Y)}catch{ae(new Error(`Input data given to '${W.source}' is not a valid GeoJSON object.`))}else W.dataDiff?this._dataUpdateable?((function(Y,re,pe){var fe,ye,We,et;if(re.removeAll&&Y.clear(),re.remove)for(const Oe of re.remove)Y.delete(Oe);if(re.add)for(const Oe of re.add){const Ke=tt(Oe,pe);Ke!=null&&Y.set(Ke,Oe)}if(re.update)for(const Oe of re.update){let Ke=Y.get(Oe.id);if(Ke==null)continue;const it=!Oe.removeAllProperties&&(((fe=Oe.removeProperties)===null||fe===void 0?void 0:fe.length)>0||((ye=Oe.addOrUpdateProperties)===null||ye===void 0?void 0:ye.length)>0);if((Oe.newGeometry||Oe.removeAllProperties||it)&&(Ke=Object.assign({},Ke),Y.set(Oe.id,Ke),it&&(Ke.properties=Object.assign({},Ke.properties))),Oe.newGeometry&&(Ke.geometry=Oe.newGeometry),Oe.removeAllProperties)Ke.properties={};else if(((We=Oe.removeProperties)===null||We===void 0?void 0:We.length)>0)for(const bt of Oe.removeProperties)Object.prototype.hasOwnProperty.call(Ke.properties,bt)&&delete Ke.properties[bt];if(((et=Oe.addOrUpdateProperties)===null||et===void 0?void 0:et.length)>0)for(const{key:bt,value:Tt}of Oe.addOrUpdateProperties)Ke.properties[bt]=Tt}})(this._dataUpdateable,W.dataDiff,Q),ae(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):ae(new Error(`Cannot update existing geojson data in ${W.source}`)):ae(new Error(`Input data given to '${W.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,Z&&(this.loadGeoJSON=Z)}loadGeoJSONTile(E,z){const F=E.tileID.canonical;if(!this._geoJSONIndex)return z(null,null);const Z=this._geoJSONIndex.getTile(F.z,F.x,F.y);if(!Z)return z(null,null);const W=new class{constructor(Q){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=o.N,this.length=Q.length,this._features=Q}feature(Q){return new class{constructor(Y){this._feature=Y,this.extent=o.N,this.type=Y.type,this.properties=Y.tags,"id"in Y&&!isNaN(Y.id)&&(this.id=parseInt(Y.id,10))}loadGeometry(){if(this._feature.type===1){const Y=[];for(const re of this._feature.geometry)Y.push([new o.P(re[0],re[1])]);return Y}{const Y=[];for(const re of this._feature.geometry){const pe=[];for(const fe of re)pe.push(new o.P(fe[0],fe[1]));Y.push(pe)}return Y}}toGeoJSON(Y,re,pe){return He.call(this,Y,re,pe)}}(this._features[Q])}}(Z.features);let ae=Sr(W);ae.byteOffset===0&&ae.byteLength===ae.buffer.byteLength||(ae=new Uint8Array(ae)),z(null,{vectorTile:W,rawData:ae.buffer})}loadData(E,z){var F;(F=this._pendingRequest)===null||F===void 0||F.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const Z=!!(E&&E.request&&E.request.collectResourceTiming)&&new o.bu(E.request);this._pendingCallback=z,this._pendingRequest=this.loadGeoJSON(E,((W,ae)=>{if(delete this._pendingCallback,delete this._pendingRequest,W||!ae)return z(W);if(typeof ae!="object")return z(new Error(`Input data given to '${E.source}' is not a valid GeoJSON object.`));{Ze(ae,!0);try{if(E.filter){const Y=o.bC(E.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Y.result==="error")throw new Error(Y.value.map((pe=>`${pe.key}: ${pe.message}`)).join(", "));ae={type:"FeatureCollection",features:ae.features.filter((pe=>Y.value.evaluate({zoom:0},pe)))}}this._geoJSONIndex=E.cluster?new Un((function({superclusterOptions:Y,clusterProperties:re}){if(!re||!Y)return Y;const pe={},fe={},ye={accumulated:null,zoom:0},We={properties:null},et=Object.keys(re);for(const Oe of et){const[Ke,it]=re[Oe],bt=o.bC(it),Tt=o.bC(typeof Ke=="string"?[Ke,["accumulated"],["get",Oe]]:Ke);pe[Oe]=bt.value,fe[Oe]=Tt.value}return Y.map=Oe=>{We.properties=Oe;const Ke={};for(const it of et)Ke[it]=pe[it].evaluate(ye,We);return Ke},Y.reduce=(Oe,Ke)=>{We.properties=Ke;for(const it of et)ye.accumulated=Oe[it],Oe[it]=fe[it].evaluate(ye,We)},Y})(E)).load(ae.features):(function(Y,re){return new ke(Y,re)})(ae,E.geojsonVtOptions)}catch(Y){return z(Y)}this.loaded={};const Q={};if(Z){const Y=Z.finish();Y&&(Q.resourceTiming={},Q.resourceTiming[E.source]=JSON.parse(JSON.stringify(Y)))}z(null,Q)}}))}reloadTile(E,z){const F=this.loaded;return F&&F[E.uid]?super.reloadTile(E,z):this.loadTile(E,z)}removeSource(E,z){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),z()}getClusterExpansionZoom(E,z){try{z(null,this._geoJSONIndex.getClusterExpansionZoom(E.clusterId))}catch(F){z(F)}}getClusterChildren(E,z){try{z(null,this._geoJSONIndex.getChildren(E.clusterId))}catch(F){z(F)}}getClusterLeaves(E,z){try{z(null,this._geoJSONIndex.getLeaves(E.clusterId,E.limit,E.offset))}catch(F){z(F)}}}class Nr{constructor(E){this.self=E,this.actor=new o.C(E,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Ue,geojson:nt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(z,F)=>{if(this.workerSourceTypes[z])throw new Error(`Worker source with name "${z}" already registered.`);this.workerSourceTypes[z]=F},this.self.registerRTLTextPlugin=z=>{if(o.bD.isParsed())throw new Error("RTL text plugin already registered.");o.bD.applyArabicShaping=z.applyArabicShaping,o.bD.processBidirectionalText=z.processBidirectionalText,o.bD.processStyledBidirectionalText=z.processStyledBidirectionalText}}setReferrer(E,z){this.referrer=z}setImages(E,z,F){this.availableImages[E]=z;for(const Z in this.workerSources[E]){const W=this.workerSources[E][Z];for(const ae in W)W[ae].availableImages=z}F()}setLayers(E,z,F){this.getLayerIndex(E).replace(z),F()}updateLayers(E,z,F){this.getLayerIndex(E).update(z.layers,z.removedIds),F()}loadTile(E,z,F){this.getWorkerSource(E,z.type,z.source).loadTile(z,F)}loadDEMTile(E,z,F){this.getDEMWorkerSource(E,z.source).loadTile(z,F)}reloadTile(E,z,F){this.getWorkerSource(E,z.type,z.source).reloadTile(z,F)}abortTile(E,z,F){this.getWorkerSource(E,z.type,z.source).abortTile(z,F)}removeTile(E,z,F){this.getWorkerSource(E,z.type,z.source).removeTile(z,F)}removeDEMTile(E,z){this.getDEMWorkerSource(E,z.source).removeTile(z)}removeSource(E,z,F){if(!this.workerSources[E]||!this.workerSources[E][z.type]||!this.workerSources[E][z.type][z.source])return;const Z=this.workerSources[E][z.type][z.source];delete this.workerSources[E][z.type][z.source],Z.removeSource!==void 0?Z.removeSource(z,F):F()}loadWorkerSource(E,z,F){try{this.self.importScripts(z.url),F()}catch(Z){F(Z.toString())}}syncRTLPluginState(E,z,F){try{o.bD.setState(z);const Z=o.bD.getPluginURL();if(o.bD.isLoaded()&&!o.bD.isParsed()&&Z!=null){this.self.importScripts(Z);const W=o.bD.isParsed();F(W?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Z}`),W)}}catch(Z){F(Z.toString())}}getAvailableImages(E){let z=this.availableImages[E];return z||(z=[]),z}getLayerIndex(E){let z=this.layerIndexes[E];return z||(z=this.layerIndexes[E]=new te),z}getWorkerSource(E,z,F){return this.workerSources[E]||(this.workerSources[E]={}),this.workerSources[E][z]||(this.workerSources[E][z]={}),this.workerSources[E][z][F]||(this.workerSources[E][z][F]=new this.workerSourceTypes[z]({send:(Z,W,ae)=>{this.actor.send(Z,W,ae,E)}},this.getLayerIndex(E),this.getAvailableImages(E))),this.workerSources[E][z][F]}getDEMWorkerSource(E,z){return this.demWorkerSources[E]||(this.demWorkerSources[E]={}),this.demWorkerSources[E][z]||(this.demWorkerSources[E][z]=new rt),this.demWorkerSources[E][z]}}return o.i()&&(self.worker=new Nr(self)),Nr})),O(["./shared"],(function(o){var te="3.6.2";class H{static testProp(t){if(!H.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in H.docStyle)return t[n];return t[0]}static create(t,n,s){const u=window.document.createElement(t);return n!==void 0&&(u.className=n),s&&s.appendChild(u),u}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){H.docStyle&&H.selectProp&&(H.userSelect=H.docStyle[H.selectProp],H.docStyle[H.selectProp]="none")}static enableDrag(){H.docStyle&&H.selectProp&&(H.docStyle[H.selectProp]=H.userSelect)}static setTransform(t,n){t.style[H.transformProp]=n}static addEventListener(t,n,s,u={}){t.addEventListener(n,s,"passive"in u?u:u.capture)}static removeEventListener(t,n,s,u={}){t.removeEventListener(n,s,"passive"in u?u:u.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",H.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",H.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",H.suppressClickInternal,!0)}),0)}static mousePos(t,n){const s=t.getBoundingClientRect();return new o.P(n.clientX-s.left-t.clientLeft,n.clientY-s.top-t.clientTop)}static touchPos(t,n){const s=t.getBoundingClientRect(),u=[];for(let p=0;p<n.length;p++)u.push(new o.P(n[p].clientX-s.left-t.clientLeft,n[p].clientY-s.top-t.clientTop));return u}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}H.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,H.selectProp=H.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),H.transformProp=H.testProp(["transform","WebkitTransform"]);const ve={supported:!1,testSupport:function(h){!Ue&&ge&&(rt?Te(h):de=h)}};let de,ge,Ue=!1,rt=!1;function Te(h){const t=h.createTexture();h.bindTexture(h.TEXTURE_2D,t);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,ge),h.isContextLost())return;ve.supported=!0}catch{}h.deleteTexture(t),Ue=!0}var Be,Ze;typeof document<"u"&&(ge=document.createElement("img"),ge.onload=function(){de&&Te(de),de=null,rt=!0},ge.onerror=function(){Ue=!0,de=null},ge.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(h){let t,n,s,u;h.resetRequestQueue=()=>{t=[],n=0,s=0,u={}},h.addThrottleControl=w=>{const I=s++;return u[I]=w,I},h.removeThrottleControl=w=>{delete u[w],_()},h.getImage=(w,I,A=!0)=>{ve.supported&&(w.headers||(w.headers={}),w.headers.accept="image/webp,*/*");const D={requestParameters:w,supportImageRefresh:A,callback:I,cancelled:!1,completed:!1,cancel:()=>{D.completed||D.cancelled||(D.cancelled=!0,D.innerRequest&&(D.innerRequest.cancel(),n--),_())}};return t.push(D),_(),D};const p=w=>{const{requestParameters:I,supportImageRefresh:A,callback:D}=w;return o.e(I,{type:"image"}),(A!==!1||o.i()||o.g(I.url)||I.headers&&!Object.keys(I.headers).reduce((($,U)=>$&&U==="accept"),!0)?o.m:v)(I,(($,U,q,N)=>{g(w,D,$,U,q,N)}))},g=(w,I,A,D,$,U)=>{A?I(A):D instanceof HTMLImageElement||o.a(D)?I(null,D):D&&((q,N)=>{typeof createImageBitmap=="function"?o.b(q,N):o.d(q,N)})(D,((q,N)=>{q!=null?I(q):N!=null&&I(null,N,{cacheControl:$,expires:U})})),w.cancelled||(w.completed=!0,n--,_())},_=()=>{const w=(()=>{const I=Object.keys(u);let A=!1;if(I.length>0){for(const D of I)if(A=u[D](),A)break}return A})()?o.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:o.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let I=n;I<w&&t.length>0;I++){const A=t.shift();if(A.cancelled){I--;continue}const D=p(A);n++,A.innerRequest=D}},v=(w,I)=>{const A=new Image,D=w.url;let $=!1;const U=w.credentials;return U&&U==="include"?A.crossOrigin="use-credentials":(U&&U==="same-origin"||!o.s(D))&&(A.crossOrigin="anonymous"),A.fetchPriority="high",A.onload=()=>{I(null,A),A.onerror=A.onload=null},A.onerror=()=>{$||I(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.")),A.onerror=A.onload=null},A.src=D,{cancel:()=>{$=!0,A.src=""}}}})(Be||(Be={})),Be.resetRequestQueue(),(function(h){h.Glyphs="Glyphs",h.Image="Image",h.Source="Source",h.SpriteImage="SpriteImage",h.SpriteJSON="SpriteJSON",h.Style="Style",h.Tile="Tile",h.Unknown="Unknown"})(Ze||(Ze={}));class He{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,s){const u=(function(p){const g=p.match(Et);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 u.path+=`${n}${s}`,(function(p){const g=p.params.length?`?${p.params.join("&")}`:"";return`${p.protocol}://${p.authority}${p.path}${g}`})(u)}setTransformRequest(t){this._transformRequestFn=t}}const Et=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Di(h){var t=new o.A(3);return t[0]=h[0],t[1]=h[1],t[2]=h[2],t}var Kr,ar=function(h,t,n){return h[0]=t[0]-n[0],h[1]=t[1]-n[1],h[2]=t[2]-n[2],h};Kr=new o.A(3),o.A!=Float32Array&&(Kr[0]=0,Kr[1]=0,Kr[2]=0);var mn=function(h){var t=h[0],n=h[1];return t*t+n*n};function ii(h){const t=[];if(typeof h=="string")t.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:s,url:u}of h){const p=`${s}${u}`;n.indexOf(p)===-1&&(n.push(p),t.push({id:s,url:u}))}}return t}function Vn(h,t,n,s,u){if(s)return void h(s);if(u!==Object.values(t).length||u!==Object.values(n).length)return;const p={};for(const g in t){p[g]={};const _=o.h.getImageCanvasContext(n[g]),v=t[g];for(const w in v){const{width:I,height:A,x:D,y:$,sdf:U,pixelRatio:q,stretchX:N,stretchY:ee,content:oe}=v[w];p[g][w]={data:null,pixelRatio:q,sdf:U,stretchX:N,stretchY:ee,content:oe,spriteData:{width:I,height:A,x:D,y:$,context:_}}}}h(null,p)}(function(){var h=new o.A(2);o.A!=Float32Array&&(h[0]=0,h[1]=0)})();class Mt{constructor(t,n,s,u){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(n,u)}update(t,n,s){const{width:u,height:p}=t,g=!(this.size&&this.size[0]===u&&this.size[1]===p||s),{context:_}=this,{gl:v}=_;if(this.useMipmap=!!(n&&n.useMipmap),v.bindTexture(v.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===v.RGBA&&(!n||n.premultiply!==!1)),g)this.size=[u,p],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||o.a(t)?v.texImage2D(v.TEXTURE_2D,0,this.format,this.format,v.UNSIGNED_BYTE,t):v.texImage2D(v.TEXTURE_2D,0,this.format,u,p,0,this.format,v.UNSIGNED_BYTE,t.data);else{const{x:w,y:I}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||o.a(t)?v.texSubImage2D(v.TEXTURE_2D,0,w,I,v.RGBA,v.UNSIGNED_BYTE,t):v.texSubImage2D(v.TEXTURE_2D,0,w,I,u,p,v.RGBA,v.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&v.generateMipmap(v.TEXTURE_2D)}bind(t,n,s){const{context:u}=this,{gl:p}=u;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 Yr(h){const{userImage:t}=h;return!!(t&&t.render&&t.render())&&(h.data.replace(new Uint8Array(t.data.buffer)),!0)}class Gi extends o.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new o.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 o.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 u=n.data||n.spriteData;return this._validateStretch(n.stretchX,u&&u.width)||(this.fire(new o.j(new Error(`Image "${t}" has invalid "stretchX" value`))),s=!1),this._validateStretch(n.stretchY,u&&u.height)||(this.fire(new o.j(new Error(`Image "${t}" has invalid "stretchY" value`))),s=!1),this._validateContent(n.content,n)||(this.fire(new o.j(new Error(`Image "${t}" has invalid "content" value`))),s=!1),s}_validateStretch(t,n){if(!t)return!0;let s=0;for(const u of t){if(u[0]<s||u[1]<u[0]||n<u[1])return!1;s=u[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const s=n.spriteData,u=s&&s.width||n.data.width,p=s&&s.height||n.data.height;return!(t[0]<0||u<t[0]||t[1]<0||p<t[1]||t[2]<0||u<t[2]||t[3]<0||p<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,s=!0){const u=this.getImage(t);if(s&&(u.data.width!==n.data.width||u.data.height!==n.data.height))throw new Error(`size mismatch between old image (${u.data.width}x${u.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=u.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 u of t)this.images[u]||(s=!1);this.isLoaded()||s?this._notify(t,n):this.requestors.push({ids:t,callback:n})}_notify(t,n){const s={};for(const u of t){let p=this.getImage(u);p||(this.fire(new o.k("styleimagemissing",{id:u})),p=this.getImage(u)),p?s[u]={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)}:o.w(`Image "${u}" 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 u={w:s.data.width+2,h:s.data.height+2,x:0,y:0},p=new o.I(u,s);this.patterns[t]={bin:u,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 Mt(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}=o.p(t),u=this.atlasImage;u.resize({width:n||1,height:s||1});for(const p in this.patterns){const{bin:g}=this.patterns[p],_=g.x+1,v=g.y+1,w=this.getImage(p).data,I=w.width,A=w.height;o.R.copy(w,u,{x:0,y:0},{x:_,y:v},{width:I,height:A}),o.R.copy(w,u,{x:0,y:A-1},{x:_,y:v-1},{width:I,height:1}),o.R.copy(w,u,{x:0,y:0},{x:_,y:v+A},{width:I,height:1}),o.R.copy(w,u,{x:I-1,y:0},{x:_-1,y:v},{width:1,height:A}),o.R.copy(w,u,{x:0,y:0},{x:_+I,y:v},{width:1,height:A})}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||o.w(`Image with ID: "${n}" was not found`),Yr(s)&&this.updateImage(n,s)}}}const wr=1e20;function Le(h,t,n,s,u,p,g,_,v){for(let w=t;w<t+s;w++)qe(h,n*p+w,p,u,g,_,v);for(let w=n;w<n+u;w++)qe(h,w*p+t,1,s,g,_,v)}function qe(h,t,n,s,u,p,g){p[0]=0,g[0]=-wr,g[1]=wr,u[0]=h[t];for(let _=1,v=0,w=0;_<s;_++){u[_]=h[t+_*n];const I=_*_;do{const A=p[v];w=(u[_]-u[A]+I-A*A)/(_-A)/2}while(w<=g[v]&&--v>-1);v++,p[v]=_,g[v]=w,g[v+1]=wr}for(let _=0,v=0;_<s;_++){for(;g[v+1]<_;)v++;const w=p[v],I=_-w;h[t+_*n]=u[w]+I*I}}class pt{constructor(t,n){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={}}setURL(t){this.url=t}getGlyphs(t,n){const s=[];for(const u in t)for(const p of t[u])s.push({stack:u,id:p});o.o(s,(({stack:u,id:p},g)=>{let _=this.entries[u];_||(_=this.entries[u]={glyphs:{},requests:{},ranges:{}});let v=_.glyphs[p];if(v!==void 0)return void g(null,{stack:u,id:p,glyph:v});if(v=this._tinySDF(_,u,p),v)return _.glyphs[p]=v,void g(null,{stack:u,id:p,glyph:v});const w=Math.floor(p/256);if(256*w>65535)return void g(new Error("glyphs > 65535 not supported"));if(_.ranges[w])return void g(null,{stack:u,id:p,glyph:v});if(!this.url)return void g(new Error("glyphsUrl is not set"));let I=_.requests[w];I||(I=_.requests[w]=[],pt.loadGlyphRange(u,w,this.url,this.requestManager,((A,D)=>{if(D){for(const $ in D)this._doesCharSupportLocalGlyph(+$)||(_.glyphs[+$]=D[+$]);_.ranges[w]=!0}for(const $ of I)$(A,D);delete _.requests[w]}))),I.push(((A,D)=>{A?g(A):D&&g(null,{stack:u,id:p,glyph:D[p]||null})}))}),((u,p)=>{if(u)n(u);else if(p){const g={};for(const{stack:_,id:v,glyph:w}of p)(g[_]||(g[_]={}))[v]=w&&{id:w.id,bitmap:w.bitmap.clone(),metrics:w.metrics};n(null,g)}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(o.u["CJK Unified Ideographs"](t)||o.u["Hangul Syllables"](t)||o.u.Hiragana(t)||o.u.Katakana(t))}_tinySDF(t,n,s){const u=this.localIdeographFontFamily;if(!u||!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 pt.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:u,fontWeight:_})}const g=p.draw(String.fromCharCode(s));return{id:s,bitmap:new o.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}}}}pt.loadGlyphRange=function(h,t,n,s,u){const p=256*t,g=p+255,_=s.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${p}-${g}`),Ze.Glyphs);o.l(_,((v,w)=>{if(v)u(v);else if(w){const I={};for(const A of o.n(w))I[A.id]=A;u(null,I)}}))},pt.TinySDF=class{constructor({fontSize:h=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:u="sans-serif",fontWeight:p="normal",fontStyle:g="normal"}={}){this.buffer=t,this.cutoff=s,this.radius=n;const _=this.size=h+4*t,v=this._createCanvas(_),w=this.ctx=v.getContext("2d",{willReadFrequently:!0});w.font=`${g} ${p} ${h}px ${u}`,w.textBaseline="alphabetic",w.textAlign="left",w.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){const t=document.createElement("canvas");return t.width=t.height=h,t}draw(h){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:u,actualBoundingBoxRight:p}=this.ctx.measureText(h),g=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-u))),v=Math.min(this.size-this.buffer,g+Math.ceil(s)),w=_+2*this.buffer,I=v+2*this.buffer,A=Math.max(w*I,0),D=new Uint8ClampedArray(A),$={data:D,width:w,height:I,glyphWidth:_,glyphHeight:v,glyphTop:g,glyphLeft:0,glyphAdvance:t};if(_===0||v===0)return $;const{ctx:U,buffer:q,gridInner:N,gridOuter:ee}=this;U.clearRect(q,q,_,v),U.fillText(h,q,q+g);const oe=U.getImageData(q,q,_,v);ee.fill(wr,0,A),N.fill(0,0,A);for(let X=0;X<v;X++)for(let ie=0;ie<_;ie++){const ce=oe.data[4*(X*_+ie)+3]/255;if(ce===0)continue;const ue=(X+q)*w+ie+q;if(ce===1)ee[ue]=0,N[ue]=wr;else{const me=.5-ce;ee[ue]=me>0?me*me:0,N[ue]=me<0?me*me:0}}Le(ee,0,0,w,I,w,this.f,this.v,this.z),Le(N,q,q,_,v,w,this.f,this.v,this.z);for(let X=0;X<A;X++){const ie=Math.sqrt(ee[X])-Math.sqrt(N[X]);D[X]=Math.round(255-255*(ie/this.radius+this.cutoff))}return $}};class $t{constructor(){this.specification=o.v.light.position}possiblyEvaluate(t,n){return o.z(t.expression.evaluate(n))}interpolate(t,n,s){return{x:o.B.number(t.x,n.x,s),y:o.B.number(t.y,n.y,s),z:o.B.number(t.z,n.z,s)}}}let Rt;class Sr extends o.E{constructor(t){super(),Rt=Rt||new o.r({anchor:new o.D(o.v.light.anchor),position:new $t,color:new o.D(o.v.light.color),intensity:new o.D(o.v.light.intensity)}),this._transitionable=new o.T(Rt),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(o.t,t,n))for(const s in t){const u=t[s];s.endsWith("-transition")?this._transitionable.setTransition(s.slice(0,-11),u):this._transitionable.setValue(s,u)}}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)&&o.x(this,t.call(o.y,o.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:o.v})))}}class Li{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 u=[];let p=t.length%2==1?-t[t.length-1]*s:0,g=t[0]*s,_=!0;u.push({left:p,right:g,isDash:_,zeroLength:t[0]===0});let v=t[0];for(let w=1;w<t.length;w++){_=!_;const I=t[w];p=v*s,v+=I,g=v*s,u.push({left:p,right:g,isDash:_,zeroLength:I===0})}return u}addRoundDash(t,n,s){const u=n/2;for(let p=-s;p<=s;p++){const g=this.width*(this.nextRow+s+p);let _=0,v=t[_];for(let w=0;w<this.width;w++){w/v.right>1&&(v=t[++_]);const I=Math.abs(w-v.left),A=Math.abs(w-v.right),D=Math.min(I,A);let $;const U=p/s*(u+1);if(v.isDash){const q=u-Math.abs(U);$=Math.sqrt(D*D+q*q)}else $=u-Math.sqrt(D*D+U*U);this.data[g+w]=Math.max(0,Math.min(255,$+128))}}}addRegularDash(t){for(let _=t.length-1;_>=0;--_){const v=t[_],w=t[_+1];v.zeroLength?t.splice(_,1):w&&w.isDash===v.isDash&&(w.left=v.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 u=this.width*this.nextRow;let p=0,g=t[p];for(let _=0;_<this.width;_++){_/g.right>1&&(g=t[++p]);const v=Math.abs(_-g.left),w=Math.abs(_-g.right),I=Math.min(v,w);this.data[u+_]=Math.max(0,Math.min(255,(g.isDash?I:-I)+128))}}addDash(t,n){const s=n?7:0,u=2*s+1;if(this.nextRow+u>this.height)return o.w("LineAtlas out of space"),null;let p=0;for(let _=0;_<t.length;_++)p+=t[_];if(p!==0){const _=this.width/p,v=this.getDashRanges(t,this.width,_);n?this.addRoundDash(v,_,s):this.addRegularDash(v)}const g={y:(this.nextRow+s+.5)/this.height,height:2*s/this.height,width:p};return this.nextRow+=u,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 da{constructor(t,n,s){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=s;const u=this.workerPool.acquire(s);for(let p=0;p<u.length;p++){const g=new o.C(u[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){o.o(this.actors,((u,p)=>{u.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 Tr(h,t,n){const s=function(u,p){if(u)return n(u);if(p){const g=o.F(o.e(p,h),["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 h.url?o.f(t.transformRequest(h.url,Ze.Source),s):o.h.frame((()=>s(null,h)))}class Pt{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 o.L?new o.L(t.lng,t.lat):o.L.convert(t),this}setSouthWest(t){return this._sw=t instanceof o.L?new o.L(t.lng,t.lat):o.L.convert(t),this}extend(t){const n=this._sw,s=this._ne;let u,p;if(t instanceof o.L)u=t,p=t;else{if(!(t instanceof Pt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Pt.convert(t)):this.extend(o.L.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(o.L.convert(t)):this;if(u=t._sw,p=t._ne,!u||!p)return this}return n||s?(n.lng=Math.min(u.lng,n.lng),n.lat=Math.min(u.lat,n.lat),s.lng=Math.max(p.lng,s.lng),s.lat=Math.max(p.lat,s.lat)):(this._sw=new o.L(u.lng,u.lat),this._ne=new o.L(p.lng,p.lat)),this}getCenter(){return new o.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 o.L(this.getWest(),this.getNorth())}getSouthEast(){return new o.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}=o.L.convert(t);let u=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(u=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=s&&s<=this._ne.lat&&u}static convert(t){return t instanceof Pt?t:t&&new Pt(t)}static fromLngLat(t,n=0){const s=360*n/40075017,u=s/Math.cos(Math.PI/180*t.lat);return new Pt(new o.L(t.lng-u,t.lat-s),new o.L(t.lng+u,t.lat+s))}}class Ri{constructor(t,n,s){this.bounds=Pt.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(o.G(this.bounds.getWest())*n),u=Math.floor(o.H(this.bounds.getNorth())*n),p=Math.ceil(o.G(this.bounds.getEast())*n),g=Math.ceil(o.H(this.bounds.getSouth())*n);return t.x>=s&&t.x<p&&t.y>=u&&t.y<g}}class gn extends o.E{constructor(t,n,s,u){if(super(),this.load=()=>{this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Tr(this._options,this.map._requestManager,((p,g)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),p?this.fire(new o.j(p)):g&&(o.e(this,g),g.bounds&&(this.tileBounds=new Ri(g.bounds,this.minzoom,this.maxzoom)),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new o.k("data",{dataType:"source",sourceDataType:"content"})))}))},this.serialize=()=>o.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,o.e(this,o.F(n,["url","scheme","tileSize","promoteId"])),this._options=o.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(u)}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),u={request:this.map._requestManager.transformRequest(s,Ze.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)))}u.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",u,p.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",u,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 Un extends o.E{constructor(t,n,s,u){super(),this.id=t,this.dispatcher=s,this.setEventedParent(u),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=o.e({type:"raster"},n),o.e(this,o.F(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Tr(this._options,this.map._requestManager,((t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new o.j(t)):n&&(o.e(this,n),n.bounds&&(this.tileBounds=new Ri(n.bounds,this.minzoom,this.maxzoom)),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new o.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 o.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=Be.getImage(this.map._requestManager.transformRequest(s,Ze.Tile),((u,p,g)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(u)t.state="errored",n(u);else if(p){this.map._refreshExpiredTiles&&g&&t.setExpiryData(g);const _=this.map.painter.context,v=_.gl;t.texture=this.map.painter.getTileTexture(p.width),t.texture?t.texture.update(p,{useMipmap:!0}):(t.texture=new Mt(_,p,v.RGBA,{useMipmap:!0}),t.texture.bind(v.LINEAR,v.CLAMP_TO_EDGE,v.LINEAR_MIPMAP_NEAREST),_.extTextureFilterAnisotropic&&v.texParameterf(v.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 $n extends Un{constructor(t,n,s,u){super(t,n,s,u),this.type="raster-dem",this.maxzoom=22,this._options=o.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),u=this.map._requestManager.transformRequest(s,Ze.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=Be.getImage(u,((g,_,v)=>o._(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(v);const w=o.a(_)&&o.J()?_:yield(function(A){return o._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&o.K()){const D=A.width+2,$=A.height+2;try{return new o.R({width:D,height:$},yield o.M(A,-1,-1,D,$))}catch{}}return o.h.getImageData(A,1)}))})(_),I={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:w,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",I,p))}}))),this.map._refreshExpiredTiles)}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),u=(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,v={};return v[new o.O(t.overscaledZ,p,n.z,u,n.y).key]={backfilled:!1},v[new o.O(t.overscaledZ,_,n.z,g,n.y).key]={backfilled:!1},n.y>0&&(v[new o.O(t.overscaledZ,p,n.z,u,n.y-1).key]={backfilled:!1},v[new o.O(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},v[new o.O(t.overscaledZ,_,n.z,g,n.y-1).key]={backfilled:!1}),n.y+1<s&&(v[new o.O(t.overscaledZ,p,n.z,u,n.y+1).key]={backfilled:!1},v[new o.O(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},v[new o.O(t.overscaledZ,_,n.z,g,n.y+1).key]={backfilled:!1}),v}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 Jr extends o.E{constructor(t,n,s,u){super(),this.load=()=>{this._updateWorkerData()},this.serialize=()=>o.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(u),this._data=n.data,this._options=o.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=o.N/this.tileSize;this.workerOptions=o.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:o.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:o.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,u){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:s},u),this}_updateWorkerData(t){const n=o.e({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(o.h.resolveURL(this._data),Ze.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new o.k("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,((s,u)=>{if(this._pendingLoads--,this._removed||u&&u.abandoned)return void this.fire(new o.k("dataabort",{dataType:"source"}));let p=null;if(u&&u.resourceTiming&&u.resourceTiming[this.id]&&(p=u.resourceTiming[this.id].slice(0)),s)return void this.fire(new o.j(s));const g={dataType:"source"};this._collectResourceTiming&&p&&p.length>0&&o.e(g,{resourceTiming:p}),this.fire(new o.k("data",Object.assign(Object.assign({},g),{sourceDataType:"metadata"}))),this.fire(new o.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 u={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,u,((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 _r=o.Q([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class sr extends o.E{constructor(t,n,s,u){super(),this.load=(p,g)=>{this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Be.getImage(this.map._requestManager.transformRequest(this.url,Ze.Image),((_,v)=>{this._request=null,this._loaded=!0,_?this.fire(new o.j(_)):v&&(this.image=v,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,_r.members)),this.boundsSegments||(this.boundsSegments=o.S.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Mt(p,this.image,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let _=!1;for(const v in this.tiles){const w=this.tiles[v];w.state!=="loaded"&&(w.state="loaded",w.texture=this.texture,_=!0)}_&&this.fire(new o.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(u),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 o.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(o.U.fromLngLat);this.tileID=(function(u){let p=1/0,g=1/0,_=-1/0,v=-1/0;for(const D of u)p=Math.min(p,D.x),g=Math.min(g,D.y),_=Math.max(_,D.x),v=Math.max(v,D.y);const w=Math.max(_-p,v-g),I=Math.max(0,Math.floor(-Math.log(w)/Math.LN2)),A=Math.pow(2,I);return new o.W(I,Math.floor((p+_)/2*A),Math.floor((g+v)/2*A))})(n),this.minzoom=this.maxzoom=this.tileID.z;const s=n.map((u=>this.tileID.getTilePoint(u)._round()));return this._boundsArray=new o.V,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,o.N,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,o.N),this._boundsArray.emplaceBack(s[2].x,s[2].y,o.N,o.N),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new o.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 fa extends sr{constructor(t,n,s,u){super(t,n,s,u),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,Ze.Source).url);o.X(this.urls,((g,_)=>{this._loaded=!0,g?this.fire(new o.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,_r.members)),this.boundsSegments||(this.boundsSegments=o.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 Mt(p,this.video,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let _=!1;for(const v in this.tiles){const w=this.tiles[v];w.state!=="loaded"&&(w.state="loaded",w.texture=this.texture,_=!0)}_&&this.fire(new o.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 o.j(new o.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 Qr extends sr{constructor(t,n,s,u){super(t,n,s,u),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 o.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,_r.members)),this.boundsSegments||(this.boundsSegments=o.S.simpleSegment(0,0,4,2)),this.texture?(p||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Mt(g,this.canvas,_.RGBA,{premultiply:!0});let v=!1;for(const w in this.tiles){const I=this.tiles[w];I.state!=="loaded"&&(I.state="loaded",I.texture=this.texture,v=!0)}v&&this.fire(new o.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 o.j(new o.Y(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new o.j(new o.Y(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new o.j(new o.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 o.j(new o.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 o.j(new o.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 ma={},Fr=h=>{switch(h){case"geojson":return Jr;case"image":return sr;case"raster":return Un;case"raster-dem":return $n;case"vector":return gn;case"video":return fa;case"canvas":return Qr}return ma[h]};function jn(h,t){const n=o.Z();return o.$(n,n,[1,1,0]),o.a0(n,n,[.5*h.width,.5*h.height,1]),o.a1(n,n,h.calculatePosMatrix(t.toUnwrapped()))}function _n(h,t,n,s,u,p){const g=(function(A,D,$){if(A)for(const U of A){const q=D[U];if(q&&q.source===$&&q.type==="fill-extrusion")return!0}else for(const U in D){const q=D[U];if(q.source===$&&q.type==="fill-extrusion")return!0}return!1})(u&&u.layers,t,h.id),_=p.maxPitchScaleFactor(),v=h.tilesIn(s,_,g);v.sort(en);const w=[];for(const A of v)w.push({wrappedTileID:A.tileID.wrapped().key,queryResults:A.tile.queryRenderedFeatures(t,n,h._state,A.queryGeometry,A.cameraQueryGeometry,A.scale,u,p,_,jn(h.transform,A.tileID))});const I=(function(A){const D={},$={};for(const U of A){const q=U.queryResults,N=U.wrappedTileID,ee=$[N]=$[N]||{};for(const oe in q){const X=q[oe],ie=ee[oe]=ee[oe]||{},ce=D[oe]=D[oe]||[];for(const ue of X)ie[ue.featureIndex]||(ie[ue.featureIndex]=!0,ce.push(ue))}}return D})(w);for(const A in I)I[A].forEach((D=>{const $=D.feature,U=h.getFeatureState($.layer["source-layer"],$.id);$.source=$.layer.source,$.layer["source-layer"]&&($.sourceLayer=$.layer["source-layer"]),$.state=U}));return I}function en(h,t){const n=h.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 tn{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=o.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(u,p){const g={};if(!p)return g;for(const _ of u){const v=_.layerIds.map((w=>p.getLayer(w))).filter(Boolean);if(v.length!==0){_.layers=v,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((w=>v.filter((I=>I.id===w))[0])));for(const w of v)g[w.id]=_}}return g})(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const u in this.buckets){const p=this.buckets[u];if(p instanceof o.a4){if(this.hasSymbolBuckets=!0,!s)break;p.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const u in this.buckets){const p=this.buckets[u];if(p instanceof o.a4&&p.hasRTLText){this.hasRTLText=!0,o.a5();break}}this.queryPadding=0;for(const u in this.buckets){const p=this.buckets[u];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(u).queryRadius(p))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new o.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 u=this.buckets[s];u.uploadPending()&&u.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Mt(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Mt(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,s,u,p,g,_,v,w,I){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:u,cameraQueryGeometry:p,scale:g,tileSize:this.tileSize,pixelPosMatrix:I,transform:v,params:_,queryPadding:this.queryPadding*w},t,n,s):{}}querySourceFeatures(t,n){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const u=s.loadVTLayers(),p=n&&n.sourceLayer?n.sourceLayer:"",g=u._geojsonTileLayer||u[p];if(!g)return;const _=o.a6(n&&n.filter),{z:v,x:w,y:I}=this.tileID.canonical,A={z:v,x:w,y:I};for(let D=0;D<g.length;D++){const $=g.feature(D);if(_.needGeometry){const N=o.a7($,!0);if(!_.filter(new o.a8(this.tileID.overscaledZ),N,this.tileID.canonical))continue}else if(!_.filter(new o.a8(this.tileID.overscaledZ),$))continue;const U=s.getId($,p),q=new o.a9($,v,w,I,U);q.tile=A,t.push(q)}}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=o.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 u=!1;if(this.expirationTime>s)u=!1;else if(n)if(this.expirationTime<n)u=!0;else{const p=this.expirationTime-n;p?this.expirationTime=s+Math.max(p,3e4):u=!0}else u=!0;u?(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 u in this.buckets){if(!n.style.hasLayer(u))continue;const p=this.buckets[u],g=p.layers[0].sourceLayer||"_geojsonTileLayer",_=s[g],v=t[g];if(!_||!v||Object.keys(v).length===0)continue;p.update(v,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});const w=n&&n.style&&n.style.getLayer(u);w&&(this.queryPadding=Math.max(this.queryPadding,w.queryRadius(p)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<o.h.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=o.h.now()+t}setDependencies(t,n){const s={};for(const u of n)s[u]=!0;this.dependencies[t]=s}hasDependency(t,n){for(const s of t){const u=this.dependencies[s];if(u){for(const p of n)if(u[p])return!0}}return!1}}class yn{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 u=t.wrapped().key;this.data[u]===void 0&&(this.data[u]=[]);const p={value:n,timeout:void 0};if(s!==void 0&&(p.timeout=setTimeout((()=>{this.remove(t,p)}),s)),this.data[u].push(p),this.order.push(u),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,u=n===void 0?0:this.data[s].indexOf(n),p=this.data[s][u];return this.data[s].splice(u,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 u of this.data[s])t(u.value)||n.push(u);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 u=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][u]=this.stateChanges[t][u]||{},o.e(this.stateChanges[t][u],s),this.deletedStates[t]===null){this.deletedStates[t]={};for(const p in this.state[t])p!==u&&(this.deletedStates[t][p]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][u]===null){this.deletedStates[t][u]={};for(const p in this.state[t][u])s[p]||(this.deletedStates[t][u][p]=null)}else for(const p in s)this.deletedStates[t]&&this.deletedStates[t][u]&&this.deletedStates[t][u][p]===null&&delete this.deletedStates[t][u][p]}removeFeatureState(t,n,s){if(this.deletedStates[t]===null)return;const u=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},s&&n!==void 0)this.deletedStates[t][u]!==null&&(this.deletedStates[t][u]=this.deletedStates[t][u]||{},this.deletedStates[t][u][s]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][u])for(s in this.deletedStates[t][u]={},this.stateChanges[t][u])this.deletedStates[t][u][s]=null;else this.deletedStates[t][u]=null;else this.deletedStates[t]=null}getState(t,n){const s=String(n),u=o.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 u[g]}return u}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const s={};for(const u in this.stateChanges){this.state[u]=this.state[u]||{};const p={};for(const g in this.stateChanges[u])this.state[u][g]||(this.state[u][g]={}),o.e(this.state[u][g],this.stateChanges[u][g]),p[g]=this.state[u][g];s[u]=p}for(const u in this.deletedStates){this.state[u]=this.state[u]||{};const p={};if(this.deletedStates[u]===null)for(const g in this.state[u])p[g]={},this.state[u][g]={};else for(const g in this.deletedStates[u]){if(this.deletedStates[u][g]===null)this.state[u][g]={};else for(const _ of Object.keys(this.deletedStates[u][g]))delete this.state[u][g][_];p[g]=this.state[u][g]}s[u]=s[u]||{},o.e(s[u],p)}if(this.stateChanges={},this.deletedStates={},Object.keys(s).length!==0)for(const u in t)t[u].setFeatureState(s,n)}}class Fi extends o.E{constructor(t,n,s){super(),this.id=t,this.dispatcher=s,this.on("data",(u=>{u.dataType==="source"&&u.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&u.dataType==="source"&&u.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=((u,p,g,_)=>{const v=new(Fr(p.type))(u,p,g,_);if(v.id!==u)throw new Error(`Expected Source id to be ${u} instead of ${v.id}`);return v})(t,n,s,this),this._tiles={},this._cache=new yn(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 o.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(or).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,u)=>{const p=s.tileID,g=u.tileID,_=new o.P(p.canonical.x,p.canonical.y)._rotate(this.transform.angle),v=new o.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle);return p.overscaledZ-g.overscaledZ||v.y-_.y||v.x-_.x})).map((s=>s.tileID.key)):n.map((s=>s.tileID)).sort(or).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,u){if(u)return t.state="errored",void(u.status!==404?this._source.fire(new o.j(u,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=o.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 o.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let u=0;u<n.length;u++){const p=n[u];if(t.neighboringTiles&&t.neighboringTiles[p]){const g=this.getTileByID(p);s(t,g),s(g,t)}}function s(u,p){u.needsHillshadePrepare=!0,u.needsTerrainPrepare=!0;let g=p.tileID.canonical.x-u.tileID.canonical.x;const _=p.tileID.canonical.y-u.tileID.canonical.y,v=Math.pow(2,u.tileID.canonical.z),w=p.tileID.key;g===0&&_===0||Math.abs(_)>1||(Math.abs(g)>1&&(Math.abs(g+v)===1?g+=v:Math.abs(g-v)===1&&(g-=v)),p.dem&&u.dem&&(u.dem.backfillBorder(p.dem,g,_),u.neighboringTiles&&u.neighboringTiles[w]&&(u.neighboringTiles[w].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,s,u){for(const p in this._tiles){let g=this._tiles[p];if(u[p]||!g.hasData()||g.tileID.overscaledZ<=n||g.tileID.overscaledZ>s)continue;let _=g.tileID;for(;g&&g.tileID.overscaledZ>n+1;){const w=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[w.key],g&&g.hasData()&&(_=w)}let v=_;for(;v.overscaledZ>n;)if(v=v.scaledTo(v.overscaledZ-1),t[v.key]){u[_.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 u=t.scaledTo(s),p=this._getLoadedTile(u);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,u=Math.floor(n*s*(this._maxTileCacheZoomLevels===null?o.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,u):u;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 u in this._tiles){const p=this._tiles[u];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+n),s[p.tileID.key]=p}this._tiles=s;for(const u in this._timers)clearTimeout(this._timers[u]),delete this._timers[u];for(const u in this._tiles)this._setTileReloadTimer(u,this._tiles[u])}}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((I=>new o.O(I.canonical.z,I.wrap,I.canonical.z,I.canonical.x,I.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((I=>this._source.hasTile(I))))):s=[];const u=t.coveringZoomLevel(this._source),p=Math.max(u-Fi.maxOverzooming,this._source.minzoom),g=Math.max(u+Fi.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const I={};for(const A of s)if(A.canonical.z>this._source.minzoom){const D=A.scaledTo(A.canonical.z-1);I[D.key]=D;const $=A.scaledTo(Math.max(this._source.minzoom,Math.min(A.canonical.z,5)));I[$.key]=$}s=s.concat(Object.values(I))}const _=s.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new o.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const v=this._updateRetainedTiles(s,u);if(At(this._source.type)){const I={},A={},D=Object.keys(v),$=o.h.now();for(const U of D){const q=v[U],N=this._tiles[U];if(!N||N.fadeEndTime!==0&&N.fadeEndTime<=$)continue;const ee=this.findLoadedParent(q,p);ee&&(this._addTile(ee.tileID),I[ee.tileID.key]=ee.tileID),A[U]=q}this._retainLoadedChildren(A,u,g,v);for(const U in I)v[U]||(this._coveredTiles[U]=!0,v[U]=I[U]);if(n){const U={},q={};for(const N of s)this._tiles[N.key].hasData()?U[N.key]=N:q[N.key]=N;for(const N in q){const ee=q[N].children(this._source.maxzoom);this._tiles[ee[0].key]&&this._tiles[ee[1].key]&&this._tiles[ee[2].key]&&this._tiles[ee[3].key]&&(U[ee[0].key]=v[ee[0].key]=ee[0],U[ee[1].key]=v[ee[1].key]=ee[1],U[ee[2].key]=v[ee[2].key]=ee[2],U[ee[3].key]=v[ee[3].key]=ee[3],delete q[N])}for(const N in q){const ee=this.findLoadedParent(q[N],this._source.minzoom);if(ee){U[ee.tileID.key]=v[ee.tileID.key]=ee.tileID;for(const oe in U)U[oe].isChildOf(ee.tileID)&&delete U[oe]}}for(const N in this._tiles)U[N]||(this._coveredTiles[N]=!0)}}for(const I in v)this._tiles[I].clearFadeHold();const w=o.ab(this._tiles,v);for(const I of w){const A=this._tiles[I];A.hasSymbolBuckets&&!A.holdingForFade()?A.setHoldDuration(this.map._fadeDuration):A.hasSymbolBuckets&&!A.symbolFadeFinished()||this._removeTile(I)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const s={},u={},p=Math.max(n-Fi.maxOverzooming,this._source.minzoom),g=Math.max(n+Fi.maxUnderzooming,this._source.minzoom),_={};for(const v of t){const w=this._addTile(v);s[v.key]=v,w.hasData()||n<this._source.maxzoom&&(_[v.key]=v)}this._retainLoadedChildren(_,n,g,s);for(const v of t){let w=this._tiles[v.key];if(w.hasData())continue;if(n+1>this._source.maxzoom){const A=v.children(this._source.maxzoom)[0],D=this.getTile(A);if(D&&D.hasData()){s[A.key]=A;continue}}else{const A=v.children(this._source.maxzoom);if(s[A[0].key]&&s[A[1].key]&&s[A[2].key]&&s[A[3].key])continue}let I=w.wasRequested();for(let A=v.overscaledZ-1;A>=p;--A){const D=v.scaledTo(A);if(u[D.key])break;if(u[D.key]=!0,w=this.getTile(D),!w&&I&&(w=this._addTile(D)),w){const $=w.hasData();if((I||$)&&(s[D.key]=D),I=w.wasRequested(),$)break}}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let s,u=this._tiles[t].tileID;for(;u.overscaledZ>0;){if(u.key in this._loadedParentTiles){s=this._loadedParentTiles[u.key];break}n.push(u.key);const p=u.scaledTo(u.overscaledZ-1);if(s=this._getLoadedTile(p),s)break;u=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 tn(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 o.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 u=[],p=this.transform;if(!p)return u;const g=s?p.getCameraQueryGeometry(t):t,_=t.map((U=>p.pointCoordinate(U,this.terrain))),v=g.map((U=>p.pointCoordinate(U,this.terrain))),w=this.getIds();let I=1/0,A=1/0,D=-1/0,$=-1/0;for(const U of v)I=Math.min(I,U.x),A=Math.min(A,U.y),D=Math.max(D,U.x),$=Math.max($,U.y);for(let U=0;U<w.length;U++){const q=this._tiles[w[U]];if(q.holdingForFade())continue;const N=q.tileID,ee=Math.pow(2,p.zoom-q.tileID.overscaledZ),oe=n*q.queryPadding*o.N/q.tileSize/ee,X=[N.getTilePoint(new o.U(I,A)),N.getTilePoint(new o.U(D,$))];if(X[0].x-oe<o.N&&X[0].y-oe<o.N&&X[1].x+oe>=0&&X[1].y+oe>=0){const ie=_.map((ue=>N.getTilePoint(ue))),ce=v.map((ue=>N.getTilePoint(ue)));u.push({tile:q,tileID:N,queryGeometry:ie,cameraQueryGeometry:ce,scale:ee})}}return u}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=o.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 u=this._tiles[t];u&&u.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 or(h,t){const n=Math.abs(2*h.wrap)-+(h.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return h.overscaledZ-t.overscaledZ||s-n||t.canonical.y-h.canonical.y||t.canonical.x-h.canonical.x}function At(h){return h==="raster"||h==="image"||h==="video"}Fi.maxOverzooming=10,Fi.maxUnderzooming=3;const _t="mapboxgl_preloaded_worker_pool";class Ir{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Ir.workerCount;)this.workers.push(new Worker(o.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 qn=Math.floor(o.h.hardwareConcurrency/2);let Br;function qa(){return Br||(Br=new Ir),Br}Ir.workerCount=o.ac(globalThis)?Math.max(Math.min(qn,3),1):1;class Zn{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=o.ad(t,0,1);let n=1,s=this._distances[n];const u=t*this.paddedLength+this.padding;for(;s<u&&n<this._distances.length;)s=this._distances[++n];const p=n-1,g=this._distances[p],_=s-g,v=_>0?(u-g)/_:0;return this.points[p].mult(1-v).add(this.points[n].mult(v))}}function rn(h,t){let n=!0;return h==="always"||h!=="never"&&t!=="never"||(n=!1),n}class xn{constructor(t,n,s){const u=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++)u.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,u,p){this._forEachCell(n,s,u,p,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(s),this.bboxes.push(u),this.bboxes.push(p)}insertCircle(t,n,s,u){this._forEachCell(n-u,s-u,n+u,s+u,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(s),this.circles.push(u)}_insertBoxCell(t,n,s,u,p,g){this.boxCells[p].push(g)}_insertCircleCell(t,n,s,u,p,g){this.circleCells[p].push(g)}_query(t,n,s,u,p,g,_){if(s<0||t>this.width||u<0||n>this.height)return[];const v=[];if(t<=0&&n<=0&&this.width<=s&&this.height<=u){if(p)return[{key:null,x1:t,y1:n,x2:s,y2:u}];for(let w=0;w<this.boxKeys.length;w++)v.push({key:this.boxKeys[w],x1:this.bboxes[4*w],y1:this.bboxes[4*w+1],x2:this.bboxes[4*w+2],y2:this.bboxes[4*w+3]});for(let w=0;w<this.circleKeys.length;w++){const I=this.circles[3*w],A=this.circles[3*w+1],D=this.circles[3*w+2];v.push({key:this.circleKeys[w],x1:I-D,y1:A-D,x2:I+D,y2:A+D})}}else this._forEachCell(t,n,s,u,this._queryCell,v,{hitTest:p,overlapMode:g,seenUids:{box:{},circle:{}}},_);return v}query(t,n,s,u){return this._query(t,n,s,u,!1,null)}hitTest(t,n,s,u,p,g){return this._query(t,n,s,u,!0,p,g).length>0}hitTestCircle(t,n,s,u,p){const g=t-s,_=t+s,v=n-s,w=n+s;if(_<0||g>this.width||w<0||v>this.height)return!1;const I=[];return this._forEachCell(g,v,_,w,this._queryCellCircle,I,{hitTest:!0,overlapMode:u,circle:{x:t,y:n,radius:s},seenUids:{box:{},circle:{}}},p),I.length>0}_queryCell(t,n,s,u,p,g,_,v){const{seenUids:w,hitTest:I,overlapMode:A}=_,D=this.boxCells[p];if(D!==null){const U=this.bboxes;for(const q of D)if(!w.box[q]){w.box[q]=!0;const N=4*q,ee=this.boxKeys[q];if(t<=U[N+2]&&n<=U[N+3]&&s>=U[N+0]&&u>=U[N+1]&&(!v||v(ee))&&(!I||!rn(A,ee.overlapMode))&&(g.push({key:ee,x1:U[N],y1:U[N+1],x2:U[N+2],y2:U[N+3]}),I))return!0}}const $=this.circleCells[p];if($!==null){const U=this.circles;for(const q of $)if(!w.circle[q]){w.circle[q]=!0;const N=3*q,ee=this.circleKeys[q];if(this._circleAndRectCollide(U[N],U[N+1],U[N+2],t,n,s,u)&&(!v||v(ee))&&(!I||!rn(A,ee.overlapMode))){const oe=U[N],X=U[N+1],ie=U[N+2];if(g.push({key:ee,x1:oe-ie,y1:X-ie,x2:oe+ie,y2:X+ie}),I)return!0}}}return!1}_queryCellCircle(t,n,s,u,p,g,_,v){const{circle:w,seenUids:I,overlapMode:A}=_,D=this.boxCells[p];if(D!==null){const U=this.bboxes;for(const q of D)if(!I.box[q]){I.box[q]=!0;const N=4*q,ee=this.boxKeys[q];if(this._circleAndRectCollide(w.x,w.y,w.radius,U[N+0],U[N+1],U[N+2],U[N+3])&&(!v||v(ee))&&!rn(A,ee.overlapMode))return g.push(!0),!0}}const $=this.circleCells[p];if($!==null){const U=this.circles;for(const q of $)if(!I.circle[q]){I.circle[q]=!0;const N=3*q,ee=this.circleKeys[q];if(this._circlesCollide(U[N],U[N+1],U[N+2],w.x,w.y,w.radius)&&(!v||v(ee))&&!rn(A,ee.overlapMode))return g.push(!0),!0}}}_forEachCell(t,n,s,u,p,g,_,v){const w=this._convertToXCellCoord(t),I=this._convertToYCellCoord(n),A=this._convertToXCellCoord(s),D=this._convertToYCellCoord(u);for(let $=w;$<=A;$++)for(let U=I;U<=D;U++)if(p.call(this,t,n,s,u,this.xCellCount*U+$,g,_,v))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,u,p,g){const _=u-t,v=p-n,w=s+g;return w*w>_*_+v*v}_circleAndRectCollide(t,n,s,u,p,g,_){const v=(g-u)/2,w=Math.abs(t-(u+v));if(w>v+s)return!1;const I=(_-p)/2,A=Math.abs(n-(p+I));if(A>I+s)return!1;if(w<=v||A<=I)return!0;const D=w-v,$=A-I;return D*D+$*$<=s*s}}function Ae(h,t,n,s,u){const p=o.Z();return t?(o.a0(p,p,[1/u,1/u,1]),n||o.ae(p,p,s.angle)):o.a1(p,s.labelPlaneMatrix,h),p}function Ar(h,t,n,s,u){if(t){const p=o.af(h);return o.a0(p,p,[u,u,1]),n||o.ae(p,p,-s.angle),p}return s.glCoordMatrix}function jt(h,t,n){let s;n?(s=[h.x,h.y,n(h.x,h.y),1],o.ag(s,s,t)):(s=[h.x,h.y,0,1],Z(s,s,t));const u=s[3];return{point:new o.P(s[0]/u,s[1]/u),signedDistanceFromCamera:u}}function vn(h,t){return .5+h/t*.5}function Or(h,t){const n=h[0]/h[3],s=h[1]/h[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function ke(h,t,n,s,u,p,g,_,v,w){const I=s?h.textSizeData:h.iconSizeData,A=o.ah(I,n.transform.zoom),D=[256/n.width*2+1,256/n.height*2+1],$=s?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;$.clear();const U=h.lineVertexArray,q=s?h.text.placedSymbolArray:h.icon.placedSymbolArray,N=n.transform.width/n.transform.height;let ee=!1;for(let oe=0;oe<q.length;oe++){const X=q.get(oe);if(X.hidden||X.writingMode===o.ai.vertical&&!ee){F(X.numGlyphs,$);continue}let ie;if(ee=!1,w?(ie=[X.anchorX,X.anchorY,w(X.anchorX,X.anchorY),1],o.ag(ie,ie,t)):(ie=[X.anchorX,X.anchorY,0,1],Z(ie,ie,t)),!Or(ie,D)){F(X.numGlyphs,$);continue}const ce=vn(n.transform.cameraToCenterDistance,ie[3]),ue=o.aj(I,A,X),me=g?ue/ce:ue*ce,be=new o.P(X.anchorX,X.anchorY),xe=jt(be,u,w).point,Se={projections:{},offsets:{}},Ne=Ii(X,me,!1,_,t,u,p,h.glyphOffsetArray,U,$,xe,be,Se,N,v,w);ee=Ne.useVertical,(Ne.notEnoughRoom||ee||Ne.needsFlipping&&Ii(X,me,!0,_,t,u,p,h.glyphOffsetArray,U,$,xe,be,Se,N,v,w).notEnoughRoom)&&F(X.numGlyphs,$)}s?h.text.dynamicLayoutVertexBuffer.updateData($):h.icon.dynamicLayoutVertexBuffer.updateData($)}function st(h,t,n,s,u,p,g,_,v,w,I,A,D){const $=_.glyphStartIndex+_.numGlyphs,U=_.lineStartIndex,q=_.lineStartIndex+_.lineLength,N=t.getoffsetX(_.glyphStartIndex),ee=t.getoffsetX($-1),oe=E(h*N,n,s,u,p,g,_.segment,U,q,v,w,I,A,D);if(!oe)return null;const X=E(h*ee,n,s,u,p,g,_.segment,U,q,v,w,I,A,D);return X?{first:oe,last:X}:null}function tt(h,t,n,s){return h===o.ai.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*s?{useVertical:!0}:(h===o.ai.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function Ii(h,t,n,s,u,p,g,_,v,w,I,A,D,$,U,q){const N=t/24,ee=h.lineOffsetX*N,oe=h.lineOffsetY*N;let X;if(h.numGlyphs>1){const ie=h.glyphStartIndex+h.numGlyphs,ce=h.lineStartIndex,ue=h.lineStartIndex+h.lineLength,me=st(N,_,ee,oe,n,I,A,h,v,p,D,U,q);if(!me)return{notEnoughRoom:!0};const be=jt(me.first.point,g,q).point,xe=jt(me.last.point,g,q).point;if(s&&!n){const Se=tt(h.writingMode,be,xe,$);if(Se)return Se}X=[me.first];for(let Se=h.glyphStartIndex+1;Se<ie-1;Se++)X.push(E(N*_.getoffsetX(Se),ee,oe,n,I,A,h.segment,ce,ue,v,p,D,U,q));X.push(me.last)}else{if(s&&!n){const ce=jt(A,u,q).point,ue=h.lineStartIndex+h.segment+1,me=new o.P(v.getx(ue),v.gety(ue)),be=jt(me,u,q),xe=be.signedDistanceFromCamera>0?be.point:Cr(A,me,ce,1,u,q),Se=tt(h.writingMode,ce,xe,$);if(Se)return Se}const ie=E(N*_.getoffsetX(h.glyphStartIndex),ee,oe,n,I,A,h.segment,h.lineStartIndex,h.lineStartIndex+h.lineLength,v,p,D,U,q);if(!ie)return{notEnoughRoom:!0};X=[ie]}for(const ie of X)o.ak(w,ie.point,ie.angle);return{}}function Cr(h,t,n,s,u,p){const g=jt(h.add(h.sub(t)._unit()),u,p).point,_=n.sub(g);return n.add(_._mult(s/_.mag()))}function nt(h,t){const{projectionCache:n,lineVertexArray:s,labelPlaneMatrix:u,tileAnchorPoint:p,distanceFromAnchor:g,getElevation:_,previousVertex:v,direction:w,absOffsetX:I}=t;if(n.projections[h])return n.projections[h];const A=new o.P(s.getx(h),s.gety(h)),D=jt(A,u,_);if(D.signedDistanceFromCamera>0)return n.projections[h]=D.point,D.point;const $=h-w;return Cr(g===0?p:new o.P(s.getx($),s.gety($)),A,v,I-g+1,u,_)}function Nr(h,t,n){return h._unit()._perp()._mult(t*n)}function j(h,t,n,s,u,p,g,_){const{projectionCache:v,direction:w}=_;if(v.offsets[h])return v.offsets[h];const I=n.add(t);if(h+w<s||h+w>=u)return v.offsets[h]=I,I;const A=nt(h+w,_),D=Nr(A.sub(n),g,w),$=n.add(D),U=A.add(D);return v.offsets[h]=o.al(p,I,$,U)||I,v.offsets[h]}function E(h,t,n,s,u,p,g,_,v,w,I,A,D,$){const U=s?h-t:h+t;let q=U>0?1:-1,N=0;s&&(q*=-1,N=Math.PI),q<0&&(N+=Math.PI);let ee,oe,X=q>0?_+g:_+g+1,ie=u,ce=u,ue=0,me=0;const be=Math.abs(U),xe=[];let Se;for(;ue+me<=be;){if(X+=q,X<_||X>=v)return null;ue+=me,ce=ie,oe=ee;const Ee={projectionCache:A,lineVertexArray:w,labelPlaneMatrix:I,tileAnchorPoint:p,distanceFromAnchor:ue,getElevation:$,previousVertex:ce,direction:q,absOffsetX:be};if(ie=nt(X,Ee),n===0)xe.push(ce),Se=ie.sub(ce);else{let Je;const $e=ie.sub(ce);Je=$e.mag()===0?Nr(nt(X+q,Ee).sub(ie),n,q):Nr($e,n,q),oe||(oe=ce.add(Je)),ee=j(X,Je,ie,_,v,oe,n,Ee),xe.push(oe),Se=ee.sub(oe)}me=Se.mag()}const Ne=Se._mult((be-ue)/me)._add(oe||ce),ct=N+Math.atan2(ie.y-ce.y,ie.x-ce.x);return xe.push(Ne),{point:Ne,angle:D?ct:0,path:xe}}const z=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function F(h,t){for(let n=0;n<h;n++){const s=t.length;t.resize(s+4),t.float32.set(z,3*s)}}function Z(h,t,n){const s=t[0],u=t[1];return h[0]=n[0]*s+n[4]*u+n[12],h[1]=n[1]*s+n[5]*u+n[13],h[3]=n[3]*s+n[7]*u+n[15],h}const W=100;class ae{constructor(t,n=new xn(t.width+200,t.height+200,25),s=new xn(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+W,this.screenBottomBoundary=t.height+W,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,s,u,p,g){const _=this.projectAndGetPerspectiveRatio(u,t.anchorPointX,t.anchorPointY,g),v=s*_.perspectiveRatio,w=t.x1*v+_.point.x,I=t.y1*v+_.point.y,A=t.x2*v+_.point.x,D=t.y2*v+_.point.y;return!this.isInsideGrid(w,I,A,D)||n!=="always"&&this.grid.hitTest(w,I,A,D,n,p)||_.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[w,I,A,D],offscreen:this.isOffscreen(w,I,A,D)}}placeCollisionCircles(t,n,s,u,p,g,_,v,w,I,A,D,$,U){const q=[],N=new o.P(n.anchorX,n.anchorY),ee=jt(N,g,U),oe=vn(this.transform.cameraToCenterDistance,ee.signedDistanceFromCamera),X=(I?p/oe:p*oe)/o.ap,ie=jt(N,_,U).point,ce=st(X,u,n.lineOffsetX*X,n.lineOffsetY*X,!1,ie,N,n,s,_,{projections:{},offsets:{}},!1,U);let ue=!1,me=!1,be=!0;if(ce){const xe=.5*D*oe+$,Se=new o.P(-100,-100),Ne=new o.P(this.screenRightBoundary,this.screenBottomBoundary),ct=new Zn,Ee=ce.first,Je=ce.last;let $e=[];for(let at=Ee.path.length-1;at>=1;at--)$e.push(Ee.path[at]);for(let at=1;at<Je.path.length;at++)$e.push(Je.path[at]);const St=2.5*xe;if(v){const at=$e.map((ut=>jt(ut,v,U)));$e=at.some((ut=>ut.signedDistanceFromCamera<=0))?[]:at.map((ut=>ut.point))}let lt=[];if($e.length>0){const at=$e[0].clone(),ut=$e[0].clone();for(let Ht=1;Ht<$e.length;Ht++)at.x=Math.min(at.x,$e[Ht].x),at.y=Math.min(at.y,$e[Ht].y),ut.x=Math.max(ut.x,$e[Ht].x),ut.y=Math.max(ut.y,$e[Ht].y);lt=at.x>=Se.x&&ut.x<=Ne.x&&at.y>=Se.y&&ut.y<=Ne.y?[$e]:ut.x<Se.x||at.x>Ne.x||ut.y<Se.y||at.y>Ne.y?[]:o.am([$e],Se.x,Se.y,Ne.x,Ne.y)}for(const at of lt){ct.reset(at,.25*xe);let ut=0;ut=ct.length<=.5*xe?1:Math.ceil(ct.paddedLength/St)+1;for(let Ht=0;Ht<ut;Ht++){const kt=Ht/Math.max(ut-1,1),mi=ct.lerp(kt),ri=mi.x+W,Yt=mi.y+W;q.push(ri,Yt,xe,0);const Ji=ri-xe,Dt=Yt-xe,Er=ri+xe,Mr=Yt+xe;if(be=be&&this.isOffscreen(Ji,Dt,Er,Mr),me=me||this.isInsideGrid(Ji,Dt,Er,Mr),t!=="always"&&this.grid.hitTestCircle(ri,Yt,xe,t,A)&&(ue=!0,!w))return{circles:[],offscreen:!1,collisionDetected:ue}}}}return{circles:!w&&ue||!me||oe<this.perspectiveRatioCutoff?[]:q,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,u=1/0,p=-1/0,g=-1/0;for(const I of t){const A=new o.P(I.x+W,I.y+W);s=Math.min(s,A.x),u=Math.min(u,A.y),p=Math.max(p,A.x),g=Math.max(g,A.y),n.push(A)}const _=this.grid.query(s,u,p,g).concat(this.ignoredGrid.query(s,u,p,g)),v={},w={};for(const I of _){const A=I.key;if(v[A.bucketInstanceId]===void 0&&(v[A.bucketInstanceId]={}),v[A.bucketInstanceId][A.featureIndex])continue;const D=[new o.P(I.x1,I.y1),new o.P(I.x2,I.y1),new o.P(I.x2,I.y2),new o.P(I.x1,I.y2)];o.an(n,D)&&(v[A.bucketInstanceId][A.featureIndex]=!0,w[A.bucketInstanceId]===void 0&&(w[A.bucketInstanceId]=[]),w[A.bucketInstanceId].push(A.featureIndex))}return w}insertCollisionBox(t,n,s,u,p,g){(s?this.ignoredGrid:this.grid).insert({bucketInstanceId:u,featureIndex:p,collisionGroupID:g,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,s,u,p,g){const _=s?this.ignoredGrid:this.grid,v={bucketInstanceId:u,featureIndex:p,collisionGroupID:g,overlapMode:n};for(let w=0;w<t.length;w+=4)_.insertCircle(v,t[w],t[w+1],t[w+2])}projectAndGetPerspectiveRatio(t,n,s,u){let p;return u?(p=[n,s,u(n,s),1],o.ag(p,p,t)):(p=[n,s,0,1],Z(p,p,t)),{point:new o.P((p[0]/p[3]+1)/2*this.transform.width+W,(-p[1]/p[3]+1)/2*this.transform.height+W),perspectiveRatio:.5+this.transform.cameraToCenterDistance/p[3]*.5}}isOffscreen(t,n,s,u){return s<W||t>=this.screenRightBoundary||u<W||n>this.screenBottomBoundary}isInsideGrid(t,n,s,u){return s>=0&&t<this.gridRightBoundary&&u>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=o.ao([]);return o.$(t,t,[-100,-100,0]),t}}function Q(h,t,n){return t*(o.N/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Y{constructor(t,n,s,u){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):u&&s?1:0,this.placed=s}isHidden(){return this.opacity===0&&!this.placed}}class re{constructor(t,n,s,u,p){this.text=new Y(t?t.text:null,n,s,p),this.icon=new Y(t?t.icon:null,n,u,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=o.Z(),this.viewportMatrix=o.Z(),this.circles=[]}}class ye{constructor(t,n,s,u,p){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=s,this.bucketIndex=u,this.tileID=p}}class We{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 et(h,t,n,s,u){const{horizontalAlign:p,verticalAlign:g}=o.au(h);return new o.P(-(p-.5)*t+s[0]*u,-(g-.5)*n+s[1]*u)}function Oe(h,t,n,s,u,p){const{x1:g,x2:_,y1:v,y2:w,anchorPointX:I,anchorPointY:A}=h,D=new o.P(t,n);return s&&D._rotate(u?p:-p),{x1:g+D.x,y1:v+D.y,x2:_+D.x,y2:w+D.y,anchorPointX:I,anchorPointY:A}}class Ke{constructor(t,n,s,u,p){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new ae(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=s,this.retainedQueryData={},this.collisionGroups=new We(u),this.collisionCircleArrays={},this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,u){const p=s.getBucket(n),g=s.latestFeatureIndex;if(!p||!g||n.id!==p.layerIds[0])return;const _=s.collisionBoxArray,v=p.layers[0].layout,w=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),I=s.tileSize/o.N,A=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),D=v.get("text-pitch-alignment")==="map",$=v.get("text-rotation-alignment")==="map",U=Q(s,1,this.transform.zoom),q=Ae(A,D,$,this.transform,U);let N=null;if(D){const oe=Ar(A,D,$,this.transform,U);N=o.a1([],this.transform.labelPlaneMatrix,oe)}this.retainedQueryData[p.bucketInstanceId]=new ye(p.bucketInstanceId,g,p.sourceLayerIndex,p.index,s.tileID);const ee={bucket:p,layout:v,posMatrix:A,textLabelPlaneMatrix:q,labelToScreenMatrix:N,scale:w,textPixelRatio:I,holdingForFade:s.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:o.ah(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(u)for(const oe of p.sortKeyRanges){const{sortKey:X,symbolInstanceStart:ie,symbolInstanceEnd:ce}=oe;t.push({sortKey:X,symbolInstanceStart:ie,symbolInstanceEnd:ce,parameters:ee})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(t,n,s,u,p,g,_,v,w,I,A,D,$,U,q,N){const ee=o.aq[t.textAnchor],oe=[t.textOffset0,t.textOffset1],X=et(ee,s,u,oe,p),ie=this.collisionIndex.placeCollisionBox(Oe(n,X.x,X.y,g,_,this.transform.angle),A,v,w,I.predicate,N);if((!q||this.collisionIndex.placeCollisionBox(Oe(q,X.x,X.y,g,_,this.transform.angle),A,v,w,I.predicate,N).box.length!==0)&&ie.box.length>0){let ce;if(this.prevPlacement&&this.prevPlacement.variableOffsets[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID].text&&(ce=this.prevPlacement.variableOffsets[D.crossTileID].anchor),D.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[D.crossTileID]={textOffset:oe,width:s,height:u,anchor:ee,textBoxScale:p,prevAnchor:ce},this.markUsedJustification($,ee,D,U),$.allowVerticalPlacement&&(this.markUsedOrientation($,U,D),this.placedOrientations[D.crossTileID]=U),{shift:X,placedGlyphBoxes:ie}}}placeLayerBucketPart(t,n,s){const{bucket:u,layout:p,posMatrix:g,textLabelPlaneMatrix:_,labelToScreenMatrix:v,textPixelRatio:w,holdingForFade:I,collisionBoxArray:A,partiallyEvaluatedTextSize:D,collisionGroup:$}=t.parameters,U=p.get("text-optional"),q=p.get("icon-optional"),N=o.ar(p,"text-overlap","text-allow-overlap"),ee=N==="always",oe=o.ar(p,"icon-overlap","icon-allow-overlap"),X=oe==="always",ie=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&&(X||!u.hasIconData()||q),xe=X&&(ee||!u.hasTextData()||U);!u.collisionArrays&&A&&u.deserializeCollisionBoxes(A);const Se=this.retainedQueryData[u.bucketInstanceId].tileID,Ne=this.terrain?(Ee,Je)=>this.terrain.getElevation(Se,Ee,Je):null,ct=(Ee,Je)=>{var $e,St;if(n[Ee.crossTileID])return;if(I)return void(this.placements[Ee.crossTileID]=new pe(!1,!1,!1));let lt=!1,at=!1,ut=!0,Ht=null,kt={box:null,offscreen:null},mi={box:null},ri=null,Yt=null,Ji=null,Dt=0,Er=0,Mr=0;Je.textFeatureIndex?Dt=Je.textFeatureIndex:Ee.useRuntimeCollisionCircles&&(Dt=Ee.featureIndex),Je.verticalTextFeatureIndex&&(Er=Je.verticalTextFeatureIndex);const hn=Je.textBox;if(hn){const vi=Wt=>{let ni=o.ai.horizontal;if(u.allowVerticalPlacement&&!Wt&&this.prevPlacement){const Ni=this.prevPlacement.placedOrientations[Ee.crossTileID];Ni&&(this.placedOrientations[Ee.crossTileID]=Ni,ni=Ni,this.markUsedOrientation(u,ni,Ee))}return ni},gi=(Wt,ni)=>{if(u.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&Je.verticalTextBox){for(const Ni of u.writingModes)if(Ni===o.ai.vertical?(kt=ni(),mi=kt):kt=Wt(),kt&&kt.box&&kt.box.length)break}else kt=Wt()},Ci=Ee.textAnchorOffsetStartIndex,Mn=Ee.textAnchorOffsetEndIndex;if(Mn===Ci){const Wt=(ni,Ni)=>{const Xt=this.collisionIndex.placeCollisionBox(ni,N,w,g,$.predicate,Ne);return Xt&&Xt.box&&Xt.box.length&&(this.markUsedOrientation(u,Ni,Ee),this.placedOrientations[Ee.crossTileID]=Ni),Xt};gi((()=>Wt(hn,o.ai.horizontal)),(()=>{const ni=Je.verticalTextBox;return u.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&ni?Wt(ni,o.ai.vertical):{box:null,offscreen:null}})),vi(kt&&kt.box&&kt.box.length)}else{let Wt=o.aq[(St=($e=this.prevPlacement)===null||$e===void 0?void 0:$e.variableOffsets[Ee.crossTileID])===null||St===void 0?void 0:St.anchor];const ni=(Xt,Pn,xs)=>{const Ol=Xt.x2-Xt.x1,Nl=Xt.y2-Xt.y1,$c=Ee.textBoxScale,To=ue&&oe==="never"?Pn:null;let Pr={box:[],offscreen:!1},zn=N==="never"?1:2,zr="never";Wt&&zn++;for(let fr=0;fr<zn;fr++){for(let Dr=Ci;Dr<Mn;Dr++){const Io=u.textAnchorOffsets.get(Dr);if(Wt&&Io.textAnchor!==Wt)continue;const qr=this.attemptAnchorPlacement(Io,Xt,Ol,Nl,$c,ie,ce,w,g,$,zr,Ee,u,xs,To,Ne);if(qr&&(Pr=qr.placedGlyphBoxes,Pr&&Pr.box&&Pr.box.length))return lt=!0,Ht=qr.shift,Pr}Wt?Wt=null:zr=N}return Pr};gi((()=>ni(hn,Je.iconBox,o.ai.horizontal)),(()=>{const Xt=Je.verticalTextBox;return u.allowVerticalPlacement&&!(kt&&kt.box&&kt.box.length)&&Ee.numVerticalGlyphVertices>0&&Xt?ni(Xt,Je.verticalIconBox,o.ai.vertical):{box:null,offscreen:null}})),kt&&(lt=kt.box,ut=kt.offscreen);const Ni=vi(kt&&kt.box);if(!lt&&this.prevPlacement){const Xt=this.prevPlacement.variableOffsets[Ee.crossTileID];Xt&&(this.variableOffsets[Ee.crossTileID]=Xt,this.markUsedJustification(u,Xt.anchor,Ee,Ni))}}}if(ri=kt,lt=ri&&ri.box&&ri.box.length>0,ut=ri&&ri.offscreen,Ee.useRuntimeCollisionCircles){const vi=u.text.placedSymbolArray.get(Ee.centerJustifiedTextSymbolIndex),gi=o.aj(u.textSizeData,D,vi),Ci=p.get("text-padding");Yt=this.collisionIndex.placeCollisionCircles(N,vi,u.lineVertexArray,u.glyphOffsetArray,gi,g,_,v,s,ce,$.predicate,Ee.collisionCircleDiameter,Ci,Ne),Yt.circles.length&&Yt.collisionDetected&&!s&&o.w("Collisions detected, but collision boxes are not shown"),lt=ee||Yt.circles.length>0&&!Yt.collisionDetected,ut=ut&&Yt.offscreen}if(Je.iconFeatureIndex&&(Mr=Je.iconFeatureIndex),Je.iconBox){const vi=gi=>{const Ci=ue&&Ht?Oe(gi,Ht.x,Ht.y,ie,ce,this.transform.angle):gi;return this.collisionIndex.placeCollisionBox(Ci,oe,w,g,$.predicate,Ne)};mi&&mi.box&&mi.box.length&&Je.verticalIconBox?(Ji=vi(Je.verticalIconBox),at=Ji.box.length>0):(Ji=vi(Je.iconBox),at=Ji.box.length>0),ut=ut&&Ji.offscreen}const En=U||Ee.numHorizontalGlyphVertices===0&&Ee.numVerticalGlyphVertices===0,aa=q||Ee.numIconVertices===0;if(En||aa?aa?En||(at=at&&lt):lt=at&&lt:at=lt=at&&lt,lt&&ri&&ri.box&&this.collisionIndex.insertCollisionBox(ri.box,N,p.get("text-ignore-placement"),u.bucketInstanceId,mi&&mi.box&&Er?Er:Dt,$.ID),at&&Ji&&this.collisionIndex.insertCollisionBox(Ji.box,oe,p.get("icon-ignore-placement"),u.bucketInstanceId,Mr,$.ID),Yt&&(lt&&this.collisionIndex.insertCollisionCircles(Yt.circles,N,p.get("text-ignore-placement"),u.bucketInstanceId,Dt,$.ID),s)){const vi=u.bucketInstanceId;let gi=this.collisionCircleArrays[vi];gi===void 0&&(gi=this.collisionCircleArrays[vi]=new fe);for(let Ci=0;Ci<Yt.circles.length;Ci+=4)gi.circles.push(Yt.circles[Ci+0]),gi.circles.push(Yt.circles[Ci+1]),gi.circles.push(Yt.circles[Ci+2]),gi.circles.push(Yt.collisionDetected?1:0)}if(Ee.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(u.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Ee.crossTileID]=new pe(lt||be,at||xe,ut||u.justReloaded),n[Ee.crossTileID]=!0};if(me){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Ee=u.getSortedSymbolIndexes(this.transform.angle);for(let Je=Ee.length-1;Je>=0;--Je){const $e=Ee[Je];ct(u.symbolInstances.get($e),u.collisionArrays[$e])}}else for(let Ee=t.symbolInstanceStart;Ee<t.symbolInstanceEnd;Ee++)ct(u.symbolInstances.get(Ee),u.collisionArrays[Ee]);if(s&&u.bucketInstanceId in this.collisionCircleArrays){const Ee=this.collisionCircleArrays[u.bucketInstanceId];o.as(Ee.invProjMatrix,g),Ee.viewportMatrix=this.collisionIndex.getViewportMatrix()}u.justReloaded=!1}markUsedJustification(t,n,s,u){let p;p=u===o.ai.vertical?s.verticalPlacedTextSymbolIndex:{left:s.leftJustifiedTextSymbolIndex,center:s.centerJustifiedTextSymbolIndex,right:s.rightJustifiedTextSymbolIndex}[o.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 u=n===o.ai.horizontal||n===o.ai.horizontalOnly?n:0,p=n===o.ai.vertical?n:0,g=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const _ of g)t.text.placedSymbolArray.get(_).placedOrientation=u;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 u=n?n.symbolFadeChange(t):1,p=n?n.opacities:{},g=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const v in this.placements){const w=this.placements[v],I=p[v];I?(this.opacities[v]=new re(I,u,w.text,w.icon),s=s||w.text!==I.text.placed||w.icon!==I.icon.placed):(this.opacities[v]=new re(null,u,w.text,w.icon,w.skipFade),s=s||w.text||w.icon)}for(const v in p){const w=p[v];if(!this.opacities[v]){const I=new re(w,u,!1,!1);I.isHidden()||(this.opacities[v]=I,s=s||w.text.placed||w.icon.placed)}}for(const v in g)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=g[v]);for(const v in _)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=_[v]);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 u of n){const p=u.getBucket(t);p&&u.latestFeatureIndex&&t.id===p.layerIds[0]&&this.updateBucketOpacities(p,s,u.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 u=t.layers[0],p=u.layout,g=new re(null,0,!1,!1,!0),_=p.get("text-allow-overlap"),v=p.get("icon-allow-overlap"),w=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),I=p.get("text-rotation-alignment")==="map",A=p.get("text-pitch-alignment")==="map",D=p.get("icon-text-fit")!=="none",$=new re(null,0,_&&(v||!t.hasIconData()||p.get("icon-optional")),v&&(_||!t.hasTextData()||p.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const U=(q,N,ee)=>{for(let oe=0;oe<N/4;oe++)q.opacityVertexArray.emplaceBack(ee);q.hasVisibleVertices=q.hasVisibleVertices||ee!==lr};for(let q=0;q<t.symbolInstances.length;q++){const N=t.symbolInstances.get(q),{numHorizontalGlyphVertices:ee,numVerticalGlyphVertices:oe,crossTileID:X}=N;let ie=this.opacities[X];n[X]?ie=g:ie||(ie=$,this.opacities[X]=ie),n[X]=!0;const ce=N.numIconVertices>0,ue=this.placedOrientations[N.crossTileID],me=ue===o.ai.vertical,be=ue===o.ai.horizontal||ue===o.ai.horizontalOnly;if(ee>0||oe>0){const xe=di(ie.text);U(t.text,ee,me?lr:xe),U(t.text,oe,be?lr:xe);const Se=ie.text.isHidden();[N.rightJustifiedTextSymbolIndex,N.centerJustifiedTextSymbolIndex,N.leftJustifiedTextSymbolIndex].forEach((Ee=>{Ee>=0&&(t.text.placedSymbolArray.get(Ee).hidden=Se||me?1:0)})),N.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(N.verticalPlacedTextSymbolIndex).hidden=Se||be?1:0);const Ne=this.variableOffsets[N.crossTileID];Ne&&this.markUsedJustification(t,Ne.anchor,N,ue);const ct=this.placedOrientations[N.crossTileID];ct&&(this.markUsedJustification(t,"left",N,ct),this.markUsedOrientation(t,ct,N))}if(ce){const xe=di(ie.icon),Se=!(D&&N.verticalPlacedIconSymbolIndex&&me);N.placedIconSymbolIndex>=0&&(U(t.icon,N.numIconVertices,Se?xe:lr),t.icon.placedSymbolArray.get(N.placedIconSymbolIndex).hidden=ie.icon.isHidden()),N.verticalPlacedIconSymbolIndex>=0&&(U(t.icon,N.numVerticalIconVertices,Se?lr:xe),t.icon.placedSymbolArray.get(N.verticalPlacedIconSymbolIndex).hidden=ie.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const xe=t.collisionArrays[q];if(xe){let Se=new o.P(0,0);if(xe.textBox||xe.verticalTextBox){let ct=!0;if(w){const Ee=this.variableOffsets[X];Ee?(Se=et(Ee.anchor,Ee.width,Ee.height,Ee.textOffset,Ee.textBoxScale),I&&Se._rotate(A?this.transform.angle:-this.transform.angle)):ct=!1}xe.textBox&&it(t.textCollisionBox.collisionVertexArray,ie.text.placed,!ct||me,Se.x,Se.y),xe.verticalTextBox&&it(t.textCollisionBox.collisionVertexArray,ie.text.placed,!ct||be,Se.x,Se.y)}const Ne=!!(!be&&xe.verticalIconBox);xe.iconBox&&it(t.iconCollisionBox.collisionVertexArray,ie.icon.placed,Ne,D?Se.x:0,D?Se.y:0),xe.verticalIconBox&&it(t.iconCollisionBox.collisionVertexArray,ie.icon.placed,!Ne,D?Se.x:0,D?Se.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 q=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=q.invProjMatrix,t.placementViewportMatrix=q.viewportMatrix,t.collisionCircleArray=q.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 it(h,t,n,s,u){h.emplaceBack(t?1:0,n?1:0,s||0,u||0),h.emplaceBack(t?1:0,n?1:0,s||0,u||0),h.emplaceBack(t?1:0,n?1:0,s||0,u||0),h.emplaceBack(t?1:0,n?1:0,s||0,u||0)}const bt=Math.pow(2,25),Tt=Math.pow(2,24),gt=Math.pow(2,17),mt=Math.pow(2,16),yi=Math.pow(2,9),Ct=Math.pow(2,8),Qt=Math.pow(2,1);function di(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const t=h.placed?1:0,n=Math.floor(127*h.opacity);return n*bt+t*Tt+n*gt+t*mt+n*yi+t*Ct+n*Qt+t}const lr=0;class el{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,u,p){const g=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(g,u,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,p())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort(((_,v)=>_.sortKey-v.sortKey)));this._currentPartIndex<g.length;)if(n.placeLayerBucketPart(g[this._currentPartIndex],this._seenCrossTileIDs,s),this._currentPartIndex++,p())return!0;return!1}}class Gn{constructor(t,n,s,u,p,g,_,v){this.placement=new Ke(t,n,g,_,v),this._currentPlacementIndex=s.length-1,this._forceFullPlacement=u,this._showCollisionBoxes=p,this._done=!1}isDone(){return this._done}continuePlacement(t,n,s){const u=o.h.now(),p=()=>!this._forceFullPlacement&&o.h.now()-u>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 el(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 Hn=512/o.N/2;class Ic{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this._symbolsByKey={};const u=new Map;for(let p=0;p<n.length;p++){const g=n.get(p),_=g.key,v=u.get(_);v?v.push(g):u.set(_,[g])}for(const[p,g]of u){const _={positions:g.map((v=>({x:Math.floor(v.anchorX*Hn),y:Math.floor(v.anchorY*Hn)}))),crossTileIDs:g.map((v=>v.crossTileID))};if(_.positions.length>128){const v=new o.av(_.positions.length,16,Uint16Array);for(const{x:w,y:I}of _.positions)v.add(w,I);v.finish(),delete _.positions,_.index=v}this._symbolsByKey[p]=_}}getScaledCoordinates(t,n){const{x:s,y:u,z:p}=this.tileID.canonical,{x:g,y:_,z:v}=n.canonical,w=Hn/Math.pow(2,v-p),I=(_*o.N+t.anchorY)*w,A=u*o.N*Hn;return{x:Math.floor((g*o.N+t.anchorX)*w-s*o.N*Hn),y:Math.floor(I-A)}}findMatches(t,n,s){const u=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 v=this.getScaledCoordinates(g,n);if(_.index){const w=_.index.range(v.x-u,v.y-u,v.x+u,v.y+u).sort();for(const I of w){const A=_.crossTileIDs[I];if(!s[A]){s[A]=!0,g.crossTileID=A;break}}}else if(_.positions)for(let w=0;w<_.positions.length;w++){const I=_.positions[w],A=_.crossTileIDs[w];if(Math.abs(I.x-v.x)<=u&&Math.abs(I.y-v.y)<=u&&!s[A]){s[A]=!0,g.crossTileID=A;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Fs{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 u=this.indexes[s],p={};for(const g in u){const _=u[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 u=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 v=g[_];v.tileID.isChildOf(t)&&v.findMatches(n.symbolInstances,t,u)}else{const _=g[t.scaledTo(Number(p)).key];_&&_.findMatches(n.symbolInstances,t,u)}}for(let p=0;p<n.symbolInstances.length;p++){const g=n.symbolInstances.get(p);g.crossTileID||(g.crossTileID=s.generate(),u[g.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ic(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const s of n.getCrossTileIDsLists())for(const u of s)delete this.usedCrossTileIDs[t][u]}removeStaleBuckets(t){let n=!1;for(const s in this.indexes){const u=this.indexes[s];for(const p in u)t[u[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(s,u[p]),delete u[p],n=!0)}return n}}class Za{constructor(){this.layerIndexes={},this.crossTileIDs=new wt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,s){let u=this.layerIndexes[t.id];u===void 0&&(u=this.layerIndexes[t.id]=new Fs);let p=!1;const g={};u.handleWrapJump(s);for(const _ of n){const v=_.getBucket(t);v&&t.id===v.layerIds[0]&&(v.bucketInstanceId||(v.bucketInstanceId=++this.maxBucketInstanceId),u.addBucket(_.tileID,v,this.crossTileIDs)&&(p=!0),g[v.bucketInstanceId]=!0)}return u.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 xi=(h,t)=>o.x(h,t&&t.filter((n=>n.identifier!=="source.canvas"))),Hi=o.F(o.ax,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Ac=o.F(o.ax,["setCenter","setZoom","setBearing","setPitch"]),cr=o.aw();class fi extends o.E{constructor(t,n={}){super(),this.map=t,this.dispatcher=new da(qa(),this,t._getMapId()),this.imageManager=new Gi,this.imageManager.setEventedParent(this),this.glyphManager=new pt(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Li(256,512),this.crossTileSymbolIndex=new Za,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new o.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",o.az());const s=this;this._rtlTextPluginCallback=fi.registerForPluginStateChange((u=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:u.pluginStatus,pluginURL:u.pluginURL},((p,g)=>{if(o.aA(p),g&&g.every((_=>_)))for(const _ in s.sourceCaches){const v=s.sourceCaches[_].getSource().type;v!=="vector"&&v!=="geojson"||s.sourceCaches[_].reload()}}))})),this.on("data",(u=>{if(u.dataType!=="source"||u.sourceDataType!=="metadata")return;const p=this.sourceCaches[u.sourceId];if(!p)return;const g=p.getSource();if(g&&g.vectorLayerIds)for(const _ in this._layers){const v=this._layers[_];v.source===g.id&&this._validateLayer(v)}}))}loadURL(t,n={},s){this.fire(new o.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const u=this.map._requestManager.transformRequest(t,Ze.Style);this._request=o.f(u,((p,g)=>{this._request=null,p?this.fire(new o.j(p)):g&&this._load(g,n,s)}))}loadJSON(t,n={},s){this.fire(new o.k("dataloading",{dataType:"style"})),this._request=o.h.frame((()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,s)}))}loadEmpty(){this.fire(new o.k("dataloading",{dataType:"style"})),this._load(cr,{validate:!1})}_load(t,n,s){var u;const p=n.transformStyle?n.transformStyle(s,t):t;if(!n.validate||!xi(this,o.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 Sr(this.stylesheet.light),this.map.setTerrain((u=this.stylesheet.terrain)!==null&&u!==void 0?u:null),this.fire(new o.k("data",{dataType:"style"})),this.fire(new o.k("style.load"))}}_createLayers(){const t=o.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=o.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(u,p,g,_){const v=ii(u),w=v.length,I=g>1?"@2x":"",A={},D={},$={};for(const{id:U,url:q}of v){const N=p.transformRequest(p.normalizeSpriteURL(q,I,".json"),Ze.SpriteJSON),ee=`${U}_${N.url}`;A[ee]=o.f(N,((ie,ce)=>{delete A[ee],D[U]=ce,Vn(_,D,$,ie,w)}));const oe=p.transformRequest(p.normalizeSpriteURL(q,I,".png"),Ze.SpriteImage),X=`${U}_${oe.url}`;A[X]=Be.getImage(oe,((ie,ce)=>{delete A[X],$[U]=ce,Vn(_,D,$,ie,w)}))}return{cancel(){for(const U of Object.values(A))U.cancel()}}})(t,this.map._requestManager,this.map.getPixelRatio(),((u,p)=>{if(this._spriteRequest=null,u)this.fire(new o.j(u));else if(p)for(const g in p){this._spritesImagesIds[g]=[];const _=this._spritesImagesIds[g]?this._spritesImagesIds[g].filter((v=>!(v in p))):[];for(const v of _)this.imageManager.removeImage(v),this._changedImages[v]=!0;for(const v in p[g]){const w=g==="default"?v:`${g}:${v}`;this._spritesImagesIds[g].push(w),w in this.imageManager.images?this.imageManager.updateImage(w,p[g][v],!1):this.imageManager.addImage(w,p[g][v]),n&&(this._changedImages[w]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"})),s&&s(u)}))}_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 o.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const s=t.sourceLayer;if(!s)return;const u=n.getSource();(u.type==="geojson"||u.vectorLayerIds&&u.vectorLayerIds.indexOf(s)===-1)&&this.fire(new o.j(new Error(`Source layer "${s}" does not exist on source "${u.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 u of t)n[u]&&s.push(n[u]);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 u=this._layers[s];u.type!=="custom"&&(t[s]=u.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 u=Object.keys(this._updatedLayers),p=Object.keys(this._removedLayers);(u.length||p.length)&&this._updateWorkerLayers(u,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 u in this.sourceCaches){const p=this.sourceCaches[u];s[u]=p.used,p.used=!1}for(const u of this._order){const p=this._layers[u];p.recalculate(t,this._availableImages),!p.isHidden(t.zoom)&&p.source&&(this.sourceCaches[p.source].used=!0)}for(const u in s){const p=this.sourceCaches[u];s[u]!==p.used&&p.fire(new o.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:u}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new o.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,xi(this,o.y(t)))return!1;(t=o.aD(t)).layers=o.aB(t.layers);const u=o.aE(s,t).filter((g=>!(g.command in Ac)));if(u.length===0)return!1;const p=u.filter((g=>!(g.command in Hi)));if(p.length>0)throw new Error(`Unimplemented: ${p.map((g=>g.command)).join(", ")}.`);for(const g of u)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 o.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 o.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 o.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(o.y.source,`sources.${t}`,n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const u=this.sourceCaches[t]=new Fi(t,n,this.dispatcher);u.style=this,u.setEventedParent(this,(()=>({isSourceLoaded:u.loaded(),source:u.serialize(),sourceId:t}))),u.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 o.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 o.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 u=t.id;if(this.getLayer(u))return void this.fire(new o.j(new Error(`Layer "${u}" already exists on this map.`)));let p;if(t.type==="custom"){if(xi(this,o.aF(t)))return;p=o.aC(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(u,t.source),t=o.aD(t),t=o.e(t,{source:u})),this._validate(o.y.layer,`layers.${u}`,t,{arrayIndex:-1},s))return;p=o.aC(t),this._validateLayer(p),p.setEventedParent(this,{layer:{id:u}})}const g=n?this._order.indexOf(n):this._order.length;if(n&&g===-1)this.fire(new o.j(new Error(`Cannot add layer "${u}" before non-existing layer "${n}".`)));else{if(this._order.splice(g,0,u),this._layerOrderChanged=!0,this._layers[u]=p,this._removedLayers[u]&&p.source&&p.type!=="custom"){const _=this._removedLayers[u];delete this._removedLayers[u],_.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 o.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 u=n?this._order.indexOf(n):this._order.length;n&&u===-1?this.fire(new o.j(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(u,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new o.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 u=this.getLayer(t);u?u.minzoom===n&&u.maxzoom===s||(n!=null&&(u.minzoom=n),s!=null&&(u.maxzoom=s),this._updateLayer(u)):this.fire(new o.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,s={}){this._checkLoaded();const u=this.getLayer(t);if(u){if(!o.aG(u.filter,n))return n==null?(u.filter=void 0,void this._updateLayer(u)):void(this._validate(o.y.filter,`layers.${u.id}.filter`,n,null,s)||(u.filter=o.aD(n),this._updateLayer(u)))}else this.fire(new o.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return o.aD(this.getLayer(t).filter)}setLayoutProperty(t,n,s,u={}){this._checkLoaded();const p=this.getLayer(t);p?o.aG(p.getLayoutProperty(n),s)||(p.setLayoutProperty(n,s,u),this._updateLayer(p)):this.fire(new o.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 o.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,s,u={}){this._checkLoaded();const p=this.getLayer(t);p?o.aG(p.getPaintProperty(n),s)||(p.setPaintProperty(n,s,u)&&this._updateLayer(p),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new o.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,u=t.sourceLayer,p=this.sourceCaches[s];if(p===void 0)return void this.fire(new o.j(new Error(`The source '${s}' does not exist in the map's style.`)));const g=p.getSource().type;g==="geojson"&&u?this.fire(new o.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):g!=="vector"||u?(t.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),p.setFeatureState(u,t.id,n)):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const s=t.source,u=this.sourceCaches[s];if(u===void 0)return void this.fire(new o.j(new Error(`The source '${s}' does not exist in the map's style.`)));const p=u.getSource().type,g=p==="vector"?t.sourceLayer:void 0;p!=="vector"||g?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new o.j(new Error("A feature id is required to remove its specific state property."))):u.removeFeatureState(g,t.id,n):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,u=this.sourceCaches[n];if(u!==void 0)return u.getSource().type!=="vector"||s?(t.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),u.getFeatureState(s,t.id)):void this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new o.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return o.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=o.aH(this.sourceCaches,(p=>p.serialize())),n=this._serializeByIds(this._order),s=this.map.getTerrain()||void 0,u=this.stylesheet;return o.aI({version:u.version,name:u.name,metadata:u.metadata,light:u.light,center:u.center,zoom:u.zoom,bearing:u.bearing,pitch:u.pitch,sprite:u.sprite,glyphs:u.glyphs,transition:u.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={},u=[];for(let g=this._order.length-1;g>=0;g--){const _=this._order[g];if(n(_)){s[_]=g;for(const v of t){const w=v[_];if(w)for(const I of w)u.push(I)}}}u.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 v=u.length-1;v>=0;v--){const w=u[v].feature;if(s[w.layer.id]<g)break;p.push(w),u.pop()}else for(const v of t){const w=v[_];if(w)for(const I of w)p.push(I.feature)}}return p}queryRenderedFeatures(t,n,s){n&&n.filter&&this._validate(o.y.filter,"queryRenderedFeatures.filter",n.filter,null,n);const u={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new o.j(new Error("parameters.layers must be an Array."))),[];for(const _ of n.layers){const v=this._layers[_];if(!v)return this.fire(new o.j(new Error(`The layer '${_}' does not exist in the map's style and cannot be queried for features.`))),[];u[v.source]=!0}}const p=[];n.availableImages=this._availableImages;const g=this._serializedAllLayers();for(const _ in this.sourceCaches)n.layers&&!u[_]||p.push(_n(this.sourceCaches[_],this._layers,g,t,n,s));return this.placement&&p.push((function(_,v,w,I,A,D,$){const U={},q=D.queryRenderedSymbols(I),N=[];for(const ee of Object.keys(q).map(Number))N.push($[ee]);N.sort(en);for(const ee of N){const oe=ee.featureIndex.lookupSymbolFeatures(q[ee.bucketInstanceId],v,ee.bucketIndex,ee.sourceLayerIndex,A.filter,A.layers,A.availableImages,_);for(const X in oe){const ie=U[X]=U[X]||[],ce=oe[X];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)ie.push(ue)}}for(const ee in U)U[ee].forEach((oe=>{const X=oe.feature,ie=w[_[ee].source].getFeatureState(X.layer["source-layer"],X.id);X.source=X.layer.source,X.layer["source-layer"]&&(X.sourceLayer=X.layer["source-layer"]),X.state=ie}));return U})(this._layers,g,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(t,n){n&&n.filter&&this._validate(o.y.filter,"querySourceFeatures.filter",n.filter,null,n);const s=this.sourceCaches[t];return s?(function(u,p){const g=u.getRenderableIds().map((w=>u.getTileByID(w))),_=[],v={};for(let w=0;w<g.length;w++){const I=g[w],A=I.tileID.canonical.key;v[A]||(v[A]=!0,I.querySourceFeatures(_,p))}return _})(s,n):[]}addSourceType(t,n,s){return Fr(t)?s(new Error(`A source type called "${t}" already exists.`)):(((u,p)=>{ma[u]=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 u=!1;for(const g in t)if(!o.aG(t[g],s[g])){u=!0;break}if(!u)return;const p={now:o.h.now(),transition:o.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(p)}_validate(t,n,s,u,p={}){return(!p||p.validate!==!1)&&xi(this,t.call(o.y,o.e({key:n,style:this.serialize(),value:s,styleSpec:o.v},u)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),o.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,u,p=!1){let g=!1,_=!1;const v={};for(const w of this._order){const I=this._layers[w];if(I.type!=="symbol")continue;if(!v[I.source]){const D=this.sourceCaches[I.source];v[I.source]=D.getRenderableIds(!0).map(($=>D.getTileByID($))).sort((($,U)=>U.tileID.overscaledZ-$.tileID.overscaledZ||($.tileID.isLessThan(U.tileID)?-1:1)))}const A=this.crossTileSymbolIndex.addLayer(I,v[I.source],t.center.lng);g=g||A}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||s===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(o.h.now(),t.zoom))&&(this.pauseablePlacement=new Gn(t,this.map.terrain,this._order,p,n,s,u,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,v),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(o.h.now()),_=!0),g&&this.pauseablePlacement.placement.setStale()),_||g)for(const w of this._order){const I=this._layers[w];I.type==="symbol"&&this.placement.updateLayerOpacities(I,v[I.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(o.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 u=this.sourceCaches[n.source];u&&u.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,s){this.glyphManager.getGlyphs(n.stacks,s);const u=this.sourceCaches[n.source];u&&u.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,s){return o.m(n,s)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(o.y.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,s={},u){this._checkLoaded();const p=[{id:t,url:n}],g=[...ii(this.stylesheet.sprite),...p];this._validate(o.y.sprite,"sprite",g,null,s)||(this.stylesheet.sprite=g,this._loadSprite(p,!0,u))}removeSprite(t){this._checkLoaded();const n=ii(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 o.k("data",{dataType:"style"}))}else this.fire(new o.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return ii(this.stylesheet.sprite)}setSprite(t,n={},s){this._checkLoaded(),t&&this._validate(o.y.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,s):(this._unloadSprite(),s&&s(null)))}}fi.registerForPluginStateChange=o.aK;var Ga=o.Q([{name:"a_pos",type:"Int16",components:2}]),Wn="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 Ot={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);}",Wn),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);}",Wn),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);}",Wn)};function yt(h,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=t.match(/attribute ([\w]+) ([\w]+)/g),u=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=p?p.concat(u):u,_={};return{fragmentSource:h=h.replace(n,((v,w,I,A,D)=>(_[D]=!0,w==="define"?`
#ifndef HAS_UNIFORM_u_${D}
varying ${I} ${A} ${D};
#else
uniform ${I} ${A} u_${D};
#endif
`:`
#ifdef HAS_UNIFORM_u_${D}
${I} ${A} ${D} = u_${D};
#endif
`))),vertexSource:t=t.replace(n,((v,w,I,A,D)=>{const $=A==="float"?"vec2":"vec4",U=D.match(/color/)?"color":$;return _[D]?w==="define"?`
#ifndef HAS_UNIFORM_u_${D}
uniform lowp float u_${D}_t;
attribute ${I} ${$} a_${D};
varying ${I} ${A} ${D};
#else
uniform ${I} ${A} u_${D};
#endif
`:U==="vec4"?`
#ifndef HAS_UNIFORM_u_${D}
${D} = a_${D};
#else
${I} ${A} ${D} = u_${D};
#endif
`:`
#ifndef HAS_UNIFORM_u_${D}
${D} = unpack_mix_${U}(a_${D}, u_${D}_t);
#else
${I} ${A} ${D} = u_${D};
#endif
`:w==="define"?`
#ifndef HAS_UNIFORM_u_${D}
uniform lowp float u_${D}_t;
attribute ${I} ${$} a_${D};
#else
uniform ${I} ${A} u_${D};
#endif
`:U==="vec4"?`
#ifndef HAS_UNIFORM_u_${D}
${I} ${A} ${D} = a_${D};
#else
${I} ${A} ${D} = u_${D};
#endif
`:`
#ifndef HAS_UNIFORM_u_${D}
${I} ${A} ${D} = unpack_mix_${U}(a_${D}, u_${D}_t);
#else
${I} ${A} ${D} = u_${D};
#endif
`})),staticAttributes:s,staticUniforms:g}}class bn{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,u,p,g,_,v,w){this.context=t;let I=this.boundPaintVertexBuffers.length!==u.length;for(let A=0;!I&&A<u.length;A++)this.boundPaintVertexBuffers[A]!==u[A]&&(I=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==s||I||this.boundIndexBuffer!==p||this.boundVertexOffset!==g||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==v||this.boundDynamicVertexBuffer3!==w?this.freshBind(n,s,u,p,g,_,v,w):(t.bindVertexArray.set(this.vao),_&&_.bind(),p&&p.dynamicDraw&&p.bind(),v&&v.bind(),w&&w.bind())}freshBind(t,n,s,u,p,g,_,v){const w=t.numAttributes,I=this.context,A=I.gl;this.vao&&this.destroy(),this.vao=I.createVertexArray(),I.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=s,this.boundIndexBuffer=u,this.boundVertexOffset=p,this.boundDynamicVertexBuffer=g,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=v,n.enableAttributes(A,t);for(const D of s)D.enableAttributes(A,t);g&&g.enableAttributes(A,t),_&&_.enableAttributes(A,t),v&&v.enableAttributes(A,t),n.bind(),n.setVertexAttribPointers(A,t,p);for(const D of s)D.bind(),D.setVertexAttribPointers(A,t,p);g&&(g.bind(),g.setVertexAttribPointers(A,t,p)),u&&u.bind(),_&&(_.bind(),_.setVertexAttribPointers(A,t,p)),v&&(v.bind(),v.setVertexAttribPointers(A,t,p)),I.currentNumAttributes=w}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}function qt(h){const t=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;const s=h[n].split(" ");t.push(s.pop())}return t}class Ha{constructor(t,n,s,u,p,g){const _=t.gl;this.program=_.createProgram();const v=qt(n.staticAttributes),w=s?s.getBinderAttributes():[],I=v.concat(w),A=Ot.prelude.staticUniforms?qt(Ot.prelude.staticUniforms):[],D=n.staticUniforms?qt(n.staticUniforms):[],$=s?s.getBinderUniforms():[],U=A.concat(D).concat($),q=[];for(const ue of U)q.indexOf(ue)<0&&q.push(ue);const N=s?s.defines():[];p&&N.push("#define OVERDRAW_INSPECTOR;"),g&&N.push("#define TERRAIN3D;");const ee=N.concat(Ot.prelude.fragmentSource,n.fragmentSource).join(`
`),oe=N.concat(Ot.prelude.vertexSource,n.vertexSource).join(`
`),X=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(X,ee),_.compileShader(X),!_.getShaderParameter(X,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(X)}`);_.attachShader(this.program,X);const ie=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(ie,oe),_.compileShader(ie),!_.getShaderParameter(ie,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(ie)}`);_.attachShader(this.program,ie),this.attributes={};const ce={};this.numAttributes=I.length;for(let ue=0;ue<this.numAttributes;ue++)I[ue]&&(_.bindAttribLocation(this.program,ue,I[ue]),this.attributes[I[ue]]=ue);if(_.linkProgram(this.program),!_.getProgramParameter(this.program,_.LINK_STATUS))throw new Error(`Program failed to link: ${_.getProgramInfoLog(this.program)}`);_.deleteShader(ie),_.deleteShader(X);for(let ue=0;ue<q.length;ue++){const me=q[ue];if(me&&!ce[me]){const be=_.getUniformLocation(this.program,me);be&&(ce[me]=be)}}this.fixedUniforms=u(t,ce),this.terrainUniforms=((ue,me)=>({u_depth:new o.aL(ue,me.u_depth),u_terrain:new o.aL(ue,me.u_terrain),u_terrain_dim:new o.aM(ue,me.u_terrain_dim),u_terrain_matrix:new o.aN(ue,me.u_terrain_matrix),u_terrain_unpack:new o.aO(ue,me.u_terrain_unpack),u_terrain_exaggeration:new o.aM(ue,me.u_terrain_exaggeration)}))(t,ce),this.binderUniforms=s?s.getUniforms(t,ce):[]}draw(t,n,s,u,p,g,_,v,w,I,A,D,$,U,q,N,ee,oe){const X=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(s),t.setStencilMode(u),t.setColorMode(p),t.setCullFace(g),v){t.activeTexture.set(X.TEXTURE2),X.bindTexture(X.TEXTURE_2D,v.depthTexture),t.activeTexture.set(X.TEXTURE3),X.bindTexture(X.TEXTURE_2D,v.texture);for(const ce in this.terrainUniforms)this.terrainUniforms[ce].set(v[ce])}for(const ce in this.fixedUniforms)this.fixedUniforms[ce].set(_[ce]);q&&q.setUniforms(t,this.binderUniforms,$,{zoom:U});let ie=0;switch(n){case X.LINES:ie=2;break;case X.TRIANGLES:ie=3;break;case X.LINE_STRIP:ie=1}for(const ce of D.get()){const ue=ce.vaos||(ce.vaos={});(ue[w]||(ue[w]=new bn)).bind(t,this,I,q?q.getPaintVertexBuffers():[],A,ce.vertexOffset,N,ee,oe),X.drawElements(n,ce.primitiveLength*ie,X.UNSIGNED_SHORT,ce.primitiveOffset*ie*2)}}}function ur(h,t,n){const s=1/Q(n,1,t.transform.tileZoom),u=Math.pow(2,n.tileID.overscaledZ),p=n.tileSize*Math.pow(2,t.transform.tileZoom)/u,g=p*(n.tileID.canonical.x+n.tileID.wrap*u),_=p*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[g>>16,_>>16],u_pixel_coord_lower:[65535&g,65535&_]}}const Bs=(h,t,n,s)=>{const u=t.style.light,p=u.properties.get("position"),g=[p.x,p.y,p.z],_=(function(){var w=new o.A(9);return o.A!=Float32Array&&(w[1]=0,w[2]=0,w[3]=0,w[5]=0,w[6]=0,w[7]=0),w[0]=1,w[4]=1,w[8]=1,w})();u.properties.get("anchor")==="viewport"&&(function(w,I){var A=Math.sin(I),D=Math.cos(I);w[0]=D,w[1]=A,w[2]=0,w[3]=-A,w[4]=D,w[5]=0,w[6]=0,w[7]=0,w[8]=1})(_,-t.transform.angle),(function(w,I,A){var D=I[0],$=I[1],U=I[2];w[0]=D*A[0]+$*A[3]+U*A[6],w[1]=D*A[1]+$*A[4]+U*A[7],w[2]=D*A[2]+$*A[5]+U*A[8]})(g,g,_);const v=u.properties.get("color");return{u_matrix:h,u_lightpos:g,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+n,u_opacity:s}},nn=(h,t,n,s,u,p,g)=>o.e(Bs(h,t,n,s),ur(p,t,g),{u_height_factor:-Math.pow(2,u.overscaledZ)/g.tileSize/8}),tl=h=>({u_matrix:h}),Os=(h,t,n,s)=>o.e(tl(h),ur(n,t,s)),Wa=(h,t)=>({u_matrix:h,u_world:t}),Xa=(h,t,n,s,u)=>o.e(Os(h,t,n,s),{u_world:u}),an=(h,t,n,s)=>{const u=h.transform;let p,g;if(s.paint.get("circle-pitch-alignment")==="map"){const _=Q(n,1,u.zoom);p=!0,g=[_,_]}else p=!1,g=u.pixelsToGLUnits;return{u_camera_to_center_distance:u.cameraToCenterDistance,u_scale_with_map:+(s.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(t.posMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+p,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:g}},Ns=(h,t,n)=>{const s=Q(n,1,t.zoom),u=Math.pow(2,t.zoom-n.tileID.overscaledZ),p=n.tileID.overscaleFactor();return{u_matrix:h,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[t.pixelsToGLUnits[0]/(s*u),t.pixelsToGLUnits[1]/(s*u)],u_overscale_factor:p}},ga=(h,t,n=1)=>({u_matrix:h,u_color:t,u_overlay:0,u_overlay_scale:n}),il=h=>({u_matrix:h}),Cc=(h,t,n,s)=>({u_matrix:h,u_extrude_scale:Q(t,1,n),u_intensity:s});function Vs(h,t){const n=Math.pow(2,t.canonical.z),s=t.canonical.y;return[new o.U(0,s/n).toLngLat().lat,new o.U(0,(s+1)/n).toLngLat().lat]}const Us=(h,t,n,s)=>{const u=h.transform;return{u_matrix:Ka(h,t,n,s),u_ratio:1/Q(t,1,u.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},rl=(h,t,n,s,u)=>o.e(Us(h,t,n,u),{u_image:0,u_image_height:s}),kc=(h,t,n,s,u)=>{const p=h.transform,g=al(t,p);return{u_matrix:Ka(h,t,n,u),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Q(t,1,p.zoom),u_device_pixel_ratio:h.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]]}},nl=(h,t,n,s,u,p)=>{const g=h.lineAtlas,_=al(t,h.transform),v=n.layout.get("line-cap")==="round",w=g.getDash(s.from,v),I=g.getDash(s.to,v),A=w.width*u.fromScale,D=I.width*u.toScale;return o.e(Us(h,t,n,p),{u_patternscale_a:[_/A,-w.height/2],u_patternscale_b:[_/D,-I.height/2],u_sdfgamma:g.width/(256*Math.min(A,D)*h.pixelRatio)/2,u_image:0,u_tex_y_a:w.y,u_tex_y_b:I.y,u_mix:u.t})};function al(h,t){return 1/Q(h,1,t.tileZoom)}function Ka(h,t,n,s){return h.translatePosMatrix(s?s.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const sl=(h,t,n,s,u)=>{return{u_matrix:h,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*u.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:u.paint.get("raster-brightness-min"),u_brightness_high:u.paint.get("raster-brightness-max"),u_saturation_factor:(g=u.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(p=u.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:ol(u.paint.get("raster-hue-rotate"))};var p,g};function ol(h){h*=Math.PI/180;const t=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const $s=(h,t,n,s,u,p,g,_,v,w)=>{const I=u.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:I.width/I.height,u_fade_change:u.options.fadeDuration?u.symbolFadeChange:1,u_matrix:p,u_label_plane_matrix:g,u_coord_matrix:_,u_is_text:+v,u_pitch_with_map:+s,u_texsize:w,u_texture:0}},js=(h,t,n,s,u,p,g,_,v,w,I)=>{const A=u.transform;return o.e($s(h,t,n,s,u,p,g,_,v,w),{u_gamma_scale:s?Math.cos(A._pitch)*A.cameraToCenterDistance:1,u_device_pixel_ratio:u.pixelRatio,u_is_halo:1})},wn=(h,t,n,s,u,p,g,_,v,w)=>o.e(js(h,t,n,s,u,p,g,_,!0,v),{u_texsize_icon:w,u_texture_icon:1}),Ya=(h,t,n)=>({u_matrix:h,u_opacity:t,u_color:n}),hr=(h,t,n,s,u,p)=>o.e((function(g,_,v,w){const I=v.imageManager.getPattern(g.from.toString()),A=v.imageManager.getPattern(g.to.toString()),{width:D,height:$}=v.imageManager.getPixelSize(),U=Math.pow(2,w.tileID.overscaledZ),q=w.tileSize*Math.pow(2,v.transform.tileZoom)/U,N=q*(w.tileID.canonical.x+w.tileID.wrap*U),ee=q*w.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:I.tl,u_pattern_br_a:I.br,u_pattern_tl_b:A.tl,u_pattern_br_b:A.br,u_texsize:[D,$],u_mix:_.t,u_pattern_size_a:I.displaySize,u_pattern_size_b:A.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/Q(w,1,v.transform.tileZoom),u_pixel_coord_upper:[N>>16,ee>>16],u_pixel_coord_lower:[65535&N,65535&ee]}})(s,p,n,u),{u_matrix:h,u_opacity:t}),Ja={fillExtrusion:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_lightpos:new o.aP(h,t.u_lightpos),u_lightintensity:new o.aM(h,t.u_lightintensity),u_lightcolor:new o.aP(h,t.u_lightcolor),u_vertical_gradient:new o.aM(h,t.u_vertical_gradient),u_opacity:new o.aM(h,t.u_opacity)}),fillExtrusionPattern:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_lightpos:new o.aP(h,t.u_lightpos),u_lightintensity:new o.aM(h,t.u_lightintensity),u_lightcolor:new o.aP(h,t.u_lightcolor),u_vertical_gradient:new o.aM(h,t.u_vertical_gradient),u_height_factor:new o.aM(h,t.u_height_factor),u_image:new o.aL(h,t.u_image),u_texsize:new o.aQ(h,t.u_texsize),u_pixel_coord_upper:new o.aQ(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new o.aQ(h,t.u_pixel_coord_lower),u_scale:new o.aP(h,t.u_scale),u_fade:new o.aM(h,t.u_fade),u_opacity:new o.aM(h,t.u_opacity)}),fill:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix)}),fillPattern:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_image:new o.aL(h,t.u_image),u_texsize:new o.aQ(h,t.u_texsize),u_pixel_coord_upper:new o.aQ(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new o.aQ(h,t.u_pixel_coord_lower),u_scale:new o.aP(h,t.u_scale),u_fade:new o.aM(h,t.u_fade)}),fillOutline:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_world:new o.aQ(h,t.u_world)}),fillOutlinePattern:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_world:new o.aQ(h,t.u_world),u_image:new o.aL(h,t.u_image),u_texsize:new o.aQ(h,t.u_texsize),u_pixel_coord_upper:new o.aQ(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new o.aQ(h,t.u_pixel_coord_lower),u_scale:new o.aP(h,t.u_scale),u_fade:new o.aM(h,t.u_fade)}),circle:(h,t)=>({u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_scale_with_map:new o.aL(h,t.u_scale_with_map),u_pitch_with_map:new o.aL(h,t.u_pitch_with_map),u_extrude_scale:new o.aQ(h,t.u_extrude_scale),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_matrix:new o.aN(h,t.u_matrix)}),collisionBox:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_pixels_to_tile_units:new o.aM(h,t.u_pixels_to_tile_units),u_extrude_scale:new o.aQ(h,t.u_extrude_scale),u_overscale_factor:new o.aM(h,t.u_overscale_factor)}),collisionCircle:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_inv_matrix:new o.aN(h,t.u_inv_matrix),u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_viewport_size:new o.aQ(h,t.u_viewport_size)}),debug:(h,t)=>({u_color:new o.aR(h,t.u_color),u_matrix:new o.aN(h,t.u_matrix),u_overlay:new o.aL(h,t.u_overlay),u_overlay_scale:new o.aM(h,t.u_overlay_scale)}),clippingMask:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix)}),heatmap:(h,t)=>({u_extrude_scale:new o.aM(h,t.u_extrude_scale),u_intensity:new o.aM(h,t.u_intensity),u_matrix:new o.aN(h,t.u_matrix)}),heatmapTexture:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_world:new o.aQ(h,t.u_world),u_image:new o.aL(h,t.u_image),u_color_ramp:new o.aL(h,t.u_color_ramp),u_opacity:new o.aM(h,t.u_opacity)}),hillshade:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_image:new o.aL(h,t.u_image),u_latrange:new o.aQ(h,t.u_latrange),u_light:new o.aQ(h,t.u_light),u_shadow:new o.aR(h,t.u_shadow),u_highlight:new o.aR(h,t.u_highlight),u_accent:new o.aR(h,t.u_accent)}),hillshadePrepare:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_image:new o.aL(h,t.u_image),u_dimension:new o.aQ(h,t.u_dimension),u_zoom:new o.aM(h,t.u_zoom),u_unpack:new o.aO(h,t.u_unpack)}),line:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_ratio:new o.aM(h,t.u_ratio),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_units_to_pixels:new o.aQ(h,t.u_units_to_pixels)}),lineGradient:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_ratio:new o.aM(h,t.u_ratio),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_units_to_pixels:new o.aQ(h,t.u_units_to_pixels),u_image:new o.aL(h,t.u_image),u_image_height:new o.aM(h,t.u_image_height)}),linePattern:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_texsize:new o.aQ(h,t.u_texsize),u_ratio:new o.aM(h,t.u_ratio),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_image:new o.aL(h,t.u_image),u_units_to_pixels:new o.aQ(h,t.u_units_to_pixels),u_scale:new o.aP(h,t.u_scale),u_fade:new o.aM(h,t.u_fade)}),lineSDF:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_ratio:new o.aM(h,t.u_ratio),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_units_to_pixels:new o.aQ(h,t.u_units_to_pixels),u_patternscale_a:new o.aQ(h,t.u_patternscale_a),u_patternscale_b:new o.aQ(h,t.u_patternscale_b),u_sdfgamma:new o.aM(h,t.u_sdfgamma),u_image:new o.aL(h,t.u_image),u_tex_y_a:new o.aM(h,t.u_tex_y_a),u_tex_y_b:new o.aM(h,t.u_tex_y_b),u_mix:new o.aM(h,t.u_mix)}),raster:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_tl_parent:new o.aQ(h,t.u_tl_parent),u_scale_parent:new o.aM(h,t.u_scale_parent),u_buffer_scale:new o.aM(h,t.u_buffer_scale),u_fade_t:new o.aM(h,t.u_fade_t),u_opacity:new o.aM(h,t.u_opacity),u_image0:new o.aL(h,t.u_image0),u_image1:new o.aL(h,t.u_image1),u_brightness_low:new o.aM(h,t.u_brightness_low),u_brightness_high:new o.aM(h,t.u_brightness_high),u_saturation_factor:new o.aM(h,t.u_saturation_factor),u_contrast_factor:new o.aM(h,t.u_contrast_factor),u_spin_weights:new o.aP(h,t.u_spin_weights)}),symbolIcon:(h,t)=>({u_is_size_zoom_constant:new o.aL(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aL(h,t.u_is_size_feature_constant),u_size_t:new o.aM(h,t.u_size_t),u_size:new o.aM(h,t.u_size),u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_pitch:new o.aM(h,t.u_pitch),u_rotate_symbol:new o.aL(h,t.u_rotate_symbol),u_aspect_ratio:new o.aM(h,t.u_aspect_ratio),u_fade_change:new o.aM(h,t.u_fade_change),u_matrix:new o.aN(h,t.u_matrix),u_label_plane_matrix:new o.aN(h,t.u_label_plane_matrix),u_coord_matrix:new o.aN(h,t.u_coord_matrix),u_is_text:new o.aL(h,t.u_is_text),u_pitch_with_map:new o.aL(h,t.u_pitch_with_map),u_texsize:new o.aQ(h,t.u_texsize),u_texture:new o.aL(h,t.u_texture)}),symbolSDF:(h,t)=>({u_is_size_zoom_constant:new o.aL(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aL(h,t.u_is_size_feature_constant),u_size_t:new o.aM(h,t.u_size_t),u_size:new o.aM(h,t.u_size),u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_pitch:new o.aM(h,t.u_pitch),u_rotate_symbol:new o.aL(h,t.u_rotate_symbol),u_aspect_ratio:new o.aM(h,t.u_aspect_ratio),u_fade_change:new o.aM(h,t.u_fade_change),u_matrix:new o.aN(h,t.u_matrix),u_label_plane_matrix:new o.aN(h,t.u_label_plane_matrix),u_coord_matrix:new o.aN(h,t.u_coord_matrix),u_is_text:new o.aL(h,t.u_is_text),u_pitch_with_map:new o.aL(h,t.u_pitch_with_map),u_texsize:new o.aQ(h,t.u_texsize),u_texture:new o.aL(h,t.u_texture),u_gamma_scale:new o.aM(h,t.u_gamma_scale),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_is_halo:new o.aL(h,t.u_is_halo)}),symbolTextAndIcon:(h,t)=>({u_is_size_zoom_constant:new o.aL(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aL(h,t.u_is_size_feature_constant),u_size_t:new o.aM(h,t.u_size_t),u_size:new o.aM(h,t.u_size),u_camera_to_center_distance:new o.aM(h,t.u_camera_to_center_distance),u_pitch:new o.aM(h,t.u_pitch),u_rotate_symbol:new o.aL(h,t.u_rotate_symbol),u_aspect_ratio:new o.aM(h,t.u_aspect_ratio),u_fade_change:new o.aM(h,t.u_fade_change),u_matrix:new o.aN(h,t.u_matrix),u_label_plane_matrix:new o.aN(h,t.u_label_plane_matrix),u_coord_matrix:new o.aN(h,t.u_coord_matrix),u_is_text:new o.aL(h,t.u_is_text),u_pitch_with_map:new o.aL(h,t.u_pitch_with_map),u_texsize:new o.aQ(h,t.u_texsize),u_texsize_icon:new o.aQ(h,t.u_texsize_icon),u_texture:new o.aL(h,t.u_texture),u_texture_icon:new o.aL(h,t.u_texture_icon),u_gamma_scale:new o.aM(h,t.u_gamma_scale),u_device_pixel_ratio:new o.aM(h,t.u_device_pixel_ratio),u_is_halo:new o.aL(h,t.u_is_halo)}),background:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_opacity:new o.aM(h,t.u_opacity),u_color:new o.aR(h,t.u_color)}),backgroundPattern:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_opacity:new o.aM(h,t.u_opacity),u_image:new o.aL(h,t.u_image),u_pattern_tl_a:new o.aQ(h,t.u_pattern_tl_a),u_pattern_br_a:new o.aQ(h,t.u_pattern_br_a),u_pattern_tl_b:new o.aQ(h,t.u_pattern_tl_b),u_pattern_br_b:new o.aQ(h,t.u_pattern_br_b),u_texsize:new o.aQ(h,t.u_texsize),u_mix:new o.aM(h,t.u_mix),u_pattern_size_a:new o.aQ(h,t.u_pattern_size_a),u_pattern_size_b:new o.aQ(h,t.u_pattern_size_b),u_scale_a:new o.aM(h,t.u_scale_a),u_scale_b:new o.aM(h,t.u_scale_b),u_pixel_coord_upper:new o.aQ(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new o.aQ(h,t.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aM(h,t.u_tile_units_to_pixels)}),terrain:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_texture:new o.aL(h,t.u_texture),u_ele_delta:new o.aM(h,t.u_ele_delta)}),terrainDepth:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_ele_delta:new o.aM(h,t.u_ele_delta)}),terrainCoords:(h,t)=>({u_matrix:new o.aN(h,t.u_matrix),u_texture:new o.aL(h,t.u_texture),u_terrain_coords_id:new o.aM(h,t.u_terrain_coords_id),u_ele_delta:new o.aM(h,t.u_ele_delta)})};class Qa{constructor(t,n,s){this.context=t;const u=t.gl;this.buffer=u.createBuffer(),this.dynamicDraw=!!s,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),u.bufferData(u.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.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 _a={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class es{constructor(t,n,s,u){this.length=n.length,this.attributes=s,this.itemSize=n.bytesPerElement,this.dynamicDraw=u,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 u=n.attributes[this.attributes[s].name];u!==void 0&&t.enableVertexAttribArray(u)}}setVertexAttribPointers(t,n,s){for(let u=0;u<this.attributes.length;u++){const p=this.attributes[u],g=n.attributes[p.name];g!==void 0&&t.vertexAttribPointer(g,p.components,t[_a[p.type]],!1,this.itemSize,p.offset+this.itemSize*(s||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Xn=new WeakMap;function sn(h){var t;if(Xn.has(h))return Xn.get(h);{const n=(t=h.getParameter(h.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Xn.set(h,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 ts extends dt{getDefault(){return o.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 Wi extends dt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Xi extends dt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class qs 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 is extends dt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class rs extends dt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Zs 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 Gs 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 ns 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 Hs 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 Ws 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 as 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 ll 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 cl 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 Kn extends dt{getDefault(){return o.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 Ec 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 Mc 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 Pc 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 zc 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 Dc extends dt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Lc 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 Xs 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 ss 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 Ks 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 Ys 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 Yn 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 ul 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 hl extends dt{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const s=this.gl;sn(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 Js 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 Sn 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 pl 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 on extends dt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class Jn extends on{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 dl extends on{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 Qs extends on{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,u,p){this.context=t,this.width=n,this.height=s;const g=t.gl,_=this.framebuffer=g.createFramebuffer();if(this.colorAttachment=new Jn(t,_),u)this.depthAttachment=p?new Qs(t,_):new dl(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 Nt{constructor(t,n,s){this.blendFunction=t,this.blendColor=n,this.mask=s}}Nt.Replace=[1,0],Nt.disabled=new Nt(Nt.Replace,o.aT.transparent,[!1,!1,!1,!1]),Nt.unblended=new Nt(Nt.Replace,o.aT.transparent,[!0,!0,!0,!0]),Nt.alphaBlended=new Nt([1,771],o.aT.transparent,[!0,!0,!0,!0]);class Rc{constructor(t){var n,s;if(this.gl=t,this.clearColor=new ts(this),this.clearDepth=new Wi(this),this.clearStencil=new Xi(this),this.colorMask=new qs(this),this.depthMask=new is(this),this.stencilMask=new rs(this),this.stencilFunc=new Zs(this),this.stencilOp=new Gs(this),this.stencilTest=new ns(this),this.depthRange=new Hs(this),this.depthTest=new Ws(this),this.depthFunc=new as(this),this.blend=new ll(this),this.blendFunc=new cl(this),this.blendColor=new Kn(this),this.blendEquation=new Ec(this),this.cullFace=new Mc(this),this.cullFaceSide=new Pc(this),this.frontFace=new zc(this),this.program=new Dc(this),this.activeTexture=new Lc(this),this.viewport=new Xs(this),this.bindFramebuffer=new ss(this),this.bindRenderbuffer=new Ks(this),this.bindTexture=new Ys(this),this.bindVertexBuffer=new Yn(this),this.bindElementBuffer=new ul(this),this.bindVertexArray=new hl(this),this.pixelStoreUnpack=new Js(this),this.pixelStoreUnpackPremultiplyAlpha=new Sn(this),this.pixelStoreUnpackFlipY=new pl(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),sn(t)){this.HALF_FLOAT=t.HALF_FLOAT;const u=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:u==null?void 0:u.RGBA16F_EXT,this.RGB16F=(s=t.RGB16F)!==null&&s!==void 0?s:u==null?void 0:u.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const u=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=u==null?void 0:u.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 Qa(this,t,n)}createVertexBuffer(t,n,s){return new es(this,t,n,s)}createRenderbuffer(t,n,s){const u=this.gl,p=u.createRenderbuffer();return this.bindRenderbuffer.set(p),u.renderbufferStorage(u.RENDERBUFFER,t,n,s),this.bindRenderbuffer.set(null),p}createFramebuffer(t,n,s,u){return new xt(this,t,n,s,u)}clear({color:t,depth:n,stencil:s}){const u=this.gl;let p=0;t&&(p|=u.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(p|=u.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),s!==void 0&&(p|=u.STENCIL_BUFFER_BIT,this.clearStencil.set(s),this.stencilMask.set(255)),u.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){o.aG(t.blendFunction,Nt.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 sn(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 sn(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 Tn=7680;class Vt{constructor(t,n,s,u,p,g){this.test=t,this.ref=n,this.mask=s,this.fail=u,this.depthFail=p,this.pass=g}}Vt.disabled=new Vt({func:519,mask:0},0,0,Tn,Tn,Tn);class Ft{constructor(t,n,s){this.enable=t,this.mode=n,this.frontFace=s}}let ya;function fl(h,t,n,s,u,p,g){const _=h.context,v=_.gl,w=h.useProgram("collisionBox"),I=[];let A=0,D=0;for(let X=0;X<s.length;X++){const ie=s[X],ce=t.getTile(ie),ue=ce.getBucket(n);if(!ue)continue;let me=ie.posMatrix;u[0]===0&&u[1]===0||(me=h.translatePosMatrix(ie.posMatrix,ce,u,p));const be=g?ue.textCollisionBox:ue.iconCollisionBox,xe=ue.collisionCircleArray;if(xe.length>0){const Se=o.Z(),Ne=me;o.aU(Se,ue.placementInvProjMatrix,h.transform.glCoordMatrix),o.aU(Se,Se,ue.placementViewportMatrix),I.push({circleArray:xe,circleOffset:D,transform:Ne,invTransform:Se,coord:ie}),A+=xe.length/4,D=A}be&&w.draw(_,v.LINES,ft.disabled,Vt.disabled,h.colorModeForRenderPass(),Ft.disabled,Ns(me,h.transform,ce),h.style.map.terrain&&h.style.map.terrain.getTerrainData(ie),n.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,null,h.transform.zoom,null,null,be.collisionVertexBuffer)}if(!g||!I.length)return;const $=h.useProgram("collisionCircle"),U=new o.aV;U.resize(4*A),U._trim();let q=0;for(const X of I)for(let ie=0;ie<X.circleArray.length/4;ie++){const ce=4*ie,ue=X.circleArray[ce+0],me=X.circleArray[ce+1],be=X.circleArray[ce+2],xe=X.circleArray[ce+3];U.emplace(q++,ue,me,be,xe,0),U.emplace(q++,ue,me,be,xe,1),U.emplace(q++,ue,me,be,xe,2),U.emplace(q++,ue,me,be,xe,3)}(!ya||ya.length<2*A)&&(ya=(function(X){const ie=2*X,ce=new o.aX;ce.resize(ie),ce._trim();for(let ue=0;ue<ie;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})(A));const N=_.createIndexBuffer(ya,!0),ee=_.createVertexBuffer(U,o.aW.members,!0);for(const X of I){const ie={u_matrix:X.transform,u_inv_matrix:X.invTransform,u_camera_to_center_distance:(oe=h.transform).cameraToCenterDistance,u_viewport_size:[oe.width,oe.height]};$.draw(_,v.TRIANGLES,ft.disabled,Vt.disabled,h.colorModeForRenderPass(),Ft.disabled,ie,h.style.map.terrain&&h.style.map.terrain.getTerrainData(X.coord),n.id,ee,N,o.S.simpleSegment(0,2*X.circleOffset,X.circleArray.length,X.circleArray.length/2),null,h.transform.zoom,null,null,null)}var oe;ee.destroy(),N.destroy()}Ft.disabled=new Ft(!1,1029,2305),Ft.backCCW=new Ft(!0,1029,2305);const eo=o.ao(new Float32Array(16));function os(h,t,n,s,u,p){const{horizontalAlign:g,verticalAlign:_}=o.au(h);return new o.P((-(g-.5)*t/u+s[0])*p,(-(_-.5)*n/u+s[1])*p)}function ls(h,t,n,s,u,p,g,_,v,w,I){const A=h.text.placedSymbolArray,D=h.text.dynamicLayoutVertexArray,$=h.icon.dynamicLayoutVertexArray,U={};D.clear();for(let q=0;q<A.length;q++){const N=A.get(q),ee=N.hidden||!N.crossTileID||h.allowVerticalPlacement&&!N.placedOrientation?null:s[N.crossTileID];if(ee){const oe=new o.P(N.anchorX,N.anchorY),X=jt(oe,n?g:p,I),ie=vn(u.cameraToCenterDistance,X.signedDistanceFromCamera);let ce=o.aj(h.textSizeData,v,N)*ie/o.ap;n&&(ce*=h.tilePixelRatio/_);const{width:ue,height:me,anchor:be,textOffset:xe,textBoxScale:Se}=ee,Ne=os(be,ue,me,xe,Se,ce),ct=n?jt(oe.add(Ne),p,I).point:X.point.add(t?Ne.rotate(-u.angle):Ne),Ee=h.allowVerticalPlacement&&N.placedOrientation===o.ai.vertical?Math.PI/2:0;for(let Je=0;Je<N.numGlyphs;Je++)o.ak(D,ct,Ee);w&&N.associatedIconIndex>=0&&(U[N.associatedIconIndex]={shiftedAnchor:ct,angle:Ee})}else F(N.numGlyphs,D)}if(w){$.clear();const q=h.icon.placedSymbolArray;for(let N=0;N<q.length;N++){const ee=q.get(N);if(ee.hidden)F(ee.numGlyphs,$);else{const oe=U[N];if(oe)for(let X=0;X<ee.numGlyphs;X++)o.ak($,oe.shiftedAnchor,oe.angle);else F(ee.numGlyphs,$)}}h.icon.dynamicLayoutVertexBuffer.updateData($)}h.text.dynamicLayoutVertexBuffer.updateData(D)}function to(h,t,n){return n.iconsInText&&t?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function cs(h,t,n,s,u,p,g,_,v,w,I,A){const D=h.context,$=D.gl,U=h.transform,q=_==="map",N=v==="map",ee=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",oe=q&&!N&&!ee,X=!n.layout.get("symbol-sort-key").isConstant();let ie=!1;const ce=h.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),Se=xe.getBucket(n);if(!Se)continue;const Ne=u?Se.text:Se.icon;if(!Ne||!Ne.segments.get().length||!Ne.hasVisibleVertices)continue;const ct=Ne.programConfigurations.get(n.id),Ee=u||Se.sdfIcons,Je=u?Se.textSizeData:Se.iconSizeData,$e=N||U.pitch!==0,St=h.useProgram(to(Ee,u,Se),ct),lt=o.ah(Je,U.zoom),at=h.style.map.terrain&&h.style.map.terrain.getTerrainData(be);let ut,Ht,kt,mi,ri=[0,0],Yt=null;if(u)Ht=xe.glyphAtlasTexture,kt=$.LINEAR,ut=xe.glyphAtlasTexture.size,Se.iconsInText&&(ri=xe.imageAtlasTexture.size,Yt=xe.imageAtlasTexture,mi=$e||h.options.rotating||h.options.zooming||Je.kind==="composite"||Je.kind==="camera"?$.LINEAR:$.NEAREST);else{const Wt=n.layout.get("icon-size").constantOr(0)!==1||Se.iconsNeedLinear;Ht=xe.imageAtlasTexture,kt=Ee||h.options.rotating||h.options.zooming||Wt||$e?$.LINEAR:$.NEAREST,ut=xe.imageAtlasTexture.size}const Ji=Q(xe,1,h.transform.zoom),Dt=Ae(be.posMatrix,N,q,h.transform,Ji),Er=Ar(be.posMatrix,N,q,h.transform,Ji),Mr=ue&&Se.hasTextData(),hn=n.layout.get("icon-text-fit")!=="none"&&Mr&&Se.hasIconData();if(ee){const Wt=h.style.map.terrain?(Ni,Xt)=>h.style.map.terrain.getElevation(be,Ni,Xt):null,ni=n.layout.get("text-rotation-alignment")==="map";ke(Se,be.posMatrix,h,u,Dt,Er,N,w,ni,Wt)}const En=h.translatePosMatrix(be.posMatrix,xe,p,g),aa=ee||u&&ue||hn?eo:Dt,vi=h.translatePosMatrix(Er,xe,p,g,!0),gi=Ee&&n.paint.get(u?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ci;Ci=Ee?Se.iconsInText?wn(Je.kind,lt,oe,N,h,En,aa,vi,ut,ri):js(Je.kind,lt,oe,N,h,En,aa,vi,u,ut):$s(Je.kind,lt,oe,N,h,En,aa,vi,u,ut);const Mn={program:St,buffers:Ne,uniformValues:Ci,atlasTexture:Ht,atlasTextureIcon:Yt,atlasInterpolation:kt,atlasInterpolationIcon:mi,isSDF:Ee,hasHalo:gi};if(X&&Se.canOverlap){ie=!0;const Wt=Ne.segments.get();for(const ni of Wt)me.push({segments:new o.S([ni]),sortKey:ni.sortKey,state:Mn,terrainData:at})}else me.push({segments:Ne.segments,sortKey:0,state:Mn,terrainData:at})}ie&&me.sort(((be,xe)=>be.sortKey-xe.sortKey));for(const be of me){const xe=be.state;if(D.activeTexture.set($.TEXTURE0),xe.atlasTexture.bind(xe.atlasInterpolation,$.CLAMP_TO_EDGE),xe.atlasTextureIcon&&(D.activeTexture.set($.TEXTURE1),xe.atlasTextureIcon&&xe.atlasTextureIcon.bind(xe.atlasInterpolationIcon,$.CLAMP_TO_EDGE)),xe.isSDF){const Se=xe.uniformValues;xe.hasHalo&&(Se.u_is_halo=1,io(xe.buffers,be.segments,n,h,xe.program,ce,I,A,Se,be.terrainData)),Se.u_is_halo=0}io(xe.buffers,be.segments,n,h,xe.program,ce,I,A,xe.uniformValues,be.terrainData)}}function io(h,t,n,s,u,p,g,_,v,w){const I=s.context;u.draw(I,I.gl.TRIANGLES,p,g,_,Ft.disabled,v,w,n.id,h.layoutVertexBuffer,h.indexBuffer,t,n.paint,s.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function xa(h,t,n,s,u){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 v=u.getPaintProperty(t);g=p[v],_=p[v]}g&&_&&h.setConstantPatternPositions(g,_)}function va(h,t,n,s,u,p,g){const _=h.context.gl,v="fill-pattern",w=n.paint.get(v),I=w&&w.constantOr(1),A=n.getCrossfadeParameters();let D,$,U,q,N;g?($=I&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",D=_.LINES):($=I?"fillPattern":"fill",D=_.TRIANGLES);const ee=w.constantOr(null);for(const oe of s){const X=t.getTile(oe);if(I&&!X.patternsLoaded())continue;const ie=X.getBucket(n);if(!ie)continue;const ce=ie.programConfigurations.get(n.id),ue=h.useProgram($,ce),me=h.style.map.terrain&&h.style.map.terrain.getTerrainData(oe);I&&(h.context.activeTexture.set(_.TEXTURE0),X.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ce.updatePaintBuffers(A)),xa(ce,v,ee,X,n);const be=me?oe:null,xe=h.translatePosMatrix(be?be.posMatrix:oe.posMatrix,X,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(g){q=ie.indexBuffer2,N=ie.segments2;const Se=[_.drawingBufferWidth,_.drawingBufferHeight];U=$==="fillOutlinePattern"&&I?Xa(xe,h,A,X,Se):Wa(xe,Se)}else q=ie.indexBuffer,N=ie.segments,U=I?Os(xe,h,A,X):tl(xe);ue.draw(h.context,D,u,h.stencilModeForClipping(oe),p,Ft.disabled,U,me,n.id,ie.layoutVertexBuffer,q,N,n.paint,h.transform.zoom,ce)}}function ba(h,t,n,s,u,p,g){const _=h.context,v=_.gl,w="fill-extrusion-pattern",I=n.paint.get(w),A=I.constantOr(1),D=n.getCrossfadeParameters(),$=n.paint.get("fill-extrusion-opacity"),U=I.constantOr(null);for(const q of s){const N=t.getTile(q),ee=N.getBucket(n);if(!ee)continue;const oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(q),X=ee.programConfigurations.get(n.id),ie=h.useProgram(A?"fillExtrusionPattern":"fillExtrusion",X);A&&(h.context.activeTexture.set(v.TEXTURE0),N.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),X.updatePaintBuffers(D)),xa(X,w,U,N,n);const ce=h.translatePosMatrix(q.posMatrix,N,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ue=n.paint.get("fill-extrusion-vertical-gradient"),me=A?nn(ce,h,ue,$,q,D,N):Bs(ce,h,ue,$);ie.draw(_,_.gl.TRIANGLES,u,p,g,Ft.backCCW,me,oe,n.id,ee.layoutVertexBuffer,ee.indexBuffer,ee.segments,n.paint,h.transform.zoom,X,h.style.map.terrain&&ee.centroidVertexBuffer)}}function Fc(h,t,n,s,u,p,g){const _=h.context,v=_.gl,w=n.fbo;if(!w)return;const I=h.useProgram("hillshade"),A=h.style.map.terrain&&h.style.map.terrain.getTerrainData(t);_.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,w.colorAttachment.get()),I.draw(_,v.TRIANGLES,u,p,g,Ft.disabled,((D,$,U,q)=>{const N=U.paint.get("hillshade-shadow-color"),ee=U.paint.get("hillshade-highlight-color"),oe=U.paint.get("hillshade-accent-color");let X=U.paint.get("hillshade-illumination-direction")*(Math.PI/180);U.paint.get("hillshade-illumination-anchor")==="viewport"&&(X-=D.transform.angle);const ie=!D.options.moving;return{u_matrix:q?q.posMatrix:D.transform.calculatePosMatrix($.tileID.toUnwrapped(),ie),u_image:0,u_latrange:Vs(0,$.tileID),u_light:[U.paint.get("hillshade-exaggeration"),X],u_shadow:N,u_highlight:ee,u_accent:oe}})(h,n,s,A?t:null),A,s.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function ro(h,t,n,s,u,p){const g=h.context,_=g.gl,v=t.dem;if(v&&v.data){const w=v.dim,I=v.stride,A=v.getPixels();if(g.activeTexture.set(_.TEXTURE1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||h.getTileTexture(I),t.demTexture){const $=t.demTexture;$.update(A,{premultiply:!1}),$.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else t.demTexture=new Mt(g,A,_.RGBA,{premultiply:!1}),t.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);g.activeTexture.set(_.TEXTURE0);let D=t.fbo;if(!D){const $=new Mt(g,{width:w,height:w,data:null},_.RGBA);$.bind(_.LINEAR,_.CLAMP_TO_EDGE),D=t.fbo=g.createFramebuffer(w,w,!0,!1),D.colorAttachment.set($.texture)}g.bindFramebuffer.set(D.framebuffer),g.viewport.set([0,0,w,w]),h.useProgram("hillshadePrepare").draw(g,_.TRIANGLES,s,u,p,Ft.disabled,(($,U)=>{const q=U.stride,N=o.Z();return o.aS(N,0,o.N,-o.N,0,0,1),o.$(N,N,[0,-o.N,0]),{u_matrix:N,u_image:1,u_dimension:[q,q],u_zoom:$.overscaledZ,u_unpack:U.getUnpackVector()}})(t.tileID,v),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Bc(h,t,n,s,u,p){const g=s.paint.get("raster-fade-duration");if(!p&&g>0){const _=o.h.now(),v=(_-h.timeAdded)/g,w=t?(_-t.timeAdded)/g:-1,I=n.getSource(),A=u.coveringZoomLevel({tileSize:I.tileSize,roundZoom:I.roundZoom}),D=!t||Math.abs(t.tileID.overscaledZ-A)>Math.abs(h.tileID.overscaledZ-A),$=D&&h.refreshedUponExpiration?1:o.ad(D?v:1-w,0,1);return h.refreshedUponExpiration&&v>=1&&(h.refreshedUponExpiration=!1),t?{opacity:1,mix:1-$}:{opacity:$,mix:0}}return{opacity:1,mix:0}}const ml=new o.aT(1,0,0,1),us=new o.aT(0,1,0,1),no=new o.aT(0,0,1,1),gl=new o.aT(1,0,1,1),_l=new o.aT(0,1,1,1);function wa(h,t,n,s){ps(h,0,t+n/2,h.transform.width,n,s)}function hs(h,t,n,s){ps(h,t-n/2,0,n,h.transform.height,s)}function ps(h,t,n,s,u,p){const g=h.context,_=g.gl;_.enable(_.SCISSOR_TEST),_.scissor(t*h.pixelRatio,n*h.pixelRatio,s*h.pixelRatio,u*h.pixelRatio),g.clear({color:p}),_.disable(_.SCISSOR_TEST)}function yl(h,t,n){const s=h.context,u=s.gl,p=n.posMatrix,g=h.useProgram("debug"),_=ft.disabled,v=Vt.disabled,w=h.colorModeForRenderPass(),I="$debug",A=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);s.activeTexture.set(u.TEXTURE0);const D=t.getTileByID(n.key).latestRawTileData,$=Math.floor((D&&D.byteLength||0)/1024),U=t.getTile(n).tileSize,q=512/Math.min(U,512)*(n.overscaledZ/h.transform.zoom)*.5;let N=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(N+=` => ${n.overscaledZ}`),(function(ee,oe){ee.initDebugOverlayCanvas();const X=ee.debugOverlayCanvas,ie=ee.context.gl,ce=ee.debugOverlayCanvas.getContext("2d");ce.clearRect(0,0,X.width,X.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(oe,5,5),ce.strokeText(oe,5,5),ee.debugOverlayTexture.update(X),ee.debugOverlayTexture.bind(ie.LINEAR,ie.CLAMP_TO_EDGE)})(h,`${N} ${$}kB`),g.draw(s,u.TRIANGLES,_,v,Nt.alphaBlended,Ft.disabled,ga(p,o.aT.transparent,q),null,I,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),g.draw(s,u.LINE_STRIP,_,v,w,Ft.disabled,ga(p,o.aT.red),A,I,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function Zt(h,t,n){const s=h.context,u=s.gl,p=h.colorModeForRenderPass(),g=new ft(u.LEQUAL,ft.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),v=t.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,h.width,h.height]);for(const w of n){const I=h.renderToTexture.getTexture(w),A=t.getTerrainData(w.tileID);s.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,I.texture);const D={u_matrix:h.transform.calculatePosMatrix(w.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(h.transform.zoom)};_.draw(s,u.TRIANGLES,g,Vt.disabled,p,Ft.backCCW,D,A,"terrain",v.vertexBuffer,v.indexBuffer,v.segments)}}class In{constructor(t,n){this.context=new Rc(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.Z(),renderTime:0},this.setup(),this.numSublayers=Fi.maxUnderzooming+Fi.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Za}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 u of this.style._order)this.style._layers[u].resize()}setup(){const t=this.context,n=new o.a_;n.emplaceBack(0,0),n.emplaceBack(o.N,0),n.emplaceBack(0,o.N),n.emplaceBack(o.N,o.N),this.tileExtentBuffer=t.createVertexBuffer(n,Ga.members),this.tileExtentSegments=o.S.simpleSegment(0,0,4,2);const s=new o.a_;s.emplaceBack(0,0),s.emplaceBack(o.N,0),s.emplaceBack(0,o.N),s.emplaceBack(o.N,o.N),this.debugBuffer=t.createVertexBuffer(s,Ga.members),this.debugSegments=o.S.simpleSegment(0,0,4,5);const u=new o.V;u.emplaceBack(0,0,0,0),u.emplaceBack(o.N,0,o.N,0),u.emplaceBack(0,o.N,0,o.N),u.emplaceBack(o.N,o.N,o.N,o.N),this.rasterBoundsBuffer=t.createVertexBuffer(u,_r.members),this.rasterBoundsSegments=o.S.simpleSegment(0,0,4,2);const p=new o.a_;p.emplaceBack(0,0),p.emplaceBack(1,0),p.emplaceBack(0,1),p.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(p,Ga.members),this.viewportSegments=o.S.simpleSegment(0,0,4,2);const g=new o.a$;g.emplaceBack(0),g.emplaceBack(1),g.emplaceBack(3),g.emplaceBack(2),g.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(g);const _=new o.b0;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);const v=this.context.gl;this.stencilClearMode=new Vt({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=o.Z();o.aS(s,0,this.width,this.height,0,0,1),o.a0(s,s,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,ft.disabled,this.stencilClearMode,Nt.disabled,Ft.disabled,il(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,u=s.gl;this.nextStencilID+n.length>256&&this.clearStencil(),s.setColorMode(Nt.disabled),s.setDepthMode(ft.disabled);const p=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const g of n){const _=this._tileClippingMaskIDs[g.key]=this.nextStencilID++,v=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g);p.draw(s,u.TRIANGLES,ft.disabled,new Vt({func:u.ALWAYS,mask:0},_,255,u.KEEP,u.KEEP,u.REPLACE),Nt.disabled,Ft.disabled,il(g.posMatrix),v,"$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 Vt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Vt({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)),u=s[s.length-1].overscaledZ,p=s[0].overscaledZ-u+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const g={};for(let _=0;_<p;_++)g[_+u]=new Vt({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[g,s]}return[{[u]:Vt.disabled},s]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new Nt([t.CONSTANT_COLOR,t.ONE],new o.aT(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Nt.unblended:Nt.alphaBlended}depthModeForSublayer(t,n,s){if(!this.opaquePassEnabledForLayer())return ft.disabled;const u=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ft(s||this.context.gl.LEQUAL,n,[u,u])}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(o.h.now()),this.imageManager.beginFrame();const s=this.style._order,u=this.style.sourceCaches,p={},g={},_={};for(const v in u){const w=u[v];w.used&&w.prepare(this.context),p[v]=w.getVisibleCoordinates(),g[v]=p[v].slice().reverse(),_[v]=w.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let v=0;v<s.length;v++)if(this.style._layers[s[v]].is3D()){this.opaquePassCutoff=v;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;const v=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!o.b1(this.terrainFacilitator.matrix,this.transform.projMatrix)||v.length)&&(o.b2(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(w,I){const A=w.context,D=A.gl,$=Nt.unblended,U=new ft(D.LEQUAL,ft.ReadWrite,[0,1]),q=I.getTerrainMesh(),N=I.sourceCache.getRenderableTiles(),ee=w.useProgram("terrainDepth");A.bindFramebuffer.set(I.getFramebuffer("depth").framebuffer),A.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),A.clear({color:o.aT.transparent,depth:1});for(const oe of N){const X=I.getTerrainData(oe.tileID),ie={u_matrix:w.transform.calculatePosMatrix(oe.tileID.toUnwrapped()),u_ele_delta:I.getMeshFrameDelta(w.transform.zoom)};ee.draw(A,D.TRIANGLES,U,Vt.disabled,$,Ft.backCCW,ie,X,"terrain",q.vertexBuffer,q.indexBuffer,q.segments)}A.bindFramebuffer.set(null),A.viewport.set([0,0,w.width,w.height])})(this,this.style.map.terrain),(function(w,I){const A=w.context,D=A.gl,$=Nt.unblended,U=new ft(D.LEQUAL,ft.ReadWrite,[0,1]),q=I.getTerrainMesh(),N=I.getCoordsTexture(),ee=I.sourceCache.getRenderableTiles(),oe=w.useProgram("terrainCoords");A.bindFramebuffer.set(I.getFramebuffer("coords").framebuffer),A.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),A.clear({color:o.aT.transparent,depth:1}),I.coordsIndex=[];for(const X of ee){const ie=I.getTerrainData(X.tileID);A.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,N.texture);const ce={u_matrix:w.transform.calculatePosMatrix(X.tileID.toUnwrapped()),u_terrain_coords_id:(255-I.coordsIndex.length)/255,u_texture:0,u_ele_delta:I.getMeshFrameDelta(w.transform.zoom)};oe.draw(A,D.TRIANGLES,U,Vt.disabled,$,Ft.backCCW,ce,ie,"terrain",q.vertexBuffer,q.indexBuffer,q.segments),I.coordsIndex.push(X.tileID.key)}A.bindFramebuffer.set(null),A.viewport.set([0,0,w.width,w.height])})(this,this.style.map.terrain))}this.renderPass="offscreen";for(const v of s){const w=this.style._layers[v];if(!w.hasOffscreenPass()||w.isHidden(this.transform.zoom))continue;const I=g[w.source];(w.type==="custom"||I.length)&&this.renderLayer(this,u[w.source],w,I)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?o.aT.black:o.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 v=this.style._layers[s[this.currentLayer]],w=u[v.source],I=p[v.source];this._renderTileClippingMasks(v,I),this.renderLayer(this,w,v,I)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const v=this.style._layers[s[this.currentLayer]],w=u[v.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(v))continue;const I=(v.type==="symbol"?_:g)[v.source];this._renderTileClippingMasks(v,p[v.source]),this.renderLayer(this,w,v,I)}if(this.options.showTileBoundaries){const v=(function(w,I){let A=null;const D=Object.values(w._layers).flatMap((N=>N.source&&!N.isHidden(I)?[w.sourceCaches[N.source]]:[])),$=D.filter((N=>N.getSource().type==="vector")),U=D.filter((N=>N.getSource().type!=="vector")),q=N=>{(!A||A.getSource().maxzoom<N.getSource().maxzoom)&&(A=N)};return $.forEach((N=>q(N))),A||U.forEach((N=>q(N))),A})(this.style,this.transform.zoom);v&&(function(w,I,A){for(let D=0;D<A.length;D++)yl(w,I,A[D])})(this,v,v.getVisibleCoordinates())}this.options.showPadding&&(function(v){const w=v.transform.padding;wa(v,v.transform.height-(w.top||0),3,ml),wa(v,w.bottom||0,3,us),hs(v,w.left||0,3,no),hs(v,v.transform.width-(w.right||0),3,gl);const I=v.transform.centerPoint;(function(A,D,$,U){ps(A,D-1,$-10,2,20,U),ps(A,D-10,$-1,20,2,U)})(v,I.x,v.transform.height-I.y,_l)})(this),this.context.setDefault()}renderLayer(t,n,s,u){if(!s.isHidden(this.transform.zoom)&&(s.type==="background"||s.type==="custom"||(u||[]).length))switch(this.id=s.id,s.type){case"symbol":(function(p,g,_,v,w){if(p.renderPass!=="translucent")return;const I=Vt.disabled,A=p.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(D,$,U,q,N,ee,oe){const X=$.transform,ie=N==="map",ce=ee==="map";for(const ue of D){const me=q.getTile(ue),be=me.getBucket(U);if(!be||!be.text||!be.text.segments.get().length)continue;const xe=o.ah(be.textSizeData,X.zoom),Se=Q(me,1,$.transform.zoom),Ne=Ae(ue.posMatrix,ce,ie,$.transform,Se),ct=U.layout.get("icon-text-fit")!=="none"&&be.hasIconData();if(xe){const Ee=Math.pow(2,X.zoom-me.tileID.overscaledZ);ls(be,ie,ce,oe,X,Ne,ue.posMatrix,Ee,xe,ct,$.style.map.terrain?(Je,$e)=>$.style.map.terrain.getElevation(ue,Je,$e):null)}}})(v,p,_,g,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),w),_.paint.get("icon-opacity").constantOr(1)!==0&&cs(p,g,_,v,!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"),I,A),_.paint.get("text-opacity").constantOr(1)!==0&&cs(p,g,_,v,!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"),I,A),g.map.showCollisionBoxes&&(fl(p,g,_,v,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),!0),fl(p,g,_,v,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),!1))})(t,n,s,u,this.style.placement.variableOffsets);break;case"circle":(function(p,g,_,v){if(p.renderPass!=="translucent")return;const w=_.paint.get("circle-opacity"),I=_.paint.get("circle-stroke-width"),A=_.paint.get("circle-stroke-opacity"),D=!_.layout.get("circle-sort-key").isConstant();if(w.constantOr(1)===0&&(I.constantOr(1)===0||A.constantOr(1)===0))return;const $=p.context,U=$.gl,q=p.depthModeForSublayer(0,ft.ReadOnly),N=Vt.disabled,ee=p.colorModeForRenderPass(),oe=[];for(let X=0;X<v.length;X++){const ie=v[X],ce=g.getTile(ie),ue=ce.getBucket(_);if(!ue)continue;const me=ue.programConfigurations.get(_.id),be=p.useProgram("circle",me),xe=ue.layoutVertexBuffer,Se=ue.indexBuffer,Ne=p.style.map.terrain&&p.style.map.terrain.getTerrainData(ie),ct={programConfiguration:me,program:be,layoutVertexBuffer:xe,indexBuffer:Se,uniformValues:an(p,ie,ce,_),terrainData:Ne};if(D){const Ee=ue.segments.get();for(const Je of Ee)oe.push({segments:new o.S([Je]),sortKey:Je.sortKey,state:ct})}else oe.push({segments:ue.segments,sortKey:0,state:ct})}D&&oe.sort(((X,ie)=>X.sortKey-ie.sortKey));for(const X of oe){const{programConfiguration:ie,program:ce,layoutVertexBuffer:ue,indexBuffer:me,uniformValues:be,terrainData:xe}=X.state;ce.draw($,U.TRIANGLES,q,N,ee,Ft.disabled,be,xe,_.id,ue,me,X.segments,_.paint,p.transform.zoom,ie)}})(t,n,s,u);break;case"heatmap":(function(p,g,_,v){if(_.paint.get("heatmap-opacity")!==0)if(p.renderPass==="offscreen"){const w=p.context,I=w.gl,A=Vt.disabled,D=new Nt([I.ONE,I.ONE],o.aT.transparent,[!0,!0,!0,!0]);(function($,U,q){const N=$.gl;$.activeTexture.set(N.TEXTURE1),$.viewport.set([0,0,U.width/4,U.height/4]);let ee=q.heatmapFbo;if(ee)N.bindTexture(N.TEXTURE_2D,ee.colorAttachment.get()),$.bindFramebuffer.set(ee.framebuffer);else{const oe=N.createTexture();N.bindTexture(N.TEXTURE_2D,oe),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_S,N.CLAMP_TO_EDGE),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_T,N.CLAMP_TO_EDGE),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MIN_FILTER,N.LINEAR),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MAG_FILTER,N.LINEAR),ee=q.heatmapFbo=$.createFramebuffer(U.width/4,U.height/4,!1,!1),(function(X,ie,ce,ue){var me,be;const xe=X.gl,Se=(me=X.HALF_FLOAT)!==null&&me!==void 0?me:xe.UNSIGNED_BYTE,Ne=(be=X.RGBA16F)!==null&&be!==void 0?be:xe.RGBA;xe.texImage2D(xe.TEXTURE_2D,0,Ne,ie.width/4,ie.height/4,0,xe.RGBA,Se,null),ue.colorAttachment.set(ce)})($,U,oe,ee)}})(w,p,_),w.clear({color:o.aT.transparent});for(let $=0;$<v.length;$++){const U=v[$];if(g.hasRenderableParent(U))continue;const q=g.getTile(U),N=q.getBucket(_);if(!N)continue;const ee=N.programConfigurations.get(_.id),oe=p.useProgram("heatmap",ee),{zoom:X}=p.transform;oe.draw(w,I.TRIANGLES,ft.disabled,A,D,Ft.disabled,Cc(U.posMatrix,q,X,_.paint.get("heatmap-intensity")),null,_.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,_.paint,p.transform.zoom,ee)}w.viewport.set([0,0,p.width,p.height])}else p.renderPass==="translucent"&&(p.context.setColorMode(p.colorModeForRenderPass()),(function(w,I){const A=w.context,D=A.gl,$=I.heatmapFbo;if(!$)return;A.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,$.colorAttachment.get()),A.activeTexture.set(D.TEXTURE1);let U=I.colorRampTexture;U||(U=I.colorRampTexture=new Mt(A,I.colorRamp,D.RGBA)),U.bind(D.LINEAR,D.CLAMP_TO_EDGE),w.useProgram("heatmapTexture").draw(A,D.TRIANGLES,ft.disabled,Vt.disabled,w.colorModeForRenderPass(),Ft.disabled,((q,N,ee,oe)=>{const X=o.Z();o.aS(X,0,q.width,q.height,0,0,1);const ie=q.context.gl;return{u_matrix:X,u_world:[ie.drawingBufferWidth,ie.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:N.paint.get("heatmap-opacity")}})(w,I),null,I.id,w.viewportBuffer,w.quadTriangleIndexBuffer,w.viewportSegments,I.paint,w.transform.zoom)})(p,_))})(t,n,s,u);break;case"line":(function(p,g,_,v){if(p.renderPass!=="translucent")return;const w=_.paint.get("line-opacity"),I=_.paint.get("line-width");if(w.constantOr(1)===0||I.constantOr(1)===0)return;const A=p.depthModeForSublayer(0,ft.ReadOnly),D=p.colorModeForRenderPass(),$=_.paint.get("line-dasharray"),U=_.paint.get("line-pattern"),q=U.constantOr(1),N=_.paint.get("line-gradient"),ee=_.getCrossfadeParameters(),oe=q?"linePattern":$?"lineSDF":N?"lineGradient":"line",X=p.context,ie=X.gl;let ce=!0;for(const ue of v){const me=g.getTile(ue);if(q&&!me.patternsLoaded())continue;const be=me.getBucket(_);if(!be)continue;const xe=be.programConfigurations.get(_.id),Se=p.context.program.get(),Ne=p.useProgram(oe,xe),ct=ce||Ne.program!==Se,Ee=p.style.map.terrain&&p.style.map.terrain.getTerrainData(ue),Je=U.constantOr(null);if(Je&&me.imageAtlas){const lt=me.imageAtlas,at=lt.patternPositions[Je.to.toString()],ut=lt.patternPositions[Je.from.toString()];at&&ut&&xe.setConstantPatternPositions(at,ut)}const $e=Ee?ue:null,St=q?kc(p,me,_,ee,$e):$?nl(p,me,_,$,ee,$e):N?rl(p,me,_,be.lineClipsArray.length,$e):Us(p,me,_,$e);if(q)X.activeTexture.set(ie.TEXTURE0),me.imageAtlasTexture.bind(ie.LINEAR,ie.CLAMP_TO_EDGE),xe.updatePaintBuffers(ee);else if($&&(ct||p.lineAtlas.dirty))X.activeTexture.set(ie.TEXTURE0),p.lineAtlas.bind(X);else if(N){const lt=be.gradients[_.id];let at=lt.texture;if(_.gradientVersion!==lt.version){let ut=256;if(_.stepInterpolant){const Ht=g.getSource().maxzoom,kt=ue.canonical.z===Ht?Math.ceil(1<<p.transform.maxZoom-ue.canonical.z):1;ut=o.ad(o.aY(be.maxLineLength/o.N*1024*kt),256,X.maxTextureSize)}lt.gradient=o.aZ({expression:_.gradientExpression(),evaluationKey:"lineProgress",resolution:ut,image:lt.gradient||void 0,clips:be.lineClipsArray}),lt.texture?lt.texture.update(lt.gradient):lt.texture=new Mt(X,lt.gradient,ie.RGBA),lt.version=_.gradientVersion,at=lt.texture}X.activeTexture.set(ie.TEXTURE0),at.bind(_.stepInterpolant?ie.NEAREST:ie.LINEAR,ie.CLAMP_TO_EDGE)}Ne.draw(X,ie.TRIANGLES,A,p.stencilModeForClipping(ue),D,Ft.disabled,St,Ee,_.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,_.paint,p.transform.zoom,xe,be.layoutVertexBuffer2),ce=!1}})(t,n,s,u);break;case"fill":(function(p,g,_,v){const w=_.paint.get("fill-color"),I=_.paint.get("fill-opacity");if(I.constantOr(1)===0)return;const A=p.colorModeForRenderPass(),D=_.paint.get("fill-pattern"),$=p.opaquePassEnabledForLayer()&&!D.constantOr(1)&&w.constantOr(o.aT.transparent).a===1&&I.constantOr(0)===1?"opaque":"translucent";if(p.renderPass===$){const U=p.depthModeForSublayer(1,p.renderPass==="opaque"?ft.ReadWrite:ft.ReadOnly);va(p,g,_,v,U,A,!1)}if(p.renderPass==="translucent"&&_.paint.get("fill-antialias")){const U=p.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,ft.ReadOnly);va(p,g,_,v,U,A,!0)}})(t,n,s,u);break;case"fill-extrusion":(function(p,g,_,v){const w=_.paint.get("fill-extrusion-opacity");if(w!==0&&p.renderPass==="translucent"){const I=new ft(p.context.gl.LEQUAL,ft.ReadWrite,p.depthRangeFor3D);if(w!==1||_.paint.get("fill-extrusion-pattern").constantOr(1))ba(p,g,_,v,I,Vt.disabled,Nt.disabled),ba(p,g,_,v,I,p.stencilModeFor3D(),p.colorModeForRenderPass());else{const A=p.colorModeForRenderPass();ba(p,g,_,v,I,Vt.disabled,A)}}})(t,n,s,u);break;case"hillshade":(function(p,g,_,v){if(p.renderPass!=="offscreen"&&p.renderPass!=="translucent")return;const w=p.context,I=p.depthModeForSublayer(0,ft.ReadOnly),A=p.colorModeForRenderPass(),[D,$]=p.renderPass==="translucent"?p.stencilConfigForOverlap(v):[{},v];for(const U of $){const q=g.getTile(U);q.needsHillshadePrepare!==void 0&&q.needsHillshadePrepare&&p.renderPass==="offscreen"?ro(p,q,_,I,Vt.disabled,A):p.renderPass==="translucent"&&Fc(p,U,q,_,I,D[U.overscaledZ],A)}w.viewport.set([0,0,p.width,p.height])})(t,n,s,u);break;case"raster":(function(p,g,_,v){if(p.renderPass!=="translucent"||_.paint.get("raster-opacity")===0||!v.length)return;const w=p.context,I=w.gl,A=g.getSource(),D=p.useProgram("raster"),$=p.colorModeForRenderPass(),[U,q]=A instanceof sr?[{},v]:p.stencilConfigForOverlap(v),N=q[q.length-1].overscaledZ,ee=!p.options.moving;for(const oe of q){const X=p.depthModeForSublayer(oe.overscaledZ-N,_.paint.get("raster-opacity")===1?ft.ReadWrite:ft.ReadOnly,I.LESS),ie=g.getTile(oe);ie.registerFadeDuration(_.paint.get("raster-fade-duration"));const ce=g.findLoadedParent(oe,0),ue=Bc(ie,ce,g,_,p.transform,p.style.map.terrain);let me,be;const xe=_.paint.get("raster-resampling")==="nearest"?I.NEAREST:I.LINEAR;w.activeTexture.set(I.TEXTURE0),ie.texture.bind(xe,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),w.activeTexture.set(I.TEXTURE1),ce?(ce.texture.bind(xe,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),me=Math.pow(2,ce.tileID.overscaledZ-ie.tileID.overscaledZ),be=[ie.tileID.canonical.x*me%1,ie.tileID.canonical.y*me%1]):ie.texture.bind(xe,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST);const Se=p.style.map.terrain&&p.style.map.terrain.getTerrainData(oe),Ne=Se?oe:null,ct=Ne?Ne.posMatrix:p.transform.calculatePosMatrix(oe.toUnwrapped(),ee),Ee=sl(ct,be||[0,0],me||1,ue,_);A instanceof sr?D.draw(w,I.TRIANGLES,X,Vt.disabled,$,Ft.disabled,Ee,Se,_.id,A.boundsBuffer,p.quadTriangleIndexBuffer,A.boundsSegments):D.draw(w,I.TRIANGLES,X,U[oe.overscaledZ],$,Ft.disabled,Ee,Se,_.id,p.rasterBoundsBuffer,p.quadTriangleIndexBuffer,p.rasterBoundsSegments)}})(t,n,s,u);break;case"background":(function(p,g,_,v){const w=_.paint.get("background-color"),I=_.paint.get("background-opacity");if(I===0)return;const A=p.context,D=A.gl,$=p.transform,U=$.tileSize,q=_.paint.get("background-pattern");if(p.isPatternMissing(q))return;const N=!q&&w.a===1&&I===1&&p.opaquePassEnabledForLayer()?"opaque":"translucent";if(p.renderPass!==N)return;const ee=Vt.disabled,oe=p.depthModeForSublayer(0,N==="opaque"?ft.ReadWrite:ft.ReadOnly),X=p.colorModeForRenderPass(),ie=p.useProgram(q?"backgroundPattern":"background"),ce=v||$.coveringTiles({tileSize:U,terrain:p.style.map.terrain});q&&(A.activeTexture.set(D.TEXTURE0),p.imageManager.bind(p.context));const ue=_.getCrossfadeParameters();for(const me of ce){const be=v?me.posMatrix:p.transform.calculatePosMatrix(me.toUnwrapped()),xe=q?hr(be,I,p,q,{tileID:me,tileSize:U},ue):Ya(be,I,w),Se=p.style.map.terrain&&p.style.map.terrain.getTerrainData(me);ie.draw(A,D.TRIANGLES,oe,ee,X,Ft.disabled,xe,Se,_.id,p.tileExtentBuffer,p.quadTriangleIndexBuffer,p.tileExtentSegments)}})(t,0,s,u);break;case"custom":(function(p,g,_){const v=p.context,w=_.implementation;if(p.renderPass==="offscreen"){const I=w.prerender;I&&(p.setCustomLayerDefaults(),v.setColorMode(p.colorModeForRenderPass()),I.call(w,v.gl,p.transform.customLayerMatrix()),v.setDirty(),p.setBaseState())}else if(p.renderPass==="translucent"){p.setCustomLayerDefaults(),v.setColorMode(p.colorModeForRenderPass()),v.setStencilMode(Vt.disabled);const I=w.renderingMode==="3d"?new ft(p.context.gl.LEQUAL,ft.ReadWrite,p.depthRangeFor3D):p.depthModeForSublayer(0,ft.ReadOnly);v.setDepthMode(I),w.render(v.gl,p.transform.customLayerMatrix()),v.setDirty(),p.setBaseState(),v.bindFramebuffer.set(null)}})(t,0,s)}}translatePosMatrix(t,n,s,u,p){if(!s[0]&&!s[1])return t;const g=p?u==="map"?this.transform.angle:0:u==="viewport"?-this.transform.angle:0;if(g){const w=Math.sin(g),I=Math.cos(g);s=[s[0]*I-s[1]*w,s[0]*w+s[1]*I]}const _=[p?s[0]:Q(n,s[0],this.transform.zoom),p?s[1]:Q(n,s[1],this.transform.zoom),0],v=new Float32Array(16);return o.$(v,t,_),v}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 Ha(this.context,Ot[t],n,Ja[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Mt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class Bi{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,s){const u=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 v=1/(_=o.ag([],_,t))[3]/n*u;return o.b3(_,_,[v,v,1/_[3],v])})),g=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((_=>{const v=(function(D,$){var U=$[0],q=$[1],N=$[2],ee=U*U+q*q+N*N;return ee>0&&(ee=1/Math.sqrt(ee)),D[0]=$[0]*ee,D[1]=$[1]*ee,D[2]=$[2]*ee,D})([],(function(D,$,U){var q=$[0],N=$[1],ee=$[2],oe=U[0],X=U[1],ie=U[2];return D[0]=N*ie-ee*X,D[1]=ee*oe-q*ie,D[2]=q*X-N*oe,D})([],ar([],p[_[0]],p[_[1]]),ar([],p[_[2]],p[_[1]]))),w=-((I=v)[0]*(A=p[_[1]])[0]+I[1]*A[1]+I[2]*A[2]);var I,A;return v.concat(w)}));return new Bi(p,g)}}class Qn{constructor(t,n){this.min=t,this.max=n,this.center=(function(s,u,p){return s[0]=.5*u[0],s[1]=.5*u[1],s[2]=.5*u[2],s})([],(function(s,u,p){return s[0]=u[0]+p[0],s[1]=u[1]+p[1],s[2]=u[2]+p[2],s})([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],s=Di(this.min),u=Di(this.max);for(let p=0;p<n.length;p++)s[p]=n[p]?this.min[p]:this.center[p],u[p]=n[p]?this.center[p]:this.max[p];return u[2]=this.max[2],new Qn(s,u)}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 u=0;u<t.planes.length;u++){const p=t.planes[u];let g=0;for(let _=0;_<n.length;_++)o.b4(p,n[_])>=0&&g++;if(g===0)return 0;g!==n.length&&(s=!1)}if(s)return 2;for(let u=0;u<3;u++){let p=Number.MAX_VALUE,g=-Number.MAX_VALUE;for(let _=0;_<t.points.length;_++){const v=t.points[_][u]-this.min[u];p=Math.min(p,v),g=Math.max(g,v)}if(g<0||p>this.max[u]-this.min[u])return 0}return 1}}class Sa{constructor(t=0,n=0,s=0,u=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0||isNaN(u)||u<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=u}interpolate(t,n,s){return n.top!=null&&t.top!=null&&(this.top=o.B.number(t.top,n.top,s)),n.bottom!=null&&t.bottom!=null&&(this.bottom=o.B.number(t.bottom,n.bottom,s)),n.left!=null&&t.left!=null&&(this.left=o.B.number(t.left,n.left,s)),n.right!=null&&t.right!=null&&(this.right=o.B.number(t.right,n.right,s)),this}getCenter(t,n){const s=o.ad((this.left+t-this.right)/2,0,t),u=o.ad((this.top+n-this.bottom)/2,0,n);return new o.P(s,u)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Sa(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class ds{constructor(t,n,s,u,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=u??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.L(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Sa,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0}clone(){const t=new ds(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 o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-o.b5(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(function(){var s=new o.A(4);return o.A!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s})(),(function(s,u,p){var g=u[0],_=u[1],v=u[2],w=u[3],I=Math.sin(p),A=Math.cos(p);s[0]=g*A+v*I,s[1]=_*A+w*I,s[2]=g*-I+v*A,s[3]=_*-I+w*A})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=o.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 o.b6(0,t)];if(this._renderWorldCopies){const s=this.pointCoordinate(new o.P(0,0)),u=this.pointCoordinate(new o.P(this.width,0)),p=this.pointCoordinate(new o.P(this.width,this.height)),g=this.pointCoordinate(new o.P(0,this.height)),_=Math.floor(Math.min(s.x,u.x,p.x,g.x)),v=Math.floor(Math.max(s.x,u.x,p.x,g.x)),w=1;for(let I=_-w;I<=v+w;I++)I!==0&&n.push(new o.b6(I,t))}return n}coveringTiles(t){var n,s;let u=this.coveringZoomLevel(t);const p=u;if(t.minzoom!==void 0&&u<t.minzoom)return[];t.maxzoom!==void 0&&u>t.maxzoom&&(u=t.maxzoom);const g=this.pointCoordinate(this.getCameraPoint()),_=o.U.fromLngLat(this.center),v=Math.pow(2,u),w=[v*g.x,v*g.y,0],I=[v*_.x,v*_.y,0],A=Bi.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,u);let D=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(D=u);const $=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,U=X=>({aabb:new Qn([X*v,0,0],[(X+1)*v,v,0]),zoom:0,x:0,y:0,wrap:X,fullyVisible:!1}),q=[],N=[],ee=u,oe=t.reparseOverscaled?p:u;if(this._renderWorldCopies)for(let X=1;X<=3;X++)q.push(U(-X)),q.push(U(X));for(q.push(U(0));q.length>0;){const X=q.pop(),ie=X.x,ce=X.y;let ue=X.fullyVisible;if(!ue){const Ne=X.aabb.intersects(A);if(Ne===0)continue;ue=Ne===2}const me=t.terrain?w:I,be=X.aabb.distanceX(me),xe=X.aabb.distanceY(me),Se=Math.max(Math.abs(be),Math.abs(xe));if(X.zoom===ee||Se>$+(1<<ee-X.zoom)-2&&X.zoom>=D){const Ne=ee-X.zoom,ct=w[0]-.5-(ie<<Ne),Ee=w[1]-.5-(ce<<Ne);N.push({tileID:new o.O(X.zoom===ee?oe:X.zoom,X.wrap,X.zoom,ie,ce),distanceSq:mn([I[0]-.5-ie,I[1]-.5-ce]),tileDistanceToCamera:Math.sqrt(ct*ct+Ee*Ee)})}else for(let Ne=0;Ne<4;Ne++){const ct=(ie<<1)+Ne%2,Ee=(ce<<1)+(Ne>>1),Je=X.zoom+1;let $e=X.aabb.quadrant(Ne);if(t.terrain){const St=new o.O(Je,X.wrap,Je,ct,Ee),lt=t.terrain.getMinMaxElevation(St),at=(n=lt.minElevation)!==null&&n!==void 0?n:this.elevation,ut=(s=lt.maxElevation)!==null&&s!==void 0?s:this.elevation;$e=new Qn([$e.min[0],$e.min[1],at],[$e.max[0],$e.max[1],ut])}q.push({aabb:$e,zoom:Je,x:ct,y:Ee,wrap:X.wrap,fullyVisible:ue})}}return N.sort(((X,ie)=>X.distanceSq-ie.distanceSq)).map((X=>X.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=o.ad(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new o.P(o.G(t.lng)*this.worldSize,o.H(n)*this.worldSize)}unproject(t){return new o.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 u=this.getCameraPosition(),p=o.U.fromLngLat(u.lngLat,u.altitude),g=o.U.fromLngLat(n,s),_=p.x-g.x,v=p.y-g.y,w=p.z-g.z,I=Math.sqrt(_*_+v*v+w*w),A=this.scaleZoom(this.cameraToCenterDistance/I/this.tileSize);this._elevation=s,this._center=n,this.zoom=A}setLocationAtPoint(t,n){const s=this.pointCoordinate(n),u=this.pointCoordinate(this.centerPoint),p=this.locationCoordinate(t),g=new o.U(p.x-(s.x-u.x),p.y-(s.y-u.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 o.U.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const D=n.pointCoordinate(t);if(D!=null)return D}const s=[t.x,t.y,0,1],u=[t.x,t.y,1,1];o.ag(s,s,this.pixelMatrixInverse),o.ag(u,u,this.pixelMatrixInverse);const p=s[3],g=u[3],_=s[1]/p,v=u[1]/g,w=s[2]/p,I=u[2]/g,A=w===I?0:(0-w)/(I-w);return new o.U(o.B.number(s[0]/p,u[0]/g,A)/this.worldSize,o.B.number(_,v,A)/this.worldSize)}coordinatePoint(t,n=0,s=this.pixelMatrix){const u=[t.x*this.worldSize,t.y*this.worldSize,n,1];return o.ag(u,u,s),new o.P(u[0]/u[3],u[1]/u[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new Pt().extend(this.pointLocation(new o.P(0,t))).extend(this.pointLocation(new o.P(this.width,t))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Pt([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,u=n?this._alignedPosMatrixCache:this._posMatrixCache;if(u[s])return u[s];const p=t.canonical,g=this.worldSize/this.zoomScale(p.z),_=p.x+Math.pow(2,p.z)*t.wrap,v=o.ao(new Float64Array(16));return o.$(v,v,[_*g,p.y*g,0]),o.a0(v,v,[g/o.N,g/o.N,1]),o.a1(v,n?this.alignedProjMatrix:this.projMatrix,v),u[s]=new Float32Array(v),u[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,s,u,p=-90,g=90,_=-180,v=180;const w=this.size,I=this._unmodified;if(this.latRange){const $=this.latRange;p=o.H($[1])*this.worldSize,g=o.H($[0])*this.worldSize,t=g-p<w.y?w.y/(g-p):0}if(this.lngRange){const $=this.lngRange;_=o.b5(o.G($[0])*this.worldSize,0,this.worldSize),v=o.b5(o.G($[1])*this.worldSize,0,this.worldSize),v<_&&(v+=this.worldSize),n=v-_<w.x?w.x/(v-_):0}const A=this.point,D=Math.max(n||0,t||0);if(D)return this.center=this.unproject(new o.P(n?(v+_)/2:A.x,t?(g+p)/2:A.y)),this.zoom+=this.scaleZoom(D),this._unmodified=I,void(this._constraining=!1);if(this.latRange){const $=A.y,U=w.y/2;$-U<p&&(u=p+U),$+U>g&&(u=g-U)}if(this.lngRange){const $=(_+v)/2,U=o.b5(A.x,$-this.worldSize/2,$+this.worldSize/2),q=w.x/2;U-q<_&&(s=_+q),U+q>v&&(s=v-q)}s===void 0&&u===void 0||(this.center=this.unproject(new o.P(s!==void 0?s:A.x,u!==void 0?u:A.y)).wrap()),this._unmodified=I,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=o.b7(1,this.center.lat)*this.worldSize;let u=o.ao(new Float64Array(16));o.a0(u,u,[this.width/2,-this.height/2,1]),o.$(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=o.ao(new Float64Array(16)),o.a0(u,u,[1,-1,1]),o.$(u,u,[-1,-1,0]),o.a0(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u;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),v=g<0?_:p,w=Math.PI/2+this._pitch,I=this._fov*(.5+t.y/this.height),A=Math.sin(I)*v/Math.sin(o.ad(Math.PI-w-I,.01,Math.PI-.01)),D=this.getHorizon(),$=2*Math.atan(D/this.cameraToCenterDistance)*(.5+t.y/(2*D)),U=Math.sin($)*v/Math.sin(o.ad(Math.PI-w-$,.01,Math.PI-.01)),q=Math.min(A,U),N=1.01*(Math.cos(Math.PI/2-this._pitch)*q+v),ee=this.height/50;u=new Float64Array(16),o.b8(u,this._fov,this.width/this.height,ee,N),u[8]=2*-t.x/this.width,u[9]=2*t.y/this.height,o.a0(u,u,[1,-1,1]),o.$(u,u,[0,0,-this.cameraToCenterDistance]),o.b9(u,u,this._pitch),o.ae(u,u,this.angle),o.$(u,u,[-n,-s,0]),this.mercatorMatrix=o.a0([],u,[this.worldSize,this.worldSize,this.worldSize]),o.a0(u,u,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.a1(new Float64Array(16),this.labelPlaneMatrix,u),o.$(u,u,[0,0,-this.elevation]),this.projMatrix=u,this.invProjMatrix=o.as([],u),this.pixelMatrix3D=o.a1(new Float64Array(16),this.labelPlaneMatrix,u);const oe=this.width%2/2,X=this.height%2/2,ie=Math.cos(this.angle),ce=Math.sin(this.angle),ue=n-Math.round(n)+ie*oe+ce*X,me=s-Math.round(s)+ie*X+ce*oe,be=new Float64Array(u);if(o.$(be,be,[ue>.5?ue-1:ue,me>.5?me-1:me,0]),this.alignedProjMatrix=be,u=o.as(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");this.pixelMatrixInverse=u,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new o.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return o.ag(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let s=n.x,u=n.y,p=n.x,g=n.y;for(const _ of t)s=Math.min(s,_.x),u=Math.min(u,_.y),p=Math.max(p,_.x),g=Math.max(g,_.y);return[new o.P(s,u),new o.P(p,u),new o.P(p,g),new o.P(s,g),new o.P(s,u)]}}}function An(h,t){let n,s=!1,u=null,p=null;const g=()=>{u=null,s&&(h.apply(p,n),u=setTimeout(g,t),s=!1)};return(..._)=>(s=!0,p=this,n=_,u||g(),u)}class Ta{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let s;return n.split("&").map((u=>u.split("="))).forEach((u=>{u[0]===this._hashName&&(s=u)})),(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=An(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,u=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,u),g=Math.round(n.lng*p)/p,_=Math.round(n.lat*p)/p,v=this._map.getBearing(),w=this._map.getPitch();let I="";if(I+=t?`/${g}/${_}/${s}`:`${s}/${_}/${g}`,(v||w)&&(I+="/"+Math.round(10*v)/10),w&&(I+=`/${Math.round(w)}`),this._hashName){const A=this._hashName;let D=!1;const $=window.location.hash.slice(1).split("&").map((U=>{const q=U.split("=")[0];return q===A?(D=!0,`${q}=${I}`):U})).filter((U=>U));return D||$.push(`${A}=${I}`),`#${$.join("&")}`}return`#${I}`}}const ea={linearity:.3,easing:o.ba(0,0,.3,1)},xl=o.e({deceleration:2500,maxSpeed:1400},ea),vl=o.e({deceleration:20,maxSpeed:1400},ea),bl=o.e({deceleration:1e3,maxSpeed:360},ea),wl=o.e({deceleration:1e3,maxSpeed:90},ea);class Sl{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:o.h.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=o.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 o.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,u={};if(n.pan.mag()){const p=Ia(n.pan.mag(),s,o.e({},xl,t||{}));u.offset=n.pan.mult(p.amount/n.pan.mag()),u.center=this._map.transform.center,kr(u,p)}if(n.zoom){const p=Ia(n.zoom,s,vl);u.zoom=this._map.transform.zoom+p.amount,kr(u,p)}if(n.bearing){const p=Ia(n.bearing,s,bl);u.bearing=this._map.transform.bearing+o.ad(p.amount,-179,179),kr(u,p)}if(n.pitch){const p=Ia(n.pitch,s,wl);u.pitch=this._map.transform.pitch+p.amount,kr(u,p)}if(u.zoom||u.bearing){const p=n.pinchAround===void 0?n.around:n.pinchAround;u.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),o.e(u,{noMoveStart:!0})}}function kr(h,t){(!h.duration||h.duration<t.duration)&&(h.duration=t.duration,h.easing=t.easing)}function Ia(h,t,n){const{maxSpeed:s,linearity:u,deceleration:p}=n,g=o.ad(h*u/(t/1e3),-s,s),_=Math.abs(g)/(p*u);return{easing:n.easing,duration:1e3*_,amount:g*(_/2)}}class Ki extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s,u={}){const p=H.mousePos(n.getCanvasContainer(),s),g=n.unproject(p);super(t,o.e({point:p,lngLat:g,originalEvent:s},u)),this._defaultPrevented=!1,this.target=n}}class Aa extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){const u=t==="touchend"?s.changedTouches:s.touches,p=H.touchPos(n.getCanvasContainer(),u),g=p.map((v=>n.unproject(v))),_=p.reduce(((v,w,I,A)=>v.add(w.div(A.length))),new o.P(0,0));super(t,{points:p,point:_,lngLats:g,lngLat:n.unproject(_),originalEvent:s}),this._defaultPrevented=!1}}class Tl extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){super(t,{originalEvent:s}),this._defaultPrevented=!1}}class Il{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Tl(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Ki(t.type,this._map,t))}mouseup(t){this._map.fire(new Ki(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Ki(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Ki(t.type,this._map,t))}mouseover(t){this._map.fire(new Ki(t.type,this._map,t))}mouseout(t){this._map.fire(new Ki(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Aa(t.type,this._map,t))}touchmove(t){this._map.fire(new Aa(t.type,this._map,t))}touchend(t){this._map.fire(new Aa(t.type,this._map,t))}touchcancel(t){this._map.fire(new Aa(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Al{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Ki(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ki("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Ki(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{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(o.P.convert(t),this._map.terrain)}}class Cl{constructor(t,n){this._map=t,this._tr=new ln(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&&(H.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 u=this._startPos;this._lastPos=s,this._box||(this._box=H.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const p=Math.min(u.x,s.x),g=Math.max(u.x,s.x),_=Math.min(u.y,s.y),v=Math.max(u.y,s.y);H.setTransform(this._box,`translate(${p}px,${_}px)`),this._box.style.width=g-p+"px",this._box.style.height=v-_+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const s=this._startPos,u=n;if(this.reset(),H.suppressClick(),s.x!==u.x||s.y!==u.y)return this._map.fire(new o.k("boxzoomend",{originalEvent:t})),{cameraAnimation:p=>p.fitScreenCoordinates(s,u,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&&(H.remove(this._box),this._box=null),H.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new o.k(t,{originalEvent:n}))}}function pr(h,t){if(h.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${t.length}`);const n={};for(let s=0;s<h.length;s++)n[h[s].identifier]=t[s];return n}class Vr{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(u){const p=new o.P(0,0);for(const g of u)p._add(g);return p.div(u.length)})(n),this.touches=pr(s,n)))}touchmove(t,n,s){if(this.aborted||!this.centroid)return;const u=pr(s,n);for(const p in this.touches){const g=u[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 u=!this.aborted&&this.centroid;if(this.reset(),u)return u}}}class fs{constructor(t){this.singleTap=new Vr(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 u=this.singleTap.touchend(t,n,s);if(u){const p=t.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(u)<30;if(p&&g||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=u,this.count===this.numTaps)return this.reset(),u}}}class Ur{constructor(t){this._tr=new ln(t),this._zoomIn=new fs({numTouches:1,numTaps:2}),this._zoomOut=new fs({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 u=this._zoomIn.touchend(t,n,s),p=this._zoomOut.touchend(t,n,s),g=this._tr;return u?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:g.zoom+1,around:g.unproject(u)},{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 $r{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 u=n.length?n[0]:n;return!this._moved&&u.dist(s)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=u,this._move(s,u))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&H.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 Oc={0:1,2:2};class ao{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=H.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,s){const u=Oc[s];return n.buttons===void 0||(n.buttons&u)!==u})(t,this._eventButton)}isValidEndEvent(t){return H.mouseButton(t)===this._eventButton}}class kl{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 ms=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=function(t){t.preventDefault()}},ta=({enable:h,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const s=new ao({checkCorrectEvent:u=>H.mouseButton(u)===0&&u.ctrlKey||H.mouseButton(u)===2});return new $r({clickTolerance:t,move:(u,p)=>({bearingDelta:(p.x-u.x)*n}),moveStateManager:s,enable:h,assignEvents:ms})},jr=({enable:h,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const s=new ao({checkCorrectEvent:u=>H.mouseButton(u)===0&&u.ctrlKey||H.mouseButton(u)===2});return new $r({clickTolerance:t,move:(u,p)=>({pitchDelta:(p.y-u.y)*n}),moveStateManager:s,enable:h,assignEvents:ms})};class Re{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 o.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 u=pr(s,n),p=new o.P(0,0),g=new o.P(0,0);let _=0;for(const w in u){const I=u[w],A=this._touches[w];A&&(p._add(I),g._add(I.sub(A)),_++,u[w]=I)}if(this._touches=u,_<this._minTouches||!g.mag())return;const v=g.div(_);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(_),panDelta:v}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class gs{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[u,p]=this._firstTwoTouches,g=cn(s,n,u),_=cn(s,n,p);if(!g||!_)return;const v=this._aroundCenter?null:g.add(_).div(2);return this._move([g,_],v,t)}touchend(t,n,s){if(!this._firstTwoTouches)return;const[u,p]=this._firstTwoTouches,g=cn(s,n,u),_=cn(s,n,p);g&&_||(this._active&&H.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 cn(h,t,n){for(let s=0;s<h.length;s++)if(h[s].identifier===n)return t[s]}function ia(h,t){return Math.log(h/t)/Math.LN2}class El extends gs{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(ia(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ia(this._distance,s),pinchAround:n}}}function ze(h,t){return 180*h.angleWith(t)/Math.PI}class so extends gs{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 oo(h){return Math.abs(h.y)>Math.abs(h.x)}class Nc extends gs{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,oo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,s){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const u=t[0].sub(this._lastPoints[0]),p=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(u,p,s.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(u.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,s){if(this._valid!==void 0)return this._valid;const u=t.mag()>=2,p=n.mag()>=2;if(!u&&!p)return;if(!u||!p)return this._firstMove===void 0&&(this._firstMove=s),s-this._firstMove<100&&void 0;const g=t.y>0==n.y>0;return oo(t)&&oo(n)&&g}}const lo={panStep:100,bearingStep:15,pitchStep:10};class Ml{constructor(t){this._tr=new ln(t);const n=lo;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,u=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?u=1:(t.preventDefault(),g=-1);break;case 40:t.shiftKey?u=-1:(t.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(s=0,u=0),{cameraAnimation:_=>{const v=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Pl,zoom:n?Math.round(v.zoom)+n*(t.shiftKey?2:1):v.zoom,bearing:v.bearing+s*this._bearingStep,pitch:v.pitch+u*this._pitchStep,offset:[-p*this._panStep,-g*this._panStep],center:v.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 Pl(h){return h*(2-h)}const zl=4.000244140625;class Vc{constructor(t,n){this._onTimeout=s=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(s)},this._map=t,this._tr=new ln(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=o.h.now(),u=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,n!==0&&n%zl==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":u>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(u*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=H.mousePos(this._el,t),s=this._tr;this._around=o.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)>zl?this._wheelZoomRate:this._defaultZoomRate;let v=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&v!==0&&(v=1/v);const w=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(w*v))),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,u=this._easing;let p,g=!1;if(this._type==="wheel"&&s&&u){const _=Math.min((o.h.now()-this._lastWheelEventTime)/200,1),v=u(_);p=o.B.number(s,n,v),_<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=o.bb;if(this._prevEase){const s=this._prevEase,u=(o.h.now()-s.start)/s.duration,p=s.easing(u+.01)-s.easing(u),g=.27/Math.sqrt(p*p+1e-4)*.01,_=Math.sqrt(.0729-g*g);n=o.ba(g,_,.25,1)}return this._prevEase={start:o.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 co{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 uo{constructor(t){this._tr=new ln(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 ho{constructor(){this._tap=new fs({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 u=n[0],p=t.timeStamp-this._tapTime<500,g=this._tapPoint.dist(u)<30;p&&g?s.length>0&&(this._swipePoint=u,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 u=n[0],p=u.y-this._swipePoint.y;return this._swipePoint=u,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 u=this._tap.touchend(t,n,s);u&&(this._tapTime=t.timeStamp,this._tapPoint=u)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class po{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 Oi{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 un{constructor(t,n,s,u){this._el=t,this._touchZoom=n,this._touchRotate=s,this._tapDragZoom=u,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 Ca=h=>h.zoom||h.drag||h.pitch||h.rotate;class fo extends o.k{}function ka(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class mo{constructor(t,n){this.handleWindowEvent=u=>{this.handleEvent(u,`${u.type}Window`)},this.handleEvent=(u,p)=>{if(u.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const g=u.type==="renderFrame"?void 0:u,_={needsRenderFrame:!1},v={},w={},I=u.touches,A=I?this._getMapTouches(I):void 0,D=A?H.touchPos(this._el,A):H.mousePos(this._el,u);for(const{handlerName:q,handler:N,allowed:ee}of this._handlers){if(!N.isEnabled())continue;let oe;this._blockedByActive(w,ee,q)?N.reset():N[p||u.type]&&(oe=N[p||u.type](u,D,A),this.mergeHandlerResult(_,v,oe,q,g),oe&&oe.needsRenderFrame&&this._triggerRenderFrame()),(oe||N.isActive())&&(w[q]=N)}const $={};for(const q in this._previousActiveHandlers)w[q]||($[q]=g);this._previousActiveHandlers=w,(Object.keys($).length||ka(_))&&(this._changes.push([_,v,$]),this._triggerRenderFrame()),(Object.keys(w).length||ka(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:U}=_;U&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],U(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Sl(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[u,p,g]of this._listeners)H.addEventListener(u,p,u===document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[t,n,s]of this._listeners)H.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(t){const n=this._map,s=n.getCanvasContainer();this._add("mapEvent",new Il(n,t));const u=n.boxZoom=new Cl(n,t);this._add("boxZoom",u),t.interactive&&t.boxZoom&&u.enable();const p=new Ur(n),g=new uo(n);n.doubleClickZoom=new co(g,p),this._add("tapZoom",p),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const _=new ho;this._add("tapDragZoom",_);const v=n.touchPitch=new Nc(n);this._add("touchPitch",v),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const w=ta(t),I=jr(t);n.dragRotate=new Oi(t,w,I),this._add("mouseRotate",w,["mousePitch"]),this._add("mousePitch",I,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const A=(({enable:ee,clickTolerance:oe})=>{const X=new ao({checkCorrectEvent:ie=>H.mouseButton(ie)===0&&!ie.ctrlKey});return new $r({clickTolerance:oe,move:(ie,ce)=>({around:ce,panDelta:ce.sub(ie)}),activateOnStart:!0,moveStateManager:X,enable:ee,assignEvents:ms})})(t),D=new Re(t,n);n.dragPan=new po(s,A,D),this._add("mousePan",A),this._add("touchPan",D,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const $=new so,U=new El;n.touchZoomRotate=new un(s,U,$,_),this._add("touchRotate",$,["touchPan","touchZoom"]),this._add("touchZoom",U,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const q=n.scrollZoom=new Vc(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",q,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const N=n.keyboard=new Ml(n);this._add("keyboard",N),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Al(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!!Ca(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,s){for(const u in t)if(u!==s&&(!n||n.indexOf(u)<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,u,p){if(!s)return;o.e(t,s);const g={handlerName:u,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[u,p,g]of this._changes)u.panDelta&&(t.panDelta=(t.panDelta||new o.P(0,0))._add(u.panDelta)),u.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+u.zoomDelta),u.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+u.bearingDelta),u.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+u.pitchDelta),u.around!==void 0&&(t.around=u.around),u.pinchAround!==void 0&&(t.pinchAround=u.pinchAround),u.noInertia&&(t.noInertia=u.noInertia),o.e(n,p),o.e(s,g);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const u=this._map,p=u._getTransformForUpdate(),g=u.terrain;if(!(ka(t)||g&&this._terrainMovement))return this._fireEvents(n,s,!0);let{panDelta:_,zoomDelta:v,bearingDelta:w,pitchDelta:I,around:A,pinchAround:D}=t;D!==void 0&&(A=D),u._stop(!0),A=A||u.transform.centerPoint;const $=p.pointLocation(_?A.sub(_):A);w&&(p.bearing+=w),I&&(p.pitch+=I),v&&(p.zoom+=v),g?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?p.center=p.pointLocation(p.centerPoint.sub(_)):p.setLocationAtPoint($,A):(this._terrainMovement=!0,this._map._elevationFreeze=!0,p.setLocationAtPoint($,A),this._map.once("moveend",(()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,p.recalculateZoom(u.terrain)}))):p.setLocationAtPoint($,A),u._applyUpdatedTransform(p),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const u=Ca(this._eventsInProgress),p=Ca(t),g={};for(const I in t){const{originalEvent:A}=t[I];this._eventsInProgress[I]||(g[`${I}start`]=A),this._eventsInProgress[I]=t[I]}!u&&p&&this._fireEvent("movestart",p.originalEvent);for(const I in g)this._fireEvent(I,g[I]);p&&this._fireEvent("move",p.originalEvent);for(const I in t){const{originalEvent:A}=t[I];this._fireEvent(I,A)}const _={};let v;for(const I in this._eventsInProgress){const{handlerName:A,originalEvent:D}=this._eventsInProgress[I];this._handlersById[A].isActive()||(delete this._eventsInProgress[I],v=n[A]||D,_[`${I}end`]=v)}for(const I in _)this._fireEvent(I,_[I]);const w=Ca(this._eventsInProgress);if(s&&(u||p)&&!w){this._updatingCamera=!0;const I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),A=D=>D!==0&&-this._bearingSnap<D&&D<this._bearingSnap;!I||!I.essential&&o.h.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:v})),A(this._map.getBearing())&&this._map.resetNorth()):(A(I.bearing||this._map.getBearing())&&(I.bearing=0),I.freezeElevation=!0,this._map.easeTo(I,{originalEvent:v})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new o.k(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new fo("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Dl extends o.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const s=Math.min((o.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 o.L(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,s){return t=o.P.convert(t).mult(-1),this.panTo(this.transform.center,o.e({offset:t},n),s)}panTo(t,n,s){return this.easeTo(o.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(o.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(o.e({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,o.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(o.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=Pt.convert(t);const s=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),s,n)}_cameraForBoxAndBearing(t,n,s,u){const p={top:0,bottom:0,right:0,left:0};if(typeof(u=o.e({padding:p,offset:[0,0],maxZoom:this.transform.maxZoom},u)).padding=="number"){const ce=u.padding;u.padding={top:ce,bottom:ce,right:ce,left:ce}}u.padding=o.e(p,u.padding);const g=this.transform,_=g.padding,v=g.project(o.L.convert(t)),w=g.project(o.L.convert(n)),I=v.rotate(-s*Math.PI/180),A=w.rotate(-s*Math.PI/180),D=new o.P(Math.max(I.x,A.x),Math.max(I.y,A.y)),$=new o.P(Math.min(I.x,A.x),Math.min(I.y,A.y)),U=D.sub($),q=(g.width-(_.left+_.right+u.padding.left+u.padding.right))/U.x,N=(g.height-(_.top+_.bottom+u.padding.top+u.padding.bottom))/U.y;if(N<0||q<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ee=Math.min(g.scaleZoom(g.scale*Math.min(q,N)),u.maxZoom),oe=o.P.convert(u.offset),X=new o.P((u.padding.left-u.padding.right)/2,(u.padding.top-u.padding.bottom)/2).rotate(s*Math.PI/180),ie=oe.add(X).mult(g.scale/g.zoomScale(ee));return{center:g.unproject(v.add(w).div(2).sub(ie)),zoom:ee,bearing:s}}fitBounds(t,n,s){return this._fitInternal(this.cameraForBounds(t,n),n,s)}fitScreenCoordinates(t,n,s,u,p){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(t)),this.transform.pointLocation(o.P.convert(n)),s,u),u,p)}_fitInternal(t,n,s){return t?(delete(n=o.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 u=!1,p=!1,g=!1;return"zoom"in t&&s.zoom!==+t.zoom&&(u=!0,s.zoom=+t.zoom),t.center!==void 0&&(s.center=o.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 o.k("movestart",n)).fire(new o.k("move",n)),u&&this.fire(new o.k("zoomstart",n)).fire(new o.k("zoom",n)).fire(new o.k("zoomend",n)),p&&this.fire(new o.k("rotatestart",n)).fire(new o.k("rotate",n)).fire(new o.k("rotateend",n)),g&&this.fire(new o.k("pitchstart",n)).fire(new o.k("pitch",n)).fire(new o.k("pitchend",n)),this.fire(new o.k("moveend",n))}calculateCameraOptionsFromTo(t,n,s,u=0){const p=o.U.fromLngLat(t,n),g=o.U.fromLngLat(s,u),_=g.x-p.x,v=g.y-p.y,w=g.z-p.z,I=Math.hypot(_,v,w);if(I===0)throw new Error("Can't calculate camera options with same From and To");const A=Math.hypot(_,v),D=this.transform.scaleZoom(this.transform.cameraToCenterDistance/I/this.transform.tileSize),$=180*Math.atan2(_,-v)/Math.PI;let U=180*Math.acos(A/I)/Math.PI;return U=w<0?90-U:90+U,{center:g.toLngLat(),zoom:D,pitch:U,bearing:$}}easeTo(t,n){this._stop(!1,t.easeId),((t=o.e({offset:[0,0],duration:500,easing:o.bb},t)).animate===!1||!t.essential&&o.h.prefersReducedMotion)&&(t.duration=0);const s=this._getTransformForUpdate(),u=this.getZoom(),p=this.getBearing(),g=this.getPitch(),_=this.getPadding(),v="zoom"in t?+t.zoom:u,w="bearing"in t?this._normalizeBearing(t.bearing,p):p,I="pitch"in t?+t.pitch:g,A="padding"in t?t.padding:s.padding,D=o.P.convert(t.offset);let $=s.centerPoint.add(D);const U=s.pointLocation($),q=o.L.convert(t.center||U);this._normalizeCenter(q);const N=s.project(U),ee=s.project(q).sub(N),oe=s.zoomScale(v-u);let X,ie;t.around&&(X=o.L.convert(t.around),ie=s.locationPoint(X));const ce={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||v!==u,this._rotating=this._rotating||p!==w,this._pitching=this._pitching||I!==g,this._padding=!s.isPaddingEqual(A),this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ce),this.terrain&&this._prepareElevation(q),this._ease((ue=>{if(this._zooming&&(s.zoom=o.B.number(u,v,ue)),this._rotating&&(s.bearing=o.B.number(p,w,ue)),this._pitching&&(s.pitch=o.B.number(g,I,ue)),this._padding&&(s.interpolatePadding(_,A,ue),$=s.centerPoint.add(D)),this.terrain&&!t.freezeElevation&&this._updateElevation(ue),X)s.setLocationAtPoint(X,ie);else{const me=s.zoomScale(s.zoom-u),be=v>u?Math.min(2,oe):Math.max(.5,oe),xe=Math.pow(be,1-ue),Se=s.unproject(N.add(ee.mult(ue*xe)).mult(me));s.setLocationAtPoint(s.renderWorldCopies?Se.wrap():Se,$)}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 o.k("movestart",t)),this._zooming&&!s.zooming&&this.fire(new o.k("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new o.k("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new o.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=o.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:u,pitch:p,bearing:g,elevation:_}=this.transformCameraUpdate(n);s&&(n.center=s),u!==void 0&&(n.zoom=u),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 o.k("move",t)),this._zooming&&this.fire(new o.k("zoom",t)),this._rotating&&this.fire(new o.k("rotate",t)),this._pitching&&this.fire(new o.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const s=this._zooming,u=this._rotating,p=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new o.k("zoomend",t)),u&&this.fire(new o.k("rotateend",t)),p&&this.fire(new o.k("pitchend",t)),this.fire(new o.k("moveend",t))}flyTo(t,n){if(!t.essential&&o.h.prefersReducedMotion){const $e=o.F(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo($e,n)}this.stop(),t=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.bb},t);const s=this._getTransformForUpdate(),u=this.getZoom(),p=this.getBearing(),g=this.getPitch(),_=this.getPadding(),v="zoom"in t?o.ad(+t.zoom,s.minZoom,s.maxZoom):u,w="bearing"in t?this._normalizeBearing(t.bearing,p):p,I="pitch"in t?+t.pitch:g,A="padding"in t?t.padding:s.padding,D=s.zoomScale(v-u),$=o.P.convert(t.offset);let U=s.centerPoint.add($);const q=s.pointLocation(U),N=o.L.convert(t.center||q);this._normalizeCenter(N);const ee=s.project(q),oe=s.project(N).sub(ee);let X=t.curve;const ie=Math.max(s.width,s.height),ce=ie/D,ue=oe.mag();if("minZoom"in t){const $e=o.ad(Math.min(t.minZoom,u,v),s.minZoom,s.maxZoom),St=ie/s.zoomScale($e-u);X=Math.sqrt(St/ue*2)}const me=X*X;function be($e){const St=(ce*ce-ie*ie+($e?-1:1)*me*me*ue*ue)/(2*($e?ce:ie)*me*ue);return Math.log(Math.sqrt(St*St+1)-St)}function xe($e){return(Math.exp($e)-Math.exp(-$e))/2}function Se($e){return(Math.exp($e)+Math.exp(-$e))/2}const Ne=be(!1);let ct=function($e){return Se(Ne)/Se(Ne+X*$e)},Ee=function($e){return ie*((Se(Ne)*(xe(St=Ne+X*$e)/Se(St))-xe(Ne))/me)/ue;var St},Je=(be(!0)-Ne)/X;if(Math.abs(ue)<1e-6||!isFinite(Je)){if(Math.abs(ie-ce)<1e-6)return this.easeTo(t,n);const $e=ce<ie?-1:1;Je=Math.abs(Math.log(ce/ie))/X,Ee=function(){return 0},ct=function(St){return Math.exp($e*X*St)}}return t.duration="duration"in t?+t.duration:1e3*Je/("screenSpeed"in t?+t.screenSpeed/X:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=p!==w,this._pitching=I!==g,this._padding=!s.isPaddingEqual(A),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(($e=>{const St=$e*Je,lt=1/ct(St);s.zoom=$e===1?v:u+s.scaleZoom(lt),this._rotating&&(s.bearing=o.B.number(p,w,$e)),this._pitching&&(s.pitch=o.B.number(g,I,$e)),this._padding&&(s.interpolatePadding(_,A,$e),U=s.centerPoint.add($)),this.terrain&&!t.freezeElevation&&this._updateElevation($e);const at=$e===1?N:s.unproject(ee.add(oe.mult(Ee(St))).mult(lt));s.setLocationAtPoint(s.renderWorldCopies?at.wrap():at,U),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=o.h.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=o.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(o.L.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}class Yi{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=H.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=H.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=H.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(){H.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((u=>typeof u!="string"?"":u))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const u=this._map.style.stylesheet;this.styleOwner=u.owner,this.styleId=u.id}const n=this._map.style.sourceCaches;for(const u in n){const p=n[u];if(p.used||p.usedForTerrain){const g=p.getSource();g.attribution&&t.indexOf(g.attribution)<0&&t.push(g.attribution)}}t=t.filter((u=>String(u).trim())),t.sort(((u,p)=>u.length-p.length)),t=t.filter(((u,p)=>{for(let g=p+1;g<t.length;g++)if(t[g].indexOf(u)>=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 zt{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=H.create("div","maplibregl-ctrl");const n=H.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(){H.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class _s{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 u of s)if(u.id===t)return void(u.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 go={"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 Ll=o.Q([{name:"a_pos3d",type:"Int16",components:3}]);class Rl extends o.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 u of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))s[u.key]=!0,this._renderableTilesKeys.push(u.key),this._tiles[u.key]||(u.posMatrix=new Float64Array(16),o.aS(u.posMatrix,0,o.N,0,o.N,0,1),this._tiles[u.key]=new tn(u,this.tileSize));for(const u in this._tiles)s[u]||delete this._tiles[u]}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 u=this._tiles[s].tileID;if(u.canonical.equals(t.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16),o.aS(p.posMatrix,0,o.N,0,o.N,0,1),n[s]=p}else if(u.canonical.isChildOf(t.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16);const g=u.canonical.z-t.canonical.z,_=u.canonical.x-(u.canonical.x>>g<<g),v=u.canonical.y-(u.canonical.y>>g<<g),w=o.N>>g;o.aS(p.posMatrix,0,w,0,w,0,1),o.$(p.posMatrix,p.posMatrix,[-_*w,-v*w,0]),n[s]=p}else if(t.canonical.isChildOf(u.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16);const g=t.canonical.z-u.canonical.z,_=t.canonical.x-(t.canonical.x>>g<<g),v=t.canonical.y-(t.canonical.y>>g<<g),w=o.N>>g;o.aS(p.posMatrix,0,o.N,0,o.N,0,1),o.$(p.posMatrix,p.posMatrix,[_*w,v*w,0]),o.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 u=t.overscaledZ-this.deltaZoom;if(u>s.maxzoom&&(u=s.maxzoom),u<s.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(u).key);let p=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!p||!p.dem)&&n)for(;u>=s.minzoom&&(!p||!p.dem);)p=this.sourceCache.getTileByID(t.scaledTo(u--).key);return p}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((n=>n.timeAdded>=t))}}class Fl{constructor(t,n,s){this.painter=t,this.sourceCache=new Rl(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,u=o.N){var p;if(!(n>=0&&n<u&&s>=0&&s<u))return 0;const g=this.getTerrainData(t),_=(p=g.tile)===null||p===void 0?void 0:p.dem;if(!_)return 0;const v=(function(U,q,N){var ee=q[0],oe=q[1];return U[0]=N[0]*ee+N[4]*oe+N[12],U[1]=N[1]*ee+N[5]*oe+N[13],U})([],[n/u*o.N,s/u*o.N],g.u_terrain_matrix),w=[v[0]*_.dim,v[1]*_.dim],I=Math.floor(w[0]),A=Math.floor(w[1]),D=w[0]-I,$=w[1]-A;return _.get(I,A)*(1-D)*(1-$)+_.get(I+1,A)*D*(1-$)+_.get(I,A+1)*(1-D)*$+_.get(I+1,A+1)*D*$}getElevationForLngLatZoom(t,n){const{tileID:s,mercatorX:u,mercatorY:p}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(s,u%o.N,p%o.N,o.N)}getElevation(t,n,s,u=o.N){return this.getDEMElevation(t,n,s,u)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const u=this.painter.context,p=new o.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Mt(u,p,u.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Mt(u,new o.R({width:1,height:1}),u.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(u.gl.NEAREST,u.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=o.ao([])}const n=this.sourceCache.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const u=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new Mt(u,n.dem.getPixels(),u.gl.RGBA,{premultiply:!1}),n.demTexture.bind(u.gl.NEAREST,u.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const s=n&&n+n.tileID.key+t.key;if(s&&!this._demMatrixCache[s]){const u=this.sourceCache.sourceCache._source.maxzoom;let p=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=u?p=t.canonical.z-u:o.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),v=o.bc(new Float64Array(16),[1/(o.N<<p),1/(o.N<<p),0]);o.$(v,v,[g*o.N,_*o.N,0]),this._demMatrixCache[t.key]={matrix:v,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,u=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===s&&this._fbo.height===u||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Mt(n.context,{width:s,height:u,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Mt(n.context,{width:s,height:u,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,u,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,s,u))),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 o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),u=new Mt(t,s,t.gl.RGBA,{premultiply:!1});return u.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=u,u}pointCoordinate(t){const n=new Uint8Array(4),s=this.painter.context,u=s.gl;s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),u.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,u.RGBA,u.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]],v=_&&this.sourceCache.getTileByID(_);if(!v)return null;const w=this._coordsTextureSize,I=(1<<v.tileID.canonical.z)*w;return new o.U(this._allowMercatorOverflow(t,(v.tileID.canonical.x*w+p)/I),(v.tileID.canonical.y*w+g)/I,this.getElevation(v.tileID,p,g,w))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,n=new o.bd,s=new o.b0,u=this.meshSize,p=o.N/u,g=u*u;for(let A=0;A<=u;A++)for(let D=0;D<=u;D++)n.emplaceBack(D*p,A*p,0);for(let A=0;A<g;A+=u+1)for(let D=0;D<u;D++)s.emplaceBack(D+A,u+D+A+1,u+D+A+2),s.emplaceBack(D+A,u+D+A+2,D+A+1);const _=n.length,v=_+2*(u+1);for(const A of[0,1])for(let D=0;D<=u;D++)for(const $ of[0,1])n.emplaceBack(D*p,A*o.N,$);for(let A=0;A<2*u;A+=2)s.emplaceBack(v+A,v+A+1,v+A+3),s.emplaceBack(v+A,v+A+3,v+A+2),s.emplaceBack(_+A,_+A+3,_+A+1),s.emplaceBack(_+A,_+A+2,_+A+3);const w=n.length,I=w+2*(u+1);for(const A of[0,1])for(let D=0;D<=u;D++)for(const $ of[0,1])n.emplaceBack(A*o.N,D*p,$);for(let A=0;A<2*u;A+=2)s.emplaceBack(w+A,w+A+1,w+A+3),s.emplaceBack(w+A,w+A+3,w+A+2),s.emplaceBack(I+A,I+A+3,I+A+1),s.emplaceBack(I+A,I+A+2,I+A+3);return this._mesh={indexBuffer:t.createIndexBuffer(s),vertexBuffer:t.createVertexBuffer(n,Ll.members),segments:o.S.simpleSegment(0,0,n.length,s.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*o.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,n){var s;const{tileID:u}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(s=this.getMinMaxElevation(u).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=o.U.fromLngLat(t.wrap()),u=(1<<n)*o.N,p=s.x*u,g=s.y*u,_=Math.floor(p/o.N),v=Math.floor(g/o.N);return{tileID:new o.O(n,0,n,_,v),mercatorX:p,mercatorY:g}}_allowMercatorOverflow(t,n){const s=t.x<this.painter.width/2;let u=o.bf(n);const p=this.painter.transform.center.lng;return s&&Math.sign(u)>0&&Math.sign(p)<0||!s&&Math.sign(u)<0&&Math.sign(p)>0?(u=360*Math.sign(p)+u,o.G(u)):n}}class Uc{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 Mt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return s.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_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 Ai={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ys{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new Uc(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 u=t.sourceCaches[s].getVisibleCoordinates();for(const p of u){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 u=t._layers[s],p=u.source;if(Ai[u.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 u in this._coordsDescendingInvStr){const p=this._coordsDescendingInvStr[u][s.tileID.key];p&&p!==s.rttCoords[u]&&(s.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,s=this.painter,u=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Ai[n]&&(this._prevType&&Ai[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!u))return!0;if(Ai[this._prevType]||Ai[n]&&u){this._prevType=n;const p=this._stacks.length-1,g=this._stacks[p]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(Zt(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[p]){const w=this.pool.getObjectForId(_.rtt[p].id);if(w.stamp===_.rtt[p].stamp){this.pool.useObject(w);continue}}const v=this.pool.getOrCreateFreeObject();this.pool.useObject(v),this.pool.stampObject(v),_.rtt[p]={id:v.id,stamp:v.stamp},s.context.bindFramebuffer.set(v.fbo.framebuffer),s.context.clear({color:o.aT.transparent,stencil:0}),s.currentStencilSource=void 0;for(let w=0;w<g.length;w++){const I=s.style._layers[g[w]],A=I.source?this._coordsDescendingInv[I.source][_.tileID.key]:[_.tileID];s.context.viewport.set([0,0,v.fbo.width,v.fbo.height]),s._renderTileClippingMasks(I,A),s.renderLayer(s,s.style.sourceCaches[I.source],I,A),I.source&&(_.rttCoords[I.source]=this._coordsDescendingInvStr[I.source][_.tileID.key])}}return Zt(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Ai[n]}return!1}}const Ge=te,Ye={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:o.c.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},Ea=h=>{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},_o={showCompass:!0,showZoom:!0,visualizePitch:!1};class yo{constructor(t,n,s=!1){this.mousedown=g=>{this.startMouse(o.e({},g,{ctrlKey:!0,preventDefault:()=>g.preventDefault()}),H.mousePos(this.element,g)),H.addEventListener(window,"mousemove",this.mousemove),H.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=g=>{this.moveMouse(g,H.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=H.touchPos(this.element,g.targetTouches)[0],this.startTouch(g,this._startPos),H.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.addEventListener(window,"touchend",this.touchend))},this.touchmove=g=>{g.targetTouches.length!==1?this.reset():(this._lastPos=H.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 u=t.dragRotate._mouseRotate.getClickTolerance(),p=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=ta({clickTolerance:u,enable:!0}),this.touchRotate=(({enable:g,clickTolerance:_,bearingDegreesPerPixelMoved:v=.8})=>{const w=new kl;return new $r({clickTolerance:_,move:(I,A)=>({bearingDelta:(A.x-I.x)*v}),moveStateManager:w,enable:g,assignEvents:Ea})})({clickTolerance:u,enable:!0}),this.map=t,s&&(this.mousePitch=jr({clickTolerance:p,enable:!0}),this.touchPitch=(({enable:g,clickTolerance:_,pitchDegreesPerPixelMoved:v=-.5})=>{const w=new kl;return new $r({clickTolerance:_,move:(I,A)=>({pitchDelta:(A.y-I.y)*v}),moveStateManager:w,enable:g,assignEvents:Ea})})({clickTolerance:p,enable:!0})),H.addEventListener(n,"mousedown",this.mousedown),H.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),H.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),H.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),H.disableDrag()}moveMouse(t,n){const s=this.map,{bearingDelta:u}=this.mouseRotate.dragMove(t,n)||{};if(u&&s.setBearing(s.getBearing()+u),this.mousePitch){const{pitchDelta:p}=this.mousePitch.dragMove(t,n)||{};p&&s.setPitch(s.getPitch()+p)}}moveTouch(t,n){const s=this.map,{bearingDelta:u}=this.touchRotate.dragMove(t,n)||{};if(u&&s.setBearing(s.getBearing()+u),this.touchPitch){const{pitchDelta:p}=this.touchPitch.dragMove(t,n)||{};p&&s.setPitch(s.getPitch()+p)}}off(){const t=this.element;H.removeEventListener(t,"mousedown",this.mousedown),H.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),H.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.removeEventListener(window,"touchend",this.touchend),H.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){H.enableDrag(),H.removeEventListener(window,"mousemove",this.mousemove),H.removeEventListener(window,"mouseup",this.mouseup),H.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),H.removeEventListener(window,"touchend",this.touchend)}}let Kt;function xo(h,t,n){if(h=new o.L(h.lng,h.lat),t){const s=new o.L(h.lng-360,h.lat),u=new o.L(h.lng+360,h.lat),p=n.locationPoint(h).distSqr(t);n.locationPoint(s).distSqr(t)<p?h=s:n.locationPoint(u).distSqr(t)<p&&(h=u)}for(;Math.abs(h.lng-n.center.lng)>180;){const s=n.locationPoint(h);if(s.x>=0&&s.y>=0&&s.x<=n.width&&s.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h}const dr={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 Bl(h,t,n){const s=h.classList;for(const u in dr)s.remove(`maplibregl-${n}-anchor-${u}`);s.add(`maplibregl-${n}-anchor-${t}`)}class Cn extends o.E{constructor(t){if(super(),this._onKeyPress=n=>{const s=n.code,u=n.charCode||n.keyCode;s!=="Space"&&s!=="Enter"&&u!==32&&u!==13||this.togglePopup()},this._onMapClick=n=>{const s=n.originalEvent.target,u=this._element;this._popup&&(s===u||u.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=xo(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let u="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?u=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let 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()),H.setTransform(this._element,`${dr[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${u}`),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 o.k("dragstart"))),this.fire(new o.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 o.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=o.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=H.create("div"),this._element.setAttribute("aria-label","Map marker");const n=H.createNS("http://www.w3.org/2000/svg","svg"),s=41,u=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${s}px`),n.setAttributeNS(null,"width",`${u}px`),n.setAttributeNS(null,"viewBox",`0 0 ${u} ${s}`);const p=H.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=H.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const _=H.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const v=[{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 v){const oe=H.createNS("http://www.w3.org/2000/svg","ellipse");oe.setAttributeNS(null,"opacity","0.04"),oe.setAttributeNS(null,"cx","10.5"),oe.setAttributeNS(null,"cy","5.80029008"),oe.setAttributeNS(null,"rx",ee.rx),oe.setAttributeNS(null,"ry",ee.ry),_.appendChild(oe)}const w=H.createNS("http://www.w3.org/2000/svg","g");w.setAttributeNS(null,"fill",this._color);const I=H.createNS("http://www.w3.org/2000/svg","path");I.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"),w.appendChild(I);const A=H.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"opacity","0.25"),A.setAttributeNS(null,"fill","#000000");const D=H.createNS("http://www.w3.org/2000/svg","path");D.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"),A.appendChild(D);const $=H.createNS("http://www.w3.org/2000/svg","g");$.setAttributeNS(null,"transform","translate(6.0, 7.0)"),$.setAttributeNS(null,"fill","#FFFFFF");const U=H.createNS("http://www.w3.org/2000/svg","g");U.setAttributeNS(null,"transform","translate(8.0, 8.0)");const q=H.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#000000"),q.setAttributeNS(null,"opacity","0.25"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962");const N=H.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#FFFFFF"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962"),U.appendChild(q),U.appendChild(N),g.appendChild(_),g.appendChild(w),g.appendChild(A),g.appendChild($),g.appendChild(U),n.appendChild(g),n.setAttributeNS(null,"height",s*this._scale+"px"),n.setAttributeNS(null,"width",u*this._scale+"px"),this._element.appendChild(n),this._offset=o.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()})),Bl(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),H.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=o.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 u=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":[u,-1*(38.1-13.5+u)],"bottom-right":[-u,-1*(38.1-13.5+u)],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=o.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 Gt={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ut=0,ra=!1;const Ma={maxWidth:100,unit:"metric"};function Pa(h,t,n){const s=n&&n.maxWidth||100,u=h._container.clientHeight/2,p=h.unproject([0,u]),g=h.unproject([s,u]),_=p.distanceTo(g);if(n&&n.unit==="imperial"){const v=3.2808*_;v>5280?kn(t,s,v/5280,h._getUIString("ScaleControl.Miles")):kn(t,s,v,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?kn(t,s,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?kn(t,s,_/1e3,h._getUIString("ScaleControl.Kilometers")):kn(t,s,_,h._getUIString("ScaleControl.Meters"))}function kn(h,t,n,s){const u=(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(v){const w=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*w)/w})(_),g*_})(n);h.style.width=t*(u/n)+"px",h.innerHTML=`${u}&nbsp;${s}`}const vo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},bo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function na(h){if(h){if(typeof h=="number"){const t=Math.round(Math.abs(h)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,h),"top-left":new o.P(t,t),"top-right":new o.P(-t,t),bottom:new o.P(0,-h),"bottom-left":new o.P(t,-t),"bottom-right":new o.P(-t,-t),left:new o.P(h,0),right:new o.P(-h,0)}}if(h instanceof o.P||Array.isArray(h)){const t=o.P.convert(h);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:o.P.convert(h.center||[0,0]),top:o.P.convert(h.top||[0,0]),"top-left":o.P.convert(h["top-left"]||[0,0]),"top-right":o.P.convert(h["top-right"]||[0,0]),bottom:o.P.convert(h.bottom||[0,0]),"bottom-left":o.P.convert(h["bottom-left"]||[0,0]),"bottom-right":o.P.convert(h["bottom-right"]||[0,0]),left:o.P.convert(h.left||[0,0]),right:o.P.convert(h.right||[0,0])}}return na(new o.P(0,0))}const wo={extend:(h,...t)=>o.e(h,...t),run(h){h()},logToElement(h,t=!1,n="log"){const s=window.document.getElementById(n);s&&(t&&(s.innerHTML=""),s.innerHTML+=`<br>${h}`)}},So=te;class vt{static get version(){return So}static get workerCount(){return Ir.workerCount}static set workerCount(t){Ir.workerCount=t}static get maxParallelImageRequests(){return o.c.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(t){o.c.MAX_PARALLEL_IMAGE_REQUESTS=t}static get workerUrl(){return o.c.WORKER_URL}static set workerUrl(t){o.c.WORKER_URL=t}static addProtocol(t,n){o.c.REGISTERED_PROTOCOLS[t]=n}static removeProtocol(t){delete o.c.REGISTERED_PROTOCOLS[t]}}return vt.Map=class extends Dl{constructor(h){if(o.bg.mark(o.bh.create),(h=o.e({},Ye,h)).minZoom!=null&&h.maxZoom!=null&&h.minZoom>h.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(h.minPitch!=null&&h.maxPitch!=null&&h.minPitch>h.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(h.minPitch!=null&&h.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(h.maxPitch!=null&&h.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ds(h.minZoom,h.maxZoom,h.minPitch,h.maxPitch,h.renderWorldCopies),{bearingSnap:h.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 o.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.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=h.interactive,this._cooperativeGestures=h.cooperativeGestures,this._metaKey=navigator.platform.indexOf("Mac")===0?"metaKey":"ctrlKey",this._maxTileCacheSize=h.maxTileCacheSize,this._maxTileCacheZoomLevels=h.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=h.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=h.preserveDrawingBuffer,this._antialias=h.antialias,this._trackResize=h.trackResize,this._bearingSnap=h.bearingSnap,this._refreshExpiredTiles=h.refreshExpiredTiles,this._fadeDuration=h.fadeDuration,this._crossSourceCollisions=h.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=h.collectResourceTiming,this._renderTaskQueue=new _s,this._controls=[],this._mapId=o.a2(),this._locale=o.e({},go,h.locale),this._clickTolerance=h.clickTolerance,this._overridePixelRatio=h.pixelRatio,this._maxCanvasSize=h.maxCanvasSize,this.transformCameraUpdate=h.transformCameraUpdate,this._imageQueueHandle=Be.addThrottleControl((()=>this.isMoving())),this._requestManager=new He(h.transformRequest),typeof h.container=="string"){if(this._container=document.getElementById(h.container),!this._container)throw new Error(`Container '${h.container}' not found.`)}else{if(!(h.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=h.container}if(h.maxBounds&&this.setMaxBounds(h.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=An((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 mo(this,h),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=h.hash&&new Ta(typeof h.hash=="string"&&h.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:h.center,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch}),h.bounds&&(this.resize(),this.fitBounds(h.bounds,o.e({},h.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=h.localIdeographFontFamily,this._validateStyle=h.validateStyle,h.style&&this.setStyle(h.style,{localIdeographFontFamily:h.localIdeographFontFamily}),h.attributionControl&&this.addControl(new Yi({customAttribution:h.customAttribution})),h.maplibreLogo&&this.addControl(new zt,h.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 o.k(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new o.k(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new o.k("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(h,t){if(t===void 0&&(t=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const s=this._controlPositions[t];return t.indexOf("bottom")!==-1?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(h);return t>-1&&this._controls.splice(t,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,t,n,s){return s==null&&this.terrain&&(s=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,t,n,s)}resize(h){var t;const n=this._containerDimensions(),s=n[0],u=n[1],p=this._getClampedPixelRatio(s,u);if(this._resizeCanvas(s,u,p),this.painter.resize(s,u,p),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const v=this._getClampedPixelRatio(s,u);this._resizeCanvas(s,u,v),this.painter.resize(s,u,v)}this.transform.resize(s,u),(t=this._requestedCameraState)===null||t===void 0||t.resize(s,u);const g=!this._moving;return g&&(this.stop(),this.fire(new o.k("movestart",h)).fire(new o.k("move",h))),this.fire(new o.k("resize",h)),g&&this.fire(new o.k("moveend",h)),this}_getClampedPixelRatio(h,t){const{0:n,1:s}=this._maxCanvasSize,u=this.getPixelRatio(),p=h*u,g=t*u;return Math.min(p>n?n/p:1,g>s?s/g:1)*u}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(Pt.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(h){return this._cooperativeGestures=h,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(h){return this.transform.locationPoint(o.L.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(o.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,t,n){if(h==="mouseenter"||h==="mouseover"){let 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 Ki(h,this,p.originalEvent,{features:g}))):s=!1},mouseout:()=>{s=!1}}}}if(h==="mouseleave"||h==="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 Ki(h,this,g.originalEvent)))},mouseout:g=>{s&&(s=!1,n.call(this,new Ki(h,this,g.originalEvent)))}}}}{const s=u=>{const p=this.getLayer(t)?this.queryRenderedFeatures(u.point,{layers:[t]}):[];p.length&&(u.features=p,n.call(this,u),delete u.features)};return{layer:t,listener:n,delegates:{[h]:s}}}}on(h,t,n){if(n===void 0)return super.on(h,t);const s=this._createDelegatedListener(h,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(s);for(const u in s.delegates)this.on(u,s.delegates[u]);return this}once(h,t,n){if(n===void 0)return super.once(h,t);const s=this._createDelegatedListener(h,t,n);for(const u in s.delegates)this.once(u,s.delegates[u]);return this}off(h,t,n){return n===void 0?super.off(h,t):(this._delegatedListeners&&this._delegatedListeners[h]&&(s=>{const u=this._delegatedListeners[h];for(let p=0;p<u.length;p++){const g=u[p];if(g.layer===t&&g.listener===n){for(const _ in g.delegates)this.off(_,g.delegates[_]);return u.splice(p,1),this}}})(),this)}queryRenderedFeatures(h,t){if(!this.style)return[];let n;const s=h instanceof o.P||Array.isArray(h),u=s?h:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(s?{}:h)||{},u instanceof o.P||typeof u[0]=="number")n=[o.P.convert(u)];else{const p=o.P.convert(u[0]),g=o.P.convert(u[1]);n=[p,new o.P(g.x,p.y),g,new o.P(p.x,g.y),p]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(h,t){return this.style.querySourceFeatures(h,t)}setStyle(h,t){return(t=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(h,t))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const t=this._locale[h];if(t==null)throw new Error(`Missing UI string '${h}'`);return t}_updateStyle(h,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(h,t)));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new fi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,t,n):this.style.loadJSON(h,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new fi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,t){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,Ze.Style);o.f(n,((s,u)=>{s?this.fire(new o.j(s)):u&&this._updateDiff(u,t)}))}else typeof h=="object"&&this._updateDiff(h,t)}_updateDiff(h,t){try{this.style.setState(h,t)&&this._update(!0)}catch(n){o.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(h,t){return this._lazyInitEmptyStyle(),this.style.addSource(h,t),this._update(!0)}isSourceLoaded(h){const t=this.style&&this.style.sourceCaches[h];if(t!==void 0)return t.loaded();this.fire(new o.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const t=this.style.sourceCaches[h.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);for(const n in this.style._layers){const s=this.style._layers[n];s.type==="hillshade"&&s.source===h.source&&o.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 Fl(this.painter,t,h),this.painter.renderToTexture=new ys(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!==h.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 o.k("terrain",{terrain:h})),this}getTerrain(){var h,t;return(t=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const t in h){const n=h[t]._tiles;for(const s in n){const u=n[s];if(u.state!=="loaded"&&u.state!=="errored")return!1}}return!0}addSourceType(h,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(h,t,n)}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,t,n={}){const{pixelRatio:s=1,sdf:u=!1,stretchX:p,stretchY:g,content:_}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||o.a(t))){if(t.width===void 0||t.height===void 0)return this.fire(new o.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:v,height:w,data:I}=t,A=t;return this.style.addImage(h,{data:new o.R({width:v,height:w},new Uint8Array(I)),pixelRatio:s,stretchX:p,stretchY:g,content:_,sdf:u,version:0,userImage:A}),A.onAdd&&A.onAdd(this,h),this}}{const{width:v,height:w,data:I}=o.h.getImageData(t);this.style.addImage(h,{data:new o.R({width:v,height:w},I),pixelRatio:s,stretchX:p,stretchY:g,content:_,sdf:u,version:0})}}updateImage(h,t){const n=this.style.getImage(h);if(!n)return this.fire(new o.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||o.a(t)?o.h.getImageData(t):t,{width:u,height:p,data:g}=s;if(u===void 0||p===void 0)return this.fire(new o.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(u!==n.data.width||p!==n.data.height)return this.fire(new o.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||o.a(t));return n.data.replace(g,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h,t){Be.getImage(this._requestManager.transformRequest(h,Ze.Image),t)}listImages(){return this.style.listImages()}addLayer(h,t){return this._lazyInitEmptyStyle(),this.style.addLayer(h,t),this._update(!0)}moveLayer(h,t){return this.style.moveLayer(h,t),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,t,n){return this.style.setLayerZoomRange(h,t,n),this._update(!0)}setFilter(h,t,n={}){return this.style.setFilter(h,t,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,t,n,s={}){return this.style.setPaintProperty(h,t,n,s),this._update(!0)}getPaintProperty(h,t){return this.style.getPaintProperty(h,t)}setLayoutProperty(h,t,n,s={}){return this.style.setLayoutProperty(h,t,n,s),this._update(!0)}getLayoutProperty(h,t){return this.style.getLayoutProperty(h,t)}setGlyphs(h,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,t,n,(s=>{s||this._update(!0)})),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,t,(n=>{n||this._update(!0)})),this}setLight(h,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(h,t){return this.style.setFeatureState(h,t),this._update()}removeFeatureState(h,t){return this.style.removeFeatureState(h,t),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,t=0;return this._container&&(h=this._container.clientWidth||400,t=this._container.clientHeight||300),[h,t]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const t=this._canvasContainer=H.create("div","maplibregl-canvas-container",h);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=H.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 u=this._controlContainer=H.create("div","maplibregl-control-container",h),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((g=>{p[g]=H.create("div",`maplibregl-ctrl-${g} `,u)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){this._cooperativeGesturesScreen=H.create("div","maplibregl-cooperative-gesture-screen",this._container);let h=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(h=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=`
<div class="maplibregl-desktop-message">${h}</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(){H.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures")}_resizeCanvas(h,t,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",(s=>{t={requestedAttributes:h},s&&(t.statusMessage=s.statusMessage,t.type=s.type)}),{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const s="Failed to initialize WebGL";throw t?(t.message=s,new Error(JSON.stringify(t))):new Error(s)}this.painter=new In(n,this.transform),ve.testSupport(n)}_onCooperativeGesture(h,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(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const u=this.transform.zoom,p=o.h.now();this.style.zoomHistory.update(u,p);const g=new o.a8(u,{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 o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bg.mark(o.bh.load),this.fire(new o.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 o.k("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,o.bg.mark(o.bh.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._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),Be.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.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),H.remove(this._canvasContainer),H.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),o.bg.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=o.h.frame((h=>{o.bg.frame(h),this._frame=null,this._render(h)})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ge}getCameraTargetElevation(){return this.transform.elevation}},vt.NavigationControl=class{constructor(h){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=o.e({},_o,h),this._container=H.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}))),H.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}))),H.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=H.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new yo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){H.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,t){const n=H.create("button",h,this._container);return n.type="button",n.addEventListener("click",t),n}},vt.GeolocateControl=class extends o.E{constructor(h){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new o.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 o.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new o.L(t.coords.longitude,t.coords.latitude),s=t.coords.accuracy,u=this._map.getBearing(),p=o.e({bearing:u},this.options.fitBoundsOptions),g=Pt.fromLngLat(n,s);this._map.fitBounds(g,p,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new o.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&&ra)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.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=H.create("button","maplibregl-ctrl-geolocate",this._container),H.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){o.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=H.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Cn({element:this._dotElement}),this._circleElement=H.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Cn({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 o.k("trackuserlocationend")))}))}},this.options=o.e({},Gt,h)}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),(function(t,n=!1){Kt===void 0||n?window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then((s=>{Kt=s.state!=="denied",t(Kt)})).catch((()=>{Kt=!!window.navigator.geolocation,t(Kt)})):(Kt=!!window.navigator.geolocation,t(Kt)):t(Kt)})(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(),H.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ut=0,ra=!1}_isOutOfMapMaxBounds(h){const t=this._map.getMaxBounds(),n=h.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),t=h.getSouthEast(),n=h.getNorthEast(),s=t.distanceTo(n),u=Math.ceil(this._accuracy/(s/this._map._container.clientHeight)*2);this._circleElement.style.width=`${u}px`,this._circleElement.style.height=`${u}px`}trigger(){if(!this._setup)return o.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 o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ut--,ra=!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 o.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 o.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 h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ut++,Ut>1?(h={maximumAge:6e5,timeout:0},ra=!0):(h=this.options.positionOptions,ra=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},vt.AttributionControl=Yi,vt.LogoControl=zt,vt.ScaleControl=class{constructor(h){this._onMove=()=>{Pa(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Pa(this._map,this._container,this.options)},this.options=o.e({},Ma,h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){H.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},vt.FullscreenControl=class extends o.E{constructor(h={}){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,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:o.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){H.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=H.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);H.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new o.k("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new o.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(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))},this.options=h}onAdd(h){return this._map=h,this._container=H.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=H.create("button","maplibregl-ctrl-terrain",this._container),H.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(){H.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},vt.Popup=class extends o.E{constructor(h){super(),this.remove=()=>(this._content&&H.remove(this._content),this._container&&(H.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 o.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=H.create("div","maplibregl-popup",this._map.getContainer()),this._tip=H.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=xo(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 u=na(this.options.offset);if(!s){const g=this._container.offsetWidth,_=this._container.offsetHeight;let v;v=n.y+u.bottom.y<_?["top"]:n.y>this._map.transform.height-_?["bottom"]:[],n.x<g/2?v.push("left"):n.x>this._map.transform.width-g/2&&v.push("right"),s=v.length===0?"bottom":v.join("-")}const p=n.add(u[s]).round();H.setTransform(this._container,`${dr[s]} translate(${p.x}px,${p.y}px)`),Bl(this._container,s,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(vo),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=o.L.convert(h),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(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const t=document.createDocumentFragment(),n=document.createElement("body");let s;for(n.innerHTML=h;s=n.firstChild,s;)t.appendChild(s);return this.setDOMContent(t)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=H.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){this._container&&this._container.classList.add(h)}removeClassName(h){this._container&&this._container.classList.remove(h)}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}_createCloseButton(){this.options.closeButton&&(this._closeButton=H.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 h=this._container.querySelector(bo);h&&h.focus()}},vt.Marker=Cn,vt.Style=fi,vt.LngLat=o.L,vt.LngLatBounds=Pt,vt.Point=o.P,vt.MercatorCoordinate=o.U,vt.Evented=o.E,vt.AJAXError=o.bi,vt.config=o.c,vt.CanvasSource=Qr,vt.GeoJSONSource=Jr,vt.ImageSource=sr,vt.RasterDEMTileSource=$n,vt.RasterTileSource=Un,vt.VectorTileSource=gn,vt.VideoSource=fa,vt.setRTLTextPlugin=o.bj,vt.getRTLTextPluginStatus=o.bk,vt.prewarm=function(){qa().acquire(_t)},vt.clearPrewarmedResources=function(){const h=Br;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(_t),Br=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()"))},wo.extend(vt,{isSafari:o.ac,getPerformanceMetrics:o.bg.getPerformanceMetrics}),vt}));var B=P;return B}))})(jo)),jo.exports}var Od=Bd();const Du=Rd(Od);function Nd(c,x){if(c.match(/^[a-z]+:\/\//i))return c;if(c.match(/^\/\//))return window.location.protocol+c;if(c.match(/^[a-z]+:/i))return c;const T=document.implementation.createHTMLDocument(),k=T.createElement("base"),P=T.createElement("a");return T.head.appendChild(k),T.body.appendChild(P),x&&(k.href=x),P.href=c,P.href}const Vd=(()=>{let c=0;const x=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(c+=1,`u${x()}${c}`)})();function Bn(c){const x=[];for(let T=0,k=c.length;T<k;T++)x.push(c[T]);return x}let Ba=null;function Lu(c={}){return Ba||(c.includeStyleProperties?(Ba=c.includeStyleProperties,Ba):(Ba=Bn(window.getComputedStyle(document.documentElement)),Ba))}function qo(c,x){const k=(c.ownerDocument.defaultView||window).getComputedStyle(c).getPropertyValue(x);return k?parseFloat(k.replace("px","")):0}function Ud(c){const x=qo(c,"border-left-width"),T=qo(c,"border-right-width");return c.clientWidth+x+T}function $d(c){const x=qo(c,"border-top-width"),T=qo(c,"border-bottom-width");return c.clientHeight+x+T}function Ru(c,x={}){const T=x.width||Ud(c),k=x.height||$d(c);return{width:T,height:k}}function jd(){let c,x;try{x=process}catch{}const T=x&&x.env?x.env.devicePixelRatio:null;return T&&(c=parseInt(T,10),Number.isNaN(c)&&(c=1)),c||window.devicePixelRatio||1}const gr=16384;function qd(c){(c.width>gr||c.height>gr)&&(c.width>gr&&c.height>gr?c.width>c.height?(c.height*=gr/c.width,c.width=gr):(c.width*=gr/c.height,c.height=gr):c.width>gr?(c.height*=gr/c.width,c.width=gr):(c.width*=gr/c.height,c.height=gr))}function Zo(c){return new Promise((x,T)=>{const k=new Image;k.onload=()=>{k.decode().then(()=>{requestAnimationFrame(()=>x(k))})},k.onerror=T,k.crossOrigin="anonymous",k.decoding="async",k.src=c})}async function Zd(c){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(c)).then(encodeURIComponent).then(x=>`data:image/svg+xml;charset=utf-8,${x}`)}async function Gd(c,x,T){const k="http://www.w3.org/2000/svg",P=document.createElementNS(k,"svg"),O=document.createElementNS(k,"foreignObject");return P.setAttribute("width",`${x}`),P.setAttribute("height",`${T}`),P.setAttribute("viewBox",`0 0 ${x} ${T}`),O.setAttribute("width","100%"),O.setAttribute("height","100%"),O.setAttribute("x","0"),O.setAttribute("y","0"),O.setAttribute("externalResourcesRequired","true"),P.appendChild(O),O.appendChild(c),Zd(P)}const rr=(c,x)=>{if(c instanceof x)return!0;const T=Object.getPrototypeOf(c);return T===null?!1:T.constructor.name===x.name||rr(T,x)};function Hd(c){const x=c.getPropertyValue("content");return`${c.cssText} content: '${x.replace(/'|"/g,"")}';`}function Wd(c,x){return Lu(x).map(T=>{const k=c.getPropertyValue(T),P=c.getPropertyPriority(T);return`${T}: ${k}${P?" !important":""};`}).join(" ")}function Xd(c,x,T,k){const P=`.${c}:${x}`,O=T.cssText?Hd(T):Wd(T,k);return document.createTextNode(`${P}{${O}}`)}function Fu(c,x,T,k){const P=window.getComputedStyle(c,T),O=P.getPropertyValue("content");if(O===""||O==="none")return;const B=Vd();try{x.className=`${x.className} ${B}`}catch{return}const o=document.createElement("style");o.appendChild(Xd(B,T,P,k)),x.appendChild(o)}function Kd(c,x,T){Fu(c,x,":before",T),Fu(c,x,":after",T)}const Bu="application/font-woff",Ou="image/jpeg",Yd={woff:Bu,woff2:Bu,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Ou,jpeg:Ou,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Jd(c){const x=/\.([^./]*?)$/g.exec(c);return x?x[1]:""}function oc(c){const x=Jd(c).toLowerCase();return Yd[x]||""}function Qd(c){return c.split(/,/)[1]}function lc(c){return c.search(/^(data:)/)!==-1}function ef(c,x){return`data:${x};base64,${c}`}async function Nu(c,x,T){const k=await fetch(c,x);if(k.status===404)throw new Error(`Resource "${k.url}" not found`);const P=await k.blob();return new Promise((O,B)=>{const o=new FileReader;o.onerror=B,o.onloadend=()=>{try{O(T({res:k,result:o.result}))}catch(te){B(te)}},o.readAsDataURL(P)})}const cc={};function tf(c,x,T){let k=c.replace(/\?.*/,"");return T&&(k=c),/ttf|otf|eot|woff2?/i.test(k)&&(k=k.replace(/.*\//,"")),x?`[${x}]${k}`:k}async function uc(c,x,T){const k=tf(c,x,T.includeQueryParams);if(cc[k]!=null)return cc[k];T.cacheBust&&(c+=(/\?/.test(c)?"&":"?")+new Date().getTime());let P;try{const O=await Nu(c,T.fetchRequestInit,({res:B,result:o})=>(x||(x=B.headers.get("Content-Type")||""),Qd(o)));P=ef(O,x)}catch(O){P=T.imagePlaceholder||"";let B=`Failed to fetch resource: ${c}`;O&&(B=typeof O=="string"?O:O.message),B&&console.warn(B)}return cc[k]=P,P}async function rf(c){const x=c.toDataURL();return x==="data:,"?c.cloneNode(!1):Zo(x)}async function nf(c,x){if(c.currentSrc){const O=document.createElement("canvas"),B=O.getContext("2d");O.width=c.clientWidth,O.height=c.clientHeight,B==null||B.drawImage(c,0,0,O.width,O.height);const o=O.toDataURL();return Zo(o)}const T=c.poster,k=oc(T),P=await uc(T,k,x);return Zo(P)}async function af(c,x){var T;try{if(!((T=c==null?void 0:c.contentDocument)===null||T===void 0)&&T.body)return await Go(c.contentDocument.body,x,!0)}catch{}return c.cloneNode(!1)}async function sf(c,x){return rr(c,HTMLCanvasElement)?rf(c):rr(c,HTMLVideoElement)?nf(c,x):rr(c,HTMLIFrameElement)?af(c,x):c.cloneNode(Vu(c))}const of=c=>c.tagName!=null&&c.tagName.toUpperCase()==="SLOT",Vu=c=>c.tagName!=null&&c.tagName.toUpperCase()==="SVG";async function lf(c,x,T){var k,P;if(Vu(x))return x;let O=[];return of(c)&&c.assignedNodes?O=Bn(c.assignedNodes()):rr(c,HTMLIFrameElement)&&(!((k=c.contentDocument)===null||k===void 0)&&k.body)?O=Bn(c.contentDocument.body.childNodes):O=Bn(((P=c.shadowRoot)!==null&&P!==void 0?P:c).childNodes),O.length===0||rr(c,HTMLVideoElement)||await O.reduce((B,o)=>B.then(()=>Go(o,T)).then(te=>{te&&x.appendChild(te)}),Promise.resolve()),x}function cf(c,x,T){const k=x.style;if(!k)return;const P=window.getComputedStyle(c);P.cssText?(k.cssText=P.cssText,k.transformOrigin=P.transformOrigin):Lu(T).forEach(O=>{let B=P.getPropertyValue(O);O==="font-size"&&B.endsWith("px")&&(B=`${Math.floor(parseFloat(B.substring(0,B.length-2)))-.1}px`),rr(c,HTMLIFrameElement)&&O==="display"&&B==="inline"&&(B="block"),O==="d"&&x.getAttribute("d")&&(B=`path(${x.getAttribute("d")})`),k.setProperty(O,B,P.getPropertyPriority(O))})}function uf(c,x){rr(c,HTMLTextAreaElement)&&(x.innerHTML=c.value),rr(c,HTMLInputElement)&&x.setAttribute("value",c.value)}function hf(c,x){if(rr(c,HTMLSelectElement)){const k=Array.from(x.children).find(P=>c.value===P.getAttribute("value"));k&&k.setAttribute("selected","")}}function pf(c,x,T){return rr(x,Element)&&(cf(c,x,T),Kd(c,x,T),uf(c,x),hf(c,x)),x}async function df(c,x){const T=c.querySelectorAll?c.querySelectorAll("use"):[];if(T.length===0)return c;const k={};for(let O=0;O<T.length;O++){const o=T[O].getAttribute("xlink:href");if(o){const te=c.querySelector(o),H=document.querySelector(o);!te&&H&&!k[o]&&(k[o]=await Go(H,x,!0))}}const P=Object.values(k);if(P.length){const O="http://www.w3.org/1999/xhtml",B=document.createElementNS(O,"svg");B.setAttribute("xmlns",O),B.style.position="absolute",B.style.width="0",B.style.height="0",B.style.overflow="hidden",B.style.display="none";const o=document.createElementNS(O,"defs");B.appendChild(o);for(let te=0;te<P.length;te++)o.appendChild(P[te]);c.appendChild(B)}return c}async function Go(c,x,T){return!T&&x.filter&&!x.filter(c)?null:Promise.resolve(c).then(k=>sf(k,x)).then(k=>lf(c,k,x)).then(k=>pf(c,k,x)).then(k=>df(k,x))}const Uu=/url\((['"]?)([^'"]+?)\1\)/g,ff=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,mf=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function gf(c){const x=c.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${x})(['"]?\\))`,"g")}function _f(c){const x=[];return c.replace(Uu,(T,k,P)=>(x.push(P),T)),x.filter(T=>!lc(T))}async function yf(c,x,T,k,P){try{const O=T?Nd(x,T):x,B=oc(x);let o;return P||(o=await uc(O,B,k)),c.replace(gf(x),`$1${o}$3`)}catch{}return c}function xf(c,{preferredFontFormat:x}){return x?c.replace(mf,T=>{for(;;){const[k,,P]=ff.exec(T)||[];if(!P)return"";if(P===x)return`src: ${k};`}}):c}function $u(c){return c.search(Uu)!==-1}async function ju(c,x,T){if(!$u(c))return c;const k=xf(c,T);return _f(k).reduce((O,B)=>O.then(o=>yf(o,B,x,T)),Promise.resolve(k))}async function Oa(c,x,T){var k;const P=(k=x.style)===null||k===void 0?void 0:k.getPropertyValue(c);if(P){const O=await ju(P,null,T);return x.style.setProperty(c,O,x.style.getPropertyPriority(c)),!0}return!1}async function vf(c,x){await Oa("background",c,x)||await Oa("background-image",c,x),await Oa("mask",c,x)||await Oa("-webkit-mask",c,x)||await Oa("mask-image",c,x)||await Oa("-webkit-mask-image",c,x)}async function bf(c,x){const T=rr(c,HTMLImageElement);if(!(T&&!lc(c.src))&&!(rr(c,SVGImageElement)&&!lc(c.href.baseVal)))return;const k=T?c.src:c.href.baseVal,P=await uc(k,oc(k),x);await new Promise((O,B)=>{c.onload=O,c.onerror=x.onImageErrorHandler?(...te)=>{try{O(x.onImageErrorHandler(...te))}catch(H){B(H)}}:B;const o=c;o.decode&&(o.decode=O),o.loading==="lazy"&&(o.loading="eager"),T?(c.srcset="",c.src=P):c.href.baseVal=P})}async function wf(c,x){const k=Bn(c.childNodes).map(P=>qu(P,x));await Promise.all(k).then(()=>c)}async function qu(c,x){rr(c,Element)&&(await vf(c,x),await bf(c,x),await wf(c,x))}function Sf(c,x){const{style:T}=c;x.backgroundColor&&(T.backgroundColor=x.backgroundColor),x.width&&(T.width=`${x.width}px`),x.height&&(T.height=`${x.height}px`);const k=x.style;return k!=null&&Object.keys(k).forEach(P=>{T[P]=k[P]}),c}const Zu={};async function Gu(c){let x=Zu[c];if(x!=null)return x;const k=await(await fetch(c)).text();return x={url:c,cssText:k},Zu[c]=x,x}async function Hu(c,x){let T=c.cssText;const k=/url\(["']?([^"')]+)["']?\)/g,O=(T.match(/url\([^)]+\)/g)||[]).map(async B=>{let o=B.replace(k,"$1");return o.startsWith("https://")||(o=new URL(o,c.url).href),Nu(o,x.fetchRequestInit,({result:te})=>(T=T.replace(B,`url(${te})`),[B,te]))});return Promise.all(O).then(()=>T)}function Wu(c){if(c==null)return[];const x=[],T=/(\/\*[\s\S]*?\*\/)/gi;let k=c.replace(T,"");const P=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const te=P.exec(k);if(te===null)break;x.push(te[0])}k=k.replace(P,"");const O=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,B="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",o=new RegExp(B,"gi");for(;;){let te=O.exec(k);if(te===null){if(te=o.exec(k),te===null)break;O.lastIndex=o.lastIndex}else o.lastIndex=O.lastIndex;x.push(te[0])}return x}async function Tf(c,x){const T=[],k=[];return c.forEach(P=>{if("cssRules"in P)try{Bn(P.cssRules||[]).forEach((O,B)=>{if(O.type===CSSRule.IMPORT_RULE){let o=B+1;const te=O.href,H=Gu(te).then(ve=>Hu(ve,x)).then(ve=>Wu(ve).forEach(de=>{try{P.insertRule(de,de.startsWith("@import")?o+=1:P.cssRules.length)}catch(ge){console.error("Error inserting rule from remote css",{rule:de,error:ge})}})).catch(ve=>{console.error("Error loading remote css",ve.toString())});k.push(H)}})}catch(O){const B=c.find(o=>o.href==null)||document.styleSheets[0];P.href!=null&&k.push(Gu(P.href).then(o=>Hu(o,x)).then(o=>Wu(o).forEach(te=>{B.insertRule(te,B.cssRules.length)})).catch(o=>{console.error("Error loading remote stylesheet",o)})),console.error("Error inlining remote css file",O)}}),Promise.all(k).then(()=>(c.forEach(P=>{if("cssRules"in P)try{Bn(P.cssRules||[]).forEach(O=>{T.push(O)})}catch(O){console.error(`Error while reading CSS rules from ${P.href}`,O)}}),T))}function If(c){return c.filter(x=>x.type===CSSRule.FONT_FACE_RULE).filter(x=>$u(x.style.getPropertyValue("src")))}async function Af(c,x){if(c.ownerDocument==null)throw new Error("Provided element is not within a Document");const T=Bn(c.ownerDocument.styleSheets),k=await Tf(T,x);return If(k)}function Xu(c){return c.trim().replace(/["']/g,"")}function Cf(c){const x=new Set;function T(k){(k.style.fontFamily||getComputedStyle(k).fontFamily).split(",").forEach(O=>{x.add(Xu(O))}),Array.from(k.children).forEach(O=>{O instanceof HTMLElement&&T(O)})}return T(c),x}async function kf(c,x){const T=await Af(c,x),k=Cf(c);return(await Promise.all(T.filter(O=>k.has(Xu(O.style.fontFamily))).map(O=>{const B=O.parentStyleSheet?O.parentStyleSheet.href:null;return ju(O.cssText,B,x)}))).join(`
`)}async function Ef(c,x){const T=x.fontEmbedCSS!=null?x.fontEmbedCSS:x.skipFonts?null:await kf(c,x);if(T){const k=document.createElement("style"),P=document.createTextNode(T);k.appendChild(P),c.firstChild?c.insertBefore(k,c.firstChild):c.appendChild(k)}}async function Mf(c,x={}){const{width:T,height:k}=Ru(c,x),P=await Go(c,x,!0);return await Ef(P,x),await qu(P,x),Sf(P,x),await Gd(P,T,k)}async function Pf(c,x={}){const{width:T,height:k}=Ru(c,x),P=await Mf(c,x),O=await Zo(P),B=document.createElement("canvas"),o=B.getContext("2d"),te=x.pixelRatio||jd(),H=x.canvasWidth||T,ve=x.canvasHeight||k;return B.width=H*te,B.height=ve*te,x.skipAutoScale||qd(B),B.style.width=`${H}`,B.style.height=`${ve}`,x.backgroundColor&&(o.fillStyle=x.backgroundColor,o.fillRect(0,0,B.width,B.height)),o.drawImage(O,0,0,B.width,B.height),B}async function zf(c,x={}){return(await Pf(c,x)).toDataURL()}function Ho(c,x,T,k,P,O,B,o){var te=typeof c=="function"?c.options:c;return x&&(te.render=x,te.staticRenderFns=T,te._compiled=!0),O&&(te._scopeId="data-v-"+O),{exports:c,options:te}}const Df={props:{center:{type:Object,required:!0},zoom:{type:Number,required:!0},markers:{type:Array,default:()=>[]},selectedMarkerId:{type:String,default:null}},setup(c,{emit:x}){const T=Vue.ref(null),k=Vue.ref(null),P=Vue.ref(!0),O=Vue.ref(new Map),B=Vue.ref(!1);Vue.onMounted(async()=>{await Vue.nextTick(),o()}),Vue.onBeforeUnmount(()=>{k.value&&(k.value.remove(),k.value=null),O.value.clear()}),Vue.watch(()=>c.center,Te=>{if(k.value&&k.value.loaded()&&!B.value){const Be=k.value.getCenter();(Math.abs(Be.lat-Te.lat)>1e-5||Math.abs(Be.lng-Te.lon)>1e-5)&&k.value.setCenter([Te.lon,Te.lat])}},{deep:!0}),Vue.watch(()=>c.zoom,Te=>{if(k.value&&k.value.loaded()){const Be=k.value.getZoom();Math.abs(Be-Te)>.01&&k.value.setZoom(Te)}}),Vue.watch(()=>c.markers,()=>{te()},{deep:!0}),Vue.watch(()=>c.selectedMarkerId,Te=>{ve(Te)});function o(){if(!T.value){console.error("Map container not found");return}P.value=!0;try{k.value=new Du.Map({container:T.value,preserveDrawingBuffer:!0,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:[c.center.lon,c.center.lat],zoom:c.zoom}),k.value.on("load",()=>{P.value=!1,te()}),k.value.on("click",Te=>{if(!Te.originalEvent.target.closest(".custom-marker")){const He={lat:Te.lngLat.lat,lng:Te.lngLat.lng};x("map-click",He)}})}catch(Te){console.error("Error initializing map:",Te),P.value=!1}}function te(){!k.value||!k.value.loaded()||(O.value.forEach(({marker:Te})=>{Te&&Te.remove()}),O.value.clear(),c.markers&&Array.isArray(c.markers)&&c.markers.forEach((Te,Be)=>{H(Te,Be)}))}function H(Te,Be){if(!k.value||!Te||!Te.position)return;const Ze=document.createElement("div");if(Ze.className="custom-marker",Te.iconUrl){Ze.classList.add("custom-icon");const He=document.createElement("img");He.src=Te.iconUrl,He.className="marker-icon-image";const Et=Te.iconSize||40;He.style.width=`${Et}px`,He.style.height=`${Et}px`,c.selectedMarkerId===Te.id&&He.classList.add("selected"),Ze.appendChild(He)}else{const He=document.createElement("div");He.className="marker-inner",c.selectedMarkerId===Te.id&&He.classList.add("selected");const Et=document.createElement("div");Et.className="marker-number",Et.textContent=Be+1,He.appendChild(Et),Ze.appendChild(He)}try{const He=[Te.position.lon,Te.position.lat],Et=new Du.Marker({element:Ze,draggable:!0,anchor:"bottom"}).setLngLat(He).addTo(k.value);Et.on("dragstart",()=>{B.value=!0}),Et.on("dragend",()=>{const Di=Et.getLngLat();x("marker-moved",{markerId:Te.id,position:{lat:Di.lat,lng:Di.lng}}),setTimeout(()=>{B.value=!1},100)}),Ze.addEventListener("click",Di=>{Di.stopPropagation(),x("marker-click",Te.id)}),Ze.addEventListener("dblclick",Di=>{Di.stopPropagation(),x("marker-dblclick",Te.id)}),O.value.set(Te.id,{marker:Et,element:Ze})}catch(He){console.error("Error adding marker to map:",He)}}function ve(Te){O.value.forEach(({element:Be},Ze)=>{if(Be){const He=Be.querySelector(".marker-inner");He&&(Ze===Te?He.classList.add("selected"):He.classList.remove("selected"));const Et=Be.querySelector(".marker-icon-image");Et&&(Ze===Te?Et.classList.add("selected"):Et.classList.remove("selected"))}})}function de(){if(k.value&&k.value.loaded()){const Te=k.value.getCenter();return{lat:Te.lat,lon:Te.lng}}return{lat:c.center.lat,lon:c.center.lon}}function ge(){return k.value&&k.value.loaded()?k.value.getZoom():c.zoom}function Ue(Te,Be){k.value&&k.value.loaded()&&k.value.flyTo({center:[Be,Te],zoom:k.value.getZoom(),duration:1e3})}async function rt(){if(console.log("[MapPreview] captureMapImage called"),!k.value)throw new Error("Map is not initialized");if(!k.value.loaded())throw new Error("Map is not loaded");if(!T.value)throw new Error("Map container not found");console.log("[MapPreview] Map is loaded, capturing container...");try{const Te=await zf(T.value,{quality:.95,pixelRatio:2,cacheBust:!0,filter:Be=>!(Be.classList&&Be.classList.contains("maplibregl-ctrl"))});return console.log("[MapPreview] Container captured, image size:",Te==null?void 0:Te.length),Te}catch(Te){throw console.error("[MapPreview] Error capturing map image:",Te),Te}}return{mapContainer:T,loading:P,map:k,getCurrentCenter:de,getCurrentZoom:ge,centerOnPosition:Ue,captureMapImage:rt}}};var Lf=function(){var x=this,T=x._self._c;return T("div",{staticClass:"map-preview"},[T("div",{ref:"mapContainer",staticClass:"map-container"}),x.loading?T("div",{staticClass:"map-loading"},[T("div",{staticClass:"spinner"}),T("span",[x._v("Loading map...")])]):x._e()])},Rf=[],Ff=Ho(Df,Lf,Rf,!1,null,null);const Bf=Ff.exports,Ms={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"},Of={GEOCODING:500};async function Nf(c){if(!c||c.trim().length<Ms.MIN_QUERY_LENGTH)return[];try{const x=new URLSearchParams({q:c.trim(),format:"json",addressdetails:"1",limit:String(Ms.MAX_RESULTS),"accept-language":Ms.DEFAULT_LANGUAGE}),T=await fetch(`${Ms.BASE_URL}?${x.toString()}`,{headers:{"User-Agent":Ms.USER_AGENT}});if(!T.ok)throw new Error(`Nominatim API error: ${T.status}`);return(await T.json()).map(P=>({id:P.place_id,displayName:P.display_name,lat:parseFloat(P.lat),lon:parseFloat(P.lon),type:P.type,importance:P.importance,boundingBox:P.boundingbox}))}catch(x){throw console.error("Geocoding error:",x),x}}function Vf(c,x=500){let T;return function(...P){const O=()=>{clearTimeout(T),c(...P)};clearTimeout(T),T=setTimeout(O,x)}}const Uf={emits:["select-location","center-map"],setup(c,{emit:x}){const T=Vue.ref(null),k=Vue.ref(""),P=Vue.ref([]),O=Vue.ref(!1),B=Vue.ref(null),o=Vue.ref(!1),te=Vue.ref(-1),H=Vf(async Ze=>{if(!Ze||Ze.trim().length<3){P.value=[],o.value=!1,O.value=!1;return}O.value=!0,B.value=null;try{const He=await Nf(Ze);P.value=He,o.value=!0,te.value=-1}catch{B.value="Erreur lors de la recherche. Veuillez réessayer.",P.value=[]}finally{O.value=!1}},Of.GEOCODING);function ve(){H(k.value)}function de(Ze){x("select-location",{lat:Ze.lat,lon:Ze.lon,displayName:Ze.displayName}),k.value=Ze.displayName,o.value=!1}function ge(){P.value.length>0&&de(P.value[0])}function Ue(Ze){!o.value||P.value.length===0||(te.value+=Ze,te.value<0?te.value=P.value.length-1:te.value>=P.value.length&&(te.value=0))}function rt(){k.value="",P.value=[],o.value=!1,B.value=null,te.value=-1}function Te(){T.value&&T.value.focus()}function Be(Ze){Ze.target.closest(".geocode-search")||(o.value=!1)}return Vue.watch(o,Ze=>{Ze?setTimeout(()=>{document.addEventListener("click",Be)},100):document.removeEventListener("click",Be)}),{searchInput:T,searchQuery:k,results:P,isLoading:O,error:B,showResults:o,selectedIndex:te,handleInput:ve,selectResult:de,selectFirstResult:ge,navigateResults:Ue,clearSearch:rt,focus:Te}}};var $f=function(){var x=this,T=x._self._c;return T("div",{staticClass:"geocode-search"},[T("div",{staticClass:"search-input-wrapper"},[T("input",{directives:[{name:"model",rawName:"v-model",value:x.searchQuery,expression:"searchQuery"}],ref:"searchInput",staticClass:"search-input",attrs:{type:"text",placeholder:"Rechercher une adresse..."},domProps:{value:x.searchQuery},on:{input:[function(k){k.target.composing||(x.searchQuery=k.target.value)},x.handleInput],keydown:[function(k){return!k.type.indexOf("key")&&x._k(k.keyCode,"escape",void 0,k.key,void 0)?null:x.clearSearch.apply(null,arguments)},function(k){return!k.type.indexOf("key")&&x._k(k.keyCode,"enter",13,k.key,"Enter")?null:(k.preventDefault(),x.selectFirstResult.apply(null,arguments))},function(k){return!k.type.indexOf("key")&&x._k(k.keyCode,"down",40,k.key,["Down","ArrowDown"])?null:(k.preventDefault(),x.navigateResults(1))},function(k){return!k.type.indexOf("key")&&x._k(k.keyCode,"up",38,k.key,["Up","ArrowUp"])?null:(k.preventDefault(),x.navigateResults(-1))}]}}),x.searchQuery?T("button",{staticClass:"clear-button",attrs:{type:"button",title:"Effacer"},on:{click:x.clearSearch}},[T("k-icon",{attrs:{type:"cancel"}})],1):x._e(),x.isLoading?T("div",{staticClass:"search-spinner"},[T("div",{staticClass:"spinner-icon"})]):x._e()]),x.showResults?T("div",{staticClass:"results-dropdown"},[x.error?T("div",{staticClass:"error-message"},[T("k-icon",{attrs:{type:"alert"}}),T("span",[x._v(x._s(x.error))])],1):x.results.length===0&&!x.isLoading?T("div",{staticClass:"no-results"},[x._v(" Aucun résultat trouvé ")]):T("div",{staticClass:"results-list"},x._l(x.results,function(k,P){return T("div",{key:k.id,staticClass:"result-item",class:{active:P===x.selectedIndex},on:{click:function(O){return x.selectResult(k)},mouseenter:function(O){x.selectedIndex=P}}},[T("div",{staticClass:"result-icon"},[T("k-icon",{attrs:{type:"pin"}})],1),T("div",{staticClass:"result-content"},[T("div",{staticClass:"result-name"},[x._v(x._s(k.displayName))]),T("div",{staticClass:"result-coords"},[x._v(" "+x._s(k.lat.toFixed(6))+", "+x._s(k.lon.toFixed(6))+" ")])])])}),0),x.results.length>0?T("div",{staticClass:"results-footer"},[T("small",[x._v("Powered by OpenStreetMap Nominatim")])]):x._e()]):x._e()])},jf=[],qf=Ho(Uf,$f,jf,!1,null,null);const Zf={components:{GeocodeSearch:qf.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(c){return{canAddMarker:Vue.computed(()=>c.markers.length<c.maxMarkers)}}};var Gf=function(){var x=this,T=x._self._c;return T("aside",{staticClass:"k-map-markers-sidebar"},[T("header",{staticClass:"k-section-header"},[T("k-headline",[x._v(" Marqueurs "),T("k-counter",[x._v(x._s(x.markers.length)+"/"+x._s(x.maxMarkers))])],1),T("k-button",{attrs:{icon:"add",size:"xs",variant:"filled",title:"Ajouter un marqueur",disabled:!x.canAddMarker},on:{click:function(k){return x.$emit("add-marker")}}},[x._v(" Ajouter ")])],1),T("div",{staticClass:"k-map-markers-search"},[T("GeocodeSearch",{on:{"select-location":function(k){return x.$emit("select-location",k)}}})],1),T("div",{staticClass:"k-map-markers-list"},[x._l(x.markers,function(k,P){return T("div",{key:k.id,staticClass:"k-map-marker-item",class:{"is-selected":x.selectedMarkerId===k.id},on:{click:function(O){return x.$emit("select-marker",k.id)}}},[T("span",{staticClass:"k-map-marker-icon"},[x._v(" "+x._s(P+1)+" ")]),T("span",{staticClass:"k-map-marker-text"},[x._v(" "+x._s(k.title||`Marqueur ${P+1}`)+" ")]),T("span",{staticClass:"k-map-marker-options"},[T("k-button",{attrs:{icon:"open",size:"xs",title:"Modifier le marqueur"},on:{click:function(O){return O.stopPropagation(),x.$emit("edit-marker",k.id)}}}),T("k-button",{attrs:{icon:"trash",size:"xs",title:"Supprimer le marqueur"},on:{click:function(O){return O.stopPropagation(),x.$emit("delete-marker",k.id)}}})],1)])}),x.markers.length===0?T("div",{staticClass:"k-map-markers-empty"},[T("k-icon",{attrs:{type:"map-pin"}}),T("p",{staticClass:"k-map-markers-empty-text"},[x._v("Aucun marqueur")]),T("p",{staticClass:"k-map-markers-empty-info"},[x._v(' Cliquez sur la carte ou sur "Ajouter" pour créer un marqueur ')])],1):x._e()],2)])},Hf=[],Wf=Ho(Zf,Gf,Hf,!1,null,"6f63259e");const Xf=Wf.exports;function Kf(c){const x=Vue.ref([]),T=Vue.ref(!1),k=Vue.ref(null),P=()=>{if(window.panel&&window.panel.csrf)return window.panel.csrf;const H=document.querySelector('meta[name="csrf"]');return H&&H.content?H.content:window.csrf?window.csrf:(console.warn("CSRF token not found"),"")};async function O(){T.value=!0,k.value=null;try{const ve=await(await fetch(`/api/map-editor/pages/${c}/markers`,{method:"GET",headers:{"Content-Type":"application/json"}})).json();if(ve.status==="error")throw new Error(ve.message||"Failed to fetch markers");return x.value=ve.data.markers||[],x.value}catch(H){throw k.value=H.message,console.error("Error fetching markers:",H),H}finally{T.value=!1}}async function B(H){T.value=!0,k.value=null;try{const de=await(await fetch(`/api/map-editor/pages/${c}/markers`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF":P()},body:JSON.stringify({position:H})})).json();if(de.status==="error")throw new Error(de.message||"Failed to create marker");const ge=de.data.marker;return x.value.push(ge),console.log(ge),ge}catch(ve){throw k.value=ve.message,console.error("Error creating marker:",ve),ve}finally{T.value=!1}}async function o(H,ve){T.value=!0,k.value=null;try{const ge=await(await fetch(`/api/map-editor/pages/${c}/markers/${H}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF":P()},body:JSON.stringify({position:ve})})).json();if(ge.status==="error")throw new Error(ge.message||"Failed to update marker position");const Ue=x.value.findIndex(rt=>rt.id===H);return Ue!==-1&&(x.value[Ue]=ge.data.marker),ge.data.marker}catch(de){throw k.value=de.message,console.error("Error updating marker position:",de),de}finally{T.value=!1}}async function te(H){T.value=!0,k.value=null;try{const de=await(await fetch(`/api/map-editor/pages/${c}/markers/${H}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRF":P()}})).json();if(de.status==="error")throw new Error(de.message||"Failed to delete marker");const ge=x.value.findIndex(Ue=>Ue.id===H);return ge!==-1&&x.value.splice(ge,1),!0}catch(ve){throw k.value=ve.message,console.error("Error deleting marker:",ve),ve}finally{T.value=!1}}return{markers:x,loading:T,error:k,fetchMarkers:O,createMarker:B,updateMarkerPosition:o,deleteMarker:te}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function Ku(c){return typeof c>"u"||c===null}function Yf(c){return typeof c=="object"&&c!==null}function Jf(c){return Array.isArray(c)?c:Ku(c)?[]:[c]}function Qf(c,x){var T,k,P,O;if(x)for(O=Object.keys(x),T=0,k=O.length;T<k;T+=1)P=O[T],c[P]=x[P];return c}function em(c,x){var T="",k;for(k=0;k<x;k+=1)T+=c;return T}function tm(c){return c===0&&Number.NEGATIVE_INFINITY===1/c}var im=Ku,rm=Yf,nm=Jf,am=em,sm=tm,om=Qf,pi={isNothing:im,isObject:rm,toArray:nm,repeat:am,isNegativeZero:sm,extend:om};function Yu(c,x){var T="",k=c.reason||"(unknown reason)";return c.mark?(c.mark.name&&(T+='in "'+c.mark.name+'" '),T+="("+(c.mark.line+1)+":"+(c.mark.column+1)+")",!x&&c.mark.snippet&&(T+=`
`+c.mark.snippet),k+" "+T):k}function Ps(c,x){Error.call(this),this.name="YAMLException",this.reason=c,this.mark=x,this.message=Yu(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ps.prototype=Object.create(Error.prototype),Ps.prototype.constructor=Ps,Ps.prototype.toString=function(x){return this.name+": "+Yu(this,x)};var Zi=Ps;function hc(c,x,T,k,P){var O="",B="",o=Math.floor(P/2)-1;return k-x>o&&(O=" ... ",x=k-o+O.length),T-k>o&&(B=" ...",T=k+o-B.length),{str:O+c.slice(x,T).replace(/\t/g,"→")+B,pos:k-x+O.length}}function pc(c,x){return pi.repeat(" ",x-c.length)+c}function lm(c,x){if(x=Object.create(x||null),!c.buffer)return null;x.maxLength||(x.maxLength=79),typeof x.indent!="number"&&(x.indent=1),typeof x.linesBefore!="number"&&(x.linesBefore=3),typeof x.linesAfter!="number"&&(x.linesAfter=2);for(var T=/\r?\n|\r|\0/g,k=[0],P=[],O,B=-1;O=T.exec(c.buffer);)P.push(O.index),k.push(O.index+O[0].length),c.position<=O.index&&B<0&&(B=k.length-2);B<0&&(B=k.length-1);var o="",te,H,ve=Math.min(c.line+x.linesAfter,P.length).toString().length,de=x.maxLength-(x.indent+ve+3);for(te=1;te<=x.linesBefore&&!(B-te<0);te++)H=hc(c.buffer,k[B-te],P[B-te],c.position-(k[B]-k[B-te]),de),o=pi.repeat(" ",x.indent)+pc((c.line-te+1).toString(),ve)+" | "+H.str+`
`+o;for(H=hc(c.buffer,k[B],P[B],c.position,de),o+=pi.repeat(" ",x.indent)+pc((c.line+1).toString(),ve)+" | "+H.str+`
`,o+=pi.repeat("-",x.indent+ve+3+H.pos)+`^
`,te=1;te<=x.linesAfter&&!(B+te>=P.length);te++)H=hc(c.buffer,k[B+te],P[B+te],c.position-(k[B]-k[B+te]),de),o+=pi.repeat(" ",x.indent)+pc((c.line+te+1).toString(),ve)+" | "+H.str+`
`;return o.replace(/\n$/,"")}var cm=lm,um=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],hm=["scalar","sequence","mapping"];function pm(c){var x={};return c!==null&&Object.keys(c).forEach(function(T){c[T].forEach(function(k){x[String(k)]=T})}),x}function dm(c,x){if(x=x||{},Object.keys(x).forEach(function(T){if(um.indexOf(T)===-1)throw new Zi('Unknown option "'+T+'" is met in definition of "'+c+'" YAML type.')}),this.options=x,this.tag=c,this.kind=x.kind||null,this.resolve=x.resolve||function(){return!0},this.construct=x.construct||function(T){return T},this.instanceOf=x.instanceOf||null,this.predicate=x.predicate||null,this.represent=x.represent||null,this.representName=x.representName||null,this.defaultStyle=x.defaultStyle||null,this.multi=x.multi||!1,this.styleAliases=pm(x.styleAliases||null),hm.indexOf(this.kind)===-1)throw new Zi('Unknown kind "'+this.kind+'" is specified for "'+c+'" YAML type.')}var Ti=dm;function Ju(c,x){var T=[];return c[x].forEach(function(k){var P=T.length;T.forEach(function(O,B){O.tag===k.tag&&O.kind===k.kind&&O.multi===k.multi&&(P=B)}),T[P]=k}),T}function fm(){var c={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},x,T;function k(P){P.multi?(c.multi[P.kind].push(P),c.multi.fallback.push(P)):c[P.kind][P.tag]=c.fallback[P.tag]=P}for(x=0,T=arguments.length;x<T;x+=1)arguments[x].forEach(k);return c}function dc(c){return this.extend(c)}dc.prototype.extend=function(x){var T=[],k=[];if(x instanceof Ti)k.push(x);else if(Array.isArray(x))k=k.concat(x);else if(x&&(Array.isArray(x.implicit)||Array.isArray(x.explicit)))x.implicit&&(T=T.concat(x.implicit)),x.explicit&&(k=k.concat(x.explicit));else throw new Zi("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");T.forEach(function(O){if(!(O instanceof Ti))throw new Zi("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(O.loadKind&&O.loadKind!=="scalar")throw new Zi("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(O.multi)throw new Zi("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),k.forEach(function(O){if(!(O instanceof Ti))throw new Zi("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var P=Object.create(dc.prototype);return P.implicit=(this.implicit||[]).concat(T),P.explicit=(this.explicit||[]).concat(k),P.compiledImplicit=Ju(P,"implicit"),P.compiledExplicit=Ju(P,"explicit"),P.compiledTypeMap=fm(P.compiledImplicit,P.compiledExplicit),P};var Qu=dc,eh=new Ti("tag:yaml.org,2002:str",{kind:"scalar",construct:function(c){return c!==null?c:""}}),th=new Ti("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(c){return c!==null?c:[]}}),ih=new Ti("tag:yaml.org,2002:map",{kind:"mapping",construct:function(c){return c!==null?c:{}}}),rh=new Qu({explicit:[eh,th,ih]});function mm(c){if(c===null)return!0;var x=c.length;return x===1&&c==="~"||x===4&&(c==="null"||c==="Null"||c==="NULL")}function gm(){return null}function _m(c){return c===null}var nh=new Ti("tag:yaml.org,2002:null",{kind:"scalar",resolve:mm,construct:gm,predicate:_m,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function ym(c){if(c===null)return!1;var x=c.length;return x===4&&(c==="true"||c==="True"||c==="TRUE")||x===5&&(c==="false"||c==="False"||c==="FALSE")}function xm(c){return c==="true"||c==="True"||c==="TRUE"}function vm(c){return Object.prototype.toString.call(c)==="[object Boolean]"}var ah=new Ti("tag:yaml.org,2002:bool",{kind:"scalar",resolve:ym,construct:xm,predicate:vm,represent:{lowercase:function(c){return c?"true":"false"},uppercase:function(c){return c?"TRUE":"FALSE"},camelcase:function(c){return c?"True":"False"}},defaultStyle:"lowercase"});function bm(c){return 48<=c&&c<=57||65<=c&&c<=70||97<=c&&c<=102}function wm(c){return 48<=c&&c<=55}function Sm(c){return 48<=c&&c<=57}function Tm(c){if(c===null)return!1;var x=c.length,T=0,k=!1,P;if(!x)return!1;if(P=c[T],(P==="-"||P==="+")&&(P=c[++T]),P==="0"){if(T+1===x)return!0;if(P=c[++T],P==="b"){for(T++;T<x;T++)if(P=c[T],P!=="_"){if(P!=="0"&&P!=="1")return!1;k=!0}return k&&P!=="_"}if(P==="x"){for(T++;T<x;T++)if(P=c[T],P!=="_"){if(!bm(c.charCodeAt(T)))return!1;k=!0}return k&&P!=="_"}if(P==="o"){for(T++;T<x;T++)if(P=c[T],P!=="_"){if(!wm(c.charCodeAt(T)))return!1;k=!0}return k&&P!=="_"}}if(P==="_")return!1;for(;T<x;T++)if(P=c[T],P!=="_"){if(!Sm(c.charCodeAt(T)))return!1;k=!0}return!(!k||P==="_")}function Im(c){var x=c,T=1,k;if(x.indexOf("_")!==-1&&(x=x.replace(/_/g,"")),k=x[0],(k==="-"||k==="+")&&(k==="-"&&(T=-1),x=x.slice(1),k=x[0]),x==="0")return 0;if(k==="0"){if(x[1]==="b")return T*parseInt(x.slice(2),2);if(x[1]==="x")return T*parseInt(x.slice(2),16);if(x[1]==="o")return T*parseInt(x.slice(2),8)}return T*parseInt(x,10)}function Am(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!pi.isNegativeZero(c)}var sh=new Ti("tag:yaml.org,2002:int",{kind:"scalar",resolve:Tm,construct:Im,predicate:Am,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Cm=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function km(c){return!(c===null||!Cm.test(c)||c[c.length-1]==="_")}function Em(c){var x,T;return x=c.replace(/_/g,"").toLowerCase(),T=x[0]==="-"?-1:1,"+-".indexOf(x[0])>=0&&(x=x.slice(1)),x===".inf"?T===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:x===".nan"?NaN:T*parseFloat(x,10)}var Mm=/^[-+]?[0-9]+e/;function Pm(c,x){var T;if(isNaN(c))switch(x){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(x){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(x){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(pi.isNegativeZero(c))return"-0.0";return T=c.toString(10),Mm.test(T)?T.replace("e",".e"):T}function zm(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||pi.isNegativeZero(c))}var oh=new Ti("tag:yaml.org,2002:float",{kind:"scalar",resolve:km,construct:Em,predicate:zm,represent:Pm,defaultStyle:"lowercase"}),lh=rh.extend({implicit:[nh,ah,sh,oh]}),ch=lh,uh=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),hh=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 Dm(c){return c===null?!1:uh.exec(c)!==null||hh.exec(c)!==null}function Lm(c){var x,T,k,P,O,B,o,te=0,H=null,ve,de,ge;if(x=uh.exec(c),x===null&&(x=hh.exec(c)),x===null)throw new Error("Date resolve error");if(T=+x[1],k=+x[2]-1,P=+x[3],!x[4])return new Date(Date.UTC(T,k,P));if(O=+x[4],B=+x[5],o=+x[6],x[7]){for(te=x[7].slice(0,3);te.length<3;)te+="0";te=+te}return x[9]&&(ve=+x[10],de=+(x[11]||0),H=(ve*60+de)*6e4,x[9]==="-"&&(H=-H)),ge=new Date(Date.UTC(T,k,P,O,B,o,te)),H&&ge.setTime(ge.getTime()-H),ge}function Rm(c){return c.toISOString()}var ph=new Ti("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Dm,construct:Lm,instanceOf:Date,represent:Rm});function Fm(c){return c==="<<"||c===null}var dh=new Ti("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Fm}),fc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
\r`;function Bm(c){if(c===null)return!1;var x,T,k=0,P=c.length,O=fc;for(T=0;T<P;T++)if(x=O.indexOf(c.charAt(T)),!(x>64)){if(x<0)return!1;k+=6}return k%8===0}function Om(c){var x,T,k=c.replace(/[\r\n=]/g,""),P=k.length,O=fc,B=0,o=[];for(x=0;x<P;x++)x%4===0&&x&&(o.push(B>>16&255),o.push(B>>8&255),o.push(B&255)),B=B<<6|O.indexOf(k.charAt(x));return T=P%4*6,T===0?(o.push(B>>16&255),o.push(B>>8&255),o.push(B&255)):T===18?(o.push(B>>10&255),o.push(B>>2&255)):T===12&&o.push(B>>4&255),new Uint8Array(o)}function Nm(c){var x="",T=0,k,P,O=c.length,B=fc;for(k=0;k<O;k++)k%3===0&&k&&(x+=B[T>>18&63],x+=B[T>>12&63],x+=B[T>>6&63],x+=B[T&63]),T=(T<<8)+c[k];return P=O%3,P===0?(x+=B[T>>18&63],x+=B[T>>12&63],x+=B[T>>6&63],x+=B[T&63]):P===2?(x+=B[T>>10&63],x+=B[T>>4&63],x+=B[T<<2&63],x+=B[64]):P===1&&(x+=B[T>>2&63],x+=B[T<<4&63],x+=B[64],x+=B[64]),x}function Vm(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}var fh=new Ti("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Bm,construct:Om,predicate:Vm,represent:Nm}),Um=Object.prototype.hasOwnProperty,$m=Object.prototype.toString;function jm(c){if(c===null)return!0;var x=[],T,k,P,O,B,o=c;for(T=0,k=o.length;T<k;T+=1){if(P=o[T],B=!1,$m.call(P)!=="[object Object]")return!1;for(O in P)if(Um.call(P,O))if(!B)B=!0;else return!1;if(!B)return!1;if(x.indexOf(O)===-1)x.push(O);else return!1}return!0}function qm(c){return c!==null?c:[]}var mh=new Ti("tag:yaml.org,2002:omap",{kind:"sequence",resolve:jm,construct:qm}),Zm=Object.prototype.toString;function Gm(c){if(c===null)return!0;var x,T,k,P,O,B=c;for(O=new Array(B.length),x=0,T=B.length;x<T;x+=1){if(k=B[x],Zm.call(k)!=="[object Object]"||(P=Object.keys(k),P.length!==1))return!1;O[x]=[P[0],k[P[0]]]}return!0}function Hm(c){if(c===null)return[];var x,T,k,P,O,B=c;for(O=new Array(B.length),x=0,T=B.length;x<T;x+=1)k=B[x],P=Object.keys(k),O[x]=[P[0],k[P[0]]];return O}var gh=new Ti("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Gm,construct:Hm}),Wm=Object.prototype.hasOwnProperty;function Xm(c){if(c===null)return!0;var x,T=c;for(x in T)if(Wm.call(T,x)&&T[x]!==null)return!1;return!0}function Km(c){return c!==null?c:{}}var _h=new Ti("tag:yaml.org,2002:set",{kind:"mapping",resolve:Xm,construct:Km}),mc=ch.extend({implicit:[ph,dh],explicit:[fh,mh,gh,_h]}),On=Object.prototype.hasOwnProperty,Wo=1,yh=2,xh=3,Xo=4,gc=1,Ym=2,vh=3,Jm=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Qm=/[\x85\u2028\u2029]/,eg=/[,\[\]\{\}]/,bh=/^(?:!|!!|![a-z\-]+!)$/i,wh=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Sh(c){return Object.prototype.toString.call(c)}function Xr(c){return c===10||c===13}function pa(c){return c===9||c===32}function nr(c){return c===9||c===32||c===10||c===13}function Na(c){return c===44||c===91||c===93||c===123||c===125}function tg(c){var x;return 48<=c&&c<=57?c-48:(x=c|32,97<=x&&x<=102?x-97+10:-1)}function ig(c){return c===120?2:c===117?4:c===85?8:0}function rg(c){return 48<=c&&c<=57?c-48:-1}function Th(c){return c===48?"\0":c===97?"\x07":c===98?"\b":c===116||c===9?" ":c===110?`
`:c===118?"\v":c===102?"\f":c===114?"\r":c===101?"\x1B":c===32?" ":c===34?'"':c===47?"/":c===92?"\\":c===78?"…":c===95?" ":c===76?"\u2028":c===80?"\u2029":""}function ng(c){return c<=65535?String.fromCharCode(c):String.fromCharCode((c-65536>>10)+55296,(c-65536&1023)+56320)}function Ih(c,x,T){x==="__proto__"?Object.defineProperty(c,x,{configurable:!0,enumerable:!0,writable:!0,value:T}):c[x]=T}for(var Ah=new Array(256),Ch=new Array(256),Va=0;Va<256;Va++)Ah[Va]=Th(Va)?1:0,Ch[Va]=Th(Va);function ag(c,x){this.input=c,this.filename=x.filename||null,this.schema=x.schema||mc,this.onWarning=x.onWarning||null,this.legacy=x.legacy||!1,this.json=x.json||!1,this.listener=x.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=c.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function kh(c,x){var T={name:c.filename,buffer:c.input.slice(0,-1),position:c.position,line:c.line,column:c.position-c.lineStart};return T.snippet=cm(T),new Zi(x,T)}function Qe(c,x){throw kh(c,x)}function Ko(c,x){c.onWarning&&c.onWarning.call(null,kh(c,x))}var Eh={YAML:function(x,T,k){var P,O,B;x.version!==null&&Qe(x,"duplication of %YAML directive"),k.length!==1&&Qe(x,"YAML directive accepts exactly one argument"),P=/^([0-9]+)\.([0-9]+)$/.exec(k[0]),P===null&&Qe(x,"ill-formed argument of the YAML directive"),O=parseInt(P[1],10),B=parseInt(P[2],10),O!==1&&Qe(x,"unacceptable YAML version of the document"),x.version=k[0],x.checkLineBreaks=B<2,B!==1&&B!==2&&Ko(x,"unsupported YAML version of the document")},TAG:function(x,T,k){var P,O;k.length!==2&&Qe(x,"TAG directive accepts exactly two arguments"),P=k[0],O=k[1],bh.test(P)||Qe(x,"ill-formed tag handle (first argument) of the TAG directive"),On.call(x.tagMap,P)&&Qe(x,'there is a previously declared suffix for "'+P+'" tag handle'),wh.test(O)||Qe(x,"ill-formed tag prefix (second argument) of the TAG directive");try{O=decodeURIComponent(O)}catch{Qe(x,"tag prefix is malformed: "+O)}x.tagMap[P]=O}};function Nn(c,x,T,k){var P,O,B,o;if(x<T){if(o=c.input.slice(x,T),k)for(P=0,O=o.length;P<O;P+=1)B=o.charCodeAt(P),B===9||32<=B&&B<=1114111||Qe(c,"expected valid JSON character");else Jm.test(o)&&Qe(c,"the stream contains non-printable characters");c.result+=o}}function Mh(c,x,T,k){var P,O,B,o;for(pi.isObject(T)||Qe(c,"cannot merge mappings; the provided source object is unacceptable"),P=Object.keys(T),B=0,o=P.length;B<o;B+=1)O=P[B],On.call(x,O)||(Ih(x,O,T[O]),k[O]=!0)}function Ua(c,x,T,k,P,O,B,o,te){var H,ve;if(Array.isArray(P))for(P=Array.prototype.slice.call(P),H=0,ve=P.length;H<ve;H+=1)Array.isArray(P[H])&&Qe(c,"nested arrays are not supported inside keys"),typeof P=="object"&&Sh(P[H])==="[object Object]"&&(P[H]="[object Object]");if(typeof P=="object"&&Sh(P)==="[object Object]"&&(P="[object Object]"),P=String(P),x===null&&(x={}),k==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(H=0,ve=O.length;H<ve;H+=1)Mh(c,x,O[H],T);else Mh(c,x,O,T);else!c.json&&!On.call(T,P)&&On.call(x,P)&&(c.line=B||c.line,c.lineStart=o||c.lineStart,c.position=te||c.position,Qe(c,"duplicated mapping key")),Ih(x,P,O),delete T[P];return x}function _c(c){var x;x=c.input.charCodeAt(c.position),x===10?c.position++:x===13?(c.position++,c.input.charCodeAt(c.position)===10&&c.position++):Qe(c,"a line break is expected"),c.line+=1,c.lineStart=c.position,c.firstTabInLine=-1}function hi(c,x,T){for(var k=0,P=c.input.charCodeAt(c.position);P!==0;){for(;pa(P);)P===9&&c.firstTabInLine===-1&&(c.firstTabInLine=c.position),P=c.input.charCodeAt(++c.position);if(x&&P===35)do P=c.input.charCodeAt(++c.position);while(P!==10&&P!==13&&P!==0);if(Xr(P))for(_c(c),P=c.input.charCodeAt(c.position),k++,c.lineIndent=0;P===32;)c.lineIndent++,P=c.input.charCodeAt(++c.position);else break}return T!==-1&&k!==0&&c.lineIndent<T&&Ko(c,"deficient indentation"),k}function Yo(c){var x=c.position,T;return T=c.input.charCodeAt(x),!!((T===45||T===46)&&T===c.input.charCodeAt(x+1)&&T===c.input.charCodeAt(x+2)&&(x+=3,T=c.input.charCodeAt(x),T===0||nr(T)))}function yc(c,x){x===1?c.result+=" ":x>1&&(c.result+=pi.repeat(`
`,x-1))}function sg(c,x,T){var k,P,O,B,o,te,H,ve,de=c.kind,ge=c.result,Ue;if(Ue=c.input.charCodeAt(c.position),nr(Ue)||Na(Ue)||Ue===35||Ue===38||Ue===42||Ue===33||Ue===124||Ue===62||Ue===39||Ue===34||Ue===37||Ue===64||Ue===96||(Ue===63||Ue===45)&&(P=c.input.charCodeAt(c.position+1),nr(P)||T&&Na(P)))return!1;for(c.kind="scalar",c.result="",O=B=c.position,o=!1;Ue!==0;){if(Ue===58){if(P=c.input.charCodeAt(c.position+1),nr(P)||T&&Na(P))break}else if(Ue===35){if(k=c.input.charCodeAt(c.position-1),nr(k))break}else{if(c.position===c.lineStart&&Yo(c)||T&&Na(Ue))break;if(Xr(Ue))if(te=c.line,H=c.lineStart,ve=c.lineIndent,hi(c,!1,-1),c.lineIndent>=x){o=!0,Ue=c.input.charCodeAt(c.position);continue}else{c.position=B,c.line=te,c.lineStart=H,c.lineIndent=ve;break}}o&&(Nn(c,O,B,!1),yc(c,c.line-te),O=B=c.position,o=!1),pa(Ue)||(B=c.position+1),Ue=c.input.charCodeAt(++c.position)}return Nn(c,O,B,!1),c.result?!0:(c.kind=de,c.result=ge,!1)}function og(c,x){var T,k,P;if(T=c.input.charCodeAt(c.position),T!==39)return!1;for(c.kind="scalar",c.result="",c.position++,k=P=c.position;(T=c.input.charCodeAt(c.position))!==0;)if(T===39)if(Nn(c,k,c.position,!0),T=c.input.charCodeAt(++c.position),T===39)k=c.position,c.position++,P=c.position;else return!0;else Xr(T)?(Nn(c,k,P,!0),yc(c,hi(c,!1,x)),k=P=c.position):c.position===c.lineStart&&Yo(c)?Qe(c,"unexpected end of the document within a single quoted scalar"):(c.position++,P=c.position);Qe(c,"unexpected end of the stream within a single quoted scalar")}function lg(c,x){var T,k,P,O,B,o;if(o=c.input.charCodeAt(c.position),o!==34)return!1;for(c.kind="scalar",c.result="",c.position++,T=k=c.position;(o=c.input.charCodeAt(c.position))!==0;){if(o===34)return Nn(c,T,c.position,!0),c.position++,!0;if(o===92){if(Nn(c,T,c.position,!0),o=c.input.charCodeAt(++c.position),Xr(o))hi(c,!1,x);else if(o<256&&Ah[o])c.result+=Ch[o],c.position++;else if((B=ig(o))>0){for(P=B,O=0;P>0;P--)o=c.input.charCodeAt(++c.position),(B=tg(o))>=0?O=(O<<4)+B:Qe(c,"expected hexadecimal character");c.result+=ng(O),c.position++}else Qe(c,"unknown escape sequence");T=k=c.position}else Xr(o)?(Nn(c,T,k,!0),yc(c,hi(c,!1,x)),T=k=c.position):c.position===c.lineStart&&Yo(c)?Qe(c,"unexpected end of the document within a double quoted scalar"):(c.position++,k=c.position)}Qe(c,"unexpected end of the stream within a double quoted scalar")}function cg(c,x){var T=!0,k,P,O,B=c.tag,o,te=c.anchor,H,ve,de,ge,Ue,rt=Object.create(null),Te,Be,Ze,He;if(He=c.input.charCodeAt(c.position),He===91)ve=93,Ue=!1,o=[];else if(He===123)ve=125,Ue=!0,o={};else return!1;for(c.anchor!==null&&(c.anchorMap[c.anchor]=o),He=c.input.charCodeAt(++c.position);He!==0;){if(hi(c,!0,x),He=c.input.charCodeAt(c.position),He===ve)return c.position++,c.tag=B,c.anchor=te,c.kind=Ue?"mapping":"sequence",c.result=o,!0;T?He===44&&Qe(c,"expected the node content, but found ','"):Qe(c,"missed comma between flow collection entries"),Be=Te=Ze=null,de=ge=!1,He===63&&(H=c.input.charCodeAt(c.position+1),nr(H)&&(de=ge=!0,c.position++,hi(c,!0,x))),k=c.line,P=c.lineStart,O=c.position,$a(c,x,Wo,!1,!0),Be=c.tag,Te=c.result,hi(c,!0,x),He=c.input.charCodeAt(c.position),(ge||c.line===k)&&He===58&&(de=!0,He=c.input.charCodeAt(++c.position),hi(c,!0,x),$a(c,x,Wo,!1,!0),Ze=c.result),Ue?Ua(c,o,rt,Be,Te,Ze,k,P,O):de?o.push(Ua(c,null,rt,Be,Te,Ze,k,P,O)):o.push(Te),hi(c,!0,x),He=c.input.charCodeAt(c.position),He===44?(T=!0,He=c.input.charCodeAt(++c.position)):T=!1}Qe(c,"unexpected end of the stream within a flow collection")}function ug(c,x){var T,k,P=gc,O=!1,B=!1,o=x,te=0,H=!1,ve,de;if(de=c.input.charCodeAt(c.position),de===124)k=!1;else if(de===62)k=!0;else return!1;for(c.kind="scalar",c.result="";de!==0;)if(de=c.input.charCodeAt(++c.position),de===43||de===45)gc===P?P=de===43?vh:Ym:Qe(c,"repeat of a chomping mode identifier");else if((ve=rg(de))>=0)ve===0?Qe(c,"bad explicit indentation width of a block scalar; it cannot be less than one"):B?Qe(c,"repeat of an indentation width identifier"):(o=x+ve-1,B=!0);else break;if(pa(de)){do de=c.input.charCodeAt(++c.position);while(pa(de));if(de===35)do de=c.input.charCodeAt(++c.position);while(!Xr(de)&&de!==0)}for(;de!==0;){for(_c(c),c.lineIndent=0,de=c.input.charCodeAt(c.position);(!B||c.lineIndent<o)&&de===32;)c.lineIndent++,de=c.input.charCodeAt(++c.position);if(!B&&c.lineIndent>o&&(o=c.lineIndent),Xr(de)){te++;continue}if(c.lineIndent<o){P===vh?c.result+=pi.repeat(`
`,O?1+te:te):P===gc&&O&&(c.result+=`
`);break}for(k?pa(de)?(H=!0,c.result+=pi.repeat(`
`,O?1+te:te)):H?(H=!1,c.result+=pi.repeat(`
`,te+1)):te===0?O&&(c.result+=" "):c.result+=pi.repeat(`
`,te):c.result+=pi.repeat(`
`,O?1+te:te),O=!0,B=!0,te=0,T=c.position;!Xr(de)&&de!==0;)de=c.input.charCodeAt(++c.position);Nn(c,T,c.position,!1)}return!0}function Ph(c,x){var T,k=c.tag,P=c.anchor,O=[],B,o=!1,te;if(c.firstTabInLine!==-1)return!1;for(c.anchor!==null&&(c.anchorMap[c.anchor]=O),te=c.input.charCodeAt(c.position);te!==0&&(c.firstTabInLine!==-1&&(c.position=c.firstTabInLine,Qe(c,"tab characters must not be used in indentation")),!(te!==45||(B=c.input.charCodeAt(c.position+1),!nr(B))));){if(o=!0,c.position++,hi(c,!0,-1)&&c.lineIndent<=x){O.push(null),te=c.input.charCodeAt(c.position);continue}if(T=c.line,$a(c,x,xh,!1,!0),O.push(c.result),hi(c,!0,-1),te=c.input.charCodeAt(c.position),(c.line===T||c.lineIndent>x)&&te!==0)Qe(c,"bad indentation of a sequence entry");else if(c.lineIndent<x)break}return o?(c.tag=k,c.anchor=P,c.kind="sequence",c.result=O,!0):!1}function hg(c,x,T){var k,P,O,B,o,te,H=c.tag,ve=c.anchor,de={},ge=Object.create(null),Ue=null,rt=null,Te=null,Be=!1,Ze=!1,He;if(c.firstTabInLine!==-1)return!1;for(c.anchor!==null&&(c.anchorMap[c.anchor]=de),He=c.input.charCodeAt(c.position);He!==0;){if(!Be&&c.firstTabInLine!==-1&&(c.position=c.firstTabInLine,Qe(c,"tab characters must not be used in indentation")),k=c.input.charCodeAt(c.position+1),O=c.line,(He===63||He===58)&&nr(k))He===63?(Be&&(Ua(c,de,ge,Ue,rt,null,B,o,te),Ue=rt=Te=null),Ze=!0,Be=!0,P=!0):Be?(Be=!1,P=!0):Qe(c,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),c.position+=1,He=k;else{if(B=c.line,o=c.lineStart,te=c.position,!$a(c,T,yh,!1,!0))break;if(c.line===O){for(He=c.input.charCodeAt(c.position);pa(He);)He=c.input.charCodeAt(++c.position);if(He===58)He=c.input.charCodeAt(++c.position),nr(He)||Qe(c,"a whitespace character is expected after the key-value separator within a block mapping"),Be&&(Ua(c,de,ge,Ue,rt,null,B,o,te),Ue=rt=Te=null),Ze=!0,Be=!1,P=!1,Ue=c.tag,rt=c.result;else if(Ze)Qe(c,"can not read an implicit mapping pair; a colon is missed");else return c.tag=H,c.anchor=ve,!0}else if(Ze)Qe(c,"can not read a block mapping entry; a multiline key may not be an implicit key");else return c.tag=H,c.anchor=ve,!0}if((c.line===O||c.lineIndent>x)&&(Be&&(B=c.line,o=c.lineStart,te=c.position),$a(c,x,Xo,!0,P)&&(Be?rt=c.result:Te=c.result),Be||(Ua(c,de,ge,Ue,rt,Te,B,o,te),Ue=rt=Te=null),hi(c,!0,-1),He=c.input.charCodeAt(c.position)),(c.line===O||c.lineIndent>x)&&He!==0)Qe(c,"bad indentation of a mapping entry");else if(c.lineIndent<x)break}return Be&&Ua(c,de,ge,Ue,rt,null,B,o,te),Ze&&(c.tag=H,c.anchor=ve,c.kind="mapping",c.result=de),Ze}function pg(c){var x,T=!1,k=!1,P,O,B;if(B=c.input.charCodeAt(c.position),B!==33)return!1;if(c.tag!==null&&Qe(c,"duplication of a tag property"),B=c.input.charCodeAt(++c.position),B===60?(T=!0,B=c.input.charCodeAt(++c.position)):B===33?(k=!0,P="!!",B=c.input.charCodeAt(++c.position)):P="!",x=c.position,T){do B=c.input.charCodeAt(++c.position);while(B!==0&&B!==62);c.position<c.length?(O=c.input.slice(x,c.position),B=c.input.charCodeAt(++c.position)):Qe(c,"unexpected end of the stream within a verbatim tag")}else{for(;B!==0&&!nr(B);)B===33&&(k?Qe(c,"tag suffix cannot contain exclamation marks"):(P=c.input.slice(x-1,c.position+1),bh.test(P)||Qe(c,"named tag handle cannot contain such characters"),k=!0,x=c.position+1)),B=c.input.charCodeAt(++c.position);O=c.input.slice(x,c.position),eg.test(O)&&Qe(c,"tag suffix cannot contain flow indicator characters")}O&&!wh.test(O)&&Qe(c,"tag name cannot contain such characters: "+O);try{O=decodeURIComponent(O)}catch{Qe(c,"tag name is malformed: "+O)}return T?c.tag=O:On.call(c.tagMap,P)?c.tag=c.tagMap[P]+O:P==="!"?c.tag="!"+O:P==="!!"?c.tag="tag:yaml.org,2002:"+O:Qe(c,'undeclared tag handle "'+P+'"'),!0}function dg(c){var x,T;if(T=c.input.charCodeAt(c.position),T!==38)return!1;for(c.anchor!==null&&Qe(c,"duplication of an anchor property"),T=c.input.charCodeAt(++c.position),x=c.position;T!==0&&!nr(T)&&!Na(T);)T=c.input.charCodeAt(++c.position);return c.position===x&&Qe(c,"name of an anchor node must contain at least one character"),c.anchor=c.input.slice(x,c.position),!0}function fg(c){var x,T,k;if(k=c.input.charCodeAt(c.position),k!==42)return!1;for(k=c.input.charCodeAt(++c.position),x=c.position;k!==0&&!nr(k)&&!Na(k);)k=c.input.charCodeAt(++c.position);return c.position===x&&Qe(c,"name of an alias node must contain at least one character"),T=c.input.slice(x,c.position),On.call(c.anchorMap,T)||Qe(c,'unidentified alias "'+T+'"'),c.result=c.anchorMap[T],hi(c,!0,-1),!0}function $a(c,x,T,k,P){var O,B,o,te=1,H=!1,ve=!1,de,ge,Ue,rt,Te,Be;if(c.listener!==null&&c.listener("open",c),c.tag=null,c.anchor=null,c.kind=null,c.result=null,O=B=o=Xo===T||xh===T,k&&hi(c,!0,-1)&&(H=!0,c.lineIndent>x?te=1:c.lineIndent===x?te=0:c.lineIndent<x&&(te=-1)),te===1)for(;pg(c)||dg(c);)hi(c,!0,-1)?(H=!0,o=O,c.lineIndent>x?te=1:c.lineIndent===x?te=0:c.lineIndent<x&&(te=-1)):o=!1;if(o&&(o=H||P),(te===1||Xo===T)&&(Wo===T||yh===T?Te=x:Te=x+1,Be=c.position-c.lineStart,te===1?o&&(Ph(c,Be)||hg(c,Be,Te))||cg(c,Te)?ve=!0:(B&&ug(c,Te)||og(c,Te)||lg(c,Te)?ve=!0:fg(c)?(ve=!0,(c.tag!==null||c.anchor!==null)&&Qe(c,"alias node should not have any properties")):sg(c,Te,Wo===T)&&(ve=!0,c.tag===null&&(c.tag="?")),c.anchor!==null&&(c.anchorMap[c.anchor]=c.result)):te===0&&(ve=o&&Ph(c,Be))),c.tag===null)c.anchor!==null&&(c.anchorMap[c.anchor]=c.result);else if(c.tag==="?"){for(c.result!==null&&c.kind!=="scalar"&&Qe(c,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+c.kind+'"'),de=0,ge=c.implicitTypes.length;de<ge;de+=1)if(rt=c.implicitTypes[de],rt.resolve(c.result)){c.result=rt.construct(c.result),c.tag=rt.tag,c.anchor!==null&&(c.anchorMap[c.anchor]=c.result);break}}else if(c.tag!=="!"){if(On.call(c.typeMap[c.kind||"fallback"],c.tag))rt=c.typeMap[c.kind||"fallback"][c.tag];else for(rt=null,Ue=c.typeMap.multi[c.kind||"fallback"],de=0,ge=Ue.length;de<ge;de+=1)if(c.tag.slice(0,Ue[de].tag.length)===Ue[de].tag){rt=Ue[de];break}rt||Qe(c,"unknown tag !<"+c.tag+">"),c.result!==null&&rt.kind!==c.kind&&Qe(c,"unacceptable node kind for !<"+c.tag+'> tag; it should be "'+rt.kind+'", not "'+c.kind+'"'),rt.resolve(c.result,c.tag)?(c.result=rt.construct(c.result,c.tag),c.anchor!==null&&(c.anchorMap[c.anchor]=c.result)):Qe(c,"cannot resolve a node with !<"+c.tag+"> explicit tag")}return c.listener!==null&&c.listener("close",c),c.tag!==null||c.anchor!==null||ve}function mg(c){var x=c.position,T,k,P,O=!1,B;for(c.version=null,c.checkLineBreaks=c.legacy,c.tagMap=Object.create(null),c.anchorMap=Object.create(null);(B=c.input.charCodeAt(c.position))!==0&&(hi(c,!0,-1),B=c.input.charCodeAt(c.position),!(c.lineIndent>0||B!==37));){for(O=!0,B=c.input.charCodeAt(++c.position),T=c.position;B!==0&&!nr(B);)B=c.input.charCodeAt(++c.position);for(k=c.input.slice(T,c.position),P=[],k.length<1&&Qe(c,"directive name must not be less than one character in length");B!==0;){for(;pa(B);)B=c.input.charCodeAt(++c.position);if(B===35){do B=c.input.charCodeAt(++c.position);while(B!==0&&!Xr(B));break}if(Xr(B))break;for(T=c.position;B!==0&&!nr(B);)B=c.input.charCodeAt(++c.position);P.push(c.input.slice(T,c.position))}B!==0&&_c(c),On.call(Eh,k)?Eh[k](c,k,P):Ko(c,'unknown document directive "'+k+'"')}if(hi(c,!0,-1),c.lineIndent===0&&c.input.charCodeAt(c.position)===45&&c.input.charCodeAt(c.position+1)===45&&c.input.charCodeAt(c.position+2)===45?(c.position+=3,hi(c,!0,-1)):O&&Qe(c,"directives end mark is expected"),$a(c,c.lineIndent-1,Xo,!1,!0),hi(c,!0,-1),c.checkLineBreaks&&Qm.test(c.input.slice(x,c.position))&&Ko(c,"non-ASCII line breaks are interpreted as content"),c.documents.push(c.result),c.position===c.lineStart&&Yo(c)){c.input.charCodeAt(c.position)===46&&(c.position+=3,hi(c,!0,-1));return}if(c.position<c.length-1)Qe(c,"end of the stream or a document separator is expected");else return}function zh(c,x){c=String(c),x=x||{},c.length!==0&&(c.charCodeAt(c.length-1)!==10&&c.charCodeAt(c.length-1)!==13&&(c+=`
`),c.charCodeAt(0)===65279&&(c=c.slice(1)));var T=new ag(c,x),k=c.indexOf("\0");for(k!==-1&&(T.position=k,Qe(T,"null byte is not allowed in input")),T.input+="\0";T.input.charCodeAt(T.position)===32;)T.lineIndent+=1,T.position+=1;for(;T.position<T.length-1;)mg(T);return T.documents}function gg(c,x,T){x!==null&&typeof x=="object"&&typeof T>"u"&&(T=x,x=null);var k=zh(c,T);if(typeof x!="function")return k;for(var P=0,O=k.length;P<O;P+=1)x(k[P])}function _g(c,x){var T=zh(c,x);if(T.length!==0){if(T.length===1)return T[0];throw new Zi("expected a single document in the stream, but found more")}}var yg=gg,xg=_g,Dh={loadAll:yg,load:xg},Lh=Object.prototype.toString,Rh=Object.prototype.hasOwnProperty,xc=65279,vg=9,zs=10,bg=13,wg=32,Sg=33,Tg=34,vc=35,Ig=37,Ag=38,Cg=39,kg=42,Fh=44,Eg=45,Jo=58,Mg=61,Pg=62,zg=63,Dg=64,Bh=91,Oh=93,Lg=96,Nh=123,Rg=124,Vh=125,zi={};zi[0]="\\0",zi[7]="\\a",zi[8]="\\b",zi[9]="\\t",zi[10]="\\n",zi[11]="\\v",zi[12]="\\f",zi[13]="\\r",zi[27]="\\e",zi[34]='\\"',zi[92]="\\\\",zi[133]="\\N",zi[160]="\\_",zi[8232]="\\L",zi[8233]="\\P";var Fg=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Bg=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Og(c,x){var T,k,P,O,B,o,te;if(x===null)return{};for(T={},k=Object.keys(x),P=0,O=k.length;P<O;P+=1)B=k[P],o=String(x[B]),B.slice(0,2)==="!!"&&(B="tag:yaml.org,2002:"+B.slice(2)),te=c.compiledTypeMap.fallback[B],te&&Rh.call(te.styleAliases,o)&&(o=te.styleAliases[o]),T[B]=o;return T}function Ng(c){var x,T,k;if(x=c.toString(16).toUpperCase(),c<=255)T="x",k=2;else if(c<=65535)T="u",k=4;else if(c<=4294967295)T="U",k=8;else throw new Zi("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+T+pi.repeat("0",k-x.length)+x}var Vg=1,Ds=2;function Ug(c){this.schema=c.schema||mc,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=pi.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=Og(this.schema,c.styles||null),this.sortKeys=c.sortKeys||!1,this.lineWidth=c.lineWidth||80,this.noRefs=c.noRefs||!1,this.noCompatMode=c.noCompatMode||!1,this.condenseFlow=c.condenseFlow||!1,this.quotingType=c.quotingType==='"'?Ds:Vg,this.forceQuotes=c.forceQuotes||!1,this.replacer=typeof c.replacer=="function"?c.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Uh(c,x){for(var T=pi.repeat(" ",x),k=0,P=-1,O="",B,o=c.length;k<o;)P=c.indexOf(`
`,k),P===-1?(B=c.slice(k),k=o):(B=c.slice(k,P+1),k=P+1),B.length&&B!==`
`&&(O+=T),O+=B;return O}function bc(c,x){return`
`+pi.repeat(" ",c.indent*x)}function $g(c,x){var T,k,P;for(T=0,k=c.implicitTypes.length;T<k;T+=1)if(P=c.implicitTypes[T],P.resolve(x))return!0;return!1}function Qo(c){return c===wg||c===vg}function Ls(c){return 32<=c&&c<=126||161<=c&&c<=55295&&c!==8232&&c!==8233||57344<=c&&c<=65533&&c!==xc||65536<=c&&c<=1114111}function $h(c){return Ls(c)&&c!==xc&&c!==bg&&c!==zs}function jh(c,x,T){var k=$h(c),P=k&&!Qo(c);return(T?k:k&&c!==Fh&&c!==Bh&&c!==Oh&&c!==Nh&&c!==Vh)&&c!==vc&&!(x===Jo&&!P)||$h(x)&&!Qo(x)&&c===vc||x===Jo&&P}function jg(c){return Ls(c)&&c!==xc&&!Qo(c)&&c!==Eg&&c!==zg&&c!==Jo&&c!==Fh&&c!==Bh&&c!==Oh&&c!==Nh&&c!==Vh&&c!==vc&&c!==Ag&&c!==kg&&c!==Sg&&c!==Rg&&c!==Mg&&c!==Pg&&c!==Cg&&c!==Tg&&c!==Ig&&c!==Dg&&c!==Lg}function qg(c){return!Qo(c)&&c!==Jo}function Rs(c,x){var T=c.charCodeAt(x),k;return T>=55296&&T<=56319&&x+1<c.length&&(k=c.charCodeAt(x+1),k>=56320&&k<=57343)?(T-55296)*1024+k-56320+65536:T}function qh(c){var x=/^\n* /;return x.test(c)}var Zh=1,wc=2,Gh=3,Hh=4,ja=5;function Zg(c,x,T,k,P,O,B,o){var te,H=0,ve=null,de=!1,ge=!1,Ue=k!==-1,rt=-1,Te=jg(Rs(c,0))&&qg(Rs(c,c.length-1));if(x||B)for(te=0;te<c.length;H>=65536?te+=2:te++){if(H=Rs(c,te),!Ls(H))return ja;Te=Te&&jh(H,ve,o),ve=H}else{for(te=0;te<c.length;H>=65536?te+=2:te++){if(H=Rs(c,te),H===zs)de=!0,Ue&&(ge=ge||te-rt-1>k&&c[rt+1]!==" ",rt=te);else if(!Ls(H))return ja;Te=Te&&jh(H,ve,o),ve=H}ge=ge||Ue&&te-rt-1>k&&c[rt+1]!==" "}return!de&&!ge?Te&&!B&&!P(c)?Zh:O===Ds?ja:wc:T>9&&qh(c)?ja:B?O===Ds?ja:wc:ge?Hh:Gh}function Gg(c,x,T,k,P){c.dump=(function(){if(x.length===0)return c.quotingType===Ds?'""':"''";if(!c.noCompatMode&&(Fg.indexOf(x)!==-1||Bg.test(x)))return c.quotingType===Ds?'"'+x+'"':"'"+x+"'";var O=c.indent*Math.max(1,T),B=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-O),o=k||c.flowLevel>-1&&T>=c.flowLevel;function te(H){return $g(c,H)}switch(Zg(x,o,c.indent,B,te,c.quotingType,c.forceQuotes&&!k,P)){case Zh:return x;case wc:return"'"+x.replace(/'/g,"''")+"'";case Gh:return"|"+Wh(x,c.indent)+Xh(Uh(x,O));case Hh:return">"+Wh(x,c.indent)+Xh(Uh(Hg(x,B),O));case ja:return'"'+Wg(x)+'"';default:throw new Zi("impossible error: invalid scalar style")}})()}function Wh(c,x){var T=qh(c)?String(x):"",k=c[c.length-1]===`
`,P=k&&(c[c.length-2]===`
`||c===`
`),O=P?"+":k?"":"-";return T+O+`
`}function Xh(c){return c[c.length-1]===`
`?c.slice(0,-1):c}function Hg(c,x){for(var T=/(\n+)([^\n]*)/g,k=(function(){var H=c.indexOf(`
`);return H=H!==-1?H:c.length,T.lastIndex=H,Kh(c.slice(0,H),x)})(),P=c[0]===`
`||c[0]===" ",O,B;B=T.exec(c);){var o=B[1],te=B[2];O=te[0]===" ",k+=o+(!P&&!O&&te!==""?`
`:"")+Kh(te,x),P=O}return k}function Kh(c,x){if(c===""||c[0]===" ")return c;for(var T=/ [^ ]/g,k,P=0,O,B=0,o=0,te="";k=T.exec(c);)o=k.index,o-P>x&&(O=B>P?B:o,te+=`
`+c.slice(P,O),P=O+1),B=o;return te+=`
`,c.length-P>x&&B>P?te+=c.slice(P,B)+`
`+c.slice(B+1):te+=c.slice(P),te.slice(1)}function Wg(c){for(var x="",T=0,k,P=0;P<c.length;T>=65536?P+=2:P++)T=Rs(c,P),k=zi[T],!k&&Ls(T)?(x+=c[P],T>=65536&&(x+=c[P+1])):x+=k||Ng(T);return x}function Xg(c,x,T){var k="",P=c.tag,O,B,o;for(O=0,B=T.length;O<B;O+=1)o=T[O],c.replacer&&(o=c.replacer.call(T,String(O),o)),(fn(c,x,o,!1,!1)||typeof o>"u"&&fn(c,x,null,!1,!1))&&(k!==""&&(k+=","+(c.condenseFlow?"":" ")),k+=c.dump);c.tag=P,c.dump="["+k+"]"}function Yh(c,x,T,k){var P="",O=c.tag,B,o,te;for(B=0,o=T.length;B<o;B+=1)te=T[B],c.replacer&&(te=c.replacer.call(T,String(B),te)),(fn(c,x+1,te,!0,!0,!1,!0)||typeof te>"u"&&fn(c,x+1,null,!0,!0,!1,!0))&&((!k||P!=="")&&(P+=bc(c,x)),c.dump&&zs===c.dump.charCodeAt(0)?P+="-":P+="- ",P+=c.dump);c.tag=O,c.dump=P||"[]"}function Kg(c,x,T){var k="",P=c.tag,O=Object.keys(T),B,o,te,H,ve;for(B=0,o=O.length;B<o;B+=1)ve="",k!==""&&(ve+=", "),c.condenseFlow&&(ve+='"'),te=O[B],H=T[te],c.replacer&&(H=c.replacer.call(T,te,H)),fn(c,x,te,!1,!1)&&(c.dump.length>1024&&(ve+="? "),ve+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),fn(c,x,H,!1,!1)&&(ve+=c.dump,k+=ve));c.tag=P,c.dump="{"+k+"}"}function Yg(c,x,T,k){var P="",O=c.tag,B=Object.keys(T),o,te,H,ve,de,ge;if(c.sortKeys===!0)B.sort();else if(typeof c.sortKeys=="function")B.sort(c.sortKeys);else if(c.sortKeys)throw new Zi("sortKeys must be a boolean or a function");for(o=0,te=B.length;o<te;o+=1)ge="",(!k||P!=="")&&(ge+=bc(c,x)),H=B[o],ve=T[H],c.replacer&&(ve=c.replacer.call(T,H,ve)),fn(c,x+1,H,!0,!0,!0)&&(de=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024,de&&(c.dump&&zs===c.dump.charCodeAt(0)?ge+="?":ge+="? "),ge+=c.dump,de&&(ge+=bc(c,x)),fn(c,x+1,ve,!0,de)&&(c.dump&&zs===c.dump.charCodeAt(0)?ge+=":":ge+=": ",ge+=c.dump,P+=ge));c.tag=O,c.dump=P||"{}"}function Jh(c,x,T){var k,P,O,B,o,te;for(P=T?c.explicitTypes:c.implicitTypes,O=0,B=P.length;O<B;O+=1)if(o=P[O],(o.instanceOf||o.predicate)&&(!o.instanceOf||typeof x=="object"&&x instanceof o.instanceOf)&&(!o.predicate||o.predicate(x))){if(T?o.multi&&o.representName?c.tag=o.representName(x):c.tag=o.tag:c.tag="?",o.represent){if(te=c.styleMap[o.tag]||o.defaultStyle,Lh.call(o.represent)==="[object Function]")k=o.represent(x,te);else if(Rh.call(o.represent,te))k=o.represent[te](x,te);else throw new Zi("!<"+o.tag+'> tag resolver accepts not "'+te+'" style');c.dump=k}return!0}return!1}function fn(c,x,T,k,P,O,B){c.tag=null,c.dump=T,Jh(c,T,!1)||Jh(c,T,!0);var o=Lh.call(c.dump),te=k,H;k&&(k=c.flowLevel<0||c.flowLevel>x);var ve=o==="[object Object]"||o==="[object Array]",de,ge;if(ve&&(de=c.duplicates.indexOf(T),ge=de!==-1),(c.tag!==null&&c.tag!=="?"||ge||c.indent!==2&&x>0)&&(P=!1),ge&&c.usedDuplicates[de])c.dump="*ref_"+de;else{if(ve&&ge&&!c.usedDuplicates[de]&&(c.usedDuplicates[de]=!0),o==="[object Object]")k&&Object.keys(c.dump).length!==0?(Yg(c,x,c.dump,P),ge&&(c.dump="&ref_"+de+c.dump)):(Kg(c,x,c.dump),ge&&(c.dump="&ref_"+de+" "+c.dump));else if(o==="[object Array]")k&&c.dump.length!==0?(c.noArrayIndent&&!B&&x>0?Yh(c,x-1,c.dump,P):Yh(c,x,c.dump,P),ge&&(c.dump="&ref_"+de+c.dump)):(Xg(c,x,c.dump),ge&&(c.dump="&ref_"+de+" "+c.dump));else if(o==="[object String]")c.tag!=="?"&&Gg(c,c.dump,x,O,te);else{if(o==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new Zi("unacceptable kind of an object to dump "+o)}c.tag!==null&&c.tag!=="?"&&(H=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21"),c.tag[0]==="!"?H="!"+H:H.slice(0,18)==="tag:yaml.org,2002:"?H="!!"+H.slice(18):H="!<"+H+">",c.dump=H+" "+c.dump)}return!0}function Jg(c,x){var T=[],k=[],P,O;for(Sc(c,T,k),P=0,O=k.length;P<O;P+=1)x.duplicates.push(T[k[P]]);x.usedDuplicates=new Array(O)}function Sc(c,x,T){var k,P,O;if(c!==null&&typeof c=="object")if(P=x.indexOf(c),P!==-1)T.indexOf(P)===-1&&T.push(P);else if(x.push(c),Array.isArray(c))for(P=0,O=c.length;P<O;P+=1)Sc(c[P],x,T);else for(k=Object.keys(c),P=0,O=k.length;P<O;P+=1)Sc(c[k[P]],x,T)}function Qg(c,x){x=x||{};var T=new Ug(x);T.noRefs||Jg(c,T);var k=c;return T.replacer&&(k=T.replacer.call({"":k},"",k)),fn(T,0,k,!0,!0)?T.dump+`
`:""}var e_=Qg,t_={dump:e_};function Tc(c,x){return function(){throw new Error("Function yaml."+c+" is removed in js-yaml 4. Use yaml."+x+" instead, which is now safe by default.")}}var i_=Ti,r_=Qu,n_=rh,a_=lh,s_=ch,o_=mc,l_=Dh.load,c_=Dh.loadAll,u_=t_.dump,h_=Zi,p_={binary:fh,float:oh,map:ih,null:nh,pairs:gh,set:_h,timestamp:ph,bool:ah,int:sh,merge:dh,omap:mh,seq:th,str:eh},d_=Tc("safeLoad","load"),f_=Tc("safeLoadAll","loadAll"),m_=Tc("safeDump","dump"),Qh={Type:i_,Schema:r_,FAILSAFE_SCHEMA:n_,JSON_SCHEMA:a_,CORE_SCHEMA:s_,DEFAULT_SCHEMA:o_,load:l_,loadAll:c_,dump:u_,YAMLException:h_,types:p_,safeLoad:d_,safeLoadAll:f_,safeDump:m_};function g_(c={}){const{defaultCenter:x={lat:43.836699,lon:4.360054},defaultZoom:T=13,onSave:k=()=>{}}=c,P=Vue.ref({...x}),O=Vue.ref(T),B=Vue.ref(null);Vue.onBeforeUnmount(()=>{B.value&&clearTimeout(B.value)});function o(ve){if(!ve||ve.trim()==="")return null;try{const de=Qh.load(ve);if(de)return de.center&&(P.value={lat:de.center.lat,lon:de.center.lon}),de.zoom!==void 0&&(O.value=de.zoom),de}catch(de){return console.error("Error loading map data:",de),null}return null}function te(){const ve={background:{type:"osm"},center:{lat:P.value.lat,lon:P.value.lon},zoom:O.value},de=Qh.dump(ve,{indent:2,lineWidth:-1,noRefs:!0});return k(de),de}function H(ve=300){B.value&&clearTimeout(B.value),B.value=setTimeout(()=>{te()},ve)}return{center:P,zoom:O,loadMapData:o,saveMapData:te,debouncedSave:H}}const __={components:{MapPreview:Bf,MarkerList:Xf},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:c=>["multi","single"].includes(c)},latitude:{type:[Number,String],default:null},longitude:{type:[Number,String],default:null},markerIconUrl:{type:String,default:null},markerIconSize:{type:Number,default:40}},setup(c,{emit:x}){const T=Vue.ref(!1),k=Vue.ref(null),P=Vue.ref(null),O=Vue.ref(!0),B=Vue.computed(()=>{var pt;if(c.mode==="single")return null;const Le=window.location.pathname.match(/\/panel\/pages\/(.+)/);if(Le)return Le[1].replace(/\+/g,"/");const qe=(pt=c.name)==null?void 0:pt.match(/pages\/([^/]+)/);return qe?qe[1].replace(/\+/g,"/"):(console.warn("Could not extract page ID, using default"),"map/carte")}),o=c.mode==="multi"?Kf(B.value):{markers:Vue.ref([]),loading:Vue.ref(!1),error:Vue.ref(null)},{center:te,zoom:H,loadMapData:ve,saveMapData:de,debouncedSave:ge}=g_({defaultCenter:{lat:c.defaultCenter[0],lon:c.defaultCenter[1]},defaultZoom:c.defaultZoom,onSave:Le=>x("input",Le)}),Ue=Vue.computed(()=>{if(c.mode==="single"){const Le=Te.value,qe=Be.value;return!isNaN(Le)&&!isNaN(qe)&&Le!==null&&qe!==null&&Le!==0&&qe!==0?[{id:"single-marker",position:{lat:Le,lon:qe},title:"Current position",iconUrl:c.markerIconUrl,iconSize:c.markerIconSize}]:[]}return o.markers.value}),rt=Vue.computed(()=>c.mode==="single"?!1:Ue.value.length<c.maxMarkers),Te=Vue.ref(null),Be=Vue.ref(null);function Ze(){const Le=document.querySelector(".k-form");if(!Le)return{lat:null,lon:null};const qe=Le.querySelector('input[name*="latitude"]'),pt=Le.querySelector('input[name*="longitude"]');return{lat:qe?parseFloat(qe.value):null,lon:pt?parseFloat(pt.value):null}}Vue.onMounted(async()=>{if(c.mode==="multi")try{await o.fetchMarkers()}catch(Le){console.error("Failed to load markers:",Le)}else if(c.mode==="single"){const Le=Ze();Te.value=Le.lat,Be.value=Le.lon,!isNaN(Le.lat)&&!isNaN(Le.lon)&&Le.lat!==0&&Le.lon!==0&&(te.value={lat:Le.lat,lon:Le.lon});const qe=document.querySelector(".k-form");if(qe){qe.addEventListener("input",Rt=>{if(Rt.target.name&&(Rt.target.name.includes("latitude")||Rt.target.name.includes("longitude"))){const Sr=Ze();Te.value=Sr.lat,Be.value=Sr.lon}});const pt=qe.querySelector('input[name*="latitude"]'),$t=qe.querySelector('input[name*="longitude"]');if(pt&&$t){const Rt=new MutationObserver(()=>{const Li=Ze();(Li.lat!==Te.value||Li.lon!==Be.value)&&(Te.value=Li.lat,Be.value=Li.lon)});Rt.observe(pt,{attributes:!0,attributeFilter:["value"]}),Rt.observe($t,{attributes:!0,attributeFilter:["value"]});const Sr=setInterval(()=>{const Li=Ze();(Li.lat!==Te.value||Li.lon!==Be.value)&&(Te.value=Li.lat,Be.value=Li.lon)},500);Vue.onBeforeUnmount(()=>{Rt.disconnect(),clearInterval(Sr)})}}}c.value&&c.mode==="multi"&&ve(c.value),await Vue.nextTick(),T.value=!0,await Vue.nextTick(),O.value=!1,c.mode==="multi"&&await Yr()}),Vue.watch([te,H],()=>{c.mode==="multi"&&!O.value&&ge()},{deep:!0}),Vue.watch(()=>[Te.value,Be.value],([Le,qe])=>{c.mode==="single"&&(!isNaN(Le)&&!isNaN(qe)&&Le!==null&&qe!==null&&Le!==0&&qe!==0?Vue.nextTick(()=>{k.value&&k.value.centerOnPosition&&k.value.centerOnPosition(Le,qe)}):(te.value={lat:c.defaultCenter[0],lon:c.defaultCenter[1]},Vue.nextTick(()=>{k.value&&k.value.centerOnPosition&&k.value.centerOnPosition(te.value.lat,te.value.lon)})))});function He(){return k.value&&k.value.getCurrentCenter?k.value.getCurrentCenter():{lat:te.value.lat,lon:te.value.lon}}async function Et(){if(!rt.value||c.mode==="single")return;const Le=He(),qe={lat:Le.lat,lon:Le.lon||Le.lng};try{await o.createMarker(qe)}catch(pt){console.error("Failed to create marker:",pt)}}async function Di(Le){if(!(!rt.value||c.mode==="single"))try{await o.createMarker({lat:Le.lat,lon:Le.lng})}catch(qe){console.error("Failed to create marker:",qe)}}function Kr(Le){P.value=Le;const qe=Ue.value.find(pt=>pt.id===Le);qe&&k.value&&k.value.centerOnPosition&&k.value.centerOnPosition(qe.position.lat,qe.position.lon)}async function ar({markerId:Le,position:qe}){if(c.mode==="single"){const pt=document.querySelector(".k-form");if(pt){const $t=pt.querySelector('input[name*="latitude"]'),Rt=pt.querySelector('input[name*="longitude"]');$t&&Rt&&($t.value=qe.lat,Rt.value=qe.lng,$t.dispatchEvent(new Event("input",{bubbles:!0})),Rt.dispatchEvent(new Event("input",{bubbles:!0})),Te.value=qe.lat,Be.value=qe.lng)}}else try{await o.updateMarkerPosition(Le,{lat:qe.lat,lon:qe.lng})}catch(pt){console.error("Failed to update marker position:",pt)}}function mn(Le){if(c.mode==="single")return;const qe=Ue.value.find(pt=>pt.id===Le);qe&&qe.panelUrl&&(window.top.location.href=qe.panelUrl)}async function ii(Le){if(c.mode!=="single"&&confirm("Supprimer ce marqueur ?"))try{await o.deleteMarker(Le),P.value===Le&&(P.value=null)}catch(qe){console.error("Failed to delete marker:",qe)}}function Vn(Le){k.value&&k.value.centerOnPosition&&k.value.centerOnPosition(Le.lat,Le.lon)}function Mt(){if(!k.value)return;const Le=k.value.getCurrentCenter?k.value.getCurrentCenter():{lat:te.value.lat,lon:te.value.lon},qe=k.value.getCurrentZoom?k.value.getCurrentZoom():H.value;te.value={lat:Le.lat,lon:Le.lon},H.value=qe,de()}async function Yr(){if(B.value)try{const qe=await(await fetch(`/api/map-editor/pages/${B.value}/check-regenerate-flag`)).json();qe.status==="success"&&qe.data.needsRegeneration&&(console.log("Regeneration flag detected, waiting for map to be ready..."),await Gi(),console.log("Map ready, capturing image..."),await wr(),await fetch(`/api/map-editor/pages/${B.value}/clear-regenerate-flag`,{method:"DELETE"}),console.log("Map image regenerated successfully"))}catch(Le){console.error("Error checking/regenerating map image:",Le)}}async function Gi(Le=10){var qe,pt;for(let $t=0;$t<Le;$t++){if((pt=(qe=k.value)==null?void 0:qe.map)!=null&&pt.loaded&&k.value.map.loaded())return await new Promise(Rt=>setTimeout(Rt,500)),!0;await new Promise(Rt=>setTimeout(Rt,500))}throw new Error("Map failed to load within timeout")}async function wr(){if(!k.value||!k.value.captureMapImage){console.warn("Map preview not ready for capture");return}try{console.log("Starting image capture...");const Le=await Promise.race([k.value.captureMapImage(),new Promise(($t,Rt)=>setTimeout(()=>Rt(new Error("Capture timeout after 10s")),1e4))]);console.log("Image captured, size:",Le.length,"bytes"),console.log("Sending to API:",`/api/map-editor/pages/${B.value}/capture-image`);const qe=await fetch(`/api/map-editor/pages/${B.value}/capture-image`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:Le})});console.log("Response status:",qe.status);const pt=await qe.json();if(console.log("Response data:",pt),pt.status==="error")throw new Error(pt.message||"Failed to save map image");console.log("Map image saved successfully:",pt.data.filename)}catch(Le){throw console.error("Error capturing and saving map image:",Le),Le}}return{center:te,zoom:H,markers:Ue,selectedMarkerId:P,mapReady:T,mapPreview:k,canAddMarker:rt,loading:o.loading,error:o.error,handleAddMarker:Et,handleMapClick:Di,handleSelectMarker:Kr,handleMarkerMoved:ar,handleLocationSelect:Vn,deleteMarker:ii,editMarker:mn,saveCurrentFraming:Mt}}};var y_=function(){var x=this,T=x._self._c;return T("k-field",x._b({staticClass:"k-map-editor-field"},"k-field",x.$props,!1),[T("div",{staticClass:"map-editor-container"},[T("div",{staticClass:"map-content",class:{"single-mode":x.mode==="single"}},[x.mode==="multi"?T("MarkerList",{attrs:{markers:x.markers,"selected-marker-id":x.selectedMarkerId,"max-markers":x.maxMarkers},on:{"add-marker":x.handleAddMarker,"select-marker":x.handleSelectMarker,"edit-marker":x.editMarker,"delete-marker":x.deleteMarker,"select-location":x.handleLocationSelect}}):x._e(),T("div",{staticClass:"map-preview-container"},[x.mode==="multi"?T("button",{staticClass:"save-framing-button",attrs:{type:"button",title:"Utiliser le niveau de zoom et centrage actuel comme cadrage par défaut"},on:{click:x.saveCurrentFraming}},[x._v(" Définir le cadrage ")]):x._e(),x.mapReady?T("MapPreview",{ref:"mapPreview",attrs:{center:x.center,zoom:x.zoom,markers:x.markers,"selected-marker-id":x.selectedMarkerId},on:{"marker-moved":x.handleMarkerMoved,"map-click":x.handleMapClick,"marker-click":x.handleSelectMarker,"marker-dblclick":x.editMarker}}):x._e()],1)],1)])])},x_=[],v_=Ho(__,y_,x_,!1,null,null);const b_=v_.exports;window.panel.plugin("geoproject/map-editor",{fields:{"map-editor":b_}})})();