@mapcreator/mapcreator-gl 5.0.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/lib.js +2 -1
- package/dist/lib/lib.js.LICENSE.txt +4 -0
- package/dist/lib/lib.js.map +1 -1
- package/dist/lib/style.css +2 -2
- package/dist/lib/style.css.map +1 -1
- package/package.json +8 -9
- package/readme.md +2 -2
package/dist/lib/lib.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var t={527:function(t){t.exports=function(){var t,e,i;function r(r,n){if(t)if(e){var o="var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk);",a={};t(a),i=n(a),"undefined"!=typeof window&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=n;else t=n}return r(["exports"],(function(t){var e=i;function i(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}function r(t,i,r,n){const o=new e(t,i,r,n);return function(t){return o.solve(t)}}i.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var a=0,s=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?a=i:s=i,i=.5*(s-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};const n=r(.25,.1,.25,1);function o(t,e,i){return Math.min(i,Math.max(e,t))}function a(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function s(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let l=1;function c(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function h(t,e,i){const r={};for(const n in t)r[n]=e.call(i||this,t[n],n,t);return r}function u(t,e,i){const r={};for(const n in t)e.call(i||this,t[n],n,t)&&(r[n]=t[n]);return r}function p(t){return Array.isArray(t)?t.map(p):"object"==typeof t&&t?h(t,p):t}const d={};function m(t){d[t]||("undefined"!=typeof console&&console.warn(t),d[t]=!0)}function f(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function g(t){let e=0;for(let i,r,n=0,o=t.length,a=o-1;n<o;a=n++)i=t[n],r=t[a],e+=(r.x-i.x)*(i.y+r.y);return e}function _(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function y(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const o=r||n;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let x,v,b=null;function w(t){if(null==b){const e=t.navigator?t.navigator.userAgent:null;b=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return b}function T(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const E={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const i=window.document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return i.width=t.width,i.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:t=>(x||(x=document.createElement("a")),x.href=t,x.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==v&&(v=matchMedia("(prefers-reduced-motion: reduce)")),v.matches)},dynamicScale:1,detailLevel:0};var S=A;function A(t,e){this.x=t,this.y=e}A.prototype={clone:function(){return new A(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},A.convert=function(t){return t instanceof A?t:Array.isArray(t)?new A(t[0],t[1]):t};const I={MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},C="mapbox-tiles";let M,k,P=500,z=50;function L(){"undefined"==typeof caches||M||(M=caches.open(C))}let D=1/0;const B={supported:!1,testSupport:function(t){!O&&F&&(U?V(t):R=t)}};let R,F,O=!1,U=!1;function V(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,F),t.isContextLost())return;B.supported=!0}catch(t){}t.deleteTexture(e),O=!0}"undefined"!=typeof document&&(F=document.createElement("img"),F.onload=function(){R&&V(R),R=null,U=!0},F.onerror=function(){O=!0,R=null},F.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const N={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(N);class $ extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const G=_()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href;function j(t,e){const i=new AbortController,r=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:G(),signal:i.signal});let n=!1,o=!1;return"json"===t.type&&r.headers.set("Accept","application/json"),((i,a,s)=>{if(o)return;const l=Date.now();fetch(r).then((i=>i.ok?((i,a,s)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{o||(a&&s&&function(t,e,i){if(L(),!M)return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const n=y(e.headers.get("Cache-Control")||"");n["no-store"]||(n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-i<42e4||function(t,e){if(void 0===k)try{new Response(new ReadableStream),k=!0}catch(t){k=!1}k?e(t.body):t.blob().then(e)}(e,(e=>{const i=new Response(e,r);L(),M&&M.then((e=>e.put(function(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}(t.url),i))).catch((t=>m(t.message)))})))}(r,a,s),n=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{o||e(new Error(t.message))}))})(i,null,l):i.blob().then((r=>e(new $(i.status,i.statusText,t.url,r)))))).catch((t=>{20!==t.code&&e(new Error(t.message))}))})(),{cancel:()=>{o=!0,n||i.abort()}}}const q=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(_()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!_()){const i=t.url.substring(0,t.url.indexOf("://"));return(I.REGISTERED_PROTOCOLS[i]||j)(t,e)}}if(!(/^file:/.test(i=t.url)||/^file:/.test(G())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return j(t,e);if(_()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else{const r=new Blob([i.response],{type:i.getResponseHeader("Content-Type")});e(new $(i.status,i.statusText,t.url,r))}},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},Z=function(t,e){return q(s(t,{type:"arrayBuffer"}),e)};function X(t){const e=window.document.createElement("a");return e.href=t,e.protocol===window.document.location.protocol&&e.host===window.document.location.host}const W="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let H,K;H=[],K=0;const Y=function(t,e){if(B.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),K>=I.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return H.push(i),i}K++;let i=!1;const r=()=>{if(!i)for(i=!0,K--;H.length&&K<I.MAX_PARALLEL_IMAGE_REQUESTS;){const t=H.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=Y(e,i).cancel)}},n=Z(t,((t,i,n,o)=>{r(),t?e(t):i&&function(t,e){"function"==typeof createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(t,e):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame((()=>{i.src=W}))},i.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 r=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(r):W}(t,e)}(i,((t,i)=>{null!=t?e(t):null!=i&&e(null,i,{cacheControl:n,expires:o})}))}));return{cancel:()=>{n.cancel(),r()}}};function J(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Q(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class tt{constructor(t,e={}){s(this,e),this.type=t}}class et extends tt{constructor(t,e={}){super("error",s({error:t},e))}}class it{on(t,e){return this._listeners=this._listeners||{},J(t,e,this._listeners),this}off(t,e){return Q(t,e,this._listeners),Q(t,e,this._oneTimeListeners),this}once(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},J(t,e,this._oneTimeListeners),this}fire(t,e){"string"==typeof t&&(t=new tt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)Q(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(s(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof et&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var rt={$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:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1},elevationOffset:{type:"number",default:450}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};class nt{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function ot(t){const e=t.value;return e?[new nt(t.key,e,"constants have been deprecated as of v8")]:[]}function at(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function st(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function lt(t){if(Array.isArray(t))return t.map(lt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=lt(t[i]);return e}return st(t)}class ct extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class ht{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new ht(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const ut={kind:"null"},pt={kind:"number"},dt={kind:"string"},mt={kind:"boolean"},ft={kind:"color"},gt={kind:"object"},_t={kind:"value"},yt={kind:"collator"},xt={kind:"formatted"},vt={kind:"padding"},bt={kind:"resolvedImage"};function wt(t,e){return{kind:"array",itemType:t,N:e}}function Tt(t){if("array"===t.kind){const e=Tt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Et=[ut,pt,dt,mt,ft,xt,gt,wt(_t),vt,bt];function St(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!St(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Et)if(!St(t,e))return null}return`Expected ${Tt(t)} but found ${Tt(e)} instead.`}function At(t,e){return e.some((e=>e.kind===t.kind))}function It(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}var Ct,Mt={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function kt(t){return(t=Math.round(t))<0?0:t>255?255:t}function Pt(t){return kt("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function zt(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Lt(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Ct={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Mt)return Mt[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),a=i.substr(r+1,n-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=zt(a.pop());case"rgb":return 3!==a.length?null:[Pt(a[0]),Pt(a[1]),Pt(a[2]),s];case"hsla":if(4!==a.length)return null;s=zt(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,c=zt(a[1]),h=zt(a[2]),u=h<=.5?h*(c+1):h+c-h*c,p=2*h-u;return[kt(255*Lt(p,u,l+1/3)),kt(255*Lt(p,u,l)),kt(255*Lt(p,u,l-1/3)),s];default:return null}}return null}}catch(t){}class Dt{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Dt)return t;if("string"!=typeof t)return;const e=Ct(t);return e?new Dt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}Dt.black=new Dt(0,0,0,1),Dt.white=new Dt(1,1,1,1),Dt.transparent=new Dt(0,0,0,0),Dt.red=new Dt(1,0,0,1);class Bt{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Rt{constructor(t,e,i,r,n){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n}}class Ft{constructor(t){this.sections=t}static fromString(t){return new Ft([new Rt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Ft?t:Ft.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Ot{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ot)return t;if("number"==typeof t)return new Ot([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Ot(t)}}toString(){return JSON.stringify(this.values)}}class Ut{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ut({name:t,available:!1}):null}}function Vt(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Dt)return!0;if(t instanceof Bt)return!0;if(t instanceof Ft)return!0;if(t instanceof Ot)return!0;if(t instanceof Ut)return!0;if(Array.isArray(t)){for(const e of t)if(!Nt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Nt(t[e]))return!1;return!0}return!1}function $t(t){if(null===t)return ut;if("string"==typeof t)return dt;if("boolean"==typeof t)return mt;if("number"==typeof t)return pt;if(t instanceof Dt)return ft;if(t instanceof Bt)return yt;if(t instanceof Ft)return xt;if(t instanceof Ot)return vt;if(t instanceof Ut)return bt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=$t(e);if(i){if(i===t)continue;i=_t;break}i=t}return wt(i||_t,e)}return gt}function Gt(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Dt||t instanceof Ft||t instanceof Ot||t instanceof Ut?t.toString():JSON.stringify(t)}class jt{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Nt(t[1]))return e.error("invalid value");const i=t[1];let r=$t(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new jt(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class qt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Zt={string:dt,number:pt,boolean:mt,object:gt};class Xt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,o;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in Zt)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=Zt[i],r++}else n=_t;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],r++}i=wt(n,o)}else{if(!Zt[n])throw new Error(`Types doesn't contain name = ${n}`);i=Zt[n]}const o=[];for(;r<t.length;r++){const i=e.parse(t[r],r,_t);if(!i)return null;o.push(i)}return new Xt(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!St(this.type,$t(i)))return i;if(e===this.args.length-1)throw new qt(`Expected value to be of type ${Tt(this.type)}, but found ${Tt($t(i))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Wt={"to-boolean":mt,"to-color":ft,"to-number":pt,"to-string":dt};class Ht{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(!Wt[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Wt[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,_t);if(!r)return null;n.push(r)}return new Ht(r,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof Dt)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Vt(e[0],e[1],e[2],e[3]),!i))return new Dt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new qt(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}if("padding"===this.type.kind){let e;for(const i of this.args){e=i.evaluate(t);const r=Ot.parse(e);if(r)return r}throw new qt(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new qt(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Ft.fromString(Gt(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Ut.fromString(Gt(this.args[0].evaluate(t))):Gt(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Kt=["Unknown","Point","LineString","Polygon"];class Yt{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?"number"==typeof this.feature.type?Kt[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(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Dt.parse(t)),e}}class Jt{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],r=Jt.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let s=null;for(const[r,o]of a){s=new be(e.registry,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,o=s.parse(i,1+a.length,n);if(!o){l=!0;break}a.push(o)}if(!l)if(Array.isArray(r)&&r.length!==a.length)s.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let t=0;t<a.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=a[t];s.concat(t+1).checkSubtype(e,i.type)}if(0===s.errors.length)return new Jt(i,n,o,a)}}if(1===a.length)e.errors.push(...s.errors);else{const i=(a.length?a:o).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Tt).join(", ")})`:`(${Tt(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(Tt(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){Jt.definitions=e;for(const i in e)t[i]=Jt}}class Qt{constructor(t,e,i){this.type=yt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,mt);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,mt);if(!n)return null;let o=null;return i.locale&&(o=e.parse(i.locale,1,dt),!o)?null:new Qt(r,n,o)}evaluate(t){return new Bt(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}const te=8192;function ee(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function ie(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function re(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*te),Math.round(r*n*te)]}function ne(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],o=t[0]-i[0],a=t[1]-i[1];return r*a-o*n==0&&r*o<=0&&n*a<=0}function oe(t,e){let i=!1;for(let a=0,s=e.length;a<s;a++){const s=e[a];for(let e=0,a=s.length;e<a-1;e++){if(ne(t,s[e],s[e+1]))return!1;(n=s[e])[1]>(r=t)[1]!=(o=s[e+1])[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function ae(t,e){for(let i=0;i<e.length;i++)if(oe(t,e[i]))return!0;return!1}function se(t,e,i,r){const n=r[0]-i[0],o=r[1]-i[1],a=(t[0]-i[0])*o-n*(t[1]-i[1]),s=(e[0]-i[0])*o-n*(e[1]-i[1]);return a>0&&s<0||a<0&&s>0}function le(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(s=[(a=c[i+1])[0]-(o=c[i])[0],a[1]-o[1]])[0]*(l=[(n=e)[0]-(r=t)[0],n[1]-r[1]])[1]-s[1]*l[0]&&se(r,n,o,a)&&se(o,a,r,n))return!0;var r,n,o,a,s,l;return!1}function ce(t,e){for(let i=0;i<t.length;++i)if(!oe(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(le(t[i],t[i+1],e))return!1;return!0}function he(t,e){for(let i=0;i<e.length;i++)if(ce(t,e[i]))return!0;return!1}function ue(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=[];for(let r=0;r<t[n].length;r++){const a=re(t[n][r],i);ee(e,a),o.push(a)}r.push(o)}return r}function pe(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=ue(t[n],e,i);r.push(o)}return r}function de(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}ee(e,t)}function me(t,e,i,r){const n=Math.pow(2,r.z)*te,o=[r.x*te,r.y*te],a=[];for(const r of t)for(const t of r){const r=[t.x+o[0],t.y+o[1]];de(r,e,i,n),a.push(r)}return a}function fe(t,e,i,r){const n=Math.pow(2,r.z)*te,o=[r.x*te,r.y*te],a=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];ee(e,i),t.push(i)}a.push(t)}if(e[2]-e[0]<=n/2){(s=e)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const t of a)for(const r of t)de(r,e,i,n)}var s;return a}class ge{constructor(t,e){this.type=mt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Nt(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new ge(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new ge(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new ge(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=ue(e.coordinates,r,n),a=me(t.geometry(),i,r,n);if(!ie(i,r))return!1;for(const t of a)if(!oe(t,o))return!1}if("MultiPolygon"===e.type){const o=pe(e.coordinates,r,n),a=me(t.geometry(),i,r,n);if(!ie(i,r))return!1;for(const t of a)if(!ae(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=ue(e.coordinates,r,n),a=fe(t.geometry(),i,r,n);if(!ie(i,r))return!1;for(const t of a)if(!ce(t,o))return!1}if("MultiPolygon"===e.type){const o=pe(e.coordinates,r,n),a=fe(t.geometry(),i,r,n);if(!ie(i,r))return!1;for(const t of a)if(!he(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}function _e(t){if(t instanceof Jt){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof ge)return!1;let e=!0;return t.eachChild((t=>{e&&!_e(t)&&(e=!1)})),e}function ye(t){if(t instanceof Jt&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!ye(t)&&(e=!1)})),e}function xe(t,e){if(t instanceof Jt&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!xe(t,e)&&(i=!1)})),i}class ve{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ve(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class be{constructor(t,e=[],i,r=new ht,n=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new Xt(e,[t]):"coerce"===i?new Ht(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind)if("padding"!==t.kind||"value"!==n.kind&&"number"!==n.kind&&"array"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof jt)&&"resolvedImage"!==r.type.kind&&we(r)){const e=new Yt;try{r=new jt(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new be(this.registry,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new ct(i,t))}checkSubtype(t,e){const i=St(t,e);return i&&this.error(i),i}}function we(t){if(t instanceof ve)return we(t.boundExpression);if(t instanceof Jt&&"error"===t.name)return!1;if(t instanceof Qt)return!1;if(t instanceof ge)return!1;const e=t instanceof Ht||t instanceof Xt;let i=!0;return t.eachChild((t=>{i=e?i&&we(t):i&&t instanceof jt})),!!i&&_e(t)&&xe(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Te(t,e){const i=t.length-1;let r,n,o=0,a=i,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=t[s],n=t[s+1],r<=e){if(s===i||e<n)return s;o=s+1}else{if(!(r>e))throw new qt("Input is not a number.");a=s-1}return 0}class Ee{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,pt);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const o=1===i?-1/0:t[i],a=t[i+1],s=i,l=i+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(r.length&&r[r.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(a,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Ee(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[Te(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Se(t,e,i){return t*(1-i)+e*i}var Ae=Object.freeze({__proto__:null,number:Se,color:function(t,e,i){return new Dt(Se(t.r,e.r,i),Se(t.g,e.g,i),Se(t.b,e.b,i),Se(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>Se(t,e[r],i)))},padding:function(t,e,i){const r=t.values,n=e.values;return new Ot([Se(r[0],n[0],i),Se(r[1],n[1],i),Se(r[2],n[2],i),Se(r[3],n[3],i)])}});const Ie=.95047,Ce=1.08883,Me=4/29,ke=6/29,Pe=3*ke*ke,ze=Math.PI/180,Le=180/Math.PI;function De(t){return t>.008856451679035631?Math.pow(t,1/3):t/Pe+Me}function Be(t){return t>ke?t*t*t:Pe*(t-Me)}function Re(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Fe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Oe(t){const e=Fe(t.r),i=Fe(t.g),r=Fe(t.b),n=De((.4124564*e+.3575761*i+.1804375*r)/Ie),o=De((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-De((.0193339*e+.119192*i+.9503041*r)/Ce)),alpha:t.a}}function Ue(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Be(e),i=Ie*Be(i),r=Ce*Be(r),new Dt(Re(3.2404542*i-1.5371385*e-.4985314*r),Re(-.969266*i+1.8760108*e+.041556*r),Re(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Ve(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Ne={forward:Oe,reverse:Ue,interpolate:function(t,e,i){return{l:Se(t.l,e.l,i),a:Se(t.a,e.a,i),b:Se(t.b,e.b,i),alpha:Se(t.alpha,e.alpha,i)}}},$e={forward:function(t){const{l:e,a:i,b:r}=Oe(t),n=Math.atan2(r,i)*Le;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*ze,i=t.c;return Ue({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Ve(t.h,e.h,i),c:Se(t.c,e.c,i),l:Se(t.l,e.l,i),alpha:Se(t.alpha,e.alpha,i)}}};var Ge=Object.freeze({__proto__:null,lab:Ne,hcl:$e});class je{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,i,r,n){let o=0;if("exponential"===t.name)o=qe(i,t.base,r,n);else if("linear"===t.name)o=qe(i,1,r,n);else if("cubic-bezier"===t.name){const a=t.controlPoints;o=new e(a[0],a[1],a[2],a[3]).solve(qe(i,1,r,n))}return o}static parse(t,e){let[i,r,n,...o]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,pt),!n)return null;const a=[];let s=null;"interpolate-hcl"===i||"interpolate-lab"===i?s=ft:e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let t=0;t<o.length;t+=2){const i=o[t],r=o[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(a.length&&a[a.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,s);if(!c)return null;s=s||c.type,a.push([i,c])}return"number"===s.kind||"color"===s.kind||"padding"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new je(s,i,r,n,a):e.error(`Type ${Tt(s)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const o=Te(e,r),a=je.interpolationFactor(this.interpolation,r,e[o],e[o+1]),s=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Ae[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?$e.reverse($e.interpolate($e.forward(s),$e.forward(l),a)):Ne.reverse(Ne.interpolate(Ne.forward(s),Ne.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function qe(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}class Ze{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}if(!i)throw new Error("No output type");const o=r&&n.some((t=>St(r,t.type)));return new Ze(o?_t:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Ut&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class Xe{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=e.parse(t[r+1],r+1);if(!o)return null;i.push([n,o])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Xe(i,r):null}outputDefined(){return this.result.outputDefined()}}class We{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,pt),r=e.parse(t[2],2,wt(e.expectedType||_t));return i&&r?new We(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new qt(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new qt(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new qt(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class He{constructor(t,e){this.type=mt,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,_t),r=e.parse(t[2],2,_t);return i&&r?At(i.type,[mt,dt,pt,ut,_t])?new He(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Tt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!It(e,["boolean","string","number","null"]))throw new qt(`Expected first argument to be of type boolean, string, number or null, but found ${Tt($t(e))} instead.`);if(!It(i,["string","array"]))throw new qt(`Expected second argument to be of type array or string, but found ${Tt($t(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Ke{constructor(t,e,i){this.type=pt,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,_t),r=e.parse(t[2],2,_t);if(!i||!r)return null;if(!At(i.type,[mt,dt,pt,ut,_t]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Tt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,pt);return n?new Ke(i,r,n):null}return new Ke(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!It(e,["boolean","string","number","null"]))throw new qt(`Expected first argument to be of type boolean, string, number or null, but found ${Tt($t(e))} instead.`);if(!It(i,["string","array"]))throw new qt(`Expected second argument to be of type array or string, but found ${Tt($t(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Ye{constructor(t,e,i,r,n,o){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},o=[];for(let a=2;a<t.length-1;a+=2){let s=t[a];const l=t[a+1];Array.isArray(s)||(s=[s]);const c=e.concat(a);if(0===s.length)return c.error("Expected at least one branch label.");for(const t of s){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,$t(t)))return null}else i=$t(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=o.length}const h=e.parse(l,a,r);if(!h)return null;r=r||h.type,o.push(h)}const a=e.parse(t[1],1,_t);if(!a)return null;const s=e.parse(t[t.length-1],t.length-1,r);return s?"value"!==a.type.kind&&e.concat(1).checkSubtype(i,a.type)?null:new Ye(i,r,a,n,o,s):null}evaluate(t){const e=this.input.evaluate(t);return($t(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Je{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const o=e.parse(t[n],n,mt);if(!o)return null;const a=e.parse(t[n+1],n+1,i);if(!a)return null;r.push([o,a]),i=i||a.type}const n=e.parse(t[t.length-1],t.length-1,i);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new Je(i,r,n)}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}}class Qe{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,_t),r=e.parse(t[2],2,pt);if(!i||!r)return null;if(!At(i.type,[wt(_t),dt,_t]))return e.error(`Expected first argument to be of type array or string, but found ${Tt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,pt);return n?new Qe(i.type,i,r,n):null}return new Qe(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!It(e,["string","array"]))throw new qt(`Expected first argument to be of type array or string, but found ${Tt($t(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function ti(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function ei(t,e,i,r){return 0===r.compare(e,i)}function ii(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=mt,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,_t);if(!o)return null;if(!ti(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Tt(o.type)}'.`);let a=e.parse(t[2],2,_t);if(!a)return null;if(!ti(i,a.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Tt(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Tt(o.type)}' and '${Tt(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Xt(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Xt(o.type,[a])));let s=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(s=e.parse(t[3],3,yt),!s)return null}return new n(o,a,s)}evaluate(n){const o=this.lhs.evaluate(n),a=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=$t(o),i=$t(a);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new qt(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=$t(o),i=$t(a);if("string"!==t.kind||"string"!==i.kind)return e(n,o,a)}return this.collator?i(n,o,a,this.collator.evaluate(n)):e(n,o,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const ri=ii("==",(function(t,e,i){return e===i}),ei),ni=ii("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!ei(0,e,i,r)})),oi=ii("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),ai=ii(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),si=ii("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),li=ii(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class ci{constructor(t,e,i,r,n){this.type=dt,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,pt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,dt),!n))return null;let o=null;if(r.currency&&(o=e.parse(r.currency,1,dt),!o))return null;let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,pt),!a))return null;let s=null;return r["max-fraction-digits"]&&(s=e.parse(r["max-fraction-digits"],1,pt),!s)?null:new ci(i,n,o,a,s)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class hi{constructor(t){this.type=xt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const o=t[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,pt),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,wt(dt)),!i))return null;let a=null;if(o["text-color"]&&(a=e.parse(o["text-color"],1,ft),!a))return null;const s=r[r.length-1];s.scale=t,s.font=i,s.textColor=a}else{const o=e.parse(t[i],1,_t);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new hi(r)}evaluate(t){return new Ft(this.sections.map((e=>{const i=e.content.evaluate(t);return $t(i)===bt?new Rt("",i,null,null,null):new Rt(Gt(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}}class ui{constructor(t){this.type=bt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,dt);return i?new ui(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Ut.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class pi{constructor(t){this.type=pt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Tt(i.type)} instead.`):new pi(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new qt(`Expected value to be of type string or array, but found ${Tt($t(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const di={"==":ri,"!=":ni,">":ai,"<":oi,">=":li,"<=":si,array:Xt,at:We,boolean:Xt,case:Je,coalesce:Ze,collator:Qt,format:hi,image:ui,in:He,"index-of":Ke,interpolate:je,"interpolate-hcl":je,"interpolate-lab":je,length:pi,let:Xe,literal:jt,match:Ye,number:Xt,"number-format":ci,object:Xt,slice:Qe,step:Ee,string:Xt,"to-boolean":Ht,"to-color":Ht,"to-number":Ht,"to-string":Ht,var:ve,within:ge};function mi(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const o=n?n.evaluate(t):1,a=Vt(e,i,r,o);if(a)throw new qt(a);return new Dt(e/255*o,i/255*o,r/255*o,o)}function fi(t,e){return t in e}function gi(t,e){const i=e[t];return void 0===i?null:i}function _i(t){return{type:t}}function yi(t){return{result:"success",value:t}}function xi(t){return{result:"error",value:t}}function vi(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function bi(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function wi(t){return!!t.expression&&t.expression.interpolated}function Ti(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Ei(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Si(t){return t}function Ai(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),o=t.type||(wi(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?Dt.parse:Ot.parse;(t=at({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==t.colorSpace&&!Ge[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let a,s,l;if("exponential"===o)a=ki;else if("interval"===o)a=Mi;else if("categorical"===o){a=Ci,s=Object.create(null);for(const e of t.stops)s[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Pi}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Ai(i[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:je.interpolationFactor.bind(void 0,o),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>ki({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:je.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,s,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Ii(t.default,e.default):a(t,e,n,s,l)}}}function Ii(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Ci(t,e,i,r,n){return Ii(typeof i===n?r[i]:void 0,t.default,e.default)}function Mi(t,e,i){if("number"!==Ti(i))return Ii(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=Te(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function ki(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Ti(i))return Ii(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const o=Te(t.stops.map((t=>t[0])),i),a=function(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[o][0],t.stops[o+1][0]),s=t.stops[o][1],l=t.stops[o+1][1];let c=Ae[e.type]||Si;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Ge[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),a))}return"function"==typeof s.evaluate?{evaluate(...t){const e=s.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,a)}}:c(s,l,a)}function Pi(t,e,i){switch(e.type){case"color":i=Dt.parse(i);break;case"formatted":i=Ft.fromString(i.toString());break;case"resolvedImage":i=Ut.fromString(i.toString());break;case"padding":i=Ot.parse(i);break;default:Ti(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return Ii(i,t.default,e.default)}Jt.register(di,{error:[{kind:"error"},[dt],(t,[e])=>{throw new qt(e.evaluate(t))}],typeof:[dt,[_t],(t,[e])=>Tt($t(e.evaluate(t)))],"to-rgba":[wt(pt,4),[ft],(t,[e])=>e.evaluate(t).toArray()],rgb:[ft,[pt,pt,pt],mi],rgba:[ft,[pt,pt,pt,pt],mi],has:{type:mt,overloads:[[[dt],(t,[e])=>fi(e.evaluate(t),t.properties())],[[dt,gt],(t,[e,i])=>fi(e.evaluate(t),i.evaluate(t))]]},get:{type:_t,overloads:[[[dt],(t,[e])=>gi(e.evaluate(t),t.properties())],[[dt,gt],(t,[e,i])=>gi(e.evaluate(t),i.evaluate(t))]]},"feature-state":[_t,[dt],(t,[e])=>gi(e.evaluate(t),t.featureState||{})],properties:[gt,[],t=>t.properties()],"geometry-type":[dt,[],t=>t.geometryType()],id:[_t,[],t=>t.id()],zoom:[pt,[],t=>t.globals.zoom],"heatmap-density":[pt,[],t=>t.globals.heatmapDensity||0],"line-progress":[pt,[],t=>t.globals.lineProgress||0],accumulated:[_t,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[pt,_i(pt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[pt,_i(pt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:pt,overloads:[[[pt,pt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[pt],(t,[e])=>-e.evaluate(t)]]},"/":[pt,[pt,pt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[pt,[pt,pt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[pt,[],()=>Math.LN2],pi:[pt,[],()=>Math.PI],e:[pt,[],()=>Math.E],"^":[pt,[pt,pt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[pt,[pt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))],log2:[pt,[pt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[pt,[pt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[pt,[pt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[pt,[pt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[pt,[pt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[pt,[pt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[pt,[pt],(t,[e])=>Math.atan(e.evaluate(t))],min:[pt,_i(pt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[pt,_i(pt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[pt,[pt],(t,[e])=>Math.abs(e.evaluate(t))],round:[pt,[pt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[pt,[pt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[pt,[pt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[mt,[dt,_t],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[mt,[_t],(t,[e])=>t.id()===e.value],"filter-type-==":[mt,[dt],(t,[e])=>t.geometryType()===e.value],"filter-<":[mt,[dt,_t],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[mt,[_t],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[mt,[dt,_t],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[mt,[_t],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[mt,[dt,_t],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[mt,[_t],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[mt,[dt,_t],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[mt,[_t],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[mt,[_t],(t,[e])=>e.value in t.properties()],"filter-has-id":[mt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[mt,[wt(dt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[mt,[wt(_t)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[mt,[dt,wt(_t)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[mt,[dt,wt(_t)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:mt,overloads:[[[mt,mt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[_i(mt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:mt,overloads:[[[mt,mt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[_i(mt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[mt,[mt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[mt,[dt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[dt,[dt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[dt,[dt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[dt,_i(_t),(t,e)=>e.map((e=>Gt(e.evaluate(t)))).join("")],"resolved-locale":[dt,[yt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class zi{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Yt,this._defaultValue=e?function(t){return"color"===t.type&&Ei(t.default)?new Dt(0,0,0,0):"color"===t.type?Dt.parse(t.default)||null:"padding"===t.type?Ot.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new qt(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Li(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in di}function Di(t,e){const i=new be(di,[],e?function(t){const e={color:ft,string:dt,number:pt,enum:dt,boolean:mt,formatted:xt,padding:vt,resolvedImage:bt};return"array"===t.type?wt(e[t.value]||_t,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?yi(new zi(r,e)):xi(i.errors)}class Bi{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!ye(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}}class Ri{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!ye(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}interpolationFactor(t,e,i){return this.interpolationType?je.interpolationFactor(this.interpolationType,t,e,i):0}}function Fi(t,e){const i=Di(t,e);if("error"===i.result)return i;const r=i.value.expression,n=_e(r);if(!n&&!vi(e))return xi([new ct("","data expressions not supported")]);const o=xe(r,["zoom"]);if(!o&&!bi(e))return xi([new ct("","zoom expressions not supported")]);const a=Ui(r);return a||o?a instanceof ct?xi([a]):a instanceof je&&!wi(e)?xi([new ct("",'"interpolate" expressions cannot be used with this property')]):yi(a?new Ri(n?"camera":"composite",i.value,a.labels,a instanceof je?a.interpolation:void 0):new Bi(n?"constant":"source",i.value)):xi([new ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Oi{constructor(t,e){this._parameters=t,this._specification=e,at(this,Ai(this._parameters,this._specification))}static deserialize(t){return new Oi(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Ui(t){let e=null;if(t instanceof Xe)e=Ui(t.result);else if(t instanceof Ze){for(const i of t.args)if(e=Ui(i),e)break}else(t instanceof Ee||t instanceof je)&&t.input instanceof Jt&&"zoom"===t.input.name&&(e=t);return e instanceof ct||t.eachChild((t=>{const i=Ui(t);i instanceof ct?e=i:!e&&i?e=new ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new ct("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Vi(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,a=t.styleSpec;let s=[];const l=Ti(i);if("object"!==l)return[new nt(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(n[l])h=n[l];else if(r[l])h=mr;else if(n["*"])h=n["*"];else{if(!r["*"]){s.push(new nt(e,i[t],`unknown property "${t}"`));continue}h=mr}s=s.concat(h({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:o,styleSpec:a,object:i,objectKey:t},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&s.push(new nt(e,i,`missing required property "${t}"`));return s}function Ni(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,o=t.key,a=t.arrayElementValidator||mr;if("array"!==Ti(e))return[new nt(o,e,`array expected, ${Ti(e)} found`)];if(i.length&&e.length!==i.length)return[new nt(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new nt(o,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let s={type:i.value,values:i.values};n.$version<7&&(s.function=i.function),"object"===Ti(i.value)&&(s=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(a({array:e,arrayIndex:t,value:e[t],valueSpec:s,style:r,styleSpec:n,key:`${o}[${t}]`}));return l}function $i(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Ti(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new nt(e,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new nt(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new nt(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function Gi(t){const e=t.valueSpec,i=st(t.value.type);let r,n,o,a={};const s="categorical"!==i&&void 0===t.value.property,l=!s,c="array"===Ti(t.value.stops)&&"array"===Ti(t.value.stops[0])&&"object"===Ti(t.value.stops[0][0]),h=Vi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new nt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ni({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Ti(r)&&0===r.length&&e.push(new nt(t.key,r,"array must have at least one stop")),e},default:function(t){return mr({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&s&&h.push(new nt(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new nt(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!wi(t.valueSpec)&&h.push(new nt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!vi(t.valueSpec)?h.push(new nt(t.key,t.value,"property functions not supported")):s&&!bi(t.valueSpec)&&h.push(new nt(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new nt(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,s=t.key;if("array"!==Ti(r))return[new nt(s,r,`array expected, ${Ti(r)} found`)];if(2!==r.length)return[new nt(s,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Ti(r[0]))return[new nt(s,r,`object expected, ${Ti(r[0])} found`)];if(void 0===r[0].zoom)return[new nt(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new nt(s,r,"object stop key must have value")];if(o&&o>st(r[0].zoom))return[new nt(s,r[0].zoom,"stop zoom values must appear in ascending order")];st(r[0].zoom)!==o&&(o=st(r[0].zoom),n=void 0,a={}),i=i.concat(Vi({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:$i,value:p}}))}else i=i.concat(p({key:`${s}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return Li(lt(r[1]))?i.concat([new nt(`${s}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(mr({key:`${s}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,o){const s=Ti(t.value),l=st(t.value),c=null!==t.value?t.value:o;if(r){if(s!==r)return[new nt(t.key,c,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new nt(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==i){let r=`number expected, ${s} found`;return vi(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new nt(t.key,c,r)]}return"categorical"!==i||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===s&&void 0!==n&&l<n?[new nt(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in a?[new nt(t.key,c,"stop domain values must be unique")]:(a[l]=!0,[])):[new nt(t.key,c,`integer expected, found ${l}`)]}}function ji(t){const e=("property"===t.expressionContext?Fi:Di)(lt(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new nt(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new nt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!ye(i))return[new nt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!ye(i))return[new nt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!xe(i,["zoom","feature-state"]))return[new nt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!_e(i))return[new nt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function qi(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(st(i))&&n.push(new nt(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(st(i))&&n.push(new nt(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Zi(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Zi(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const Xi={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Wi(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Zi(t)||(t=Yi(t));const e=Di(t,Xi);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:Ki(t)}}function Hi(t,e){return t<e?-1:t>e?1:0}function Ki(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(Ki(t[e]))return!0;return!1}function Yi(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?Ji(t[1],t[2],"=="):"!="===e?er(Ji(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?Ji(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Yi))):"all"===e?["all"].concat(t.slice(1).map(Yi)):"none"===e?["all"].concat(t.slice(1).map(Yi).map(er)):"in"===e?Qi(t[1],t.slice(2)):"!in"===e?er(Qi(t[1],t.slice(2))):"has"===e?tr(t[1]):"!has"===e?er(tr(t[1])):"within"!==e||t;var i}function Ji(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Qi(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Hi)]]:["filter-in-small",t,["literal",e]]}}function tr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function er(t){return["!",t]}function ir(t){return Zi(lt(t.value))?ji(at({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):rr(t)}function rr(t){const e=t.value,i=t.key;if("array"!==Ti(e))return[new nt(i,e,`array expected, ${Ti(e)} found`)];const r=t.styleSpec;let n,o=[];if(e.length<1)return[new nt(i,e,"filter array must have at least 1 element")];switch(o=o.concat(qi({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),st(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===st(e[1])&&o.push(new nt(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new nt(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Ti(e[1]),"string"!==n&&o.push(new nt(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let a=2;a<e.length;a++)n=Ti(e[a]),"$type"===st(e[1])?o=o.concat(qi({key:`${i}[${a}]`,value:e[a],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new nt(`${i}[${a}]`,e[a],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)o=o.concat(rr({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Ti(e[1]),2!==e.length?o.push(new nt(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new nt(`${i}[1]`,e[1],`string expected, ${n} found`));break;case"within":n=Ti(e[1]),2!==e.length?o.push(new nt(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new nt(`${i}[1]`,e[1],`object expected, ${n} found`))}return o}function nr(t,e){const i=t.key,r=t.style,n=t.styleSpec,o=t.value,a=t.objectKey,s=n[`${e}_${t.layerType}`];if(!s)return[];const l=a.match(/^(.*)-transition$/);if("paint"===e&&l&&s[l[1]]&&s[l[1]].transition)return mr({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=t.valueSpec||s[a];if(!c)return[new nt(i,o,`unknown property "${a}"`)];let h;if("string"===Ti(o)&&vi(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new nt(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===a&&r&&!r.glyphs&&u.push(new nt(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Ei(lt(o))&&"identity"===st(o.type)&&u.push(new nt(i,o,'"text-font" does not support identity functions'))),u.concat(mr({key:t.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:a}))}function or(t){return nr(t,"paint")}function ar(t){return nr(t,"layout")}function sr(t){let e=[];const i=t.value,r=t.key,n=t.style,o=t.styleSpec;i.type||i.ref||e.push(new nt(r,i,'either "type" or "ref" is required'));let a=st(i.type);const s=st(i.ref);if(i.id){const o=st(i.id);for(let a=0;a<t.arrayIndex;a++){const t=n.layers[a];st(t.id)===o&&e.push(new nt(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new nt(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{st(e.id)===s&&(t=e)})),t?t.ref?e.push(new nt(r,i.ref,"ref cannot reference another ref layer")):a=st(t.type):e.push(new nt(r,i.ref,`ref layer "${s}" not found`))}else if("background"!==a)if(i.source){const t=n.sources&&n.sources[i.source],o=t&&st(t.type);t?"vector"===o&&"raster"===a?e.push(new nt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==a?e.push(new nt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==a?e.push(new nt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&t.lineMetrics||e.push(new nt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new nt(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new nt(r,i.source,`source "${i.source}" not found`))}else e.push(new nt(r,i,'missing required property "source"'));return e=e.concat(Vi({key:r,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>mr({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:ir,layout:t=>Vi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ar(at({layerType:a},t))}}),paint:t=>Vi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>or(at({layerType:a},t))}})}})),e}function lr(t){const e=t.value,i=t.key,r=Ti(e);return"string"!==r?[new nt(i,e,`string expected, ${r} found`)]:[]}const cr={promoteId:function({key:t,value:e}){if("string"===Ti(e))return lr({key:t,value:e});{const i=[];for(const r in e)i.push(...lr({key:`${t}.${r}`,value:e[r]}));return i}}};function hr(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style;if(!e.type)return[new nt(i,e,'"type" is required')];const o=st(e.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Vi({key:i,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:cr}),a;case"geojson":if(a=Vi({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:cr}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...ji({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),a.push(...ji({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Vi({key:i,value:e,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Vi({key:i,value:e,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new nt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return qi({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function ur(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let o=[];const a=Ti(e);if(void 0===e)return o;if("object"!==a)return o=o.concat([new nt("light",e,`object expected, ${a} found`)]),o;for(const t in e){const a=t.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?mr({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?mr({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new nt(t,e[t],`unknown property "${t}"`)])}return o}function pr(t){const e=t.value,i=t.styleSpec,r=i.terrain,n=t.style;let o=[];const a=Ti(e);if(void 0===e)return o;if("object"!==a)return o=o.concat([new nt("terrain",e,`object expected, ${a} found`)]),o;for(const t in e)o=o.concat(r[t]?mr({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new nt(t,e[t],`unknown property "${t}"`)]);return o}const dr={"*":()=>[],array:Ni,boolean:function(t){const e=t.value,i=t.key,r=Ti(e);return"boolean"!==r?[new nt(i,e,`boolean expected, ${r} found`)]:[]},number:$i,color:function(t){const e=t.key,i=t.value,r=Ti(i);return"string"!==r?[new nt(e,i,`color expected, ${r} found`)]:null===Ct(i)?[new nt(e,i,`color expected, "${i}" found`)]:[]},constants:ot,enum:qi,filter:ir,function:Gi,layer:sr,object:Vi,source:hr,light:ur,terrain:pr,string:lr,formatted:function(t){return 0===lr(t).length?[]:ji(t)},resolvedImage:function(t){return 0===lr(t).length?[]:ji(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Ti(i)){if(i.length<1||i.length>4)return[new nt(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const t={type:"number"};let r=[];for(let n=0;n<i.length;n++)r=r.concat(mr({key:`${e}[${n}]`,value:i[n],valueSpec:t}));return r}return $i({key:e,value:i,valueSpec:{}})}};function mr(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Ei(st(e))?Gi(t):i.expression&&Li(lt(e))?ji(t):i.type&&dr[i.type]?dr[i.type](t):Vi(at({},t,{valueSpec:i.type?r[i.type]:i}))}function fr(t){const e=t.value,i=t.key,r=lr(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new nt(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new nt(i,e,'"glyphs" url must include a "{range}" token'))),r}function gr(t,e=rt){let i=[];return i=i.concat(mr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:fr,"*":()=>[]}})),t.constants&&(i=i.concat(ot({key:"constants",value:t.constants,style:t,styleSpec:e}))),_r(i)}function _r(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function yr(t){return function(...e){return _r(t.apply(this,e))}}gr.source=yr(hr),gr.light=yr(ur),gr.terrain=yr(pr),gr.layer=yr(sr),gr.filter=yr(ir),gr.paintProperty=yr(or),gr.layoutProperty=yr(ar);const xr=gr,vr=xr.light,br=xr.paintProperty,wr=xr.layoutProperty;function Tr(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new et(new Error(r.message))),i=!0;return i}class Er{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(let t=0;t<this.d*this.d;t++){const e=n[3+t],i=n[3+t+1];r.push(e===i?null:n.subarray(e,i))}const o=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],o),this.bboxes=n.subarray(o),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const n=i/e*t;this.min=-n,this.max=t+n}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,n,o){this.cells[n].push(o)}query(t,e,i,r,n){const o=this.min,a=this.max;if(t<=o&&e<=o&&a<=i&&a<=r&&!n)return Array.prototype.slice.call(this.keys);{const o=[];return this._forEachCell(t,e,i,r,this._queryCell,o,{},n),o}}_queryCell(t,e,i,r,n,o,a,s){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===a[u]){const l=4*u;(s?s(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(a[u]=!0,o.push(n[u])):a[u]=!1}}}}_forEachCell(t,e,i,r,n,o,a,s){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++){const c=this.d*l+p;if((!s||s(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&n.call(this,t,e,i,r,c,o,a,s))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=n,r.set(i,n),n+=i.length}return r[3+t.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+t.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new Er(t.buffer)}}const Sr={};function Ar(t,e,i={}){if(Sr[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Sr[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Ar("Object",Object),Ar("TransferableGridIndex",Er),Ar("Color",Dt),Ar("Error",Error),Ar("AJAXError",$),Ar("ResolvedImage",Ut),Ar("StylePropertyFunction",Oi),Ar("StyleExpression",zi,{omit:["_evaluator"]}),Ar("ZoomDependentExpression",Ri),Ar("ZoomConstantExpression",Bi),Ar("CompoundExpression",Jt,{omit:["_evaluate"]});for(const t in di)di[t]._classRegistryKey||Ar(`Expression_${t}`,di[t]);function Ir(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Cr(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob)return t;if(Ir(t))return e&&e.push(t),t;if(T(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(Cr(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class");if(!Sr[r])throw new Error(`${r} is not registered.`);const n=i.serialize?i.serialize(t,e):{};if(i.serialize){if(e&&n===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const i in t){if(!t.hasOwnProperty(i))continue;if(Sr[r].omit.indexOf(i)>=0)continue;const o=t[i];n[i]=Sr[r].shallow.indexOf(i)>=0?o:Cr(o,e)}t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof t)}function Mr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Ir(t)||T(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Mr);if("object"==typeof t){const e=t.$name||"Object";if(!Sr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Sr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const n=t[i];r[i]=Sr[e].shallow.indexOf(i)>=0?n:Mr(n)}return r}throw new Error("can't deserialize object of type "+typeof t)}class kr{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const Pr={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function zr(t){for(const e of t)if(Br(e.charCodeAt(0)))return!0;return!1}function Lr(t){for(const e of t)if(!Dr(e.charCodeAt(0)))return!1;return!0}function Dr(t){return!(Pr.Arabic(t)||Pr["Arabic Supplement"](t)||Pr["Arabic Extended-A"](t)||Pr["Arabic Presentation Forms-A"](t)||Pr["Arabic Presentation Forms-B"](t))}function Br(t){return!(746!==t&&747!==t&&(t<4352||!(Pr["Bopomofo Extended"](t)||Pr.Bopomofo(t)||Pr["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Pr["CJK Compatibility Ideographs"](t)||Pr["CJK Compatibility"](t)||Pr["CJK Radicals Supplement"](t)||Pr["CJK Strokes"](t)||!(!Pr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Pr["CJK Unified Ideographs Extension A"](t)||Pr["CJK Unified Ideographs"](t)||Pr["Enclosed CJK Letters and Months"](t)||Pr["Hangul Compatibility Jamo"](t)||Pr["Hangul Jamo Extended-A"](t)||Pr["Hangul Jamo Extended-B"](t)||Pr["Hangul Jamo"](t)||Pr["Hangul Syllables"](t)||Pr.Hiragana(t)||Pr["Ideographic Description Characters"](t)||Pr.Kanbun(t)||Pr["Kangxi Radicals"](t)||Pr["Katakana Phonetic Extensions"](t)||Pr.Katakana(t)&&12540!==t||!(!Pr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Pr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Pr["Unified Canadian Aboriginal Syllabics"](t)||Pr["Unified Canadian Aboriginal Syllabics Extended"](t)||Pr["Vertical Forms"](t)||Pr["Yijing Hexagram Symbols"](t)||Pr["Yi Syllables"](t)||Pr["Yi Radicals"](t))))}function Rr(t){return!(Br(t)||function(t){return!!(Pr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Pr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Pr["Letterlike Symbols"](t)||Pr["Number Forms"](t)||Pr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Pr["Control Pictures"](t)&&9251!==t||Pr["Optical Character Recognition"](t)||Pr["Enclosed Alphanumerics"](t)||Pr["Geometric Shapes"](t)||Pr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Pr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Pr["CJK Symbols and Punctuation"](t)||Pr.Katakana(t)||Pr["Private Use Area"](t)||Pr["CJK Compatibility Forms"](t)||Pr["Small Form Variants"](t)||Pr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Fr(t){return t>=1424&&t<=2303||Pr["Arabic Presentation Forms-A"](t)||Pr["Arabic Presentation Forms-B"](t)}function Or(t,e){return!(!e&&Fr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Pr.Khmer(t))}function Ur(t){for(const e of t)if(Fr(e.charCodeAt(0)))return!0;return!1}const Vr="deferred",Nr="loading",$r="loaded";let Gr=null,jr="unavailable",qr=null;const Zr=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(jr="error"),Gr&&Gr(t)};function Xr(){Wr.fire(new tt("pluginStateChange",{pluginStatus:jr,pluginURL:qr}))}const Wr=new it,Hr=function(){return jr},Kr=function(){if(jr!==Vr||!qr)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");jr=Nr,Xr(),qr&&Z({url:qr},(t=>{t?Zr(t):(jr=$r,Xr())}))},Yr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>jr===$r||null!=Yr.applyArabicShaping,isLoading:()=>jr===Nr,setState(t){if(!_())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");jr=t.pluginStatus,qr=t.pluginURL},isParsed(){if(!_())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return null!=Yr.applyArabicShaping&&null!=Yr.processBidirectionalText&&null!=Yr.processStyledBidirectionalText},getPluginURL(){if(!_())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return qr}};class Jr{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new kr,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!Or(i.charCodeAt(0),e))return!1;return!0}(t,Yr.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class Qr{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Ei(t))return new Oi(t,e);if(Li(t)){const i=Fi(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=Dt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)||(i=Ot.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class tn{constructor(t){this.property=t,this.value=new Qr(t,void 0)}transitioned(t,e){return new rn(this.property,this.value,e,s({},t.transition,this.transition),t.now)}untransitioned(){return new rn(this.property,this.value,null,{},0)}}class en{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return p(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new tn(this._values[t].property)),this._values[t].value=new Qr(this._values[t].property,null===e?void 0:p(e))}getTransition(t){return p(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new tn(this._values[t].property)),this._values[t].transition=p(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new nn(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new nn(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class rn{constructor(t,e,i,r,n){this.property=t,this.value=e,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(t,e,i);{const a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,i),n,function(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(a))}}return n}}class nn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new sn(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class on{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return p(this._values[t].value)}setValue(t,e){this._values[t]=new Qr(this._values[t].property,null===e?void 0:p(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new sn(this._properties);for(const n of Object.keys(this._values)){const o="text-letter-spacing"===n?s({},t,{zoom:Math.floor(t.zoom)}):t;r._values[n]=this._values[n].possiblyEvaluate(o,e,i)}return r}}class an{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class sn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class ln{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=Ae[this.specification.type];return r?r(t,e,i):t}}class cn{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new an(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new an(this,{kind:"constant",value:void 0},t.parameters);const r=Ae[this.specification.type];return r?new an(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,n,o){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,o)}}class hn extends cn{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new an(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),o="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,a=this._calculate(o,o,o,e);return new an(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new an(this,{kind:"constant",value:i},e)}return new an(this,t.expression,e)}evaluate(t,e,i,r,n,o){if("source"===t.kind){const a=t.evaluate(e,i,r,n,o);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class un{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new Jr(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Jr(Math.floor(e.zoom),e)),t.expression.evaluate(new Jr(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class pn{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class dn{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new Qr(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new tn(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Ar("DataDrivenProperty",cn),Ar("DataConstantProperty",ln),Ar("CrossFadedDataDrivenProperty",hn),Ar("CrossFadedProperty",un),Ar("ColorRampProperty",pn);const mn="-transition";class fn extends it{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new on(e.layout)),e.paint)){this._transitionablePaint=new en(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new sn(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(wr,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(mn)?this._transitionablePaint.getTransition(t.slice(0,-mn.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(br,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(mn))return this._transitionablePaint.setTransition(t.slice(0,-mn.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,o,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),u(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Tr(this,t.call(xr,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:rt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof an&&vi(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const gn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class _n{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class yn{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function xn(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=gn[t.type].BYTES_PER_ELEMENT,o=i=vn(i,Math.max(e,n)),a=t.components||1;return r=Math.max(r,n),i+=n*a,{name:t.name,type:t.type,components:a,offset:o}})),size:vn(i,Math.max(r,e)),alignment:e}}function vn(t,e){return Math.ceil(t/e)*e}class bn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}bn.prototype.bytesPerElement=4,Ar("StructArrayLayout2i4",bn);class wn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,t}}wn.prototype.bytesPerElement=8,Ar("StructArrayLayout4i8",wn);class Tn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,a){const s=6*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,this.int16[s+5]=a,t}}Tn.prototype.bytesPerElement=12,Ar("StructArrayLayout2i4i12",Tn);class En extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,a){const s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=o,this.uint8[l+7]=a,t}}En.prototype.bytesPerElement=8,Ar("StructArrayLayout2i4ub8",En);class Sn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Sn.prototype.bytesPerElement=8,Ar("StructArrayLayout2f8",Sn);class An extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,a,s,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,o,a,s,l,c)}emplace(t,e,i,r,n,o,a,s,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=a,this.uint16[u+6]=s,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}An.prototype.bytesPerElement=20,Ar("StructArrayLayout10ui20",An);class In extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,a,s,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,n,o,a,s,l,c,h,u)}emplace(t,e,i,r,n,o,a,s,l,c,h,u,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=a,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,t}}In.prototype.bytesPerElement=24,Ar("StructArrayLayout4i4ui4i24",In);class Cn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}Cn.prototype.bytesPerElement=12,Ar("StructArrayLayout3f12",Cn);class Mn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Mn.prototype.bytesPerElement=4,Ar("StructArrayLayout1ul4",Mn);class kn extends yn{_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(t,e,i,r,n,o,a,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,n,o,a,s,l)}emplace(t,e,i,r,n,o,a,s,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=o,this.int16[h+5]=a,this.uint32[u+3]=s,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}kn.prototype.bytesPerElement=20,Ar("StructArrayLayout6i1ul2ui20",kn);class Pn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,a){const s=6*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,this.int16[s+5]=a,t}}Pn.prototype.bytesPerElement=12,Ar("StructArrayLayout2i2i2i12",Pn);class zn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n)}emplace(t,e,i,r,n,o){const a=4*t,s=8*t;return this.float32[a+0]=e,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[s+6]=n,this.int16[s+7]=o,t}}zn.prototype.bytesPerElement=16,Ar("StructArrayLayout2f1f2i16",zn);class Ln extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=12*t,a=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[a+1]=r,this.float32[a+2]=n,t}}Ln.prototype.bytesPerElement=12,Ar("StructArrayLayout2ub2f12",Ln);class Dn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}Dn.prototype.bytesPerElement=6,Ar("StructArrayLayout3ui6",Dn);class Bn extends yn{_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),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g)}emplace(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g,_){const y=26*t,x=13*t,v=52*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint32[x+1]=r,this.uint32[x+2]=n,this.uint32[x+3]=o,this.uint32[x+4]=a,this.uint32[x+5]=s,this.uint16[y+12]=l,this.uint16[y+13]=c,this.uint16[y+14]=h,this.float32[x+8]=u,this.float32[x+9]=p,this.uint8[v+40]=d,this.uint8[v+41]=m,this.uint8[v+42]=f,this.uint32[x+11]=g,this.int16[y+24]=_,t}}Bn.prototype.bytesPerElement=52,Ar("StructArrayLayout2i5ul3ui2f3ub1ul1i52",Bn);class Rn extends yn{_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(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g,_,y,x,v,b,w,T,E,S,A,I,C){const M=this.length;return this.resize(M+1),this.emplace(M,t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g,_,y,x,v,b,w,T,E,S,A,I,C)}emplace(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g,_,y,x,v,b,w,T,E,S,A,I,C,M){const k=36*t,P=18*t;return this.int16[k+0]=e,this.int16[k+1]=i,this.int16[k+2]=r,this.int16[k+3]=n,this.int16[k+4]=o,this.int16[k+5]=a,this.int16[k+6]=s,this.int16[k+7]=l,this.uint16[k+8]=c,this.uint16[k+9]=h,this.uint16[k+10]=u,this.uint16[k+11]=p,this.uint16[k+12]=d,this.uint16[k+13]=m,this.uint16[k+14]=f,this.uint16[k+15]=g,this.uint16[k+16]=_,this.uint16[k+17]=y,this.uint16[k+18]=x,this.uint16[k+19]=v,this.uint16[k+20]=b,this.uint16[k+21]=w,this.uint16[k+22]=T,this.uint32[P+12]=E,this.float32[P+13]=S,this.float32[P+14]=A,this.float32[P+15]=I,this.float32[P+16]=C,this.float32[P+17]=M,t}}Rn.prototype.bytesPerElement=72,Ar("StructArrayLayout8i15ui1ul5f72",Rn);class Fn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Fn.prototype.bytesPerElement=4,Ar("StructArrayLayout1f4",Fn);class On extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}On.prototype.bytesPerElement=6,Ar("StructArrayLayout3i6",On);class Un extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=4*t;return this.uint32[2*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,t}}Un.prototype.bytesPerElement=8,Ar("StructArrayLayout1ul2ui8",Un);class Vn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Vn.prototype.bytesPerElement=4,Ar("StructArrayLayout2ui4",Vn);class Nn extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Nn.prototype.bytesPerElement=2,Ar("StructArrayLayout1ui2",Nn);class $n extends yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,t}}$n.prototype.bytesPerElement=16,Ar("StructArrayLayout4f16",$n);class Gn extends _n{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 S(this.anchorPointX,this.anchorPointY)}}Gn.prototype.size=20;class jn extends kn{get(t){return new Gn(this,t)}}Ar("CollisionBoxArray",jn);class qn extends _n{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint32[this._pos4+1]}get numGlyphs(){return this._structArray.uint32[this._pos4+2]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineStartIndex(){return this._structArray.uint32[this._pos4+4]}get lineLength(){return this._structArray.uint32[this._pos4+5]}get segment(){return this._structArray.uint16[this._pos2+12]}get lowerSize(){return this._structArray.uint16[this._pos2+13]}get upperSize(){return this._structArray.uint16[this._pos2+14]}get lineOffsetX(){return this._structArray.float32[this._pos4+8]}get lineOffsetY(){return this._structArray.float32[this._pos4+9]}get writingMode(){return this._structArray.uint8[this._pos1+40]}get placedOrientation(){return this._structArray.uint8[this._pos1+41]}set placedOrientation(t){this._structArray.uint8[this._pos1+41]=t}get hidden(){return this._structArray.uint8[this._pos1+42]}set hidden(t){this._structArray.uint8[this._pos1+42]=t}get crossTileID(){return this._structArray.uint32[this._pos4+11]}set crossTileID(t){this._structArray.uint32[this._pos4+11]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+24]}}qn.prototype.size=52;class Zn extends Bn{get(t){return new qn(this,t)}}Ar("PlacedSymbolArray",Zn);class Xn extends _n{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(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}get angle(){return this._structArray.float32[this._pos4+17]}set angle(t){this._structArray.float32[this._pos4+17]=t}}Xn.prototype.size=72;class Wn extends Rn{get(t){return new Xn(this,t)}}Ar("SymbolInstanceArray",Wn);class Hn extends Fn{getoffsetX(t){return this.float32[1*t+0]}}Ar("GlyphOffsetArray",Hn);class Kn extends On{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Ar("SymbolLineVertexArray",Kn);class Yn extends _n{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]}}Yn.prototype.size=8;class Jn extends Un{get(t){return new Yn(this,t)}}Ar("FeatureIndexArray",Jn);class Qn extends bn{}class to extends bn{}class eo extends bn{}class io extends Tn{}class ro extends En{}class no extends Sn{}class oo extends An{}class ao extends In{}class so extends Cn{}class lo extends Mn{}class co extends Pn{}class ho extends Ln{}class uo extends Dn{}class po extends Vn{}const mo=xn([{name:"a_pos",components:2,type:"Int16"}],4),{members:fo}=mo;class go{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let n=this.segments[this.segments.length-1];return t>go.MAX_VERTEX_ARRAY_LENGTH&&m(`Max vertices per segment is ${go.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!n||n.vertexLength+t>go.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new go([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function _o(t,e){return 256*(t=o(Math.floor(t),0,255))+o(Math.floor(e),0,255)}go.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ar("SegmentVector",go);const yo=xn([{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 xo={exports:{}},vo={exports:{}};vo.exports=function(t,e){var i,r,n,o,a,s,l,c;for(r=t.length-(i=3&t.length),n=e,a=3432918353,s=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};var bo={exports:{}};bo.exports=function(t,e){for(var i,r=t.length,n=e^r,o=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&t.charCodeAt(o+2))<<16;case 2:n^=(255&t.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0};var wo=vo.exports,To=bo.exports;xo.exports=wo,xo.exports.murmur3=wo,xo.exports.murmur2=To;class Eo{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(So(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=So(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Ao(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Eo;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function So(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:xo.exports(String(t))}function Ao(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let o=i-1,a=r+1;for(;;){do{o++}while(t[o]<n);do{a--}while(t[a]>n);if(o>=a)break;Io(t,o,a),Io(e,3*o,3*a),Io(e,3*o+1,3*a+1),Io(e,3*o+2,3*a+2)}a-i<r-a?(Ao(t,e,i,a),i=a+1):(Ao(t,e,a+1,r),r=a)}}function Io(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Ar("FeaturePositionMap",Eo);class Co{constructor(t,e){this.gl=t.gl,this.location=e}}class Mo extends Co{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class ko extends Co{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Po extends Co{constructor(t,e){super(t,e),this.current=Dt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const zo=new Float32Array(16);function Lo(t){return[_o(255*t.r,255*t.g),_o(255*t.b,255*t.a)]}class Do{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Po(t,e):new Mo(t,e)}}class Bo{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,i,r){const n="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new ko(t,e):new Mo(t,e)}}class Ro{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n){const o=this.paintVertexArray.length,a=this.expression.evaluate(new Jr(0),e,{},r,[],n);this.paintVertexArray.resize(t),this._setPaintValue(o,t,a)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){const r=Lo(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Fo{constructor(t,e,i,r,n,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,r,n){const o=this.expression.evaluate(new Jr(this.zoom),e,{},r,[],n),a=this.expression.evaluate(new Jr(this.zoom+1),e,{},r,[],n),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,o,a)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:this.zoom},i,r),o=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,n,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=Lo(i),o=Lo(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=o(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Mo(t,e)}}class Oo{constructor(t,e,i,r,n,o){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=o,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],n)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:o,max:a}=i,s=r[n],l=r[o],c=r[a];if(s&&l&&c)for(let i=t;i<e;i++)this.zoomInPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],s.tl[0],s.tl[1],s.br[0],s.br[1],l.pixelRatio,s.pixelRatio),this.zoomOutPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],c.tl[0],c.tl[1],c.br[0],c.br[1],l.pixelRatio,c.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,yo.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,yo.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Uo{constructor(t,e,i){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const o=t.paint.get(n);if(!(o instanceof an&&vi(o.property.specification)))continue;const a=No(n,t.type),s=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===s.kind)this.binders[n]=u?new Bo(s.value,a):new Do(s.value,a,l),r.push(`/u_${n}`);else if("source"===s.kind||u){const i=$o(n,l,"source");this.binders[n]=u?new Oo(s,l,c,e,i,t.id):new Ro(s,a,l,i),r.push(`/a_${n}`)}else{const t=$o(n,l,"composite");this.binders[n]=new Fo(s,a,l,c,e,t),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Ro||e instanceof Fo?e.maxValue:0}populatePaintArrays(t,e,i,r,n){for(const o in this.binders){const a=this.binders[o];(a instanceof Ro||a instanceof Fo||a instanceof Oo)&&a.populatePaintArray(t,e,i,r,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Bo&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n){let o=!1;for(const a in t){const s=e.getPositions(a);for(const e of s){const s=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof Ro||l instanceof Fo||l instanceof Oo)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,s,t[a],n),o=!0}}}}return o}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Do||i instanceof Bo)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ro||i instanceof Fo)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof Oo)for(let e=0;e<yo.members.length;e++)t.push(yo.members[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Do||i instanceof Bo||i instanceof Fo)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Do||n instanceof Bo||n instanceof Fo)for(const o of n.uniformNames)if(e[o]){const a=n.getBinding(t,e[o],o);i.push({name:o,property:r,binding:a})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:o}of e)this.binders[n].setUniform(o,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof Oo){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Ro||i instanceof Fo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Ro||i instanceof Fo||i instanceof Oo)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Ro||e instanceof Fo||e instanceof Oo)&&e.destroy()}}}class Vo{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Uo(r,e,i);this.needsUpload=!1,this._featureMap=new Eo,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,o);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function No(t,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"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function $o(t,e,i){const r={color:{source:Sn,composite:$n},number:{source:Fn,composite:Sn}},n=function(t){return{"line-pattern":{source:oo,composite:oo},"fill-pattern":{source:oo,composite:oo},"fill-extrusion-pattern":{source:oo,composite:oo}}[t]}(t);return n&&n[i]||r[e][i]}Ar("ConstantBinder",Do),Ar("CrossFadedConstantBinder",Bo),Ar("SourceExpressionBinder",Ro),Ar("CrossFadedCompositeBinder",Oo),Ar("CompositeExpressionBinder",Fo),Ar("ProgramConfiguration",Uo,{omit:["_buffers"]}),Ar("ProgramConfigurationSet",Vo);var Go=8192;const jo=Math.pow(2,14)-1,qo=-jo-1;function Zo(t){const e=Go/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],n=Math.round(i.x*e),a=Math.round(i.y*e);i.x=o(n,qo,jo),i.y=o(a,qo,jo),(n<i.x||n>i.x+1||a<i.y||a>i.y+1)&&m("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Xo(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Zo(t):[]}}function Wo(t,e,i,r,n){t.emplaceBack(2*e+(r+1)/2,2*i+(n+1)/2)}class Ho{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new to,this.indexArray=new uo,this.segments=new go,this.programConfigurations=new Vo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],n=[];let o=null,a=!1;"circle"===r.type&&(o=r.layout.get("circle-sort-key"),a=!o.isConstant());for(const{feature:e,id:r,index:s,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Xo(e,t);if(!this.layers[0]._featureFilter.filter(new Jr(this.zoom),c,i))continue;const h=a?o.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:s,geometry:t?c.geometry:Zo(e),patterns:{},sortKey:h};n.push(u)}a&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:n,index:o,sourceLayerIndex:a}=r,s=t[o].feature;this.addFeature(r,n,o,i),e.featureIndex.insert(s,n,o,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fo),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=Go||r<0||r>=Go)continue;const n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=n.vertexLength;Wo(this.layoutVertexArray,i,r,-1,-1),Wo(this.layoutVertexArray,i,r,1,-1),Wo(this.layoutVertexArray,i,r,1,1),Wo(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+3,o+2),n.vertexLength+=4,n.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function Ko(t,e){for(let i=0;i<t.length;i++)if(oa(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(oa(t,e[i]))return!0;return!!ta(t,e)}function Yo(t,e,i){return!!oa(t,e)||!!ia(e,t,i)}function Jo(t,e){if(1===t.length)return na(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(oa(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(na(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(ta(t,e[i]))return!0;return!1}function Qo(t,e,i){if(t.length>1){if(ta(t,e))return!0;for(let r=0;r<e.length;r++)if(ia(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(ia(t[r],e,i))return!0;return!1}function ta(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(ea(r,n,e[t],e[t+1]))return!0}return!1}function ea(t,e,i,r){return f(t,i,r)!==f(e,i,r)&&f(t,e,i)!==f(t,e,r)}function ia(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(ra(t,e[i-1],e[i])<r)return!0;return!1}function ra(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function na(t,e){let i,r,n,o=!1;for(let a=0;a<t.length;a++){i=t[a];for(let t=0,a=i.length-1;t<i.length;a=t++)r=i[t],n=i[a],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function oa(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const o=t[r],a=t[n];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(i=!i)}return i}function aa(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const o=f(t,e,i[0]);return o!==f(t,e,i[1])||o!==f(t,e,i[2])||o!==f(t,e,i[3])}function sa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function la(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ca(t,e,i,r,n){if(!e[0]&&!e[1])return t;const o=S.convert(e)._mult(n);"viewport"===i&&o._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(o));return a}Ar("CircleBucket",Ho,{omit:["layers"]});const ha=new dn({"circle-sort-key":new cn(rt.layout_circle["circle-sort-key"])});var ua={paint:new dn({"circle-radius":new cn(rt.paint_circle["circle-radius"]),"circle-color":new cn(rt.paint_circle["circle-color"]),"circle-blur":new cn(rt.paint_circle["circle-blur"]),"circle-opacity":new cn(rt.paint_circle["circle-opacity"]),"circle-translate":new ln(rt.paint_circle["circle-translate"]),"circle-translate-anchor":new ln(rt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ln(rt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ln(rt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new cn(rt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new cn(rt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new cn(rt.paint_circle["circle-stroke-opacity"])}),layout:ha},pa=1e-6,da="undefined"!=typeof Float32Array?Float32Array:Array;function ma(){var t=new da(9);return da!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function fa(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ga(t,e,i){var r=e[0],n=e[1],o=e[2],a=e[3],s=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],f=e[12],g=e[13],_=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*s+b*u+w*f,t[1]=x*n+v*l+b*p+w*g,t[2]=x*o+v*c+b*d+w*_,t[3]=x*a+v*h+b*m+w*y,t[4]=(x=i[4])*r+(v=i[5])*s+(b=i[6])*u+(w=i[7])*f,t[5]=x*n+v*l+b*p+w*g,t[6]=x*o+v*c+b*d+w*_,t[7]=x*a+v*h+b*m+w*y,t[8]=(x=i[8])*r+(v=i[9])*s+(b=i[10])*u+(w=i[11])*f,t[9]=x*n+v*l+b*p+w*g,t[10]=x*o+v*c+b*d+w*_,t[11]=x*a+v*h+b*m+w*y,t[12]=(x=i[12])*r+(v=i[13])*s+(b=i[14])*u+(w=i[15])*f,t[13]=x*n+v*l+b*p+w*g,t[14]=x*o+v*c+b*d+w*_,t[15]=x*a+v*h+b*m+w*y,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var _a,ya=ga;function xa(){var t=new da(3);return da!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function va(t,e,i){var r=new da(3);return r[0]=t,r[1]=e,r[2]=i,r}function ba(t,e,i){var r=e[0],n=e[1],o=e[2],a=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*a,t[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*a,t[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*a,t[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*a,t}function wa(){var t=new da(4);return da!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Ta(t,e){const i=ba([],[t.x,t.y,0,1],e);return new S(i[0]/i[3],i[1]/i[3])}xa(),_a=new da(4),da!=Float32Array&&(_a[0]=0,_a[1]=0,_a[2]=0,_a[3]=0),xa(),va(1,0,0),va(0,1,0),wa(),wa(),ma(),function(){var t;t=new da(2),da!=Float32Array&&(t[0]=0,t[1]=0)}();class Ea extends Ho{}Ar("HeatmapBucket",Ea,{omit:["layers"]});var Sa={paint:new dn({"heatmap-radius":new cn(rt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new cn(rt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ln(rt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new pn(rt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ln(rt.paint_heatmap["heatmap-opacity"])})};function Aa(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${e*i*r}`)}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Ia(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const n=Aa({},{width:e,height:i},r);Ca(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=n.data}function Ca(t,e,i,r,n,o){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,s=e.data;if(a===s)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*o,h=((r.y+l)*e.width+r.x)*o;for(let t=0;t<n.width*o;t++)s[h+t]=a[c+t]}return e}class Ma{constructor(t,e){Aa(this,t,1,e)}resize(t){Ia(this,t,1)}clone(){return new Ma({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ca(t,e,i,r,n,1)}}class ka{constructor(t,e){Aa(this,t,4,e)}resize(t){Ia(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new ka({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ca(t,e,i,r,n,4)}}function Pa(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new ka({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const o=(i,r,o)=>{e[t.evaluationKey]=o;const a=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*a.r/a.a),n.data[i+r+1]=Math.floor(255*a.g/a.a),n.data[i+r+2]=Math.floor(255*a.b/a.a),n.data[i+r+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,a=0;r<i;r++,a+=4){const s=r/(i-1),{start:l,end:c}=t.clips[e];o(n,a,l*(1-s)+c*s)}else for(let t=0,e=0;t<i;t++,e+=4)o(0,e,t/(i-1));return n}Ar("AlphaImage",Ma),Ar("RGBAImage",ka);var za={paint:new dn({"hillshade-illumination-direction":new ln(rt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ln(rt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ln(rt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ln(rt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ln(rt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ln(rt.paint_hillshade["hillshade-accent-color"])})};const La=xn([{name:"a_pos",components:2,type:"Int16"}],4),{members:Da}=La;var Ba={exports:{}};function Ra(t,e,i){i=i||2;var r,n,o,a,s,l,c,h=e&&e.length,u=h?e[0]*i:t.length,p=Fa(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,i,r){var n,o,a,s=[];for(n=0,o=e.length;n<o;n++)(a=Fa(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),s.push(Wa(a));for(s.sort(ja),n=0;n<s.length;n++)i=qa(s[n],i);return i}(t,e,p,i)),t.length>80*i){r=o=t[0],n=a=t[1];for(var m=i;m<u;m+=i)(s=t[m])<r&&(r=s),(l=t[m+1])<n&&(n=l),s>o&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-r,a-n))?32767/c:0}return Ua(p,d,i,r,n,c,0),d}function Fa(t,e,i,r,n){var o,a;if(n===ss(t,e,i,r)>0)for(o=e;o<i;o+=r)a=ns(o,t[o],t[o+1],a);else for(o=i-r;o>=e;o-=r)a=ns(o,t[o],t[o+1],a);return a&&Ja(a,a.next)&&(os(a),a=a.next),a}function Oa(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Ja(r,r.next)&&0!==Ya(r.prev,r,r.next))r=r.next;else{if(os(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Ua(t,e,i,r,n,o,a){if(t){!a&&o&&function(t,e,i,r){var n=t;do{0===n.z&&(n.z=Xa(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,o,a,s,l,c=1;do{for(i=t,t=null,o=null,a=0;i;){for(a++,r=i,s=0,e=0;e<c&&(s++,r=r.nextZ);e++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,s--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(a>1)}(n)}(t,r,n,o);for(var s,l,c=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Na(t,r,n,o):Va(t))e.push(s.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),os(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Ua(t=$a(Oa(t),e,i),e,i,r,n,o,2):2===a&&Ga(t,e,i,r,n,o):Ua(Oa(t),e,i,r,n,o,1);break}}}function Va(t){var e=t.prev,i=t,r=t.next;if(Ya(e,i,r)>=0)return!1;for(var n=e.x,o=i.x,a=r.x,s=e.y,l=i.y,c=r.y,h=n<o?n<a?n:a:o<a?o:a,u=s<l?s<c?s:c:l<c?l:c,p=n>o?n>a?n:a:o>a?o:a,d=s>l?s>c?s:c:l>c?l:c,m=r.next;m!==e;){if(m.x>=h&&m.x<=p&&m.y>=u&&m.y<=d&&Ha(n,s,o,l,a,c,m.x,m.y)&&Ya(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Na(t,e,i,r){var n=t.prev,o=t,a=t.next;if(Ya(n,o,a)>=0)return!1;for(var s=n.x,l=o.x,c=a.x,h=n.y,u=o.y,p=a.y,d=s<l?s<c?s:c:l<c?l:c,m=h<u?h<p?h:p:u<p?u:p,f=s>l?s>c?s:c:l>c?l:c,g=h>u?h>p?h:p:u>p?u:p,_=Xa(d,m,e,i,r),y=Xa(f,g,e,i,r),x=t.prevZ,v=t.nextZ;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=g&&x!==n&&x!==a&&Ha(s,h,l,u,c,p,x.x,x.y)&&Ya(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=d&&v.x<=f&&v.y>=m&&v.y<=g&&v!==n&&v!==a&&Ha(s,h,l,u,c,p,v.x,v.y)&&Ya(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=g&&x!==n&&x!==a&&Ha(s,h,l,u,c,p,x.x,x.y)&&Ya(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=f&&v.y>=m&&v.y<=g&&v!==n&&v!==a&&Ha(s,h,l,u,c,p,v.x,v.y)&&Ya(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function $a(t,e,i){var r=t;do{var n=r.prev,o=r.next.next;!Ja(n,o)&&Qa(n,r,r.next,o)&&is(n,o)&&is(o,n)&&(e.push(n.i/i|0),e.push(r.i/i|0),e.push(o.i/i|0),os(r),os(r.next),r=t=o),r=r.next}while(r!==t);return Oa(r)}function Ga(t,e,i,r,n,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ka(a,s)){var l=rs(a,s);return a=Oa(a,a.next),l=Oa(l,l.next),Ua(a,e,i,r,n,o,0),void Ua(l,e,i,r,n,o,0)}s=s.next}a=a.next}while(a!==t)}function ja(t,e){return t.x-e.x}function qa(t,e){var i=function(t,e){var i,r=e,n=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=n&&s>a&&(a=s,i=r.x<r.next.x?r:r.next,s===n))return i}r=r.next}while(r!==e);if(!i)return null;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&Ha(o<u?n:a,o,h,u,o<u?a:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),is(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&Za(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=rs(i,t);return Oa(r,r.next),Oa(i,i.next)}function Za(t,e){return Ya(t.prev,t,e.prev)<0&&Ya(e.next,t,t.next)<0}function Xa(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Wa(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Ha(t,e,i,r,n,o,a,s){return(n-a)*(e-s)>=(t-a)*(o-s)&&(t-a)*(r-s)>=(i-a)*(e-s)&&(i-a)*(o-s)>=(n-a)*(r-s)}function Ka(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Qa(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(is(t,e)&&is(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Ya(t.prev,t,e.prev)||Ya(t,e.prev,e))||Ja(t,e)&&Ya(t.prev,t,t.next)>0&&Ya(e.prev,e,e.next)>0)}function Ya(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ja(t,e){return t.x===e.x&&t.y===e.y}function Qa(t,e,i,r){var n=es(Ya(t,e,i)),o=es(Ya(t,e,r)),a=es(Ya(i,r,t)),s=es(Ya(i,r,e));return n!==o&&a!==s||!(0!==n||!ts(t,i,e))||!(0!==o||!ts(t,r,e))||!(0!==a||!ts(i,t,r))||!(0!==s||!ts(i,e,r))}function ts(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function es(t){return t>0?1:t<0?-1:0}function is(t,e){return Ya(t.prev,t,t.next)<0?Ya(t,e,t.next)>=0&&Ya(t,t.prev,e)>=0:Ya(t,e,t.prev)<0||Ya(t,t.next,e)<0}function rs(t,e){var i=new as(t.i,t.x,t.y),r=new as(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function ns(t,e,i,r){var n=new as(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function os(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function as(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ss(t,e,i,r){for(var n=0,o=e,a=i-r;o<i;o+=r)n+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return n}function ls(t,e,i,r,n){cs(t,e,i||0,r||t.length-1,n||us)}function cs(t,e,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,a=e-i+1,s=Math.log(o),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);cs(t,e,Math.max(i,Math.floor(e-a*l/o+c)),Math.min(r,Math.floor(e+(o-a)*l/o+c)),n)}var h=t[e],u=i,p=r;for(hs(t,i,e),n(t[r],h)>0&&hs(t,i,r);u<p;){for(hs(t,u,p),u++,p--;n(t[u],h)<0;)u++;for(;n(t[p],h)>0;)p--}0===n(t[i],h)?hs(t,i,p):hs(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function hs(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function us(t,e){return t<e?-1:t>e?1:0}function ps(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,o;for(let e=0;e<i;e++){const i=g(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[e]]):n.push(t[e]))}if(n&&r.push(n),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(ls(r[t],e,1,r[t].length-1,ds),r[t]=r[t].slice(0,e));return r}function ds(t,e){return e.area-t.area}function ms(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const o=e.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function fs(t,e,i,r,n){const o=n.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),s=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,s=s&&s.name?s.name:s,l=l&&l.name?l.name:l,o[t]=!0,o[s]=!0,o[l]=!0,i.patterns[a.id]={min:t,mid:s,max:l}}}return i}Ba.exports=Ra,Ba.exports.default=Ra,Ra.deviation=function(t,e,i,r){var n=e&&e.length,o=Math.abs(ss(t,0,n?e[0]*i:t.length,i));if(n)for(var a=0,s=e.length;a<s;a++)o-=Math.abs(ss(t,e[a]*i,a<s-1?e[a+1]*i:t.length,i));var l=0;for(a=0;a<r.length;a+=3){var c=r[a]*i,h=r[a+1]*i,u=r[a+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Ra.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,n=0;n<t.length;n++){for(var o=0;o<t[n].length;o++)for(var a=0;a<e;a++)i.vertices.push(t[n][o][a]);n>0&&i.holes.push(r+=t[n-1].length)}return i};class gs{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new eo,this.indexArray=new uo,this.indexArray2=new po,this.programConfigurations=new Vo(t.layers,t.zoom),this.segments=new go,this.segments2=new go,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=ms("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=Xo(a,t);if(!this.layers[0]._featureFilter.filter(new Jr(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,e.availableImages):void 0,p={id:s,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Zo(a),patterns:{},sortKey:u};o.push(p)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const t=fs("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{});e.featureIndex.insert(t[o].feature,n,o,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Da),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,e,i,r,n){for(const t of ps(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),n.push(e[0].x),n.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),n.push(e[t].x),n.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const a=Ba.exports(n,o);for(let t=0;t<a.length;t+=3)this.indexArray.emplaceBack(r+a[t],r+a[t+1],r+a[t+2]);i.vertexLength+=e,i.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}}Ar("FillBucket",gs,{omit:["layers","patternFeatures"]});const _s=new dn({"fill-sort-key":new cn(rt.layout_fill["fill-sort-key"])});var ys={paint:new dn({"fill-antialias":new ln(rt.paint_fill["fill-antialias"]),"fill-opacity":new cn(rt.paint_fill["fill-opacity"]),"fill-color":new cn(rt.paint_fill["fill-color"]),"fill-outline-color":new cn(rt.paint_fill["fill-outline-color"]),"fill-translate":new ln(rt.paint_fill["fill-translate"]),"fill-translate-anchor":new ln(rt.paint_fill["fill-translate-anchor"]),"fill-pattern":new hn(rt.paint_fill["fill-pattern"])}),layout:_s};const xs=xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),vs=xn([{name:"a_centroid",components:2,type:"Int16"}],4),{members:bs}=xs;var ws={},Ts=S,Es=Ss;function Ss(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(As,this,e)}function As(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Is(t){for(var e,i,r=0,n=0,o=t.length,a=o-1;n<o;a=n++)r+=((i=t[a]).x-(e=t[n]).x)*(e.y+i.y);return r}Ss.types=["Unknown","Point","LineString","Polygon"],Ss.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,n=0,o=0,a=0,s=[];t.pos<i;){if(n<=0){var l=t.readVarint();r=7&l,n=l>>3}if(n--,1===r||2===r)o+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&s.push(e),e=[]),e.push(new Ts(o,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&s.push(e),s},Ss.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,o=0,a=1/0,s=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<a&&(a=n),n>s&&(s=n),(o+=t.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,s,c]},Ss.prototype.toGeoJSON=function(t,e,i){var r,n,o=this.extent*Math.pow(2,i),a=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=Ss.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+a)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+s)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,n=[],o=0;o<e;o++){var a=Is(t[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&n.push(i),i=[t[o]]):i.push(t[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var Cs=Es,Ms=ks;function ks(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ps,this,e),this.length=this._features.length}function Ps(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}ks.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Cs(this._pbf,e,this.extent,this._keys,this._values)};var zs=Ms;function Ls(t,e,i){if(3===t){var r=new zs(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}ws.VectorTile=function(t,e){this.layers=t.readFields(Ls,{},e)},ws.VectorTileFeature=Es,ws.VectorTileLayer=Ms;const Ds=ws.VectorTileFeature.types,Bs=Math.pow(2,13);function Rs(t,e,i,r,n,o,a,s){t.emplaceBack(e,i,2*Math.floor(r*Bs)+a,n*Bs*2,o*Bs*2,Math.round(s))}class Fs{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new io,this.centroidVertexArray=new Qn,this.indexArray=new uo,this.programConfigurations=new Vo(t.layers,t.zoom),this.segments=new go,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=ms("fill-extrusion",this.layers,e);for(const{feature:r,id:n,index:o,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,s=Xo(r,t);if(!this.layers[0]._featureFilter.filter(new Jr(this.zoom),s,i))continue;const l={id:n,sourceLayerIndex:a,index:o,geometry:t?s.geometry:Zo(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(fs("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,o,i,{}),e.featureIndex.insert(r,l.geometry,o,a,this.index,!0)}}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bs),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,vs.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,n){const o={x:0,y:0,vertexCount:0};for(const i of ps(e,500)){let e=0;for(const t of i)e+=t.length;let r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of i){if(0===t.length)continue;if(Us(t))continue;let e=0;for(let i=0;i<t.length;i++){const n=t[i];if(i>=1){const a=t[i-1];if(!Os(n,a)){r.vertexLength+4>go.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=n.sub(a)._perp()._unit(),i=a.dist(n);e+i>32768&&(e=0),Rs(this.layoutVertexArray,n.x,n.y,t.x,t.y,0,0,e),Rs(this.layoutVertexArray,n.x,n.y,t.x,t.y,0,1,e),o.x+=2*n.x,o.y+=2*n.y,o.vertexCount+=2,e+=i,Rs(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),Rs(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),o.x+=2*a.x,o.y+=2*a.y,o.vertexCount+=2;const s=r.vertexLength;this.indexArray.emplaceBack(s,s+2,s+1),this.indexArray.emplaceBack(s+1,s+2,s+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>go.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==Ds[t.type])continue;const n=[],a=[],s=r.vertexLength;for(const t of i)if(0!==t.length){t!==i[0]&&a.push(n.length/2);for(let e=0;e<t.length;e++){const i=t[e];Rs(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),o.x+=i.x,o.y+=i.y,o.vertexCount+=1,n.push(i.x),n.push(i.y)}}const l=Ba.exports(n,a);for(let t=0;t<l.length;t+=3)this.indexArray.emplaceBack(s+l[t],s+l[t+2],s+l[t+1]);r.primitiveLength+=l.length/3,r.vertexLength+=e}for(let t=0;t<o.vertexCount;t++)this.centroidVertexArray.emplaceBack(Math.floor(o.x/o.vertexCount),Math.floor(o.y/o.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}}function Os(t,e){return t.x===e.x&&(t.x<0||t.x>Go)||t.y===e.y&&(t.y<0||t.y>Go)}function Us(t){return t.every((t=>t.x<0))||t.every((t=>t.x>Go))||t.every((t=>t.y<0))||t.every((t=>t.y>Go))}Ar("FillExtrusionBucket",Fs,{omit:["layers","features"]});var Vs={paint:new dn({"fill-extrusion-opacity":new ln(rt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new cn(rt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ln(rt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ln(rt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new hn(rt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new cn(rt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new cn(rt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ln(rt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Ns(t,e){return t.x*e.x+t.y*e.y}function $s(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const o=e[i],a=t[0],s=n.sub(r),l=o.sub(r),c=a.sub(r),h=Ns(s,s),u=Ns(s,l),p=Ns(l,l),d=Ns(c,s),m=Ns(c,l),f=h*p-u*u,g=(p*d-u*m)/f,_=(h*m-u*d)/f,y=r.z*(1-g-_)+n.z*g+o.z*_;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const Gs=xn([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:js}=Gs,qs=xn([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Zs}=qs,Xs=ws.VectorTileFeature.types,Ws=Math.cos(Math.PI/180*37.5),Hs=Math.pow(2,14)/.5;class Ks{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new ro,this.layoutVertexArray2=new no,this.indexArray=new uo,this.programConfigurations=new Vo(t.layers,t.zoom),this.segments=new go,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=ms("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),o=[];for(const{feature:e,id:a,index:s,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Xo(e,t);if(!this.layers[0]._featureFilter.filter(new Jr(this.zoom),c,i))continue;const h=n?r.evaluate(c,{},i):void 0,u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:s,geometry:t?c.geometry:Zo(e),patterns:{},sortKey:h};o.push(u)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const t=fs("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{});e.featureIndex.insert(t[o].feature,n,o,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Zs)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,js),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n){const o=this.layers[0].layout,a=o.get("line-join").evaluate(t,{}),s=o.get("line-cap"),l=o.get("line-miter-limit"),c=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,s,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}addLine(t,e,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a="Polygon"===Xs[e.type];let s=t.length;for(;s>=2&&t[s-1].equals(t[s-2]);)s--;let l=0;for(;l<s-1&&t[l].equals(t[l+1]);)l++;if(s<(a?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*s,this.layoutVertexArray,this.indexArray);let u,p,d,m,f;this.e1=this.e2=-1,a&&(u=t[s-2],f=t[l].sub(u)._unit()._perp());for(let e=l;e<s;e++){if(d=e===s-1?a?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;f&&(m=f),u&&(p=u),u=t[e],f=d?d.sub(u)._unit()._perp():m,m=m||f;let g=m.add(f);0===g.x&&0===g.y||g._unit();const _=m.x*f.x+m.y*f.y,y=g.x*f.x+g.y*f.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<Ws&&p&&d,w=m.x*f.y-m.y*f.x>0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}const T=p&&d;let E=T?i:a?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),p&&this.updateDistance(p,u),"miter"===E)g._mult(x),this.addCurrentVertex(u,g,0,0,h);else if("flipbevel"===E){if(x>100)g=f.mult(-1);else{const t=x*m.add(f).mag()/m.sub(f).mag();g._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,g,0,0,h),this.addCurrentVertex(u,g.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,m,e,i,h),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+_*(_*(3.55645-1.43519*_)-3.2452))*t*t+(.848013+_*(.215638*_-1.06021)))}const r=f.sub(m)._mult(i)._add(m)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}d&&this.addCurrentVertex(u,f,-e,-i,h)}else if("butt"===E)this.addCurrentVertex(u,g,0,0,h);else if("square"===E){const t=p?1:-1;this.addCurrentVertex(u,g,t,t,h)}else"round"===E&&(p&&(this.addCurrentVertex(u,m,0,0,h),this.addCurrentVertex(u,m,1,1,h,!0)),d&&(this.addCurrentVertex(u,f,-1,-1,h,!0),this.addCurrentVertex(u,f,0,0,h)));if(b&&e<s-1){const t=u.dist(d);if(t>2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,n,o=!1){const a=e.y*r-e.x,s=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,o,!1,i,n),this.addHalfVertex(t,a,s,o,!0,-r,n),this.distance>Hs/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,i,r,n,o))}addHalfVertex({x:t,y:e},i,r,n,o,a,s){const l=.5*(this.lineClips?this.scaledDistance*(Hs-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),s.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Ar("LineBucket",Ks,{omit:["layers","patternFeatures"]});const Ys=new dn({"line-cap":new ln(rt.layout_line["line-cap"]),"line-join":new cn(rt.layout_line["line-join"]),"line-miter-limit":new ln(rt.layout_line["line-miter-limit"]),"line-round-limit":new ln(rt.layout_line["line-round-limit"]),"line-sort-key":new cn(rt.layout_line["line-sort-key"])});var Js={paint:new dn({"line-opacity":new cn(rt.paint_line["line-opacity"]),"line-color":new cn(rt.paint_line["line-color"]),"line-translate":new ln(rt.paint_line["line-translate"]),"line-translate-anchor":new ln(rt.paint_line["line-translate-anchor"]),"line-width":new cn(rt.paint_line["line-width"]),"line-gap-width":new cn(rt.paint_line["line-gap-width"]),"line-offset":new cn(rt.paint_line["line-offset"]),"line-blur":new cn(rt.paint_line["line-blur"]),"line-dasharray":new un(rt.paint_line["line-dasharray"]),"line-pattern":new hn(rt.paint_line["line-pattern"]),"line-gradient":new pn(rt.paint_line["line-gradient"])}),layout:Ys};const Qs=new class extends cn{possiblyEvaluate(t,e){return e=new Jr(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=s({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Js.paint.properties["line-width"].specification);function tl(t,e){return e>0?e+2*t:t}Qs.useIntegerZoom=!0;const el=xn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),il=xn([{name:"a_projected_pos",components:3,type:"Float32"}],4);xn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const rl=xn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);xn([{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 nl=xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ol=xn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function al(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Yr.applyArabicShaping&&(t=Yr.applyArabicShaping(t)),t}(t.text,e,i)})),t}xn([{name:"triangle",components:3,type:"Uint16"}]),xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint32",name:"glyphStartIndex"},{type:"Uint32",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"}]),xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"angle"}]),xn([{type:"Float32",name:"offsetX"}]),xn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const sl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ll=24,cl=pl,hl=function(t,e,i,r,n){var o,a,s=8*n-r-1,l=(1<<s)-1,c=l>>1,h=-7,u=i?n-1:0,p=i?-1:1,d=t[e+u];for(u+=p,o=d&(1<<-h)-1,d>>=-h,h+=s;h>0;o=256*o+t[e+u],u+=p,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=r;h>0;a=256*a+t[e+u],u+=p,h-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},ul=function(t,e,i,r,n,o){var a,s,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(a++,l/=2),a+u>=h?(s=0,a=h):a+u>=1?(s=(e*l-1)*Math.pow(2,n),a+=u):(s=e*Math.pow(2,u-1)*Math.pow(2,n),a=0));n>=8;t[i+d]=255&s,d+=m,s/=256,n-=8);for(a=a<<n|s,c+=n;c>0;t[i+d]=255&a,d+=m,a/=256,c-=8);t[i+d-m]|=128*f};function pl(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}pl.Varint=0,pl.Fixed64=1,pl.Bytes=2,pl.Fixed32=5;var dl,ml=4294967296,fl=1/ml,gl="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _l(t){return t.type===pl.Bytes?t.readVarint()+t.pos:t.pos+1}function yl(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function xl(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function vl(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function bl(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function wl(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function Tl(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function El(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function Sl(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function Al(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Il(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function Cl(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Ml(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function kl(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Pl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function zl(t,e,i){1===t&&i.readMessage(Ll,e)}function Ll(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:o,left:a,top:s,advance:l}=i.readMessage(Dl,{});e.push({id:t,bitmap:new Ma({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:a,top:s,advance:l}})}}function Dl(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Bl(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,o=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:o,fill:e/(n*o)||0}}pl.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,t(n,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Ml(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Pl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ml(this.buf,this.pos)+Ml(this.buf,this.pos+4)*ml;return this.pos+=8,t},readSFixed64:function(){var t=Ml(this.buf,this.pos)+Pl(this.buf,this.pos+4)*ml;return this.pos+=8,t},readFloat:function(){var t=hl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=hl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return yl(t,r,e);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return yl(t,r,e);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return yl(t,r,e);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return yl(t,r,e);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return yl(t,r,e);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return yl(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&gl?function(t,e,i){return gl.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var o,a,s,l=t[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=t[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(a=t[n+2],128==(192&(o=t[n+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&o)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(a=t[n+2],s=t[n+3],128==(192&(o=t[n+1]))&&128==(192&a)&&128==(192&s)&&((c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==pl.Bytes)return t.push(this.readVarint(e));var i=_l(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==pl.Bytes)return t.push(this.readSVarint());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==pl.Bytes)return t.push(this.readBoolean());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==pl.Bytes)return t.push(this.readFloat());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==pl.Bytes)return t.push(this.readDouble());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==pl.Bytes)return t.push(this.readFixed32());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==pl.Bytes)return t.push(this.readSFixed32());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==pl.Bytes)return t.push(this.readFixed64());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==pl.Bytes)return t.push(this.readSFixed64());var e=_l(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===pl.Varint)for(;this.buf[this.pos++]>127;);else if(e===pl.Bytes)this.pos=this.readVarint()+this.pos;else if(e===pl.Fixed32)this.pos+=4;else{if(e!==pl.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),kl(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),kl(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),kl(this.buf,-1&t,this.pos),kl(this.buf,Math.floor(t*fl),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),kl(this.buf,-1&t,this.pos),kl(this.buf,Math.floor(t*fl),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&xl(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),ul(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ul(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&xl(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,pl.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,vl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,bl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,El,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,wl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Tl,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Sl,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Al,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Il,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Cl,e)},writeBytesField:function(t,e){this.writeTag(t,pl.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,pl.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,pl.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,pl.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,pl.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,pl.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,pl.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,pl.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,pl.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,pl.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class Rl{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Fl{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:o,h:a}=Bl(n),s=new ka({width:o||1,height:a||1});for(const e in t){const r=t[e],n=i[e].paddedRect;ka.copy(r.data,s,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,o=n.x+1,a=n.y+1,l=i.data.width,c=i.data.height;ka.copy(i.data,s,{x:0,y:0},{x:o,y:a},i.data),ka.copy(i.data,s,{x:0,y:c-1},{x:o,y:a-1},{width:l,height:1}),ka.copy(i.data,s,{x:0,y:0},{x:o,y:a+c},{width:l,height:1}),ka.copy(i.data,s,{x:l-1,y:0},{x:o-1,y:a},{width:1,height:c}),ka.copy(i.data,s,{x:0,y:0},{x:o+l,y:a},{width:1,height:c})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),e[r]=new Rl(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}Ar("ImagePosition",Rl),Ar("ImageAtlas",Fl),t.WritingMode=void 0,(dl=t.WritingMode||(t.WritingMode={}))[dl.none=0]="none",dl[dl.horizontal=1]="horizontal",dl[dl.vertical=2]="vertical",dl[dl.horizontalOnly=3]="horizontalOnly";const Ol=-17;class Ul{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Ul;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Ul;return e.imageName=t,e}}class Vl{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Vl;for(let r=0;r<t.sections.length;r++){const n=t.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,e)}return i}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=function(t){let e="";for(let i=0;i<t.length;i++){const r=t.charCodeAt(i+1)||null,n=t.charCodeAt(i-1)||null;e+=r&&Rr(r)&&!sl[t[i+1]]||n&&Rr(n)&&!sl[t[i-1]]||!sl[t[i]]?t[i]:sl[t[i]]}return e}(this.text)}trim(){let t=0;for(let e=0;e<this.text.length&&Gl[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let i=this.text.length-1;i>=0&&i>=t&&Gl[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Vl;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Ul.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(i)}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void m("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(Ul.forImage(e)),this.sectionIndex.push(this.sections.length-1)):m("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Nl(t,e){const i=[],r=t.text;let n=0;for(const r of e)i.push(t.substring(n,r)),n=r;return n<r.length&&i.push(t.substring(n,r.length)),i}function $l(e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g){const _=Vl.fromFeature(e,o);let y;p===t.WritingMode.vertical&&_.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Yr;if(x&&1===_.sections.length){y=[];const t=x(_.toString(),Kl(_,h,a,i,n,m,f));for(const e of t){const t=new Vl;t.text=e,t.sections=_.sections;for(let i=0;i<e.length;i++)t.sectionIndex.push(0);y.push(t)}}else if(v){y=[];const t=v(_.text,_.sectionIndex,Kl(_,h,a,i,n,m,f));for(const e of t){const t=new Vl;t.text=e[0],t.sectionIndex=e[1],t.sections=_.sections,y.push(t)}}else y=Nl(_,Kl(_,h,a,i,n,m,f));const b=[],w={positionedLines:b,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:p,iconsInText:!1,verticalizable:!1};return function(e,i,r,n,o,a,s,l,c,h,u,p){let d=0,m=Ol,f=0,g=0;const _="right"===l?1:"left"===l?0:.5;let y=0;for(const s of o){s.trim();const o=s.getMaxScale(),l=(o-1)*ll,v={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=v;const b=v.positionedGlyphs;let w=0;if(!s.length()){m+=a,++y;continue}for(let a=0;a<s.length();a++){const f=s.getSection(a),g=s.getSectionIndex(a),_=s.getCharCode(a);let y=0,v=null,T=null,E=null,S=ll;const A=!(c===t.WritingMode.horizontal||!u&&!Br(_)||u&&(Gl[_]||(x=_,Pr.Arabic(x)||Pr["Arabic Supplement"](x)||Pr["Arabic Extended-A"](x)||Pr["Arabic Presentation Forms-A"](x)||Pr["Arabic Presentation Forms-B"](x))));if(f.imageName){const t=n[f.imageName];if(!t)continue;E=f.imageName,e.iconsInText=e.iconsInText||!0,T=t.paddedRect;const i=t.displaySize;f.scale=f.scale*ll/p,v={width:i[0],height:i[1],left:1,top:-3,advance:A?i[1]:i[0]},y=l+(ll-i[1]*f.scale),S=v.advance;const r=A?i[0]*f.scale-ll*o:i[1]*f.scale-ll*o;r>0&&r>w&&(w=r)}else{const t=r[f.fontStack],e=t&&t[_];if(e&&e.rect)T=e.rect,v=e.metrics;else{const t=i[f.fontStack],e=t&&t[_];if(!e)continue;v=e.metrics}y=(o-f.scale)*ll}A?(e.verticalizable=!0,b.push({glyph:_,imageName:E,x:d,y:m+y,vertical:A,scale:f.scale,fontStack:f.fontStack,sectionIndex:g,metrics:v,rect:T}),d+=S*f.scale+h):(b.push({glyph:_,imageName:E,x:d,y:m+y,vertical:A,scale:f.scale,fontStack:f.fontStack,sectionIndex:g,metrics:v,rect:T}),d+=v.advance*f.scale+h)}0!==b.length&&(f=Math.max(d-h,f),Jl(b,0,b.length-1,_,w)),d=0;const T=a*o+w;v.lineOffset=Math.max(w,l),m+=T,g=Math.max(T,g),++y}var x;const v=m-Ol,{horizontalAlign:b,verticalAlign:w}=Yl(s);(function(t,e,i,r,n,o,a,s,l){const c=(e-i)*n;let h=0;h=o!==a?-s*r-Ol:(-r*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(e.positionedLines,_,b,w,f,g,a,v,o.length),e.top+=-w*v,e.bottom=e.top+v,e.left+=-b*f,e.right=e.left+f}(w,i,r,n,y,s,l,c,p,h,d,g),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&w}const Gl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},jl={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 ql(t,e,i,r,n,o){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*ll/o+n:0}{const r=i[e.fontStack],o=r&&r[t];return o?o.metrics.advance*e.scale+n:0}}function Zl(t,e,i,r){const n=Math.pow(t-e,2);return r?t<e?n/2:2*n:n+Math.abs(i)*i}function Xl(t,e,i){let r=0;return 10===t&&(r-=1e4),i&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function Wl(t,e,i,r,n,o){let a=null,s=Zl(e,i,n,o);for(const t of r){const r=Zl(e-t.x,i,n,o)+t.badness;r<=s&&(a=t,s=r)}return{index:t,x:e,priorBreak:a,badness:s}}function Hl(t){return t?Hl(t.priorBreak).concat(t.index):[]}function Kl(t,e,i,r,n,o,a){if("point"!==o)return[];if(!t)return[];const s=[],l=function(t,e,i,r,n,o){let a=0;for(let i=0;i<t.length();i++){const s=t.getSection(i);a+=ql(t.getCharCode(i),s,r,n,e,o)}return a/Math.max(1,Math.ceil(a/i))}(t,e,i,r,n,a),c=t.text.indexOf("")>=0;let h=0;for(let i=0;i<t.length();i++){const o=t.getSection(i),p=t.getCharCode(i);if(Gl[p]||(h+=ql(p,o,r,n,e,a)),i<t.length()-1){const e=!((u=p)<11904||!(Pr["Bopomofo Extended"](u)||Pr.Bopomofo(u)||Pr["CJK Compatibility Forms"](u)||Pr["CJK Compatibility Ideographs"](u)||Pr["CJK Compatibility"](u)||Pr["CJK Radicals Supplement"](u)||Pr["CJK Strokes"](u)||Pr["CJK Symbols and Punctuation"](u)||Pr["CJK Unified Ideographs Extension A"](u)||Pr["CJK Unified Ideographs"](u)||Pr["Enclosed CJK Letters and Months"](u)||Pr["Halfwidth and Fullwidth Forms"](u)||Pr.Hiragana(u)||Pr["Ideographic Description Characters"](u)||Pr["Kangxi Radicals"](u)||Pr["Katakana Phonetic Extensions"](u)||Pr.Katakana(u)||Pr["Vertical Forms"](u)||Pr["Yi Radicals"](u)||Pr["Yi Syllables"](u)));(jl[p]||e||o.imageName)&&s.push(Wl(i+1,h,l,s,Xl(p,t.getCharCode(i+1),e&&c),!1))}}var u;return Hl(Wl(t.length(),h,l,s,0,!0))}function Yl(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Jl(t,e,i,r,n){if(!r&&!n)return;const o=t[i],a=(t[i].x+o.metrics.advance*o.scale)*r;for(let r=e;r<=i;r++)t[r].x-=a,t[r].y+=n}function Ql(t,e,i){const{horizontalAlign:r,verticalAlign:n}=Yl(i),o=e[0]-t.displaySize[0]*r,a=e[1]-t.displaySize[1]*n;return{image:t,top:a,bottom:a+t.displaySize[1],left:o,right:o+t.displaySize[0]}}function tc(t,e,i,r,n,o){const a=t.image;let s;if(a.content){const t=a.content,e=a.pixelRatio||1;s=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e]}const l=e.left*o,c=e.right*o;let h,u,p,d;"width"===i||"both"===i?(d=n[0]+l-r[3],u=n[0]+c+r[1]):(d=n[0]+(l+c-a.displaySize[0])/2,u=d+a.displaySize[0]);const m=e.top*o,f=e.bottom*o;return"height"===i||"both"===i?(h=n[1]+m-r[0],p=n[1]+f+r[2]):(h=n[1]+(m+f-a.displaySize[1])/2,p=h+a.displaySize[1]),{image:a,top:h,right:u,bottom:p,left:d,collisionPadding:s}}const ec=128;function ic(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Jr(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let o=n;for(;o<e.length&&e[o]<t+1;)o++;o=Math.min(e.length-1,o);const a=e[n],s=e[o];return"composite"===i.kind?{kind:"composite",minZoom:a,maxZoom:s,interpolationType:r}:{kind:"camera",minZoom:a,maxZoom:s,minSize:i.evaluate(new Jr(a)),maxSize:i.evaluate(new Jr(s)),interpolationType:r}}}class rc extends S{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new rc(this.x,this.y,this.angle,this.segment)}}function nc(t,e,i,r,n){if(void 0===e.segment)return!0;let o=e,a=e.segment+1,s=0;for(;s>-i/2&&(a--,!(a<0));)s-=t[a].dist(o),o=t[a];a=Math.max(a,0),s+=t[a].dist(t[a+1]),a++;const l=[];let c=0;for(;s<i/2;){const e=t[a-1],i=t[a],o=t[a+1];if(!o)break;let h=e.angleTo(i)-i.angleTo(o);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:s,angleDelta:h}),c+=h;s-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;a++,s+=i.dist(o)}return!0}function oc(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function ac(t,e,i){return t?.6*e*i:0}function sc(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function lc(t,e){return 0===t.x||t.x===e||0===t.y||t.y===e}function cc(t,e,i,r,n,o){const a=ac(i,n,o),s=sc(i,r)*o;let l=0;const c=oc(t)/2;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=Se(r.x,n.x,h),p=Se(r.y,n.y,h),d=new rc(u,p,n.angleTo(r),i);return d._round(),!a||nc(t,d,s,a,e)?d:void 0}l+=o}}function hc(t,e,i,r,n,o,a,s,l){const c=ac(r,o,a),h=sc(r,n),u=h*a,p=u/4,d=oc(t),m=lc(t[0],l),f=lc(t[t.length-1],l),g=m||f;let _;e=Math.max(e,u+e/4),_=g?m?e/2*s%e:(h/2+2*o)*a*s%e:(d-(1+2*Math.floor(d/e/2)-1)*e)/2;let y=0,x=_-e;const v=[];for(let r=0;r<t.length-1;r++){const n=t[r],o=t[r+1],a=n.dist(o),s=o.angleTo(n);for(;x+e<y+a;){x+=e;const h=(x-y)/a,m=Se(n.x,o.x,h),f=Se(n.y,o.y,h);if(m>=0&&m<l&&f>=0&&f<l&&x-p>=0&&x+p<=d){const e=new rc(m,f,s,r);e._round(),c&&!nc(t,e,u,c,i)||v.push(e)}}y+=a}return v}function uc(t,e,i,r,n){const o=[];for(let a=0;a<t.length;a++){const s=t[a];let l;for(let t=0;t<s.length-1;t++){let a=s[t],c=s[t+1];a.x<e&&c.x<e||(a.x<e?a=new S(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x<e&&(c=new S(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y<i&&c.y<i||(a.y<i?a=new S(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y<i&&(c=new S(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),a.x>=r&&c.x>=r||(a.x>=r?a=new S(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=r&&(c=new S(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=n&&c.y>=n||(a.y>=n?a=new S(a.x+(n-a.y)/(c.y-a.y)*(c.x-a.x),n)._round():c.y>=n&&(c=new S(a.x+(n-a.y)/(c.y-a.y)*(c.x-a.x),n)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(c)))))}}return o}function pc(t,e,i,r){const n=[],o=t.image,a=o.pixelRatio,s=o.paddedRect.w-2,l=o.paddedRect.h-2,c=t.right-t.left,h=t.bottom-t.top,u=o.stretchX||[[0,s]],p=o.stretchY||[[0,l]],d=(t,e)=>t+e[1]-e[0],m=u.reduce(d,0),f=p.reduce(d,0),g=s-m,_=l-f;let y=0,x=m,v=0,b=f,w=0,T=g,E=0,A=_;if(o.content&&r){const t=o.content;y=dc(u,0,t[0]),v=dc(p,0,t[1]),x=dc(u,t[0],t[2]),b=dc(p,t[1],t[3]),w=t[0]-y,E=t[1]-v,T=t[2]-t[0]-x,A=t[3]-t[1]-b}const I=(r,n,s,l)=>{const u=fc(r.stretch-y,x,c,t.left),p=gc(r.fixed-w,T,r.stretch,m),d=fc(n.stretch-v,b,h,t.top),g=gc(n.fixed-E,A,n.stretch,f),_=fc(s.stretch-y,x,c,t.left),I=gc(s.fixed-w,T,s.stretch,m),C=fc(l.stretch-v,b,h,t.top),M=gc(l.fixed-E,A,l.stretch,f),k=new S(u,d),P=new S(_,d),z=new S(_,C),L=new S(u,C),D=new S(p/a,g/a),B=new S(I/a,M/a),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),i=[e,-t,t,e];k._matMult(i),P._matMult(i),L._matMult(i),z._matMult(i)}const F=r.stretch+r.fixed,O=n.stretch+n.fixed;return{tl:k,tr:P,bl:L,br:z,tex:{x:o.paddedRect.x+1+F,y:o.paddedRect.y+1+O,w:s.stretch+s.fixed-F,h:l.stretch+l.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:B,minFontScaleX:T/a/c,minFontScaleY:A/a/h,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const t=mc(u,g,m),e=mc(p,_,f);for(let i=0;i<t.length-1;i++){const r=t[i],o=t[i+1];for(let t=0;t<e.length-1;t++)n.push(I(r,e[t],o,e[t+1]))}}else n.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:l+1}));return n}function dc(t,e,i){let r=0;for(const n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function mc(t,e,i){const r=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+1,stretch:i}),r}function fc(t,e,i,r){return t/e*i+r}function gc(t,e,i,r){return t-e*i/r}Ar("Anchor",rc);class _c{constructor(t,e,i,r,n,o,a,s,l,c){if(this.boxStartIndex=t.length,l){let t=o.top,e=o.bottom;const i=o.collisionPadding;i&&(t-=i[1],e+=i[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=o.top*a-s[0],h=o.bottom*a+s[2],u=o.left*a-s[3],p=o.right*a+s[1];const d=o.collisionPadding;if(d&&(u-=d[0]*a,l-=d[1]*a,p+=d[2]*a,h+=d[3]*a),c){const t=new S(u,l),e=new S(p,l),i=new S(u,h),r=new S(p,h),n=c*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),u=Math.min(t.x,e.x,i.x,r.x),p=Math.max(t.x,e.x,i.x,r.x),l=Math.min(t.y,e.y,i.y,r.y),h=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,u,l,p,h,i,r,n)}this.boxEndIndex=t.length}}class yc{constructor(t=[],e=xc){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1),o=e[r];const a=r+1;if(a<this.length&&i(e[a],o)<0&&(r=a,o=e[a]),i(o,n)>=0)break;e[t]=o,t=r}e[t]=n}}function xc(t,e){return t<e?-1:t>e?1:0}function vc(t,e=1,i=!1){let r=1/0,n=1/0,o=-1/0,a=-1/0;const s=t[0];for(let t=0;t<s.length;t++){const e=s[t];(!t||e.x<r)&&(r=e.x),(!t||e.y<n)&&(n=e.y),(!t||e.x>o)&&(o=e.x),(!t||e.y>a)&&(a=e.y)}const l=Math.min(o-r,a-n);let c=l/2;const h=new yc([],bc);if(0===l)return new S(r,n);for(let e=r;e<o;e+=l)for(let i=n;i<a;i+=l)h.push(new wc(e+c,i+c,c,t));let u=function(t){let e=0,i=0,r=0;const n=t[0];for(let t=0,o=n.length,a=o-1;t<o;a=t++){const o=n[t],s=n[a],l=o.x*s.y-s.x*o.y;i+=(o.x+s.x)*l,r+=(o.y+s.y)*l,e+=3*l}return new wc(i/e,r/e,0,t)}(t),p=h.length;for(;h.length;){const r=h.pop();(r.d>u.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-u.d<=e||(c=r.h/2,h.push(new wc(r.p.x-c,r.p.y-c,c,t)),h.push(new wc(r.p.x+c,r.p.y-c,c,t)),h.push(new wc(r.p.x-c,r.p.y+c,c,t)),h.push(new wc(r.p.x+c,r.p.y+c,c,t)),p+=4)}return i&&(console.log(`num probes: ${p}`),console.log(`best distance: ${u.d}`)),u.p}function bc(t,e){return e.max-t.max}function wc(t,e,i,r){this.p=new S(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;n<e.length;n++){const o=e[n];for(let e=0,n=o.length,a=n-1;e<n;a=e++){const n=o[e],s=o[a];n.y>t.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(i=!i),r=Math.min(r,ra(t,n,s))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const Tc=Number.POSITIVE_INFINITY;function Ec(t,e){return e[1]!==Tc?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Sc(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Ac(e,i,r,n,o,a,s,l,c,h,u){let p=a.textMaxSize.evaluate(i,{});void 0===p&&(p=s);const d=e.layers[0].layout,f=d.get("icon-offset").evaluate(i,{},u),g=Mc(r.horizontal),_=s/24,y=e.tilePixelRatio*_,x=e.tilePixelRatio*p/24,v=e.tilePixelRatio*l,b=e.tilePixelRatio*d.get("symbol-spacing"),w=d.get("text-padding")*e.tilePixelRatio,T=function(t,e,i,r=1){const n=t.get("icon-padding").evaluate(e,{},i),o=n&&n.values;return[o[0]*r,o[1]*r,o[2]*r,o[3]*r]}(d,i,u,e.tilePixelRatio),E=d.get("text-max-angle")/180*Math.PI,S="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),A="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),I=d.get("symbol-placement"),C=b/2,M=d.get("icon-text-fit");let k;n&&"none"!==M&&(e.allowVerticalPlacement&&r.vertical&&(k=tc(n,r.vertical,M,d.get("icon-text-fit-padding"),f,_)),g&&(n=tc(n,g,M,d.get("icon-text-fit-padding"),f,_)));const P=(l,p)=>{p.x<0||p.x>=Go||p.y<0||p.y>=Go||function(e,i,r,n,o,a,s,l,c,h,u,p,d,f,g,_,y,x,v,b,w,T,E,S,A){const I=e.addToLineVertexArray(i,r);let C,M,k,P,z=0,L=0,D=0,B=0,R=-1,F=-1;const O={};let U=xo.exports(""),V=0,N=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[V,N]=l.layout.get("text-offset").evaluate(w,{},S).map((t=>t*ll)):(V=l.layout.get("text-radial-offset").evaluate(w,{},S)*ll,N=Tc),e.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},S)+90;k=new _c(c,i,h,u,p,n.vertical,d,f,g,t),s&&(P=new _c(c,i,h,u,p,s,y,x,g,t))}if(o){const r=l.layout.get("icon-rotate").evaluate(w,{}),n="none"!==l.layout.get("icon-text-fit"),a=pc(o,r,E,n),d=s?pc(s,r,E,n):void 0;M=new _c(c,i,h,u,p,o,y,x,!1,r),z=4*a.length;const f=e.iconSizeData;let g=null;"source"===f.kind?(g=[ec*l.layout.get("icon-size").evaluate(w,{})],g[0]>Ic&&m(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(g=[ec*T.compositeIconSizes[0].evaluate(w,{},S),ec*T.compositeIconSizes[1].evaluate(w,{},S)],(g[0]>Ic||g[1]>Ic)&&m(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,g,b,v,w,t.WritingMode.none,i,I.lineStartIndex,I.lineLength,-1,S),R=e.icon.placedSymbolArray.length-1,d&&(L=4*d.length,e.addSymbols(e.icon,d,g,b,v,w,t.WritingMode.vertical,i,I.lineStartIndex,I.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1)}const $=Object.keys(n.horizontal);for(const r of $){const o=n.horizontal[r];if(!C){U=xo.exports(o.text);const t=l.layout.get("text-rotate").evaluate(w,{},S);C=new _c(c,i,h,u,p,o,d,f,g,t)}const s=1===o.positionedLines.length;if(D+=Cc(e,i,o,a,l,g,w,_,I,n.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,s?$:[r],O,R,T,S),s)break}n.vertical&&(B+=Cc(e,i,n.vertical,a,l,g,w,_,I,t.WritingMode.vertical,["vertical"],O,F,T,S));const G=C?C.boxStartIndex:e.collisionBoxArray.length,j=C?C.boxEndIndex:e.collisionBoxArray.length,q=k?k.boxStartIndex:e.collisionBoxArray.length,Z=k?k.boxEndIndex:e.collisionBoxArray.length,X=M?M.boxStartIndex:e.collisionBoxArray.length,W=M?M.boxEndIndex:e.collisionBoxArray.length,H=P?P.boxStartIndex:e.collisionBoxArray.length,K=P?P.boxEndIndex:e.collisionBoxArray.length;let Y=-1;const J=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;Y=J(C,Y),Y=J(k,Y),Y=J(M,Y),Y=J(P,Y);const Q=Y>-1?1:0;Q&&(Y*=A/ll),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey),e.symbolInstances.emplaceBack(i.x,i.y,O.right>=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,R,F,U,G,j,q,Z,X,W,H,K,h,D,B,z,L,Q,0,d,V,N,Y,i.angle)}(e,p,l,r,n,o,k,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,y,[w,w,w,w],S,c,v,T,A,f,i,a,h,u,s)};if("line"===I)for(const t of uc(i.geometry,0,0,Go,Go)){const i=hc(t,b,E,r.vertical||g,n,24,x,e.overscaling,Go);for(const r of i)g&&kc(e,g.text,C,r)||P(t,r)}else if("line-center"===I){for(const t of i.geometry)if(t.length>1){const e=cc(t,E,r.vertical||g,n,24,x);e&&P(t,e)}}else if("Polygon"===i.type)for(const t of ps(i.geometry,0)){const e=vc(t,16);P(t[0],new rc(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry)P(t,new rc(t[0].x,t[0].y,0));else if("Point"===i.type)for(const t of i.geometry)for(const e of t)P([e],new rc(e.x,e.y,0))}const Ic=32640;function Cc(t,e,i,r,n,o,a,s,l,c,h,u,p,d,f){const g=function(t,e,i,r,n,o,a,s){const l=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const r of t.positionedGlyphs){if(!r.rect)continue;const o=r.rect||{};let h=4,u=!0,p=1,d=0;const m=(n||s)&&r.vertical,f=r.metrics.advance*r.scale/2;if(s&&e.verticalizable){const e=(r.scale-1)*ll,i=(ll-r.metrics.width*r.scale)/2;d=t.lineOffset/2-(r.imageName?-i:e)}if(r.imageName){const t=a[r.imageName];u=t.sdf,p=t.pixelRatio,h=1/p}const g=n?[r.x+f,r.y]:[0,0];let _=n?[0,0]:[r.x+f+i[0],r.y+i[1]-d],y=[0,0];m&&(y=_,_=[0,0]);const x=(r.metrics.left-h)*r.scale-f+_[0],v=(-r.metrics.top-h)*r.scale+_[1],b=x+o.w*r.scale/p,w=v+o.h*r.scale/p,T=new S(x,v),E=new S(b,v),A=new S(x,w),I=new S(b,w);if(m){const t=new S(-f,f-Ol),e=-Math.PI/2,i=12-f,n=new S(22-i,-(r.imageName?i:0)),o=new S(...y);T._rotateAround(e,t)._add(n)._add(o),E._rotateAround(e,t)._add(n)._add(o),A._rotateAround(e,t)._add(n)._add(o),I._rotateAround(e,t)._add(n)._add(o)}if(l){const t=Math.sin(l),e=Math.cos(l),i=[e,-t,t,e];T._matMult(i),E._matMult(i),A._matMult(i),I._matMult(i)}const C=new S(0,0),M=new S(0,0);c.push({tl:T,tr:E,bl:A,br:I,tex:o,writingMode:e.writingMode,glyphOffset:g,sectionIndex:r.sectionIndex,isSDF:u,pixelOffsetTL:C,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return c}(0,i,s,n,o,a,r,t.allowVerticalPlacement),_=t.textSizeData;let y=null;"source"===_.kind?(y=[ec*n.layout.get("text-size").evaluate(a,{})],y[0]>Ic&&m(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(y=[ec*d.compositeTextSizes[0].evaluate(a,{},f),ec*d.compositeTextSizes[1].evaluate(a,{},f)],(y[0]>Ic||y[1]>Ic)&&m(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,g,y,s,o,a,c,e,l.lineStartIndex,l.lineLength,p,f);for(const e of h)u[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function Mc(t){for(const e in t)return t[e];return null}function kc(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const Pc=ws.VectorTileFeature.types,zc=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Lc(t,e,i,r,n,o,a,s,l,c,h,u,p){const d=s?Math.min(Ic,Math.round(s[0])):0,m=s?Math.min(Ic,Math.round(s[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),o,a,(d<<1)+(l?1:0),m,16*c,16*h,256*u,256*p)}function Dc(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function Bc(t){for(const e of t.sections)if(Ur(e.text))return!0;return!1}class Rc{constructor(t){this.layoutVertexArray=new ao,this.indexArray=new uo,this.programConfigurations=t,this.segments=new go,this.dynamicLayoutVertexArray=new so,this.opacityVertexArray=new lo,this.placedSymbolArray=new Zn}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,el.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,il.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,zc,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Ar("SymbolBuffers",Rc);class Fc{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new go,this.collisionVertexArray=new ho}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,rl.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Ar("CollisionBuffers",Fc);class Oc{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.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=fa([]),this.placementViewportMatrix=fa([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ic(this.zoom,i["text-size"]),this.iconSizeData=ic(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap="never"!==Gc(r,"text-overlap","text-allow-overlap")||"never"!==Gc(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.WritingMode[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Rc(new Vo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Rc(new Vo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Hn,this.lineVertexArray=new Kn,this.symbolInstances=new Wn}calculateGlyphDependencies(t,e,i,r,n){for(let o=0;o<t.length;o++)if(e[t.charCodeAt(o)]=!0,(i||r)&&n){const i=sl[t.charAt(o)];i&&(e[i.charCodeAt(0)]=!0)}}populate(e,i,r){const n=this.layers[0],o=n.layout,a=o.get("text-font"),s=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==s.value.kind||s.value.value instanceof Ft&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const p=i.iconDependencies,d=i.glyphDependencies,m=i.availableImages,f=new Jr(this.zoom);for(const{feature:i,id:s,index:l,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,_=Xo(i,e);if(!n._featureFilter.filter(f,_,r))continue;let y,x;if(e||(_.geometry=Zo(i)),c){const t=n.getValueAndResolveTokens("text-field",_,r,m),e=Ft.factory(t);Bc(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Hr()||this.hasRTLText&&Yr.isParsed())&&(y=al(e,n,_))}if(h){const t=n.getValueAndResolveTokens("icon-image",_,r,m);x=t instanceof Ut?t:Ut.fromString(t)}if(!y&&!x)continue;const v=this.sortFeaturesByKey?u.evaluate(_,{},r):void 0;if(this.features.push({id:s,text:y,icon:x,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:Pc[i.type],sortKey:v}),x&&(p[x.name]=!0),y){const e=a.evaluate(_,{},r).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.WritingMode.vertical)>=0;for(const t of y.sections)if(t.image)p[t.image.name]=!0;else{const r=zr(y.toString()),n=t.fontStack||e,o=d[n]=d[n]||{};this.calculateGlyphDependencies(t.text,o,i,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function o(e){r.push(t[e]),n++}function a(t,e,n){const o=i[t];return delete i[t],i[e]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function s(t,i,n){const o=e[i];return delete e[i],e[t]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){o(c);continue}const d=l(p,u),m=l(p,u,!0);if(d in i&&m in e&&i[d]!==e[m]){const t=s(d,m,u),n=a(d,m,r[t].geometry);delete e[d],delete i[m],i[l(p,r[n].geometry,!0)]=n,r[t].geometry=null}else d in i?a(d,m,u):m in e?s(d,m,u):(o(c),e[d]=n-1,i[m]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let r=t.segment+1;r<e.length;r++)n[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=n[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,i,r,n,o,a,s,l,c,h,u,p){const d=e.indexArray,m=e.layoutVertexArray,f=e.segments.prepareSegment(4*i.length,m,d,this.canOverlap?a.sortKey:void 0),g=this.glyphOffsetArray.length,_=f.vertexLength,y=this.allowVerticalPlacement&&s===t.WritingMode.vertical?Math.PI/2:0,x=a.text&&a.text.sections;for(let t=0;t<i.length;t++){const{tl:n,tr:o,bl:s,br:c,tex:h,pixelOffsetTL:u,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=i[t],E=f.vertexLength,S=b[1];Lc(m,l.x,l.y,n.x,S+n.y,h.x,h.y,r,w,u.x,u.y,_,v),Lc(m,l.x,l.y,o.x,S+o.y,h.x+h.w,h.y,r,w,g.x,u.y,_,v),Lc(m,l.x,l.y,s.x,S+s.y,h.x,h.y+h.h,r,w,u.x,g.y,_,v),Lc(m,l.x,l.y,c.x,S+c.y,h.x+h.w,h.y+h.h,r,w,g.x,g.y,_,v),Dc(e.dynamicLayoutVertexArray,l,y),d.emplaceBack(E,E+1,E+2),d.emplaceBack(E+1,E+2,E+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),t!==i.length-1&&T===i[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,a,a.index,{},p,x&&x[T])}e.placedSymbolArray.emplaceBack(l.x,l.y,g,this.glyphOffsetArray.length-g,_,c,h,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],s,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,r,n,o){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,n,Math.round(o.x),Math.round(o.y))}addCollisionDebugVertices(t,e,i,r,n,o,a){const s=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),l=s.vertexLength,c=n.layoutVertexArray,h=n.collisionVertexArray,u=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(c,h,o,u,p,new S(t,e)),this._addCollisionDebugVertex(c,h,o,u,p,new S(i,e)),this._addCollisionDebugVertex(c,h,o,u,p,new S(i,r)),this._addCollisionDebugVertex(c,h,o,u,p,new S(t,r)),s.vertexLength+=4;const d=n.indexArray;d.emplaceBack(l,l+1),d.emplaceBack(l+1,l+2),d.emplaceBack(l+2,l+3),d.emplaceBack(l+3,l),s.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let n=t;n<e;n++){const t=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Fc(co,nl.members,po),this.iconCollisionBox=new Fc(co,nl.members,po);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,n,o,a,s,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=o;e<a;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=s;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.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(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const a=this.symbolInstances.get(t);r.push(0|Math.round(e*a.anchorX+i*a.anchorY)),n.push(a.featureIndex)}return o.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),o}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ar("SymbolBucket",Oc,{omit:["layers","collisionBoxArray","features","compareText"]}),Oc.addDynamicAttributes=Dc;const Uc=new dn({"symbol-placement":new ln(rt.layout_symbol["symbol-placement"]),"symbol-spacing":new ln(rt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ln(rt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new cn(rt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ln(rt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ln(rt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new ln(rt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new ln(rt.layout_symbol["icon-ignore-placement"]),"icon-optional":new ln(rt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ln(rt.layout_symbol["icon-rotation-alignment"]),"icon-size":new cn(rt.layout_symbol["icon-size"]),"icon-text-fit":new ln(rt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ln(rt.layout_symbol["icon-text-fit-padding"]),"icon-image":new cn(rt.layout_symbol["icon-image"]),"icon-rotate":new cn(rt.layout_symbol["icon-rotate"]),"icon-padding":new cn(rt.layout_symbol["icon-padding"]),"icon-keep-upright":new ln(rt.layout_symbol["icon-keep-upright"]),"icon-offset":new cn(rt.layout_symbol["icon-offset"]),"icon-anchor":new cn(rt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ln(rt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ln(rt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ln(rt.layout_symbol["text-rotation-alignment"]),"text-field":new cn(rt.layout_symbol["text-field"]),"text-font":new cn(rt.layout_symbol["text-font"]),"text-size":new cn(rt.layout_symbol["text-size"]),"text-max-width":new cn(rt.layout_symbol["text-max-width"]),"text-line-height":new ln(rt.layout_symbol["text-line-height"]),"text-letter-spacing":new cn(rt.layout_symbol["text-letter-spacing"]),"text-justify":new cn(rt.layout_symbol["text-justify"]),"text-radial-offset":new cn(rt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ln(rt.layout_symbol["text-variable-anchor"]),"text-anchor":new cn(rt.layout_symbol["text-anchor"]),"text-max-angle":new ln(rt.layout_symbol["text-max-angle"]),"text-writing-mode":new ln(rt.layout_symbol["text-writing-mode"]),"text-rotate":new cn(rt.layout_symbol["text-rotate"]),"text-padding":new ln(rt.layout_symbol["text-padding"]),"text-keep-upright":new ln(rt.layout_symbol["text-keep-upright"]),"text-transform":new cn(rt.layout_symbol["text-transform"]),"text-offset":new cn(rt.layout_symbol["text-offset"]),"text-allow-overlap":new ln(rt.layout_symbol["text-allow-overlap"]),"text-overlap":new ln(rt.layout_symbol["text-overlap"]),"text-ignore-placement":new ln(rt.layout_symbol["text-ignore-placement"]),"text-optional":new ln(rt.layout_symbol["text-optional"])});var Vc={paint:new dn({"icon-opacity":new cn(rt.paint_symbol["icon-opacity"]),"icon-color":new cn(rt.paint_symbol["icon-color"]),"icon-halo-color":new cn(rt.paint_symbol["icon-halo-color"]),"icon-halo-width":new cn(rt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new cn(rt.paint_symbol["icon-halo-blur"]),"icon-translate":new ln(rt.paint_symbol["icon-translate"]),"icon-translate-anchor":new ln(rt.paint_symbol["icon-translate-anchor"]),"text-opacity":new cn(rt.paint_symbol["text-opacity"]),"text-color":new cn(rt.paint_symbol["text-color"],{runtimeType:ft,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new cn(rt.paint_symbol["text-halo-color"]),"text-halo-width":new cn(rt.paint_symbol["text-halo-width"]),"text-halo-blur":new cn(rt.paint_symbol["text-halo-blur"]),"text-translate":new ln(rt.paint_symbol["text-translate"]),"text-translate-anchor":new ln(rt.paint_symbol["text-translate-anchor"])}),layout:Uc};class Nc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:ut,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ar("FormatSectionOverride",Nc,{omit:["defaultValue"]});class $c extends fn{constructor(t){super(t,Vc)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||Li(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Oc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Vc.paint.overridableProperties){if(!$c.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Nc(e),r=new zi(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Bi("source",r):new Ri("composite",r,e.value.zoomStops),this.paint._values[t]=new an(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&$c.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Vc.paint.properties[e];let n=!1;const o=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ft)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof jt&&$t(e.value)===xt?o(e.value.sections):e instanceof hi?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}}function Gc(t,e,i){let r="never";const n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}var jc={paint:new dn({"background-color":new ln(rt.paint_background["background-color"]),"background-pattern":new un(rt.paint_background["background-pattern"]),"background-opacity":new ln(rt.paint_background["background-opacity"])})},qc={paint:new dn({"raster-opacity":new ln(rt.paint_raster["raster-opacity"]),"raster-hue-rotate":new ln(rt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ln(rt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ln(rt.paint_raster["raster-brightness-max"]),"raster-saturation":new ln(rt.paint_raster["raster-saturation"]),"raster-contrast":new ln(rt.paint_raster["raster-contrast"]),"raster-resampling":new ln(rt.paint_raster["raster-resampling"]),"raster-fade-duration":new ln(rt.paint_raster["raster-fade-duration"])})};class Zc extends fn{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const Xc={circle:class extends fn{constructor(t){super(t,ua)}createBucket(t){return new Ho(t)}queryRadius(t){const e=t;return sa("circle-radius",this,e)+sa("circle-stroke-width",this,e)+la(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,o,a,s){const l=ca(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,a),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e){return t.map((t=>Ta(t,e)))}(l,s),p=h?c*a:c;for(const t of r)for(const e of t){const t=h?e:Ta(e,s);let i=p;const r=ba([],[e.x,e.y,0,1],s);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/o.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=o.cameraToCenterDistance/r[3]),Yo(u,t,i))return!0}return!1}},heatmap:class extends fn{constructor(t){super(t,Sa),this._updateColorRamp()}createBucket(t){return new Ea(t)}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Pa({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 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}},hillshade:class extends fn{constructor(t){super(t,za)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}},fill:class extends fn{constructor(t){super(t,ys)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new gs(t)}queryRadius(){return la(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,o,a){return Jo(ca(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,a),r)}isTileClipped(){return!0}},"fill-extrusion":class extends fn{constructor(t){super(t,Vs)}createBucket(t){return new Fs(t)}queryRadius(){return la(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,n,o,a,s){const l=ca(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,a),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e,i,r){const n=[];for(const i of t){const t=[i.x,i.y,0,1];ba(t,t,e),n.push(new S(t[0]/t[3],t[1]/t[3]))}return n}(l,s),p=function(t,e,i,r){const n=[],o=[],a=r[8]*e,s=r[9]*e,l=r[10]*e,c=r[11]*e,h=r[8]*i,u=r[9]*i,p=r[10]*i,d=r[11]*i;for(const e of t){const t=[],i=[];for(const n of e){const e=n.x,o=n.y,m=r[0]*e+r[4]*o+r[12],f=r[1]*e+r[5]*o+r[13],g=r[2]*e+r[6]*o+r[14],_=r[3]*e+r[7]*o+r[15],y=g+l,x=_+c,v=m+h,b=f+u,w=g+p,T=_+d,E=new S((m+a)/x,(f+s)/x);E.z=y/x,t.push(E);const A=new S(v/T,b/T);A.z=w/T,i.push(A)}n.push(t),o.push(i)}return[n,o]}(r,h,c,s);return function(t,e,i){let r=1/0;Jo(i,e)&&(r=$s(i,e[0]));for(let n=0;n<e.length;n++){const o=e[n],a=t[n];for(let t=0;t<o.length-1;t++){const e=o[t],n=[e,o[t+1],a[t+1],a[t],e];Ko(i,n)&&(r=Math.min(r,$s(i,n)))}}return r!==1/0&&r}(p[0],p[1],u)}},line:class extends fn{constructor(t){super(t,Js),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof Ee,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Qs.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Ks(t)}queryRadius(t){const e=t,i=tl(sa("line-width",this,e),sa("line-gap-width",this,e)),r=sa("line-offset",this,e);return i/2+Math.abs(r)+la(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,n,o,a){const s=ca(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,a),l=a/2*tl(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=t[r],o=[];for(let t=0;t<n.length;t++){const i=n[t-1],r=n[t],a=n[t+1],s=0===t?new S(0,0):r.sub(i)._unit()._perp(),l=t===n.length-1?new S(0,0):a.sub(r)._unit()._perp(),c=s._add(l)._unit(),h=c.x*l.x+c.y*l.y;0!==h&&c._mult(1/h),o.push(c._mult(e)._add(r))}i.push(o)}return i}(r,c*a)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(oa(t,n[e]))return!0;if(Qo(t,n,i))return!0}return!1}(s,r,l)}isTileClipped(){return!0}},symbol:$c,background:class extends fn{constructor(t){super(t,jc)}},raster:class extends fn{constructor(t){super(t,qc)}}};class Wc{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(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 Hc=6371008.8;class Kc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Kc(a(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Hc*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Yc(new Kc(this.lng-i,this.lat-e),new Kc(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Kc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Kc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Kc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Yc{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?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 Kc?new Kc(t.lng,t.lat):Kc.convert(t),this}setSouthWest(t){return this._sw=t instanceof Kc?new Kc(t.lng,t.lat):Kc.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof Kc)r=t,n=t;else{if(!(t instanceof Yc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Yc.convert(t)):this.extend(Kc.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Kc(r.lng,r.lat),this._ne=new Kc(n.lng,n.lat)),this}getCenter(){return new Kc((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 Kc(this.getWest(),this.getNorth())}getSouthEast(){return new Kc(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:e,lat:i}=Kc.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return t instanceof Yc?t:t?new Yc(t):t}}const Jc=2*Math.PI*Hc;function Qc(t){return Jc*Math.cos(t*Math.PI/180)}function th(t){return(180+t)/360}function eh(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ih(t,e){return t/Qc(e)}function rh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class nh{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Kc.convert(t);return new nh(th(i.lng),eh(i.lat),ih(e,i.lat))}toLngLat(){return new Kc(360*this.x-180,rh(this.y))}toAltitude(){return this.z*Qc(rh(this.y))}meterInMercatorCoordinateUnits(){return 1/Jc*(t=rh(this.y),1/Math.cos(t*Math.PI/180));var t}}function oh(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class ah{constructor(t,e,i){if(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=ch(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(o=this.y,a=this.z,s=oh(256*(n=this.x),256*(o=Math.pow(2,a)-o-1),a),l=oh(256*(n+1),256*(o+1),a),s[0]+","+s[1]+","+l[0]+","+l[1]);var n,o,a,s,l;const c=function(t,e,i){let r,n="";for(let o=t;o>0;o--)r=1<<o-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.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("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new S((t.x*e-this.x)*Go,(t.y*e-this.y)*Go)}toString(){return`${this.z}/${this.x}/${this.y}`}}class sh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=ch(t,e.z,e.z,e.x,e.y)}}class lh{constructor(t,e,i,r,n){if(t<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new ah(i,+r,+n),this.key=ch(e,t,i,r,n)}clone(){return new lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new lh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new lh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?ch(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):ch(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new lh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new lh(e,this.wrap,e,i,r),new lh(e,this.wrap,e,i+1,r),new lh(e,this.wrap,e,i,r+1),new lh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new lh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new lh(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new sh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new nh(t.x-this.wrap,t.y))}}function ch(t,e,i,r,n){(t*=2)<0&&(t=-1*t-1);const o=1<<i;return(o*o*t+o*n+r).toString(36)+i.toString(36)+e.toString(36)}Ar("CanonicalTileID",ah),Ar("OverscaledTileID",lh,{omit:["posMatrix"]});class hh{constructor(t,e,i){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void m(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const r=this.dim=e.height-2;this.data=new Uint32Array(e.data.buffer),this.encoding=i||"mapbox";for(let t=0;t<r;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(r,t)]=this.data[this._idx(r-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,r)]=this.data[this._idx(t,r-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(r,-1)]=this.data[this._idx(r-1,0)],this.data[this._idx(-1,r)]=this.data[this._idx(0,r-1)],this.data[this._idx(r,r)]=this.data[this._idx(r-1,r-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<r;t++)for(let e=0;e<r;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(i[r],i[r+1],i[r+2])}getUnpackVector(){return"terrarium"===this.encoding?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}getPixels(){return new ka({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=a-1;break;case 1:a=o+1}const s=-e*this.dim,l=-i*this.dim;for(let e=o;e<a;e++)for(let i=r;i<n;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+s,e+l)]}}Ar("DEMData",hh);class uh{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class ph{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class dh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Er(Go,16,0),this.grid3D=new Er(Go,16,0),this.featureIndexArray=new Jn,this.promoteId=e}insert(t,e,i,r,n,o){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const s=o?this.grid3D:this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<Go&&r[1]<Go&&r[2]>=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ws.VectorTile(new cl(this.rawTileData)).layers,this.sourceLayerCoder=new uh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},o=Go/t.tileSize/t.scale,a=Wi(n.filter),s=t.queryGeometry,l=t.queryPadding*o,c=fh(s),h=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),u=fh(t.cameraQueryGeometry),p=this.grid3D.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l,((e,i,r,n)=>function(t,e,i,r,n){for(const o of t)if(e<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new S(e,i),new S(e,n),new S(r,n),new S(r,i)];if(t.length>2)for(const e of o)if(oa(t,e))return!0;for(let e=0;e<t.length-1;e++)if(aa(t[e],t[e+1],o))return!0;return!1}(t.cameraQueryGeometry,e-l,i-l,r+l,n+l)));for(const t of p)h.push(t);h.sort(gh);const d={};let m;for(let l=0;l<h.length;l++){const c=h[l];if(c===m)continue;m=c;const u=this.featureIndexArray.get(c);let p=null;this.loadMatchingFeature(d,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,a,n.layers,n.availableImages,e,i,r,((e,i,r)=>(p||(p=Zo(e)),i.queryIntersectsFeature(s,e,r,p,this.z,t.transform,o,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,i,r,n,o,a,l,c,h,u){const p=this.bucketLayerIDs[e];if(o&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(o,p))return;const d=this.sourceLayerCoder.decode(i),m=this.vtLayers[d].feature(r);if(n.needGeometry){const t=Xo(m,!0);if(!n.filter(new Jr(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new Jr(this.tileID.overscaledZ),m))return;const f=this.getId(m,d);for(let e=0;e<p.length;e++){const i=p[e];if(o&&o.indexOf(i)<0)continue;const n=l[i];if(!n)continue;let d={};f&&h&&(d=h.getState(n.sourceLayer||"_geojsonTileLayer",f));const g=s({},c[i]);g.paint=mh(g.paint,n.paint,m,d,a),g.layout=mh(g.layout,n.layout,m,d,a);const _=!u||u(m,n,d);if(!_)continue;const y=new ph(m,this.z,this.x,this.y,f);y.layer=g;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:r,feature:y,intersectionZ:_})}}lookupSymbolFeatures(t,e,i,r,n,o,a,s){const l={};this.loadVTLayers();const c=Wi(n);for(const n of t)this.loadMatchingFeature(l,i,r,n,c,o,a,s,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}}function mh(t,e,i,r,n){return h(t,((t,o)=>{const a=e instanceof sn?e.get(o):null;return a&&a.evaluate?a.evaluate(i,r,n):a}))}function fh(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of t)e=Math.min(e,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return{minX:e,minY:i,maxX:r,maxY:n}}function gh(t,e){return e-t}var _h;Ar("FeatureIndex",dh,{omit:["rawTileData","sourceLayerCoder"]}),t.PerformanceMarkers=void 0,(_h=t.PerformanceMarkers||(t.PerformanceMarkers={})).create="create",_h.load="load",_h.fullLoad="fullLoad";let yh=null,xh=[];const vh=1e3/30,bh={mark(t){performance.mark(t)},frame(t){const e=t;null!=yh&&xh.push(e-yh),yh=e},clearMetrics(){yh=null,xh=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const e in t.PerformanceMarkers)performance.clearMarks(t.PerformanceMarkers[e])},getPerformanceMetrics(){performance.measure("loadTime",t.PerformanceMarkers.create,t.PerformanceMarkers.load),performance.measure("fullLoadTime",t.PerformanceMarkers.create,t.PerformanceMarkers.fullLoad);const e=performance.getEntriesByName("loadTime")[0].duration,i=performance.getEntriesByName("fullLoadTime")[0].duration,r=xh.length,n=1/(xh.reduce(((t,e)=>t+e),0)/r/1e3),o=xh.filter((t=>t>vh)).reduce(((t,e)=>t+(e-vh)/vh),0);return{loadTime:e,fullLoadTime:i,fps:n,percentDroppedFrames:o/(r+o)*100}}};t.AJAXError=$,t.ARRAY_TYPE=da,t.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},c(["receive","process"],this),this.invoker=new Wc(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=_()?t:window}send(t,e,i,r,n=!1){const o=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(this.callbacks[o]=i);const a=w(this.globalScope)?void 0:[];return this.target.postMessage({id:o,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Cr(e,a)},a),{cancel:()=>{i&&delete this.callbacks[o],this.target.postMessage({id:o,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){delete this.tasks[i];const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t()}else _()||e.mustQueue?(this.tasks[i]=e,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,e)}process(){if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Mr(e.error)):i(null,Mr(e.data)))}else{let i=!1;const r=w(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{i=!0,delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Cr(e):null,data:Cr(n,r)},r)}:t=>{i=!0};let o=null;const a=Mr(e.data);if(this.parent[e.type])o=this.parent[e.type](e.sourceMapId,a,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");o=this.parent.getWorkerSource(e.sourceMapId,t[0],a.source)[t[1]](a,n)}else n(new Error(`Could not find function ${e.type}`));!i&&o&&o.cancel&&(this.cancelCallbacks[t]=o.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.AlphaImage=Ma,t.CanonicalTileID=ah,t.CollisionBoxArray=jn,t.CollisionCircleLayoutArray=class extends zn{},t.Color=Dt,t.DEMData=hh,t.DataConstantProperty=ln,t.DictionaryCoder=uh,t.EXTENT=Go,t.ErrorEvent=et,t.EvaluationParameters=Jr,t.Event=tt,t.Evented=it,t.FeatureIndex=dh,t.FillBucket=gs,t.FillExtrusionBucket=Fs,t.GeoJSONFeature=ph,t.ImageAtlas=Fl,t.ImagePosition=Rl,t.LineBucket=Ks,t.LineStripIndexArray=class extends Nn{},t.LngLat=Kc,t.LngLatBounds=Yc,t.MercatorCoordinate=nh,t.ONE_EM=ll,t.OverscaledTileID=lh,t.PerformanceUtils=bh,t.PosArray=Qn,t.Properties=dn,t.QuadTriangleArray=class extends Dn{},t.RGBAImage=ka,t.RasterBoundsArray=class extends wn{},t.RequestPerformance=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.ResourceType=N,t.SegmentVector=go,t.SymbolBucket=Oc,t.Transitionable=en,t.TriangleIndexArray=uo,t.Uniform1f=Mo,t.Uniform1i=class extends Co{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends Co{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends Co{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=ko,t.UniformColor=Po,t.UniformMatrix4f=class extends Co{constructor(t,e){super(t,e),this.current=zo}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=sh,t.ValidationError=nt,t.ZoomHistory=kr,t.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t},t.addDynamicAttributes=Dc,t.asyncAll=function(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let o=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(o=t),n[a]=e,0==--r&&i(o,n)}))}))},t.bezier=r,t.bindAll=c,t.cacheEntryPossiblyAdded=function(t){D++,D>z&&(t.getActor().send("enforceCacheSizeLimit",P),D=0)},t.calculateBreakLines=function(t,e,i,r,n,o,a,s){const l=r*ll,c=i*ll,h=Ft.fromString(t),u=Vl.fromFeature(h,e);return Nl(u,Kl(u,c,l,a,s,o,n))},t.clamp=o,t.clearTileCache=function(t){const e=caches.delete(C);t&&e.catch(t).then((()=>t()))},t.clipLine=uc,t.clone=function(t){var e=new da(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=p,t.clone$2=function(t){var e=new da(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.collisionCircleLayout=ol,t.config=I,t.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.create=function(){var t=new da(16);return da!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=ma,t.createExpression=Di,t.createFilter=Wi,t.createLayout=xn,t.createStyleLayer=function(t){return"custom"===t.type?new Zc(t):new Xc[t.type](t)},t.cross=function(t,e,i){var r=e[0],n=e[1],o=e[2],a=i[0],s=i[1],l=i[2];return t[0]=n*l-o*s,t[1]=o*a-r*l,t[2]=r*s-n*a,t},t.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.dot$1=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.ease=n,t.emitValidationErrors=Tr,t.enforceCacheSizeLimit=function(t){L(),M&&M.then((e=>{e.keys().then((i=>{for(let r=0;r<i.length-t;r++)e.delete(i[r])}))}))},t.equals=function(t,e){var i=t[0],r=t[1],n=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],h=t[8],u=t[9],p=t[10],d=t[11],m=t[12],f=t[13],g=t[14],_=t[15],y=e[0],x=e[1],v=e[2],b=e[3],w=e[4],T=e[5],E=e[6],S=e[7],A=e[8],I=e[9],C=e[10],M=e[11],k=e[12],P=e[13],z=e[14],L=e[15];return Math.abs(i-y)<=pa*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=pa*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=pa*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=pa*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(a-w)<=pa*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-T)<=pa*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-E)<=pa*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-S)<=pa*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(h-A)<=pa*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(u-I)<=pa*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(p-C)<=pa*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(d-M)<=pa*Math.max(1,Math.abs(d),Math.abs(M))&&Math.abs(m-k)<=pa*Math.max(1,Math.abs(m),Math.abs(k))&&Math.abs(f-P)<=pa*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(g-z)<=pa*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-L)<=pa*Math.max(1,Math.abs(_),Math.abs(L))},t.evaluateSizeForFeature=function(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/ec:"composite"===t.kind?Se(r/ec,n/ec,i):e},t.evaluateSizeForZoom=function(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:a,maxZoom:s}=t,l=n?o(je.interpolationFactor(n,e,a,s),0,1):0;"camera"===t.kind?r=Se(t.minSize,t.maxSize,l):i=l}return{uSizeT:i,uSize:r}},t.evaluateVariableOffset=Ec,t.evented=Wr,t.exported=E,t.exported$1=B,t.extend=s,t.filterObject=u,t.fromRotation=function(t,e){var i=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.getAnchorAlignment=Yl,t.getAnchorJustification=Sc,t.getArrayBuffer=Z,t.getImage=Y,t.getJSON=function(t,e){return q(s(t,{type:"json"}),e)},t.getOverlapMode=Gc,t.getRTLTextPluginStatus=Hr,t.getReferrer=G,t.getVideo=function(t,e){const i=window.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=window.document.createElement("source");X(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}return{cancel:()=>{}}},t.identity=fa,t.invert=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],m=e[12],f=e[13],g=e[14],_=e[15],y=i*s-r*a,x=i*l-n*a,v=i*c-o*a,b=r*l-n*s,w=r*c-o*s,T=n*c-o*l,E=h*f-u*m,S=h*g-p*m,A=h*_-d*m,I=u*g-p*f,C=u*_-d*f,M=p*_-d*g,k=y*M-x*C+v*I+b*A-w*S+T*E;return k?(t[0]=(s*M-l*C+c*I)*(k=1/k),t[1]=(n*C-r*M-o*I)*k,t[2]=(f*T-g*w+_*b)*k,t[3]=(p*w-u*T-d*b)*k,t[4]=(l*A-a*M-c*S)*k,t[5]=(i*M-n*A+o*S)*k,t[6]=(g*v-m*T-_*x)*k,t[7]=(h*T-p*v+d*x)*k,t[8]=(a*C-s*A+c*E)*k,t[9]=(r*A-i*C-o*E)*k,t[10]=(m*w-f*v+_*y)*k,t[11]=(u*v-h*w-d*y)*k,t[12]=(s*S-a*I-l*E)*k,t[13]=(i*I-r*S+n*E)*k,t[14]=(f*x-m*b-g*y)*k,t[15]=(h*b-u*x+p*y)*k,t):null},t.isImageBitmap=T,t.isSafari=w,t.isWorker=_,t.keysDifference=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i},t.lazyLoadRTLTextPlugin=function(){Yr.isLoading()||Yr.isLoaded()||"deferred"!==Hr()||Kr()},t.makeRequest=q,t.mapObject=h,t.mercatorXfromLng=th,t.mercatorYfromLat=eh,t.mercatorZfromAltitude=ih,t.mul=ya,t.mul$1=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.multiply=ga,t.nextPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.normalize=function(t,e){var i=e[0],r=e[1],n=e[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},t.number=Se,t.ortho=function(t,e,i,r,n,o,a){var s=1/(e-i),l=1/(r-n),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*s,t[13]=(n+r)*l,t[14]=(a+o)*c,t[15]=1,t},t.parseCacheControl=y,t.parseGlyphPbf=function(t){return new cl(t).readFields(zl,[])},t.pbf=cl,t.performSymbolLayout=function(e){e.bucket.createArrays(),e.bucket.tilePixelRatio=Go/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const i=e.bucket.layers[0].layout,r=e.bucket.layers[0].metadata||{},n=e.bucket.layers[0]._unevaluatedLayout._values,o={layoutIconSize:n["icon-size"].possiblyEvaluate(new Jr(e.bucket.zoom+1),e.canonical),layoutTextSize:n["text-size"].possiblyEvaluate(new Jr(e.bucket.zoom+1),e.canonical),textMaxSize:n["text-size"].possiblyEvaluate(new Jr(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;o.compositeTextSizes=[n["text-size"].possiblyEvaluate(new Jr(t),e.canonical),n["text-size"].possiblyEvaluate(new Jr(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;o.compositeIconSizes=[n["icon-size"].possiblyEvaluate(new Jr(t),e.canonical),n["icon-size"].possiblyEvaluate(new Jr(i),e.canonical)]}const a=i.get("text-line-height")*ll,s="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement"),l=i.get("text-keep-upright"),c=i.get("text-size");for(const n of e.bucket.features){const h=i.get("text-font").evaluate(n,{},e.canonical).join(","),u=c.evaluate(n,{},e.canonical),p=o.layoutTextSize.evaluate(n,{},e.canonical),d=o.layoutIconSize.evaluate(n,{},e.canonical),f={horizontal:{},vertical:void 0},g=n.text;let _,y=[0,0];if(g){const o=g.toString(),c=r["text-letter-spacing-correction"]||0,d=(i.get("text-letter-spacing").evaluate(n,{},e.canonical)+c)*ll,m=Lr(o)?d:0,_=i.get("text-anchor").evaluate(n,{},e.canonical),x=i.get("text-variable-anchor");if(!x){const t=i.get("text-radial-offset").evaluate(n,{},e.canonical);y=t?Ec(_,[t*ll,Tc]):i.get("text-offset").evaluate(n,{},e.canonical).map((t=>t*ll))}let v=s?"center":i.get("text-justify").evaluate(n,{},e.canonical);const b=i.get("symbol-placement"),w="point"===b?i.get("text-max-width").evaluate(n,{},e.canonical)*ll:0,T=()=>{e.bucket.allowVerticalPlacement&&zr(o)&&(f.vertical=$l(g,e.glyphMap,e.glyphPositions,e.imagePositions,h,w,a,_,"left",m,y,t.WritingMode.vertical,!0,b,p,u))};if(!s&&x){const i="auto"===v?x.map((t=>Sc(t))):[v];let r=!1;for(let n=0;n<i.length;n++){const o=i[n];if(!f.horizontal[o])if(r)f.horizontal[o]=f.horizontal[0];else{const i=$l(g,e.glyphMap,e.glyphPositions,e.imagePositions,h,w,a,"center",o,m,y,t.WritingMode.horizontal,!1,b,p,u);i&&(f.horizontal[o]=i,r=1===i.positionedLines.length)}}T()}else{"auto"===v&&(v=Sc(_));const i=$l(g,e.glyphMap,e.glyphPositions,e.imagePositions,h,w,a,_,v,m,y,t.WritingMode.horizontal,!1,b,p,u);i&&(f.horizontal[v]=i),T(),zr(o)&&s&&l&&(f.vertical=$l(g,e.glyphMap,e.glyphPositions,e.imagePositions,h,w,a,_,v,m,y,t.WritingMode.vertical,!1,b,p,u))}}let x=!1;if(n.icon&&n.icon.name){const t=e.imageMap[n.icon.name];if(t){_=Ql(e.imagePositions[n.icon.name],i.get("icon-offset").evaluate(n,{},e.canonical),i.get("icon-anchor").evaluate(n,{},e.canonical)),x=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=x:e.bucket.sdfIcons!==x&&m("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer");const r=void 0!==n.properties?n.properties["icon-rotate"]:void 0,o=void 0!==r?r:i.get("icon-rotate").constantOr(1),a=void 0!==n.properties?n.properties["icon-size"]:void 0,s=void 0!==a?a:i.get("icon-size").constantOr(1);(t.pixelRatio!==e.bucket.pixelRatio||0!==o||1!==s)&&(e.bucket.iconsNeedLinear=!0)}}const v=Mc(f.horizontal)||f.vertical;e.bucket.iconsInText=!!v&&v.iconsInText,(v||_)&&Ac(e.bucket,n,f,_,e.imageMap,o,p,d,y,x,e.canonical)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},t.perspective=function(t,e,i,r,n){var o,a=1/Math.tan(e/2);return t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(o=1/(r-n)),t[14]=2*n*r*o):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i},t.plugin=Yr,t.pointGeometry=S,t.polygonIntersectsPolygon=Ko,t.potpack=Bl,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.register=Ar,t.registerForPluginStateChange=function(t){return t({pluginStatus:jr,pluginURL:qr}),Wr.on("pluginStateChange",t),t},t.renderColorRamp=Pa,t.rotateX=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+c*r,t[5]=a*n+h*r,t[6]=s*n+u*r,t[7]=l*n+p*r,t[8]=c*n-o*r,t[9]=h*n-a*r,t[10]=u*n-s*r,t[11]=p*n-l*r,t},t.rotateZ=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],a=e[1],s=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+c*r,t[1]=a*n+h*r,t[2]=s*n+u*r,t[3]=l*n+p*r,t[4]=c*n-o*r,t[5]=h*n-a*r,t[6]=u*n-s*r,t[7]=p*n-l*r,t},t.scale=function(t,e,i){var r=i[0],n=i[1],o=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.scale$1=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},t.setCacheLimits=function(t,e){P=t,z=e},t.setRTLTextPlugin=function(t,e,i=!1){if(jr===Vr||jr===Nr||jr===$r)throw new Error("setRTLTextPlugin cannot be called multiple times.");qr=E.resolveURL(t),jr=Vr,Gr=e,Xr(),i||Kr()},t.spec=rt,t.sphericalToCartesian=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}},t.sqrLen=function(t){var e=t[0],i=t[1];return e*e+i*i},t.sub=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},t.toEvaluationFeature=Xo,t.transformMat3=function(t,e,i){var r=e[0],n=e[1],o=e[2];return t[0]=r*i[0]+n*i[3]+o*i[6],t[1]=r*i[1]+n*i[4]+o*i[7],t[2]=r*i[2]+n*i[5]+o*i[8],t},t.transformMat4=ba,t.transformMat4$1=function(t,e,i){var r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t},t.translate=function(t,e,i){var r,n,o,a,s,l,c,h,u,p,d,m,f=i[0],g=i[1],_=i[2];return e===t?(t[12]=e[0]*f+e[4]*g+e[8]*_+e[12],t[13]=e[1]*f+e[5]*g+e[9]*_+e[13],t[14]=e[2]*f+e[6]*g+e[10]*_+e[14],t[15]=e[3]*f+e[7]*g+e[11]*_+e[15]):(n=e[1],o=e[2],a=e[3],s=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],t[0]=r=e[0],t[1]=n,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=m,t[12]=r*f+s*g+u*_+e[12],t[13]=n*f+l*g+p*_+e[13],t[14]=o*f+c*g+d*_+e[14],t[15]=a*f+h*g+m*_+e[15]),t},t.triggerPluginCompletionEvent=Zr,t.unicodeBlockLookup=Pr,t.uniqueId=function(){return l++},t.validateCustomStyleLayer=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateLight=vr,t.validateStyle=xr,t.vectorTile=ws,t.warnOnce=m,t.wrap=a})),r(["./shared"],(function(t){function e(t){const i=typeof t;if("number"===i||"boolean"===i||"string"===i||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const r of t)i+=`${e(r)},`;return`${i}]`}const r=Object.keys(t).sort();let n="{";for(let i=0;i<r.length;i++)n+=`${JSON.stringify(r[i])}:${e(t[r[i]])},`;return`${n}}`}function i(i){let r="";for(const n of t.refProperties)r+=`/${e(i[n])}`;return r}class r{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.createStyleLayer(i);e._featureFilter=t.createFilter(e.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=function(t,e){const r={};for(let n=0;n<t.length;n++){const o=e&&e[t[n].id]||i(t[n]);e&&(e[t[n].id]=o);let a=r[o];a||(a=r[o]=[]),a.push(t[n])}const n=[];for(const t in r)n.push(r[t]);return n}(Object.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let a=n[o];a||(a=n[o]=[]),a.push(e)}}}class n{constructor(e){const i={},r=[];for(const t in e){const n=e[t],o=i[t]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),o[t]={rect:i,metrics:e.metrics}}}const{w:n,h:o}=t.potpack(r),a=new t.AlphaImage({width:n||1,height:o||1});for(const r in e){const n=e[r];for(const e in n){const o=n[+e];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const s=i[r][e].rect;t.AlphaImage.copy(o.bitmap,a,{x:0,y:0},{x:s.x+1,y:s.y+1},o.bitmap)}}this.image=a,this.positions=i}}t.register("GlyphAtlas",n);class o{constructor(e){this.tileID=new t.OverscaledTileID(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}parse(e,i,r,o,s){this.status="parsing",this.data=e,this.collisionBoxArray=new t.CollisionBoxArray;const l=new t.DictionaryCoder(Object.keys(e.layers).sort()),c=new t.FeatureIndex(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:r},p=i.familiesBySource[this.source];for(const i in p){const n=e.layers[i];if(!n)continue;1===n.version&&t.warnOnce(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=l.encode(i),s=[];for(let t=0;t<n.length;t++){const e=n.feature(t),r=c.getId(e,i);s.push({feature:e,id:r,index:t,sourceLayerIndex:o})}for(const e of p[i]){const i=e[0];i.source!==this.source&&t.warnOnce(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.minzoom&&this.zoom<Math.floor(i.minzoom)||i.maxzoom&&this.zoom>=i.maxzoom||"none"!==i.visibility&&(a(e,this.zoom,r),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(s,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map((t=>t.id))))}}let d,m,f,g;const _=t.mapObject(u.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?o.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{d||(d=t,m=e,v.call(this))})):m={};const y=Object.keys(u.iconDependencies);y.length?o.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{d||(d=t,f=e,v.call(this))})):f={};const x=Object.keys(u.patternDependencies);function v(){if(d)return s(d);if(m&&f&&g){const e=new n(m),i=new t.ImageAtlas(f,g);for(const n in h){const o=h[n];o instanceof t.SymbolBucket?(a(o.layers,this.zoom,r),t.performSymbolLayout({bucket:o,glyphMap:m,glyphPositions:e.positions,imageMap:f,imagePositions:i.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):o.hasPattern&&(o instanceof t.LineBucket||o instanceof t.FillBucket||o instanceof t.FillExtrusionBucket)&&(a(o.layers,this.zoom,r),o.addFeatures(u,this.tileID.canonical,i.patternPositions))}this.status="done",s(null,{buckets:Object.values(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:i,glyphMap:this.returnDependencies?m:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}x.length?o.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{d||(d=t,g=e,v.call(this))})):g={},v.call(this)}}function a(e,i,r){const n=new t.EvaluationParameters(i);for(const t of e)t.recalculate(n,r)}function s(e,i){const r=t.getArrayBuffer(e.request,((e,r,n,o)=>{e?i(e):r&&i(null,{vectorTile:new t.vectorTile.VectorTile(new t.pbf(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),i()}}class l{constructor(t,e,i,r){this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=r||s,this.loading={},this.loaded={}}loadTile(e,i){const r=e.uid;this.loading||(this.loading={});const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request),a=this.loading[r]=new o(e);a.abort=this.loadVectorData(e,((e,o)=>{if(delete this.loading[r],e||!o)return a.status="done",this.loaded[r]=a,i(e);const s=o.rawData,l={};o.expires&&(l.expires=o.expires),o.cacheControl&&(l.cacheControl=o.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}a.vectorTile=o.vectorTile,a.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,r)=>{if(e||!r)return i(e);i(null,t.extend({rawTileData:s.slice(0)},r,l,c))})),this.loaded=this.loaded||{},this.loaded[r]=a}))}reloadTile(t,e){const i=this.loaded,r=t.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=t.showCollisionBoxes;const a=(t,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),e(t,i)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(t,e){const i=this.loading,r=t.uid;i&&i[r]&&i[r].abort&&(i[r].abort(),delete i[r]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}}class c{constructor(){this.loaded={}}loadTile(e,i){const{uid:r,encoding:n,rawImageData:o}=e,a=t.isImageBitmap(o)?this.getImageData(o):o,s=new t.DEMData(r,a,n);this.loaded=this.loaded||{},this.loaded[r]=s,i(null,s)}getImageData(e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=this.offscreenCanvasContext.getImageData(-1,-1,e.width+2,e.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:i.width,height:i.height},i.data)}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}var h=function t(e,i){var r,n=e&&e.type;if("FeatureCollection"===n)for(r=0;r<e.features.length;r++)t(e.features[r],i);else if("GeometryCollection"===n)for(r=0;r<e.geometries.length;r++)t(e.geometries[r],i);else if("Feature"===n)t(e.geometry,i);else if("Polygon"===n)u(e.coordinates,i);else if("MultiPolygon"===n)for(r=0;r<e.coordinates.length;r++)u(e.coordinates[r],i);return e};function u(t,e){if(0!==t.length){p(t[0],e);for(var i=1;i<t.length;i++)p(t[i],!e)}}function p(t,e){for(var i=0,r=0,n=0,o=t.length,a=o-1;n<o;a=n++){var s=(t[n][0]-t[a][0])*(t[a][1]+t[n][1]),l=i+s;r+=Math.abs(i)>=Math.abs(s)?i-l+s:s-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const d=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class m{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new m(this._features[t])}}var g={exports:{}},_=t.pointGeometry,y=t.vectorTile.VectorTileFeature,x=v;function v(t,e){this.options=e||{},this.features=t,this.length=t.length}function b(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}v.prototype.feature=function(t){return new b(this.features[t],this.options.extent)},b.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e<t.length;e++){for(var i=t[e],r=[],n=0;n<i.length;n++)r.push(new _(i[n][0],i[n][1]));this.geometry.push(r)}return this.geometry},b.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<t.length;o++)for(var a=t[o],s=0;s<a.length;s++){var l=a[s];e=Math.min(e,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[e,r,i,n]},b.prototype.toGeoJSON=y.prototype.toGeoJSON;var w=t.pbf,T=x;function E(t){var e=new w;return function(t,e){for(var i in t.layers)e.writeMessage(3,S,t.layers[i])}(t,e),e.finish()}function S(t,e){var i;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<t.length;i++)r.feature=t.feature(i),e.writeMessage(2,A,r);var n=r.keys;for(i=0;i<n.length;i++)e.writeStringField(3,n[i]);var o=r.values;for(i=0;i<o.length;i++)e.writeMessage(4,P,o[i])}function A(t,e){var i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,I,t),e.writeVarintField(3,i.type),e.writeMessage(4,k,i)}function I(t,e){var i=t.feature,r=t.keys,n=t.values,o=t.keycache,a=t.valuecache;for(var s in i.properties){var l=i.properties[s],c=o[s];if(null!==l){void 0===c&&(r.push(s),o[s]=c=r.length-1),e.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,p=a[u];void 0===p&&(n.push(l),a[u]=p=n.length-1),e.writeVarint(p)}}}function C(t,e){return(e<<3)+(7&t)}function M(t){return t<<1^t>>31}function k(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,a=i.length,s=0;s<a;s++){var l=i[s],c=1;1===r&&(c=l.length),e.writeVarint(C(1,c));for(var h=3===r?l.length-1:l.length,u=0;u<h;u++){1===u&&1!==r&&e.writeVarint(C(2,h-1));var p=l[u].x-n,d=l[u].y-o;e.writeVarint(M(p)),e.writeVarint(M(d)),n+=p,o+=d}3===r&&e.writeVarint(C(7,1))}}function P(t,e){var i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}function z(t,e,i,r,n,o){if(n-r<=i)return;const a=r+n>>1;L(t,e,a,r,n,o%2),z(t,e,i,r,a-1,o+1),z(t,e,i,a+1,n,o+1)}function L(t,e,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);L(t,e,i,Math.max(r,Math.floor(i-s*c/a+h)),Math.min(n,Math.floor(i+(a-s)*c/a+h)),o)}const a=e[2*i+o];let s=r,l=n;for(D(t,e,r,i),e[2*n+o]>a&&D(t,e,r,n);s<l;){for(D(t,e,s,l),s++,l--;e[2*s+o]<a;)s++;for(;e[2*l+o]>a;)l--}e[2*r+o]===a?D(t,e,r,l):(l++,D(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function D(t,e,i,r){B(t,i,r),B(e,2*i,2*r),B(e,2*i+1,2*r+1)}function B(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function R(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}g.exports=E,g.exports.fromVectorTileJs=E,g.exports.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new T(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return E({layers:i})},g.exports.GeoJSONWrapper=T;const F=t=>t[0],O=t=>t[1];class U{constructor(t,e=F,i=O,r=64,n=Float64Array){this.nodeSize=r,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(t.length),s=this.coords=new n(2*t.length);for(let r=0;r<t.length;r++)a[r]=r,s[2*r]=e(t[r]),s[2*r+1]=i(t[r]);z(a,s,r,0,a.length-1,0)}range(t,e,i,r){return function(t,e,i,r,n,o,a){const s=[0,t.length-1,0],l=[];let c,h;for(;s.length;){const u=s.pop(),p=s.pop(),d=s.pop();if(p-d<=a){for(let a=d;a<=p;a++)c=e[2*a],h=e[2*a+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(t[a]);continue}const m=Math.floor((d+p)/2);c=e[2*m],h=e[2*m+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(t[m]);const f=(u+1)%2;(0===u?i<=c:r<=h)&&(s.push(d),s.push(m-1),s.push(f)),(0===u?n>=c:o>=h)&&(s.push(m+1),s.push(p),s.push(f))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,n,o){const a=[0,t.length-1,0],s=[],l=n*n;for(;a.length;){const c=a.pop(),h=a.pop(),u=a.pop();if(h-u<=o){for(let n=u;n<=h;n++)R(e[2*n],e[2*n+1],i,r)<=l&&s.push(t[n]);continue}const p=Math.floor((u+h)/2),d=e[2*p],m=e[2*p+1];R(d,m,i,r)<=l&&s.push(t[p]);const f=(c+1)%2;(0===c?i-n<=d:r-n<=m)&&(a.push(u),a.push(p-1),a.push(f)),(0===c?i+n>=d:r+n>=m)&&(a.push(p+1),a.push(h),a.push(f))}return s}(this.ids,this.coords,t,e,i,this.nodeSize)}}const V={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},N=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class G{constructor(t){this.options=Y(Object.create(V),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:n}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;let a=[];for(let e=0;e<t.length;e++)t[e].geometry&&a.push(q(t[e],e));this.trees[r+1]=new U(a,J,Q,n,Float32Array),e&&console.timeEnd(o);for(let t=r;t>=i;t--){const i=+Date.now();a=this._cluster(a,t),this.trees[t]=new U(a,J,Q,n,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,a.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,o],e),a=this.getClusters([-180,r,n,o],e);return t.concat(a)}const a=this.trees[this._limitZoom(e)],s=a.range(W(i),H(o),W(n),H(r)),l=[];for(const t of s){const e=a.points[t];l.push(e.numPoints?Z(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[e];if(!o)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=n.within(o.x,o.y,a),l=[];for(const e of s){const i=n.points[e];i.parentId===t&&l.push(i.numPoints?Z(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,h={features:[]};return this._addTileFeatures(r.range((e-s)/n,l,(e+1+s)/n,c),r.points,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.points,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.points,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(t,o.cluster_id,i,r,n):n<r?n++:t.push(e),t.length===i)break}return n}_addTileFeatures(t,e,i,r,n,o){for(const a of t){const t=e[a],s=t.numPoints;let l,c,h;if(s)l=X(t),c=t.x,h=t.y;else{const e=this.points[t.index];l=e.properties,c=W(e.geometry.coordinates[0]),h=H(e.geometry.coordinates[1])}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let p;s?p=t.id:this.options.generateId?p=t.index:this.points[t.index].id&&(p=this.points[t.index].id),void 0!==p&&(u.id=p),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const i=[],{radius:r,extent:n,reduce:o,minPoints:a}=this.options,s=r/(n*Math.pow(2,e));for(let r=0;r<t.length;r++){const n=t[r];if(n.zoom<=e)continue;n.zoom=e;const l=this.trees[e+1],c=l.within(n.x,n.y,s),h=n.numPoints||1;let u=h;for(const t of c){const i=l.points[t];i.zoom>e&&(u+=i.numPoints||1)}if(u>h&&u>=a){let t=n.x*h,a=n.y*h,s=o&&h>1?this._map(n,!0):null;const p=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,a+=r.y*c,r.parentId=p,o&&(s||(s=this._map(n,!0)),o(s,this._map(r)))}n.parentId=p,i.push(j(t/u,a/u,p,u,s))}else if(i.push(n),u>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?Y({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?Y({},r):r}}function j(t,e,i,r,n){return{x:N(t),y:N(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function q(t,e){const[i,r]=t.geometry.coordinates;return{x:N(W(i)),y:N(H(r)),zoom:1/0,index:e,parentId:-1}}function Z(t){return{type:"Feature",id:t.id,properties:X(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),K(t.y)]}};var e}function X(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return Y(Y({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function W(t){return t/360+.5}function H(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function K(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Y(t,e){for(const i in e)t[i]=e[i];return t}function J(t){return t.x}function Q(t){return t.y}function tt(t,e,i,r){for(var n,o=r,a=i-e>>1,s=i-e,l=t[e],c=t[e+1],h=t[i],u=t[i+1],p=e+3;p<i;p+=3){var d=et(t[p],t[p+1],l,c,h,u);if(d>o)n=p,o=d;else if(d===o){var m=Math.abs(p-a);m<s&&(n=p,s=m)}}o>r&&(n-e>3&&tt(t,e,n,r),t[n+2]=o,i-n>3&&tt(t,n,i,r))}function et(t,e,i,r,n,o){var a=n-i,s=o-r;if(0!==a||0!==s){var l=((t-i)*a+(e-r)*s)/(a*a+s*s);l>1?(i=n,r=o):l>0&&(i+=a*l,r+=s*l)}return(a=t-i)*a+(s=e-r)*s}function it(t,e,i,r){var n={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)rt(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r<e.length;r++)rt(t,e[r]);else if("MultiPolygon"===i)for(r=0;r<e.length;r++)for(var n=0;n<e[r].length;n++)rt(t,e[r][n])}(n),n}function rt(t,e){for(var i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function nt(t,e,i,r){if(e.geometry){var n=e.geometry.coordinates,o=e.geometry.type,a=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),s=[],l=e.id;if(i.promoteId?l=e.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)ot(n,s);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)ot(n[c],s);else if("LineString"===o)at(n,s,a,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<n.length;c++)at(n[c],s=[],a,!1),t.push(it(l,"LineString",s,e.properties));return}st(n,s,a,!1)}else if("Polygon"===o)st(n,s,a,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<e.geometry.geometries.length;c++)nt(t,{id:l,geometry:e.geometry.geometries[c],properties:e.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var h=[];st(n[c],h,a,!0),s.push(h)}}t.push(it(l,o,s,e.properties))}}function ot(t,e){e.push(lt(t[0])),e.push(ct(t[1])),e.push(0)}function at(t,e,i,r){for(var n,o,a=0,s=0;s<t.length;s++){var l=lt(t[s][0]),c=ct(t[s][1]);e.push(l),e.push(c),e.push(0),s>0&&(a+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var h=e.length-3;e[2]=1,tt(e,0,h,i),e[h+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function st(t,e,i,r){for(var n=0;n<t.length;n++){var o=[];at(t[n],o,i,r),e.push(o)}}function lt(t){return t/360+.5}function ct(t){var e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function ht(t,e,i,r,n,o,a,s){if(r/=e,o>=(i/=e)&&a<r)return t;if(a<i||o>=r)return null;for(var l=[],c=0;c<t.length;c++){var h=t[c],u=h.geometry,p=h.type,d=0===n?h.minX:h.minY,m=0===n?h.maxX:h.maxY;if(d>=i&&m<r)l.push(h);else if(!(m<i||d>=r)){var f=[];if("Point"===p||"MultiPoint"===p)ut(u,f,i,r,n);else if("LineString"===p)pt(u,f,i,r,n,!1,s.lineMetrics);else if("MultiLineString"===p)mt(u,f,i,r,n,!1);else if("Polygon"===p)mt(u,f,i,r,n,!0);else if("MultiPolygon"===p)for(var g=0;g<u.length;g++){var _=[];mt(u[g],_,i,r,n,!0),_.length&&f.push(_)}if(f.length){if(s.lineMetrics&&"LineString"===p){for(g=0;g<f.length;g++)l.push(it(h.id,p,f[g],h.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===f.length?(p="LineString",f=f[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===f.length?"Point":"MultiPoint"),l.push(it(h.id,p,f,h.tags))}}}return l.length?l:null}function ut(t,e,i,r,n){for(var o=0;o<t.length;o+=3){var a=t[o+n];a>=i&&a<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function pt(t,e,i,r,n,o,a){for(var s,l,c=dt(t),h=0===n?gt:_t,u=t.start,p=0;p<t.length-3;p+=3){var d=t[p],m=t[p+1],f=t[p+2],g=t[p+3],_=t[p+4],y=0===n?d:m,x=0===n?g:_,v=!1;a&&(s=Math.sqrt(Math.pow(d-g,2)+Math.pow(m-_,2))),y<i?x>i&&(l=h(c,d,m,g,_,i),a&&(c.start=u+s*l)):y>r?x<r&&(l=h(c,d,m,g,_,r),a&&(c.start=u+s*l)):ft(c,d,m,f),x<i&&y>=i&&(l=h(c,d,m,g,_,i),v=!0),x>r&&y<=r&&(l=h(c,d,m,g,_,r),v=!0),!o&&v&&(a&&(c.end=u+s*l),e.push(c),c=dt(t)),a&&(u+=s)}var b=t.length-3;d=t[b],m=t[b+1],f=t[b+2],(y=0===n?d:m)>=i&&y<=r&&ft(c,d,m,f),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&ft(c,c[0],c[1],c[2]),c.length&&e.push(c)}function dt(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function mt(t,e,i,r,n,o){for(var a=0;a<t.length;a++)pt(t[a],e,i,r,n,o,!1)}function ft(t,e,i,r){t.push(e),t.push(i),t.push(r)}function gt(t,e,i,r,n,o){var a=(o-e)/(r-e);return t.push(o),t.push(i+(n-i)*a),t.push(1),a}function _t(t,e,i,r,n,o){var a=(o-i)/(n-i);return t.push(e+(r-e)*a),t.push(o),t.push(1),a}function yt(t,e){for(var i=[],r=0;r<t.length;r++){var n,o=t[r],a=o.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)n=xt(o.geometry,e);else if("MultiLineString"===a||"Polygon"===a){n=[];for(var s=0;s<o.geometry.length;s++)n.push(xt(o.geometry[s],e))}else if("MultiPolygon"===a)for(n=[],s=0;s<o.geometry.length;s++){for(var l=[],c=0;c<o.geometry[s].length;c++)l.push(xt(o.geometry[s][c],e));n.push(l)}i.push(it(o.id,a,n,o.tags))}return i}function xt(t,e){var i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(var r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function vt(t,e){if(t.transformed)return t;var i,r,n,o=1<<t.z,a=t.x,s=t.y;for(i=0;i<t.features.length;i++){var l=t.features[i],c=l.geometry,h=l.type;if(l.geometry=[],1===h)for(r=0;r<c.length;r+=2)l.geometry.push(bt(c[r],c[r+1],e,o,a,s));else for(r=0;r<c.length;r++){var u=[];for(n=0;n<c[r].length;n+=2)u.push(bt(c[r][n],c[r][n+1],e,o,a,s));l.geometry.push(u)}}return t.transformed=!0,t}function bt(t,e,i,r,n,o){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-o))]}function wt(t,e,i,r,n){for(var o=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),a={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},s=0;s<t.length;s++){a.numFeatures++,Tt(a,t[s],o,n);var l=t[s].minX,c=t[s].minY,h=t[s].maxX,u=t[s].maxY;l<a.minX&&(a.minX=l),c<a.minY&&(a.minY=c),h>a.maxX&&(a.maxX=h),u>a.maxY&&(a.maxY=u)}return a}function Tt(t,e,i,r){var n=e.geometry,o=e.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s<n.length;s+=3)a.push(n[s]),a.push(n[s+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)Et(a,n,t,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(s=0;s<n.length;s++)Et(a,n[s],t,i,"Polygon"===o,0===s);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(s=0;s<c.length;s++)Et(a,c[s],t,i,!0,0===s)}if(a.length){var h=e.tags||null;if("LineString"===o&&r.lineMetrics){for(var u in h={},e.tags)h[u]=e.tags[u];h.mapbox_clip_start=n.start/n.size,h.mapbox_clip_end=n.end/n.size}var p={geometry:a,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:h};null!==e.id&&(p.id=e.id),t.features.push(p)}}function Et(t,e,i,r,n,o){var a=r*r;if(r>0&&e.size<(n?a:r))i.numPoints+=e.length/3;else{for(var s=[],l=0;l<e.length;l+=3)(0===r||e[l+2]>a)&&(i.numSimplified++,s.push(e[l]),s.push(e[l+1])),i.numPoints++;n&&function(t,e){for(var i=0,r=0,n=t.length,o=n-2;r<n;o=r,r+=2)i+=(t[r]-t[o])*(t[r+1]+t[o+1]);if(i>0===e)for(r=0,n=t.length;r<n/2;r+=2){var a=t[r],s=t[r+1];t[r]=t[n-2-r],t[r+1]=t[n-1-r],t[n-2-r]=a,t[n-1-r]=s}}(s,o),t.push(s)}}function St(t,e){var i=(e=this.options=function(t,e){for(var i in e)t[i]=e[i];return t}(Object.create(this.options),e)).debug;if(i&&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 r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)nt(i,t.features[r],e,r);else nt(i,"Feature"===t.type?t:{geometry:t},e);return i}(t,e);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(t,e){var i=e.buffer/e.extent,r=t,n=ht(t,1,-1-i,i,0,-1,2,e),o=ht(t,1,1-i,2+i,0,-1,2,e);return(n||o)&&(r=ht(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=yt(n,1).concat(r)),o&&(r=r.concat(yt(o,-1)))),r}(r,e),r.length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function At(t,e,i){return 32*((1<<t)*i+e)+t}function It(t,e){const i=t.tileID.canonical;if(!this._geoJSONIndex)return e(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return e(null,null);const n=new f(r.features);let o=g.exports(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),e(null,{vectorTile:n,rawData:o.buffer})}St.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},St.prototype.splitTile=function(t,e,i,r,n,o,a){for(var s=[t,e,i,r],l=this.options,c=l.debug;s.length;){r=s.pop(),i=s.pop(),e=s.pop(),t=s.pop();var h=1<<e,u=At(e,i,r),p=this.tiles[u];if(!p&&(c>1&&console.time("creation"),p=this.tiles[u]=wt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,n){if(e===l.maxZoom||e===n)continue;var m=1<<n-e;if(i!==Math.floor(o/m)||r!==Math.floor(a/m))continue}else if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==t.length){c>1&&console.time("clipping");var f,g,_,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;f=g=_=y=null,x=ht(t,h,i-b,i+T,0,p.minX,p.maxX,l),v=ht(t,h,i+w,i+E,0,p.minX,p.maxX,l),t=null,x&&(f=ht(x,h,r-b,r+T,1,p.minY,p.maxY,l),g=ht(x,h,r+w,r+E,1,p.minY,p.maxY,l),x=null),v&&(_=ht(v,h,r-b,r+T,1,p.minY,p.maxY,l),y=ht(v,h,r+w,r+E,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),s.push(f||[],e+1,2*i,2*r),s.push(g||[],e+1,2*i,2*r+1),s.push(_||[],e+1,2*i+1,2*r),s.push(y||[],e+1,2*i+1,2*r+1)}}},St.prototype.getTile=function(t,e,i){var r=this.options,n=r.extent,o=r.debug;if(t<0||t>24)return null;var a=1<<t,s=At(t,e=(e%a+a)%a,i);if(this.tiles[s])return vt(this.tiles[s],n);o>1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,h=e,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[At(c,h,u)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,h,u),o>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[s]?vt(this.tiles[s],n):null):null};class Ct extends l{constructor(t,e,i,r){super(t,e,i,It),r&&(this.loadGeoJSON=r)}loadData(e,i){var r;null===(r=this._pendingRequest)||void 0===r||r.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request);this._pendingCallback=i,this._pendingRequest=this.loadGeoJSON(e,((r,o)=>{if(delete this._pendingCallback,delete this._pendingRequest,r||!o)return i(r);if("object"!=typeof o)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{h(o,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=o.features.filter((t=>i.value.evaluate({zoom:0},t)));o={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new G(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(i);for(const e of s){const[o,a]=i[e],s=t.createExpression(a),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);r[e]=s.value,n[e]=l.value}return e.map=t=>{a.properties=t;const e={};for(const t of s)e[t]=r[t].evaluate(o,a);return e},e.reduce=(t,e)=>{a.properties=e;for(const e of s)o.accumulated=t[e],t[e]=n[e].evaluate(o,a)},e}(e)).load(o.features):function(t,e){return new St(t,e)}(o,e.geojsonVtOptions)}catch(r){return i(r)}this.loaded={};const a={};if(n){const t=n.finish();t&&(a.resourceTiming={},a.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}i(null,a)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)return t.getJSON(e.request,i);if("string"==typeof e.data)try{i(null,JSON.parse(e.data))}catch(t){i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}else i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}}removeSource(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class Mt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:l,geojson:Ct},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}setReferrer(t,e){this.referrer=e}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const r=this.workerSources[t][i];for(const t in r)r[t].availableImages=e}i()}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(t,e,i){this.getWorkerSource(t,e.type,e.source).loadTile(e,i)}loadDEMTile(t,e,i){this.getDEMWorkerSource(t,e.source).loadTile(e,i)}reloadTile(t,e,i){this.getWorkerSource(t,e.type,e.source).reloadTile(e,i)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeDEMTile(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={send:(e,i,r)=>{this.actor.send(e,i,r,t)}};this.workerSources[t][e][i]=new this.workerSourceTypes[e](r,this.getLayerIndex(t),this.getAvailableImages(t))}return this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new c),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}}return t.isWorker()&&(self.worker=new Mt(self)),Mt})),r(["./shared"],(function(t){var e=i;function i(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===r[e=t&&t.failIfMajorPerformanceCaveat]&&(r[e]=function(t){var e,r=function(t){var e=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,e.getContext("webgl",r)||e.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{e=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!e||r.isContextLost())&&(r.shaderSource(e,"void main() {}"),r.compileShader(e),!0===r.getShaderParameter(e,r.COMPILE_STATUS))}(e)),r[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var r={};function n(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!n(t[i],e[i]))return!1;return!0}return t===e}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};class o{static testProp(t){if(!o.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in o.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){o.docStyle&&o.selectProp&&(o.userSelect=o.docStyle[o.selectProp],o.docStyle[o.selectProp]="none")}static enableDrag(){o.docStyle&&o.selectProp&&(o.docStyle[o.selectProp]=o.userSelect)}static setTransform(t,e){t.style[o.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",o.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",o.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",o.suppressClickInternal,!0)}),0)}static mousePos(e,i){const r=e.getBoundingClientRect();return new t.pointGeometry((i.clientX-r.left)/t.exported.dynamicScale-e.clientLeft,(i.clientY-r.top)/t.exported.dynamicScale-e.clientTop)}static touchPos(e,i){const r=e.getBoundingClientRect(),n=[];for(let o=0;o<i.length;o++)n.push(new t.pointGeometry((i[o].clientX-r.left)/t.exported.dynamicScale-e.clientLeft,(i[o].clientY-r.top)/t.exported.dynamicScale-e.clientTop));return n}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}o.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,o.selectProp=o.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),o.transformProp=o.testProp(["transform","WebkitTransform"]);class a{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeSpriteURL(t,e,i){const r=function(t){const e=t.match(s);if(!e)throw new Error(`Unable to parse URL "${t}"`);return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}(t);return r.path+=`${e}${i}`,function(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}(r)}setTransformRequest(t){this._transformRequestFn=t}}const s=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;class l{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(e,i,r){const{width:n,height:o}=e,a=!(this.size&&this.size[0]===n&&this.size[1]===o||r),{context:s}=this,{gl:l}=s;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),a)this.size=[n,o],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.isImageBitmap(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,n,o,0,this.format,l.UNSIGNED_BYTE,e.data);else{const{x:i,y:a}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.isImageBitmap(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,a,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,a,n,o,l.RGBA,l.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),t!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}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 c(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class h extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){const i=this.images[t];if(i.data.width!==e.data.width||i.data.height!==e.data.height)throw new Error(`size mismatch between old image (${i.data.width}x${i.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=i.version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(e,i){const r={};for(const i of e){this.images[i]||this.fire(new t.Event("styleimagemissing",{id:i}));const e=this.images[i];e?r[i]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.warnOnce(`Image "${i}" 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.`)}i(null,r)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new t.ImagePosition(i,r);this.patterns[e]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[e].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new l(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.potpack(e),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,o=i.y+1,a=this.images[e].data,s=a.width,l=a.height;t.RGBAImage.copy(a,n,{x:0,y:0},{x:r,y:o},{width:s,height:l}),t.RGBAImage.copy(a,n,{x:0,y:l-1},{x:r,y:o-1},{width:s,height:1}),t.RGBAImage.copy(a,n,{x:0,y:0},{x:r,y:o+l},{width:s,height:1}),t.RGBAImage.copy(a,n,{x:s-1,y:0},{x:r-1,y:o},{width:1,height:l}),t.RGBAImage.copy(a,n,{x:0,y:0},{x:r+s,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.images[i];e||t.warnOnce(`Image with ID: "${i}" was not found`),c(e)&&this.updateImage(i,e)}}}const u=1e20;function p(t,e,i,r,n,o,a,s,l){for(let c=e;c<e+r;c++)d(t,i*o+c,o,n,a,s,l);for(let c=i;c<i+n;c++)d(t,c*o+e,1,r,a,s,l)}function d(t,e,i,r,n,o,a){o[0]=0,a[0]=-u,a[1]=u,n[0]=t[e];for(let s=1,l=0,c=0;s<r;s++){n[s]=t[e+s*i];const r=s*s;do{const t=o[l];c=(n[s]-n[t]+r-t*t)/(s-t)/2}while(c<=a[l]&&--l>-1);l++,o[l]=s,a[l]=c,a[l+1]=u}for(let s=0,l=0;s<r;s++){for(;a[l+1]<s;)l++;const r=o[l],c=s-r;t[e+s*i]=n[r]+c*c}}class m{constructor(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}}setURL(t){this.url=t}getGlyphs(e,i){const r=[];for(const t in e)for(const i of e[t])r.push({stack:t,id:i});t.asyncAll(r,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const o=Math.floor(e/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:t,id:e,glyph:n});let a=r.requests[o];a||(a=r.requests[o]=[],m.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[o]=!0}for(const i of a)i(t,e);delete r.requests[o]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:r,glyph:n}of e)(t[i]||(t[i]={}))[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};i(null,t)}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(t.unicodeBlockLookup["CJK Unified Ideographs"](e)||t.unicodeBlockLookup["Hangul Syllables"](e)||t.unicodeBlockLookup.Hiragana(e)||t.unicodeBlockLookup.Katakana(e))}_tinySDF(e,i,r){const n=this.localIdeographFontFamily;if(!n)return;if(!this._doesCharSupportLocalGlyph(r))return;let o=e.tinySDF;if(!o){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),o=e.tinySDF=new m.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:n,fontWeight:t})}const a=o.draw(String.fromCharCode(r));return{id:r,bitmap:new t.AlphaImage({width:a.width||30,height:a.height||30},a.data),metrics:{width:a.glyphWidth||24,height:a.glyphHeight||24,left:a.glyphLeft||0,top:a.glyphTop-27||-8,advance:a.glyphAdvance||24}}}}m.loadGlyphRange=function(e,i,r,n,o){const a=256*i,s=a+255,l=n.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),t.ResourceType.Glyphs);t.getArrayBuffer(l,((e,i)=>{if(e)o(e);else if(i){const e={};for(const r of t.parseGlyphPbf(i))e[r.id]=r;o(null,e)}}))},m.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const s=this.size=t+4*e,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),a=Math.ceil(i),s=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=s+2*this.buffer,h=l+2*this.buffer,d=Math.max(c*h,0),m=new Uint8ClampedArray(d),f={data:m,width:c,height:h,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===s||0===l)return f;const{ctx:g,buffer:_,gridInner:y,gridOuter:x}=this;g.clearRect(_,_,s,l),g.fillText(t,_,_+a);const v=g.getImageData(_,_,s,l);x.fill(u,0,d),y.fill(0,0,d);for(let t=0;t<l;t++)for(let e=0;e<s;e++){const i=v.data[4*(t*s+e)+3]/255;if(0===i)continue;const r=(t+_)*c+e+_;if(1===i)x[r]=0,y[r]=u;else{const t=.5-i;x[r]=t>0?t*t:0,y[r]=t<0?t*t:0}}p(x,0,0,c,h,c,this.f,this.v,this.z),p(y,_,_,s,l,c,this.f,this.v,this.z);for(let t=0;t<d;t++){const e=Math.sqrt(x[t])-Math.sqrt(y[t]);m[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return f}};const f=new t.Properties({anchor:new t.DataConstantProperty(t.spec.light.anchor),position:new class{constructor(){this.specification=t.spec.light.position}possiblyEvaluate(e,i){return t.sphericalToCartesian(e.expression.evaluate(i))}interpolate(e,i,r){return{x:t.number(e.x,i.x,r),y:t.number(e.y,i.y,r),z:t.number(e.z,i.z,r)}}},color:new t.DataConstantProperty(t.spec.light.color),intensity:new t.DataConstantProperty(t.spec.light.intensity)}),g="-transition";class _ extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(f),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.validateLight,e,i))for(const t in e){const i=e[t];t.endsWith(g)?this._transitionable.setTransition(t.slice(0,-g.length),i):this._transitionable.setValue(t,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}class y{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,a=!0;r.push({left:n,right:o,isDash:a,zeroLength:0===t[0]});let s=t[0];for(let e=1;e<t.length;e++){a=!a;const l=t[e];n=s*i,s+=l,o=s*i,r.push({left:n,right:o,isDash:a,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let o=0,a=t[o];for(let s=0;s<this.width;s++){s/a.right>1&&(a=t[++o]);const l=Math.abs(s-a.left),c=Math.abs(s-a.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(a.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[n+s]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let n=0,o=t[n];for(let e=0;e<this.width;e++){e/o.right>1&&(o=t[++n]);const i=Math.abs(e-o.left),a=Math.abs(e-o.right),s=Math.min(i,a);this.data[r+e]=Math.max(0,Math.min(255,(o.isDash?s:-s)+128))}}addDash(e,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return t.warnOnce("LineAtlas out of space"),null;let o=0;for(let t=0;t<e.length;t++)o+=e[t];if(0!==o){const t=this.width/o,n=this.getDashRanges(e,this.width,t);i?this.addRoundDash(n,t,r):this.addRegularDash(n)}const a={y:(this.nextRow+r+.5)/this.height,height:2*r/this.height,width:o};return this.nextRow+=n,this.dirty=!0,a}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}class x{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t.uniqueId();const r=this.workerPool.acquire(this.id);for(let t=0;t<r.length;t++){const e=new x.Actor(r[t],i,this.id);e.name=`Worker ${t}`,this.actors.push(e)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,i,r){t.asyncAll(this.actors,((t,r)=>{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function v(e,i,r){const n=function(i,n){if(i)return r(i);if(n){const i=t.pick(t.extend(n,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(i.vectorLayers=n.vector_layers,i.vectorLayerIds=i.vectorLayers.map((t=>t.id))),r(null,i)}};return e.url?t.getJSON(i.transformRequest(e.url,t.ResourceType.Source),n):t.exported.frame((()=>n(null,e)))}x.Actor=t.Actor;class b{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[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(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),n=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),a=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x<o&&e.y>=n&&e.y<a}}class w extends t.Evented{constructor(e,i,r,n){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(i,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n)}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=v(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new b(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function o(r,n){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}n.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state?"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",n,o.bind(this)):(e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",n,o.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 T extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},i),t.extend(this,t.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=v(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new b(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),((r,n,o)=>{if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&e.setExpiryData(o);const r=this.map.painter.context,a=r.gl;e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0}):(e.texture=new l(r,n,a.RGBA,{useMipmap:!0}),e.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST),r.extTextureFilterAnisotropic&&a.texParameterf(a.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax)),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),i(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let E;class S extends T{constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function n(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,o){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData(o),delete o.cacheControl,delete o.expires;const i=t.isImageBitmap(o)&&(null==E&&(E="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),E)?o:t.exported.getImageData(o,1),r={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:i,encoding:this.encoding};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",r,n.bind(this)))}}.bind(this)),e.neighboringTiles=this._getNeighboringTiles(e.tileID)}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?e.wrap-1:e.wrap,a=(i.x+1+r)%r,s=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,i.z,a,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,i.z,a,i.y+1).key]={backfilled:!1}),l}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 A extends t.Evented{constructor(e,i,r,n){super(),this.id=e,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=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=t.extend({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.EXTENT,radius:(i.clusterRadius||50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}load(){this._updateWorkerData("metadata")}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData("content"),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(e){const i=t.extend({},this.workerOptions),r=this._data;"string"==typeof r?(i.request=this.map._requestManager.transformRequest(t.exported.resolveURL(r),t.ResourceType.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(r),this._pendingLoads++,this.fire(new t.Event("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,i,((i,r)=>{if(this._pendingLoads--,this._removed||r&&r.abandoned)return void this.fire(new t.Event("dataabort",{dataType:"source",sourceDataType:e}));let n=null;if(r&&r.resourceTiming&&r.resourceTiming[this.id]&&(n=r.resourceTiming[this.id].slice(0)),i)return void this.fire(new t.ErrorEvent(i));const o={dataType:"source",sourceDataType:e};this._collectResourceTiming&&n&&n.length>0&&t.extend(o,{resourceTiming:n}),this.fire(new t.Event("data",o))}))}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r={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(i,r,((r,n)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),e(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var I=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class C extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((r,n)=>{this._loaded=!0,r?this.fire(new t.ErrorEvent(r)):n&&(this.image=n,e&&(this.coordinates=e),i&&i(),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}setCoordinates(e){this.coordinates=e;const i=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),o=Math.max(o,t.y);const a=Math.max(n-i,o-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new t.CanonicalTileID(s,Math.floor((i+n)/2*l),Math.floor((r+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const r=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new t.RasterBoundsArray,this._boundsArray.emplaceBack(r[0].x,r[0].y,0,0),this._boundsArray.emplaceBack(r[1].x,r[1].y,t.EXTENT,0),this._boundsArray.emplaceBack(r[3].x,r[3].y,0,t.EXTENT),this._boundsArray.emplaceBack(r[2].x,r[2].y,t.EXTENT,t.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,I.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new l(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class M extends C{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,I.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new l(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class k extends C{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,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 t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,I.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new l(i,this.canvas,r.RGBA,{premultiply:!0});for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const P={vector:w,raster:T,"raster-dem":S,geojson:A,video:M,image:C,canvas:k};class z{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.clamp(e,0,1);let i=1,r=this._distances[i];const n=e*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,a=this._distances[o],s=r-a,l=s>0?(n-a)/s:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function L(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class D{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(t,e,i,r,n,o){this.circleCells[n].push(o)}_query(t,e,i,r,n,o,a){if(i<0||t>this.width||r<0||e>this.height)return[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)s.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];s.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,s,{hitTest:n,overlapMode:o,seenUids:{box:{},circle:{}}},a);return s}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,n,o){return this._query(t,e,i,r,!0,n,o).length>0}hitTestCircle(t,e,i,r,n){const o=t-i,a=t+i,s=e-i,l=e+i;if(a<0||o>this.width||l<0||s>this.height)return!1;const c=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(t,e,i,r,n,o,a,s){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,p=this.boxKeys[a];if(t<=n[u+2]&&e<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!s||s(p))&&(!c||!L(h,p.overlapMode))&&(o.push({key:p,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const p=this.circleCells[n];if(null!==p){const n=this.circles;for(const a of p)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,p=this.circleKeys[a];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!s||s(p))&&(!c||!L(h,p.overlapMode))){const t=n[u],e=n[u+1],i=n[u+2];if(o.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,o,a,s){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!s||s(r))&&!L(h,r.overlapMode))return o.push(!0),!0}}const p=this.circleCells[n];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!s||s(r))&&!L(h,r.overlapMode))return o.push(!0),!0}}}_forEachCell(t,e,i,r,n,o,a,s){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,o,a,s))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,e,i,r,n,o){const a=r-t,s=n-e,l=i+o;return l*l>a*a+s*s}_circleAndRectCollide(t,e,i,r,n,o,a){const s=(o-r)/2,l=Math.abs(t-(r+s));if(l>s+i)return!1;const c=(a-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=s||h<=c)return!0;const u=l-s,p=h-c;return u*u+p*p<=i*i}}function B(e,i,r,n,o){const a=t.create();return i?(t.scale(a,a,[1/o,1/o,1]),r||t.rotateZ(a,a,n.angle)):t.multiply(a,n.labelPlaneMatrix,e),a}function R(e,i,r,n,o){if(i){const i=t.clone(e);return t.scale(i,i,[o,o,1]),r||t.rotateZ(i,i,-n.angle),i}return n.glCoordMatrix}function F(e,i,r){let n;r?(n=[e.x,e.y,r(e.x,e.y),1],t.transformMat4(n,n,i)):(n=[e.x,e.y,0,1],W(n,n,i));const o=n[3];return{point:new t.pointGeometry(n[0]/o,n[1]/o),signedDistanceFromCamera:o}}function O(t,e){return.5+t/e*.5}function U(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function V(e,i,r,n,o,a,s,l,c,h){const u=n?e.textSizeData:e.iconSizeData,p=t.evaluateSizeForZoom(u,r.transform.zoom),d=[256/r.width*2+1,256/r.height*2+1],m=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();const f=e.lineVertexArray,g=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,_=r.transform.width/r.transform.height;let y=!1;for(let n=0;n<g.length;n++){const x=g.get(n);if(x.hidden||x.writingMode===t.WritingMode.vertical&&!y){X(x.numGlyphs,m);continue}let v;if(y=!1,h?(v=[x.anchorX,x.anchorY,h(x.anchorX,x.anchorY),1],t.transformMat4(v,v,i)):(v=[x.anchorX,x.anchorY,0,1],W(v,v,i)),!U(v,d)){X(x.numGlyphs,m);continue}const b=O(r.transform.cameraToCenterDistance,v[3]),w=t.evaluateSizeForFeature(u,p,x),T=s?w/b:w*b,E=new t.pointGeometry(x.anchorX,x.anchorY),S=F(E,o,h).point,A={},I=G(x,T,!1,l,i,o,a,e.glyphOffsetArray,f,m,S,E,A,_,c,h);y=I.useVertical,(I.notEnoughRoom||y||I.needsFlipping&&G(x,T,!0,l,i,o,a,e.glyphOffsetArray,f,m,S,E,A,_,c,h).notEnoughRoom)&&X(x.numGlyphs,m)}n?e.text.dynamicLayoutVertexBuffer.updateData(m):e.icon.dynamicLayoutVertexBuffer.updateData(m)}function N(t,e,i,r,n,o,a,s,l,c,h,u,p){const d=s.glyphStartIndex+s.numGlyphs,m=s.lineStartIndex,f=s.lineStartIndex+s.lineLength,g=e.getoffsetX(s.glyphStartIndex),_=e.getoffsetX(d-1),y=q(t*g,i,r,n,o,a,s.segment,m,f,l,c,h,u,p);if(!y)return null;const x=q(t*_,i,r,n,o,a,s.segment,m,f,l,c,h,u,p);return x?{first:y,last:x}:null}function $(e,i,r,n){return e===t.WritingMode.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(e===t.WritingMode.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function G(e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g){const _=i/24,y=e.lineOffsetX*_,x=e.lineOffsetY*_;let v;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,i=e.lineStartIndex,o=e.lineStartIndex+e.lineLength,h=N(_,l,y,x,r,u,p,e,c,a,d,f,g);if(!h)return{notEnoughRoom:!0};const b=F(h.first.point,s,g).point,w=F(h.last.point,s,g).point;if(n&&!r){const t=$(e.writingMode,b,w,m);if(t)return t}v=[h.first];for(let n=e.glyphStartIndex+1;n<t-1;n++)v.push(q(_*l.getoffsetX(n),y,x,r,u,p,e.segment,i,o,c,a,d,f,g));v.push(h.last)}else{if(n&&!r){const i=F(p,o,g).point,r=e.lineStartIndex+e.segment+1,n=new t.pointGeometry(c.getx(r),c.gety(r)),a=F(n,o,g),s=a.signedDistanceFromCamera>0?a.point:j(p,n,i,1,o,g),l=$(e.writingMode,i,s,m);if(l)return l}const i=q(_*l.getoffsetX(e.glyphStartIndex),y,x,r,u,p,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,a,d,f,g);if(!i)return{notEnoughRoom:!0};v=[i]}for(const e of v)t.addDynamicAttributes(h,e.point,e.angle);return{}}function j(t,e,i,r,n,o){const a=F(t.add(t.sub(e)._unit()),n,o).point,s=i.sub(a);return i.add(s._mult(r/s.mag()))}function q(e,i,r,n,o,a,s,l,c,h,u,p,d,m){const f=n?e-i:e+i;let g=f>0?1:-1,_=0;n&&(g*=-1,_=Math.PI),g<0&&(_+=Math.PI);let y=g>0?l+s:l+s+1,x=o,v=o,b=0,w=0;const T=Math.abs(f),E=[];for(;b+w<=T;){if(y+=g,y<l||y>=c)return null;const e=x.sub(v);if(e.mag()>0?E.push(x.add(e.unit().perp().mult(r*g))):E.push(x),v=x,x=p[y],void 0===x){const e=new t.pointGeometry(h.getx(y),h.gety(y)),i=F(e,u,m);if(i.signedDistanceFromCamera>0)x=p[y]=i.point;else{const i=y-g;x=j(0===b?a:new t.pointGeometry(h.getx(i),h.gety(i)),e,v,T-b+1,u,m)}}b+=w,w=v.dist(x)}const S=(T-b)/w,A=x.sub(v),I=A.mult(S)._add(v);I._add(A._unit()._perp()._mult(r*g));const C=_+Math.atan2(x.y-v.y,x.x-v.x);return E.push(I),{point:I,angle:d?C:0,path:E}}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 X(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(Z,3*t)}}function W(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const H=100;class K{constructor(t,e=new D(t.width+200,t.height+200,25),i=new D(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+H,this.screenBottomBoundary=t.height+H,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,n,o){const a=this.projectAndGetPerspectiveRatio(r,t.anchorPointX,t.anchorPointY,o),s=i*a.perspectiveRatio,l=t.x1*s+a.point.x,c=t.y1*s+a.point.y,h=t.x2*s+a.point.x,u=t.y2*s+a.point.y;return!this.isInsideGrid(l,c,h,u)||"always"!==e&&this.grid.hitTest(l,c,h,u,e,n)||a.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[l,c,h,u],offscreen:this.isOffscreen(l,c,h,u)}}placeCollisionCircles(e,i,r,n,o,a,s,l,c,h,u,p,d,m){const f=[],g=new t.pointGeometry(i.anchorX,i.anchorY),_=F(g,a,m),y=O(this.transform.cameraToCenterDistance,_.signedDistanceFromCamera),x=(h?o/y:o*y)/t.ONE_EM,v=F(g,s,m).point,b=N(x,n,i.lineOffsetX*x,i.lineOffsetY*x,!1,v,g,i,r,s,{},!1,m);let w=!1,T=!1,E=!0;if(b){const i=.5*p*y+d,r=new t.pointGeometry(-100,-100),n=new t.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new z,a=b.first,s=b.last;let h=[];for(let t=a.path.length-1;t>=1;t--)h.push(a.path[t]);for(let t=1;t<s.path.length;t++)h.push(s.path[t]);const g=2.5*i;if(l){const t=h.map((t=>F(t,l,m)));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(h.length>0){const e=h[0].clone(),i=h[0].clone();for(let t=1;t<h.length;t++)e.x=Math.min(e.x,h[t].x),e.y=Math.min(e.y,h[t].y),i.x=Math.max(i.x,h[t].x),i.y=Math.max(i.y,h[t].y);_=e.x>=r.x&&i.x<=n.x&&e.y>=r.y&&i.y<=n.y?[h]:i.x<r.x||e.x>n.x||i.y<r.y||e.y>n.y?[]:t.clipLine([h],r.x,r.y,n.x,n.y)}for(const t of _){o.reset(t,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/g)+1;for(let t=0;t<r;t++){const n=t/Math.max(r-1,1),a=o.lerp(n),s=a.x+H,l=a.y+H;f.push(s,l,i,0);const h=s-i,p=l-i,d=s+i,m=l+i;if(E=E&&this.isOffscreen(h,p,d,m),T=T||this.isInsideGrid(h,p,d,m),"always"!==e&&this.grid.hitTestCircle(s,l,i,e,u)&&(w=!0,!c))return{circles:[],offscreen:!1,collisionDetected:w}}}}return{circles:!c&&w||!T||y<this.perspectiveRatioCutoff?[]:f,offscreen:E,collisionDetected:w}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,a=-1/0;for(const s of e){const e=new t.pointGeometry(s.x+H,s.y+H);r=Math.min(r,e.x),n=Math.min(n,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y),i.push(e)}const s=this.grid.query(r,n,o,a).concat(this.ignoredGrid.query(r,n,o,a)),l={},c={};for(const e of s){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new t.pointGeometry(e.x1,e.y1),new t.pointGeometry(e.x2,e.y1),new t.pointGeometry(e.x2,e.y2),new t.pointGeometry(e.x1,e.y2)];t.polygonIntersectsPolygon(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,e,i,r,n,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n,o){const a=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e};for(let e=0;e<t.length;e+=4)a.insertCircle(s,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(e,i,r,n){let o;return n?(o=[i,r,n(i,r),1],t.transformMat4(o,o,e)):(o=[i,r,0,1],W(o,o,e)),{point:new t.pointGeometry((o[0]/o[3]+1)/2*this.transform.width+H,(-o[1]/o[3]+1)/2*this.transform.height+H),perspectiveRatio:.5+this.transform.cameraToCenterDistance/o[3]*.5}}isOffscreen(t,e,i,r){return i<H||t>=this.screenRightBoundary||r<H||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const e=t.identity([]);return t.translate(e,e,[-100,-100,0]),e}}function Y(e,i){const r=t.create();return t.translate(r,r,[1,1,0]),t.scale(r,r,[.5*e.width,.5*e.height,1]),t.multiply(r,r,e.calculatePosMatrix(i.toUnwrapped()))}function J(t,e,i,r,n,o){const a=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(n&&n.layers,e,t.id),s=o.maxPitchScaleFactor(),l=t.tilesIn(r,s,a);l.sort(Q);const c=[];for(const r of l)c.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,n,o,s,Y(t.transform,r.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in t){const r=t[i],n=o[i]=o[i]||{},a=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,a.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function Q(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function tt(e,i,r,n,o){const a=e[i[n].source],s=a.style.placement.glyphCircles,l=a.style.placement.placedBoxes,c=a.style.placement.anchorAngles,h=a.style.placement.variableAnchors,u=r.bucketInstanceId,p=o.featureIndex;if(u in s&&p in s[u]){const e=s[u][p],i=c[u][p];let r=0;o.feature.paths=[],e.forEach((e=>{let n=[];const a=e.length/4;for(let t=0;t<a;t++)n.push(e[4*t]-H),n.push(e[4*t+1]-H);const s=n.length/2;if(n[0]>n[n.length-2]){const t=[];for(let e=1;e<=s;e++)t.push(n[2*(s-e)]),t.push(n[2*(s-e)+1]);n=t}if(1===s){const e=i[r],a=new t.pointGeometry(n[0],n[1]);let s=new t.pointGeometry(n[0]-20,n[1]),l=new t.pointGeometry(n[0]+20,n[1]);s=s.rotateAround(e,a),l=l.rotateAround(e,a),o.feature.paths.push([s.x,s.y,l.x,l.y])}else{const t=et(n[2],n[3],n[0],n[1],20);void 0!==t&&(n[0]=t.x,n[1]=t.y);const e=n.length,i=et(n[e-4],n[e-3],n[e-2],n[e-1],20);void 0!==i&&(n[e-2]=i.x,n[e-1]=i.y),o.feature.paths.push(n)}r++}))}if(u in l&&p in l[u]){const t=l[u][p];o.feature.iconBoxes=[],o.feature.textBoxes=[],t.forEach((t=>{const{purpose:e,coords:i}=t;("icon"===e?o.feature.iconBoxes:o.feature.textBoxes).push(i.map((t=>t-H)))}))}if(u in c&&p in c[u]){const t=c[u][p];o.feature.angles=[],t.forEach((t=>{o.feature.angles.push(180*t/Math.PI)}))}u in h&&p in h[u]&&(o.feature["placement-anchor"]=h[u][p])}function et(t,e,i,r,n){if(t===i&&e===r)return;const o=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-r,2)),a=(n+o)/o;return{x:t+(i-t)*a,y:e+(r-e)*a}}class it{constructor(e,i){this.tileID=e,this.uid=t.uniqueId(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const i=e+this.timeAdded;i<t.exported.now()||this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.textures.forEach((e=>t.saveTileTexture(e))),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(e,i,r){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.SymbolBucket){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.SymbolBucket&&i.hasRTLText){this.hasRTLText=!0,t.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new t.CollisionBoxArray}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,a,s,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:s,params:a,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i?i.sourceLayer:"",a=n._geojsonTileLayer||n[o];if(!a)return;const s=t.createFilter(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<a.length;i++){const n=a.feature(i);if(s.needGeometry){const e=t.toEvaluationFeature(n,!0);if(!s.filter(new t.EvaluationParameters(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new t.EvaluationParameters(this.tileID.overscaledZ),n))continue;const p=r.getId(n,o),d=new t.GeoJSONFeature(n,l,c,h,p);d.tile=u,e.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const i=t.parseCacheControl(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const r=this.expirationTime-i;r?this.expirationTime=t+Math.max(r,3e4):e=!0}else e=!0;e?(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,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const i=this.latestFeatureIndex.loadVTLayers();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const n=this.buckets[r],o=n.layers[0].sourceLayer||"_geojsonTileLayer",a=i[o],s=t[o];if(!a||!s||0===Object.keys(s).length)continue;n.update(s,a,this.imageAtlas&&this.imageAtlas.patternPositions||{});const l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(n)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<t.exported.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=t.exported.now()+e}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class rt{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}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 e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class nt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,r){const n=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},t.extend(this.stateChanges[e][n],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])r[t]||(this.deletedStates[e][n][t]=null)}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(e,i){const r=String(i),n=t.extend({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete n[e]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.extend(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t]}r[e]=r[e]||{},t.extend(r[e],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i)}}class ot extends t.Evented{constructor(e,i,r){super(),this.id=e,this.dispatcher=r,this.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=function(e,i,r,n){const o=new P[i.type](e,i,r,n);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],o),o}(e,i,r,this),this._tiles={},this._cache=new rt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new nt}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)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,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(e){this._source.abortTile&&this._source.abortTile(e,(()=>{})),this._source.fire(new t.Event("dataabort",{tile:e,coord:e.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 e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(at).map((t=>t.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,n=i.tileID,o=new t.pointGeometry(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),a=new t.pointGeometry(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||a.y-o.y||a.x-o.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(at).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(e,i,r,n){if(n)return e.state="errored",void(404!==n.status?this._source.fire(new t.ErrorEvent(n,{tile:e})):this.update(this.transform,this.terrain));e.timeAdded=t.exported.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.Event("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(a=t)}let s=a;for(;s.overscaledZ>e;)if(s=s.scaledTo(s.overscaledZ-1),t[s.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const e=Math.ceil(t.width/this._source.tileSize)+1,i=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*i*5),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t])}}update(e,i){if(this.transform=e,this.terrain=i,!this._sourceLoaded||this._paused)return;let r;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=e.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:i}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=e.coveringZoomLevel(this._source),o=Math.max(n-ot.maxOverzooming,this._source.minzoom),a=Math.max(n+ot.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of r)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}r=r.concat(Object.values(t))}const s=this._updateRetainedTiles(r,n);if(st(this._source.type)){const e={},l={},c=Object.keys(s);for(const i of c){const r=s[i],n=this._tiles[i];if(!n||n.fadeEndTime&&n.fadeEndTime<=t.exported.now())continue;const a=this.findLoadedParent(r,o);a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),l[i]=r}this._retainLoadedChildren(l,n,a,s);for(const t in e)s[t]||(this._coveredTiles[t]=!0,s[t]=e[t]);if(i){const t={},e={};for(const i of r)this._tiles[i.key].hasData()?t[i.key]=i:e[i.key]=i;for(const i in e){const r=e[i].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=s[r[0].key]=r[0],t[r[1].key]=s[r[1].key]=r[1],t[r[2].key]=s[r[2].key]=r[2],t[r[3].key]=s[r[3].key]=r[3],delete e[i])}for(const i in e){const r=this.findLoadedParent(e[i],this._source.minzoom);if(r){t[r.tileID.key]=s[r.tileID.key]=r.tileID;for(const e in t)t[e].isChildOf(r.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}for(const t in s)this._tiles[t].clearFadeHold();const l=t.keysDifference(this._tiles,s);for(const t of l){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){const i={},r={},n=Math.max(e-ot.maxOverzooming,this._source.minzoom),o=Math.max(e+ot.maxUnderzooming,this._source.minzoom),a={};for(const r of t){const t=this._addTile(r);i[r.key]=r,t.hasData()||e<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,e,o,i);for(const o of t){let t=this._tiles[o.key];if(t.hasData())continue;if(e+1>this._source.maxzoom){const t=o.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else{const t=o.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let e=o.overscaledZ-1;e>=n;--e){const n=o.scaledTo(e);if(r[n.key])break;if(r[n.key]=!0,t=this.getTile(n),!t&&a&&(t=this._addTile(n)),t&&(i[n.key]=n,a=t.wasRequested(),t.hasData()))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new it(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.Event("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(e,i,r){const n=[],o=this.transform;if(!o)return n;const a=r?o.getCameraQueryGeometry(e):e,s=e.map((t=>o.pointCoordinate(t,this.terrain))),l=a.map((t=>o.pointCoordinate(t,this.terrain))),c=this.getIds();let h=1/0,u=1/0,p=-1/0,d=-1/0;for(const t of l)h=Math.min(h,t.x),u=Math.min(u,t.y),p=Math.max(p,t.x),d=Math.max(d,t.y);for(let e=0;e<c.length;e++){const r=this._tiles[c[e]];if(r.holdingForFade())continue;const a=r.tileID,m=Math.pow(2,o.zoom-r.tileID.overscaledZ),f=i*r.queryPadding*t.EXTENT/r.tileSize/m,g=[a.getTilePoint(new t.MercatorCoordinate(h,u)),a.getTilePoint(new t.MercatorCoordinate(p,d))];if(g[0].x-f<t.EXTENT&&g[0].y-f<t.EXTENT&&g[1].x+f>=0&&g[1].y+f>=0){const t=s.map((t=>a.getTilePoint(t))),e=l.map((t=>a.getTilePoint(t)));n.push({tile:r,tileID:a,queryGeometry:t,cameraQueryGeometry:e,scale:m})}}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(st(this._source.type))for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t.exported.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function at(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function st(t){return"raster"===t||"image"===t||"video"===t}ot.maxOverzooming=10,ot.maxUnderzooming=3;const lt="mapboxgl_preloaded_worker_pool";class ct{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<ct.workerCount;)this.workers.push(new Worker(Tn.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lt]}numActive(){return Object.keys(this.active).length}}const ht=Math.floor(t.exported.hardwareConcurrency/2);let ut;function pt(){return ut||(ut=new ct),ut}function dt(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function mt(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=dt(t[i],e[t[i].ref]));return t}ct.workerCount=Math.max(Math.min(ht,6),1);const ft={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 gt(t,e,i){i.push({command:ft.addSource,args:[t,e[t]]})}function _t(t,e,i){e.push({command:ft.removeSource,args:[t]}),i[t]=!0}function yt(t,e,i,r){_t(t,i,r),gt(t,e,i)}function xt(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;return!0}function vt(t,e,i,r,o,a){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(n(t[s],e[s])||i.push({command:a,args:[r,s,e[s],o]}));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(n(t[s],e[s])||i.push({command:a,args:[r,s,e[s],o]}))}function bt(t){return t.id}function wt(t,e){return t[e.id]=e,t}function Tt(e,i,r){return i*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))*2**t.exported.detailLevel}class Et{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class St{constructor(t,e,i,r,n){this.text=new Et(t?t.text:null,e,i,n),this.icon=new Et(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class At{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class It{constructor(){this.invProjMatrix=t.create(),this.viewportMatrix=t.create(),this.circles=[]}}class Ct{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Mt{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 e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function kt(e,i,r,n,o){const{horizontalAlign:a,verticalAlign:s}=t.getAnchorAlignment(e),l=-(a-.5)*i,c=-(s-.5)*r,h=t.evaluateVariableOffset(e,n);return new t.pointGeometry(l+h[0]*o,c+h[1]*o)}function Pt(e,i,r,n,o,a){const{x1:s,x2:l,y1:c,y2:h,anchorPointX:u,anchorPointY:p}=e,d=new t.pointGeometry(i,r);return n&&d._rotate(o?a:-a),{x1:s+d.x,y1:c+d.y,x2:l+d.x,y2:h+d.y,anchorPointX:u,anchorPointY:p}}class zt{constructor(t,e,i,r,n){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new K(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Mt(r),this.collisionCircleArrays={},this.glyphCircles={},this.placedBoxes={},this.anchorAngles={},this.variableAnchors={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,n){const o=r.getBucket(i),a=r.latestFeatureIndex;if(!o||!a||i.id!==o.layerIds[0])return;const s=r.collisionBoxArray,l=o.layers[0].layout,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/t.EXTENT,u=this.transform.calculatePosMatrix(r.tileID.toUnwrapped()),p="map"===l.get("text-pitch-alignment"),d="map"===l.get("text-rotation-alignment"),m=Tt(r,1,this.transform.zoom),f=B(u,p,d,this.transform,m);let g=null;if(p){const e=R(u,p,d,this.transform,m);g=t.multiply([],this.transform.labelPlaneMatrix,e)}this.retainedQueryData[o.bucketInstanceId]=new Ct(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const _={bucket:o,layout:l,posMatrix:u,textLabelPlaneMatrix:f,labelToScreenMatrix:g,scale:c,textPixelRatio:h,holdingForFade:r.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:_})}attemptAnchorPlacement(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f){const g=[u.textOffset0,u.textOffset1],_=kt(t,i,r,g,n),y=this.collisionIndex.placeCollisionBox(Pt(e,_.x,_.y,o,a,this.transform.angle),h,s,l,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(Pt(m,_.x,_.y,o,a,this.transform.angle),h,s,l,c.predicate,f).box.length)&&y.box.length>0){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),0===u.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[u.crossTileID]={textOffset:g,width:i,height:r,anchor:t,textBoxScale:n,prevAnchor:e},this.markUsedJustification(p,t,u,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,u),this.placedOrientations[u.crossTileID]=d),{shift:_,placedGlyphBoxes:y}}}placeLayerBucketPart(e,i,r){const{bucket:n,layout:o,posMatrix:a,textLabelPlaneMatrix:s,labelToScreenMatrix:l,textPixelRatio:c,holdingForFade:h,collisionBoxArray:u,partiallyEvaluatedTextSize:p,collisionGroup:d}=e.parameters,m=o.get("text-optional"),f=o.get("icon-optional"),g=t.getOverlapMode(o,"text-overlap","text-allow-overlap"),_="always"===g,y=t.getOverlapMode(o,"icon-overlap","icon-allow-overlap"),x="always"===y,v="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=_&&(x||!n.hasIconData()||f),S=x&&(_||!n.hasTextData()||m);!n.collisionArrays&&u&&n.deserializeCollisionBoxes(u);const A=(e,u)=>{if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new At(!1,!1,!1));let x=!1,T=!1,A=!0,I=null,C={box:null,offscreen:null},M={box:null,offscreen:null},k=null,P=null,z=null,L=0,D=0,B=0;u.textFeatureIndex?L=u.textFeatureIndex:e.useRuntimeCollisionCircles&&(L=e.featureIndex),u.verticalTextFeatureIndex&&(D=u.verticalTextFeatureIndex);const R=this.retainedQueryData[n.bucketInstanceId].tileID,F=this.terrain?(t,e)=>this.terrain.getElevation(R,t,e):null;for(const t of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const e=u[t];e&&(e.elevation=F?F(e.anchorPointX,e.anchorPointY):0)}const O=u.textBox;if(O){const i=i=>{let r=t.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},r=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&u.verticalTextBox){for(const e of n.writingModes)if(e===t.WritingMode.vertical?(C=r(),M=C):C=i(),C&&C.box&&C.box.length)break}else C=i()};if(o.get("text-variable-anchor")){let s=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];s.indexOf(t.anchor)>0&&(s=s.filter((e=>e!==t.anchor)),s.unshift(t.anchor))}const l=(t,i,r)=>{const o=t.x2-t.x1,l=t.y2-t.y1,h=e.textBoxScale,u=w&&"never"===y?i:null;let p={box:[],offscreen:!1};const m="never"!==g?2*s.length:s.length;for(let i=0;i<m;++i){const m=s[i%s.length],f=this.attemptAnchorPlacement(m,t,o,l,h,v,b,c,a,d,i>=s.length?g:"never",e,n,r,u,F);if(f&&(p=f.placedGlyphBoxes,p&&p.box&&p.box.length)){x=!0,I=f.shift,this.addVariableAnchor(n.bucketInstanceId,L,m);break}}return p};r((()=>l(O,u.iconBox,t.WritingMode.horizontal)),(()=>{const i=u.verticalTextBox;return n.allowVerticalPlacement&&!(C&&C.box&&C.box.length)&&e.numVerticalGlyphVertices>0&&i?l(i,u.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),C&&(x=C.box,A=C.offscreen);const h=i(C&&C.box);if(!x&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,h))}}else{const o=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,c,a,d.predicate,F);return r&&r.box&&r.box.length&&(this.markUsedOrientation(n,i,e),this.placedOrientations[e.crossTileID]=i),r};r((()=>o(O,t.WritingMode.horizontal)),(()=>{const i=u.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?o(i,t.WritingMode.vertical):{box:null,offscreen:null}})),i(C&&C.box&&C.box.length)}}if(k=C,x=k&&k.box&&k.box.length>0,A=k&&k.offscreen,e.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),c=t.evaluateSizeForFeature(n.textSizeData,p,i),h=o.get("text-padding");P=this.collisionIndex.placeCollisionCircles(g,i,n.lineVertexArray,n.glyphOffsetArray,c,a,s,l,r,b,d.predicate,e.collisionCircleDiameter,h,F),P.circles.length&&P.collisionDetected&&!r&&t.warnOnce("Collisions detected, but collision boxes are not shown"),x=_||P.circles.length>0&&!P.collisionDetected,A=A&&P.offscreen}if(u.iconFeatureIndex&&(B=u.iconFeatureIndex),u.iconBox){const t=t=>{const e=w&&I?Pt(t,I.x,I.y,v,b,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,y,c,a,d.predicate,F)};M&&M.box&&M.box.length&&u.verticalIconBox?(z=t(u.verticalIconBox),T=z.box.length>0):(z=t(u.iconBox),T=z.box.length>0),A=A&&z.offscreen}const U=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,V=f||0===e.numIconVertices;if(U||V?V?U||(T=T&&x):x=T&&x:T=x=T&&x,x&&k&&k.box&&(this.collisionIndex.insertCollisionBox(k.box,g,o.get("text-ignore-placement"),n.bucketInstanceId,M&&M.box&&D?D:L,d.ID),this.addPlacedBox(n.bucketInstanceId,L,k.box,"text")),T&&z&&(this.collisionIndex.insertCollisionBox(z.box,y,o.get("icon-ignore-placement"),n.bucketInstanceId,B,d.ID),this.addPlacedBox(n.bucketInstanceId,B,z.box,"icon")),(x||T)&&this.addAnchorAngle(n.bucketInstanceId,L,e.angle),P&&(x&&(A||this.addGlyphCircles(n.bucketInstanceId,L,P.circles),this.collisionIndex.insertCollisionCircles(P.circles,g,o.get("text-ignore-placement"),n.bucketInstanceId,L,d.ID)),r)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new It);for(let t=0;t<P.circles.length;t+=4)e.circles.push(P.circles[t+0]),e.circles.push(P.circles[t+1]),e.circles.push(P.circles[t+2]),e.circles.push(P.collisionDetected?1:0)}if(0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new At(x||E,T||S,A||n.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=n.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];A(n.symbolInstances.get(i),n.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)A(n.symbolInstances.get(t),n.collisionArrays[t]);if(r&&n.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[n.bucketInstanceId];t.invert(e.invProjMatrix,a),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}n.justReloaded=!1}markUsedJustification(e,i,r,n){let o;o=n===t.WritingMode.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.getAnchorJustification(i)];const a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const t of a)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,o=i===t.WritingMode.vertical?i:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of a)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},o=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=n[t];o?(this.opacities[t]=new St(o,r,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new St(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new St(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in a)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=a[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,o=new St(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),s=n.get("icon-allow-overlap"),l=n.get("text-variable-anchor"),c="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),u="none"!==n.get("icon-text-fit"),p=new St(null,0,a&&(s||!e.hasIconData()||n.get("icon-optional")),s&&(a||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const d=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:s,crossTileID:m}=n;let f=this.opacities[m];i[m]?f=o:f||(f=p,this.opacities[m]=f),i[m]=!0;const g=n.numIconVertices>0,_=this.placedOrientations[n.crossTileID],y=_===t.WritingMode.vertical,x=_===t.WritingMode.horizontal||_===t.WritingMode.horizontalOnly;if(a>0||s>0){const t=Nt(f.text);d(e.text,a,y?$t:t),d(e.text,s,x?$t:t);const i=f.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,_);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(e,"left",n,o),this.markUsedOrientation(e,o,n))}if(g){const t=Nt(f.icon),i=!(u&&n.verticalPlacedIconSymbolIndex&&y);n.placedIconSymbolIndex>=0&&(d(e.icon,n.numIconVertices,i?t:$t),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=f.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(d(e.icon,n.numVerticalIconVertices,i?$t:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=f.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[r];if(i){let r=new t.pointGeometry(0,0);if(i.textBox||i.verticalTextBox){let t=!0;if(l){const e=this.variableOffsets[m];e?(r=kt(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):t=!1}i.textBox&&Lt(e.textCollisionBox.collisionVertexArray,f.text.placed,!t||y,r.x,r.y),i.verticalTextBox&&Lt(e.textCollisionBox.collisionVertexArray,f.text.placed,!t||x,r.x,r.y)}const n=Boolean(!x&&i.verticalIconBox);i.iconBox&&Lt(e.iconCollisionBox.collisionVertexArray,f.icon.placed,n,u?r.x:0,u?r.y:0),i.verticalIconBox&&Lt(e.iconCollisionBox.collisionVertexArray,f.icon.placed,!n,u?r.x:0,u?r.y:0)}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?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,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}addGlyphCircles(t,e,i){t in this.glyphCircles||(this.glyphCircles[t]={}),e in this.glyphCircles[t]||(this.glyphCircles[t][e]=[]),this.glyphCircles[t][e].push(i)}addPlacedBox(t,e,i,r){t in this.placedBoxes||(this.placedBoxes[t]={}),e in this.placedBoxes[t]||(this.placedBoxes[t][e]=[]),this.placedBoxes[t][e].push({purpose:r,coords:i})}addAnchorAngle(t,e,i){t in this.anchorAngles||(this.anchorAngles[t]={}),e in this.anchorAngles[t]||(this.anchorAngles[t][e]=[]),this.anchorAngles[t][e].push(i)}addVariableAnchor(t,e,i){t in this.variableAnchors||(this.variableAnchors[t]={}),this.variableAnchors[t][e]=i}}function Lt(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const Dt=Math.pow(2,25),Bt=Math.pow(2,24),Rt=Math.pow(2,17),Ft=Math.pow(2,16),Ot=Math.pow(2,9),Ut=Math.pow(2,8),Vt=Math.pow(2,1);function Nt(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Dt+e*Bt+i*Rt+e*Ft+i*Ot+e*Ut+i*Vt+e}const $t=0;class Gt{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(o,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<o.length;)if(e.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class jt{constructor(t,e,i,r,n,o,a,s){this.placement=new zt(t,e,o,a,s),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(e,i,r){const n=t.exported.now(),o=()=>{const e=t.exported.now()-n;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=n)&&(!t.maxzoom||t.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Gt(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const qt=512/t.EXTENT/2;class Zt{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(e,i){const r=qt/Math.pow(2,i.canonical.z-this.tileID.canonical.z);return{x:Math.floor((i.canonical.x*t.EXTENT+e.anchorX)*r),y:Math.floor((i.canonical.y*t.EXTENT+e.anchorY)*r)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const o=t.get(n);if(o.crossTileID)continue;const a=this.indexedSymbolInstances[o.key];if(!a)continue;const s=this.getScaledCoordinates(o,e);for(const t of a)if(Math.abs(t.coord.x-s.x)<=r&&Math.abs(t.coord.y-s.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,o.crossTileID=t.crossTileID;break}}}}class Xt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Wt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,r)}else{const o=n[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Zt(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class Ht{constructor(){this.layerIndexes={},this.crossTileIDs=new Xt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Wt);let n=!1;const o={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(n=!0),o[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(n=!0),n}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var Kt=t.createLayout([{name:"a_pos",type:"Int16",components:2}]);class Yt extends t.Evented{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=t._cache.max,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const t in this._tiles){const e=this._tiles[t];e.textures.forEach((t=>t.destroy())),e.textures=[]}}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];for(const r of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.posMatrix=new Float64Array(16),t.ortho(r.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),this._tiles[r.key]=new it(r,this.tileSize))}removeOutdated(t){const e={};this.renderHistory=this.renderHistory.filter(((t,e)=>this.renderHistory.indexOf(t)===e)).slice(0,this.renderHistorySize);for(const t of this._renderableTilesKeys)e[t]=!0;for(const t of this.renderHistory)e[t]=!0;for(const i in this._tiles)e[i]||(this._tiles[i].clearTextures(t),delete this._tiles[i])}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(e){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID;if(n.canonical.equals(e.canonical)){const n=e.clone();n.posMatrix=new Float64Array(16),t.ortho(n.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),i[r]=n}else if(n.canonical.isChildOf(e.canonical)){const o=e.clone();o.posMatrix=new Float64Array(16);const a=n.canonical.z-e.canonical.z,s=n.canonical.x-(n.canonical.x>>a<<a),l=n.canonical.y-(n.canonical.y>>a<<a),c=t.EXTENT>>a;t.ortho(o.posMatrix,0,c,0,c,0,1),t.translate(o.posMatrix,o.posMatrix,[-s*c,-l*c,0]),i[r]=o}else if(e.canonical.isChildOf(n.canonical)){const o=e.clone();o.posMatrix=new Float64Array(16);const a=e.canonical.z-n.canonical.z,s=e.canonical.x-(e.canonical.x>>a<<a),l=e.canonical.y-(e.canonical.y>>a<<a),c=t.EXTENT>>a;t.ortho(o.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),t.translate(o.posMatrix,o.posMatrix,[s*c,l*c,0]),t.scale(o.posMatrix,o.posMatrix,[1/2**a,1/2**a,0]),i[r]=o}}return i}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let n=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!n||!n.dem)&&e)for(;r>=i.minzoom&&(!n||!n.dem);)n=this.sourceCache.getTileByID(t.scaledTo(r--).key);return n}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeLoaded>=t))}}class Jt{constructor(t,e,i){this.style=t,this.sourceCache=new Yt(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.elevationOffset="number"==typeof i.elevationOffset?i.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(e,i,r,n=t.EXTENT){if(!(i>=0&&i<n&&r>=0&&r<n))return this.elevationOffset;let o=0;const a=this.getTerrainData(e);if(a.tile&&a.tile.dem){const e=t.transformMat4$1([],[i/n*t.EXTENT,r/n*t.EXTENT],a.u_terrain_matrix),s=[e[0]*a.tile.dem.dim,e[1]*a.tile.dem.dim],l=[Math.floor(s[0]),Math.floor(s[1])],c=a.tile.dem.get(l[0],l[1]),h=a.tile.dem.get(l[0],l[1]+1),u=a.tile.dem.get(l[0]+1,l[1]),p=a.tile.dem.get(l[0]+1,l[1]+1);o=t.number(t.number(c,h,s[0]-l[0]),t.number(u,p,s[0]-l[0]),s[1]-l[1])}return o}rememberForRerender(t,e){for(const i in this.sourceCache._tiles){const r=this.sourceCache._tiles[i];(r.tileID.equals(e)||r.tileID.isChildOf(e))&&(t===this.sourceCache.sourceCache.id&&(r.timeLoaded=Date.now()),this._rerender[t]=this._rerender[t]||{},this._rerender[t][r.tileID.key]=!0)}}needsRerender(t,e){return this._rerender[t]&&this._rerender[t][e.key]}clearRerenderCache(){this._rerender={}}getElevation(e,i,r,n=t.EXTENT){return(this.getDEMElevation(e,i,r,n)+this.elevationOffset)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.style.map.painter.context,i=new t.RGBAImage({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new l(e,i,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new l(e,new t.RGBAImage({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.identity([])}const i=this.sourceCache.getSourceTile(e,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const t=this.style.map.painter.context;i.demTexture=this.style.map.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new l(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const r=i&&i+i.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){const r=this.sourceCache.sourceCache._source.maxzoom;let n=e.canonical.z-i.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=r?n=e.canonical.z-r:t.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),s=t.fromScaling(new Float64Array(16),[1/(t.EXTENT<<n),1/(t.EXTENT<<n),0]);t.translate(s,s,[o*t.EXTENT,a*t.EXTENT,0]),this._demMatrixCache[e.key]={matrix:s,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_offset:this.elevationOffset,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getRTTFramebuffer(){const t=this.style.map.painter;if(!this._rttFramebuffer){const e=this.sourceCache.tileSize*this.qualityFactor;this._rttFramebuffer=t.context.createFramebuffer(e,e,!0),this._rttFramebuffer.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,e,e))}return this._rttFramebuffer}getFramebuffer(t){const e=this.style.map.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new l(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new l(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.style.map.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,e+=4)i[e+0]=255&r,i[e+1]=255&t,i[e+2]=r>>8<<4|t>>8,i[e+3]=0;const r=new t.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new l(e,r,e.gl.RGBA,{premultiply:!1});return n.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(e){const i=new Uint8Array(4),r=this.style.map.painter,n=r.context,o=n.gl;n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(e.x,r.height/devicePixelRatio-e.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const a=i[0]+(i[2]>>4<<8),s=i[1]+((15&i[2])<<8),l=this.coordsIndex[255-i[3]],c=l&&this.sourceCache.getTileByID(l);if(!c)return null;const h=this._coordsTextureSize,u=(1<<c.tileID.canonical.z)*h;return new t.MercatorCoordinate((c.tileID.canonical.x*h+a)/u,(c.tileID.canonical.y*h+s)/u,this.getElevation(c.tileID,a,s,h))}getTerrainMesh(){if(this._mesh)return this._mesh;const e=this.style.map.painter.context,i=new t.PosArray,r=new t.TriangleIndexArray,n=this.meshSize,o=t.EXTENT/n,a=n*n;for(let t=0;t<=n;t++)for(let e=0;e<=n;e++)i.emplaceBack(e*o,t*o);for(let t=0;t<a;t+=n+1)for(let e=0;e<n;e++)r.emplaceBack(e+t,n+e+t+1,n+e+t+2),r.emplaceBack(e+t,n+e+t+2,e+t+1);return this._mesh={indexBuffer:e.createIndexBuffer(r),vertexBuffer:e.createVertexBuffer(i,Kt.members),segments:t.SegmentVector.simpleSegment(0,0,i.length,r.length)},this._mesh}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=(e.dem.min+this.elevationOffset)*this.exaggeration,i.maxElevation=(e.dem.max+this.elevationOffset)*this.exaggeration),i}}const Qt=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),te=t.pick(ft,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),ee=t.pick(ft,["setCenter","setZoom","setBearing","setPitch"]),ie=function(){const e={},i=t.spec.$version;for(const r in t.spec.$root){const n=t.spec.$root[r];if(n.required){let t=null;t="version"===r?i:"array"===n.type?[]:{},null!=t&&(e[r]=t)}}return e}();class re extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new x(pt(),this),this.imageManager=new h,this.imageManager.setEventedParent(this),this.glyphManager=new m(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new y(256,512),this.crossTileSymbolIndex=new Ht,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=re.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r.sourceCaches)r.sourceCaches[t].reload()}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"!=typeof i.validate||i.validate,n=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(n,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(ie,!1)}_load(e,i){if(i&&Qt(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=e;for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});e.sprite?this._loadSprite(e.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);const r=mt(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let e of r)e=t.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new _(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}_loadSprite(e){this._spriteRequest=function(e,i,r,n){let o,a,s;const l=r>1?"@2x":"";let c=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,l,".json"),t.ResourceType.SpriteJSON),((t,e)=>{c=null,s||(s=t,o=e,u())})),h=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,l,".png"),t.ResourceType.SpriteImage),((t,e)=>{h=null,s||(s=t,a=e,u())}));function u(){if(s)n(s);else if(o&&a){const e=t.exported.getImageData(a),i={};for(const r in o){const{width:n,height:a,x:s,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:p,content:d}=o[r],m=new t.RGBAImage({width:n,height:a});t.RGBAImage.copy(e,m,{x:s,y:l},{x:0,y:0},{width:n,height:a}),i[r]={data:m,pixelRatio:h,sdf:c,stretchX:u,stretchY:p,content:d}}n(null,i)}}return{cancel(){c&&(c.cancel(),c=null),h&&(h.cancel(),h=null)}}}(e,this.map._requestManager,this.map.getPixelRatio(),((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}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(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const e in r){const i=this.sourceCaches[e];r[e]!==i.used&&i.fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.z=e.zoom,i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(e){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),e){const t=this.sourceCaches[e.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain=new Jt(this,t,e),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=t=>{t.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=t=>{t.tile&&(t.sourceId===e.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(t.sourceId,t.tile.tileID)):"geojson"===t.source.type&&this.terrain.rememberForRerender(t.sourceId,t.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new t.Event("terrain",{terrain:e}))}setState(e){if(this._checkLoaded(),Qt(this,t.validateStyle(e)))return!1;(e=t.clone$1(e)).layers=mt(e.layers);const i=function(t,e){if(!t)return[{command:ft.setStyle,args:[e]}];let i=[];try{if(!n(t.version,e.version))return[{command:ft.setStyle,args:[e]}];n(t.center,e.center)||i.push({command:ft.setCenter,args:[e.center]}),n(t.zoom,e.zoom)||i.push({command:ft.setZoom,args:[e.zoom]}),n(t.bearing,e.bearing)||i.push({command:ft.setBearing,args:[e.bearing]}),n(t.pitch,e.pitch)||i.push({command:ft.setPitch,args:[e.pitch]}),n(t.sprite,e.sprite)||i.push({command:ft.setSprite,args:[e.sprite]}),n(t.glyphs,e.glyphs)||i.push({command:ft.setGlyphs,args:[e.glyphs]}),n(t.transition,e.transition)||i.push({command:ft.setTransition,args:[e.transition]}),n(t.light,e.light)||i.push({command:ft.setLight,args:[e.light]});const r={},o=[];!function(t,e,i,r){let o;for(o in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,o)&&(Object.prototype.hasOwnProperty.call(e,o)||_t(o,i,r));for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(Object.prototype.hasOwnProperty.call(t,o)?n(t[o],e[o])||("geojson"===t[o].type&&"geojson"===e[o].type&&xt(t,e,o)?i.push({command:ft.setGeoJSONSourceData,args:[o,e[o].data]}):yt(o,e,i,r)):gt(o,e,i))}(t.sources,e.sources,o,r);const a=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:ft.removeLayer,args:[t.id]}):a.push(t)})),i=i.concat(o),function(t,e,i){e=e||[];const r=(t=t||[]).map(bt),o=e.map(bt),a=t.reduce(wt,{}),s=e.reduce(wt,{}),l=r.slice(),c=Object.create(null);let h,u,p,d,m,f,g;for(h=0,u=0;h<r.length;h++)p=r[h],Object.prototype.hasOwnProperty.call(s,p)?u++:(i.push({command:ft.removeLayer,args:[p]}),l.splice(l.indexOf(p,u),1));for(h=0,u=0;h<o.length;h++)p=o[o.length-1-h],l[l.length-1-h]!==p&&(Object.prototype.hasOwnProperty.call(a,p)?(i.push({command:ft.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-u),1)):u++,f=l[l.length-h],i.push({command:ft.addLayer,args:[s[p],f]}),l.splice(l.length-h,0,p),c[p]=!0);for(h=0;h<o.length;h++)if(p=o[h],d=a[p],m=s[p],!c[p]&&!n(d,m))if(n(d.source,m.source)&&n(d["source-layer"],m["source-layer"])&&n(d.type,m.type)){for(g in vt(d.layout,m.layout,i,p,null,ft.setLayoutProperty),vt(d.paint,m.paint,i,p,null,ft.setPaintProperty),n(d.filter,m.filter)||i.push({command:ft.setFilter,args:[p,m.filter]}),n(d.minzoom,m.minzoom)&&n(d.maxzoom,m.maxzoom)||i.push({command:ft.setLayerZoomRange,args:[p,m.minzoom,m.maxzoom]}),d)Object.prototype.hasOwnProperty.call(d,g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?vt(d[g],m[g],i,p,g.slice(6),ft.setPaintProperty):n(d[g],m[g])||i.push({command:ft.setLayerProperty,args:[p,g,m[g]]}));for(g in m)Object.prototype.hasOwnProperty.call(m,g)&&!Object.prototype.hasOwnProperty.call(d,g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?vt(d[g],m[g],i,p,g.slice(6),ft.setPaintProperty):n(d[g],m[g])||i.push({command:ft.setLayerProperty,args:[p,g,m[g]]}))}else i.push({command:ft.removeLayer,args:[p]}),f=l[l.lastIndexOf(p)+1],i.push({command:ft.addLayer,args:[m,f]})}(a,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:ft.setStyle,args:[e]}]}return i}(this.serialize(),e).filter((t=>!(t.command in ee)));if(0===i.length)return!1;const r=i.filter((t=>!(t.command in te)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((t=>t.command)).join(", ")}.`);return i.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=e,!0}addImage(e,i){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateStyle.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.sourceCaches[e]=new ot(e,i,this.dispatcher);n.style=this,n.setEventedParent(this,(()=>({isSourceLoaded:this.loaded(),source:n.serialize(),sourceId:e}))),n.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.ErrorEvent(new Error(`Layer "${n}" already exists on this map.`)));let o;if("custom"===e.type){if(Qt(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(n,e.source),e=t.clone$1(e),e=t.extend(e,{source:n})),this._validate(t.validateStyle.layer,`layers.${n}`,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize()}const a=i?this._order.indexOf(i):this._order.length;if(i&&-1===a)this.fire(new t.ErrorEvent(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(a,0,n),this._layerOrderChanged=!0,this._layers[n]=o,this._removedLayers[n]&&o.source&&"custom"!==o.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.ErrorEvent(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!n(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.validateStyle.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.clone$1(i),this._updateLayer(o)))}else this.fire(new t.ErrorEvent(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.clone$1(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?n(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.ErrorEvent(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?n(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type;"geojson"===a&&n?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||n?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),o.setFeatureState(n,e.id,i)):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.sourceCaches[r];if(void 0===n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.getSource().type,a="vector"===o?e.sourceLayer:void 0;"vector"!==o||a?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(a,e.id,i):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.sourceCaches[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,e.id)):void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,(t=>t.serialize())),layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(e(o)){i[o]=n;for(const e of t){const t=e[o];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(e(a))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<o)break;n.push(e),r.pop()}else for(const e of t){const t=e[a];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(e,i,r){i&&i.filter&&this._validate(t.validateStyle.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const o=[];i.availableImages=this._availableImages;for(const t in this.sourceCaches)i.layers&&!n[t]||o.push(J(this.sourceCaches[t],this._layers,this._serializedLayers,e,i,r));return this.placement&&o.push(function(t,e,i,r,n,o,a){const s={},l=o.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(a[t]);c.sort(Q);for(const r of c){const o=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],e,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const e in o){const n=s[e]=s[e]||[],a=o[e];a.sort(((t,e)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(t.featureIndex);return i.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const o of a)tt(i,t,r,e,o),n.push(o)}}for(const e in s)s[e].forEach((r=>{const n=r.feature,o=i[t[e].source].getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return s}(this._layers,this._serializedLayers,this.sourceCaches,e,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateStyle.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const o=i[t],a=o.tileID.canonical.key;n[a]||(n[a]=!0,o.querySourceFeatures(r,e))}return r}(r,i):[]}addSourceType(t,e,i){return re.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(re.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const t in e)if(!n(e[t],r[t])){o=!0;break}if(!o)return;const a={now:t.exported.now(),transition:t.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(a)}_validate(e,i,r,n,o={}){return(!o||!1!==o.validate)&&Qt(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:r,styleSpec:t.spec},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(e,i,r,n,o=!1){let a=!1,s=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this.sourceCaches[i.source];l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===r)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new jt(e,this.terrain,this._order,o,i,r,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}}re.getSourceType=function(t){return P[t]},re.setSourceType=function(t,e){P[t]=e},re.registerForPluginStateChange=t.registerForPluginStateChange;var ne="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}";const oe={prelude:ae("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 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\n);}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;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_offset;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst 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) {\n#ifdef TERRAIN3D\nhighp 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));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 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;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 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_offset)*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:ae("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:ae("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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:ae("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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:ae("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:ae("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 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:ae("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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","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:ae("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:ae("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:ae("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:ae("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),fillOutline:ae("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillOutlinePattern:ae("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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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:ae("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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:ae("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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:ae("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;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef TERRAIN3D\nfloat baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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\n? a_pos\n: 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:ae("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:ae("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;\n#define PI 3.141592653589793\nvoid 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:ae("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute 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;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat 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;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:ae("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;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute 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;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat 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;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:ae("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform 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;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute 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;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat 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;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:ae("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;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute 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;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat 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;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_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:ae("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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:ae("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_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:ae("#define SDF_PX 8.0\nuniform 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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat 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 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_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:ae("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform 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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_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:ae("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",ne),terrainDepth:ae("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);}",ne),terrainCoords:ae("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);}",ne)};function ae(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=o?o.concat(n):n,s={};return{fragmentSource:t=t.replace(i,((t,e,i,r,n)=>(s[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,n)=>{const o="float"===r?"vec2":"vec4",a=n.match(/color/)?"color":o;return s[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class se{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,o,a,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===n&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===a&&this.boundDynamicVertexBuffer2===s&&this.boundDynamicVertexBuffer3===l?(t.bindVertexArrayOES.set(this.vao),a&&a.bind(),n&&n.dynamicDraw&&n.bind(),s&&s.bind(),l&&l.bind()):this.freshBind(e,i,r,n,o,a,s,l)}freshBind(t,e,i,r,n,o,a,s){let l;const c=t.numAttributes,h=this.context,u=h.gl;if(h.extVertexArrayObject)this.vao&&this.destroy(),this.vao=h.extVertexArrayObject.createVertexArrayOES(),h.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=a,this.boundDynamicVertexBuffer3=s;else{l=h.currentNumAttributes||0;for(let t=c;t<l;t++)u.disableVertexAttribArray(t)}e.enableAttributes(u,t);for(const e of i)e.enableAttributes(u,t);o&&o.enableAttributes(u,t),a&&a.enableAttributes(u,t),s&&s.enableAttributes(u,t),e.bind(),e.setVertexAttribPointers(u,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(u,t,n);o&&(o.bind(),o.setVertexAttribPointers(u,t,n)),r&&r.bind(),a&&(a.bind(),a.setVertexAttribPointers(u,t,n)),s&&(s.bind(),s.setVertexAttribPointers(u,t,n)),h.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function le(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class ce{constructor(e,i,r,n,o,a,s,l){const c=e.gl;this.program=c.createProgram(),this.painter=l;const h=le(r.staticAttributes),u=n?n.getBinderAttributes():[],p=h.concat(u),d=oe.prelude.staticUniforms?le(oe.prelude.staticUniforms):[],m=r.staticUniforms?le(r.staticUniforms):[],f=n?n.getBinderUniforms():[],g=d.concat(m).concat(f),_=[];for(const t of g)_.indexOf(t)<0&&_.push(t);const y=n?n.defines():[];a&&y.push("#define OVERDRAW_INSPECTOR;"),s&&y.push("#define TERRAIN3D;");const x=y.concat(oe.prelude.fragmentSource,r.fragmentSource).join("\n"),v=y.concat(oe.prelude.vertexSource,r.vertexSource).join("\n"),b=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);c.shaderSource(b,x),c.compileShader(b),c.attachShader(this.program,b);const w=c.createShader(c.VERTEX_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);c.shaderSource(w,v),c.compileShader(w),c.attachShader(this.program,w),this.attributes={};const T={};this.numAttributes=p.length;for(let t=0;t<this.numAttributes;t++)p[t]&&(c.bindAttribLocation(this.program,t,p[t]),this.attributes[p[t]]=t);c.linkProgram(this.program),c.deleteShader(w),c.deleteShader(b);for(let t=0;t<_.length;t++){const e=_[t];if(e&&!T[e]){const t=c.getUniformLocation(this.program,e);t&&(T[e]=t)}}this.fixedUniforms=o(e,T),this.terrainUniforms=((e,i)=>({u_depth:new t.Uniform1i(e,i.u_depth),u_terrain:new t.Uniform1i(e,i.u_terrain),u_terrain_dim:new t.Uniform1f(e,i.u_terrain_dim),u_terrain_matrix:new t.UniformMatrix4f(e,i.u_terrain_matrix),u_terrain_unpack:new t.Uniform4f(e,i.u_terrain_unpack),u_terrain_offset:new t.Uniform1f(e,i.u_terrain_offset),u_terrain_exaggeration:new t.Uniform1f(e,i.u_terrain_exaggeration)}))(e,T),this.binderUniforms=n?n.getUniforms(e,T):[]}draw(t,e,i,r,n,o,a,s,l,c,h,u,p,d,m,f,g,_){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(o),s){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,s.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,s.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(s[t])}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(a[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});let x=0;switch(e){case y.LINES:x=2;break;case y.TRIANGLES:x=3;break;case y.LINE_STRIP:x=1}for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[l]||(r[l]=new se)).bind(t,this,c,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,f,g,_),y.drawElements(e,i.primitiveLength*x,y.UNSIGNED_SHORT,i.primitiveOffset*x*2),this.painter.visibleLayers.add(l)}}}function he(t,e,i){const r=1/Tt(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,a=o*(i.tileID.canonical.x+i.tileID.wrap*n),s=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}const ue=(e,i,r,n)=>{const o=i.style.light,a=o.properties.get("position"),s=[a.x,a.y,a.z],l=t.create$1();"viewport"===o.properties.get("anchor")&&t.fromRotation(l,-i.transform.angle),t.transformMat3(s,s,l);const c=o.properties.get("color");return{u_matrix:e,u_lightpos:s,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+r,u_opacity:n}},pe=(e,i,r,n,o,a,s)=>t.extend(ue(e,i,r,n),he(a,i,s),{u_height_factor:-Math.pow(2,o.overscaledZ)/s.tileSize/8}),de=t=>({u_matrix:t}),me=(e,i,r,n)=>t.extend(de(e),he(r,i,n)),fe=(t,e)=>({u_matrix:t,u_world:e}),ge=(e,i,r,n,o)=>t.extend(me(e,i,r,n),{u_world:o}),_e=(t,e,i,r)=>{const n=t.transform;let o,a;if("map"===r.paint.get("circle-pitch-alignment")){const t=Tt(i,1,n.zoom);o=!0,a=[t,t]}else o=!1,a=n.pixelsToGLUnits;return{u_camera_to_center_distance:n.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+o,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},ye=(t,e,i)=>{const r=Tt(i,1,e.zoom),n=Math.pow(2,e.zoom-i.tileID.overscaledZ),o=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*n),e.pixelsToGLUnits[1]/(r*n)],u_overscale_factor:o}},xe=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),ve=t=>({u_matrix:t}),be=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:Tt(e,1,i),u_intensity:r});function we(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.MercatorCoordinate(0,n/r).toLngLat().lat,new t.MercatorCoordinate(0,(n+1)/r).toLngLat().lat]}const Te=(t,e,i,r)=>{const n=t.transform;return{u_matrix:Ce(t,e,i,r),u_ratio:1/Tt(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},Ee=(e,i,r,n,o)=>t.extend(Te(e,i,r,o),{u_image:0,u_image_height:n}),Se=(t,e,i,r,n)=>{const o=t.transform,a=Ie(e,o);return{u_matrix:Ce(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_ratio:1/Tt(e,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Ae=(e,i,r,n,o,a)=>{const s=e.lineAtlas,l=Ie(i,e.transform),c="round"===r.layout.get("line-cap"),h=s.getDash(n.from,c),u=s.getDash(n.to,c),p=h.width*o.fromScale,d=u.width*o.toScale;return t.extend(Te(e,i,r,a),{u_patternscale_a:[l/p,-h.height/2],u_patternscale_b:[l/d,-u.height/2],u_sdfgamma:s.width/(256*Math.min(p,d)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:o.t})};function Ie(t,e){return 1/Tt(t,1,e.tileZoom)}function Ce(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Me=(t,e,i,r,n)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:ke(n.paint.get("raster-hue-rotate"))};var o,a};function ke(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Pe=(t,e,i,r,n,o,a,s,l,c)=>{const h=n.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},ze=(e,i,r,n,o,a,s,l,c,h,u)=>{const p=o.transform;return t.extend(Pe(e,i,r,n,o,a,s,l,c,h),{u_gamma_scale:n?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:o.pixelRatio,u_is_halo:+u})},Le=(e,i,r,n,o,a,s,l,c,h)=>t.extend(ze(e,i,r,n,o,a,s,l,!0,c,!0),{u_texsize_icon:h,u_texture_icon:1}),De=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),Be=(e,i,r,n,o,a)=>t.extend(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),o=i.imageManager.getPattern(t.to.toString()),{width:a,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,s],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/Tt(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(n,a,r,o),{u_matrix:e,u_opacity:i}),Re={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,i.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,i.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,i.u_overscale_factor)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmapTexture:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_image:new t.Uniform1i(e,i.u_image),u_image_height:new t.Uniform1f(e,i.u_image_height)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),lineSDF:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,i.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,i.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,i.u_sdfgamma),u_image:new t.Uniform1i(e,i.u_image),u_tex_y_a:new t.Uniform1f(e,i.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,i.u_tex_y_b),u_mix:new t.Uniform1f(e,i.u_mix)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,i.u_buffer_scale),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texture:new t.Uniform1i(e,i.u_texture)}),terrainDepth:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),terrainCoords:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texture:new t.Uniform1i(e,i.u_texture),u_terrain_coords_id:new t.Uniform1f(e,i.u_terrain_coords_id)})};class Fe{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Oe={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ue{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.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 e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=e.attributes[n.name];void 0!==o&&t.vertexAttribPointer(o,n.components,t[Oe[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ve{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 Ne extends Ve{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class $e extends Ve{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Ge extends Ve{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class je extends Ve{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class qe extends Ve{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Ze extends Ve{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Xe extends Ve{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class We extends Ve{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class He extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class Ke extends Ve{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Ye extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class Je extends Ve{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Qe extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class ti extends Ve{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class ei extends Ve{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class ii extends Ve{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ri extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class ni extends Ve{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class oi extends Ve{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class ai extends Ve{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class si extends Ve{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class li extends Ve{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ci extends Ve{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class hi extends Ve{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class ui extends Ve{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class pi extends Ve{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class di extends Ve{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class mi extends Ve{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class fi extends Ve{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class gi extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class _i extends Ve{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class yi extends Ve{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class xi extends yi{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class vi extends yi{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class bi{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const n=t.gl,o=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new xi(t,o),r&&(this.depthAttachment=new vi(t,o)),n.checkFramebufferStatus(n.FRAMEBUFFER)!==n.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class wi{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}wi.Replace=[1,0],wi.disabled=new wi(wi.Replace,t.Color.transparent,[!1,!1,!1,!1]),wi.unblended=new wi(wi.Replace,t.Color.transparent,[!0,!0,!0,!0]),wi.alphaBlended=new wi([1,771],t.Color.transparent,[!0,!0,!0,!0]);class Ti{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Ne(this),this.clearDepth=new $e(this),this.clearStencil=new Ge(this),this.colorMask=new je(this),this.depthMask=new qe(this),this.stencilMask=new Ze(this),this.stencilFunc=new Xe(this),this.stencilOp=new We(this),this.stencilTest=new He(this),this.depthRange=new Ke(this),this.depthTest=new Ye(this),this.depthFunc=new Je(this),this.blend=new Qe(this),this.blendFunc=new ti(this),this.blendColor=new ei(this),this.blendEquation=new ii(this),this.cullFace=new ri(this),this.cullFaceSide=new ni(this),this.frontFace=new oi(this),this.program=new ai(this),this.activeTexture=new si(this),this.viewport=new li(this),this.bindFramebuffer=new ci(this),this.bindRenderbuffer=new hi(this),this.bindTexture=new ui(this),this.bindVertexBuffer=new pi(this),this.bindElementBuffer=new di(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new mi(this),this.pixelStoreUnpack=new fi(this),this.pixelStoreUnpackPremultiplyAlpha=new gi(this),this.pixelStoreUnpackFlipY=new _i(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new Fe(this,t,e)}createVertexBuffer(t,e,i){return new Ue(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i){return new bi(this,t,e,i)}clear({color:t,depth:e}){const i=this.gl;let r=0;t&&(r|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),i.clear(r)}setCullFace(t){!1===t.enable?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){n(t.blendFunction,wi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Ei{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Ei.ReadOnly=!1,Ei.ReadWrite=!0,Ei.disabled=new Ei(519,Ei.ReadOnly,[0,1]);const Si=7680;class Ai{constructor(t,e,i,r,n,o){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Ai.disabled=new Ai({func:519,mask:0},0,0,Si,Si,Si);class Ii{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}let Ci;function Mi(e,i,r,n,o,a,s){const l=e.context,c=l.gl,h=e.useProgram("collisionBox"),u=[];let p=0,d=0;for(let m=0;m<n.length;m++){const f=n[m],g=i.getTile(f),_=g.getBucket(r);if(!_)continue;let y=f.posMatrix;0===o[0]&&0===o[1]||(y=e.translatePosMatrix(f.posMatrix,g,o,a));const x=s?_.textCollisionBox:_.iconCollisionBox,v=_.collisionCircleArray;if(v.length>0){const i=t.create(),r=y;t.mul(i,_.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul(i,i,_.placementViewportMatrix),u.push({circleArray:v,circleOffset:d,transform:r,invTransform:i,coord:f}),p+=v.length/4,d=p}x&&h.draw(l,c.LINES,Ei.disabled,Ai.disabled,e.colorModeForRenderPass(),Ii.disabled,ye(y,e.transform,g),e.style.terrain&&e.style.terrain.getTerrainData(f),r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,e.transform.zoom,null,null,x.collisionVertexBuffer)}if(!s||!u.length)return;const m=e.useProgram("collisionCircle"),f=new t.CollisionCircleLayoutArray;f.resize(4*p),f._trim();let g=0;for(const t of u)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],o=t.circleArray[i+2],a=t.circleArray[i+3];f.emplace(g++,r,n,o,a,0),f.emplace(g++,r,n,o,a,1),f.emplace(g++,r,n,o,a,2),f.emplace(g++,r,n,o,a,3)}(!Ci||Ci.length<2*p)&&(Ci=function(e){const i=2*e,r=new t.QuadTriangleArray;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(p));const _=l.createIndexBuffer(Ci,!0),y=l.createVertexBuffer(f,t.collisionCircleLayout.members,!0);for(const i of u){const n={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(x=e.transform).cameraToCenterDistance,u_viewport_size:[x.width,x.height]};m.draw(l,c.TRIANGLES,Ei.disabled,Ai.disabled,e.colorModeForRenderPass(),Ii.disabled,n,e.style.terrain&&e.style.terrain.getTerrainData(i.coord),r.id,y,_,t.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,e.transform.zoom,null,null,null)}var x;y.destroy(),_.destroy()}Ii.disabled=new Ii(!1,1029,2305),Ii.backCCW=new Ii(!0,1029,2305);const ki=t.identity(new Float32Array(16));function Pi(e,i,r,n,o,a){const{horizontalAlign:s,verticalAlign:l}=t.getAnchorAlignment(e),c=-(s-.5)*i,h=-(l-.5)*r,u=t.evaluateVariableOffset(e,n);return new t.pointGeometry((c/o+u[0])*a,(h/o+u[1])*a)}function zi(e,i,r,n,o,a,s,l,c,h,u){const p=e.text.placedSymbolArray,d=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,f={};d.clear();for(let m=0;m<p.length;m++){const g=p.get(m),_=e.allowVerticalPlacement&&!g.placedOrientation,y=g.hidden||!g.crossTileID||_?null:n[g.crossTileID];if(y){const n=new t.pointGeometry(g.anchorX,g.anchorY),p=F(n,r?s:a,u),m=O(o.cameraToCenterDistance,p.signedDistanceFromCamera);let _=t.evaluateSizeForFeature(e.textSizeData,c,g)*m/t.ONE_EM;r&&(_*=e.tilePixelRatio/l);const{width:x,height:v,anchor:b,textOffset:w,textBoxScale:T}=y,E=Pi(b,x,v,w,T,_),S=r?F(n.add(E),a,u).point:p.point.add(i?E.rotate(-o.angle):E),A=e.allowVerticalPlacement&&g.placedOrientation===t.WritingMode.vertical?Math.PI/2:0;for(let e=0;e<g.numGlyphs;e++)t.addDynamicAttributes(d,S,A);h&&g.associatedIconIndex>=0&&(f[g.associatedIconIndex]={shiftedAnchor:S,angle:A})}else X(g.numGlyphs,d)}if(h){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const r=i.get(e);if(r.hidden)X(r.numGlyphs,m);else{const i=f[e];if(i)for(let e=0;e<r.numGlyphs;e++)t.addDynamicAttributes(m,i.shiftedAnchor,i.angle);else X(r.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(d)}function Li(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function Di(e,i,r,n,o,a,s,l,c,h,u,p){const d=e.context,m=d.gl,f=e.transform,g="map"===l,_="map"===c,y="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),x=g&&!_&&!y,v=!r.layout.get("symbol-sort-key").isConstant();let b=!1;const w=e.depthModeForSublayer(0,Ei.ReadOnly),T=r.layout.get("text-variable-anchor"),E=[];for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c)continue;const u=o?c.text:c.icon;if(!u||!u.segments.get().length)continue;const p=u.programConfigurations.get(r.id),d=o||c.sdfIcons,w=o?c.textSizeData:c.iconSizeData,S=_||0!==f.pitch,A=e.useProgram(Li(d,o,c),p),I=t.evaluateSizeForZoom(w,f.zoom),C=e.style.terrain&&e.style.terrain.getTerrainData(l);let M,k,P,z,L=[0,0],D=null;if(o){if(k=n.glyphAtlasTexture,P=m.LINEAR,M=n.glyphAtlasTexture.size,c.iconsInText){L=n.imageAtlasTexture.size,D=n.imageAtlasTexture;const t="composite"===w.kind||"camera"===w.kind;z=S||e.options.rotating||e.options.zooming||t?m.LINEAR:m.NEAREST}}else{const t=c.iconsNeedLinear;k=n.imageAtlasTexture,P=d||e.options.rotating||e.options.zooming||t||S?m.LINEAR:m.NEAREST,M=n.imageAtlasTexture.size}const F=Tt(n,1,e.transform.zoom),O=B(l.posMatrix,_,g,e.transform,F),U=R(l.posMatrix,_,g,e.transform,F),N=T&&c.hasTextData(),$="none"!==r.layout.get("icon-text-fit")&&N&&c.hasIconData();if(y){const t=e.style.terrain?(t,i)=>e.style.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");V(c,l.posMatrix,e,o,O,U,_,h,i,t)}const G=e.translatePosMatrix(l.posMatrix,n,a,s),j=y||o&&T||$?ki:O,q=e.translatePosMatrix(U,n,a,s,!0),Z=d&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=d?c.iconsInText?Le(w.kind,I,x,_,e,G,j,q,M,L):ze(w.kind,I,x,_,e,G,j,q,o,M,!0):Pe(w.kind,I,x,_,e,G,j,q,o,M);const W={program:A,buffers:u,uniformValues:X,atlasTexture:k,atlasTextureIcon:D,atlasInterpolation:P,atlasInterpolationIcon:z,isSDF:d,hasHalo:Z};if(v&&c.canOverlap){b=!0;const e=u.segments.get();for(const i of e)E.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:W,terrainData:C})}else E.push({segments:u.segments,sortKey:0,state:W,terrainData:C})}b&&E.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of E){const i=t.state;if(d.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Bi(i.buffers,t.segments,r,e,i.program,w,u,p,n,t.terrainData)),n.u_is_halo=0}Bi(i.buffers,t.segments,r,e,i.program,w,u,p,i.uniformValues,t.terrainData)}}function Bi(t,e,i,r,n,o,a,s,l,c){const h=r.context;n.draw(h,h.gl.TRIANGLES,o,a,s,Ii.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Ri(t,e,i,r,n,o,a){const s=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,m,f;a?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=s.LINES):(p=c?"fillPattern":"fill",u=s.TRIANGLES);for(const g of r){const r=e.getTile(g);if(c&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;const y=_.programConfigurations.get(i.id),x=t.useProgram(p,y),v=t.style.terrain&&t.style.terrain.getTerrainData(g);c&&(t.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const b=l.constantOr(null);if(b&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const w=v?g:null,T=t.translatePosMatrix(w?w.posMatrix:g.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){m=_.indexBuffer2,f=_.segments2;const e=[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===p&&c?ge(T,t,h,r,e):fe(T,e)}else m=_.indexBuffer,f=_.segments,d=c?me(T,t,h,r):de(T);x.draw(t.context,u,n,t.stencilModeForClipping(g),o,Ii.disabled,d,v,i.id,_.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,y)}}function Fi(t,e,i,r,n,o,a){const s=t.context,l=s.gl,c=i.paint.get("fill-extrusion-pattern"),h=c.constantOr(1),u=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity");for(const d of r){const r=e.getTile(d),m=r.getBucket(i);if(!m)continue;const f=t.style.terrain&&t.style.terrain.getTerrainData(d),g=m.programConfigurations.get(i.id),_=t.useProgram(h?"fillExtrusionPattern":"fillExtrusion",g);h&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),g.updatePaintBuffers(u));const y=c.constantOr(null);if(y&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[y.to.toString()],i=t.patternPositions[y.from.toString()];e&&i&&g.setConstantPatternPositions(e,i)}const x=t.translatePosMatrix(d.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=h?pe(x,t,v,p,d,u,r):ue(x,t,v,p);_.draw(s,s.gl.TRIANGLES,n,o,a,Ii.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,g,t.style.terrain&&m.centroidVertexBuffer)}}function Oi(t,e,i,r,n,o,a){const s=t.context,l=s.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.terrain&&t.style.terrain.getTerrainData(e);s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(s,l.TRIANGLES,n,o,a,Ii.disabled,((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:we(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:n,u_highlight:o,u_accent:a}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function Ui(e,i,r,n,o,a){const s=e.context,c=s.gl,h=i.dem;if(h&&h.data){const u=h.dim,p=h.stride,d=h.getPixels();if(s.activeTexture.set(c.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(p),i.demTexture){const t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(c.NEAREST,c.CLAMP_TO_EDGE)}else i.demTexture=new l(s,d,c.RGBA,{premultiply:!1}),i.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);s.activeTexture.set(c.TEXTURE0);let m=i.fbo;if(!m){const t=new l(s,{width:u,height:u,data:null},c.RGBA);t.bind(c.LINEAR,c.CLAMP_TO_EDGE),m=i.fbo=s.createFramebuffer(u,u,!0),m.colorAttachment.set(t.texture)}s.bindFramebuffer.set(m.framebuffer),s.viewport.set([0,0,u,u]),e.useProgram("hillshadePrepare").draw(s,c.TRIANGLES,n,o,a,Ii.disabled,((e,i)=>{const r=i.stride,n=t.create();return t.ortho(n,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(n,n,[0,-t.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,h),null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}}function Vi(e,i,r,n,o,a){const s=n.paint.get("raster-fade-duration");if(!a&&s>0){const n=t.exported.now(),a=(n-e.timeAdded)/s,l=i?(n-i.timeAdded)/s:-1,c=r.getSource(),h=o.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),p=u&&e.refreshedUponExpiration?1:t.clamp(u?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const Ni=new t.Color(1,0,0,1),$i=new t.Color(0,1,0,1),Gi=new t.Color(0,0,1,1),ji=new t.Color(1,0,1,1),qi=new t.Color(0,1,1,1);function Zi(t,e,i,r){Wi(t,0,e+i/2,t.transform.width,i,r)}function Xi(t,e,i,r){Wi(t,e-i/2,0,i,t.transform.height,r)}function Wi(t,e,i,r,n,o){const a=t.context,s=a.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),a.clear({color:o}),s.disable(s.SCISSOR_TEST)}function Hi(e,i,r){const n=e.context,o=n.gl,a=r.posMatrix,s=e.useProgram("debug"),l=Ei.disabled,c=Ai.disabled,h=e.colorModeForRenderPass(),u="$debug",p=e.style.terrain&&e.style.terrain.getTerrainData(r);n.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);const d=i.getTileByID(r.key).latestRawTileData,m=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,g=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5;let _=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(_+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${_} ${m}kB`),s.draw(n,o.TRIANGLES,l,c,wi.alphaBlended,Ii.disabled,xe(a,t.Color.transparent,g),null,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(n,o.LINE_STRIP,l,c,h,Ii.disabled,xe(a,t.Color.red),p,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Ki(t,e,i){const r=t.context,n=r.gl,o=t.colorModeForRenderPass(),a=new Ei(n.LEQUAL,Ei.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh(),c=e.getTerrainData(i.tileID);r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]),r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.getRTTFramebuffer().colorAttachment.get());const h=t.transform.calculatePosMatrix(i.tileID.toUnwrapped());s.draw(r,n.TRIANGLES,a,Ai.disabled,o,Ii.backCCW,{u_matrix:h,u_texture:0},c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}function Yi(t,e,i,r){const n=t.context,o=i.tileSize*e.qualityFactor;i.textures[r]||(i.textures[r]=t.getTileTexture(o)||new l(n,{width:o,height:o,data:null},n.gl.RGBA),i.textures[r].bind(n.gl.LINEAR,n.gl.CLAMP_TO_EDGE),0===r&&e.sourceCache.renderHistory.unshift(i.tileID.key));const a=e.getRTTFramebuffer();a.colorAttachment.set(i.textures[r].texture),n.bindFramebuffer.set(a.framebuffer),n.viewport.set([0,0,o,o])}class Ji{constructor(t){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=t,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=t.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const t=this.painter.style,e=t.terrain;for(const i in t.sourceCaches){this._coordsDescendingInv[i]={};const r=t.sourceCaches[i].getVisibleCoordinates();for(const t of r){const r=e.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[i][t]||(this._coordsDescendingInv[i][t]=[]),this._coordsDescendingInv[i][t].push(r[t])}}for(const e of t._order){const i=t._layers[e],r=i.source;if(this._renderToTexture[i.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}return this._renderableTiles.forEach((t=>{for(const i in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[i][t.tileID.key];r&&r!==t.textureCoords[i]&&t.clearTextures(this.painter),e.needsRerender(i,t.tileID)&&t.clearTextures(this.painter)}this._rerender[t.tileID.key]=!t.textures.length})),e.clearRerenderCache(),e.sourceCache.removeOutdated(this.painter),this}renderLayer(e){const i=e.type,r=this.painter,n=r.style._order,o=r.currentLayer,a=o+1===n.length;if(this._renderToTexture[i]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(n[o]),!a))return!0;if(this._renderToTexture[this._prevType]||"hillshade"===i||this._renderToTexture[i]&&a){this._prevType=i;const a=this._stacks.length-1,s=this._stacks[a]||[];for(const e of this._renderableTiles){if(Yi(r,r.style.terrain,e,a),this._rerender[e.tileID.key]){r.context.clear({color:t.Color.transparent});for(let t=0;t<s.length;t++){const i=r.style._layers[s[t]],n=i.source?this._coordsDescendingInv[i.source][e.tileID.key]:[e.tileID];r._renderTileClippingMasks(i,n),r.renderLayer(r,r.style.sourceCaches[i.source],i,n),i.source&&(e.textureCoords[i.source]=this._coordsDescendingInvStr[i.source][e.tileID.key])}}Ki(r,r.style.terrain,e)}if("hillshade"===i){this._stacks.push([n[o]]);for(const i of this._renderableTiles){const n=this._coordsDescendingInv[e.source][i.tileID.key];Yi(r,r.style.terrain,i,this._stacks.length-1),r.context.clear({color:t.Color.transparent}),r._renderTileClippingMasks(e,n),r.renderLayer(r,r.style.sourceCaches[e.source],e,n),Ki(r,r.style.terrain,i)}return!0}return this._renderToTexture[i]}return!1}}const Qi={symbol:function(e,i,r,n,o){if("translucent"!==e.renderPass)return;const a=Ai.disabled,s=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,i,r,n,o,a,s){const l=i.transform,c="map"===o,h="map"===a;for(const o of e){const e=n.getTile(o),a=e.getBucket(r);if(!a||!a.text||!a.text.segments.get().length)continue;const u=t.evaluateSizeForZoom(a.textSizeData,l.zoom),p=Tt(e,1,i.transform.zoom),d=B(o.posMatrix,h,c,i.transform,p),m="none"!==r.layout.get("icon-text-fit")&&a.hasIconData();if(u){const t=Math.pow(2,l.zoom-e.tileID.overscaledZ);zi(a,c,h,s,l,d,o.posMatrix,t,u,m,i.style.terrain?(t,e)=>i.style.terrain.getElevation(o,t,e):null)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&Di(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&Di(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,s),i.map.showCollisionBoxes&&(Mi(e,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Mi(e,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const c=e.context,h=c.gl,u=e.depthModeForSublayer(0,Ei.ReadOnly),p=Ai.disabled,d=e.colorModeForRenderPass(),m=[];for(let o=0;o<n.length;o++){const a=n[o],s=i.getTile(a),c=s.getBucket(r);if(!c)continue;const h=c.programConfigurations.get(r.id),u=e.useProgram("circle",h),p=c.layoutVertexBuffer,d=c.indexBuffer,f=e.style.terrain&&e.style.terrain.getTerrainData(a),g={programConfiguration:h,program:u,layoutVertexBuffer:p,indexBuffer:d,uniformValues:_e(e,a,s,r),terrainData:f};if(l){const e=c.segments.get();for(const i of e)m.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:g})}else m.push({segments:c.segments,sortKey:0,state:g})}l&&m.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of m){const{programConfiguration:i,program:n,layoutVertexBuffer:o,indexBuffer:a,uniformValues:s,terrainData:l}=t.state;n.draw(c,h.TRIANGLES,u,p,d,Ii.disabled,s,l,r.id,o,a,t.segments,r.paint,e.transform.zoom,i)}},heatmap:function(e,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,a=o.gl,s=Ai.disabled,l=new wi([a.ONE,a.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer);else{const o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const n=t.gl;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width/4,e.height/4,0,n.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,o,n)}}(o,e,r),o.clear({color:t.Color.transparent});for(let t=0;t<n.length;t++){const c=n[t];if(i.hasRenderableParent(c))continue;const h=i.getTile(c),u=h.getBucket(r);if(!u)continue;const p=u.programConfigurations.get(r.id),d=e.useProgram("heatmap",p),{zoom:m}=e.transform;d.draw(o,a.TRIANGLES,Ei.disabled,s,l,Ii.disabled,be(c.posMatrix,h,m,r.paint.get("heatmap-intensity")),null,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}o.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,i){const r=e.context,n=r.gl,o=i.heatmapFbo;if(!o)return;r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1);let a=i.colorRampTexture;a||(a=i.colorRampTexture=new l(r,i.colorRamp,n.RGBA)),a.bind(n.LINEAR,n.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,n.TRIANGLES,Ei.disabled,Ai.disabled,e.colorModeForRenderPass(),Ii.disabled,((e,i,r,n)=>{const o=t.create();t.ortho(o,0,e.width,e.height,0,0,1);const a=e.context.gl;return{u_matrix:o,u_world:[a.drawingBufferWidth,a.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(e,i),null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=e.depthModeForSublayer(0,Ei.ReadOnly),c=e.colorModeForRenderPass(),h=r.paint.get("line-dasharray"),u=r.paint.get("line-pattern"),p=u.constantOr(1),d=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),f=p?"linePattern":h?"lineSDF":d?"lineGradient":"line",g=e.context,_=g.gl;let y=!0;for(const o of n){const n=i.getTile(o);if(p&&!n.patternsLoaded())continue;const a=n.getBucket(r);if(!a)continue;const x=a.programConfigurations.get(r.id),v=e.context.program.get(),b=e.useProgram(f,x),w=y||b.program!==v,T=e.style.terrain&&e.style.terrain.getTerrainData(o),E=u.constantOr(null);if(E&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const S=T?o:null,A=p?Se(e,n,r,m,S):h?Ae(e,n,r,h,m,S):d?Ee(e,n,r,a.lineClipsArray.length,S):Te(e,n,r,S);if(p)g.activeTexture.set(_.TEXTURE0),n.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),x.updatePaintBuffers(m);else if(h&&(w||e.lineAtlas.dirty))g.activeTexture.set(_.TEXTURE0),e.lineAtlas.bind(g);else if(d){const n=a.gradients[r.id];let s=n.texture;if(r.gradientVersion!==n.version){let c=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-o.canonical.z):1;c=t.clamp(t.nextPowerOfTwo(a.maxLineLength/t.EXTENT*1024*n),256,g.maxTextureSize)}n.gradient=t.renderColorRamp({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:c,image:n.gradient||void 0,clips:a.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new l(g,n.gradient,_.RGBA),n.version=r.gradientVersion,s=n.texture}g.activeTexture.set(_.TEXTURE0),s.bind(r.stepInterpolant?_.NEAREST:_.LINEAR,_.CLAMP_TO_EDGE)}b.draw(g,_.TRIANGLES,s,e.stencilModeForClipping(o),c,Ii.disabled,A,T,r.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,r.paint,e.transform.zoom,x,a.layoutVertexBuffer2),y=!1}},fill:function(e,i,r,n){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const t=e.depthModeForSublayer(1,"opaque"===e.renderPass?Ei.ReadWrite:Ei.ReadOnly);Ri(e,i,r,n,t,s,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const t=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Ei.ReadOnly);Ri(e,i,r,n,t,s,!0)}},"fill-extrusion":function(t,e,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===t.renderPass){const o=new Ei(t.context.gl.LEQUAL,Ei.ReadWrite,t.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))Fi(t,e,i,r,o,Ai.disabled,wi.disabled),Fi(t,e,i,r,o,t.stencilModeFor3D(),t.colorModeForRenderPass());else{const n=t.colorModeForRenderPass();Fi(t,e,i,r,o,Ai.disabled,n)}}},hillshade:function(t,e,i,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const n=t.context,o=t.depthModeForSublayer(0,Ei.ReadOnly),a=t.colorModeForRenderPass(),[s,l]="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r];for(const r of l){const n=e.getTile(r);void 0!==n.needsHillshadePrepare&&n.needsHillshadePrepare&&"offscreen"===t.renderPass?Ui(t,n,i,o,Ai.disabled,a):"translucent"===t.renderPass&&Oi(t,r,n,i,o,s[r.overscaledZ],a)}n.viewport.set([0,0,t.width,t.height])},raster:function(t,e,i,r){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const n=t.context,o=n.gl,a=e.getSource(),s=t.useProgram("raster"),l=t.colorModeForRenderPass(),[c,h]=a instanceof C?[{},r]:t.stencilConfigForOverlap(r),u=h[h.length-1].overscaledZ,p=!t.options.moving;for(const r of h){const h=t.depthModeForSublayer(r.overscaledZ-u,1===i.paint.get("raster-opacity")?Ei.ReadWrite:Ei.ReadOnly,o.LESS),d=e.getTile(r);d.registerFadeDuration(i.paint.get("raster-fade-duration"));const m=e.findLoadedParent(r,0),f=Vi(d,m,e,i,t.transform,t.style.terrain);let g,_;const y="nearest"===i.paint.get("raster-resampling")?o.NEAREST:o.LINEAR;n.activeTexture.set(o.TEXTURE0),d.texture.bind(y,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),n.activeTexture.set(o.TEXTURE1),m?(m.texture.bind(y,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),g=Math.pow(2,m.tileID.overscaledZ-d.tileID.overscaledZ),_=[d.tileID.canonical.x*g%1,d.tileID.canonical.y*g%1]):d.texture.bind(y,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);const x=t.style.terrain&&t.style.terrain.getTerrainData(r),v=x?r:null,b=v?v.posMatrix:t.transform.calculatePosMatrix(r.toUnwrapped(),p),w=Me(b,_||[0,0],g||1,f,i);a instanceof C?s.draw(n,o.TRIANGLES,h,Ai.disabled,l,Ii.disabled,w,x,i.id,a.boundsBuffer,t.quadTriangleIndexBuffer,a.boundsSegments):s.draw(n,o.TRIANGLES,h,c[r.overscaledZ],l,Ii.disabled,w,x,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}},background:function(t,e,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const a=t.context,s=a.gl,l=t.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const u=!h&&1===n.a&&1===o&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const p=Ai.disabled,d=t.depthModeForSublayer(0,"opaque"===u?Ei.ReadWrite:Ei.ReadOnly),m=t.colorModeForRenderPass(),f=t.useProgram(h?"backgroundPattern":"background"),g=r||l.coveringTiles({tileSize:c,terrain:t.style.terrain});h&&(a.activeTexture.set(s.TEXTURE0),t.imageManager.bind(t.context));const _=i.getCrossfadeParameters();for(const e of g){const l=r?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=h?Be(l,o,t,h,{tileID:e,tileSize:c},_):De(l,o,n),g=t.style.terrain&&t.style.terrain.getTerrainData(e);f.draw(a,s.TRIANGLES,d,p,m,Ii.disabled,u,g,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}},debug:function(t,e,i){for(let r=0;r<i.length;r++)Hi(t,e,i[r])},custom:function(t,e,i){const r=t.context,n=i.implementation;if("offscreen"===t.renderPass){const e=n.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(n,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(Ai.disabled);const e="3d"===n.renderingMode?new Ei(t.context.gl.LEQUAL,Ei.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Ei.ReadOnly);r.setDepthMode(e),n.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class tr{constructor(e,i){this.context=new Ti(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.create(),renderTime:0},this.setup(),this.numSublayers=ot.maxUnderzooming+ot.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ht,this.gpuTimers={},this.visibleLayers=new Set}resize(e,i,r){if(this.width=e*r/t.exported.dynamicScale,this.height=i*r/t.exported.dynamicScale,this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.PosArray;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,Kt.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const r=new t.PosArray;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,Kt.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const n=new t.RasterBoundsArray;n.emplaceBack(0,0,0,0),n.emplaceBack(t.EXTENT,0,t.EXTENT,0),n.emplaceBack(0,t.EXTENT,0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.rasterBoundsBuffer=e.createVertexBuffer(n,I.members),this.rasterBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const o=new t.PosArray;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Kt.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const a=new t.LineStripIndexArray;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const s=new t.TriangleIndexArray;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new l(e,{width:1,height:1,data:new Uint8Array([0,0,0,0])},e.gl.RGBA);const c=this.context.gl;this.stencilClearMode=new Ai({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.create();t.ortho(r,0,this.width,this.height,0,0,1),t.scale(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,i.TRIANGLES,Ei.disabled,this.stencilClearMode,wi.disabled,Ii.disabled,ve(r),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const i=this.context,r=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(wi.disabled),i.setDepthMode(Ei.disabled);const n=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,o=this.style.terrain&&this.style.terrain.getTerrainData(t);n.draw(i,r.TRIANGLES,Ei.disabled,new Ai({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),wi.disabled,Ii.disabled,ve(t.posMatrix),o,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Ai({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Ai({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let i=0;i<n;i++)t[i+r]=new Ai({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:Ai.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new wi([e.CONSTANT_COLOR,e.ONE],new t.Color(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?wi.unblended:wi.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return Ei.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Ei(i||this.context.gl.LEQUAL,e,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(t.exported.now()),this.imageManager.beginFrame(),this.visibleLayers.clear();const r=this.style._order,n=this.style.sourceCaches,o=this.style.terrain&&new Ji(this);for(const t in n){const e=n[t];e.used&&e.prepare(this.context)}const a={},s={},l={};for(const t in n){const e=n[t];a[t]=e.getVisibleCoordinates(),s[t]=a[t].slice().reverse(),l[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<r.length;t++)if(this.style._layers[r[t]].is3D()){this.opaquePassCutoff=t;break}if(o){this.opaquePassCutoff=0;const e=this.style.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!t.equals(this.terrainFacilitator.matrix,this.transform.projMatrix)||e.length)&&(t.copy(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,i){const r=e.context,n=r.gl,o=wi.unblended,a=new Ei(n.LEQUAL,Ei.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.sourceCache.getRenderableTiles(),c=e.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.Color.transparent,depth:1});for(const t of l){const l=i.getTerrainData(t.tileID),h=e.transform.calculatePosMatrix(t.tileID.toUnwrapped());c.draw(r,n.TRIANGLES,a,Ai.disabled,o,Ii.backCCW,{u_matrix:h},l,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.terrain),function(e,i){const r=e.context,n=r.gl,o=wi.unblended,a=new Ei(n.LEQUAL,Ei.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),h=e.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.Color.transparent,depth:1}),i.coordsIndex=[];for(const t of c){const c=i.getTerrainData(t.tileID);r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l.texture);const u=e.transform.calculatePosMatrix(t.tileID.toUnwrapped());h.draw(r,n.TRIANGLES,a,Ai.disabled,o,Ii.backCCW,{u_matrix:u,u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0},c,"terrain",s.vertexBuffer,s.indexBuffer,s.segments),i.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.terrain))}this.renderPass="offscreen";for(const t of r){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=s[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,n[e.source],e,i)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.Color.black:t.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!o)for(this.renderPass="opaque",this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],e=n[t.source],i=a[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const t=this.style._layers[r[this.currentLayer]],e=n[t.source];if(o&&o.renderLayer(t))continue;const i=("symbol"===t.type?l:s)[t.source];this._renderTileClippingMasks(t,a[t.source]),this.renderLayer(this,e,t,i)}if(this.options.showTileBoundaries){let t,e;Object.values(this.style._layers).forEach((i=>{i.source&&!i.isHidden(this.transform.zoom)&&(i.source!==(e&&e.id)&&(e=this.style.sourceCaches[i.source]),(!t||t.getSource().maxzoom<e.getSource().maxzoom)&&(t=e))})),t&&Qi.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;Zi(t,t.transform.height-(e.top||0),3,Ni),Zi(t,e.bottom||0,3,$i),Xi(t,e.left||0,3,Gi),Xi(t,t.transform.width-(e.right||0),3,ji);const i=t.transform.centerPoint;!function(t,e,i,r){Wi(t,e-1,i-10,2,20,r),Wi(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,qi)}(this),this.context.setDefault()}renderLayer(t,e,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"custom"===i.type||(r||[]).length)&&(this.id=i.id,this.gpuTimingStart(i),Qi[i.type](t,e,i,r,this.style.placement.variableOffsets),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),e[i]=o}return e}translatePosMatrix(e,i,r,n,o){if(!r[0]&&!r[1])return e;const a=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(a){const t=Math.sin(a),e=Math.cos(a);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e]}const s=[o?r[0]:Tt(i,r[0],this.transform.zoom),o?r[1]:Tt(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return t.translate(l,e,s),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new ce(this.context,t,oe[t],e,Re[t],this._showOverdrawInspector,this.style.terrain,this)),this.cache[i]}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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new l(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class er{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(e,i,r){const n=Math.pow(2,r),o=[[-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((r=>{const o=1/(r=t.transformMat4([],r,e))[3]/i*n;return t.mul$1(r,r,[o,o,1/r[3],o])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.sub([],o[e[0]],o[e[1]]),r=t.sub([],o[e[2]],o[e[1]]),n=t.normalize([],t.cross([],i,r)),a=-t.dot(n,o[e[1]]);return n.concat(a)}));return new er(o,a)}}class ir{constructor(e,i){this.min=e,this.max=i,this.center=t.scale$1([],t.add([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],r=t.clone$2(this.min),n=t.clone$2(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new ir(r,n)}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(e){const i=[[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 r=!0;for(let n=0;n<e.planes.length;n++){const o=e.planes[n];let a=0;for(let e=0;e<i.length;e++)t.dot$1(o,i[e])>=0&&a++;if(0===a)return 0;a!==i.length&&(r=!1)}if(r)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[t]-this.min[t])return 0}return 1}}class rr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),n=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new rr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class nr{constructor(e,i,r,n,o){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this.alignRasterLayers=!0,this._renderWorldCopies=void 0===o||!!o,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new rr,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new nr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(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 t.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const i=-t.wrap(e,-180,180)*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],n=e[1],o=e[2],a=e[3],s=Math.sin(i),l=Math.cos(i);t[0]=r*l+o*s,t[1]=n*l+a*s,t[2]=r*-s+o*l,t[3]=n*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,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 e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,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,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const i=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies){const r=this.pointCoordinate(new t.pointGeometry(0,0)),n=this.pointCoordinate(new t.pointGeometry(this.width,0)),o=this.pointCoordinate(new t.pointGeometry(this.width,this.height)),a=this.pointCoordinate(new t.pointGeometry(0,this.height)),s=Math.floor(Math.min(r.x,n.x,o.x,a.x)),l=Math.floor(Math.max(r.x,n.x,o.x,a.x)),c=1;for(let r=s-c;r<=l+c;r++)0!==r&&i.push(new t.UnwrappedTileID(r,e))}return i}coveringTiles(e){var i,r;let n=this.coveringZoomLevel(e);const o=n;if(void 0!==e.minzoom&&n<e.minzoom)return[];void 0!==e.maxzoom&&n>e.maxzoom&&(n=e.maxzoom);const a=this.pointCoordinate(this.getCameraPoint()),s=t.MercatorCoordinate.fromLngLat(this.center),l=Math.pow(2,n),c=[l*a.x,l*a.y,0],h=[l*s.x,l*s.y,0],u=er.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n);let p=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(p=n);const d=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,m=t=>({aabb:new ir([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),f=[],g=[],_=n,y=e.reparseOverscaled?o:n;if(this._renderWorldCopies)for(let t=1;t<=3;t++)f.push(m(-t)),f.push(m(t));for(f.push(m(0));f.length>0;){const n=f.pop(),o=n.x,a=n.y;let s=n.fullyVisible;if(!s){const t=n.aabb.intersects(u);if(0===t)continue;s=2===t}const l=e.terrain?c:h,m=n.aabb.distanceX(l),x=n.aabb.distanceY(l),v=Math.max(Math.abs(m),Math.abs(x)),b=d+(1<<_-n.zoom)-2;if(n.zoom===_||v>b&&n.zoom>=p){const e=_-n.zoom,i=c[0]-.5-(o<<e),r=c[1]-.5-(a<<e);g.push({tileID:new t.OverscaledTileID(n.zoom===_?y:n.zoom,n.wrap,n.zoom,o,a),distanceSq:t.sqrLen([h[0]-.5-o,h[1]-.5-a]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let l=0;l<4;l++){const c=(o<<1)+l%2,h=(a<<1)+(l>>1),u=n.zoom+1;let p=n.aabb.quadrant(l);if(e.terrain){const o=new t.OverscaledTileID(u,n.wrap,u,c,h),a=e.terrain.getMinMaxElevation(o),s=null!==(i=a.minElevation)&&void 0!==i?i:this.elevation,l=null!==(r=a.maxElevation)&&void 0!==r?r:this.elevation;p=new ir([p.min[0],p.min[1],s],[p.max[0],p.max[1],l])}f.push({aabb:p,zoom:u,x:c,y:h,wrap:n.wrap,fullyVisible:s})}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],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(e){const i=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.pointGeometry(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(i)*this.worldSize)}unproject(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(e,i){const r=t.MercatorCoordinate.fromLngLat(e),n=(1<<this.tileZoom)*t.EXTENT,o=r.x*n,a=r.y*n,s=Math.floor(o/t.EXTENT),l=Math.floor(a/t.EXTENT),c=new t.OverscaledTileID(this.tileZoom,0,this.tileZoom,s,l);return i.getElevation(c,o%t.EXTENT,a%t.EXTENT,t.EXTENT)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const i=this.pointLocation(this.centerPoint,e),r=this.getElevation(i,e);if(!(this.elevation-r))return;const n=this.getCameraPosition(),o=t.MercatorCoordinate.fromLngLat(n.lngLat,n.altitude),a=t.MercatorCoordinate.fromLngLat(i,r),s=o.x-a.x,l=o.y-a.y,c=o.z-a.z,h=Math.sqrt(s*s+l*l+c*c),u=this.scaleZoom(this.cameraToCenterDistance/h/this.tileSize);this._elevation=r,this._center=i,this.zoom=u}setLocationAtPoint(e,i){const r=this.pointCoordinate(i),n=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),a=new t.MercatorCoordinate(o.x-(r.x-n.x),o.y-(r.y-n.y));this.center=this.coordinateLocation(a),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),this.getElevation(t,e),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(e){return t.MercatorCoordinate.fromLngLat(e)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(e,i){if(i){const t=i.pointCoordinate(e);if(null!=t)return t}const r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];t.transformMat4(r,r,this.pixelMatrixInverse),t.transformMat4(n,n,this.pixelMatrixInverse);const o=r[3],a=n[3],s=r[1]/o,l=n[1]/a,c=r[2]/o,h=n[2]/a,u=c===h?0:(0-c)/(h-c);return new t.MercatorCoordinate(t.number(r[0]/o,n[0]/a,u)/this.worldSize,t.number(s,l,u)/this.worldSize)}coordinatePoint(e,i=0,r=this.pixelMatrix){const n=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.transformMat4(n,n,r),new t.pointGeometry(n[0]/n[3],n[1]/n[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return(new t.LngLatBounds).extend(this.pointLocation(new t.pointGeometry(0,e))).extend(this.pointLocation(new t.pointGeometry(this.width,e))).extend(this.pointLocation(new t.pointGeometry(this.width,this.height))).extend(this.pointLocation(new t.pointGeometry(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new t.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(e,i=!1){const r=e.key,n=i?this._alignedPosMatrixCache:this._posMatrixCache;if(n[r])return n[r];const o=e.canonical,a=this.worldSize/this.zoomScale(o.z),s=o.x+Math.pow(2,o.z)*e.wrap,l=t.identity(new Float64Array(16));return t.translate(l,l,[s*a,o.y*a,0]),t.scale(l,l,[a/t.EXTENT,a/t.EXTENT,1]),t.multiply(l,i?this.alignedProjMatrix:this.projMatrix,l),n[r]=new Float32Array(l),n[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e,i,r,n,o=-90,a=90,s=-180,l=180;const c=this.size,h=this._unmodified;if(this.latRange){const i=this.latRange;o=t.mercatorYfromLat(i[1])*this.worldSize,a=t.mercatorYfromLat(i[0])*this.worldSize,e=a-o<c.y?c.y/(a-o):0}if(this.lngRange){const e=this.lngRange;s=t.wrap(t.mercatorXfromLng(e[0])*this.worldSize,0,this.worldSize),l=t.wrap(t.mercatorXfromLng(e[1])*this.worldSize,0,this.worldSize),l<s&&(l+=this.worldSize),i=l-s<c.x?c.x/(l-s):0}const u=this.point,p=Math.max(i||0,e||0);if(p)return this.center=this.unproject(new t.pointGeometry(i?(l+s)/2:u.x,e?(a+o)/2:u.y)),this.zoom+=this.scaleZoom(p),this._unmodified=h,void(this._constraining=!1);if(this.latRange){const t=u.y,e=c.y/2;t-e<o&&(n=o+e),t+e>a&&(n=a-e)}if(this.lngRange){const e=(s+l)/2,i=t.wrap(u.x,e-this.worldSize/2,e+this.worldSize/2),n=c.x/2;i-n<s&&(r=s+n),i+n>l&&(r=l-n)}void 0===r&&void 0===n||(this.center=this.unproject(new t.pointGeometry(void 0!==r?r:u.x,void 0!==n?n:u.y)).wrap()),this._unmodified=h,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,i=this.point.x,r=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height*2**t.exported.detailLevel,this._pixelPerMeter=t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let n=t.identity(new Float64Array(16));t.scale(n,n,[this.width/2,-this.height/2,1]),t.translate(n,n,[1,-1,0]),this.labelPlaneMatrix=n,n=t.identity(new Float64Array(16)),t.scale(n,n,[1,-1,1]),t.translate(n,n,[-1,-1,0]),t.scale(n,n,[2/this.width,2/this.height,1]),this.glCoordMatrix=n,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const o=Math.PI/2+this._pitch,a=this._fov*(.5+e.y/this.height),s=Math.sin(a)*this.cameraToSeaLevelDistance/Math.sin(t.clamp(Math.PI-o-a,.01,Math.PI-.01)),l=this.getHorizon(),c=2*Math.atan(l/this.cameraToCenterDistance)*(.5+e.y/(2*l)),h=Math.sin(c)*this.cameraToSeaLevelDistance/Math.sin(t.clamp(Math.PI-o-c,.01,Math.PI-.01)),u=Math.cos(Math.PI/2-this._pitch)*s+this.cameraToSeaLevelDistance,p=Math.cos(Math.PI/2-this._pitch)*h+this.cameraToSeaLevelDistance,d=1.01*Math.min(u,p),m=this.height/50;if(n=new Float64Array(16),t.perspective(n,this._fov,this.width/this.height,m,d),n[8]=2*-e.x/this.width,n[9]=2*e.y/this.height,t.scale(n,n,[1,-1,1]),t.translate(n,n,[0,0,-this.cameraToCenterDistance]),t.rotateX(n,n,this._pitch),t.rotateZ(n,n,this.angle),t.translate(n,n,[-i,-r,0]),this.mercatorMatrix=t.scale([],n,[this.worldSize,this.worldSize,this.worldSize]),t.scale(n,n,[1,1,this._pixelPerMeter]),this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,n),t.translate(n,n,[0,0,-this.elevation]),this.projMatrix=n,this.invProjMatrix=t.invert([],n),this.pixelMatrix3D=t.multiply(new Float64Array(16),this.labelPlaneMatrix,n),this.alignRasterLayers){const e=this.width%2/2,o=this.height%2/2,a=Math.cos(this.angle),s=Math.sin(this.angle),l=i-Math.round(i)+a*e+s*o,c=r-Math.round(r)+a*o+s*e,h=new Float64Array(n);t.translate(h,h,[l>.5?l-1:l,c>.5?c-1:c,0]),this.alignedProjMatrix=h}else this.alignedProjMatrix=n;if(n=t.invert(new Float64Array(16),this.pixelMatrix),!n)throw new Error("failed to invert matrix");this.pixelMatrixInverse=n,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new t.pointGeometry(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}getCameraQueryGeometry(e){const i=this.getCameraPoint();if(1===e.length)return[e[0],i];{let r=i.x,n=i.y,o=i.x,a=i.y;for(const t of e)r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);return[new t.pointGeometry(r,n),new t.pointGeometry(o,n),new t.pointGeometry(o,a),new t.pointGeometry(r,a),new t.pointGeometry(r,n)]}}}class or{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,300),i=!1)};return()=>(i=!0,r||n(),r)}(this._updateHashUnthrottled.bind(this))}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),o=Math.round(e.lng*n)/n,a=Math.round(e.lat*n)/n,s=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${o}/${a}/${i}`:`${i}/${a}/${o}`,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_getCurrentHash(){const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}}}const ar={linearity:.3,easing:t.bezier(0,0,.3,1)},sr=t.extend({deceleration:2500,maxSpeed:1400},ar),lr=t.extend({deceleration:20,maxSpeed:1400},ar),cr=t.extend({deceleration:1e3,maxSpeed:360},ar),hr=t.extend({deceleration:1e3,maxSpeed:90},ar);class ur{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=dr(i.pan.mag(),r,t.extend({},sr,e||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,pr(n,o)}if(i.zoom){const t=dr(i.zoom,r,lr);n.zoom=this._map.transform.zoom+t.amount,pr(n,t)}if(i.bearing){const e=dr(i.bearing,r,cr);n.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),pr(n,e)}if(i.pitch){const t=dr(i.pitch,r,hr);n.pitch=this._map.transform.pitch+t.amount,pr(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),t.extend(n,{noMoveStart:!0})}}function pr(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function dr(e,i,r){const{maxSpeed:n,linearity:o,deceleration:a}=r,s=t.clamp(e*o/(i/1e3),-n,n),l=Math.abs(s)/(a*o);return{easing:r.easing,duration:1e3*l,amount:s*(l/2)}}class mr extends t.Event{constructor(e,i,r,n={}){const a=o.mousePos(i.getCanvasContainer(),r),s=i.unproject(a);super(e,t.extend({point:a,lngLat:s,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class fr extends t.Event{constructor(e,i,r){const n="touchend"===e?r.changedTouches:r.touches,a=o.touchPos(i.getCanvasContainer(),n),s=a.map((t=>i.unproject(t))),l=a.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class gr extends t.Event{constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class _r{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new gr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new mr(t.type,this._map,t))}mouseup(t){this._map.fire(new mr(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new mr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new mr(t.type,this._map,t))}mouseover(t){this._map.fire(new mr(t.type,this._map,t))}mouseout(t){this._map.fire(new mr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new fr(t.type,this._map,t))}touchmove(t){this._map.fire(new fr(t.type,this._map,t))}touchend(t){this._map.fire(new fr(t.type,this._map,t))}touchcancel(t){this._map.fire(new fr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class yr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new mr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new mr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new mr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class xr{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(o.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=o.create("div","maplibregl-boxzoom mapboxgl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair","mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),a=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y);o.setTransform(this._box,`translate(${n}px,${s}px)`),this._box.style.width=a-n+"px",this._box.style.height=l-s+"px"}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,n=i;if(this.reset(),o.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair","mapboxgl-crosshair"),this._box&&(o.remove(this._box),this._box=null),o.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function vr(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class br{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=vr(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=vr(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class wr{constructor(t){this.singleTap=new br(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Tr{constructor(){this._zoomIn=new wr({numTouches:1,numTaps:2}),this._zoomOut=new wr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{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}}const Er={0:1,2:2};class Sr{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=o.mouseButton(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),function(t,e){const i=Er[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&o.mouseButton(t)===this._eventButton&&(this._moved&&o.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ar extends Sr{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class Ir extends Sr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class Cr extends Sr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class Mr{constructor(t,e){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.pointGeometry(0,0),setTimeout((()=>{this._cancelCooperativeMessage=!1}),200)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._map._cooperativeGestures&&(2===this._minTouches&&i.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,i.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(i.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const n=vr(r,i),o=new t.pointGeometry(0,0),a=new t.pointGeometry(0,0);let s=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(o._add(e),a._add(e.sub(i)),s++,n[t]=e)}if(this._touches=n,s<this._minTouches||!a.mag())return;const l=a.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(s),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class kr{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,n]=this._firstTwoTouches,o=Pr(i,e,r),a=Pr(i,e,n);if(!o||!a)return;const s=this._aroundCenter?null:o.add(a).div(2);return this._move([o,a],s,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,a=Pr(i,e,r),s=Pr(i,e,n);a&&s||(this._active&&o.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Pr(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function zr(t,e){return Math.log(t/e)/Math.LN2}class Lr extends kr{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(zr(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:zr(this._distance,i),pinchAround:e}}}function Dr(t,e){return 180*t.angleWith(e)/Math.PI}class Br extends kr{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,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Dr(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Dr(t,this._startVector);return Math.abs(i)<e}}function Rr(t){return Math.abs(t.y)>Math.abs(t.x)}class Fr extends kr{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Rr(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return Rr(t)&&Rr(e)&&o}}const Or={panStep:100,bearingStep:15,pitchStep:10};class Ur{constructor(){const t=Or;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Vr,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Vr(t){return t*(2-t)}const Nr=4.000244140625;class $r{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;e.preventDefault()}let i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%Nr==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(e){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 i=o.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(i)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Nr?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:e.zoom,r=this._startZoom,n=this._easing;let o,a=!1;if("wheel"===this._type&&r&&n){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),s=n(e);o=t.number(r,i,s),e<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,a=Math.sqrt(.0729-o*o);i=t.bezier(o,a,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}reset(){this._active=!1}}class Gr{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 jr{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qr{constructor(){this._tap=new wr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zr{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Xr{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}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 Wr{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,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","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-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 Hr=t=>t.zoom||t.drag||t.pitch||t.rotate;class Kr extends t.Event{}function Yr(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Jr{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ur(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)o.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)o.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new _r(e,t));const r=e.boxZoom=new xr(e,t);this._add("boxZoom",r);const n=new Tr,o=new jr;e.doubleClickZoom=new Gr(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const a=new qr;this._add("tapDragZoom",a);const s=e.touchPitch=new Fr(e);this._add("touchPitch",s);const l=new Ir(t),c=new Cr(t);e.dragRotate=new Xr(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Ar(t),u=new Mr(t,e);e.dragPan=new Zr(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new Br,d=new Lr;e.touchZoomRotate=new Wr(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]);const m=e.scrollZoom=new $r(e,this);this._add("scrollZoom",m,["mousePan"]);const f=e.keyboard=new Ur;this._add("keyboard",f),this._add("blockableMapEvent",new yr(e));for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.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 Boolean(Hr(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},n={},a={},s=t.touches,l=s?this._getMapTouches(s):void 0,c=l?o.touchPos(this._el,l):o.mousePos(this._el,t);for(const{handlerName:o,handler:s,allowed:h}of this._handlers){if(!s.isEnabled())continue;let u;this._blockedByActive(a,h,o)?s.reset():s[e||t.type]&&(u=s[e||t.type](t,c,l),this.mergeHandlerResult(r,n,u,o,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||s.isActive())&&(a[o]=s)}const h={};for(const t in this._previousActiveHandlers)a[t]||(h[t]=i);this._previousActiveHandlers=a,(Object.keys(h).length||Yr(r))&&(this._changes.push([r,n,h]),this._triggerRenderFrame()),(Object.keys(a).length||Yr(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,n,o){if(!r)return;t.extend(e,r);const a={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=a),void 0!==r.panDelta&&(i.drag=a),void 0!==r.pitchDelta&&(i.pitch=a),void 0!==r.bearingDelta&&(i.rotate=a)}_applyChanges(){const e={},i={},r={};for(const[n,o,a]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.extend(i,o),t.extend(r,a);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const n=this._map,o=n.transform,a=n.style&&n.style.terrain;if(!(Yr(e)||a&&this._drag))return this._fireEvents(i,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,pinchAround:p}=e;void 0!==p&&(u=p),n._stop(!0),u=u||n.transform.centerPoint;const d=o.pointLocation(s?u.sub(s):u);c&&(o.bearing+=c),h&&(o.pitch+=h),l&&(o.zoom+=l),a?i.drag&&!this._drag?(this._drag={center:o.centerPoint,lngLat:o.pointLocation(u),point:u,handlerName:i.drag.handlerName},n.fire(new t.Event("freezeElevation",{freeze:!0}))):this._drag&&r[this._drag.handlerName]?(n.fire(new t.Event("freezeElevation",{freeze:!1})),this._drag=null):i.drag&&this._drag&&(o.center=o.pointLocation(o.centerPoint.sub(s))):o.setLocationAtPoint(d,u),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const n=Hr(this._eventsInProgress),o=Hr(e),a={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(a[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in a)this._fireEvent(t,a[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const s={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,s[`${t}end`]=l)}for(const t in s)this._fireEvent(t,s[t]);const c=Hr(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;e?(i(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:l})):(this._map.fire(new t.Event("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new t.Event(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Kr("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Qr={extend:(e,...i)=>t.extend(e,...i),run(t){t()},logToElement(t,e=!1,i="log"){const r=window.document.getElementById(i);r&&(e&&(r.innerHTML=""),r.innerHTML+=`<br>${t}`)}};class tn extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(e,i){e=t.LngLatBounds.convert(e);const r=i&&i.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,i)}_cameraForBoxAndBearing(e,i,r,n){const o={top:0,bottom:0,right:0,left:0};if("number"==typeof(n=t.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},n)).padding){const t=n.padding;n.padding={top:t,bottom:t,right:t,left:t}}n.padding=t.extend(o,n.padding);const a=this.transform,s=a.padding,l=a.project(t.LngLat.convert(e)),c=a.project(t.LngLat.convert(i)),h=l.rotate(-r*Math.PI/180),u=c.rotate(-r*Math.PI/180),p=new t.pointGeometry(Math.max(h.x,u.x),Math.max(h.y,u.y)),d=new t.pointGeometry(Math.min(h.x,u.x),Math.min(h.y,u.y)),m=p.sub(d),f=(a.width-(s.left+s.right+n.padding.left+n.padding.right))/m.x,g=(a.height-(s.top+s.bottom+n.padding.top+n.padding.bottom))/m.y;if(g<0||f<0)return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const _=Math.min(a.scaleZoom(a.scale*Math.min(f,g)),n.maxZoom),y=t.pointGeometry.convert(n.offset),x=new t.pointGeometry((n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2).rotate(r*Math.PI/180),v=y.add(x).mult(a.scale/a.zoomScale(_));return{center:a.unproject(l.add(c).div(2).sub(v)),zoom:_,bearing:r}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(e,i,r,n,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(t.pointGeometry.convert(e)),this.transform.pointLocation(t.pointGeometry.convert(i)),r,n),n,o)}_fitInternal(e,i,r){return e?(delete(i=t.extend(e,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(e,i){this.stop();const r=this.transform;let n=!1,o=!1,a=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(n=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=t.LngLat.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(o=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(a=!0,r.pitch=+e.pitch),null==e.padding||r.isPaddingEqual(e.padding)||(r.padding=e.padding),this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),n&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),o&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),a&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i))}calculateCameraOptionsFromTo(e,i,r,n=0){const o=t.MercatorCoordinate.fromLngLat(e,i),a=t.MercatorCoordinate.fromLngLat(r,n),s=a.x-o.x,l=a.y-o.y,c=a.z-o.z,h=Math.hypot(s,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(s,l),p=this.transform.scaleZoom(this.transform.cameraToCenterDistance/h/this.transform.tileSize),d=180*Math.atan2(s,-l)/Math.PI;let m=180*Math.acos(u/h)/Math.PI;return m=c<0?90-m:90+m,{center:a.toLngLat(),zoom:p,pitch:m,bearing:d}}easeTo(e,i){this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||!e.essential&&t.exported.prefersReducedMotion)&&(e.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?+e.zoom:n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="padding"in e?e.padding:r.padding,p=t.pointGeometry.convert(e.offset);let d=r.centerPoint.add(p);const m=r.pointLocation(d),f=t.LngLat.convert(e.center||m);this._normalizeCenter(f);const g=r.project(m),_=r.project(f).sub(g),y=r.zoomScale(l-n);let x,v;e.around&&(x=t.LngLat.convert(e.around),v=r.locationPoint(x));const b={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||l!==n,this._rotating=this._rotating||o!==c,this._pitching=this._pitching||h!==a,this._padding=!r.isPaddingEqual(u),this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,b),this._ease((e=>{if(this._zooming&&(r.zoom=t.number(n,l,e)),this._rotating&&(r.bearing=t.number(o,c,e)),this._pitching&&(r.pitch=t.number(a,h,e)),this._padding&&(r.interpolatePadding(s,u,e),d=r.centerPoint.add(p)),x)r.setLocationAtPoint(x,v);else{const t=r.zoomScale(r.zoom-n),i=l>n?Math.min(2,y):Math.max(.5,y),o=Math.pow(i,1-e),a=r.unproject(g.add(_.mult(e*o)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?a.wrap():a,d)}this._fireMoveEvents(i)}),(t=>{this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.fire(new t.Event("freezeElevation",{freeze:!0})),i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId,this.fire(new t.Event("freezeElevation",{freeze:!1}));const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="padding"in e?e.padding:r.padding,p=r.zoomScale(l-n),d=t.pointGeometry.convert(e.offset);let m=r.centerPoint.add(d);const f=r.pointLocation(m),g=t.LngLat.convert(e.center||f);this._normalizeCenter(g);const _=r.project(f),y=r.project(g).sub(_);let x=e.curve;const v=Math.max(r.width,r.height),b=v/p,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function E(t){const e=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function A(t){return(Math.exp(t)+Math.exp(-t))/2}const I=E(0);let C=function(t){return A(I)/A(I+x*t)},M=function(t){return v*((A(I)*(S(e=I+x*t)/A(e))-S(I))/T)/w;var e},k=(E(1)-I)/x;if(Math.abs(w)<1e-6||!isFinite(k)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,i);const t=b<v?-1:1;k=Math.abs(Math.log(b/v))/x,M=function(){return 0},C=function(e){return Math.exp(t*x*e)}}return e.duration="duration"in e?+e.duration:1e3*k/("screenSpeed"in e?+e.screenSpeed/x:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._padding=!r.isPaddingEqual(u),this._prepareEase(i,!1),this._ease((e=>{const p=e*k,f=1/C(p);r.zoom=1===e?l:n+r.scaleZoom(f),this._rotating&&(r.bearing=t.number(o,c,e)),this._pitching&&(r.pitch=t.number(a,h,e)),this._padding&&(r.interpolatePadding(s,u,e),m=r.centerPoint.add(d));const x=1===e?g:r.unproject(_.add(y.mult(M(p))).mult(f));r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,m),this._fireMoveEvents(i)}),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)<r&&(e-=360),Math.abs(e+360-i)<r&&(e+=360),e}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}}class en{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=o.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o.create("div","maplibregl-ctrl-attrib-inner mapboxgl-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(){o.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,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_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","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const i in e){const r=e[i];if(r.used||r.usedForTerrain){const e=r.getSource();if("string"==typeof e.attribution){const i=e.attribution.split("|").map((t=>t.trim()));for(let e of i)e=e.replace(/©/g,"©"),e=e.replace(/©/g,"©"),e=e.replace("©","©"),t.indexOf(e)<0&&t.push(e)}}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}));const i=t.findIndex((t=>t.includes("mapcreator")));if(-1!==i&&0!==i){const e=t[i];t.splice(i,1),t.unshift(e)}const r=t.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,t.length?(this._innerContainer.innerHTML=r,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._map.fire("attributionchange"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?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","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class rn{constructor(e={}){this.options=e,t.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=o.create("div","maplibregl-ctrl mapboxgl-ctrl");const e=o.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){o.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class nn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const on={"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"},an={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},sn={showCompass:!0,showZoom:!0,visualizePitch:!1};class ln{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Ir({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new Cr({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener(i,"mousedown",this.mousedown),o.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),o.addEventListener(i,"touchmove",this.touchmove),o.addEventListener(i,"touchend",this.touchend),o.addEventListener(i,"touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),o.disableDrag()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;o.removeEventListener(t,"mousedown",this.mousedown),o.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),o.removeEventListener(t,"touchmove",this.touchmove),o.removeEventListener(t,"touchend",this.touchend),o.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){o.enableDrag(),o.removeEventListener(window,"mousemove",this.mousemove),o.removeEventListener(window,"mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),o.mousePos(this.element,e)),o.addEventListener(window,"mousemove",this.mousemove),o.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.move(t,o.mousePos(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function cn(e,i,r){if(e=new t.LngLat(e.lng,e.lat),i){const n=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),a=r.locationPoint(e).distSqr(i);r.locationPoint(n).distSqr(i)<a?e=n:r.locationPoint(o).distSqr(i)<a&&(e=o)}for(;Math.abs(e.lng-r.center.lng)>180;){const t=r.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}const hn={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 un(t,e,i){const r=t.classList;for(const t in hn)r.remove(`maplibregl-${i}-anchor-${t}`,`mapboxgl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`,`mapboxgl-${i}-anchor-${e}`)}class pn extends t.Evented{constructor(e,i){if(super(),(e instanceof HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,e&&e.element)this._element=e.element,this._offset=t.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=o.create("div"),this._element.setAttribute("aria-label","Map marker");const i=o.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${n}px`),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const a=o.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=o.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=o.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{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 t of c){const e=o.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const h=o.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=o.createNS("http://www.w3.org/2000/svg","path");u.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"),h.appendChild(u);const p=o.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"opacity","0.25"),p.setAttributeNS(null,"fill","#000000");const d=o.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"),p.appendChild(d);const m=o.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(6.0, 7.0)"),m.setAttributeNS(null,"fill","#FFFFFF");const f=o.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=o.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=o.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),f.appendChild(g),f.appendChild(_),s.appendChild(l),s.appendChild(h),s.appendChild(p),s.appendChild(m),s.appendChild(f),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=t.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),un(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),o.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),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 e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=cn(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let e="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?e=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(e=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),o.setTransform(this._element,`${hn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${e}`),this._map.style&&this._map.style.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const t=this._map.unproject(this._pos),e=40075016.686*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=t.distanceTo(this._lngLat)>20*e?"0.2":"1.0",this._opacityTimeout=null}),100))}getOffset(){return this._offset}setOffset(e){return this._offset=t.pointGeometry.convert(e),this._update(),this}_onMove(e){if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const dn={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let mn,fn=0,gn=!1;const _n={maxWidth:100,unit:"metric"};function yn(t,e,i){const r=i&&i.maxWidth||100,n=t._container.clientHeight/2,o=t.unproject([0,n]),a=t.unproject([r,n]),s=o.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*s;i>5280?xn(e,r,i/5280,t._getUIString("ScaleControl.Miles")):xn(e,r,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?xn(e,r,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?xn(e,r,s/1e3,t._getUIString("ScaleControl.Kilometers")):xn(e,r,s,t._getUIString("ScaleControl.Meters"))}function xn(t,e,i,r){const n=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(n/i)+"px",t.innerHTML=`${n} ${r}`}const vn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},bn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function wn(e){if(e){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));return{center:new t.pointGeometry(0,0),top:new t.pointGeometry(0,e),"top-left":new t.pointGeometry(i,i),"top-right":new t.pointGeometry(-i,i),bottom:new t.pointGeometry(0,-e),"bottom-left":new t.pointGeometry(i,-i),"bottom-right":new t.pointGeometry(-i,-i),left:new t.pointGeometry(e,0),right:new t.pointGeometry(-e,0)}}if(e instanceof t.pointGeometry||Array.isArray(e)){const i=t.pointGeometry.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.pointGeometry.convert(e.center||[0,0]),top:t.pointGeometry.convert(e.top||[0,0]),"top-left":t.pointGeometry.convert(e["top-left"]||[0,0]),"top-right":t.pointGeometry.convert(e["top-right"]||[0,0]),bottom:t.pointGeometry.convert(e.bottom||[0,0]),"bottom-left":t.pointGeometry.convert(e["bottom-left"]||[0,0]),"bottom-right":t.pointGeometry.convert(e["bottom-right"]||[0,0]),left:t.pointGeometry.convert(e.left||[0,0]),right:t.pointGeometry.convert(e.right||[0,0])}}return wn(new t.pointGeometry(0,0))}const Tn={supported:e,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends tn{constructor(e){var i;if(t.PerformanceUtils.mark(t.PerformanceMarkers.create),null!=(e=t.extend({},an,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new nr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._interactive=e.interactive,this._cooperativeGestures=e.cooperativeGestures,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new nn,this._controls=[],this._mapId=t.uniqueId(),this._locale=t.extend({},on,e.locale),this._clickTolerance=e.clickTolerance,this._pixelRatio=null!==(i=e.pixelRatio)&&void 0!==i?i:devicePixelRatio,this._requestManager=new a(e.transformRequest),"string"==typeof e.container){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");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)})),"undefined"!=typeof window&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new Jr(this,e),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=e.hash&&new or("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new en({customAttribution:e.customAttribution})),e.maplibreLogo&&this.addControl(new rn,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new t.Event("sourcedataabort",e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.style.terrain&&(r=this.transform.getElevation(i,this.style.terrain)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(e){const i=this._containerDimensions(),r=i[0],n=i[1];this._resizeCanvas(r,n,this.getPixelRatio()),this.transform.resize(r/t.exported.dynamicScale,n/t.exported.dynamicScale),this.painter.resize(r,n,this.getPixelRatio());const o=!this._moving;return o&&(this.stop(),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e))),this.fire(new t.Event("resize",e)),o&&this.fire(new t.Event("moveend",e)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(t){const[e,i]=this._containerDimensions();this._pixelRatio=t,this._resizeCanvas(e,i,t),this.painter.resize(e,i,t)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(e){return this.transform.locationPoint(t.LngLat.convert(e),this.style&&this.style.terrain)}unproject(e){return this.transform.pointLocation(t.pointGeometry.convert(e),this.style&&this.style.terrain)}isMoving(){return this._moving||this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers.isRotating()}setScale(e){t.exported.dynamicScale=e,this.setPixelRatio(window.devicePixelRatio*e),this.resize()}getScale(){return t.exported.dynamicScale}setDetailLevel(e){const i=this.getDetailLevel();t.exported.detailLevel=Math.round(t.clamp(e,-3,3)),this.setZoom(this.getZoom()+t.exported.detailLevel-i)}getDetailLevel(){return t.exported.detailLevel}getVisibleLayers(){return this.painter.visibleLayers}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const o=this.getLayer(e)?this.queryRenderedFeatures(n.point,{layers:[e]}):[];o.length?r||(r=!0,i.call(this,new mr(t,this,n.originalEvent,{features:o}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{(this.getLayer(e)?this.queryRenderedFeatures(n.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new mr(t,this,n.originalEvent)))},o=e=>{r&&(r=!1,i.call(this,new mr(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const n=this._delegatedListeners[t];for(let t=0;t<n.length;t++){const r=n[t];if(r.layer===e&&r.listener===i){for(const t in r.delegates)this.off(t,r.delegates[t]);return n.splice(t,1),this}}})(),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let r;if(void 0!==i||void 0===e||e instanceof t.pointGeometry||Array.isArray(e)||(i=e,e=void 0),i=i||{},(e=e||[[0,0],[this.transform.width,this.transform.height]])instanceof t.pointGeometry||"number"==typeof e[0])r=[t.pointGeometry.convert(e)];else{const i=t.pointGeometry.convert(e[0]),n=t.pointGeometry.convert(e[1]);r=[i,new t.pointGeometry(n.x,i.y),n,new t.pointGeometry(i.x,n.y),i]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(e,i){return!1!==(i=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove()),t?(this.style=new re(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new re(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,t.ResourceType.Style);t.getJSON(r,((e,r)=>{e?this.fire(new t.ErrorEvent(e)):r&&this._updateDiff(r,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return!!this.style&&this.style.loaded()}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`)))}setTerrain(t){return this.style.setTerrain(t),this}getTerrain(){return this.style.terrain&&this.style.terrain.options}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||t.isImageBitmap(i)){const{width:l,height:c,data:h}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},h),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0})}else{if(void 0===i.width||void 0===i.height)return this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:l,height:c,data:h}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(h)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||t.isImageBitmap(i)?t.exported.getImageData(i):i,{width:o,height:a,data:s}=n;if(void 0===o||void 0===a)return this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||a!==r.data.height)return this.fire(new t.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const l=!(i instanceof HTMLImageElement||t.isImageBitmap(i));r.data.replace(s,l),this.style.updateImage(e,r)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),i)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}getLineBreaks(e,i,r,n,o,a){const s=this.style.glyphManager,l={},c=new Set;for(let t=0;t<e.length;t++)c.add(e.charCodeAt(t));l[i]=Array.from(c);let h={};s.getGlyphs(l,((t,e)=>{t||(h=e)}));const u=t.calculateBreakLines(e,i,r,n,o,a,h,{}),p=[];return u.forEach((t=>{p.push(t.text)})),p}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map","mapboxgl-map");const e=this._canvasContainer=o.create("div","maplibregl-canvas-container mapboxgl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=o.create("canvas","maplibregl-canvas mapboxgl-canvas",e),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 i=this._containerDimensions();this._resizeCanvas(i[0],i[1],this.getPixelRatio());const r=this._controlContainer=o.create("div","maplibregl-control-container mapboxgl-control-container",t),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{n[t]=o.create("div",`maplibregl-ctrl-${t} mapboxgl-ctrl-${t}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const t=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=o.create("div","maplibregl-cooperative-gesture-screen",t);let e="Control",i="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";0===navigator.platform.indexOf("Mac")&&(i="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map",e="Meta"),this._cooperativeGesturesScreen.innerHTML=`\n <div class="maplibregl-desktop-message">${i}</div>\n <div class="maplibregl-mobile-message">${"boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}</div>\n `,document.addEventListener("keydown",(t=>{t.key===e&&(this._metaPress=!0)})),document.addEventListener("keyup",(t=>{t.key===e&&(this._metaPress=!1)})),this._canvasContainer.addEventListener("wheel",(t=>{this._onCooperativeGesture(t,this._metaPress,1)}),!1),this._canvasContainer.classList.remove("mapboxgl-touch-drag-pan","maplibregl-touch-drag-pan")}_resizeCanvas(e,i,r){this._canvas.width=r*e/t.exported.dynamicScale,this._canvas.height=r*i/t.exported.dynamicScale,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${i}px`}_setupPainter(){const i=t.extend({},e.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",i)||this._canvas.getContext("experimental-webgl",i);r?(this.painter=new tr(r,this.transform),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(t,e,i){return!e&&i<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(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(e){let i,r=0;const n=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(i=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,i),r=t.exported.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let o=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=t.exported.now();this.style.zoomHistory.update(e,i);const r=new t.EvaluationParameters(e,{now:i,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(o=!0,this._crossFadingFactor=n),this.style.update(r)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.style.terrain&&this.style.terrain.sourceCache.update(this.transform,this.style.terrain),this.transform.updateElevation(this.style.terrain),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.PerformanceUtils.mark(t.PerformanceMarkers.load),this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const e=t.exported.now()-r;n.endQueryEXT(n.TIME_ELAPSED_EXT,i),setTimeout((()=>{const r=n.getQueryObjectEXT(i,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.Event("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,t.PerformanceUtils.mark(t.PerformanceMarkers.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),o.remove(this._canvasContainer),o.remove(this._controlContainer),this._cooperativeGestures&&o.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map","mapboxgl-map"),t.PerformanceUtils.clearMetrics(),this._removed=!0,this.fire(new t.Event("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=t.exported.frame((e=>{t.PerformanceUtils.frame(e),this._frame=null,this._render(e)})))}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return"2.4.0-mc.6"}},NavigationControl:class{constructor(e){this.options=t.extend({},sn,e),this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=o.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_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}onAdd(t){return this._map=t,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 ln(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){o.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(t,e){const i=o.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({},dn,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(t){var e;return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),e=this._setupUI,void 0!==mn?e(mn):void 0!==window.navigator.permissions?window.navigator.permissions.query({name:"geolocation"}).then((t=>{mn="denied"!==t.state,e(mn)})):(mn=!!window.navigator.geolocation,e(mn)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),o.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,fn=0,gn=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,n=this._map.getBearing(),o=t.extend({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([1,t]),r=e.distanceTo(i),n=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&gn)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),o.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new pn(this._dotElement),this._circleElement=o.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new pn({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",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}trigger(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":fn--,gn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),fn++,fn>1?(t={maximumAge:6e5,timeout:0},gn=!0):(t=this.options.positionOptions,gn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:en,LogoControl:rn,ScaleControl:class{constructor(e){this.options=t.extend({},_n,e),t.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){yn(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){o.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,yn(this._map,this._container,this.options)}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"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(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=o.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){o.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);o.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?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._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},TerrainControl:class{constructor(e){this.options=e,t.bindAll(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._terrainButton=o.create("button","maplibregl-ctrl-terrain mapboxgl-ctrl-terrain",this._container),o.create("span","maplibregl-ctrl-icon mapboxgl-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(){o.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._map.style.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(vn),e),t.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(e){return this._map&&this.remove(),this._map=e,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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&o.remove(this._content),this._container&&(o.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 t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=o.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=o.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(t){this._update(t.point)}_onMouseMove(t){this._update(t.point)}_onDrag(t){this._update(t.point)}_update(t){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(this._container||(this._container=o.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=o.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((t=>this._container.classList.add(t))),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=cn(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let i=this.options.anchor;const r=wn(this.options.offset);if(!i){const t=this._container.offsetWidth,n=this._container.offsetHeight;let o;o=e.y+r.bottom.y<n?["top"]:e.y>this._map.transform.height-n?["bottom"]:[],e.x<t/2?o.push("left"):e.x>this._map.transform.width-t/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}const n=e.mult(this._map.getScale()).add(r[i]);o.setTransform(this._container,`${hn[i]} translate(${n.x}px,${n.y}px)`),un(this._container,i,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(bn);t&&t.focus()}_onClose(){this.remove()}},Marker:pn,Style:re,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.pointGeometry,MercatorCoordinate:t.MercatorCoordinate,Evented:t.Evented,AJAXError:t.AJAXError,config:t.config,CanvasSource:k,GeoJSONSource:A,ImageSource:C,RasterDEMTileSource:S,RasterTileSource:T,VectorTileSource:w,VideoSource:M,prewarm:function(){pt().acquire(lt)},clearPrewarmedResources:function(){const t=ut;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lt),ut=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get version(){return"2.4.0-mc.6"},get workerCount(){return ct.workerCount},set workerCount(t){ct.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",addProtocol(e,i){t.config.REGISTERED_PROTOCOLS[e]=i},removeProtocol(e){delete t.config.REGISTERED_PROTOCOLS[e]}};return Qr.extend(Tn,{isSafari:t.isSafari,getPerformanceMetrics:t.PerformanceUtils.getPerformanceMetrics}),Tn})),i}()},582:function(t,e){var i,r,n;r=[],void 0===(n="function"==typeof(i=function(){function t(t,e){for(var i in t)t.hasOwnProperty(i)&&e(i,t[i])}function e(){var i={},r="en",n=/{{\s*(\w+)\s*}}/g,o={en:{pluralizeTo:"count",getVariationIndex:function(t){return 1===t?0:1}}};function a(t,e,n){var o=(n=n||{}).locale||r,c=n.registry||i,h=c[o]&&c[o][t];return void 0===h?a.whenUndefined(t,o):Array.isArray(h)?s(t,h,e,o,n.pluralizeTo):l(h,e)}function s(t,e,i,r,n){var a=o[r],s=Object.keys(i),c=1===s.length?s[0]:n||a.pluralizeTo,h=parseFloat(i[c]);if(isNaN(h))throw new Error('Tranlation pluralization missing parameters on key "'+t+'"');return l(e[a.getVariationIndex(h)],i)}function l(t,e){return e?t.replace(n,(function(t,i){return e.hasOwnProperty(i)?e[i]:t})):t}return a.add=function(e,n,o){return i[n=n||r]=i[n]||{},t(e,(function(t,e){var r=o?o+"."+t:t,s=typeof e;Array.isArray(e)||"string"===s||"number"===s?i[n][r]=e:a.add(e,n,r)})),this},a.setLocale=function(t){return r=t,this},a.getLocale=function(){return r},a.interpolateWith=function(t){return n=t,this},a.setPluralizationRule=function(t,e,i){return o[t]={pluralizeTo:i&&i.pluralizeTo||"count",getVariationIndex:e},this},a.whenUndefined=function(t,e){return t},a.clear=function(){return i={},this},a.createRegistry=function(){return e()},a}return e()})?i.apply(e,r):i)||(t.exports=n)},821:function(t,e,i){var r={"./da_DK/frElections2022.json":488,"./da_DK/fullscreen.json":680,"./da_DK/usElectionsFixedPopup.json":420,"./da_DK/usElectionsUpdater.json":587,"./de_DE/frElections2022.json":154,"./de_DE/fullscreen.json":422,"./de_DE/usElectionsFixedPopup.json":918,"./de_DE/usElectionsUpdater.json":596,"./en_GB/frElections2022.json":234,"./en_GB/fullscreen.json":230,"./en_GB/geoLocation.json":766,"./en_GB/search.json":52,"./en_GB/usElectionsFixedPopup.json":791,"./en_GB/usElectionsUpdater.json":352,"./es_ES/frElections2022.json":358,"./es_ES/fullscreen.json":74,"./es_ES/usElectionsFixedPopup.json":851,"./es_ES/usElectionsUpdater.json":529,"./fr_FR/frElections2022.json":568,"./fr_FR/fullscreen.json":458,"./fr_FR/usElectionsFixedPopup.json":8,"./fr_FR/usElectionsUpdater.json":105,"./it_IT/frElections2022.json":181,"./it_IT/fullscreen.json":51,"./it_IT/usElectionsFixedPopup.json":367,"./it_IT/usElectionsUpdater.json":983,"./nl_NL/frElections2022.json":745,"./nl_NL/fullscreen.json":279,"./nl_NL/usElectionsFixedPopup.json":733,"./nl_NL/usElectionsUpdater.json":661};function n(t){var e=o(t);return i(e)}function o(t){if(!i.o(r,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r[t]}n.keys=function(){return Object.keys(r)},n.resolve=o,t.exports=n,n.id=821},488:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},680:function(t){t.exports=JSON.parse('{"goBack":"Gå tilbage","notice":"Brug to fingre til at navigere i kortet"}')},420:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Stemmer","reporting":"{percentage}% optalt","ev":"VM","electoralVotes":"Valgmænd","unknown":"Ukendt"}')},587:function(t){t.exports=JSON.parse('{"loadingSettings":"Henter indstillinger","errorLoadingSettings":"Fejl i indstillinger","loadCandidates":"Henter data om kandidat","errorLoadingCandidates":"Fejl i kandidatens data","loadingResults":"Henter resultat","errorLoadingResults":"Fejl i resultater","updatedOn":"Opdateret {date} kl. {time}","checkingForData":"Opdaterer resultat om: {time}"}')},154:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},422:function(t){t.exports=JSON.parse('{"goBack":"Zurück","notice":"Verwenden Sie zwei Finger um die Karte zu bewegen"}')},918:function(t){t.exports=JSON.parse('{"party":"Partei","votes":"Stimmen","reporting":"Wahlbeteiligung {percentage}%","ev":"WL","electoralVotes":"Wahlleute","unknown":"Unbekannt"}')},596:function(t){t.exports=JSON.parse('{"loadingSettings":"Einstellungen werden geladen","errorLoadingSettings":"Fehler beim Laden der Einstellungen","loadCandidates":"Kandidat-Daten werden geladen","errorLoadingCandidates":"Fehler beim Laden der Kandidat-Daten","loadingResults":"Ergebnisse werden geladen","errorLoadingResults":"Fehler beim Laden der Ergebnisse","updatedOn":"Aktualisiert am {date} um {time}","checkingForData":"Neue Daten werden abgerufen in: {time}"}')},234:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for { interpolate }","allResults":"All results","candidateList":"Candidate list"}')},230:function(t){t.exports=JSON.parse('{"goBack":"Go back","notice":"Use two fingers to move the map"}')},766:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},52:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},791:function(t){t.exports=JSON.parse('{"party":"Party","votes":"Votes","reporting":"{ interpolate }% Reporting","ev":"E.V.","electoralVotes":"Electoral Votes","unknown":"Unknown","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},352:function(t){t.exports=JSON.parse('{"loadingSettings":"Loading settings","errorLoadingSettings":"Error loading settings","loadCandidates":"Loading candidate data","errorLoadingCandidates":"Error loading candidates","loadingResults":"Loading results","errorLoadingResults":"Error loading results","updatedOn":"Updated on { interpolate.date } at { interpolate.time }","checkingForData":"Checking for new data in: { interpolate }"}')},358:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},74:function(t){t.exports=JSON.parse('{"goBack":"Vuelve atrás","notice":"Usa dos dedos para mover el mapa"}')},851:function(t){t.exports=JSON.parse('{"party":"Partido","votes":"Votos","reporting":"{percentage}% Informando","ev":"V.E.","electoralVotes":"Votos Electorales","unknown":"Desconocido"}')},529:function(t){t.exports=JSON.parse('{"loadingSettings":"Cargando configuración","errorLoadingSettings":"Error al cargar la configuración","loadCandidates":"Cargando los datos del candidato","errorLoadingCandidates":"Error al cargar los datos de los candidatos","loadingResults":"Cargando los resultados","errorLoadingResults":"Error al cargar los resultados","updatedOn":"Actualizado el {date} a las {time}","checkingForData":"Comprobando nuevos datos en {time}"}')},568:function(t){t.exports=JSON.parse('{"showMore":"Voir plus","showLess":"Voir moins","tapFor":"Résutats de {alternative}","allResults":"Tous les résultats","candidateList":"Liste des candidats"}')},458:function(t){t.exports=JSON.parse('{"goBack":"Retour en arrière","notice":"Utilisez deux doigts pour déplacer la carte"}')},8:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Votes","reporting":"{percentage}% des votes dépouillés","ev":"C.E.","electoralVotes":"Collège électoral","unknown":"Inconnu"}')},105:function(t){t.exports=JSON.parse('{"loadingSettings":"Chargement des paramètres","errorLoadingSettings":"Erreur lors du chargement des paramètres","loadCandidates":"Chargement des données du candidat","errorLoadingCandidates":"Erreur de chargement des candidats","loadingResults":"Chargement des résultats","errorLoadingResults":"Erreur de chargement des résultats","updatedOn":"{date} à {time} ","checkingForData":"mise à jour dans : {time}"}')},181:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},51:function(t){t.exports=JSON.parse('{"goBack":"Indietro","notice":"Usa due dita per muovere la mappa"}')},367:function(t){t.exports=JSON.parse('{"party":"Partito","votes":"Voti","reporting":"{percentage}% Copertura","ev":"V.E.","electoralVotes":"Voti Elettorali","unknown":"Sconosciuto"}')},983:function(t){t.exports=JSON.parse('{"loadingSettings":"Caricamento impostazioni","errorLoadingSettings":"Errore caricamento impostazioni","loadCandidates":"Caricamento dati candidato","errorLoadingCandidates":"Errore caricamento dati candidato","loadingResults":"Caricamento risultati","errorLoadingResults":"Errore caricamento risultati","updatedOn":"Aggiornato il {date} alle {time}","checkingForData":"Controllo nuovi dati in: {time}"}')},745:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},279:function(t){t.exports=JSON.parse('{"goBack":"Ga terug","notice":"Gebruik twee vingers om de kaart te bewegen"}')},733:function(t){t.exports=JSON.parse('{"party":"Partij","votes":"Stemmen","reporting":"{percentage}% Gerapporteerd","ev":"K.M.","electoralVotes":"Kiesmannen","unknown":"Onbekend"}')},661:function(t){t.exports=JSON.parse('{"loadingSettings":"Instellingen aan het laden","errorLoadingSettings":"Fout bij het laden van de instellingen","loadCandidates":"Kandidaat data aan het laden","errorLoadingCandidates":"Fout bij het laden van kandidaat data","loadingResults":"Resultaten aan het laden","errorLoadingResults":"Fout bij het laden van de resultaten","updatedOn":"Geüpdatet op {date} om {time}","checkingForData":"Controleren op nieuwe data over: {time}"}')}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,i),o.exports}i.d=function(t,e){for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var r={};!function(){function t(t,e=void 0){return e||(e=window.location.href),new URL(e).searchParams.get(t)}i.d(r,{S:function(){return Ct}});const e=2166136261;function n(t){let i=t.split("").map((t=>t.charCodeAt(0))).reduce(((t,e)=>(t^=e)+(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)),e);return i^=i<<3,i+=i>>5,i^=i<<4,i+=i>>17,i^=i<<25,i+=i>>6,`0000000${(i>>>0).toString(16)}`.substr(-8)}let o;function a(){return void 0!==o&&("bleeding"===o||"development"===o)}function s(){return void 0!==o&&"beta"===o}class l{mapOptions;options;_favicon;constructor(t,e){this.mapOptions={...this.constructor.defaultMapOptions,...e},this.options={...this.constructor.defaultOptions,...t},this.options.libraryMode||(this.updateTitle(),this.updateFavicon())}static get defaultMapOptions(){return{container:document.getElementsByClassName("map")[0],attributionControl:!1}}static get defaultOptions(){return{noBounds:"true"===t("noBounds"),language:navigator.language||navigator.userLanguage}}updateTitle(){const t=document.querySelector("title");t.innerText=`${this.title} – ${t.innerText}`}updateFavicon(){this._favicon=document.createElement("link"),this._favicon.setAttribute("href",this.favicon),this._favicon.setAttribute("rel","shortcut icon"),this._favicon.parentElement!==document.head&&document.head.appendChild(this._favicon)}get favicon(){throw new Error("Unimplemented")}get title(){return"Unimplemented"}}var c=i(527);const h=Object.freeze({THREE:"ISO 639-2/B",API:"ISO 639-2/B",TWO:"ISO 639-1",MAPLIBRE_COMPAT:"ISO 639-1",ENDONYM:"name",NAME:"name",LOCALE:"locale",i18n:"locale"});var u=h;const p=Object.freeze([{[h.TWO]:"en",[h.THREE]:"eng",[h.ENDONYM]:"English",[h.LOCALE]:"en_GB"},{[h.TWO]:"da",[h.THREE]:"dan",[h.ENDONYM]:"Dansk",[h.LOCALE]:"da_DK"},{[h.TWO]:"nl",[h.THREE]:"dut",[h.ENDONYM]:"Nederlands",[h.LOCALE]:"nl_NL"},{[h.TWO]:"fi",[h.THREE]:"fin",[h.ENDONYM]:"Suomi",[h.LOCALE]:"fi_FI"},{[h.TWO]:"fr",[h.THREE]:"fre",[h.ENDONYM]:"Francais",[h.LOCALE]:"fr_FR"},{[h.TWO]:"de",[h.THREE]:"ger",[h.ENDONYM]:"Deutsch",[h.LOCALE]:"de_DE"},{[h.TWO]:"it",[h.THREE]:"ita",[h.ENDONYM]:"Italiano",[h.LOCALE]:"it_IT"},{[h.TWO]:"no",[h.THREE]:"nor",[h.ENDONYM]:"Norsk",[h.LOCALE]:"nn_NO"},{[h.TWO]:"pl",[h.THREE]:"pol",[h.ENDONYM]:"Polski",[h.LOCALE]:"pl_PL"},{[h.TWO]:"pt",[h.THREE]:"por",[h.ENDONYM]:"Portugues",[h.LOCALE]:"pt_PT"},{[h.TWO]:"es",[h.THREE]:"spa",[h.ENDONYM]:"Espanol",[h.LOCALE]:"es_ES"},{[h.TWO]:"sv",[h.THREE]:"swe",[h.ENDONYM]:"Svenska",[h.LOCALE]:"sv_SE"},{[h.TWO]:"ja",[h.THREE]:"jpn",[h.ENDONYM]:"日本語",[h.LOCALE]:"ja_JP"},{[h.TWO]:"zh",[h.THREE]:"chi",[h.ENDONYM]:"汉语",[h.LOCALE]:"zh_CN"},{[h.TWO]:"ru",[h.THREE]:"rus",[h.ENDONYM]:"Русский",[h.LOCALE]:"ru_RU"},{[h.TWO]:"uk",[h.THREE]:"ukr",[h.ENDONYM]:"Украї́нська",[h.LOCALE]:"uk_UK"},{[h.TWO]:"lv",[h.THREE]:"lav",[h.ENDONYM]:"Latviešu valoda",[h.LOCALE]:"lv-LV"},{[h.TWO]:"kk",[h.THREE]:"kaz",[h.ENDONYM]:"қазақша",[h.LOCALE]:"kk-KZ"},{[h.TWO]:"ar",[h.THREE]:"ara",[h.ENDONYM]:"Arabic",[h.LOCALE]:"ar_SA"},{[h.TWO]:"native",[h.THREE]:"native",[h.ENDONYM]:"Native",[h.LOCALE]:"native"}]);function d(t,e=h.MAPLIBRE_COMPAT){return(p.find((e=>Object.values(e).some((e=>e===t))))||p[0])[e]}var m={get id(){return t("id")},get accessToken(){return t("access-token")||document.querySelector("meta[name=mc-access-token]")?.getAttribute("content")},get debug(){return"true"===t("debug")},get productionJob(){return"true"===t("debug")||!a},vectorApiUrl:"https://vapi.mc-cdn.io/",get objectUrl(){return this.id?this.accessToken?this.productionJob?s()?`https://cdn.beta.mapcreator.io/jobs/${this.id}.json`:`https://cdn.mapcreator.io/jobs/${this.id}.json`:`https://cdn.bleeding.mapcreator.io/jobs/${this.id}.json`:`https://dynamic.maps4news.com/${this.id}/map.json`:location.href.replace(/(\/|\/[^/]+\.[^/.]+)?$/,"/map.json")}},f=i(582);var g=new class{fallbackLocale;constructor(t,e=void 0){f.interpolateWith(/{\s*(\w+)\s*}/g);for(const[t,e]of Object.entries(this._loadLocaleMessages()))f.add(e,t);this.locale=t,this.fallbackLocale=e??t}get locale(){return f.getLocale()}set locale(t){f.setLocale(t)}get localeMaplibreCompat(){return this.locale.substr(0,2)}get localeWithPreferredRegion(){return navigator.languages.find((t=>t.startsWith(`${this.localeMaplibreCompat}-`)))?.replace("-","_")??this.locale}t(t,e={interpolate:void 0},i=this.locale){const r=f(t,e,{locale:i});return t===r?i===this.fallbackLocale?t:f(t,e,{locale:this.fallbackLocale}):r}_loadLocaleMessages(){const t=i(821),e={};for(const i of t.keys()){const r=i.match(/\/([a-z_/]+)\/([a-z0-9-_]+)\./i);if(!r?.length)continue;const n=r[1].split("/");let o=e;for(const t of n)o.hasOwnProperty(t)||(o[t]={}),o=o[t];o[r[2]]=t(i)}return e}}("en_GB");function _(t){return t/180*Math.PI}function y(t){return 180*t/Math.PI}function x(t,e){const i=Math.PI/180,r=t.lat*i,n=e.lat*i,o=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-t.lng)*i);return 6371e3*Math.acos(Math.min(o,1))}function v(t,e=null){return t=t.replace("maps4news.com","mapcreator.io"),a()?t=(t=t.replace(/vapi\.(mc-cdn|mapcreator)/,"vapi.bleeding.$1")).replace("://cdn.mapcreator.io/live-data-layers/live/","://cdn.mapcreator.io/live-data-layers/bleeding/"):s()&&(t=t.replace(/vapi\.(mc-cdn|mapcreator)/,"vapi.beta.$1")),e&&/vapi\..*(mc-cdn|mapcreator)\.io/.test(t)&&(t=`${t}?access_token=${e}`),t}function b(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}function w(t,e,i){if(t===e)return i;const r={millimeter:1,centimeter:.1,meter:.001,kilometer:1e-6,foot:.00328084,mile:6.21371e-7,nauticalMile:5.39957e-7,inch:.0393701,pixel:2.8346472,pica:.236222};return i/r[t]*r[e]}const T={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function E(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:b((e=t).id),properties:{id:e.id,"line-width":e.lineWidth??3,"line-color":e.lineColor??"#000000","line-style":e.lineStyle??"solid"},geometry:{type:"LineString",coordinates:e.geometry}};var e}))}});for(const r in T)e.models.some((t=>(t.lineStyle??"solid")===r))&&t.addLayer({id:`${e.id}-${r}`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},filter:["==",["get","line-style"],r],paint:{"line-width":["get","line-width"],"line-color":["get","line-color"],"line-dasharray":T[r]}},i);t.addLayer({id:`${e.id}-clickable`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},paint:{"line-width":["max",["get","line-width"],15],"line-opacity":0}},i)}var S=6371008.8;Math.PI;function A(t,e,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=e||{},r.geometry=t,r}function I(t,e,i={}){for(const e of t){if(e.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(e[e.length-1].length!==e[0].length)throw new Error("First and last Position are not equivalent.");for(let t=0;t<e[e.length-1].length;t++)if(e[e.length-1][t]!==e[0][t])throw new Error("First and last Position are not equivalent.")}return A({type:"Polygon",coordinates:t},e,i)}function C(t,e,i={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return A({type:"LineString",coordinates:t},e,i)}function M(t,e={}){const i={type:"FeatureCollection"};return e.id&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.features=t,i}function k(t,e,i={}){return A({type:"MultiLineString",coordinates:t},e,i)}function P(t,e,i={}){return A({type:"MultiPolygon",coordinates:t},e,i)}function z(t,e,i){if(null!==t)for(var r,n,o,a,s,l,c,h,u=0,p=0,d=t.type,m="FeatureCollection"===d,f="Feature"===d,g=m?t.features.length:1,_=0;_<g;_++){s=(h=!!(c=m?t.features[_].geometry:f?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<s;y++){var x=0,v=0;if(null!==(a=h?c.geometries[y]:c)){l=a.coordinates;var b=a.type;switch(u=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,p,_,x,v))return!1;p++,x++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],p,_,x,v))return!1;p++,"MultiPoint"===b&&x++}"LineString"===b&&x++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-u;n++){if(!1===e(l[r][n],p,_,x,v))return!1;p++}"MultiLineString"===b&&x++,"Polygon"===b&&v++}"Polygon"===b&&x++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(v=0,n=0;n<l[r].length;n++){for(o=0;o<l[r][n].length-u;o++){if(!1===e(l[r][n][o],p,_,x,v))return!1;p++}v++}x++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===z(a.geometries[r],e,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function L(t,e){var i,r,n,o,a,s,l,c,h,u,p=0,d="FeatureCollection"===t.type,m="Feature"===t.type,f=d?t.features.length:1;for(i=0;i<f;i++){for(s=d?t.features[i].geometry:m?t.geometry:t,c=d?t.features[i].properties:m?t.properties:{},h=d?t.features[i].bbox:m?t.bbox:void 0,u=d?t.features[i].id:m?t.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,n=0;n<a;n++)if(null!==(o=l?s.geometries[n]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,p,c,h,u))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],p,c,h,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,c,h,u))return!1;p++}}function D(t,e){(e=e||{}).iterations=e.iterations||1;const{iterations:i}=e,r=[];if(!t)throw new Error("inputPolys is required");return L(t,(function(t,e,n){if("Polygon"===t.type){let e=[[]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=I(e).geometry),B(n,i),e=i.slice(0)}r.push(I(e,n))}else{if("MultiPolygon"!==t.type)throw new Error("geometry is invalid, must be Polygon or MultiPolygon");{let e=[[[]]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=P(e).geometry),R(n,i),e=i.slice(0)}r.push(P(e,n))}}})),M(r)}function B(t,e){var i,r;z(t,(function(t,n,o,a,s){if(r!==s)e.push([]);else{var l=i[0],c=i[1],h=t[0],u=t[1];e[s].push([.75*l+.25*h,.75*c+.25*u]),e[s].push([.25*l+.75*h,.25*c+.75*u])}i=t,r=s}),!1),e.forEach((function(t){t.push(t[0])}))}function R(t,e){let i,r,n;z(t,(function(t,o,a,s,l){if(r!==s)e.push([[]]);else if(n!==l)e[s].push([]);else{var c=i[0],h=i[1],u=t[0],p=t[1];e[s][l].push([.75*c+.25*u,.75*h+.25*p]),e[s][l].push([.25*c+.75*u,.25*h+.75*p])}i=t,r=s,n=l}),!1),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function F(t,e){var i,r,n,o,a,s,l;for(r=1;r<=8;r*=2){for(i=[],o=!(U(n=t[t.length-1],e)&r),a=0;a<t.length;a++)(l=!(U(s=t[a],e)&r))!==o&&i.push(O(n,s,r,e)),l&&i.push(s),n=s,o=l;if(!(t=i).length)break}return i}function O(t,e,i,r){return 8&i?[t[0]+(e[0]-t[0])*(r[3]-t[1])/(e[1]-t[1]),r[3]]:4&i?[t[0]+(e[0]-t[0])*(r[1]-t[1])/(e[1]-t[1]),r[1]]:2&i?[r[2],t[1]+(e[1]-t[1])*(r[2]-t[0])/(e[0]-t[0])]:1&i?[r[0],t[1]+(e[1]-t[1])*(r[0]-t[0])/(e[0]-t[0])]:null}function U(t,e){var i=0;return t[0]<e[0]?i|=1:t[0]>e[2]&&(i|=2),t[1]<e[1]?i|=4:t[1]>e[3]&&(i|=8),i}function V(t,e){const i=[];for(const r of t){const t=F(r,e);t.length>0&&(t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]||t.push(t[0]),t.length>=4&&i.push(t))}return i}var N=function(t,e){const i="Feature"===(r=t).type?r.geometry:r;var r;const n=i.type,o="Feature"===t.type?t.properties:{};let a=i.coordinates;switch(n){case"LineString":case"MultiLineString":{const t=[];return"LineString"===n&&(a=[a]),a.forEach((i=>{!function(t,e,i){var r,n,o,a=t.length,s=U(t[0],e),l=[];let c,h;for(i||(i=[]),r=1;r<a;r++){for(c=t[r-1],h=t[r],n=o=U(h,e);;){if(!(s|n)){l.push(c),n!==o?(l.push(h),r<a-1&&(i.push(l),l=[])):r===a-1&&l.push(h);break}if(s&n)break;s?(c=O(c,h,s,e),s=U(c,e)):(h=O(c,h,n,e),n=U(h,e))}s=o}l.length&&i.push(l)}(i,e,t)})),1===t.length?C(t[0],o):k(t,o)}case"Polygon":return I(V(a,e),o);case"MultiPolygon":return P(a.map((t=>V(t,e))),o);default:throw new Error("geometry "+n+" not supported")}};function $(t,e){const i=[],r=2*Math.PI/100;for(let n=0;n<100;n++)i.push(j(t,e,n*r));if(function(t,e){return x(t,{lng:0,lat:90})/1e3<e}(t,e)){const t=i[0],e=i[i.length-1],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.push([r,n]),i.push([r,90]),i.push([r+360,90]),i.push([r+360,n])}if(function(t,e){return x(t,{lng:0,lat:-90})/1e3<e}(t,e)){const t=i[49],e=i[50],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.splice(50,0,[r+360,n],[r+360,-90],[r,-90],[r,n])}return i.push(i[0]),i}function G(t,e,i){const r=[],n=e/100;for(let e=0;e<=100;e++)r.push(j(t,e*n,_(i)));const o=[-1/0,-85.051129,1/0,85.051129];return N(C(r),o).geometry.coordinates}function j(t,e,i){const r=e/6378.1,n=_(t.lng),o=_(t.lat),a=Math.asin(Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(i));return[y(n+Math.atan2(Math.sin(i)*Math.sin(r)*Math.cos(o),Math.cos(r)-Math.sin(o)*Math.sin(a))),y(a)]}function q(t){const{polygonType:e}=t,i="number"==typeof t.anchorPoints?.[0]?.[0]?[t.anchorPoints]:t.anchorPoints;return"smooth"===e?D(I(i),{iterations:4}).features?.[0]?.geometry?.coordinates??i.slice():i.slice()}function Z(t,e){return`${t}-${n(`${e.vectorUrl}/${e.sourceLayerId}`)}`}function X(t){return`custom-area-${n(t.vectorUrl)}`}function W(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i){const r=void 0!==t.fillPattern?i.getMaplibreImageKey(e[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:b(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":r,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":t.radiusLineColor??"#000000","radius-line-width":t.radiusLineWidth??0},geometry:{type:"GeometryCollection",geometries:[{type:"Polygon",coordinates:[$(t.center,t.radius)]},{type:"LineString",coordinates:G(t.center,t.radius,t.radiusLineBearing??0)}]}}}(t,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"circle","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-radius-line`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["all",["==",["geometry-type"],"LineString"],["get","radius-line-enabled"]],paint:{"line-color":["get","radius-line-color"],"line-width":["get","radius-line-width"]}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}function H(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i,r){const n=void 0!==t.fillPattern?r.getMaplibreImageKey(i[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:b(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":n},geometry:{type:"Polygon",coordinates:q(t)}}}(t,e.id,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"polygon","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}let K;const Y="Roboto-Regular";function J(t,e,i){const r=void 0!==t.svg?i.getMaplibreImageKey(e[t.svg],K*(t.iconScale??1)):void 0;return{type:"Feature",id:b(t.id),properties:{id:t.id,"mc-image-key":r,"icon-anchor":t.iconAnchor??"center","icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":t.iconScale??1,text:t.text,"text-anchor":t.textAnchor??"center","text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":t.textSize??16,"text-color":t.textColor??"#000000","text-halo-color":t.textHaloColor??"#000000","text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??"center"},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}}}function Q(){return navigator.userAgent.toLowerCase().indexOf("mobile")>=0}function tt(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[2]),t[3]=Math.max(t[3],e[3])}function et(t){const e=Array.from(t.querySelectorAll("[mol_embed]"));0===e.length&&e.push(t);const i=document.body.contains(t);i||document.body.appendChild(t);const r=t.getBoundingClientRect(),n=e.map((t=>{const{x:e,y:i,width:r,height:n}=t.getBoundingClientRect();return[e,i,e+r,i+n]}));i||document.body.removeChild(t);const o=function(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)tt(e,i);return e}(n);var a,s,l;return a=o,s=-r.x,l=-r.y,a[0]+=s,a[1]+=l,a[2]+=s,a[3]+=l,function(t){t[0]=Math.round(t[0]),t[1]=Math.round(t[1]),t[2]=Math.round(t[2]),t[3]=Math.round(t[3])}(o),o}async function it(t,e,i){if(void 0!==window.InstallTrigger||t.length<2e6)try{return await function(t,e,i){const r=new Image;return r.width=e,r.height=i,new Promise(((e,i)=>{r.onload=()=>e(r),r.onerror=()=>i(new Error("Failed to quickly generate image from svg")),r.src=`data:image/svg+xml;base64,${btoa(t)}`}))}(t,e,i)}catch(t){}return async function(t,e,i){const r=new Image;r.width=e,r.height=i;const n=URL.createObjectURL(t);try{await new Promise(((t,e)=>{r.onload=()=>t(),r.onerror=()=>e(new Error("Failed to safely generate image from svg")),r.src=n}))}finally{URL.revokeObjectURL(n)}return r}(new Blob([t],{type:"image/svg+xml"}),e,i)}class rt{map;domParser;keyCache;infoCache;constructor(t){this.map=t,this.domParser=new DOMParser,this.keyCache=new Map,this.infoCache=new Map}getSvgInfo(t){if(!this.infoCache.has(t)){const e=this.domParser.parseFromString(t,"image/svg+xml").firstElementChild,i=e.width.baseVal.value,r=e.height.baseVal.value,n=et(e),o=function(t,e,i){const r={},n={};if([,r.x=e/2,r.y=i/2]=(/mol_svganchor="\s*(-?[\d.]+)\s+(-?[\d.]+)\s*"/i.exec(t)||[]).map(Number.parseFloat),[,n.x=0,n.y=0,n.width=e,n.height=i]=(/view-?box="\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*"/i.exec(t)||[]).map(Number.parseFloat),!n.width||!n.height)return[0,0];const o=e/n.width,a=i/n.height;return[Math.round(-o*(r.x-n.x)+e/2),Math.round(-a*(r.y-n.y)+i/2)]}(t,i,r);this.infoCache.set(t,{ownOffset:o,bbox:n,svgElement:e,size:[i,r]})}return this.infoCache.get(t)}getMaplibreImageKey(t,e){const i=`${t}_${e}`;if(!this.keyCache.has(i)){const{size:r}=this.getSvgInfo(t),o=Math.max(r[0]*e,1),a=Math.max(r[1]*e,1),s=`mc-image-${n(i)}`;it(t,o,a).then((t=>{this.map.addImage(s,t,{pixelRatio:e})})).catch((t=>console.log(t))),this.keyCache.set(i,s)}return this.keyCache.get(i)}}const nt=/>\$(.+?)</gi,ot=/<span\s+class="mention"\s+data-mention-id="[^"]*">(.*?)<\/span>/gim,at=/(\S+?)\s*=\s*"\$([^"]+?)"/g,st=/youtube.com\/embed\/\$(.*)\?/gi;function lt(t){return null==t?"":"object"==typeof t?t.w??"":String(t)}const ct=["area","circle","dot","line","marker","polygon"];class ht{data;constructor(t){this.data={area:{},circle:{},dot:{},line:{},marker:{},polygon:{}};for(const e of ct)for(const i of t.registry.models[e]??[]){this.data[e][i.id]={};for(const t of i.models)this.data[e][i.id][t.id]=t}}getModel(t){const e=String(t.properties?.id),i=t.layer.metadata?.["mc-group-id"],r=t.layer.metadata?.["mc-model-type"];if(void 0!==i&&void 0!==e&&void 0!==r)return this.data[r]?.[i]?.[e]}}class ut{map;interactivityType="click";popupPosition="bottomLeft";mapContainer;popupContainer;feature;currentFeatureId;language="en";promoteIdCache=new Map;publication;floatingPopup;registry;constructor(t){this.map=t,this.mapContainer=this.map.getContainer(),this.popupContainer=document.createElement("div"),this.popupContainer.classList.add("popup-container"),this.popupContainer.classList.add("scrollbar"),this.map.on("mousemove",(t=>this.onMouseMove(t))),this.map.on("click",(t=>this.onClick(t)))}setJobObject(t){this.registry=new ht(t)}setParams(t,e,i){this.interactivityType=t,this.popupPosition=e,this.language=i}setPublication(t){this.publication=t}onMouseMove(t){this.feature=this.getInteractiveFeature(t),this.feature?(this.map.getCanvas().style.cursor="pointer","hover"===this.interactivityType&&this.feature.id!==this.currentFeatureId&&this.addPopup(t)):(this.map.getCanvas().style.cursor="","hover"===this.interactivityType&&(this.hidePopup(),this.floatingPopup?.remove()))}onClick(t){("hover"!==this.interactivityType||Q())&&(this.feature=this.getInteractiveFeature(t),!this.feature||this.mapContainer.contains(this.popupContainer)&&this.feature?.id===this.currentFeatureId?this.hidePopup():this.addPopup(t))}getInteractiveFeature(t){return this.map.queryRenderedFeatures(t.point).find((t=>!!Object.keys(t.layer.metadata??{}).some((t=>t.startsWith("mc-interactivity-template")))||!!this.registry.getModel(t)?.popup))}addPopup(t){if(!this.feature)return;this.floatingPopup?.remove();const e=Number(this.feature.id);this.currentFeatureId=isNaN(e)?this.feature.id:e;const i=this.getTemplate(this.feature);if(i){if(this.popupContainer.innerHTML=i,"mapElement"!==this.popupPosition||this.mapContainer.clientWidth<600){const t="bottomLeft"===this.popupPosition?"bottom-left":"bottom-right";return this.popupContainer.classList.add(t,"hide-pointer"),void this.mapContainer.appendChild(this.popupContainer)}if("Point"===this.feature.geometry.type)this.addFloatingPopup(i,this.feature.geometry.coordinates);else{const{lng:e,lat:r}=this.map.unproject(t.point);this.addFloatingPopup(i,[e,r])}}}addFloatingPopup(t,e){this.floatingPopup=new c.Popup({closeButton:!1,maxWidth:"none"}).setLngLat(e).setHTML(t).addTo(this.map)}hidePopup(){this.popupContainer&&(this.popupContainer.remove(),this.feature=void 0,this.currentFeatureId=void 0)}getTemplate(t){const{layer:e}=t;let i;const r=this.registry.getModel(t),n=r?.popup;if(n)i=function(t,e){return t?t=(t=(t=(t=(t=(t=t.replace(/placeholder="[^"]+"/,"")).replace(/onerror="[^"]+"/,"")).replace(st,((t,i)=>{const r=lt(e[i]);return r?`youtube.com/embed/${n=r,n=n.trim(),/^\$?[\w\-_]+$/.test(n)?n:(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/.exec(n)||[])[1]}?`:"";var n}))).replace(at,((t,i,r)=>{const n=lt(e[r]);return["src","href"].includes(i)&&!n?"":` ${i}="${n}"`}))).replace(nt,((t,i)=>`>${lt(e[i])}<`))).replace(ot,((t,e)=>e)):""}(n,r.dataBindings??{});else{const r=[];this.publication&&(r.push(`:${this.publication}-${this.language}`),r.push(`:${this.publication}-:en`)),r.push(`:${this.language}`),r.push(":en"),r.push("");for(const n of r){const r=e.metadata?.[`mc-interactivity-template${n}`];if(r){i=this.fillDatalayerTemplate(t,r,n);break}}}if(void 0!==i)return`<div class="mc-popup">${i}</div>`}fillDatalayerTemplate(t,e,i){const r="data-mention-id",n=(new DOMParser).parseFromString(e,"text/html").body;for(const e of n.querySelectorAll(`[${r}]`)){const n=this.getProperty(t,e.getAttribute(r),i);void 0!==n&&(e.innerText=n)}return n.innerHTML}getProperty(t,e,i){if(!e)return;const r=e.endsWith(":en")?[e.replace(":en",i),e]:[e];for(const e of r){const i=t.properties[e]??this.getVectorProperty(t,e);if(void 0!==i)return i}}getVectorProperty(t,e){let i=this.promoteIdCache.get(t.source);void 0===i&&(i=this.map.getSource(t.source)?.serialize().promoteId||"id",this.promoteIdCache.set(t.source,i));try{const r=t.properties[i];return t.layer.metadata.properties[e][r]}catch(t){return}}}function pt(t,e){return"en"!==t&&"native"!==t&&(t=d(t,u.TWO)),"native"===t?["get","name"]:"places"===e?["coalesce",["get",`name:${t}`],["case",["has","name_is_latin"],["get","name"],["get","name:en"]]]:["coalesce",["get",`name:${t}`],["get","name:en"],["get","name"]]}async function dt(t,e,i){const r=t.map((t=>v(`${m.vectorApiUrl}styles/${t}.json`,i))).map((t=>fetch(t).then((t=>t.json())))),n=await Promise.all(r);await Promise.all(n.map((t=>async function(t,e){for(const i in t.sources)void 0===e.getSource(i)&&e.addSource(i,t.sources[i]);if(void 0!==t.sprite){const i=v(t.sprite);await async function(t,e){try{const i=`${e}.json?access_token=${m.accessToken}`,r=`${e}.png?access_token=${m.accessToken}`,[n,o]=await Promise.all([fetch(i),fetch(r)]);if(!n.ok||!o.ok)throw new Error(`Failed to load sprite from ${e}`);const a=await n.json(),s=await o.blob(),l=await new Promise(((t,e)=>{const i=new Image;i.onload=()=>t(i),i.onerror=t=>e(t),i.src=URL.createObjectURL(s)})),c=document.createElement("canvas"),h=c.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("Failed to get canvas context");for(const[e,i]of Object.entries(a)){if(t.hasImage(e))continue;const{x:r,y:n,width:o,height:a,pixelRatio:s}=i;c.width=o*s,c.height=a*s,h.clearRect(0,0,c.width,c.height),h.drawImage(l,r,n,o,a,0,0,c.width,c.height);const u=h.getImageData(0,0,c.width,c.height);t.addImage(e,u,{pixelRatio:s})}}catch(t){console.error(t)}}(e,i)}for(const i of t.layers){void 0!==e.getLayer(i.id)&&e.removeLayer(i.id);const t=i.metadata?.["mc-add-before"]??"mc-before-none";e.addLayer(i,t)}}(t,e))))}var mt='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.714H6.714V11H5.286V6.714H1V5.286h4.286V1h1.428v4.286H11v1.428Z"/></svg>\n',ft='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.144H1v-1h10v1Z"/></svg>\n';function gt(t){const e=document.createElement("button");return e.className=t.className,e.innerHTML=`${t.content}`,e.addEventListener("click",t.onClick),e}var _t='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M4.774 6.44a.556.556 0 0 1 .832.734l-.047.052L2.897 9.89h1.436a.555.555 0 0 1 .065 1.107L4.333 11H1.556a.556.556 0 0 1-.552-.49L1 10.443V7.667a.556.556 0 0 1 1.107-.065l.004.065v1.436l2.663-2.662ZM10.444 1a.555.555 0 0 1 .552.49l.004.066v2.777a.556.556 0 0 1-1.107.065l-.004-.065V2.897L7.226 5.559a.556.556 0 0 1-.832-.733l.047-.052L9.103 2.11H7.667a.556.556 0 0 1-.065-1.107L7.667 1h2.777Z"/></svg>\n';function yt(t){return gt({type:"button",className:"control-button fullscreen-control-button",content:_t,onClick:()=>{const e=t.getContainer();if(Boolean(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled))!function(t){return document.fullscreenElement===t||document.webkitFullscreenElement===t||document.mozFullScreenElement===t||document.msFullscreenElement===t}(e)?function(t){t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}(e):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();else{let t=document.location.href;t+=t.includes("?")?"&":"?",t+="close-tab",window.open(t,"_blank")}}})}var xt='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.571.875V0h.858v.875a5.143 5.143 0 0 1 4.696 4.696H12v.858h-.875a5.143 5.143 0 0 1-4.696 4.696V12H5.57v-.875A5.143 5.143 0 0 1 .875 6.429H0V5.57h.875A5.143 5.143 0 0 1 5.571.875Zm0 .86a4.286 4.286 0 0 0-3.835 3.836h.835v.858h-.835a4.286 4.286 0 0 0 3.835 3.835V9.43h.858v.835a4.285 4.285 0 0 0 3.835-3.835H9.43v-.86h.835A4.285 4.285 0 0 0 6.43 1.736v.835h-.86v-.835Zm-.177 3.659a.857.857 0 1 1 1.212 1.212.857.857 0 0 1-1.212-1.212Z"/></svg>\n',vt='<svg width="34" viewBox="5 5 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#343A40"><path d="M15.016 22.656a5.797 5.797 0 0 1-1.016-.46c-2.858-1.65-3.846-5.338-2.196-8.196 1.65-2.858 5.338-3.846 8.196-2.196 2.858 1.65 3.846 5.338 2.196 8.196-.2.346-.434.673-.694.962l2.933 2.72A10.1 10.1 0 0 0 25.66 22c2.75-4.763 1.103-10.91-3.66-13.66S11.09 7.237 8.34 12 7.237 22.91 12 25.66a9.61 9.61 0 0 0 1.635.748l1.381-3.752Z"/><path d="m11.01 17.183-3.999.06a10.051 10.051 0 0 0 6.427 9.097l1.484-3.714a6.025 6.025 0 0 1-3.913-5.443Zm13.284 5.183 1-1.732-2.598-1.5-1 1.732 2.598 1.5Zm-3.428-10.062 1.5-2.598-1.732-1-1.5 2.598 1.732 1Zm-9.562 2.562 1-1.732-2.598-1.5-1 1.732 2.598 1.5Z"/><path d="m13.366 25.294 1.5-2.598-1.732-1-1.5 2.598 1.732 1Z"/></g><defs><clipPath id="a"><path fill="#fff" d="m33.393 12.607-12 20.784-20.785-12 12-20.784z"/></clipPath></defs></svg>\n';const bt=t=>{t.getSource("location-circle")||t.addSource("location-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.getSource("location-dot")||t.addSource("location-dot",{type:"geojson",data:{type:"Feature",geometry:{type:"Point",coordinates:[]},properties:{}}}),t.getLayer("location-circle")||t.addLayer({id:"location-circle",type:"fill",source:"location-circle",layout:{},paint:{"fill-color":"#349CF2","fill-opacity":.15,"fill-outline-color":"#005196"}},"mc-before-names"),t.getLayer("location-dot")||t.addLayer({id:"location-dot",type:"symbol",source:"location-dot",layout:{"icon-padding":0},paint:{"icon-opacity":1},metadata:{"mc-name":"location dot","mc-skip-load":!0}},"mc-before-names"),(t=>{const e=2*window.devicePixelRatio,i=new rt(t).getMaplibreImageKey('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><circle cx="16" cy="16" r="10" fill="#349CF2"/><circle cx="16" cy="16" r="9" stroke="#fff" stroke-width="2"/></g><defs><filter id="a" x="0" y="0" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="4"/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_15_3175"/><feBlend in="SourceGraphic" in2="effect1_dropShadow_15_3175" result="shape"/></filter></defs></svg>\n',e);t.setLayoutProperty("location-dot","icon-image",i)})(t)},wt=(t,e,i)=>{const r=t.getSource("location-dot");r&&r.setData({type:"Feature",geometry:{type:"Point",coordinates:[e,i]},properties:{}})},Tt=(t,e,i)=>{const r=i/1e3,n=[],o=r/(111.32*Math.cos(e*Math.PI/180)),a=r/110.574;for(let i=0;i<64;i++){const r=i/64*(2*Math.PI),s=o*Math.cos(r),l=a*Math.sin(r);n.push([t+s,e+l])}return n.push(n[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[n]}}]}},Et=()=>{const t=document.querySelector(".map"),e=document.createElement("div");e.classList.add("location-notification"),e.textContent="Geolocation is not available",t?.appendChild(e),setTimeout((()=>{t?.removeChild(e)}),3e3)};var St='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.155 1.146A.546.546 0 0 1 6.53 1c.14 0 .275.053.375.146l1.588 1.5c.1.094.155.221.155.354 0 .132-.056.26-.155.353l-1.588 1.5a.546.546 0 0 1-.373.14.545.545 0 0 1-.37-.146.487.487 0 0 1-.154-.349.486.486 0 0 1 .148-.352L6.84 3.5H6c-1.878 0-3.441 1.476-3.441 3.25S4.122 10 6 10s3.441-1.476 3.441-3.25c0-.133.056-.26.155-.354a.546.546 0 0 1 .375-.146c.14 0 .275.053.374.146.1.094.155.221.155.354C10.5 9.076 8.463 11 6 11S1.5 9.076 1.5 6.75 3.537 2.5 6 2.5h.84l-.685-.647A.486.486 0 0 1 6 1.5c0-.133.056-.26.155-.354Z"/></svg>\n';function At(t,e,i){const r=document.createElement("div");r.className="web-control";const n=t.buttons.flatMap((t=>"zoom"===t?["zoomIn","zoomOut"]:t));return(Q()?n.filter((t=>"zoomIn"!==t&&"zoomOut"!==t)):n).forEach((t=>{let n;if("zoomIn"===t)n=function(t){return gt({type:"button",className:"control-button zoom-in-button",content:mt,onClick:()=>t.zoomIn()})}(e);else if("zoomOut"===t)n=function(t){return gt({type:"button",className:"control-button zoom-out-button",content:ft,onClick:()=>t.zoomOut()})}(e);else if("fullscreen"===t)n=yt(e);else if("geolocation"===t)n=function(t){let e=!1;const i=t=>{const i=document.querySelector(".geolocation-button"),r=i?.querySelector(".geolocation-icon"),n=i?.querySelector(".locating-icon");r&&n&&(r.classList.toggle("active",!t),n.classList.toggle("active",t)),e=t},r=e=>{const{longitude:r,latitude:n,accuracy:o}=e.coords,a=[r,n];t.easeTo?t.easeTo({center:a,zoom:19,duration:1e3}):t.setCenter&&t.setCenter(a);const s=t.getSource("location-circle");s&&s.setData(Tt(r,n,o/2)),wt(t,r,n),t.once("moveend",(()=>i(!1)))},n=t=>{console.error("Geolocation error:",t),i(!1)};return gt({type:"button",className:"control-button geolocation-button",content:`\n <div class="location-icon geolocation-icon active">${xt}</div>\n <div class="location-icon locating-icon">${vt}</div>\n `,onClick:()=>{if(!e){if(t.getSource("location-circle")||bt(t),i(!0),!navigator.geolocation)return Et(),void i(!1);navigator.geolocation.getCurrentPosition(r,n,{maximumAge:6e4,timeout:5e3})}}})}(e);else{if("refresh"!==t)return;n=function(t,e){return gt({type:"button",className:"control-button refresh-button",content:St,onClick:()=>{const i=t.getContainer();let r=0;if(i.clientWidth>0&&i.clientHeight>0){const t=Math.min(i.clientWidth/e.width,i.clientHeight/e.height);r=Math.log(t)/Math.LN2}t.easeTo({center:e.center,zoom:e.zoom-e.detailLevel+r,pitch:e.pitch,bearing:e.rotation})}})}(e,i.initialPosition)}r.appendChild(n)})),r}class It extends l{map;svgCache;popupManager;constructor(t={},e={}){super(t,e),this.mapOptions.transformRequest||(this.mapOptions.transformRequest=t=>({url:t=v(t,this.mapOptions.mcAccessToken)})),this.map=new c.Map(this.mapOptions),this.map.getContainer().classList.add("mapcreatorgl-map"),this.svgCache=new rt(this.map),this.popupManager=new ut(this.map)}static get defaultMapOptions(){return{...super.defaultMapOptions,attributionControl:!0,mcAccessToken:m.accessToken,maxBounds:[-1/0,-90,1/0,90]}}static get defaultOptions(){return{...super.defaultOptions}}get favicon(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAAAFBlWElmTU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAtKADAAQAAAABAAAAtAAAAABECLhnAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAE/ElEQVR4Ae3dTU4jVxgFUAMt0XFCoizBU7OE7H8FSJ6yC+eHH6cKQYsMeJ2B7w1POZZKLvPc332cukY9KdhsPAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAIHN5gICge8InL6z/mmWt9vt5nK3260bThzpb/Tse97v9+mLd/Y9p5Fnm38524btl8BIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbToBhZ7uktnwSEChRzrWphNQ6OkumQ2PBBR6pGNtOgGFnu6S2fBIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbTqBL9Pt2IbbAtP8ZoDj8bjxE7pdD3lRAYWO8hreFlDotri8qIBCR3kNbwsodFtcXlRAoaO8hrcFFLotLi8qoNBRXsPbAgrdFpcXFVDoKK/hbQGFbovLiwoodJTX8LaAQrfF5UUFFDrKa3hbQKHb4vKiAgod5TW8LaDQbXF5UQGFjvIa3hZQ6La4vKiAQkd5DW8LKHRbXF5UYOa7vs9+N/LhcIhiG54X8BM6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKArM/Le+i0z/36jT6fTtb6pfXFycPruEQn/2K/Qf7+/29vb5bQv7/f7tdH3+czn+en3+/fV8ff3Hu/O39fX5YTne/s16/rb2sHxoHtfXl5eXL+fvXj++nj8sH6b1/Gk5Hpb3rc8va+v5+ri6unq8vr5+UuhF0uNjgcPh8NHi9bKwHjcfvaH99e12u/F/6La6vKiAQkd5DW8LKHRbXF5UQKGjvIa3BRS6LS4vKqDQUV7D2wIK3RaXFxVQ6Civ4W0BhW6Ly4sKKHSU1/C2gEK3xeVFBRQ6ymt4W0Ch2+LyogIKHeU1vC2g0G1xeVEBhY7yGt4WUOi2uLyogEJHeQ1vCyh0W1xeVECho7yGtwW+LHfy/nZzc/N1uYv2ejm+LnfX/rAc2+fn55fnZUM/LsdP745flvP1xsifX49fX5//8eG4u7tbvuzxXmC3271/eZbz+/v7s8wZDPn2awwG7/kUS8fjcXPWzS4fiHXey7F8KJ4+xXdpEwQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBA4N8I/A1O6KkX0GDoIwAAAABJRU5ErkJggg=="}get title(){return"Mapcreator Next"}async load(t){const{map:e,export:i,registry:r,web:n,adornments:o}=t,{language:a,zoom:s,pitch:l,rotation:c,center:h,layerInfo:p}=e,{models:f,slots:_,svgs:y}=r;g.locale=d(a,u.LOCALE);const x=d(a,u.TWO);document.body.parentElement.lang=x,this.loadFontFaces(),this.map.resize();const b={duration:0};this.map.setPitch(l,b),this.map.setBearing(c,b);const T=w(i.unit,"pixel",i.size[0]),E=w(i.unit,"pixel",i.size[1]),S=this.map?.getContainer();let A=0;if(S.clientWidth>0&&S.clientHeight>0){const t=Math.min(S.clientWidth/T,S.clientHeight/E);A=Math.log(t)/Math.LN2}if(this.map.setZoom(s-e.detailLevel+A,b),this.map.setMinZoom(0),this.map.setCenter(h,b),o&&function(t,e,i){let r=document.getElementById("adornments-container");r||(r=document.createElement("div"),r.id="adornments-container",r.className="adornments-container",e.getContainer().appendChild(r)),r.innerHTML="",t.forEach((t=>{if("copyright"!==t.type)if("custom"===t.type&&t.svg){const e=document.createElement("div");e.className="adornment",e.innerHTML=t.svg,r.appendChild(e)}else if("webControls"===t.type&&t.buttons){const n=At(t,e,i);r.appendChild(n)}}))}(o,this.map,{initialPosition:{center:h,zoom:s,pitch:l,rotation:c,detailLevel:e.detailLevel,width:T,height:E}}),this.popupManager.setJobObject(t),n){const{restrictMapMovement:t,interactivityType:e,popupPosition:i}=n;t&&(this.map.boxZoom.disable(),this.map.doubleClickZoom.disable(),this.map.dragPan.disable(),this.map.dragRotate.disable(),this.map.keyboard.disable(),this.map.scrollZoom.disable(),this.map.touchPitch.disable(),this.map.touchZoomRotate.disable()),this.popupManager.setParams(e,i,x)}const I=`${m.vectorApiUrl}styles/${t.meta.mapstyleSet}.json`,C=await fetch(v(I,this.mapOptions.mcAccessToken)).then((t=>t.json()));this.map.setStyle(C),this.setLayerVisibility(C,p),this.map.on("style.load",(async()=>{this.options.libraryMode||this.setCustomStyle(this.map.getStyle().metadata.customCssFilePath),function(t,e){for(const i of e.getStyle().layers){if("symbol"!==i.type||i.id.startsWith("custom-")||i.id.startsWith("gl-"))continue;const r=i.layout&&i.layout["text-field"];i["source-layer"]&&Array.isArray(r)&&"coalesce"===r[0]&&!r.find((t=>"name:abbr"===t[1]))&&e.setLayoutProperty(i.id,"text-field",pt(t,i["source-layer"]),{validate:!1})}}(a,this.map),await dt(t.meta.layers??[],this.map,this.mapOptions.mcAccessToken),this.addModels(f,_,y),this.popupManager.setPublication(C.metadata?.publication)}))}loadFontFaces(){if(!this.mapOptions.mcAccessToken)return;const t=s()?"b-":"",e=`${v(m.vectorApiUrl)}/stylesheets/ff-${t}${this.mapOptions.mcAccessToken}.css?access_token=${this.mapOptions.mcAccessToken}`,i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",e),i.setAttribute("type","text/css"),document.head.appendChild(i)}setCustomStyle(t){if(document.getElementById("custom-style")?.remove(),!t)return;let e;(t=v(t,this.mapOptions.mcAccessToken)).startsWith("http")?(e=document.createElement("link"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",t.replace(/https?:/,""))):(e=document.createElement("style"),e.appendChild(document.createTextNode(t))),e.setAttribute("id","custom-style"),e.setAttribute("type","text/css"),document.head.appendChild(e)}setLayerVisibility(t,e){for(const i of e){if(i.id.startsWith("custom"))continue;const e=t.layers.find((t=>t.id===i.id));void 0!==e&&void 0!==i.visibility&&e.layout&&(e.layout.visibility=i.visibility?"visible":"none")}}addModels(t,e,i){const{beforeNone:r,beforeNames:n,beforeBoundaries:o,beforeWaters:a}=e;r.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-none")})),n.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-names")})),o.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-boundaries")})),a.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-waters")}))}addModelsByType(t,e,i,r){if("marker"===e.type){const n=t.marker?.find((t=>t.id===e.groupId));n&&function(t,e,i,r,n){const o=[],a=new Set,s=new Set;K=window.devicePixelRatio*t.getScale();const l=["match",["get","text-font"]];for(const t of e.models)(t.visible??1)&&o.push(J(t,r,n)),a.add(t.textFont),s.add(t.textLineHeight??1.2);if(Array.from(a).length>0){for(const t of Array.from(a))l.push(t,["literal",[t,Y]]);l.push(["literal",[Y]])}t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:o}}),s.forEach((r=>{t.addLayer({id:`${e.id}-${r}`,type:"symbol",source:e.id,metadata:{"mc-model-type":"marker","mc-group-id":e.id},layout:{"icon-allow-overlap":!e.collisionDetection,"icon-ignore-placement":!e.collisionDetection,"text-allow-overlap":!e.collisionDetection,"text-ignore-placement":!e.collisionDetection,"icon-image":["get","mc-image-key"],"icon-anchor":["get","icon-anchor"],"icon-size":["get","icon-size"],"icon-rotate":["get","icon-rotate"],"icon-offset":["get","icon-offset"],"text-field":"{text}","text-font":l,"text-max-width":["get","text-max-width"],"text-offset":["get","text-offset"],"text-rotate":["get","text-rotate"],"text-size":["get","text-size"],"text-anchor":["get","text-anchor"],"text-letter-spacing":["get","text-letter-spacing"],"text-line-height":r,"text-justify":["get","text-justify"]},paint:{"text-color":["get","text-color"],"text-halo-color":["get","text-halo-color"],"text-halo-width":["get","text-halo-width"]},filter:["==",["get","text-line-height"],r]},i)}))}(this.map,n,r,i,this.svgCache)}else if("polygon"===e.type){const n=t.polygon?.find((t=>t.id===e.groupId));n&&H(this.map,n,r,i,this.svgCache)}else if("circle"===e.type){const n=t.circle?.find((t=>t.id===e.groupId));n&&W(this.map,n,r,i,this.svgCache)}else if("line"===e.type){const i=t.line?.find((t=>t.id===e.groupId));i&&E(this.map,i,r)}else if("dot"===e.type){const i=t.dot?.find((t=>t.id===e.groupId));i&&function(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:(e=t).id,properties:{id:e.id,"circle-radius":e.radius,"circle-color":e.fillColor??"#000000"},geometry:{type:"Point",coordinates:[e.center.lng,e.center.lat]}};var e}))}}),t.addLayer({id:e.id,type:"circle",source:e.id,metadata:{"mc-model-type":"dot","mc-group-id":e.id},paint:{"circle-color":["get","circle-color"],"circle-radius":["get","circle-radius"]}},i)}(this.map,i,r)}else if("area"===e.type){const n=t.area?.find((t=>t.id===e.groupId));n&&function(t,e,i,r,n,o){const a=new Map,s=new Map;for(const t of e.models){const i=t.id,o=e.id,l=[],c=X(t),h=Z(o,t),u=s.get(h)??{model:t,modelIds:l,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{}};if(t.visible??1){u.modelIds.push(Number(i));const e=void 0!==t.fillPattern?n.getMaplibreImageKey(r[t.fillPattern],2*window.devicePixelRatio):null;u.modelIdToFillColor[i]=t.fillColor??"#ffffff",u.modelIdToFillPattern[i]=e,u.modelIdToOutlineColor[i]=t.outlineColor??"#000000"}a.set(c,t),s.set(h,u)}for(const e of a.keys())t.addSource(e,{type:"vector",url:`${o}${a.get(e).vectorUrl}`});for(const r of s.keys()){const{model:n}=s.get(r),{sourceLayerId:o}=n,a=X(n);t.addLayer({id:r,type:"fill",source:a,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-color":"#ffffff","fill-outline-color":"#000000"}},i),t.addLayer({id:`${r}-pattern`,type:"fill",source:a,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-pattern":["get","fill-pattern"]},layout:{visibility:"visible"}},i)}s.forEach(((e,i)=>{const{modelIds:r,modelIdToFillColor:n,modelIdToFillPattern:o,modelIdToOutlineColor:a}=e;t.setFilter(i,["in","id",...r]),t.setPaintProperty(i,"fill-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",n]]),t.setPaintProperty(i,"fill-outline-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",a]]),t.setFilter(`${i}-pattern`,["to-boolean",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]]]),t.setPaintProperty(`${i}-pattern`,"fill-pattern",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]])}))}(this.map,n,r,i,this.svgCache,m.vectorApiUrl)}}}async function Ct(t){const{jobId:e,container:i,accessToken:r,env:n}=t;!function(t){o=t}(n);let a="";"development"===n||"bleeding"===n?a=".bleeding":"beta"===n&&(a=".beta");const s=t.job??await fetch(`https://cdn${a}.mapcreator.io/jobs/${e}.json?access_token=${r}`).then((t=>t.json())),l=new It({libraryMode:!0},{mcAccessToken:r,container:i});return await l.load(s),l.map}}();var n=r.S;export{n as init};
|
|
1
|
+
/*! For license information please see lib.js.LICENSE.txt */
|
|
2
|
+
var t={34:function(t){t.exports=JSON.parse('{"party":"Partij","votes":"Stemmen","reporting":"{percentage}% Gerapporteerd","ev":"K.M.","electoralVotes":"Kiesmannen","unknown":"Onbekend"}')},53:function(t){t.exports=JSON.parse('{"goBack":"Indietro","notice":"Usa due dita per muovere la mappa"}')},55:function(t){t.exports=JSON.parse('{"loadingSettings":"Loading settings","errorLoadingSettings":"Error loading settings","loadCandidates":"Loading candidate data","errorLoadingCandidates":"Error loading candidates","loadingResults":"Loading results","errorLoadingResults":"Error loading results","updatedOn":"Updated on { interpolate.date } at { interpolate.time }","checkingForData":"Checking for new data in: { interpolate }"}')},130:function(t){t.exports=JSON.parse('{"party":"Partido","votes":"Votos","reporting":"{percentage}% Informando","ev":"V.E.","electoralVotes":"Votos Electorales","unknown":"Desconocido"}')},134:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Votes","reporting":"{percentage}% des votes dépouillés","ev":"C.E.","electoralVotes":"Collège électoral","unknown":"Inconnu"}')},140:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},158:function(t){t.exports=JSON.parse('{"party":"Party","votes":"Votes","reporting":"{ interpolate }% Reporting","ev":"E.V.","electoralVotes":"Electoral Votes","unknown":"Unknown","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},160:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},173:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},241:function(t){t.exports=JSON.parse('{"loadingSettings":"Einstellungen werden geladen","errorLoadingSettings":"Fehler beim Laden der Einstellungen","loadCandidates":"Kandidat-Daten werden geladen","errorLoadingCandidates":"Fehler beim Laden der Kandidat-Daten","loadingResults":"Ergebnisse werden geladen","errorLoadingResults":"Fehler beim Laden der Ergebnisse","updatedOn":"Aktualisiert am {date} um {time}","checkingForData":"Neue Daten werden abgerufen in: {time}"}')},264:function(t){t.exports=function(){var t={},e={};function i(i,r,n){if(e[i]=n,"index"===i){var o="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",s={};return e.shared(s),e.index(t,s),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),t}}return i("shared",["exports"],(function(t){function e(t,e,i,r){return new(i||(i=Promise))((function(n,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n;function o(){if(n)return r;function t(t,e){this.x=t,this.y=e}return n=1,r=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},r}"function"==typeof SuppressedError&&SuppressedError;var s,a,l=i(o()),c=function(){if(a)return s;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return a=1,s=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},s}(),h=i(c);let u,d;function p(){return null==u&&(u="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),u}function f(){if(null==d&&(d=!1,p())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<t*t;i++){const r=4*i;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%t,Math.floor(i/t),1,1)}const i=e.getImageData(0,0,t,t).data;for(let e=0;e<t*t*4;e++)if(e%4!=3&&i[e]!==e){d=!0;break}}}return d||!1}var m=1e-6,g="undefined"!=typeof Float32Array?Float32Array:Array;function _(){var t=new g(9);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function y(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function x(){var t=new g(3);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function v(t){return Math.hypot(t[0],t[1],t[2])}function b(t,e,i){var r=new g(3);return r[0]=t,r[1]=e,r[2]=i,r}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var w,T=v;function P(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,t[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,t[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,t[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,t}function M(){var t=new g(4);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function S(){var t=new g(2);return g!=Float32Array&&(t[0]=0,t[1]=0),t}function C(t,e){var i=new g(2);return i[0]=t,i[1]=e,i}x(),w=new g(4),g!=Float32Array&&(w[0]=0,w[1]=0,w[2]=0,w[3]=0),x(),b(1,0,0),b(0,1,0),M(),M(),_(),S();const I=8192;function A(t,e,i,r){return e*(I/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))*2**r}function E(t,e){return(t%e+e)%e}function k(t,e,i){return t*(1-i)+e*i}function z(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function L(t,e,i,r){const n=new h(t,e,i,r);return t=>n.solve(t)}const D=L(.25,.1,.25,1);function R(t,e,i){return Math.min(i,Math.max(e,t))}function F(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function B(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let O=1;function j(t,e,i){const r={};for(const i in t)r[i]=e.call(this,t[i],i,t);return r}function N(t,e,i){const r={};for(const i in t)e.call(this,t[i],i,t)&&(r[i]=t[i]);return r}function V(t){return Array.isArray(t)?t.map(V):"object"==typeof t&&t?j(t,V):t}const U={};function Z(t){U[t]||("undefined"!=typeof console&&console.warn(t),U[t]=!0)}function $(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function G(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function W(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const H="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function X(t,i,r,n,o){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const s=null==e?void 0:e.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(n*o*4);if(yield e.copyTo(l,function(t,e,i,r,n){const o=4*Math.max(1,0),s=(Math.max(0,i)-i)*r*4+o,a=4*r,l=Math.max(0,e),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+n)-c},layout:[{offset:s,stride:a}]}}(t,i,r,n,o)),a)for(let t=0;t<l.length;t+=4){const e=l[t];l[t]=l[t+2],l[t+2]=e}return l}finally{e.close()}}))}let K,Y;function J(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function Q(t){return t/Math.PI*180}const tt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},et={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},it="AbortError";function rt(){return new Error(it)}const nt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ot(t){return nt.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const st="global-dispatcher";class at extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const lt=()=>G(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(t,i){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=ot(t.url);if(e)return e(t,i);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:st},i)}if(!(/^file:/.test(r=t.url)||/^file:/.test(lt())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,i){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:lt(),signal:i.signal});let r,n;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{r=yield fetch(e)}catch(e){throw new at(0,e.message,t.url,new Blob)}if(!r.ok){const e=yield r.blob();throw new at(r.status,r.statusText,t.url,e)}n="arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text();const o=yield n;if(i.signal.aborted)throw rt();return{data:o,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}}))}(t,i);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:st},i)}var r;return function(t,e){return new Promise(((i,r)=>{var n;const o=new XMLHttpRequest;o.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(o.responseType="arraybuffer");for(const e in t.headers)o.setRequestHeader(e,t.headers[e]);"json"===t.type&&(o.responseType="text",(null===(n=t.headers)||void 0===n?void 0:n.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===t.credentials,o.onerror=()=>{r(new Error(o.statusText))},o.onload=()=>{if(!e.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let e=o.response;if("json"===t.type)try{e=JSON.parse(o.response)}catch(t){return void r(t)}i({data:e,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const e=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});r(new at(o.status,o.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{o.abort(),r(rt())})),o.send(t.body)}))}(t,i)};function ht(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function ut(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function dt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class pt{constructor(t,e={}){B(this,e),this.type=t}}class ft extends pt{constructor(t,e={}){super("error",B({error:t},e))}}class mt{on(t,e){return this._listeners=this._listeners||{},ut(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return dt(t,e,this._listeners),dt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ut(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new pt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)dt(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(B(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof ft&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},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 _t=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function yt(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return _t.forEach((t=>{t in e&&(i[t]=e[t])})),i}function xt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!xt(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!xt(t[i],e[i]))return!1;return!0}return t===e}function vt(t,e){t.push(e)}function bt(t,e,i){vt(i,{command:"addSource",args:[t,e[t]]})}function wt(t,e,i){vt(e,{command:"removeSource",args:[t]}),i[t]=!0}function Tt(t,e,i,r){wt(t,i,r),bt(t,e,i)}function Pt(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!xt(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!xt(t[i][r],e[i][r]))return!1;return!0}function Mt(t,e,i,r,n,o){t=t||{},e=e||{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(xt(t[s],e[s])||i.push({command:o,args:[r,s,e[s],n]}));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(xt(t[s],e[s])||i.push({command:o,args:[r,s,e[s],n]}))}function St(t){return t.id}function Ct(t,e){return t[e.id]=e,t}class It{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function At(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Et extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class kt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new kt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const zt={kind:"null"},Lt={kind:"number"},Dt={kind:"string"},Rt={kind:"boolean"},Ft={kind:"color"},Bt={kind:"projectionDefinition"},Ot={kind:"object"},jt={kind:"value"},Nt={kind:"collator"},Vt={kind:"formatted"},Ut={kind:"padding"},Zt={kind:"resolvedImage"},$t={kind:"variableAnchorOffsetCollection"};function Gt(t,e){return{kind:"array",itemType:t,N:e}}function qt(t){if("array"===t.kind){const e=qt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Wt=[zt,Lt,Dt,Rt,Ft,Bt,Vt,Ot,Gt(jt),Ut,Zt,$t];function Ht(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ht(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Wt)if(!Ht(t,e))return null}return`Expected ${qt(t)} but found ${qt(e)} instead.`}function Xt(t,e){return e.some((e=>e.kind===t.kind))}function Kt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Yt(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Jt=.96422,Qt=.82521,te=4/29,ee=6/29,ie=3*ee*ee,re=ee*ee*ee,ne=Math.PI/180,oe=180/Math.PI;function se(t){return(t%=360)<0&&(t+=360),t}function ae([t,e,i,r]){let n,o;const s=ce((.2225045*(t=le(t))+.7168786*(e=le(e))+.0606169*(i=le(i)))/1);t===e&&e===i?n=o=s:(n=ce((.4360747*t+.3850649*e+.1430804*i)/Jt),o=ce((.0139322*t+.0971045*e+.7141733*i)/Qt));const a=116*s-16;return[a<0?0:a,500*(n-s),200*(s-o),r]}function le(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ce(t){return t>re?Math.pow(t,1/3):t/ie+te}function he([t,e,i,r]){let n=(t+16)/116,o=isNaN(e)?n:n+e/500,s=isNaN(i)?n:n-i/200;return n=1*de(n),o=Jt*de(o),s=Qt*de(s),[ue(3.1338561*o-1.6168667*n-.4906146*s),ue(-.9787684*o+1.9161415*n+.033454*s),ue(.0719453*o-.2289914*n+1.4052427*s),r]}function ue(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function de(t){return t>ee?t*t*t:ie*(t-te)}function pe(t){return parseInt(t.padEnd(2,t),16)/255}function fe(t,e){return me(e?t/100:t,0,1)}function me(t,e,i){return Math.min(Math.max(e,t),i)}function ge(t){return!t.some(Number.isNaN)}const _e={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]};function ye(t,e,i){return t+i*(e-t)}function xe(t,e,i){return t.map(((t,r)=>ye(t,e[r],i)))}class ve{constructor(t,e,i,r=1,n=!0){this.r=t,this.g=e,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static parse(t){if(t instanceof ve)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=_e[t];if(e){const[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[pe(t.slice(i,i+=e)),pe(t.slice(i,i+=e)),pe(t.slice(i,i+=e)),pe(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,r,n,o,s,a,l,c,h,u,d]=e,p=[n||" ",a||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[r,s,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[me(+i/e,0,1),me(+o/e,0,1),me(+l/e,0,1),u?fe(+u,d):1];if(ge(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,r,n,o,s,a,l,c]=i,h=[r||" ",o||" ",a].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,me(+n,0,100),me(+s,0,100),l?fe(+l,c):1];if(ge(t))return function([t,e,i,r]){function n(r){const n=(r+t/30)%12,o=e*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(n-3,9-n,1))}return t=se(t),e/=100,i/=100,[n(0),n(8),n(4),r]}(t)}}}(t);return e?new ve(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[t/n,e/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,r,n]=ae(t),o=Math.sqrt(i*i+r*r);return[Math.round(1e4*o)?se(Math.atan2(r,i)*oe):NaN,o,e,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ae(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}static interpolate(t,e,i,r="rgb"){switch(r){case"rgb":{const[r,n,o,s]=xe(t.rgb,e.rgb,i);return new ve(r,n,o,s,!1)}case"hcl":{const[r,n,o,s]=t.hcl,[a,l,c,h]=e.hcl;let u,d;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?u=NaN:(u=a,1!==o&&0!==o||(d=l)):(u=r,1!==c&&0!==c||(d=n));else{let t=a-r;a>r&&t>180?t-=360:a<r&&r-a>180&&(t+=360),u=r+i*t}const[p,f,m,g]=function([t,e,i,r]){return t=isNaN(t)?0:t*ne,he([i,Math.cos(t)*e,Math.sin(t)*e,r])}([u,null!=d?d:ye(n,l,i),ye(o,c,i),ye(s,h,i)]);return new ve(p,f,m,g,!1)}case"lab":{const[r,n,o,s]=he(xe(t.lab,e.lab,i));return new ve(r,n,o,s,!1)}}}}ve.black=new ve(0,0,0,1),ve.white=new ve(1,1,1,1),ve.transparent=new ve(0,0,0,0),ve.red=new ve(1,0,0,1);class be{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const we=["bottom","center","top"];class Te{constructor(t,e,i,r,n,o){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=o}}class Pe{constructor(t){this.sections=t}static fromString(t){return new Pe([new Te(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Pe?t:Pe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Me{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Me)return t;if("number"==typeof t)return new Me([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Me(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new Me(xe(t.values,e.values,i))}}class Se{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Ce=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ie{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ie)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){const i=t[e],r=t[e+1];if("string"!=typeof i||!Ce.has(i))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new Ie(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){const r=t.values,n=e.values;if(r.length!==n.length)throw new Se(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const o=[];for(let t=0;t<r.length;t+=2){if(r[t]!==n[t])throw new Se(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${r[t]}, to[${t}]: ${n[t]}`);o.push(r[t]);const[e,s]=r[t+1],[a,l]=n[t+1];o.push([ye(e,a,i),ye(s,l,i)])}return new Ie(o)}}class Ae{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ae({name:t,available:!1}):null}}class Ee{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}static interpolate(t,e,i){return new Ee(t,e,i)}static parse(t){return t instanceof Ee?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new Ee(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new Ee(t.from,t.to,t.transition):"string"==typeof t?new Ee(t,t,1):void 0}}function ke(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ze(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ee||t instanceof ve||t instanceof be||t instanceof Pe||t instanceof Me||t instanceof Ie||t instanceof Ae)return!0;if(Array.isArray(t)){for(const e of t)if(!ze(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!ze(t[e]))return!1;return!0}return!1}function Le(t){if(null===t)return zt;if("string"==typeof t)return Dt;if("boolean"==typeof t)return Rt;if("number"==typeof t)return Lt;if(t instanceof ve)return Ft;if(t instanceof Ee)return Bt;if(t instanceof be)return Nt;if(t instanceof Pe)return Vt;if(t instanceof Me)return Ut;if(t instanceof Ie)return $t;if(t instanceof Ae)return Zt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Le(e);if(i){if(i===t)continue;i=jt;break}i=t}return Gt(i||jt,e)}return Ot}function De(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ve||t instanceof Ee||t instanceof Pe||t instanceof Me||t instanceof Ie||t instanceof Ae?t.toString():JSON.stringify(t)}class Re{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ze(t[1]))return e.error("invalid value");const i=t[1];let r=Le(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Re(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Fe={string:Dt,number:Lt,boolean:Rt,object:Ot};class Be{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,o;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in Fe)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=Fe[i],r++}else n=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],r++}i=Gt(n,o)}else{if(!Fe[n])throw new Error(`Types doesn't contain name = ${n}`);i=Fe[n]}const o=[];for(;r<t.length;r++){const i=e.parse(t[r],r,jt);if(!i)return null;o.push(i)}return new Be(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Ht(this.type,Le(i)))return i;if(e===this.args.length-1)throw new Se(`Expected value to be of type ${qt(this.type)}, but found ${qt(Le(i))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Oe={"to-boolean":Rt,"to-color":Ft,"to-number":Lt,"to-string":Dt};class je{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(!Oe[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Oe[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,jt);if(!r)return null;n.push(r)}return new je(r,n)}evaluate(t){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(t));case"color":{let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof ve)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ke(e[0],e[1],e[2],e[3]),!i))return new ve(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Se(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const r=Me.parse(e);if(r)return r}throw new Se(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const r=Ie.parse(e);if(r)return r}throw new Se(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Se(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Pe.fromString(De(this.args[0].evaluate(t)));case"resolvedImage":return Ae.fromString(De(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return De(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ne=["Unknown","Point","LineString","Polygon"];class Ve{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?"number"==typeof this.feature.type?Ne[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(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ve.parse(t)),e}}class Ue{constructor(t,e,i=[],r,n=new kt,o=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=o,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new Be(e,[t]):"coerce"===i?new je(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("projectionDefinition"!==t.kind||"string"!==n.kind&&"array"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind)if("padding"!==t.kind||"value"!==n.kind&&"number"!==n.kind&&"array"!==n.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==n.kind&&"array"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Re)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const e=new Ve;try{r=new Re(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new Ue(this.registry,this._isConstant,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Et(i,t))}checkSubtype(t,e){const i=Ht(t,e);return i&&this.error(i),i}}class Ze{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=e.parse(t[r+1],r+1);if(!o)return null;i.push([n,o])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Ze(i,r):null}outputDefined(){return this.result.outputDefined()}}class $e{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new $e(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class Ge{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Lt),r=e.parse(t[2],2,Gt(e.expectedType||jt));return i&&r?new Ge(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Se(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new Se(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Se(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class qe{constructor(t,e){this.type=Rt,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,jt),r=e.parse(t[2],2,jt);return i&&r?Xt(i.type,[Rt,Dt,Lt,zt,jt])?new qe(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Kt(e,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Le(e))} instead.`);if(!Kt(i,["string","array"]))throw new Se(`Expected second argument to be of type array or string, but found ${qt(Le(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class We{constructor(t,e,i){this.type=Lt,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,jt),r=e.parse(t[2],2,jt);if(!i||!r)return null;if(!Xt(i.type,[Rt,Dt,Lt,zt,jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Lt);return n?new We(i,r,n):null}return new We(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Kt(e,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Le(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),Kt(i,["string"])){const t=i.indexOf(e,r);return-1===t?-1:[...i.slice(0,t)].length}if(Kt(i,["array"]))return i.indexOf(e,r);throw new Se(`Expected second argument to be of type array or string, but found ${qt(Le(i))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class He{constructor(t,e,i,r,n,o){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},o=[];for(let s=2;s<t.length-1;s+=2){let a=t[s];const l=t[s+1];Array.isArray(a)||(a=[a]);const c=e.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Le(t)))return null}else i=Le(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=o.length}const h=e.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=e.parse(t[1],1,jt);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new He(i,r,s,n,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(Le(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Xe{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const o=e.parse(t[n],n,Rt);if(!o)return null;const s=e.parse(t[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=e.parse(t[t.length-1],t.length-1,i);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new Xe(i,r,n)}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}}class Ke{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,jt),r=e.parse(t[2],2,Lt);if(!i||!r)return null;if(!Xt(i.type,[Gt(jt),Dt,jt]))return e.error(`Expected first argument to be of type array or string, but found ${qt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Lt);return n?new Ke(i.type,i,r,n):null}return new Ke(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),Kt(e,["string"]))return[...e].slice(i,r).join("");if(Kt(e,["array"]))return e.slice(i,r);throw new Se(`Expected first argument to be of type array or string, but found ${qt(Le(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Ye(t,e){const i=t.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;o=a+1}else{if(!(r>e))throw new Se("Input is not a number.");s=a-1}return 0}class Je{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,Lt);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const o=1===i?-1/0:t[i],s=t[i+1],a=i,l=i+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Je(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[Ye(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Qe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ti,ei,ii=function(){if(ei)return ti;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return ei=1,ti=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},ti}(),ri=Qe(ii);class ni{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let n=0;if("exponential"===t.name)n=oi(e,t.base,i,r);else if("linear"===t.name)n=oi(e,1,i,r);else if("cubic-bezier"===t.name){const o=t.controlPoints;n=new ri(o[0],o[1],o[2],o[3]).solve(oi(e,1,i,r))}return n}static parse(t,e){let[i,r,n,...o]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,Lt),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Ft:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<o.length;t+=2){const i=o[t],r=o[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return Yt(a,Lt)||Yt(a,Bt)||Yt(a,Ft)||Yt(a,Ut)||Yt(a,$t)||Yt(a,Gt(Lt))?new ni(a,i,r,n,s):e.error(`Type ${qt(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const o=Ye(e,r),s=ni.interpolationFactor(this.interpolation,r,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return ye(a,l,s);case"color":return ve.interpolate(a,l,s);case"padding":return Me.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Ie.interpolate(a,l,s);case"array":return xe(a,l,s);case"projectionDefinition":return Ee.interpolate(a,l,s)}case"interpolate-hcl":return ve.interpolate(a,l,s,"hcl");case"interpolate-lab":return ve.interpolate(a,l,s,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function oi(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}const si={color:ve.interpolate,number:ye,padding:Me.interpolate,variableAnchorOffsetCollection:Ie.interpolate,array:xe};class ai{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}if(!i)throw new Error("No output type");const o=r&&n.some((t=>Ht(r,t.type)));return new ai(o?jt:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Ae&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function li(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function ci(t,e,i,r){return 0===r.compare(e,i)}function hi(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=Rt,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,jt);if(!o)return null;if(!li(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${qt(o.type)}'.`);let s=e.parse(t[2],2,jt);if(!s)return null;if(!li(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${qt(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${qt(o.type)}' and '${qt(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Be(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Be(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Nt),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=Le(o),i=Le(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Se(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Le(o),i=Le(s);if("string"!==t.kind||"string"!==i.kind)return e(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):e(n,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const ui=hi("==",(function(t,e,i){return e===i}),ci),di=hi("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!ci(0,e,i,r)})),pi=hi("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),fi=hi(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),mi=hi("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),gi=hi(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class _i{constructor(t,e,i){this.type=Nt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Rt);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Rt);if(!n)return null;let o=null;return i.locale&&(o=e.parse(i.locale,1,Dt),!o)?null:new _i(r,n,o)}evaluate(t){return new be(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class yi{constructor(t,e,i,r,n){this.type=Dt,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Lt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,Dt),!n))return null;let o=null;if(r.currency&&(o=e.parse(r.currency,1,Dt),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,Lt),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,Lt),!a)?null:new yi(i,n,o,s,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class xi{constructor(t){this.type=Vt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const o=t[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,Lt),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,Gt(Dt)),!i))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,Ft),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!we.includes(o["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=e.parse(o["vertical-align"],1,Dt),!a)return null}const l=r[r.length-1];l.scale=t,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=e.parse(t[i],1,jt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new xi(r)}evaluate(t){return new Pe(this.sections.map((e=>{const i=e.content.evaluate(t);return Le(i)===Zt?new Te("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Te(De(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}}class vi{constructor(t){this.type=Zt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Dt);return i?new vi(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Ae.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class bi{constructor(t){this.type=Lt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${qt(i.type)} instead.`):new bi(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new Se(`Expected value to be of type string or array, but found ${qt(Le(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const wi=8192;function Ti(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*wi),Math.round(r*n*wi)]}function Pi(t,e){const i=Math.pow(2,e.z);return[(n=(t[0]/wi+e.x)/i,360*n-180),(r=(t[1]/wi+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function Mi(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Si(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Ci(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Ii(t,e,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-n[1]*o[0]&&!(!Di(t,e,i,r)||!Di(i,r,t,e));var n,o}function Ai(t,e,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(Ii(t,e,r[i],r[i+1]))return!0;return!1}function Ei(t,e,i=!1){let r=!1;for(const a of e)for(let e=0;e<a.length-1;e++){if(Ci(t,a[e],a[e+1]))return i;(o=a[e])[1]>(n=t)[1]!=(s=a[e+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}var n,o,s;return r}function ki(t,e){for(const i of e)if(Ei(t,i))return!0;return!1}function zi(t,e){for(const i of t)if(!Ei(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Ai(t[i],t[i+1],e))return!1;return!0}function Li(t,e){for(const i of e)if(zi(t,i))return!0;return!1}function Di(t,e,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(t[0]-i[0])*o-n*(t[1]-i[1]),a=(e[0]-i[0])*o-n*(e[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Ri(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=[];for(let r=0;r<t[n].length;r++){const s=Ti(t[n][r],i);Mi(e,s),o.push(s)}r.push(o)}return r}function Fi(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=Ri(t[n],e,i);r.push(o)}return r}function Bi(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}Mi(e,t)}function Oi(t,e,i,r){const n=Math.pow(2,r.z)*wi,o=[r.x*wi,r.y*wi],s=[];for(const r of t)for(const t of r){const r=[t.x+o[0],t.y+o[1]];Bi(r,e,i,n),s.push(r)}return s}function ji(t,e,i,r){const n=Math.pow(2,r.z)*wi,o=[r.x*wi,r.y*wi],s=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Mi(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const r of t)Bi(r,e,i,n)}var a;return s}class Ni{constructor(t,e){this.type=Rt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ze(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const i of e.features){const{type:e,coordinates:r}=i.geometry;"Polygon"===e&&t.push(r),"MultiPolygon"===e&&t.push(...r)}if(t.length)return new Ni(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Ni(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Ni(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=Ri(e.coordinates,r,n),s=Oi(t.geometry(),i,r,n);if(!Si(i,r))return!1;for(const t of s)if(!Ei(t,o))return!1}if("MultiPolygon"===e.type){const o=Fi(e.coordinates,r,n),s=Oi(t.geometry(),i,r,n);if(!Si(i,r))return!1;for(const t of s)if(!ki(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=Ri(e.coordinates,r,n),s=ji(t.geometry(),i,r,n);if(!Si(i,r))return!1;for(const t of s)if(!zi(t,o))return!1}if("MultiPolygon"===e.type){const o=Fi(e.coordinates,r,n),s=ji(t.geometry(),i,r,n);if(!Si(i,r))return!1;for(const t of s)if(!Li(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Vi=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1);const o=r+1;if(o<this.length&&i(e[o],e[r])<0&&(r=o),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}};function Ui(t,e,i=0,r=t.length-1,n=$i){for(;r>i;){if(r-i>600){const o=r-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ui(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(r,Math.floor(e+(o-s)*l/o+c)),n)}const o=t[e];let s=i,a=r;for(Zi(t,i,e),n(t[r],o)>0&&Zi(t,i,r);s<a;){for(Zi(t,s,a),s++,a--;n(t[s],o)<0;)s++;for(;n(t[a],o)>0;)a--}0===n(t[i],o)?Zi(t,i,a):(a++,Zi(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Zi(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function $i(t,e){return t<e?-1:t>e?1:0}function Gi(t,e){if(t.length<=1)return[t];const i=[];let r,n;for(const e of t){const t=Wi(e);0!==t&&(e.area=Math.abs(t),void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e]):r.push(e))}if(r&&i.push(r),e>1)for(let t=0;t<i.length;t++)i[t].length<=e||(Ui(i[t],e,1,i[t].length-1,qi),i[t]=i[t].slice(0,e));return i}function qi(t,e){return e.area-t.area}function Wi(t){let e=0;for(let i,r,n=0,o=t.length,s=o-1;n<o;s=n++)i=t[n],r=t[s],e+=(r.x-i.x)*(i.y+r.y);return e}const Hi=1/298.257223563,Xi=Hi*(2-Hi),Ki=Math.PI/180;class Yi{constructor(t){const e=6378.137*Ki*1e3,i=Math.cos(t*Ki),r=1/(1-Xi*(1-i*i)),n=Math.sqrt(r);this.kx=e*n*i,this.ky=e*n*r*(1-Xi)}distance(t,e){const i=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(t,e){let i,r,n,o,s=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],c=t[a][1],h=this.wrap(t[a+1][0]-l)*this.kx,u=(t[a+1][1]-c)*this.ky,d=0;0===h&&0===u||(d=(this.wrap(e[0]-l)*this.kx*h+(e[1]-c)*this.ky*u)/(h*h+u*u),d>1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=this.wrap(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;p<s&&(s=p,i=l,r=c,n=a,o=d)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,o))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function Ji(t,e){return e[0]-t[0]}function Qi(t){return t[1]-t[0]+1}function tr(t,e){return t[1]>=t[0]&&t[1]<e}function er(t,e){if(t[0]>t[1])return[null,null];const i=Qi(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];const r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function ir(t,e){if(!tr(e,t.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)Mi(i,t[r]);return i}function rr(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const t of i)Mi(e,t);return e}function nr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function or(t,e,i){if(!nr(t)||!nr(e))return NaN;let r=0,n=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(n=t[1]-e[3]),t[3]<e[1]&&(n=e[1]-t[3]),i.distance([0,0],[r,n])}function sr(t,e,i){const r=i.pointOnLine(e,t);return i.distance(t,r.point)}function ar(t,e,i,r,n){const o=Math.min(sr(t,[i,r],n),sr(e,[i,r],n)),s=Math.min(sr(i,[t,e],n),sr(r,[t,e],n));return Math.min(o,s)}function lr(t,e,i,r,n){if(!tr(e,t.length)||!tr(r,i.length))return 1/0;let o=1/0;for(let s=e[0];s<e[1];++s){const e=t[s],a=t[s+1];for(let t=r[0];t<r[1];++t){const r=i[t],s=i[t+1];if(Ii(e,a,r,s))return 0;o=Math.min(o,ar(e,a,r,s,n))}}return o}function cr(t,e,i,r,n){if(!tr(e,t.length)||!tr(r,i.length))return NaN;let o=1/0;for(let s=e[0];s<=e[1];++s)for(let e=r[0];e<=r[1];++e)if(o=Math.min(o,n.distance(t[s],i[e])),0===o)return o;return o}function hr(t,e,i){if(Ei(t,e,!0))return 0;let r=1/0;for(const n of e){const e=n[0],o=n[n.length-1];if(e!==o&&(r=Math.min(r,sr(t,[o,e],i)),0===r))return r;const s=i.pointOnLine(n,t);if(r=Math.min(r,i.distance(t,s.point)),0===r)return r}return r}function ur(t,e,i,r){if(!tr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Ei(t[r],i,!0))return 0;let n=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],s=t[o+1];for(const t of i)for(let i=0,o=t.length,a=o-1;i<o;a=i++){const o=t[a],l=t[i];if(Ii(e,s,o,l))return 0;n=Math.min(n,ar(e,s,o,l,r))}}return n}function dr(t,e){for(const i of t)for(const t of i)if(Ei(t,e,!0))return!0;return!1}function pr(t,e,i,r=1/0){const n=rr(t),o=rr(e);if(r!==1/0&&or(n,o,i)>=r)return r;if(Si(n,o)){if(dr(t,e))return 0}else if(dr(e,t))return 0;let s=1/0;for(const r of t)for(let t=0,n=r.length,o=n-1;t<n;o=t++){const n=r[o],a=r[t];for(const t of e)for(let e=0,r=t.length,o=r-1;e<r;o=e++){const r=t[o],l=t[e];if(Ii(n,a,r,l))return 0;s=Math.min(s,ar(n,a,r,l,i))}}return s}function fr(t,e,i,r,n,o){if(!o)return;const s=or(ir(r,o),n,i);s<e&&t.push([s,o,[0,0]])}function mr(t,e,i,r,n,o,s){if(!o||!s)return;const a=or(ir(r,o),ir(n,s),i);a<e&&t.push([a,o,s])}function gr(t,e,i,r,n=1/0){let o=Math.min(r.distance(t[0],i[0][0]),n);if(0===o)return o;const s=new Vi([[0,[0,t.length-1],[0,0]]],Ji),a=rr(i);for(;s.length>0;){const n=s.pop();if(n[0]>=o)continue;const l=n[1],c=e?50:100;if(Qi(l)<=c){if(!tr(l,t.length))return NaN;if(e){const e=ur(t,l,i,r);if(isNaN(e)||0===e)return e;o=Math.min(o,e)}else for(let e=l[0];e<=l[1];++e){const n=hr(t[e],i,r);if(o=Math.min(o,n),0===o)return 0}}else{const i=er(l,e);fr(s,o,r,t,a,i[0]),fr(s,o,r,t,a,i[1])}}return o}function _r(t,e,i,r,n,o=1/0){let s=Math.min(o,n.distance(t[0],i[0]));if(0===s)return s;const a=new Vi([[0,[0,t.length-1],[0,i.length-1]]],Ji);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],h=e?50:100,u=r?50:100;if(Qi(l)<=h&&Qi(c)<=u){if(!tr(l,t.length)&&tr(c,i.length))return NaN;let o;if(e&&r)o=lr(t,l,i,c,n),s=Math.min(s,o);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(o=sr(i[t],e,n),s=Math.min(s,o),0===s)return s}else if(!e&&r){const e=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=sr(t[i],e,n),s=Math.min(s,o),0===s)return s}else o=cr(t,l,i,c,n),s=Math.min(s,o)}else{const o=er(l,e),h=er(c,r);mr(a,s,n,t,i,o[0],h[0]),mr(a,s,n,t,i,o[0],h[1]),mr(a,s,n,t,i,o[1],h[0]),mr(a,s,n,t,i,o[1],h[1])}}return s}function yr(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class xr{constructor(t,e){this.type=Lt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ze(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new xr(e,e.features.map((t=>yr(t.geometry))).flat());if("Feature"===e.type)return new xr(e,yr(e.geometry));if("type"in e&&"coordinates"in e)return new xr(e,yr(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map((e=>Pi([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const n=new Yi(r[0][1]);let o=1/0;for(const t of e){switch(t.type){case"Point":o=Math.min(o,_r(r,!1,[t.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,_r(r,!1,t.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,gr(r,!1,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map((e=>Pi([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const n=new Yi(r[0][1]);let o=1/0;for(const t of e){switch(t.type){case"Point":o=Math.min(o,_r(r,!0,[t.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,_r(r,!0,t.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,gr(r,!0,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const i=t.geometry();if(0===i.length||0===i[0].length)return NaN;const r=Gi(i,0).map((e=>e.map((e=>e.map((e=>Pi([e.x,e.y],t.canonical))))))),n=new Yi(r[0][0][0][1]);let o=1/0;for(const t of e)for(const e of r){switch(t.type){case"Point":o=Math.min(o,gr([t.coordinates],!1,e,n,o));break;case"LineString":o=Math.min(o,gr(t.coordinates,!0,e,n,o));break;case"Polygon":o=Math.min(o,pr(e,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const vr={"==":ui,"!=":di,">":fi,"<":pi,">=":gi,"<=":mi,array:Be,at:Ge,boolean:Be,case:Xe,coalesce:ai,collator:_i,format:xi,image:vi,in:qe,"index-of":We,interpolate:ni,"interpolate-hcl":ni,"interpolate-lab":ni,length:bi,let:Ze,literal:Re,match:He,number:Be,"number-format":yi,object:Be,slice:Ke,step:Je,string:Be,"to-boolean":je,"to-color":je,"to-number":je,"to-string":je,var:$e,within:Ni,distance:xr};class br{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],r=br.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,o]of s){a=new Ue(e.registry,Sr,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,o=a.parse(i,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(r)&&r.length!==s.length)a.error(`Expected ${r.length} arguments, but found ${s.length} instead.`);else{for(let t=0;t<s.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=s[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new br(i,n,o,s)}}if(1===s.length)e.errors.push(...a.errors);else{const i=(s.length?s:o).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(qt).join(", ")})`:`(${qt(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(qt(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){br.definitions=e;for(const i in e)t[i]=br}}function wr(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const o=n?n.evaluate(t):1,s=ke(e,i,r,o);if(s)throw new Se(s);return new ve(e/255,i/255,r/255,o,!1)}function Tr(t,e){return t in e}function Pr(t,e){const i=e[t];return void 0===i?null:i}function Mr(t){return{type:t}}function Sr(t){if(t instanceof $e)return Sr(t.boundExpression);if(t instanceof br&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Ni)return!1;if(t instanceof xr)return!1;const e=t instanceof je||t instanceof Be;let i=!0;return t.eachChild((t=>{i=e?i&&Sr(t):i&&t instanceof Re})),!!i&&Cr(t)&&Ar(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Cr(t){if(t instanceof br){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Ni)return!1;if(t instanceof xr)return!1;let e=!0;return t.eachChild((t=>{e&&!Cr(t)&&(e=!1)})),e}function Ir(t){if(t instanceof br&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Ir(t)&&(e=!1)})),e}function Ar(t,e){if(t instanceof br&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ar(t,e)&&(i=!1)})),i}function Er(t){return{result:"success",value:t}}function kr(t){return{result:"error",value:t}}function zr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Lr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Dr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Fr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Br(t){return t}function Or(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),o=t.type||(Dr(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?ve.parse:Me.parse;(t=At({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(s=t.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${t.colorSpace}"`);var s;let a,l,c;if("exponential"===o)a=Ur;else if("interval"===o)a=Vr;else if("categorical"===o){a=Nr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Zr}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Or(i[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:ni.interpolationFactor.bind(void 0,o),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Ur({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ni.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?jr(t.default,e.default):a(t,e,n,l,c)}}}function jr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,r,n){return jr(typeof i===n?r[i]:void 0,t.default,e.default)}function Vr(t,e,i){if("number"!==Rr(i))return jr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=Ye(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function Ur(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Rr(i))return jr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const o=Ye(t.stops.map((t=>t[0])),i),s=function(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1],c=si[e.type]||Br;return"function"==typeof a.evaluate?{evaluate(...e){const i=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return c(i,r,s,t.colorSpace)}}:c(a,l,s,t.colorSpace)}function Zr(t,e,i){switch(e.type){case"color":i=ve.parse(i);break;case"formatted":i=Pe.fromString(i.toString());break;case"resolvedImage":i=Ae.fromString(i.toString());break;case"padding":i=Me.parse(i);break;default:Rr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return jr(i,t.default,e.default)}br.register(vr,{error:[{kind:"error"},[Dt],(t,[e])=>{throw new Se(e.evaluate(t))}],typeof:[Dt,[jt],(t,[e])=>qt(Le(e.evaluate(t)))],"to-rgba":[Gt(Lt,4),[Ft],(t,[e])=>{const[i,r,n,o]=e.evaluate(t).rgb;return[255*i,255*r,255*n,o]}],rgb:[Ft,[Lt,Lt,Lt],wr],rgba:[Ft,[Lt,Lt,Lt,Lt],wr],has:{type:Rt,overloads:[[[Dt],(t,[e])=>Tr(e.evaluate(t),t.properties())],[[Dt,Ot],(t,[e,i])=>Tr(e.evaluate(t),i.evaluate(t))]]},get:{type:jt,overloads:[[[Dt],(t,[e])=>Pr(e.evaluate(t),t.properties())],[[Dt,Ot],(t,[e,i])=>Pr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[jt,[Dt],(t,[e])=>Pr(e.evaluate(t),t.featureState||{})],properties:[Ot,[],t=>t.properties()],"geometry-type":[Dt,[],t=>t.geometryType()],id:[jt,[],t=>t.id()],zoom:[Lt,[],t=>t.globals.zoom],"heatmap-density":[Lt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Lt,[],t=>t.globals.lineProgress||0],accumulated:[jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Lt,Mr(Lt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Lt,Mr(Lt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Lt,overloads:[[[Lt,Lt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Lt],(t,[e])=>-e.evaluate(t)]]},"/":[Lt,[Lt,Lt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Lt,[Lt,Lt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Lt,[],()=>Math.LN2],pi:[Lt,[],()=>Math.PI],e:[Lt,[],()=>Math.E],"^":[Lt,[Lt,Lt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Lt,[Lt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Lt,[Lt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Lt,[Lt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Lt,[Lt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Lt,[Lt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Lt,[Lt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Lt,[Lt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Lt,Mr(Lt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Lt,Mr(Lt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Lt,[Lt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Lt,[Lt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Lt,[Lt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Lt,[Lt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Rt,[Dt,jt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Rt,[jt],(t,[e])=>t.id()===e.value],"filter-type-==":[Rt,[Dt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Rt,[jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Rt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Rt,[Gt(Dt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Rt,[Gt(jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Rt,[Dt,Gt(jt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Rt,[Dt,Gt(jt)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Rt,overloads:[[[Rt,Rt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Mr(Rt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Rt,overloads:[[[Rt,Rt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Mr(Rt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Rt,[Rt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Rt,[Dt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Dt,[Dt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Dt,[Dt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Dt,Mr(jt),(t,e)=>e.map((e=>De(e.evaluate(t)))).join("")],"resolved-locale":[Dt,[Nt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class $r{constructor(t,e){var i;this.expression=t,this._warningHistory={},this._evaluator=new Ve,this._defaultValue=e?"color"===(i=e).type&&Fr(i.default)?new ve(0,0,0,0):"color"===i.type?ve.parse(i.default)||null:"padding"===i.type?Me.parse(i.default)||null:"variableAnchorOffsetCollection"===i.type?Ie.parse(i.default)||null:"projectionDefinition"===i.type?Ee.parse(i.default)||null:void 0===i.default?null:i.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Se(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Gr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in vr}function qr(t,e){const i=new Ue(vr,Sr,[],e?function(t){const e={color:Ft,string:Dt,number:Lt,enum:Dt,boolean:Rt,formatted:Vt,padding:Ut,projectionDefinition:Bt,resolvedImage:Zt,variableAnchorOffsetCollection:$t};return"array"===t.type?Gt(e[t.value]||jt,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Er(new $r(r,e)):kr(i.errors)}class Wr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ir(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}}class Hr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ir(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}interpolationFactor(t,e,i){return this.interpolationType?ni.interpolationFactor(this.interpolationType,t,e,i):0}}function Xr(t,e){const i=qr(t,e);if("error"===i.result)return i;const r=i.value.expression,n=Cr(r);if(!n&&!zr(e))return kr([new Et("","data expressions not supported")]);const o=Ar(r,["zoom"]);if(!o&&!Lr(e))return kr([new Et("","zoom expressions not supported")]);const s=Yr(r);return s||o?s instanceof Et?kr([s]):s instanceof ni&&!Dr(e)?kr([new Et("",'"interpolate" expressions cannot be used with this property')]):Er(s?new Hr(n?"camera":"composite",i.value,s.labels,s instanceof ni?s.interpolation:void 0):new Wr(n?"constant":"source",i.value)):kr([new Et("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Kr{constructor(t,e){this._parameters=t,this._specification=e,At(this,Or(this._parameters,this._specification))}static deserialize(t){return new Kr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Yr(t){let e=null;if(t instanceof Ze)e=Yr(t.result);else if(t instanceof ai){for(const i of t.args)if(e=Yr(i),e)break}else(t instanceof Je||t instanceof ni)&&t.input instanceof br&&"zoom"===t.input.name&&(e=t);return e instanceof Et||t.eachChild((t=>{const i=Yr(t);i instanceof Et?e=i:!e&&i?e=new Et("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Et("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Jr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Jr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const Qr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function tn(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Jr(t)||(t=nn(t));const e=qr(t,Qr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:rn(t)}}function en(t,e){return t<e?-1:t>e?1:0}function rn(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(rn(t[e]))return!0;return!1}function nn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?on(t[1],t[2],"=="):"!="===e?ln(on(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?on(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(nn))):"all"===e?["all"].concat(t.slice(1).map(nn)):"none"===e?["all"].concat(t.slice(1).map(nn).map(ln)):"in"===e?sn(t[1],t.slice(2)):"!in"===e?ln(sn(t[1],t.slice(2))):"has"===e?an(t[1]):"!has"!==e||ln(an(t[1]));var i}function on(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function sn(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(en)]]:["filter-in-small",t,["literal",e]]}}function an(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ln(t){return["!",t]}function cn(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${cn(i)},`;return`${e}]`}const i=Object.keys(t).sort();let r="{";for(let e=0;e<i.length;e++)r+=`${JSON.stringify(i[e])}:${cn(t[i[e]])},`;return`${r}}`}function hn(t){let e="";for(const i of _t)e+=`/${cn(t[i])}`;return e}function un(t){const e=t.value;return e?[new It(t.key,e,"constants have been deprecated as of v8")]:[]}function dn(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function pn(t){if(Array.isArray(t))return t.map(pn);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=pn(t[i]);return e}return dn(t)}function fn(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,s=t.styleSpec,a=t.validateSpec;let l=[];const c=Rr(i);if("object"!==c)return[new It(e,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0],h=r[c]||r["*"];let u;if(n[c])u=n[c];else if(r[c])u=a;else if(n["*"])u=n["*"];else{if(!r["*"]){l.push(new It(e,i[t],`unknown property "${t}"`));continue}u=a}l=l.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:h,style:o,styleSpec:s,object:i,objectKey:t,validateSpec:a},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new It(e,i,`missing required property "${t}"`));return l}function mn(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,o=t.key,s=t.arrayElementValidator||t.validateSpec;if("array"!==Rr(e))return[new It(o,e,`array expected, ${Rr(e)} found`)];if(i.length&&e.length!==i.length)return[new It(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new It(o,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===Rr(i.value)&&(a=i.value);let l=[];for(let i=0;i<e.length;i++)l=l.concat(s({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:n,key:`${o}[${i}]`}));return l}function gn(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Rr(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new It(e,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new It(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new It(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function _n(t){const e=t.valueSpec,i=dn(t.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Rr(t.value.stops)&&"array"===Rr(t.value.stops[0])&&"object"===Rr(t.value.stops[0][0]),h=fn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new It(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(mn({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Rr(r)&&0===r.length&&e.push(new It(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new It(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new It(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Dr(t.valueSpec)&&h.push(new It(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!zr(t.valueSpec)?h.push(new It(t.key,t.value,"property functions not supported")):a&&!Lr(t.valueSpec)&&h.push(new It(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new It(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==Rr(r))return[new It(a,r,`array expected, ${Rr(r)} found`)];if(2!==r.length)return[new It(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Rr(r[0]))return[new It(a,r,`object expected, ${Rr(r[0])} found`)];if(void 0===r[0].zoom)return[new It(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new It(a,r,"object stop key must have value")];if(o&&o>dn(r[0].zoom))return[new It(a,r[0].zoom,"stop zoom values must appear in ascending order")];dn(r[0].zoom)!==o&&(o=dn(r[0].zoom),n=void 0,s={}),i=i.concat(fn({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:gn,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return Gr(pn(r[1]))?i.concat([new It(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,o){const a=Rr(t.value),l=dn(t.value),c=null!==t.value?t.value:o;if(r){if(a!==r)return[new It(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new It(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return zr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new It(t.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new It(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new It(t.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new It(t.key,c,`integer expected, found ${l}`)]}}function yn(t){const e=("property"===t.expressionContext?Xr:qr)(pn(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new It(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new It(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Ir(i))return[new It(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ir(i))return[new It(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ar(i,["zoom","feature-state"]))return[new It(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Cr(i))return[new It(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function xn(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(dn(i))&&n.push(new It(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(dn(i))&&n.push(new It(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function vn(t){return Jr(pn(t.value))?yn(At({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):bn(t)}function bn(t){const e=t.value,i=t.key;if("array"!==Rr(e))return[new It(i,e,`array expected, ${Rr(e)} found`)];const r=t.styleSpec;let n,o=[];if(e.length<1)return[new It(i,e,"filter array must have at least 1 element")];switch(o=o.concat(xn({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),dn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===dn(e[1])&&o.push(new It(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new It(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Rr(e[1]),"string"!==n&&o.push(new It(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let s=2;s<e.length;s++)n=Rr(e[s]),"$type"===dn(e[1])?o=o.concat(xn({key:`${i}[${s}]`,value:e[s],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new It(`${i}[${s}]`,e[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)o=o.concat(bn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Rr(e[1]),2!==e.length?o.push(new It(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new It(`${i}[1]`,e[1],`string expected, ${n} found`))}return o}function wn(t,e){const i=t.key,r=t.validateSpec,n=t.style,o=t.styleSpec,s=t.value,a=t.objectKey,l=o[`${e}_${t.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===e&&c&&l[c[1]]&&l[c[1]].transition)return r({key:i,value:s,valueSpec:o.transition,style:n,styleSpec:o});const h=t.valueSpec||l[a];if(!h)return[new It(i,s,`unknown property "${a}"`)];let u;if("string"===Rr(s)&&zr(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(s)))return[new It(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const d=[];return"symbol"===t.layerType&&("text-field"===a&&n&&!n.glyphs&&d.push(new It(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Fr(pn(s))&&"identity"===dn(s.type)&&d.push(new It(i,s,'"text-font" does not support identity functions'))),d.concat(r({key:t.key,value:s,valueSpec:h,style:n,styleSpec:o,expressionContext:"property",propertyType:e,propertyKey:a}))}function Tn(t){return wn(t,"paint")}function Pn(t){return wn(t,"layout")}function Mn(t){let e=[];const i=t.value,r=t.key,n=t.style,o=t.styleSpec;i.type||i.ref||e.push(new It(r,i,'either "type" or "ref" is required'));let s=dn(i.type);const a=dn(i.ref);if(i.id){const o=dn(i.id);for(let s=0;s<t.arrayIndex;s++){const t=n.layers[s];dn(t.id)===o&&e.push(new It(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new It(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{dn(e.id)===a&&(t=e)})),t?t.ref?e.push(new It(r,i.ref,"ref cannot reference another ref layer")):s=dn(t.type):e.push(new It(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const t=n.sources&&n.sources[i.source],o=t&&dn(t.type);t?"vector"===o&&"raster"===s?e.push(new It(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s?e.push(new It(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?e.push(new It(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new It(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&t.lineMetrics||e.push(new It(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new It(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new It(r,i.source,`source "${i.source}" not found`))}else e.push(new It(r,i,'missing required property "source"'));return e=e.concat(fn({key:r,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:vn,layout:t=>fn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Pn(At({layerType:s},t))}}),paint:t=>fn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Tn(At({layerType:s},t))}})}})),e}function Sn(t){const e=t.value,i=t.key,r=Rr(e);return"string"!==r?[new It(i,e,`string expected, ${r} found`)]:[]}const Cn={promoteId:function({key:t,value:e}){if("string"===Rr(e))return Sn({key:t,value:e});{const i=[];for(const r in e)i.push(...Sn({key:`${t}.${r}`,value:e[r]}));return i}}};function In(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style,o=t.validateSpec;if(!e.type)return[new It(i,e,'"type" is required')];const s=dn(e.type);let a;switch(s){case"vector":case"raster":return a=fn({key:i,value:e,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Cn,validateSpec:o}),a;case"raster-dem":return a=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,n=t.styleSpec,o=n.source_raster_dem,s=t.style;let a=[];const l=Rr(r);if(void 0===r)return a;if("object"!==l)return a.push(new It("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===dn(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!c&&h.includes(e)?a.push(new It(e,r[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):o[e]?a=a.concat(t.validateSpec({key:e,value:r[e],valueSpec:o[e],validateSpec:t.validateSpec,style:s,styleSpec:n})):a.push(new It(e,r[e],`unknown property "${e}"`));return a}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:o}),a;case"geojson":if(a=fn({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:o,objectElementValidators:Cn}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...yn({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),a.push(...yn({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return fn({key:i,value:e,valueSpec:r.source_video,style:n,validateSpec:o,styleSpec:r});case"image":return fn({key:i,value:e,valueSpec:r.source_image,style:n,validateSpec:o,styleSpec:r});case"canvas":return[new It(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return xn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function An(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let o=[];const s=Rr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new It("light",e,`object expected, ${s} found`)]),o;for(const s in e){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:s,value:e[s],valueSpec:i.transition,validateSpec:t.validateSpec,style:n,styleSpec:i}):r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new It(s,e[s],`unknown property "${s}"`)])}return o}function En(t){const e=t.value,i=t.styleSpec,r=i.sky,n=t.style,o=Rr(e);if(void 0===e)return[];if("object"!==o)return[new It("sky",e,`object expected, ${o} found`)];let s=[];for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],style:n,styleSpec:i}):[new It(o,e[o],`unknown property "${o}"`)]);return s}function kn(t){const e=t.value,i=t.styleSpec,r=i.terrain,n=t.style;let o=[];const s=Rr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new It("terrain",e,`object expected, ${s} found`)]),o;for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new It(s,e[s],`unknown property "${s}"`)]);return o}function zn(t){let e=[];const i=t.value,r=t.key;if(Array.isArray(i)){const n=[],o=[];for(const s in i)i[s].id&&n.includes(i[s].id)&&e.push(new It(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),n.push(i[s].id),i[s].url&&o.includes(i[s].url)&&e.push(new It(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),e=e.concat(fn({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Sn({key:r,value:i})}const Ln={"*":()=>[],array:mn,boolean:function(t){const e=t.value,i=t.key,r=Rr(e);return"boolean"!==r?[new It(i,e,`boolean expected, ${r} found`)]:[]},number:gn,color:function(t){const e=t.key,i=t.value,r=Rr(i);return"string"!==r?[new It(e,i,`color expected, ${r} found`)]:ve.parse(String(i))?[]:[new It(e,i,`color expected, "${i}" found`)]},constants:un,enum:xn,filter:vn,function:_n,layer:Mn,object:fn,source:In,light:An,sky:En,terrain:kn,projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style,o=Rr(e);if(void 0===e)return[];if("object"!==o)return[new It("projection",e,`object expected, ${o} found`)];let s=[];for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],style:n,styleSpec:i}):[new It(o,e[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(t){const e=t.key;let i=t.value;i=i instanceof String?i.valueOf():i;const r=Rr(i);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(i)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(i)?["array","string"].includes(r)?[]:[new It(e,i,`projection expected, invalid type "${r}" found`)]:[new It(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Sn,formatted:function(t){return 0===Sn(t).length?[]:yn(t)},resolvedImage:function(t){return 0===Sn(t).length?[]:yn(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Rr(i)){if(i.length<1||i.length>4)return[new It(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let o=0;o<i.length;o++)n=n.concat(t.validateSpec({key:`${e}[${o}]`,value:i[o],validateSpec:t.validateSpec,valueSpec:r}));return n}return gn({key:e,value:i,valueSpec:{}})},variableAnchorOffsetCollection:function(t){const e=t.key,i=t.value,r=Rr(i),n=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new It(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let o=[];for(let r=0;r<i.length;r+=2)o=o.concat(xn({key:`${e}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),o=o.concat(mn({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return o},sprite:zn};function Dn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=Dn,i.expression&&Fr(dn(e))?_n(t):i.expression&&Gr(pn(e))?yn(t):i.type&&Ln[i.type]?Ln[i.type](t):fn(At({},t,{valueSpec:i.type?r[i.type]:i}))}function Rn(t){const e=t.value,i=t.key,r=Sn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new It(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new It(i,e,'"glyphs" url must include a "{range}" token'))),r}function Fn(t,e=gt){let i=[];return i=i.concat(Dn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Dn,objectElementValidators:{glyphs:Rn,"*":()=>[]}})),t.constants&&(i=i.concat(un({key:"constants",value:t.constants}))),On(i)}function Bn(t){return function(e){return t({...e,validateSpec:Dn})}}function On(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function jn(t){return function(...e){return On(t.apply(this,e))}}Fn.source=jn(Bn(In)),Fn.sprite=jn(Bn(zn)),Fn.glyphs=jn(Bn(Rn)),Fn.light=jn(Bn(An)),Fn.sky=jn(Bn(En)),Fn.terrain=jn(Bn(kn)),Fn.layer=jn(Bn(Mn)),Fn.filter=jn(Bn(vn)),Fn.paintProperty=jn(Bn(Tn)),Fn.layoutProperty=jn(Bn(Pn));const Nn=Fn,Vn=Nn.light,Un=Nn.sky,Zn=Nn.paintProperty,$n=Nn.layoutProperty;function Gn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new ft(new Error(r.message))),i=!0;return i}class qn{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(let t=0;t<this.d*this.d;t++){const e=n[3+t],i=n[3+t+1];r.push(e===i?null:n.subarray(e,i))}const o=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],o),this.bboxes=n.subarray(o),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const n=i/e*t;this.min=-n,this.max=t+n}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,n,o){this.cells[n].push(o)}query(t,e,i,r,n,o){const s=this.min,a=this.max;if(o||t<=s&&e<=s&&a<=i&&a<=r&&!n)return Array.prototype.slice.call(this.keys);{const o=[];return this._forEachCell(t,e,i,r,this._queryCell,o,{},n),o}}_queryCell(t,e,i,r,n,o,s,a){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===s[u]){const l=4*u;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(s[u]=!0,o.push(n[u])):s[u]=!1}}}}_forEachCell(t,e,i,r,n,o,s,a){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&n.call(this,t,e,i,r,c,o,s,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=n,r.set(i,n),n+=i.length}return r[3+t.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+t.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new qn(t.buffer)}}const Wn={};function Hn(t,e,i={}){if(Wn[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Wn[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Hn("Object",Object),Hn("TransferableGridIndex",qn),Hn("Color",ve),Hn("Error",Error),Hn("AJAXError",at),Hn("ResolvedImage",Ae),Hn("StylePropertyFunction",Kr),Hn("StyleExpression",$r,{omit:["_evaluator"]}),Hn("ZoomDependentExpression",Hr),Hn("ZoomConstantExpression",Wr),Hn("CompoundExpression",br,{omit:["_evaluate"]});for(const t in vr)vr[t]._classRegistryKey||Hn(`Expression_${t}`,vr[t]);function Xn(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Kn(t){return t.$name||t.constructor._classRegistryKey}function Yn(t){return!function(t){if(null===t||"object"!=typeof t)return!1;const e=Kn(t);return!(!e||"Object"===e)}(t)&&(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||Xn(t)||W(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function Jn(t,e){if(Yn(t))return(Xn(t)||W(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(Jn(r,e));return i}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const i=Kn(t);if(!i)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!Wn[i])throw new Error(`${i} is not registered.`);const{klass:r}=Wn[i],n=r.serialize?r.serialize(t,e):{};if(r.serialize){if(e&&n===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in t){if(!t.hasOwnProperty(r))continue;if(Wn[i].omit.indexOf(r)>=0)continue;const o=t[r];n[r]=Wn[i].shallow.indexOf(r)>=0?o:Jn(o,e)}t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function Qn(t){if(Yn(t))return t;if(Array.isArray(t))return t.map(Qn);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Kn(t)||"Object";if(!Wn[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Wn[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const n=t[i];r[i]=Wn[e].shallow.indexOf(i)>=0?n:Qn(n)}return r}class to{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const eo={"Latin-1 Supplement":t=>t>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function io(t){for(const e of t)if(lo(e.charCodeAt(0)))return!0;return!1}function ro(t){for(const e of t)if(!so(e.charCodeAt(0)))return!1;return!0}function no(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const oo=no(["Arab","Dupl","Mong","Ougr","Syrc"]);function so(t){return!oo.test(String.fromCodePoint(t))}const ao=no(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function lo(t){return!(746!==t&&747!==t&&(t<4352||!(eo["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||eo["CJK Compatibility"](t)||eo["CJK Strokes"](t)||!(!eo["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||eo["Enclosed CJK Letters and Months"](t)||eo["Ideographic Description Characters"](t)||eo.Kanbun(t)||eo.Katakana(t)&&12540!==t||!(!eo["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!eo["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||eo["Vertical Forms"](t)||eo["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||ao.test(String.fromCodePoint(t)))))}function co(t){return!(lo(t)||function(t){return!!(eo["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||eo["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||eo["Letterlike Symbols"](t)||eo["Number Forms"](t)||eo["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||eo["Control Pictures"](t)&&9251!==t||eo["Optical Character Recognition"](t)||eo["Enclosed Alphanumerics"](t)||eo["Geometric Shapes"](t)||eo["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||eo["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||eo["CJK Symbols and Punctuation"](t)||eo.Katakana(t)||eo["Private Use Area"](t)||eo["CJK Compatibility Forms"](t)||eo["Small Form Variants"](t)||eo["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ho=no(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function uo(t){return ho.test(String.fromCodePoint(t))}function po(t,e){return!(!e&&uo(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||eo.Khmer(t))}function fo(t){for(const e of t)if(uo(e.charCodeAt(0)))return!0;return!1}const mo=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(mo.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,i){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,r=new Promise((t=>{this.loadScriptResolve=t}));i(e);const n=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([r,n]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class go{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new to,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!po(i.charCodeAt(0),e))return!1;return!0}(t,"loaded"===mo.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class _o{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Fr(t))return new Kr(t,e);if(Gr(t)){const i=Xr(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=ve.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?i=Ie.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(i=Ee.parse(t)):i=Me.parse(t),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class yo{constructor(t){this.property=t,this.value=new _o(t,void 0)}transitioned(t,e){return new vo(this.property,this.value,e,B({},t.transition,this.transition),t.now)}untransitioned(){return new vo(this.property,this.value,null,{},0)}}class xo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return V(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new yo(this._values[t].property)),this._values[t].value=new _o(this._values[t].property,null===e?void 0:V(e))}getTransition(t){return V(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new yo(this._values[t].property)),this._values[t].transition=V(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new bo(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new bo(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class vo{constructor(t,e,i,r,n){this.property=t,this.value=e,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(t,e,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,i),n,z(s))}}return n}}class bo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new Po(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class wo{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return V(this._values[t].value)}setValue(t,e){this._values[t]=new _o(this._values[t].property,null===e?void 0:V(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new Po(this._properties);for(const n of Object.keys(this._values)){const o="text-letter-spacing"===n?B({},t,{zoom:Math.floor(t.zoom)}):t;r._values[n]=this._values[n].possiblyEvaluate(o,e,i)}return r}}class To{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class Po{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Mo{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=si[this.specification.type];return r?r(t,e,i):t}}class So{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new To(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new To(this,{kind:"constant",value:void 0},t.parameters);const r=si[this.specification.type];if(r){const n=r(t.value.value,e.value.value,i);return new To(this,{kind:"constant",value:n},t.parameters)}return t}evaluate(t,e,i,r,n,o){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,o)}}class Co extends So{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new To(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),o="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,e);return new To(this,{kind:"constant",value:s},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new To(this,{kind:"constant",value:i},e)}return new To(this,t.expression,e)}evaluate(t,e,i,r,n,o){if("source"===t.kind){const s=t.evaluate(e,i,r,n,o);return this._calculate(s,s,s,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Io{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new go(Math.floor(e.zoom-1),e)),t.expression.evaluate(new go(Math.floor(e.zoom),e)),t.expression.evaluate(new go(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Ao{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Eo{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new _o(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new yo(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Hn("DataDrivenProperty",So),Hn("DataConstantProperty",Mo),Hn("CrossFadedDataDrivenProperty",Co),Hn("CrossFadedProperty",Io),Hn("ColorRampProperty",Ao);const ko="-transition";class zo extends mt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new wo(e.layout)),e.paint)){this._transitionablePaint=new xo(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Po(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate($n,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(ko)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Zn,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(ko))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,o,s)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),N(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Gn(this,t.call(Nn,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:gt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof To&&zr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Lo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Do{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ro{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Fo(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=Lo[t.type].BYTES_PER_ELEMENT,o=i=Bo(i,Math.max(e,n)),s=t.components||1;return r=Math.max(r,n),i+=n*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Bo(i,Math.max(r,e)),alignment:e}}function Bo(t,e){return Math.ceil(t/e)*e}class Oo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Oo.prototype.bytesPerElement=4,Hn("StructArrayLayout2i4",Oo);class jo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}jo.prototype.bytesPerElement=6,Hn("StructArrayLayout3i6",jo);class No extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,t}}No.prototype.bytesPerElement=8,Hn("StructArrayLayout4i8",No);class Vo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,t}}Vo.prototype.bytesPerElement=12,Hn("StructArrayLayout2i4i12",Vo);class Uo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=o,this.uint8[l+7]=s,t}}Uo.prototype.bytesPerElement=8,Hn("StructArrayLayout2i4ub8",Uo);class Zo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Zo.prototype.bytesPerElement=8,Hn("StructArrayLayout2f8",Zo);class $o extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,o,s,a,l,c)}emplace(t,e,i,r,n,o,s,a,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=s,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}$o.prototype.bytesPerElement=20,Hn("StructArrayLayout10ui20",$o);class Go extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,n,o,s,a,l,c,h,u)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}Go.prototype.bytesPerElement=24,Hn("StructArrayLayout4i4ui4i24",Go);class qo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}qo.prototype.bytesPerElement=12,Hn("StructArrayLayout3f12",qo);class Wo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Wo.prototype.bytesPerElement=4,Hn("StructArrayLayout1ul4",Wo);class Ho extends Ro{_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(t,e,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,n,o,s,a,l)}emplace(t,e,i,r,n,o,s,a,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=o,this.int16[h+5]=s,this.uint32[u+3]=a,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}Ho.prototype.bytesPerElement=20,Hn("StructArrayLayout6i1ul2ui20",Ho);class Xo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,t}}Xo.prototype.bytesPerElement=12,Hn("StructArrayLayout2i2i2i12",Xo);class Ko extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n)}emplace(t,e,i,r,n,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,t}}Ko.prototype.bytesPerElement=16,Hn("StructArrayLayout2f1f2i16",Ko);class Yo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=16*t,l=4*t,c=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=o,this.int16[c+7]=s,t}}Yo.prototype.bytesPerElement=16,Hn("StructArrayLayout2ub2f2i16",Yo);class Jo extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}Jo.prototype.bytesPerElement=6,Hn("StructArrayLayout3ui6",Jo);class Qo extends Ro{_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(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=n,this.uint32[x+2]=o,this.uint32[x+3]=s,this.uint32[x+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[x+10]=g,this.int16[y+22]=_,t}}Qo.prototype.bytesPerElement=48,Hn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Qo);class ts extends Ro{_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(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,P,M,S,C,I){const A=this.length;return this.resize(A+1),this.emplace(A,t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,P,M,S,C,I)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,P,M,S,C,I,A){const E=34*t,k=17*t;return this.int16[E+0]=e,this.int16[E+1]=i,this.int16[E+2]=r,this.int16[E+3]=n,this.int16[E+4]=o,this.int16[E+5]=s,this.int16[E+6]=a,this.int16[E+7]=l,this.uint16[E+8]=c,this.uint16[E+9]=h,this.uint16[E+10]=u,this.uint16[E+11]=d,this.uint16[E+12]=p,this.uint16[E+13]=f,this.uint16[E+14]=m,this.uint16[E+15]=g,this.uint16[E+16]=_,this.uint16[E+17]=y,this.uint16[E+18]=x,this.uint16[E+19]=v,this.uint16[E+20]=b,this.uint16[E+21]=w,this.uint16[E+22]=T,this.uint32[k+12]=P,this.float32[k+13]=M,this.float32[k+14]=S,this.uint16[E+30]=C,this.uint16[E+31]=I,this.float32[k+16]=A,t}}ts.prototype.bytesPerElement=68,Hn("StructArrayLayout8i15ui1ul2f2ui1f68",ts);class es extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}es.prototype.bytesPerElement=4,Hn("StructArrayLayout1f4",es);class is extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[6*t+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}is.prototype.bytesPerElement=12,Hn("StructArrayLayout1ui2f12",is);class rs extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=4*t;return this.uint32[2*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,t}}rs.prototype.bytesPerElement=8,Hn("StructArrayLayout1ul2ui8",rs);class ns extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}ns.prototype.bytesPerElement=4,Hn("StructArrayLayout2ui4",ns);class os extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}os.prototype.bytesPerElement=2,Hn("StructArrayLayout1ui2",os);class ss extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,t}}ss.prototype.bytesPerElement=16,Hn("StructArrayLayout4f16",ss);class as extends Do{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 l(this.anchorPointX,this.anchorPointY)}}as.prototype.size=20;class ls extends Ho{get(t){return new as(this,t)}}Hn("CollisionBoxArray",ls);class cs extends Do{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(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}cs.prototype.size=48;class hs extends Qo{get(t){return new cs(this,t)}}Hn("PlacedSymbolArray",hs);class us extends Do{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(t){this._structArray.uint32[this._pos4+12]=t}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]}get angle(){return this._structArray.float32[this._pos4+16]}set angle(t){this._structArray.float32[this._pos4+16]=t}}us.prototype.size=68;class ds extends ts{get(t){return new us(this,t)}}Hn("SymbolInstanceArray",ds);class ps extends es{getoffsetX(t){return this.float32[1*t+0]}}Hn("GlyphOffsetArray",ps);class fs extends jo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Hn("SymbolLineVertexArray",fs);class ms extends Do{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]}}ms.prototype.size=12;class gs extends is{get(t){return new ms(this,t)}}Hn("TextAnchorOffsetArray",gs);class _s extends Do{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]}}_s.prototype.size=8;class ys extends rs{get(t){return new _s(this,t)}}Hn("FeatureIndexArray",ys);class xs extends Oo{}class vs extends Oo{}class bs extends Oo{}class ws extends Vo{}class Ts extends Uo{}class Ps extends Zo{}class Ms extends $o{}class Ss extends Go{}class Cs extends qo{}class Is extends Wo{}class As extends Xo{}class Es extends Yo{}class ks extends Jo{}class zs extends ns{}const Ls=Fo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ds}=Ls;class Rs{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,e,i,r){const n=this.segments[this.segments.length-1];return t>Rs.MAX_VERTEX_ARRAY_LENGTH&&Z(`Max vertices per segment is ${Rs.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Rs.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Rs.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(e,i,r):n}createNewSegment(t,e,i){const r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new Rs([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function Fs(t,e){return 256*(t=R(Math.floor(t),0,255))+R(Math.floor(e),0,255)}Rs.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Hn("SegmentVector",Rs);const Bs=Fo([{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 Os,js,Ns,Vs={exports:{}},Us={exports:{}},Zs={exports:{}},$s=function(){if(Ns)return Vs.exports;Ns=1;var t=(Os||(Os=1,Us.exports=function(t,e){var i,r,n,o,s,a,l,c;for(r=t.length-(i=3&t.length),n=e,s=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),Us.exports),e=(js||(js=1,Zs.exports=function(t,e){for(var i,r=t.length,n=e^r,o=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&t.charCodeAt(o+2))<<16;case 2:n^=(255&t.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),Zs.exports);return Vs.exports=t,Vs.exports.murmur3=t,Vs.exports.murmur2=e,Vs.exports}(),Gs=i($s);class qs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Ws(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Ws(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Hs(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new qs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Ws(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Gs(String(t))}function Hs(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(t[o]<n);do{s--}while(t[s]>n);if(o>=s)break;Xs(t,o,s),Xs(e,3*o,3*s),Xs(e,3*o+1,3*s+1),Xs(e,3*o+2,3*s+2)}s-i<r-s?(Hs(t,e,i,s),i=s+1):(Hs(t,e,s+1,r),r=s)}}function Xs(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Hn("FeaturePositionMap",qs);class Ks{constructor(t,e){this.gl=t.gl,this.location=e}}class Ys extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Js extends Ks{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Qs extends Ks{constructor(t,e){super(t,e),this.current=ve.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const ta=new Float32Array(16);function ea(t){return[Fs(255*t.r,255*t.g),Fs(255*t.b,255*t.a)]}class ia{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Qs(t,e):new Ys(t,e)}}class ra{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,i,r){const n="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new Js(t,e):new Ys(t,e)}}class na{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n){const o=this.paintVertexArray.length,s=this.expression.evaluate(new go(0),e,{},r,[],n);this.paintVertexArray.resize(t),this._setPaintValue(o,t,s)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){const r=ea(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class oa{constructor(t,e,i,r,n,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,r,n){const o=this.expression.evaluate(new go(this.zoom),e,{},r,[],n),s=this.expression.evaluate(new go(this.zoom+1),e,{},r,[],n),a=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(a,t,o,s)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:this.zoom},i,r),o=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,n,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=ea(i),o=ea(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=R(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Ys(t,e)}}class sa{constructor(t,e,i,r,n,o){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=o,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],n)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:o,max:s}=i,a=r[n],l=r[o],c=r[s];if(a&&l&&c)for(let i=t;i<e;i++)this.zoomInPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],a.tl[0],a.tl[1],a.br[0],a.br[1],l.pixelRatio,a.pixelRatio),this.zoomOutPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],c.tl[0],c.tl[1],c.br[0],c.br[1],l.pixelRatio,c.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Bs.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Bs.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class aa{constructor(t,e,i){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const o=t.paint.get(n);if(!(o instanceof To&&zr(o.property.specification)))continue;const s=ca(n,t.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===a.kind)this.binders[n]=u?new ra(a.value,s):new ia(a.value,s,l),r.push(`/u_${n}`);else if("source"===a.kind||u){const i=ha(n,l,"source");this.binders[n]=u?new sa(a,l,c,e,i,t.id):new na(a,s,l,i),r.push(`/a_${n}`)}else{const t=ha(n,l,"composite");this.binders[n]=new oa(a,s,l,c,e,t),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof na||e instanceof oa?e.maxValue:0}populatePaintArrays(t,e,i,r,n){for(const o in this.binders){const s=this.binders[o];(s instanceof na||s instanceof oa||s instanceof sa)&&s.populatePaintArray(t,e,i,r,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof ra&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n){let o=!1;for(const s in t){const a=e.getPositions(s);for(const e of a){const a=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof na||l instanceof oa||l instanceof sa)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,a,t[s],n),o=!0}}}}return o}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof ia||i instanceof ra)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof na||i instanceof oa)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof sa)for(let e=0;e<Bs.members.length;e++)t.push(Bs.members[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof ia||i instanceof ra||i instanceof oa)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof ia||n instanceof ra||n instanceof oa)for(const o of n.uniformNames)if(e[o]){const s=n.getBinding(t,e[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:o}of e)this.binders[n].setUniform(o,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof sa){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof na||i instanceof oa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof na||i instanceof oa||i instanceof sa)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof na||e instanceof oa||e instanceof sa)&&e.destroy()}}}class la{constructor(t,e,i=()=>!0){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new aa(r,e,i);this.needsUpload=!1,this._featureMap=new qs,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,o);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function ca(t,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"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function ha(t,e,i){const r={color:{source:Zo,composite:ss},number:{source:es,composite:Zo}},n=function(t){return{"line-pattern":{source:Ms,composite:Ms},"fill-pattern":{source:Ms,composite:Ms},"fill-extrusion-pattern":{source:Ms,composite:Ms}}[t]}(t);return n&&n[i]||r[e][i]}Hn("ConstantBinder",ia),Hn("CrossFadedConstantBinder",ra),Hn("SourceExpressionBinder",na),Hn("CrossFadedCompositeBinder",sa),Hn("CompositeExpressionBinder",oa),Hn("ProgramConfiguration",aa,{omit:["_buffers"]}),Hn("ProgramConfigurationSet",la);const ua=Math.pow(2,14)-1,da=-ua-1;function pa(t){const e=I/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],n=Math.round(i.x*e),o=Math.round(i.y*e);i.x=R(n,da,ua),i.y=R(o,da,ua),(n<i.x||n>i.x+1||o<i.y||o>i.y+1)&&Z("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function fa(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?pa(t):[]}}const ma=-32768;function ga(t,e,i,r,n){t.emplaceBack(ma+8*e+r,ma+8*i+n)}class _a{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new vs,this.indexArray=new ks,this.segments=new Rs,this.programConfigurations=new la(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],n=[];let o=null,s=!1,a="heatmap"===r.type;if("circle"===r.type){const t=r;o=t.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===t.paint.get("circle-pitch-alignment")}const l=a?e.subdivisionGranularity.circle:1;for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=fa(e,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),c,i))continue;const h=s?o.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:pa(e),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r,a=t[o].feature;this.addFeature(r,n,o,i,l),e.featureIndex.insert(a,n,o,s,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ds),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r,n=1){let o;switch(n){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=I||r<0||r>=I)continue;const n=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,t.sortKey),a=n.vertexLength;for(let t=0;t<s;t++)for(let e=0;e<s;e++)ga(this.layoutVertexArray,i,r,o[e],o[t]);for(let t=0;t<s-1;t++)for(let e=0;e<s-1;e++){const i=a+t*s+e,r=a+(t+1)*s+e;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=s*s,n.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function ya(t,e){for(let i=0;i<t.length;i++)if(Ca(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ca(t,e[i]))return!0;return!!wa(t,e)}function xa(t,e,i){return!!Ca(t,e)||!!Pa(e,t,i)}function va(t,e){if(1===t.length)return Sa(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(Ca(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(Sa(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(wa(t,e[i]))return!0;return!1}function ba(t,e,i){if(t.length>1){if(wa(t,e))return!0;for(let r=0;r<e.length;r++)if(Pa(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Pa(t[r],e,i))return!0;return!1}function wa(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(Ta(r,n,e[t],e[t+1]))return!0}return!1}function Ta(t,e,i,r){return $(t,i,r)!==$(e,i,r)&&$(t,e,i)!==$(t,e,r)}function Pa(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Ma(t,e[i-1],e[i])<r)return!0;return!1}function Ma(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function Sa(t,e){for(let i=0;i<t.length;i++)if(Ca(t[i],e))return!0;return!1}function Ca(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const o=t[r],s=t[n];o.y>e.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Ia(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const o=$(t,e,i[0]);return o!==$(t,e,i[1])||o!==$(t,e,i[2])||o!==$(t,e,i[3])}function Aa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Ea(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ka(t,e,i,r,n){if(!e[0]&&!e[1])return t;const o=l.convert(e)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(o));return s}let za,La;Hn("CircleBucket",_a,{omit:["layers"]});var Da={get paint(){return La=La||new Eo({"circle-radius":new So(gt.paint_circle["circle-radius"]),"circle-color":new So(gt.paint_circle["circle-color"]),"circle-blur":new So(gt.paint_circle["circle-blur"]),"circle-opacity":new So(gt.paint_circle["circle-opacity"]),"circle-translate":new Mo(gt.paint_circle["circle-translate"]),"circle-translate-anchor":new Mo(gt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Mo(gt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Mo(gt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new So(gt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new So(gt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new So(gt.paint_circle["circle-stroke-opacity"])})},get layout(){return za=za||new Eo({"circle-sort-key":new So(gt.layout_circle["circle-sort-key"])})}};class Ra extends zo{constructor(t){super(t,Da)}createBucket(t){return new _a(t)}queryRadius(t){const e=t;return Aa("circle-radius",this,e)+Aa("circle-stroke-width",this,e)+Ea(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){const l=ka(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,o),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e,i,r){return t.map((t=>Fa(t,e,i,r)))}(l,n,s,a),d=h?c*o:c;for(const t of r)for(const e of t){const t=h?e:Fa(e,n,s,a);let i=d;const r=n.projectTileCoordinates(e.x,e.y,s,a).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r),xa(u,t,i))return!0}return!1}}function Fa(t,e,i,r){const n=e.projectTileCoordinates(t.x,t.y,i,r).point;return new l((.5*n.x+.5)*e.width,(.5*-n.y+.5)*e.height)}class Ba extends _a{}let Oa;Hn("HeatmapBucket",Ba,{omit:["layers"]});var ja={get paint(){return Oa=Oa||new Eo({"heatmap-radius":new So(gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new So(gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Mo(gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ao(gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Mo(gt.paint_heatmap["heatmap-opacity"])})}};function Na(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${e*i*r}`)}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Va(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const n=Na({},{width:e,height:i},r);Ua(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=n.data}function Ua(t,e,i,r,n,o){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*o,h=((r.y+l)*e.width+r.x)*o;for(let t=0;t<n.width*o;t++)a[h+t]=s[c+t]}return e}class Za{constructor(t,e){Na(this,t,1,e)}resize(t){Va(this,t,1)}clone(){return new Za({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ua(t,e,i,r,n,1)}}class $a{constructor(t,e){Na(this,t,4,e)}resize(t){Va(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new $a({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ua(t,e,i,r,n,4)}}function Ga(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new $a({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const o=(i,r,o)=>{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];o(n,s,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)o(0,e,t/(i-1));return n}Hn("AlphaImage",Za),Hn("RGBAImage",$a);const qa="big-fb";class Wa extends zo{createBucket(t){return new Ba(t)}constructor(t){super(t,ja),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ga({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(qa)&&this.heatmapFbos.delete(qa)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}}let Ha;var Xa={get paint(){return Ha=Ha||new Eo({"hillshade-illumination-direction":new Mo(gt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Mo(gt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Mo(gt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Mo(gt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Mo(gt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Mo(gt.paint_hillshade["hillshade-accent-color"])})}};class Ka extends zo{constructor(t){super(t,Xa)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}}const Ya=Fo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ja}=Ya;function Qa(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const o=e.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function tl(t,e,i,r,n){const o=n.patternDependencies;for(const s of e){const e=s.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),a=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[s.id]={min:t,mid:a,max:l}}}return i}function el(t,e,i,r,n){let o;if(n===function(t,e,i,r){let n=0;for(let o=e,s=i-r;o<i;o+=r)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}(t,e,i,r)>0)for(let n=e;n<i;n+=r)o=Tl(n/r|0,t[n],t[n+1],o);else for(let n=i-r;n>=e;n-=r)o=Tl(n/r|0,t[n],t[n+1],o);return o&&_l(o,o.next)&&(Pl(o),o=o.next),o}function il(t,e){if(!t)return t;e||(e=t);let i,r=t;do{if(i=!1,r.steiner||!_l(r,r.next)&&0!==gl(r.prev,r,r.next))r=r.next;else{if(Pl(r),r=e=r.prev,r===r.next)break;i=!0}}while(i||r!==e);return e}function rl(t,e,i,r,n,o,s){if(!t)return;!s&&o&&function(t,e,i,r){let n=t;do{0===n.z&&(n.z=ul(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let e,i=1;do{let r,n=t;t=null;let o=null;for(e=0;n;){e++;let s=n,a=0;for(let t=0;t<i&&(a++,s=s.nextZ,s);t++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(e>1)}(n)}(t,r,n,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?ol(t,r,n,o):nl(t))e.push(l.i,t.i,c.i),Pl(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?rl(t=sl(il(t),e),e,i,r,n,o,2):2===s&&al(t,e,i,r,n,o):rl(il(t),e,i,r,n,o,1);break}}}function nl(t){const e=t.prev,i=t,r=t.next;if(gl(e,i,r)>=0)return!1;const n=e.x,o=i.x,s=r.x,a=e.y,l=i.y,c=r.y,h=Math.min(n,o,s),u=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&fl(n,a,o,l,s,c,f.x,f.y)&&gl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ol(t,e,i,r){const n=t.prev,o=t,s=t.next;if(gl(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(h,u,d),m=Math.max(a,l,c),g=Math.max(h,u,d),_=ul(p,f,e,i,r),y=ul(m,g,e,i,r);let x=t.prevZ,v=t.nextZ;for(;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&fl(a,h,l,u,c,d,x.x,x.y)&&gl(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&fl(a,h,l,u,c,d,v.x,v.y)&&gl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&fl(a,h,l,u,c,d,x.x,x.y)&&gl(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&fl(a,h,l,u,c,d,v.x,v.y)&&gl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function sl(t,e){let i=t;do{const r=i.prev,n=i.next.next;!_l(r,n)&&yl(r,i,i.next,n)&&bl(r,n)&&bl(n,r)&&(e.push(r.i,i.i,n.i),Pl(i),Pl(i.next),i=t=n),i=i.next}while(i!==t);return il(i)}function al(t,e,i,r,n,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&ml(s,t)){let a=wl(s,t);return s=il(s,s.next),a=il(a,a.next),rl(s,e,i,r,n,o,0),void rl(a,e,i,r,n,o,0)}t=t.next}s=s.next}while(s!==t)}function ll(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function cl(t,e){const i=function(t,e){let i=e;const r=t.x,n=t.y;let o,s=-1/0;if(_l(t,i))return i;do{if(_l(t,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=r&&t>s&&(s=t,o=i.x<i.next.x?i:i.next,t===r))return o}i=i.next}while(i!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;i=o;do{if(r>=i.x&&i.x>=l&&r!==i.x&&pl(n<c?r:s,n,l,c,n<c?s:r,n,i.x,i.y)){const e=Math.abs(n-i.y)/(r-i.x);bl(i,t)&&(e<h||e===h&&(i.x>o.x||i.x===o.x&&hl(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const r=wl(i,t);return il(r,r.next),il(i,i.next)}function hl(t,e){return gl(t.prev,t,e.prev)<0&&gl(e.next,t,t.next)<0}function ul(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function dl(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function pl(t,e,i,r,n,o,s,a){return(n-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(r-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function fl(t,e,i,r,n,o,s,a){return!(t===s&&e===a)&&pl(t,e,i,r,n,o,s,a)}function ml(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&yl(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(bl(t,e)&&bl(e,t)&&function(t,e){let i=t,r=!1;const n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(gl(t.prev,t,e.prev)||gl(t,e.prev,e))||_l(t,e)&&gl(t.prev,t,t.next)>0&&gl(e.prev,e,e.next)>0)}function gl(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function _l(t,e){return t.x===e.x&&t.y===e.y}function yl(t,e,i,r){const n=vl(gl(t,e,i)),o=vl(gl(t,e,r)),s=vl(gl(i,r,t)),a=vl(gl(i,r,e));return n!==o&&s!==a||!(0!==n||!xl(t,i,e))||!(0!==o||!xl(t,r,e))||!(0!==s||!xl(i,t,r))||!(0!==a||!xl(i,e,r))}function xl(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function vl(t){return t>0?1:t<0?-1:0}function bl(t,e){return gl(t.prev,t,t.next)<0?gl(t,e,t.next)>=0&&gl(t,t.prev,e)>=0:gl(t,e,t.prev)<0||gl(t,t.next,e)<0}function wl(t,e){const i=Ml(t.i,t.x,t.y),r=Ml(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Tl(t,e,i,r){const n=Ml(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Pl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ml(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Sl{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class Cl{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}Cl.noSubdivision=new Cl({fill:new Sl(0,0),line:new Sl(0,0),tile:new Sl(0,0),stencil:new Sl(0,0),circle:1}),Hn("SubdivisionGranularityExpression",Sl),Hn("SubdivisionGranularitySetting",Cl);const Il=-32768,Al=32767;class El{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=I/t,this._canonical=e}_getKey(t,e){return(t+=32768)<<16|(e+=32768)}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(t),r=0|Math.round(e),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const i=[];for(let r=0;r<e.length;r+=3){const n=e[r],o=e[r+1],s=e[r+2],a=t[2*n],l=t[2*n+1];(t[2*o]-a)*(t[2*s+1]-l)-(t[2*o+1]-l)*(t[2*s]-a)>0?(i.push(n),i.push(s),i.push(o)):(i.push(n),i.push(o),i.push(s))}return i}(this._vertexBuffer,t);const e=[],i=t.length;for(let r=0;r<i;r+=3){const i=[t[r+0],t[r+1],t[r+2]],n=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]];let o=1/0,s=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){const e=n[2*t],i=n[2*t+1];o=Math.min(o,e),a=Math.max(a,e),s=Math.min(s,i),l=Math.max(l,i)}if(o===a||s===l)continue;const c=Math.floor(o/this._granularityCellSize),h=Math.ceil(a/this._granularityCellSize),u=Math.floor(s/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(c!==h||u!==d)for(let t=u;t<d;t++){const r=this._scanlineGenerateVertexRingForCellRow(t,n,i);Ll(this._vertexBuffer,r,e)}else e.push(...i)}return e}_scanlineGenerateVertexRingForCellRow(t,e,i){const r=t*this._granularityCellSize,n=r+this._granularityCellSize,o=[];for(let t=0;t<3;t++){const s=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],c=e[(2*(t+1)+1)%6],h=e[2*(t+2)%6],u=e[(2*(t+2)+1)%6],d=l-s,p=c-a,f=0===d,m=0===p,g=(r-a)/p,_=(n-a)/p,y=Math.min(g,_),x=Math.max(g,_);if(!m&&(y>=1||x<=0)||m&&(a<r||a>n)){c>=r&&c<=n&&o.push(i[(t+1)%3]);continue}!m&&y>0&&o.push(this._vertexToIndex(s+d*y,a+p*y));const v=s+d*Math.max(y,0),b=s+d*Math.min(x,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,b),!m&&x<1&&o.push(this._vertexToIndex(s+d*x,a+p*x)),(m||c>=r&&c<=n)&&o.push(i[(t+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(o,s,a,l,c,h,u,b,r,n)}return o}_generateIntraEdgeVertices(t,e,i,r,n,o,s){const a=r-e,l=n-i,c=0===l,h=c?Math.min(e,r):Math.min(o,s),u=c?Math.max(e,r):Math.max(o,s),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(u/this._granularityCellSize)-1;if(c?e<r:o<s)for(let r=d;r<=p;r++){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}else for(let r=p;r>=d;r--){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}}_generateInterEdgeVertices(t,e,i,r,n,o,s,a,l,c){const h=n-i,u=o-r,d=s-n,p=(l-n)/d,f=(c-n)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+u*m;let y=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const b=0===d;if(b&&(s===l||s===c))return;if(b||m>=1||g<=0){const t=i-s,r=o+(e-o)*Math.min((l-s)/t,(c-s)/t);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,v=a<r}const w=h>0?c:l;if(v)for(let e=y;e<=x;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,w));else for(let e=x;e>=y;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,w))}_generateOutline(t){const e=[];for(const i of t){const t=zl(i,this._granularity,!0),r=this._pointArrayToIndices(t),n=[];for(let t=1;t<r.length;t++)n.push(r[t-1]),n.push(r[t]);e.push(n)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){const i=t[e+1];i===Il&&(t[e+1]=-32767),i===Al&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,r,n,o){r>n!=(o===Il)?(t.push(e),t.push(i),t.push(this._vertexToIndex(r,o)),t.push(i),t.push(this._vertexToIndex(n,o)),t.push(this._vertexToIndex(r,o))):(t.push(i),t.push(e),t.push(this._vertexToIndex(r,o)),t.push(this._vertexToIndex(n,o)),t.push(i),t.push(this._vertexToIndex(r,o)))}_fillPoles(t,e,i){const r=this._vertexBuffer,n=I,o=t.length;for(let s=2;s<o;s+=3){const o=t[s-2],a=t[s-1],l=t[s],c=r[2*o],h=r[2*o+1],u=r[2*a],d=r[2*a+1],p=r[2*l],f=r[2*l+1];e&&(0===h&&0===d&&this._generatePoleQuad(t,o,a,c,u,Il),0===d&&0===f&&this._generatePoleQuad(t,a,l,u,p,Il),0===f&&0===h&&this._generatePoleQuad(t,l,o,p,c,Il)),i&&(h===n&&d===n&&this._generatePoleQuad(t,o,a,c,u,Al),d===n&&f===n&&this._generatePoleQuad(t,a,l,u,p,Al),f===n&&h===n&&this._generatePoleQuad(t,l,o,p,c,Al))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:r}=function(t){const e=[],i=[];for(const r of t)if(0!==r.length){r!==t[0]&&e.push(i.length/2);for(let t=0;t<r.length;t++)i.push(r[t].x),i.push(r[t].y)}return{flattened:i,holeIndices:e}}(t);let n;this._initializeVertices(i);try{const t=function(t,e,i=2){const r=e&&e.length,n=r?e[0]*i:t.length;let o=el(t,0,n,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(r&&(o=function(t,e,i,r){const n=[];for(let i=0,o=e.length;i<o;i++){const s=el(t,e[i]*r,i<o-1?e[i+1]*r:t.length,r,!1);s===s.next&&(s.steiner=!0),n.push(dl(s))}n.sort(ll);for(let t=0;t<n.length;t++)i=cl(n[t],i);return i}(t,e,o,i)),t.length>80*i){a=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=i;o<n;o+=i){const i=t[o],n=t[o+1];i<a&&(a=i),n<l&&(l=n),i>e&&(e=i),n>r&&(r=n)}c=Math.max(e-a,r-l),c=0!==c?32767/c:0}return rl(o,s,i,a,l,c,0),s}(i,r),e=this._convertIndices(i,t);n=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let o=[];return e&&(o=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_convertIndices(t,e){const i=[];for(let r=0;r<e.length;r++)i.push(this._vertexToIndex(t[2*e[r]],t[2*e[r]+1]));return i}_pointArrayToIndices(t){const e=[];for(let i=0;i<t.length;i++){const r=t[i];e.push(this._vertexToIndex(r.x,r.y))}return e}}function kl(t,e,i,r=!0){return new El(i,e).subdividePolygonInternal(t,r)}function zl(t,e,i=!1){if(!t||t.length<1)return[];if(t.length<2)return[];const r=t[0],n=t[t.length-1],o=i&&(r.x!==n.x||r.y!==n.y);if(e<2)return o?[...t,t[0]]:[...t];const s=Math.floor(I/e),a=[];a.push(new l(t[0].x,t[0].y));const c=t.length,h=o?c:c-1;for(let e=0;e<h;e++){const i=t[e],r=e<c-1?t[e+1]:t[0],n=i.x,o=i.y,h=r.x,u=r.y,d=n!==h,p=o!==u;if(!d&&!p)continue;const f=h-n,m=u-o,g=Math.abs(f),_=Math.abs(m);let y=n,x=o;for(;;){const t=f>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,e=m>0?(Math.floor(x/s)+1)*s:(Math.ceil(x/s)-1)*s,i=Math.abs(y-t),r=Math.abs(x-e),n=Math.abs(y-h),o=Math.abs(x-u),c=d?i/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((n<=i||!d)&&(o<=r||!p))break;if(c<v&&d||!p){y=t,x+=m*c;const e=new l(y,Math.round(x));a[a.length-1].x===e.x&&a[a.length-1].y===e.y||a.push(e)}else{y+=f*v,x=e;const t=new l(Math.round(y),x);a[a.length-1].x===t.x&&a[a.length-1].y===t.y||a.push(t)}}const v=new l(h,u);a[a.length-1].x===v.x&&a[a.length-1].y===v.y||a.push(v)}return a}function Ll(t,e,i){if(0===e.length)throw new Error("Subdivision vertex ring is empty.");let r=0,n=t[2*e[0]];for(let i=1;i<e.length;i++){const o=t[2*e[i]];o<n&&(n=o,r=i)}const o=e.length;let s=r,a=(s+1)%o;for(;;){const r=s-1>=0?s-1:o-1,n=(a+1)%o,l=t[2*e[r]],c=t[2*e[n]],h=t[2*e[s]],u=t[2*e[s]+1],d=t[2*e[a]+1];let p=!1;if(l<c)p=!0;else if(l>c)p=!1;else{const i=d-u,o=-(t[2*e[a]]-h),s=u<d?1:-1;((l-h)*i+(t[2*e[r]+1]-u)*o)*s>((c-h)*i+(t[2*e[n]+1]-u)*o)*s&&(p=!0)}if(p){const t=e[r],n=e[s],l=e[a];t!==n&&t!==l&&n!==l&&i.push(l,n,t),s--,s<0&&(s=o-1)}else{const t=e[n],r=e[s],l=e[a];t!==r&&t!==l&&r!==l&&i.push(l,r,t),a++,a>=o&&(a=0)}if(r===n)break}}function Dl(t,e,i,r,n,o,s,a,l){const c=n.length/2,h=s&&a&&l;if(c<Rs.MAX_VERTEX_ARRAY_LENGTH){const u=e.prepareSegment(c,i,r),d=u.vertexLength;for(let t=0;t<o.length;t+=3)r.emplaceBack(d+o[t],d+o[t+1],d+o[t+2]);let p,f;u.vertexLength+=c,u.primitiveLength+=o.length/3,h&&(f=s.prepareSegment(c,i,a),p=f.vertexLength,f.vertexLength+=c);for(let e=0;e<n.length;e+=2)t(n[e],n[e+1]);if(h)for(let t=0;t<l.length;t++){const e=l[t];for(let t=1;t<e.length;t+=2)a.emplaceBack(p+e[t-1],p+e[t]);f.primitiveLength+=e.length/2}}else!function(t,e,i,r,n,o){const s=[];for(let t=0;t<r.length/2;t++)s.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=2;u<n.length;u+=3){const d=n[u-2],p=n[u-1],f=n[u];let m=s[d]<l,g=s[p]<l,_=s[f]<l;c.vertexLength+((m?1:0)+(g?1:0)+(_?1:0))>Rs.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,m=!0,g=!0,_=!0,h=0);const y=Rl(s,r,o,a,d,m,c),x=Rl(s,r,o,a,p,g,c),v=Rl(s,r,o,a,f,_,c);i.emplaceBack(h+y-l,h+x-l,h+v-l),c.primitiveLength++}}(e,i,r,n,o,t),h&&function(t,e,i,r,n,o){const s=[];for(let t=0;t<r.length/2;t++)s.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=0;u<n.length;u++){const d=n[u];for(let p=1;p<n[u].length;p+=2){const n=d[p-1],u=d[p];let f=s[n]<l,m=s[u]<l;c.vertexLength+((f?1:0)+(m?1:0))>Rs.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,f=!0,m=!0,h=0);const g=Rl(s,r,o,a,n,f,c),_=Rl(s,r,o,a,u,m,c);i.emplaceBack(h+g-l,h+_-l),c.primitiveLength++}}}(s,i,a,n,l,t),e.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Rl(t,e,i,r,n,o,s){if(o){const o=r.count;return i(e[2*n],e[2*n+1]),t[n]=r.count,r.count++,s.vertexLength++,o}return t[n]}class Fl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new bs,this.indexArray=new ks,this.indexArray2=new zs,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.segments2=new Rs,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qa("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=fa(s,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:pa(s),patterns:{},sortKey:u};o.push(d)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=tl("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[o].feature,n,o,s,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ja),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,e,i,r,n,o){for(const t of Gi(e,500)){const e=kl(t,r,o.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;Dl(((t,e)=>{i.emplaceBack(t,e)}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}}let Bl,Ol;Hn("FillBucket",Fl,{omit:["layers","patternFeatures"]});var jl={get paint(){return Ol=Ol||new Eo({"fill-antialias":new Mo(gt.paint_fill["fill-antialias"]),"fill-opacity":new So(gt.paint_fill["fill-opacity"]),"fill-color":new So(gt.paint_fill["fill-color"]),"fill-outline-color":new So(gt.paint_fill["fill-outline-color"]),"fill-translate":new Mo(gt.paint_fill["fill-translate"]),"fill-translate-anchor":new Mo(gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Co(gt.paint_fill["fill-pattern"])})},get layout(){return Bl=Bl||new Eo({"fill-sort-key":new So(gt.layout_fill["fill-sort-key"])})}};class Nl extends zo{constructor(t){super(t,jl)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Fl(t)}queryRadius(){return Ea(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return va(ka(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}}const Vl=Fo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ul=Fo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Zl}=Vl;var $l,Gl,ql,Wl,Hl,Xl,Kl,Yl={};function Jl(){if(Gl)return $l;Gl=1;var t=o();function e(t,e,r,n,o){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=o,t.readFields(i,this,e)}function i(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function r(t){for(var e,i,r=0,n=0,o=t.length,s=o-1;n<o;s=n++)r+=((i=t[s]).x-(e=t[n]).x)*(e.y+i.y);return r}return $l=e,e.types=["Unknown","Point","LineString","Polygon"],e.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var i,r=e.readVarint()+e.pos,n=1,o=0,s=0,a=0,l=[];e.pos<r;){if(o<=0){var c=e.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==n)throw new Error("unknown command "+n);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=t.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+l)/a-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+c)/a)*Math.PI/180))-90]}}switch(this.type){case 1:var p=[];for(o=0;o<h.length;o++)p[o]=h[o][0];d(h=p);break;case 2:for(o=0;o<h.length;o++)d(h[o]);break;case 3:for(h=function(t){var e=t.length;if(e<=1)return[t];for(var i,n,o=[],s=0;s<e;s++){var a=r(t[s]);0!==a&&(void 0===n&&(n=a<0),n===a<0?(i&&o.push(i),i=[t[s]]):i.push(t[s]))}return i&&o.push(i),o}(h),o=0;o<h.length;o++)for(s=0;s<h[o].length;s++)d(h[o][s])}1===h.length?h=h[0]:u="Multi"+u;var f={type:"Feature",geometry:{type:u,coordinates:h},properties:this.properties};return"id"in this&&(f.id=this.id),f},$l}function Ql(){if(Wl)return ql;Wl=1;var t=Jl();function e(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(i,this,e),this.length=this._features.length}function i(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}return ql=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},ql}function tc(){return Kl||(Kl=1,Yl.VectorTile=function(){if(Xl)return Hl;Xl=1;var t=Ql();function e(e,i,r){if(3===e){var n=new t(r,r.readVarint()+r.pos);n.length&&(i[n.name]=n)}}return Hl=function(t,i){this.layers=t.readFields(e,{},i)},Hl}(),Yl.VectorTileFeature=Jl(),Yl.VectorTileLayer=Ql()),Yl}var ec=i(tc());const ic=ec.VectorTileFeature.types,rc=Math.pow(2,13);function nc(t,e,i,r,n,o,s,a){t.emplaceBack(e,i,2*Math.floor(r*rc)+s,n*rc*2,o*rc*2,Math.round(a))}class oc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ws,this.centroidVertexArray=new xs,this.indexArray=new ks,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=Qa("fill-extrusion",this.layers,e);for(const{feature:r,id:n,index:o,sourceLayerIndex:s}of t){const t=this.layers[0]._featureFilter.needGeometry,a=fa(r,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:s,index:o,geometry:t?a.geometry:pa(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(tl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,o,i,{},e.subdivisionGranularity),e.featureIndex.insert(r,l.geometry,o,s,this.index,!0)}}addFeatures(t,e,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,r.index,e,i,t.subdivisionGranularity)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Zl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ul.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,n,o){for(const i of Gi(e,500)){const e={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(e,r,t,i,o);const s=this.layoutVertexArray.length-n,a=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t<s;t++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}processPolygon(t,e,i,r,n){if(r.length<1)return;if(lc(r[0]))return;for(const e of r)0!==e.length&&sc(t,e);const o={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=n.fill.getGranularityForZoomLevel(e.z),a="Polygon"===ic[i.type];for(const t of r){if(0===t.length)continue;if(lc(t))continue;const e=zl(t,s,a);this._generateSideFaces(e,o)}if(!a)return;const l=kl(r,e,s,!1),c=this.layoutVertexArray;Dl(((t,e)=>{nc(c,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let r=1;r<t.length;r++){const n=t[r],o=t[r-1];if(ac(n,o))continue;e.segment.vertexLength+4>Rs.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=n.sub(o)._perp()._unit(),a=o.dist(n);i+a>32768&&(i=0),nc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,i),nc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,i),i+=a,nc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),nc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}}function sc(t,e){for(let i=0;i<e.length;i++){const r=e[i];i===e.length-1&&e[0].x===r.x&&e[0].y===r.y||(t.x+=r.x,t.y+=r.y,t.sampleCount++)}}function ac(t,e){return t.x===e.x&&(t.x<0||t.x>I)||t.y===e.y&&(t.y<0||t.y>I)}function lc(t){return t.every((t=>t.x<0))||t.every((t=>t.x>I))||t.every((t=>t.y<0))||t.every((t=>t.y>I))}let cc;Hn("FillExtrusionBucket",oc,{omit:["layers","features"]});var hc={get paint(){return cc=cc||new Eo({"fill-extrusion-opacity":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new So(gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Co(gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new So(gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new So(gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class uc extends zo{constructor(t){super(t,hc)}createBucket(t){return new oc(t)}queryRadius(){return Ea(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,pixelPosMatrix:s}){const a=ka(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,o),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e){const i=[];for(const r of t){const t=[r.x,r.y,0,1];P(t,t,e),i.push(new l(t[0]/t[3],t[1]/t[3]))}return i}(a,s),d=function(t,e,i,r){const n=[],o=[],s=r[8]*e,a=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const n of e){const e=n.x,o=n.y,m=r[0]*e+r[4]*o+r[12],g=r[1]*e+r[5]*o+r[13],_=r[2]*e+r[6]*o+r[14],y=r[3]*e+r[7]*o+r[15],x=_+c,v=y+h,b=m+u,w=g+d,T=_+p,P=y+f,M=new l((m+s)/v,(g+a)/v);M.z=x/v,t.push(M);const S=new l(b/P,w/P);S.z=T/P,i.push(S)}n.push(t),o.push(i)}return[n,o]}(r,h,c,s);return function(t,e,i){let r=1/0;va(i,e)&&(r=pc(i,e[0]));for(let n=0;n<e.length;n++){const o=e[n],s=t[n];for(let t=0;t<o.length-1;t++){const e=o[t],n=[e,o[t+1],s[t+1],s[t],e];ya(i,n)&&(r=Math.min(r,pc(i,n)))}}return r!==1/0&&r}(d[0],d[1],u)}}function dc(t,e){return t.x*e.x+t.y*e.y}function pc(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const o=e[i],s=t[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=dc(a,a),u=dc(a,l),d=dc(l,l),p=dc(c,a),f=dc(c,l),m=h*d-u*u,g=(d*p-u*f)/m,_=(h*f-u*p)/m,y=r.z*(1-g-_)+n.z*g+o.z*_;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const fc=Fo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:mc}=fc,gc=Fo([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:_c}=gc,yc=ec.VectorTileFeature.types,xc=Math.cos(Math.PI/180*37.5),vc=Math.pow(2,14)/.5;class bc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Ts,this.layoutVertexArray2=new Ps,this.indexArray=new ks,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qa("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),o=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=fa(e,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),c,i))continue;const h=n?r.evaluate(c,{},i):void 0,u={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:pa(e),patterns:{},sortKey:h};o.push(u)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=tl("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[o].feature,n,o,s,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,_c)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,mc),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap"),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,h,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}addLine(t,e,i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=zl(t,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const l="Polygon"===yc[e.type];let c=t.length;for(;c>=2&&t[c-1].equals(t[c-2]);)c--;let h=0;for(;h<c-1&&t[h].equals(t[h+1]);)h++;if(c<(l?3:2))return;"bevel"===i&&(n=1.05);const u=this.overscaling<=16?15*I/(512*this.overscaling):0,d=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let p,f,m,g,_;this.e1=this.e2=-1,l&&(p=t[c-2],_=t[h].sub(p)._unit()._perp());for(let e=h;e<c;e++){if(m=e===c-1?l?t[h+1]:void 0:t[e+1],m&&t[e].equals(m))continue;_&&(g=_),p&&(f=p),p=t[e],_=m?m.sub(p)._unit()._perp():g,g=g||_;let s=g.add(_);0===s.x&&0===s.y||s._unit();const a=g.x*_.x+g.y*_.y,y=s.x*_.x+s.y*_.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<xc&&f&&m,w=g.x*_.y-g.y*_.x>0;if(b&&e>h){const t=p.dist(f);if(t>2*u){const e=p.sub(p.sub(f)._mult(u/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,d),f=e}}const T=f&&m;let P=T?i:l?"butt":r;if(T&&"round"===P&&(x<o?P="miter":x<=2&&(P="fakeround")),"miter"===P&&x>n&&(P="bevel"),"bevel"===P&&(x>2&&(P="flipbevel"),x<n&&(P="miter")),f&&this.updateDistance(f,p),"miter"===P)s._mult(x),this.addCurrentVertex(p,s,0,0,d);else if("flipbevel"===P){if(x>100)s=_.mult(-1);else{const t=x*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===P||"fakeround"===P){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(f&&this.addCurrentVertex(p,g,e,i,d),"fakeround"===P){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)))}const r=_.sub(g)._mult(i)._add(g)._unit()._mult(w?-1:1);this.addHalfVertex(p,r.x,r.y,!1,w,0,d)}}m&&this.addCurrentVertex(p,_,-e,-i,d)}else if("butt"===P)this.addCurrentVertex(p,s,0,0,d);else if("square"===P){const t=f?1:-1;this.addCurrentVertex(p,s,t,t,d)}else"round"===P&&(f&&(this.addCurrentVertex(p,g,0,0,d),this.addCurrentVertex(p,g,1,1,d,!0)),m&&(this.addCurrentVertex(p,_,-1,-1,d,!0),this.addCurrentVertex(p,_,0,0,d)));if(b&&e<c-1){const t=p.dist(m);if(t>2*u){const e=p.add(m.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,_,0,0,d),p=e}}}}addCurrentVertex(t,e,i,r,n,o=!1){const s=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,o,!1,i,n),this.addHalfVertex(t,s,a,o,!0,-r,n),this.distance>vc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,n,o))}addHalfVertex({x:t,y:e},i,r,n,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(vc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let wc,Tc;Hn("LineBucket",bc,{omit:["layers","patternFeatures"]});var Pc={get paint(){return Tc=Tc||new Eo({"line-opacity":new So(gt.paint_line["line-opacity"]),"line-color":new So(gt.paint_line["line-color"]),"line-translate":new Mo(gt.paint_line["line-translate"]),"line-translate-anchor":new Mo(gt.paint_line["line-translate-anchor"]),"line-width":new So(gt.paint_line["line-width"]),"line-gap-width":new So(gt.paint_line["line-gap-width"]),"line-offset":new So(gt.paint_line["line-offset"]),"line-blur":new So(gt.paint_line["line-blur"]),"line-dasharray":new Io(gt.paint_line["line-dasharray"]),"line-pattern":new Co(gt.paint_line["line-pattern"]),"line-gradient":new Ao(gt.paint_line["line-gradient"])})},get layout(){return wc=wc||new Eo({"line-cap":new Mo(gt.layout_line["line-cap"]),"line-join":new So(gt.layout_line["line-join"]),"line-miter-limit":new Mo(gt.layout_line["line-miter-limit"]),"line-round-limit":new Mo(gt.layout_line["line-round-limit"]),"line-sort-key":new So(gt.layout_line["line-sort-key"])})}};class Mc extends So{possiblyEvaluate(t,e){return e=new go(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=B({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}let Sc;class Cc extends zo{constructor(t){super(t,Pc),this.gradientVersion=0,Sc||(Sc=new Mc(Pc.paint.properties["line-width"].specification),Sc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Je,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Sc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new bc(t)}queryRadius(t){const e=t,i=Ic(Aa("line-width",this,e),Aa("line-gap-width",this,e)),r=Aa("line-offset",this,e);return i/2+Math.abs(r)+Ea(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o}){const s=ka(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,o),a=o/2*Ic(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=t[r],o=[];for(let t=0;t<n.length;t++){const i=n[t-1],r=n[t],s=n[t+1],a=0===t?new l(0,0):r.sub(i)._unit()._perp(),c=t===n.length-1?new l(0,0):s.sub(r)._unit()._perp(),h=a._add(c)._unit(),u=h.x*c.x+h.y*c.y;0!==u&&h._mult(1/u),o.push(h._mult(e)._add(r))}i.push(o)}return i}(r,c*o)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(Ca(t,n[e]))return!0;if(ba(t,n,i))return!0}return!1}(s,r,a)}isTileClipped(){return!0}}function Ic(t,e){return e>0?e+2*t:t}const Ac=Fo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ec=Fo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Fo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kc=Fo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Fo([{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 zc=Fo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Lc=Fo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Fo([{name:"triangle",components:3,type:"Uint16"}]),Fo([{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"}]),Fo([{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"},{type:"Float32",name:"angle"}]),Fo([{type:"Float32",name:"offsetX"}]),Fo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Fo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Dc={debnames:"Jacob Marisplein",logLineStrings(t,e,i){let r=40265318;for(let t=0;t<e.z;t++)r/=2;const n=e.x*r-20132659,o=20132659-e.y*r,s=r/8192;let a="SELECT 'SRID=33013;MULTILINESTRING(";for(let e=0;e<t.length;e++){const i=t[e];a=`${a}(`;for(let t=0;t<i.length;t++)a=`${a+(i[t].x*s+n)} ${o-i[t].y*s}`,t<i.length-1&&(a=`${a},`);a=`${a})`,e<t.length-1&&(a=`${a},`)}a=`${a})'::geometry`,void 0!==i&&console.log(i),console.log(a)},logPoints(t,e){let i=40265318;for(let t=0;t<e.z;t++)i/=2;const r=e.x*i-20132659,n=20132659-e.y*i,o=i/8192;let s="SELECT 'SRID=33013;MULTIPOINT(";for(let e=0;e<t.length;e++)s=`${s+(t[e].x*o+r)} ${n-t[e].y*o}`,e<t.length-1&&(s=`${s},`);s=`${s})'::geometry`,console.log(s)},logPoint(t,e,i){let r=40265318;for(let t=0;t<e.z;t++)r/=2;const n=e.x*r-20132659,o=20132659-e.y*r,s=r/8192;void 0!==i&&console.log(i),console.log(`SELECT 'SRID=33013;POINT(${t.x*s+n} ${o-t.y*s})'::geometry`)}};function Rc(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Fc(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),mo.applyArabicShaping&&(t=mo.applyArabicShaping(t)),t}(t.text,e,i)})),t}function Bc(t,e){function i(t,e){const i=e?t[0]:t[t.length-1];return`${i.x}:${i.y}`}function r(t){function e(e){const r=i(t,e),n=s.get(r);o[n]=[],s.delete(r)}e(!0),e(!1)}function n(t,e,i){t!==e&&(s.set(t,i),s.set(e,i))}const o=[],s=new Map;t.lines.forEach((t=>{let a=i(t,!0),l=i(t,!1);const c=s.get(a),h=s.get(l);if(void 0!==c&&void 0!==h&&c!==h){const s=o[c],u=o[h],d=i(s,!0)===a,p=i(u,!0)===l;if(e||!d&&p){r(s),r(u),d&&s.reverse(),p||u.reverse();const e=s.concat(t.slice(1),u.slice(1));a=i(e,!0),l=i(e,!1),o[c]=e,n(a,l,c)}else o.push(t)}else if(void 0!==c||void 0!==h){const s=void 0!==c,u=void 0!==c?c:h,d=o[u],p=i(d,!0)===(void 0!==c?a:l);let f;r(d),s===!p?f=s?d.concat(t.slice(1)):t.concat(d.slice(1)):e?(s&&t.reverse(),p||d.reverse(),f=t.concat(d.slice(1))):(f=d,o.push(t)),a=i(f,!0),l=i(f,!1),o[u]=f,n(a,l,u)}else n(a,l,o.push(t)-1)}));const a=t.feature;return a.geometry=o.filter((t=>t.length>0)),a}const Oc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var jc,Nc,Vc,Uc=24,Zc={};function $c(){return jc||(jc=1,Zc.read=function(t,e,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},Zc.write=function(t,e,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,n),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;t[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Zc}function Gc(){if(Vc)return Nc;Vc=1,Nc=e;var t=$c();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,r=1/i,n="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function l(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function c(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function h(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function u(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function d(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function p(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function f(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function m(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function g(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function _(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function y(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function x(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,t(n,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=_(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=x(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_(this.buf,this.pos)+_(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=_(this.buf,this.pos)+x(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return s(t,r,e);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return s(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&n?function(t,e,i){return n.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var o,s,a,l=t[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=t[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=t[n+2],128==(192&(o=t[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=t[n+2],a=t[n+3],128==(192&(o=t[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var r=o(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(i));return t},readPackedSVarint:function(t){if(this.type!==e.Bytes)return t.push(this.readSVarint());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==e.Bytes)return t.push(this.readBoolean());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==e.Bytes)return t.push(this.readFloat());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==e.Bytes)return t.push(this.readDouble());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed32());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed32());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed64());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed64());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSFixed64());return t},skip:function(t){var i=7&t;if(i===e.Varint)for(;this.buf[this.pos++]>127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),y(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),y(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),y(this.buf,-1&t,this.pos),y(this.buf,Math.floor(t*r),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),y(this.buf,-1&t,this.pos),y(this.buf,Math.floor(t*r),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&a(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,i,r){this.writeTag(t,e.Bytes),this.writeRawMessage(i,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,g,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Nc}var qc=i(Gc());const Wc=3;function Hc(t,e,i){1===t&&i.readMessage(Xc,e)}function Xc(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Kc,{});e.push({id:t,bitmap:new Za({width:n+2*Wc,height:o+2*Wc},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}}function Kc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Yc=Wc;function Jc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,o=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:o,fill:e/(n*o)||0}}const Qc=1;class th{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:o,textFitWidth:s,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i,this.textFitWidth=s,this.textFitHeight=a}get tl(){return[this.paddedRect.x+Qc,this.paddedRect.y+Qc]}get br(){return[this.paddedRect.x+this.paddedRect.w-Qc,this.paddedRect.y+this.paddedRect.h-Qc]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*Qc)/this.pixelRatio,(this.paddedRect.h-2*Qc)/this.pixelRatio]}}class eh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:o,h:s}=Jc(n),a=new $a({width:o||1,height:s||1});for(const e in t){const r=t[e],n=i[e].paddedRect;$a.copy(r.data,a,{x:0,y:0},{x:n.x+Qc,y:n.y+Qc},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,o=n.x+Qc,s=n.y+Qc,l=i.data.width,c=i.data.height;$a.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),$a.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),$a.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),$a.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),$a.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],o={x:0,y:0,w:n.data.width+2*Qc,h:n.data.height+2*Qc};i.push(o),e[r]=new th(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}var ih;Hn("ImagePosition",th),Hn("ImageAtlas",eh),t.W=void 0,(ih=t.W||(t.W={}))[ih.none=0]="none",ih[ih.horizontal=1]="horizontal",ih[ih.vertical=2]="vertical",ih[ih.horizontalOnly=3]="horizontalOnly";const rh=-17;class nh{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,e,i){const r=new nh;return r.scale=t||1,r.fontStack=e,r.verticalAlign=i||"bottom",r}static forImage(t,e){const i=new nh;return i.imageName=t,i.verticalAlign=e||"bottom",i}}class oh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new oh;for(let r=0;r<t.sections.length;r++){const n=t.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,e)}return i}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=function(t){let e="";for(let i=0;i<t.length;i++){const r=t.charCodeAt(i+1)||null,n=t.charCodeAt(i-1)||null;e+=r&&co(r)&&!Oc[t[i+1]]||n&&co(n)&&!Oc[t[i-1]]||!Oc[t[i]]?t[i]:Oc[t[i]]}return e}(this.text)}trim(){let t=0;for(let e=0;e<this.text.length&&lh[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let i=this.text.length-1;i>=0&&i>=t&&lh[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new oh;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,i=0;for(let r=0;r<this.length();r++){const n=this.getSection(r);if(n.imageName){const r=t[n.imageName];if(!r)continue;const o=r.displaySize;e=Math.max(e,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:e,maxImageHeight:i}}addTextSection(t,e){this.text+=t.text,this.sections.push(nh.forText(t.scale,t.fontStack||e,t.verticalAlign));const i=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(i)}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void Z("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(nh.forImage(e,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):Z("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function sh(t,e){const i=[],r=t.text;let n=0;for(const r of e)i.push(t.substring(n,r)),n=r;return n<r.length&&i.push(t.substring(n,r.length)),i}function ah(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const g=oh.fromFeature(e,o);let _;d===t.W.vertical&&g.verticalizePunctuation();const{processBidirectionalText:y,processStyledBidirectionalText:x}=mo;if(y&&1===g.sections.length){_=[];const t=y(g.toString(),gh(g,h,s,i,n,f));for(const e of t){const t=new oh;t.text=e,t.sections=g.sections;for(let i=0;i<e.length;i++)t.sectionIndex.push(0);_.push(t)}}else if(x){_=[];const t=x(g.text,g.sectionIndex,gh(g,h,s,i,n,f));for(const e of t){const t=new oh;t.text=e[0],t.sectionIndex=e[1],t.sections=g.sections,_.push(t)}}else _=sh(g,gh(g,h,s,i,n,f));const v=[],b={positionedLines:v,text:g.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:d,iconsInText:!1,verticalizable:!1};return function(t,e,i,r,n,o,s,a,l,c,h,u){let d=0,p=0,f=0,m=0;const g="right"===a?1:"left"===a?0:.5,_=Uc/u;let y=0;for(const s of n){s.trim();const n=s.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[y]=a;const u=a.positionedGlyphs;let x=0;if(!s.length()){p+=o,++y;continue}const v=yh(r,s,_);for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o),g=vh(l,h,m);let y;if(a.imageName){if(t.iconsInText=!0,a.scale=a.scale*_,y=wh(a,g,n,v,r),!y)continue;x=Math.max(x,y.imageOffset)}else if(y=bh(a,m,g,v,e,i),!y)continue;const{rect:b,metrics:w,baselineOffset:T}=y;u.push({glyph:m,imageName:a.imageName,x:d,y:p+T+rh,vertical:g,scale:a.scale,fontStack:a.fontStack,sectionIndex:f,metrics:w,rect:b}),g?(t.verticalizable=!0,d+=(a.imageName?w.advance:Uc)*a.scale+c):d+=w.advance*a.scale+c}0!==u.length&&(f=Math.max(d-c,f),Th(u,0,u.length-1,g)),d=0,a.lineOffset=Math.max(x,(n-1)*Uc);const b=o*n+x;p+=b,m=Math.max(b,m),++y}const{horizontalAlign:x,verticalAlign:v}=_h(s);(function(t,e,i,r,n,o,s,a,l){const c=(e-i)*n;let h=0;h=o!==s?-a*r-rh:-r*l*s+.5*s;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(t.positionedLines,g,x,v,f,m,o,p,n.length),t.top+=-v*p,t.bottom=t.top+p,t.left+=-x*f,t.right=t.left+f}(b,i,r,n,_,a,l,c,d,h,p,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(v)&&b}const lh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},ch={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hh={40:!0};function uh(t,e,i,r,n,o){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*Uc/o+n:0}{const r=i[e.fontStack],o=r&&r[t];return o?o.metrics.advance*e.scale+n:0}}function dh(t,e,i,r){const n=Math.pow(t-e,2);return r?t<e?n/2:2*n:n+Math.abs(i)*i}function ph(t,e,i){let r=0;return 10===t&&(r-=1e4),i&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function fh(t,e,i,r,n,o){let s=null,a=dh(e,i,n,o);for(const t of r){const r=dh(e-t.x,i,n,o)+t.badness;r<=a&&(s=t,a=r)}return{index:t,x:e,priorBreak:s,badness:a}}function mh(t){return t?mh(t.priorBreak).concat(t.index):[]}function gh(t,e,i,r,n,o){if(!t)return[];const s=[],a=function(t,e,i,r,n,o){let s=0;for(let i=0;i<t.length();i++){const a=t.getSection(i);s+=uh(t.getCharCode(i),a,r,n,e,o)}return s/Math.max(1,Math.ceil(s/i))}(t,e,i,r,n,o),l=t.text.indexOf("")>=0;let c=0;for(let i=0;i<t.length();i++){const u=t.getSection(i),d=t.getCharCode(i);if(lh[d]||(c+=uh(d,u,r,n,e,o)),i<t.length()-1){const e=!((h=d)<11904)&&(!!eo["CJK Compatibility Forms"](h)||!!eo["CJK Compatibility"](h)||!!eo["CJK Strokes"](h)||!!eo["CJK Symbols and Punctuation"](h)||!!eo["Enclosed CJK Letters and Months"](h)||!!eo["Halfwidth and Fullwidth Forms"](h)||!!eo["Ideographic Description Characters"](h)||!!eo["Vertical Forms"](h)||ao.test(String.fromCodePoint(h)));(ch[d]||e||u.imageName||i!==t.length()-2&&hh[t.getCharCode(i+1)])&&s.push(fh(i+1,c,a,s,ph(d,t.getCharCode(i+1),e&&l),!1))}}var h;return mh(fh(t.length(),c,a,s,0,!0))}function _h(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function yh(t,e,i){const r=e.getMaxScale()*Uc,{maxImageWidth:n,maxImageHeight:o}=e.getMaxImageSize(t),s=Math.max(r,o*i);return{verticalLineContentWidth:Math.max(r,n*i),horizontalLineContentHeight:s}}function xh(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function vh(e,i,r){return!(e===t.W.horizontal||!i&&!lo(r)||i&&(lh[r]||(n=r,/\p{sc=Arab}/u.test(String.fromCodePoint(n)))));var n}function bh(t,e,i,r,n,o){const s=o[t.fontStack],a=function(t,e,i,r){if(t&&t.rect)return t;const n=e[i.fontStack],o=n&&n[r];return o?{rect:null,metrics:o.metrics}:null}(s&&s[e],n,t,e);if(null===a)return null;let l;if(i)l=r.verticalLineContentWidth-t.scale*Uc;else{const e=xh(t.verticalAlign);l=(r.horizontalLineContentHeight-t.scale*Uc)*e}return{rect:a.rect,metrics:a.metrics,baselineOffset:l}}function wh(t,e,i,r,n){const o=n[t.imageName];if(!o)return null;const s=o.paddedRect,a=o.displaySize,l={width:a[0],height:a[1],left:Qc,top:-3,advance:e?a[1]:a[0]};let c;if(e)c=r.verticalLineContentWidth-a[1]*t.scale;else{const e=xh(t.verticalAlign);c=(r.horizontalLineContentHeight-a[1]*t.scale)*e}return{rect:s,metrics:l,baselineOffset:c,imageOffset:(e?a[0]:a[1])*t.scale-Uc*i}}function Th(t,e,i,r){if(0===r)return;const n=t[i],o=(t[i].x+n.metrics.advance*n.scale)*r;for(let r=e;r<=i;r++)t[r].x-=o}function Ph(t,e,i){const{horizontalAlign:r,verticalAlign:n}=_h(i),o=e[0]-t.displaySize[0]*r,s=e[1]-t.displaySize[1]*n;return{image:t,top:s,bottom:s+t.displaySize[1],left:o,right:o+t.displaySize[0]}}function Mh(t){var e,i;let r=t.left,n=t.top,o=t.right-r,s=t.bottom-n;const a=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",l=null!==(i=t.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",c=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&o/s<c||"proportional"===a){const t=Math.ceil(s*c);r*=t/o,o=t}}else if("proportional"===a&&"stretchOnly"===l&&0!==c&&o/s>c){const t=Math.ceil(o/c);n*=t/s,s=t}return{x1:r,y1:n,x2:r+o,y2:n+s}}function Sh(t,e,i,r,n,o){const s=t.image;let a;if(s.content){const t=s.content,e=s.pixelRatio||1;a=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e]}const l=e.left*o,c=e.right*o;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,u=p+s.displaySize[0]);const f=e.top*o,m=e.bottom*o;return"height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):(h=n[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{image:s,top:h,right:u,bottom:d,left:p,collisionPadding:a}}const Ch=255,Ih=128,Ah=Ch*Ih;function Eh(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new go(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let o=n;for(;o<e.length&&e[o]<t+1;)o++;o=Math.min(e.length-1,o);const s=e[n],a=e[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new go(s)),maxSize:i.evaluate(new go(a)),interpolationType:r}}}function kh(t,e,i){let r="never";const n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}const zh=ec.VectorTileFeature.types,Lh=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Dh(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(Ah,Math.round(a[0])):0,f=a?Math.min(Ah,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function Rh(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function Fh(t){for(const e of t.sections)if(fo(e.text))return!0;return!1}class Bh{constructor(t){this.layoutVertexArray=new Ss,this.indexArray=new ks,this.programConfigurations=t,this.segments=new Rs,this.dynamicLayoutVertexArray=new Cs,this.opacityVertexArray=new Is,this.hasVisibleVertices=!1,this.placedSymbolArray=new hs}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ac.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Ec.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Lh,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Hn("SymbolBuffers",Bh);class Oh{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Rs,this.collisionVertexArray=new Es}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,kc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Hn("CollisionBuffers",Oh);class jh{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Eh(this.zoom,i["text-size"]),this.iconSizeData=Eh(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap="never"!==kh(r,"text-overlap","text-allow-overlap")||"never"!==kh(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.W[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Bh(new la(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bh(new la(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ps,this.lineVertexArray=new fs,this.symbolInstances=new ds,this.textAnchorOffsets=new gs}calculateGlyphDependencies(t,e,i,r,n){for(let o=0;o<t.length;o++)if(e[t.charCodeAt(o)]=!0,(i||r)&&n){const i=Oc[t.charAt(o)];i&&(e[i.charCodeAt(0)]=!0)}}populate(e,i,r){const n=this.layers[0],o=n.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Pe&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new go(this.zoom);let g=!1;for(const{feature:i,id:a,index:l,sourceLayerIndex:_}of e){const e=n._featureFilter.needGeometry,y=fa(i,e);if(!n._featureFilter.filter(m,y,r))continue;let x,v;if(e||(y.geometry=pa(i)),c){const t=n.getValueAndResolveTokens("text-field",y,r,f),e=Pe.factory(t),i=this.hasRTLText=this.hasRTLText||Fh(e);(!i||"unavailable"===mo.getRTLTextPluginStatus()||i&&mo.isParsed())&&(x=Fc(e,n,y))}if(h){const t=n.getValueAndResolveTokens("icon-image",y,r,f);v=t instanceof Ae?t:Ae.fromString(t),v&&(g=!0)}if(!(x&&x.toString()||v))continue;const b=this.sortFeaturesByKey?u.evaluate(y,{},r):void 0;if(this.features.push({id:a,text:x,icon:v,index:l,sourceLayerIndex:_,geometry:y.geometry,properties:i.properties,type:zh[i.type],sortKey:b}),v&&(d[v.name]=!0),x){const e=s.evaluate(y,{},r).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.W.vertical)>=0;for(const t of x.sections)if(t.image)d[t.image.name]=!0;else{const r=io(x.toString()),n=t.fontStack||e,o=p[n]=p[n]||{};this.calculateGlyphDependencies(t.text,o,i,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(t,e){const i={};t.forEach((t=>{const e=t.text?t.text.toString():"nn>";let r=i[e];void 0===r&&(r={feature:t,lines:[]},i[e]=r),t.geometry.forEach((t=>r.lines.push(t)))}));const r=[];for(const t in i)r.push(Bc(i[t],e));return r}(this.features,!g),this.features.forEach((t=>{var e;t.geometry.forEach((t=>{t.len=Rc(t)})),t.geometry.sort(((t,e)=>e.len-t.len)),t.text instanceof Pe&&(null===(e=t.text)||void 0===e?void 0:e.toString())===Dc.debnames&&Dc.logLineStrings(t.geometry,r)}))),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let r=t.segment+1;r<e.length;r++)n[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=n[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,i,r,n,o,s,a,l,c,h,u,d){const p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*i.length,f,p,this.canOverlap?s.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&a===t.W.vertical?Math.PI/2:0,x=s.text&&s.text.sections;for(let t=0;t<i.length;t++){const{tl:n,tr:o,bl:a,br:c,tex:h,pixelOffsetTL:u,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=i[t],P=m.vertexLength,M=b[1];Dh(f,l.x,l.y,n.x,M+n.y,h.x,h.y,r,w,u.x,u.y,_,v),Dh(f,l.x,l.y,o.x,M+o.y,h.x+h.w,h.y,r,w,g.x,u.y,_,v),Dh(f,l.x,l.y,a.x,M+a.y,h.x,h.y+h.h,r,w,u.x,g.y,_,v),Dh(f,l.x,l.y,c.x,M+c.y,h.x+h.w,h.y+h.h,r,w,g.x,g.y,_,v),Rh(e.dynamicLayoutVertexArray,l,y),p.emplaceBack(P,P+2,P+1),p.emplaceBack(P+1,P+2,P+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),t!==i.length-1&&T===i[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(f.length,s,s.index,{},d,x&&x[T])}e.placedSymbolArray.emplaceBack(l.x,l.y,g,this.glyphOffsetArray.length-g,_,c,h,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],a,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,r,n,o){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,n,Math.round(o.x),Math.round(o.y))}addCollisionDebugVertices(t,e,i,r,n,o,s){const a=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),c=a.vertexLength,h=n.layoutVertexArray,u=n.collisionVertexArray,d=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(h,u,o,d,p,new l(t,e)),this._addCollisionDebugVertex(h,u,o,d,p,new l(i,e)),this._addCollisionDebugVertex(h,u,o,d,p,new l(i,r)),this._addCollisionDebugVertex(h,u,o,d,p,new l(t,r)),a.vertexLength+=4;const f=n.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),a.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let n=t;n<e;n++){const t=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Oh(As,zc.members,zs),this.iconCollisionBox=new Oh(As,zc.members,zs);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,n,o,s,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=o;e<s;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.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(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+2,e+1),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const s=this.symbolInstances.get(t);r.push(0|Math.round(e*s.anchorX+i*s.anchorY)),n.push(s.featureIndex)}return o.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),o}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Nh,Vh;Hn("SymbolBucket",jh,{omit:["layers","collisionBoxArray","features","compareText"]}),jh.MAX_GLYPHS=65535,jh.addDynamicAttributes=Rh;var Uh={get paint(){return Vh=Vh||new Eo({"icon-opacity":new So(gt.paint_symbol["icon-opacity"]),"icon-color":new So(gt.paint_symbol["icon-color"]),"icon-halo-color":new So(gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new So(gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new So(gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Mo(gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Mo(gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new So(gt.paint_symbol["text-opacity"]),"text-color":new So(gt.paint_symbol["text-color"],{runtimeType:Ft,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new So(gt.paint_symbol["text-halo-color"]),"text-halo-width":new So(gt.paint_symbol["text-halo-width"]),"text-halo-blur":new So(gt.paint_symbol["text-halo-blur"]),"text-translate":new Mo(gt.paint_symbol["text-translate"]),"text-translate-anchor":new Mo(gt.paint_symbol["text-translate-anchor"])})},get layout(){return Nh=Nh||new Eo({"symbol-placement":new Mo(gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Mo(gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Mo(gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new So(gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Mo(gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Mo(gt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Mo(gt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Mo(gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Mo(gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Mo(gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new So(gt.layout_symbol["icon-size"]),"icon-text-fit":new Mo(gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Mo(gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new So(gt.layout_symbol["icon-image"]),"icon-rotate":new So(gt.layout_symbol["icon-rotate"]),"icon-padding":new So(gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Mo(gt.layout_symbol["icon-keep-upright"]),"icon-offset":new So(gt.layout_symbol["icon-offset"]),"icon-anchor":new So(gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Mo(gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Mo(gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Mo(gt.layout_symbol["text-rotation-alignment"]),"text-field":new So(gt.layout_symbol["text-field"]),"text-font":new So(gt.layout_symbol["text-font"]),"text-size":new So(gt.layout_symbol["text-size"]),"text-max-width":new So(gt.layout_symbol["text-max-width"]),"text-line-height":new Mo(gt.layout_symbol["text-line-height"]),"text-letter-spacing":new So(gt.layout_symbol["text-letter-spacing"]),"text-justify":new So(gt.layout_symbol["text-justify"]),"text-radial-offset":new So(gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Mo(gt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new So(gt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new So(gt.layout_symbol["text-anchor"]),"text-max-angle":new Mo(gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Mo(gt.layout_symbol["text-writing-mode"]),"text-rotate":new So(gt.layout_symbol["text-rotate"]),"text-padding":new Mo(gt.layout_symbol["text-padding"]),"text-keep-upright":new Mo(gt.layout_symbol["text-keep-upright"]),"text-transform":new So(gt.layout_symbol["text-transform"]),"text-offset":new So(gt.layout_symbol["text-offset"]),"text-allow-overlap":new Mo(gt.layout_symbol["text-allow-overlap"]),"text-overlap":new Mo(gt.layout_symbol["text-overlap"]),"text-ignore-placement":new Mo(gt.layout_symbol["text-ignore-placement"]),"text-optional":new Mo(gt.layout_symbol["text-optional"])})}};class Zh{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:zt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Hn("FormatSectionOverride",Zh,{omit:["defaultValue"]});class $h extends zo{constructor(t){super(t,Uh)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||Gr(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new jh(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Uh.paint.overridableProperties){if(!$h.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Zh(e),r=new $r(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Wr("source",r):new Hr("composite",r,e.value.zoomStops),this.paint._values[t]=new To(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&$h.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Uh.paint.properties[e];let n=!1;const o=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Pe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof Re&&Le(e.value)===Vt?o(e.value.sections):e instanceof xi?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}}let Gh;var qh={get paint(){return Gh=Gh||new Eo({"background-color":new Mo(gt.paint_background["background-color"]),"background-pattern":new Io(gt.paint_background["background-pattern"]),"background-opacity":new Mo(gt.paint_background["background-opacity"])})}};class Wh extends zo{constructor(t){super(t,qh)}}let Hh;var Xh={get paint(){return Hh=Hh||new Eo({"raster-opacity":new Mo(gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Mo(gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Mo(gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Mo(gt.paint_raster["raster-brightness-max"]),"raster-saturation":new Mo(gt.paint_raster["raster-saturation"]),"raster-contrast":new Mo(gt.paint_raster["raster-contrast"]),"raster-resampling":new Mo(gt.paint_raster["raster-resampling"]),"raster-fade-duration":new Mo(gt.paint_raster["raster-fade-duration"])})}};class Kh extends zo{constructor(t){super(t,Xh)}}class Yh extends zo{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Jh{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Qh={once:!0};function tu(t,e,i,r,n){const o=[];for(let s=0;s<t.length;s++){const a=t[s];let c;for(let t=0;t<a.length-1;t++){let s=a[t],h=a[t+1];s.x<e&&h.x<e||(s.x<e?s=new l(e,s.y+(e-s.x)/(h.x-s.x)*(h.y-s.y))._round():h.x<e&&(h=new l(e,s.y+(e-s.x)/(h.x-s.x)*(h.y-s.y))._round()),s.y<i&&h.y<i||(s.y<i?s=new l(s.x+(i-s.y)/(h.y-s.y)*(h.x-s.x),i)._round():h.y<i&&(h=new l(s.x+(i-s.y)/(h.y-s.y)*(h.x-s.x),i)._round()),s.x>=r&&h.x>=r||(s.x>=r?s=new l(r,s.y+(r-s.x)/(h.x-s.x)*(h.y-s.y))._round():h.x>=r&&(h=new l(r,s.y+(r-s.x)/(h.x-s.x)*(h.y-s.y))._round()),s.y>=n&&h.y>=n||(s.y>=n?s=new l(s.x+(n-s.y)/(h.y-s.y)*(h.x-s.x),n)._round():h.y>=n&&(h=new l(s.x+(n-s.y)/(h.y-s.y)*(h.x-s.x),n)._round()),c&&s.equals(c[c.length-1])||(c=[s],o.push(c)),c.push(h)))))}}return o}const eu=6371008.8;class iu{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new iu(F(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return eu*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof iu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new iu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new iu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const ru=2*Math.PI*eu;function nu(t){return ru*Math.cos(t*Math.PI/180)}function ou(t){return(180+t)/360}function su(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function au(t,e){return t/nu(e)}function lu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function cu(t,e){return t*nu(lu(e))}class hu{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=iu.convert(t);return new hu(ou(i.lng),su(i.lat),au(e,i.lat))}toLngLat(){return new iu(360*this.x-180,lu(this.y))}toAltitude(){return cu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ru*(t=lu(this.y),1/Math.cos(t*Math.PI/180));var t}}function uu(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class du{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,i))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=mu(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(o=this.y,s=this.z,a=uu(256*(n=this.x),256*(o=Math.pow(2,s)-o-1),s),l=uu(256*(n+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,o,s,a,l;const c=function(t,e,i){let r,n="";for(let o=t;o>0;o--)r=1<<o-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.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("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*I,(t.y*e-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class pu{constructor(t,e){this.wrap=t,this.canonical=e,this.key=mu(t,e.z,e.z,e.x,e.y)}}class fu{constructor(t,e,i,r,n){if(this.terrainRttPosMatrix32f=null,t<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new du(i,+r,+n),this.key=mu(e,t,i,r,n)}clone(){return new fu(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new fu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?mu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):mu(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new fu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new fu(e,this.wrap,e,i,r),new fu(e,this.wrap,e,i+1,r),new fu(e,this.wrap,e,i,r+1),new fu(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new fu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new fu(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new pu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new hu(t.x-this.wrap,t.y))}}function mu(t,e,i,r,n){(t*=2)<0&&(t=-1*t-1);const o=1<<i;return(o*o*t+o*n+r).toString(36)+i.toString(36)+e.toString(36)}Hn("CanonicalTileID",du),Hn("OverscaledTileID",fu,{omit:["terrainRttPosMatrix32f"]});class gu{constructor(t,e,i,r=1,n=1,o=1,s=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void Z(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=r,this.greenFactor=n,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;t<a;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(a,t)]=this.data[this._idx(a-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,a)]=this.data[this._idx(t,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<a;t++)for(let e=0;e<a;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return this.unpack(i[r],i[r+1],i[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}getPixels(){return new $a({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e<s;e++)for(let i=r;i<n;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+l)]}}Hn("DEMData",gu);class _u{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class yu{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class xu{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new qn(I,16,0),this.grid3D=new qn(I,16,0),this.featureIndexArray=new ys,this.promoteId=e}insert(t,e,i,r,n,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=o?this.grid3D:this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<I&&r[1]<I&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ec.VectorTile(new qc(this.rawTileData)).layers,this.sourceLayerCoder=new _u(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){var n;this.loadVTLayers();const o=null!==(n=t.params)&&void 0!==n?n:{},s=I/t.tileSize/t.scale,a=tn(o.filter),c=t.queryGeometry,h=t.queryPadding*s,u=bu(c),d=this.grid.query(u.minX-h,u.minY-h,u.maxX+h,u.maxY+h,null,o.skipGeoCheck),p=bu(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-h,p.minY-h,p.maxX+h,p.maxY+h,((e,i,r,n)=>function(t,e,i,r,n){for(const o of t)if(e<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new l(e,i),new l(e,n),new l(r,n),new l(r,i)];if(t.length>2)for(const e of o)if(Ca(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Ia(t[e],t[e+1],o))return!0;return!1}(t.cameraQueryGeometry,e-h,i-h,r+h,n+h)));for(const t of f)d.push(t);d.sort(wu);const m={};let g;for(let n=0;n<d.length;n++){const l=d[n];if(l===g)continue;g=l;const h=this.featureIndexArray.get(l);let u=null;this.loadMatchingFeature(m,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,a,o.layers,o.availableImages,e,i,r,((e,i,r)=>(u||(u=pa(e)),o.skipGeoCheck||i.queryIntersectsFeature({queryGeometry:c,feature:e,featureState:r,geometry:u,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))))}return m}loadMatchingFeature(t,e,i,r,n,o,s,a,l,c,h){const u=this.bucketLayerIDs[e];if(o&&!u.some((t=>o.has(t))))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(n.needGeometry){const t=fa(p,!0);if(!n.filter(new go(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new go(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let e=0;e<u.length;e++){const i=u[e];if(o&&!o.has(i))continue;const n=a[i];if(!n)continue;let d={};f&&c&&(d=c.getState(n.sourceLayer||"_geojsonTileLayer",f));const m=B({},l[i]);m.paint=vu(m.paint,n.paint,p,d,s),m.layout=vu(m.layout,n.layout,p,d,s);const g=!h||h(p,n,d);if(!g)continue;const _=new yu(p,this.z,this.x,this.y,f);_.layer=m;let y=t[i];void 0===y&&(y=t[i]=[]),y.push({featureIndex:r,feature:_,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=tn(n);for(const n of t)this.loadMatchingFeature(l,i,r,n,c,o,s,a,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){var i;let r=t.id;return this.promoteId&&(r=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(i=t.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(r=Number(t.properties.cluster_id))),r}}function vu(t,e,i,r,n){return j(t,((t,o)=>{const s=e instanceof Po?e.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function bu(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of t)e=Math.min(e,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return{minX:e,minY:i,maxX:r,maxY:n}}function wu(t,e){return e-t}Hn("FeatureIndex",xu,{omit:["rawTileData","sourceLayerCoder"]});class Tu extends l{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new Tu(this.x,this.y,this.angle,this.segment)}}Hn("Anchor",Tu);class Pu{constructor(t){this.curDist=0,this.totalDistance=0,this.segm=-1,this.cs=t}travelRouteAbsolute(t){return this.segm=-1,this.travelRouteRelative(t)}travelRouteRelative(t){let e;this.segm<1&&(e=this.cs[0],this.segm=1,this.curDist=0,this.totalDistance=0);let i=this.cs[this.segm-1];this.curDist=this.curDist+t,this.totalDistance=this.totalDistance+t;let r=this.curDist;if(t<0)for(0===r&&(e=i);r<0&&this.segm>1;){const t=this.cs[this.segm-2],n=i.dist(t);r+=n,this.curDist+=n,this.segm--,i=t,e=t}for(;r>0&&this.segm<this.cs.length;){const t=this.cs[this.segm],n=i.dist(t);if(n<r)r-=n,this.curDist-=n,this.segm++,i=t,e=t;else{const o=r/n;e=new l(i.x+(t.x-i.x)*o,i.y+(t.y-i.y)*o),r=0}}return r>0&&(e=this.cs[this.cs.length-1]),r<=0?e:null}angleOfCurrentSegm(){return this.cs[this.segm].angleTo(this.cs[this.segm-1])}}function Mu(t,e,i,r,n){if(void 0===e.segment||0===i)return!0;let o=e,s=e.segment+1,a=0;for(;a>-i/2&&(s--,!(s<0));)a-=t[s].dist(o),o=t[s];s=Math.max(s,0),a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const e=t[s-1],i=t[s],o=t[s+1];if(!o)break;let h=e.angleTo(i)-i.angleTo(o);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:h}),c+=h;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=i.dist(o)}return!0}function Su(t,e,i){return t?.6*e*i:0}function Cu(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Iu(t,e,i,r,n,o){const s=Su(i,n,o),a=Cu(i,r)*o;let l=0;const c=Rc(t)/2;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=si.number(r.x,n.x,h),d=si.number(r.y,n.y,h),p=new Tu(u,d,n.angleTo(r),i);return p._round(),!s||Mu(t,p,a,s,e)?p:void 0}l+=o}}function Au(t,e,i,r,n,o,s,a,l,c,h){var u;const d=Su(r,o,s),p=Cu(r,n)*s,f=p/4,m=Rc(t),g=(null===(u=null==r?void 0:r.text)||void 0===u?void 0:u.toString())===Dc.debnames;function _(e,r,n,o){if(e.x>=0&&e.x<l&&e.y>=0&&e.y<l&&n-f>=0&&n+f<=m){const n=new Tu(e.x,e.y,o,r);if(n._round(),!d||Mu(t,n,p,d,i))return b.push(n),!0;g&&Dc.logPoint(n,c,"Skipped anchor")}return!1}let y=Math.floor((m-e)/(p+e));y<=0&&(y=1),h&&(y=1),y>1&&(e=(m-y*p)/(y+1));const x=1===y?m/2:(e+p)/2;let v=x;g&&Dc.logLineStrings([t],c,`debnames anchorCount=${y}, spacing=${e}, firstAnchorOffset=${x}, lineLength=${m}, labelLength=${p}`);const b=[],w=new Pu(t);for(;b.length<y;){const t=w.travelRouteRelative(v);if(!t)break;_(t,w.segm-1,w.totalDistance,w.angleOfCurrentSegm())?(v=e,w.travelRouteRelative(p)):v=2}if(0===b.length)for(g&&Dc.logLineStrings(t,c,`no anchors found, search back from ${x}`),w.travelRouteAbsolute(x);0===b.length;){const t=w.travelRouteRelative(-2);if(!t)break;_(t,w.segm-1,w.totalDistance,w.angleOfCurrentSegm())}return b}const Eu=Qc;function ku(t,e,i,r){const n=[],o=t.image,s=o.pixelRatio,a=o.paddedRect.w-2*Eu,c=o.paddedRect.h-2*Eu;let h={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const u=o.stretchX||[[0,a]],d=o.stretchY||[[0,c]],p=(t,e)=>t+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),g=a-f,_=c-m;let y=0,x=f,v=0,b=m,w=0,T=g,P=0,M=_;if(o.content&&r){const e=o.content,i=e[2]-e[0],r=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(h=Mh(t)),y=zu(u,0,e[0]),v=zu(d,0,e[1]),x=zu(u,e[0],e[2]),b=zu(d,e[1],e[3]),w=e[0]-y,P=e[1]-v,T=i-x,M=r-b}const S=h.x1,C=h.y1,I=h.x2-S,A=h.y2-C,E=(t,r,n,a)=>{const c=Du(t.stretch-y,x,I,S),h=Ru(t.fixed-w,T,t.stretch,f),u=Du(r.stretch-v,b,A,C),d=Ru(r.fixed-P,M,r.stretch,m),p=Du(n.stretch-y,x,I,S),g=Ru(n.fixed-w,T,n.stretch,f),_=Du(a.stretch-v,b,A,C),E=Ru(a.fixed-P,M,a.stretch,m),k=new l(c,u),z=new l(p,u),L=new l(p,_),D=new l(c,_),R=new l(h/s,d/s),F=new l(g/s,E/s),B=e*Math.PI/180;if(B){const t=Math.sin(B),e=Math.cos(B),i=[e,-t,t,e];k._matMult(i),z._matMult(i),D._matMult(i),L._matMult(i)}const O=t.stretch+t.fixed,j=r.stretch+r.fixed;return{tl:k,tr:z,bl:D,br:L,tex:{x:o.paddedRect.x+Eu+O,y:o.paddedRect.y+Eu+j,w:n.stretch+n.fixed-O,h:a.stretch+a.fixed-j},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:T/s/I,minFontScaleY:M/s/A,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const t=Lu(u,g,f),e=Lu(d,_,m);for(let i=0;i<t.length-1;i++){const r=t[i],o=t[i+1];for(let t=0;t<e.length-1;t++)n.push(E(r,e[t],o,e[t+1]))}}else n.push(E({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:c+1}));return n}function zu(t,e,i){let r=0;for(const n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function Lu(t,e,i){const r=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+Eu,stretch:i}),r}function Du(t,e,i,r){return t/e*i+r}function Ru(t,e,i,r){return t-e*i/r}class Fu{constructor(t,e,i,r,n,o,s,a,c,h,u,d=[0,0],p="center"){var f;if(this.boxStartIndex=t.length,c){let t=o.top,e=o.bottom;const i=o.collisionPadding;i&&(t-=i[1],e+=i[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const{x1:c,x2:m,y1:g,y2:_}=u?function(t,e,i=[0,0],r="center"){const n=t.right-t.left,o=t.bottom-t.top,{horizontalAlign:s,verticalAlign:a}=_h(r),l=i[0]+e[0]-n*s,c=i[1]+e[1]-o*a;return{x1:l,y1:c,x2:l+e[2]-e[0],y2:c+e[3]-e[1]}}(o,u,d,p):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom},y=(null===(f=o.image)||void 0===f?void 0:f.content)&&(o.image.textFitWidth||o.image.textFitHeight)?Mh(o):{x1:c,y1:g,x2:m,y2:_};y.y1=y.y1*s-a[0],y.y2=y.y2*s+a[2],y.x1=y.x1*s-a[3],y.x2=y.x2*s+a[1];const x=o.collisionPadding;if(x&&(y.x1-=x[0]*s,y.y1-=x[1]*s,y.x2+=x[2]*s,y.y2+=x[3]*s),h){const t=new l(y.x1,y.y1),e=new l(y.x2,y.y1),i=new l(y.x1,y.y2),r=new l(y.x2,y.y2),n=h*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),y.x1=Math.min(t.x,e.x,i.x,r.x),y.x2=Math.max(t.x,e.x,i.x,r.x),y.y1=Math.min(t.y,e.y,i.y,r.y),y.y2=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,y.x1,y.y1,y.x2,y.y2,i,r,n)}this.boxEndIndex=t.length}}class Bu{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1);const o=r+1;if(o<this.length&&i(e[o],e[r])<0&&(r=o),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}}function Ou(t,e=1,i=!1){let r=1/0,n=1/0,o=-1/0,s=-1/0;const a=t[0];for(let t=0;t<a.length;t++){const e=a[t];(!t||e.x<r)&&(r=e.x),(!t||e.y<n)&&(n=e.y),(!t||e.x>o)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const c=Math.min(o-r,s-n);let h=c/2;const u=new Bu([],ju);if(0===c)return new l(r,n);for(let e=r;e<o;e+=c)for(let i=n;i<s;i+=c)u.push(new Nu(e+h,i+h,h,t));let d=function(t){let e=0,i=0,r=0;const n=t[0];for(let t=0,o=n.length,s=o-1;t<o;s=t++){const o=n[t],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,e+=3*l}return new Nu(i/e,r/e,0,t)}(t),p=u.length;for(;u.length;){const r=u.pop();(r.d>d.d||!d.d)&&(d=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-d.d<=e||(h=r.h/2,u.push(new Nu(r.p.x-h,r.p.y-h,h,t)),u.push(new Nu(r.p.x+h,r.p.y-h,h,t)),u.push(new Nu(r.p.x-h,r.p.y+h,h,t)),u.push(new Nu(r.p.x+h,r.p.y+h,h,t)),p+=4)}return i&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function ju(t,e){return e.max-t.max}function Nu(t,e,i,r){this.p=new l(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;n<e.length;n++){const o=e[n];for(let e=0,n=o.length,s=n-1;e<n;s=e++){const n=o[e],a=o[s];n.y>t.y!=a.y>t.y&&t.x<(a.x-n.x)*(t.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Ma(t,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Vu;t.aB=void 0,(Vu=t.aB||(t.aB={}))[Vu.center=1]="center",Vu[Vu.left=2]="left",Vu[Vu.right=3]="right",Vu[Vu.top=4]="top",Vu[Vu.bottom=5]="bottom",Vu[Vu["top-left"]=6]="top-left",Vu[Vu["top-right"]=7]="top-right",Vu[Vu["bottom-left"]=8]="bottom-left",Vu[Vu["bottom-right"]=9]="bottom-right";const Uu=7,Zu=Number.POSITIVE_INFINITY;function $u(t,e){return e[1]!==Zu?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-Uu;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+Uu}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Math.SQRT2;switch(t){case"top-right":case"top-left":r=n-Uu;break;case"bottom-right":case"bottom-left":r=-n+Uu;break;case"bottom":r=-e+Uu;break;case"top":r=e-Uu}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Gu(t,e,i){var r;const n=t.layout,o=null===(r=n.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(e,{},i);if(o){const t=o.values,e=[];for(let i=0;i<t.length;i+=2){const r=e[i]=t[i],n=t[i+1].map((t=>t*Uc));r.startsWith("top")?n[1]-=Uu:r.startsWith("bottom")&&(n[1]+=Uu),e[i+1]=n}return new Ie(e)}const s=n.get("text-variable-anchor");if(s){let r;r=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[n.get("text-radial-offset").evaluate(e,{},i)*Uc,Zu]:n.get("text-offset").evaluate(e,{},i).map((t=>t*Uc));const o=[];for(const t of s)o.push(t,$u(t,r));return new Ie(o)}return null}function qu(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Wu(e,i,r,n,o,s,a,l,c,h,u,d){var p;let f=s.textMaxSize.evaluate(i,{});void 0===f&&(f=a);const m=e.layers[0].layout,g=m.get("icon-offset").evaluate(i,{},u),_=Xu(r.horizontal),y=a/24,x=e.tilePixelRatio*y,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*m.get("symbol-spacing"),T=m.get("text-padding")*e.tilePixelRatio,P=function(t,e,i,r=1){const n=t.get("icon-padding").evaluate(e,{},i),o=n&&n.values;return[o[0]*r,o[1]*r,o[2]*r,o[3]*r]}(m,i,u,e.tilePixelRatio),M=m.get("text-max-angle")/180*Math.PI,S="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),A=m.get("symbol-placement"),E=w/2,k=m.get("icon-text-fit");let z;n&&"none"!==k&&(e.allowVerticalPlacement&&r.vertical&&(z=Sh(n,r.vertical,k,m.get("icon-text-fit-padding"),g,y)),_&&(n=Sh(n,_,k,m.get("icon-text-fit-padding"),g,y)));const L=u?d.line.getGranularityForZoomLevel(u.z):1,D=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,P,M){const S=e.addToLineVertexArray(i,r);let C,I,A,E,k=0,z=0,L=0,D=0,R=-1,F=-1;const B={};let O=Gs("");if(e.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},P)+90;A=new Fu(c,i,h,u,d,n.vertical,p,f,m,t),a&&(E=new Fu(c,i,h,u,d,a,_,y,m,t))}if(o){const r=b.properties["icon-collision-box"],n=l.layout.get("icon-anchor").evaluate(b,{},P),s=l.layout.get("icon-rotate").evaluate(b,{}),p="none"!==l.layout.get("icon-text-fit"),f=ku(o,s,T,p),m=a?ku(a,s,T,p):void 0;I=new Fu(c,i,h,u,d,o,_,y,!1,s,r,v,n),k=4*f.length;const g=e.iconSizeData;let M=null;"source"===g.kind?(M=[Ih*l.layout.get("icon-size").evaluate(b,{})],M[0]>Ah&&Z(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ch}. Reduce your "icon-size".`)):"composite"===g.kind&&(M=[Ih*w.compositeIconSizes[0].evaluate(b,{},P),Ih*w.compositeIconSizes[1].evaluate(b,{},P)],(M[0]>Ah||M[1]>Ah)&&Z(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ch}. Reduce your "icon-size".`)),e.addSymbols(e.icon,f,M,v,x,b,t.W.none,i,S.lineStartIndex,S.lineLength,-1,P),R=e.icon.placedSymbolArray.length-1,m&&(z=4*m.length,e.addSymbols(e.icon,m,M,v,x,b,t.W.vertical,i,S.lineStartIndex,S.lineLength,-1,P),F=e.icon.placedSymbolArray.length-1)}const j=Object.keys(n.horizontal);for(const r of j){const o=n.horizontal[r];if(!C){O=Gs(o.text);const t=l.layout.get("text-rotate").evaluate(b,{},P);C=new Fu(c,i,h,u,d,o,p,f,m,t)}const a=1===o.positionedLines.length;if(L+=Hu(e,i,o,s,l,m,b,g,S,n.vertical?t.W.horizontal:t.W.horizontalOnly,a?j:[r],B,R,w,P),a)break}n.vertical&&(D+=Hu(e,i,n.vertical,s,l,m,b,g,S,t.W.vertical,["vertical"],B,F,w,P));const N=C?C.boxStartIndex:e.collisionBoxArray.length,V=C?C.boxEndIndex:e.collisionBoxArray.length,U=A?A.boxStartIndex:e.collisionBoxArray.length,$=A?A.boxEndIndex:e.collisionBoxArray.length,G=I?I.boxStartIndex:e.collisionBoxArray.length,q=I?I.boxEndIndex:e.collisionBoxArray.length,W=E?E.boxStartIndex:e.collisionBoxArray.length,H=E?E.boxEndIndex:e.collisionBoxArray.length;let X=-1;const K=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=K(C,X),X=K(A,X),X=K(I,X),X=K(E,X);const Y=X>-1?1:0;Y&&(X*=M/Uc),e.glyphOffsetArray.length>=jh.MAX_GLYPHS&&Z("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const J=Gu(l,b,P),[Q,tt]=function(e,i){const r=e.length,n=null==i?void 0:i.values;if((null==n?void 0:n.length)>0)for(let i=0;i<n.length;i+=2){const r=n[i+1];e.emplaceBack(t.aB[n[i]],r[0],r[1])}return[r,e.length]}(e.textAnchorOffsets,J);e.symbolInstances.emplaceBack(i.x,i.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,R,F,O,N,V,U,$,G,q,W,H,h,L,D,k,z,Y,0,p,X,Q,tt,i.angle)}(e,d,l,r,n,o,z,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,x,[T,T,T,T],S,c,b,P,C,g,i,s,h,u,a)};if("line"===A)for(const t of tu(i.geometry,0,0,I,I)){const o=zl(t,L),s=Au(o,w,M,r.vertical||_,n,24,v,0,I,u,e.layerIds[0].endsWith("-abbr"));for(const t of s)_&&Ku(e,_.text,E,t)||D(o,t);(null===(p=null==_?void 0:_.text)||void 0===p?void 0:p.toString())===Dc.debnames&&(Dc.logLineStrings(tu(i.geometry,0,0,I,I),u),Dc.logPoints(s,u))}else if("line-center"===A){for(const t of i.geometry)if(t.length>1){const e=zl(t,L),i=Iu(e,M,r.vertical||_,n,24,v);i&&D(e,i)}}else if("Polygon"===i.type)for(const t of Gi(i.geometry,0)){const e=Ou(t,16);D(zl(t[0],L,!0),new Tu(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry){const e=zl(t,L);D(e,new Tu(e[0].x,e[0].y,0))}else if("Point"===i.type)for(const t of i.geometry)for(const e of t)D([e],new Tu(e.x,e.y,0))}function Hu(t,e,i,r,n,o,s,a,c,h,u,d,p,f,m){const g=function(t,e,i,r,n,o,s,a){const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const r of t.positionedGlyphs){if(!r.rect)continue;const o=r.rect||{};let u=Yc+1,d=!0,p=1,f=0;const m=(n||a)&&r.vertical,g=r.metrics.advance*r.scale/2;if(a&&e.verticalizable&&(f=t.lineOffset/2-(r.imageName?-(Uc-r.metrics.width*r.scale)/2:(r.scale-1)*Uc)),r.imageName){const t=s[r.imageName];d=t.sdf,p=t.pixelRatio,u=Qc/p}const _=n?[r.x+g,r.y]:[0,0];let y=n?[0,0]:[r.x+g+i[0],r.y+i[1]-f],x=[0,0];m&&(x=y,y=[0,0]);const v=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-u)*r.scale-g+y[0],w=(-r.metrics.top-u)*r.scale+y[1],T=b+o.w/v*r.scale/p,P=w+o.h/v*r.scale/p,M=new l(b,w),S=new l(T,w),C=new l(b,P),I=new l(T,P);if(m){const t=new l(-g,g-rh),e=-Math.PI/2,i=Uc/2-g,n=new l(5-rh-i,-(r.imageName?i:0)),o=new l(...x);M._rotateAround(e,t)._add(n)._add(o),S._rotateAround(e,t)._add(n)._add(o),C._rotateAround(e,t)._add(n)._add(o),I._rotateAround(e,t)._add(n)._add(o)}if(c){const t=Math.sin(c),e=Math.cos(c),i=[e,-t,t,e];M._matMult(i),S._matMult(i),C._matMult(i),I._matMult(i)}const A=new l(0,0),E=new l(0,0);h.push({tl:M,tr:S,bl:C,br:I,tex:o,writingMode:e.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:A,pixelOffsetBR:E,minFontScaleX:0,minFontScaleY:0})}return h}(0,i,a,n,o,s,r,t.allowVerticalPlacement),_=t.textSizeData;let y=null;"source"===_.kind?(y=[Ih*n.layout.get("text-size").evaluate(s,{})],y[0]>Ah&&Z(`${t.layerIds[0]}: Value for "text-size" is >= ${Ch}. Reduce your "text-size".`)):"composite"===_.kind&&(y=[Ih*f.compositeTextSizes[0].evaluate(s,{},m),Ih*f.compositeTextSizes[1].evaluate(s,{},m)],(y[0]>Ah||y[1]>Ah)&&Z(`${t.layerIds[0]}: Value for "text-size" is >= ${Ch}. Reduce your "text-size".`)),t.addSymbols(t.text,g,y,a,o,s,h,e,c.lineStartIndex,c.lineLength,p,m);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function Xu(t){for(const e in t)return t[e];return null}function Ku(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const Yu=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Ju{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Yu[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Ju(s,o,n,t)}constructor(t,e=64,i=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const n=Yu.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Qu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=t&&a<=i&&c>=e&&c<=r&&l.push(n[s])}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=t&&p<=i&&f>=e&&f<=r&&l.push(n[d]),(0===c?t<=p:e<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)rd(n[2*i],n[2*i+1],t,e)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];rd(p,f,t,e)<=l&&a.push(r[d]),(0===c?t-i<=p:e-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?t+i>=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Qu(t,e,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;td(t,e,s,r,n,o),Qu(t,e,i,r,s-1,1-o),Qu(t,e,i,s+1,n,1-o)}function td(t,e,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);td(t,e,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o)}const s=e[2*i+o];let a=r,l=n;for(ed(t,e,r,i),e[2*n+o]>s&&ed(t,e,r,n);a<l;){for(ed(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*r+o]===s?ed(t,e,r,l):(l++,ed(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function ed(t,e,i,r){id(t,i,r),id(e,2*i,2*r),id(e,2*i+1,2*r+1)}function id(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function rd(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}var nd;t.cn=void 0,(nd=t.cn||(t.cn={})).create="create",nd.load="load",nd.fullLoad="fullLoad";let od=null,sd=[];const ad=1e3/60,ld="loadTime",cd="fullLoadTime",hd={mark(t){performance.mark(t)},frame(t){const e=t;null!=od&&sd.push(e-od),od=e},clearMetrics(){od=null,sd=[],performance.clearMeasures(ld),performance.clearMeasures(cd);for(const e in t.cn)performance.clearMarks(t.cn[e])},getPerformanceMetrics(){performance.measure(ld,t.cn.create,t.cn.load),performance.measure(cd,t.cn.create,t.cn.fullLoad);const e=performance.getEntriesByName(ld)[0].duration,i=performance.getEntriesByName(cd)[0].duration,r=sd.length,n=1/(sd.reduce(((t,e)=>t+e),0)/r/1e3),o=sd.filter((t=>t>ad)).reduce(((t,e)=>t+(e-ad)/ad),0);return{loadTime:e,fullLoadTime:i,fps:n,percentDroppedFrames:o/(r+o)*100,totalFrames:r}}};t.$=function(t,e,i,r){const n=e.y-t.y,o=e.x-t.x,s=r.y-i.y,a=r.x-i.x,c=s*o-a*n;if(0===c)return null;const h=(a*(t.y-i.y)-s*(t.x-i.x))/c;return new l(t.x+h*o,t.y+h*n)},t.A=g,t.B=si,t.C=go,t.D=Mo,t.E=mt,t.F=Un,t.G=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return q},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Jh((()=>this.process())),this.subscription=J(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=G(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}sendAsync(t,e){return new Promise(((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=e?J(e.signal,"abort",(()=>{null==o||o.unsubscribe(),delete this.resolveRejects[n];const e={id:n,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)}),Qh):null;this.resolveRejects[n]={resolve:t=>{null==o||o.unsubscribe(),i(t)},reject:t=>{null==o||o.unsubscribe(),r(t)}};const s=[],a=Object.assign(Object.assign({},t),{id:n,sourceMapId:this.mapId,origin:location.origin,data:Jn(t.data,s)});this.target.postMessage(a,{transfer:s})}))}receive(t){const e=t.data,i=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];const t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(G(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,i){return e(this,void 0,void 0,(function*(){if("<response>"===i.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(i.error?e.reject(Qn(i.error)):e.resolve(Qn(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Qn(i.data),r=new AbortController;this.abortControllers[t]=r;try{const n=yield this.messageHandlers[i.type](i.sourceMapId,e,r);this.completeTask(t,null,n)}catch(e){this.completeTask(t,e)}}))}completeTask(t,e,i){const r=[];delete this.abortControllers[t];const n={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?Jn(e):null,data:Jn(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},t.I=th,t.J=st,t.K=R,t.L=function(){var t=new g(16);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.M=function(t,e,i){var r=i[0],n=i[1],o=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=t,a=n?R(ni.interpolationFactor(n,e,o,s),0,1):0;"camera"===t.kind?r=si.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}},t.O=function(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/Ih:"composite"===t.kind?si.number(r/Ih,n/Ih,i):e},t.P=l,t.Q=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],_=e[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,P=h*m-u*f,M=h*g-d*f,S=h*_-p*f,C=u*g-d*m,I=u*_-p*m,A=d*_-p*g,E=y*A-x*I+v*C+b*S-w*M+T*P;return E?(t[0]=(a*A-l*I+c*C)*(E=1/E),t[1]=(n*I-r*A-o*C)*E,t[2]=(m*T-g*w+_*b)*E,t[3]=(d*w-u*T-p*b)*E,t[4]=(l*S-s*A-c*M)*E,t[5]=(i*A-n*S+o*M)*E,t[6]=(g*v-f*T-_*x)*E,t[7]=(h*T-d*v+p*x)*E,t[8]=(s*I-a*S+c*P)*E,t[9]=(r*S-i*I-o*P)*E,t[10]=(f*w-m*v+_*y)*E,t[11]=(u*v-h*w-p*y)*E,t[12]=(a*M-s*C-l*P)*E,t[13]=(i*C-r*M+n*P)*E,t[14]=(m*x-f*b-g*y)*E,t[15]=(h*b-u*x+d*y)*E,t):null},t.R=$a,t.S=S,t.T=xo,t.U=function(t){return Math.hypot(t[0],t[1])},t.V=function(t){return t[0]=0,t[1]=0,t},t.X=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},t.Y=Rh,t.Z=P,t._=e,t.a=nt,t.a$=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+c*r,t[5]=s*n+h*r,t[6]=a*n+u*r,t[7]=l*n+d*r,t[8]=c*n-o*r,t[9]=h*n-s*r,t[10]=u*n-a*r,t[11]=d*n-l*r,t},t.a0=tu,t.a1=ya,t.a2=y,t.a3=function(t,e,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],g=i[1],_=i[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=d,t[10]=p,t[11]=f,t[12]=r*m+a*g+u*_+e[12],t[13]=n*m+l*g+d*_+e[13],t[14]=o*m+c*g+p*_+e[14],t[15]=s*m+h*g+f*_+e[15]),t},t.a4=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of t)e=Math.min(e,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return[e,i,r,n]},t.a5=Uc,t.a6=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*a+b*u+w*m,t[1]=x*n+v*l+b*d+w*g,t[2]=x*o+v*c+b*p+w*_,t[3]=x*s+v*h+b*f+w*y,t[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,t[5]=x*n+v*l+b*d+w*g,t[6]=x*o+v*c+b*p+w*_,t[7]=x*s+v*h+b*f+w*y,t[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,t[9]=x*n+v*l+b*d+w*g,t[10]=x*o+v*c+b*p+w*_,t[11]=x*s+v*h+b*f+w*y,t[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,t[13]=x*n+v*l+b*d+w*g,t[14]=x*o+v*c+b*p+w*_,t[15]=x*s+v*h+b*f+w*y,t},t.a7=function(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i},t.a8=iu,t.a9=su,t.aA=function(t,e,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const o=n?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(o){const t=Math.sin(o),e=Math.cos(o);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[n?i[0]:A(e,i[0],t.zoom,t.detailLevel),n?i[1]:A(e,i[1],t.zoom,t.detailLevel)]},t.aC=kh,t.aD=qu,t.aE=_h,t.aF=Ju,t.aG=Fo,t.aH=Cl,t.aI=xs,t.aJ=Rs,t.aK=ks,t.aL=F,t.aM=Q,t.aN=cu,t.aO=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},t.aP=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t},t.aQ=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.aS=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},t.aT=function(t,e){var i=e[0],r=e[1],n=e[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},t.aU=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=n*l-o*a,t[1]=o*s-r*l,t[2]=r*a-n*s,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=pu,t.aX=mu,t.aY=function(t,e,i,r,n){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(o=1/(r-n)),t[14]=2*n*r*o):(t[10]=-1,t[14]=-2*r),t},t.aZ=function(t){var e=new g(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+c*r,t[1]=s*n+h*r,t[2]=a*n+u*r,t[3]=l*n+d*r,t[4]=c*n-o*r,t[5]=h*n-s*r,t[6]=u*n-a*r,t[7]=d*n-l*r,t},t.aa=ou,t.ab=p,t.ac=f,t.ad=X,t.ae=fu,t.af=I,t.ag=hu,t.ah=25,t.ai=du,t.aj=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const i of t){const t=window.document.createElement("source");ht(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))},t.ak=It,t.al=function(){return O++},t.am=ls,t.an=jh,t.ao=tn,t.ap=fa,t.aq=yu,t.ar=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const o=r||n;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e},t.as=function(t){return t*Math.PI/180},t.at=function(t){return Math.pow(2,t)},t.au=85.051129,t.av=au,t.aw=function(t){return Math.log(t)/Math.LN2},t.ax=function(t){var e=t[0],i=t[1];return e*e+i*i},t.ay=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i},t.az=A,t.b=W,t.b$=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.b0=function(){const t=new Float32Array(16);return y(t),t},t.b1=function(){const t=new Float64Array(16);return y(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,i){const r=new Float64Array(4);return function(t,e,i,r){var n=.5*Math.PI/180;e*=n,i*=n,r*=n;var o=Math.sin(e),s=Math.cos(e),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);t[0]=o*l*h-s*a*c,t[1]=s*a*h+o*l*c,t[2]=s*l*c-o*a*h,t[3]=s*l*h+o*a*c}(r,t,e-90,i),r},t.b4=function(t,e,i,r){var n,o,s,a,l,c=e[0],h=e[1],u=e[2],d=e[3],p=i[0],f=i[1],g=i[2],_=i[3];return(o=c*p+h*f+u*g+d*_)<0&&(o=-o,p=-p,f=-f,g=-g,_=-_),1-o>m?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),t[0]=a*c+l*p,t[1]=a*h+l*f,t[2]=a*u+l*g,t[3]=a*d+l*_,t},t.b5=function(t){const e=new Float64Array(9);var i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x;u=(n=(r=t)[0])*(l=n+n),d=(o=r[1])*l,f=(s=r[2])*l,m=s*(c=o+o),_=(a=r[3])*l,y=a*c,x=a*(h=s+s),(i=e)[0]=1-(p=o*c)-(g=s*h),i[3]=d-x,i[6]=f+y,i[1]=d+x,i[4]=1-u-g,i[7]=m-_,i[2]=f-y,i[5]=m+_,i[8]=1-u-p;const v=Q(-Math.asin(R(e[2],-1,1)));let b,w;return Math.hypot(e[5],e[8])<.001?(b=0,w=-Q(Math.atan2(e[3],e[4]))):(b=Q(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),w=Q(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:b,pitch:v+90,bearing:w}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=ve,t.b8=Ys,t.b9=Il,t.bA=function(t){if("custom"===t.type)return new Yh(t);switch(t.type){case"background":return new Wh(t);case"circle":return new Ra(t);case"fill":return new Nl(t);case"fill-extrusion":return new uc(t);case"heatmap":return new Wa(t);case"hillshade":return new Ka(t);case"line":return new Cc(t);case"raster":return new Kh(t);case"symbol":return new $h(t)}},t.bB=V,t.bC=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!xt(t.version,e.version))return[{command:"setStyle",args:[e]}];xt(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),xt(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),xt(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),xt(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),xt(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),xt(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),xt(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),xt(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),xt(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),xt(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),xt(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),xt(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),xt(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const r={},n=[];!function(t,e,i,r){let n;for(n in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)||wt(n,i,r));for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)?xt(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&Pt(t,e,n)?vt(i,{command:"setGeoJSONSourceData",args:[n,e[n].data]}):Tt(n,e,i,r)):bt(n,e,i))}(t.sources,e.sources,n,r);const o=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):o.push(t)})),i=i.concat(n),function(t,e,i){e=e||[];const r=(t=t||[]).map(St),n=e.map(St),o=t.reduce(Ct,{}),s=e.reduce(Ct,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p;for(let t=0,e=0;t<r.length;t++)c=r[t],Object.prototype.hasOwnProperty.call(s,c)?e++:(vt(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,e),1));for(let t=0,e=0;t<n.length;t++)c=n[n.length-1-t],a[a.length-1-t]!==c&&(Object.prototype.hasOwnProperty.call(o,c)?(vt(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-e),1)):e++,d=a[a.length-t],vt(i,{command:"addLayer",args:[s[c],d]}),a.splice(a.length-t,0,c),l[c]=!0);for(let t=0;t<n.length;t++)if(c=n[t],h=o[c],u=s[c],!l[c]&&!xt(h,u))if(xt(h.source,u.source)&&xt(h["source-layer"],u["source-layer"])&&xt(h.type,u.type)){for(p in Mt(h.layout,u.layout,i,c,null,"setLayoutProperty"),Mt(h.paint,u.paint,i,c,null,"setPaintProperty"),xt(h.filter,u.filter)||vt(i,{command:"setFilter",args:[c,u.filter]}),xt(h.minzoom,u.minzoom)&&xt(h.maxzoom,u.maxzoom)||vt(i,{command:"setLayerZoomRange",args:[c,u.minzoom,u.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Mt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):xt(h[p],u[p])||vt(i,{command:"setLayerProperty",args:[c,p,u[p]]}));for(p in u)Object.prototype.hasOwnProperty.call(u,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Mt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):xt(h[p],u[p])||vt(i,{command:"setLayerProperty",args:[c,p,u[p]]}))}else vt(i,{command:"removeLayer",args:[c]}),d=a[a.lastIndexOf(c)+1],vt(i,{command:"addLayer",args:[u,d]})}(o,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i},t.bD=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.bE=function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],i[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(e).length!==Object.keys(i).length)return!1;for(const r in e)if(!t(e[r],i[r]))return!1;return!0}return e===i},t.bF=j,t.bG=N,t.bH=function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)for(let r=0;r<4;r++)if(t[i][r]!==e[i][r])return!1;return!0},t.bI=class extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.bJ=Qs,t.bK=class extends Ks{constructor(t,e){super(t,e),this.current=ta}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.bL=Js,t.bM=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.bN=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.bO=_,t.bP=function(t,e){var i=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.bQ=function(t,e,i){var r=e[0],n=e[1],o=e[2];return t[0]=r*i[0]+n*i[3]+o*i[6],t[1]=r*i[1]+n*i[4]+o*i[7],t[2]=r*i[2]+n*i[5]+o*i[8],t},t.bR=function(t,e,i,r,n,o,s){var a=1/(e-i),l=1/(r-n),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(s+o)*c,t[15]=1,t},t.bS=class extends Ko{},t.bT=Lc,t.bU=class extends Jo{},t.bV=qa,t.bW=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.bX=Ga,t.bY=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,t[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,t},t.bZ=class extends No{},t.b_=class extends os{},t.ba=Al,t.bb=Sl,t.bc=k,t.bd=z,t.be=Ee,t.bf=function(t,e,i,r,n){return k(r,n,R((t-e)/(i-e),0,1))},t.bg=E,t.bh=function(){return new Float64Array(3)},t.bi=function(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t},t.bj=T,t.bk=function(){return new Float64Array(4)},t.bl=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bm=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bn=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bo=v,t.bp=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n-c*r,t[1]=s*n-h*r,t[2]=a*n-u*r,t[3]=l*n-d*r,t[8]=o*r+c*n,t[9]=s*r+h*n,t[10]=a*r+u*n,t[11]=l*r+d*n,t},t.bq=function(t,e){const i=E(t,360),r=E(e,360),n=r-i,o=r>i?n-360:n+360;return Math.abs(n)<Math.abs(o)?n:o},t.br=function(t){return t[0]=0,t[1]=0,t[2]=0,t},t.bs=function(t,e,i,r){const n=Math.sqrt(t*t+e*e),o=Math.sqrt(i*i+r*r);t/=n,e/=n,i/=o,r/=o;const s=Math.acos(t*i+e*r);return-e*i+t*r>0?s:-s},t.bt=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bu=eu,t.bv=function(t,e){const i=E(t,2*Math.PI),r=E(e,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))},t.bw=function(){const t={},e=gt.$version;for(const i in gt.$root){const r=gt.$root[i];if(r.required){let n=null;n="version"===i?e:"array"===r.type?[]:{},null!=n&&(t[i]=n)}}return t},t.bx=to,t.by=lt,t.bz=function(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=yt(t[i],e[t[i].ref]));return t},t.c=rt,t.c0=function(t,e){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],g=t[13],_=t[14],y=t[15],x=e[0],v=e[1],b=e[2],w=e[3],T=e[4],P=e[5],M=e[6],S=e[7],C=e[8],I=e[9],A=e[10],E=e[11],k=e[12],z=e[13],L=e[14],D=e[15];return Math.abs(i-x)<=m*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(r-v)<=m*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=m*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=m*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(a-P)<=m*Math.max(1,Math.abs(a),Math.abs(P))&&Math.abs(l-M)<=m*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(c-S)<=m*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(h-C)<=m*Math.max(1,Math.abs(h),Math.abs(C))&&Math.abs(u-I)<=m*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(d-A)<=m*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(p-E)<=m*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(f-k)<=m*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(g-z)<=m*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-L)<=m*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(y-D)<=m*Math.max(1,Math.abs(y),Math.abs(D))},t.c1=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.c2=t=>"symbol"===t.type,t.c3=t=>"circle"===t.type,t.c4=t=>"heatmap"===t.type,t.c5=t=>"line"===t.type,t.c6=t=>"fill"===t.type,t.c7=t=>"fill-extrusion"===t.type,t.c8=t=>"hillshade"===t.type,t.c9=t=>"raster"===t.type,t.cA=bc,t.cB=Fl,t.cC=oc,t.cD=ec,t.cE=qc,t.cF=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cG=function(t,i,r,n,o){return e(this,void 0,void 0,(function*(){if(f())try{return yield X(t,i,r,n,o)}catch(t){}return function(t,e,i,r,n){const o=t.width,s=t.height;K&&Y||(K=new OffscreenCanvas(o,s),Y=K.getContext("2d",{willReadFrequently:!0})),K.width=o,K.height=s,Y.drawImage(t,0,0,o,s);const a=Y.getImageData(e,i,r,n);return Y.clearRect(0,0,o,s),a.data}(t,i,r,n,o)}))},t.cH=gu,t.cI=i,t.cJ=o,t.cK=tc,t.cL=Gc,t.cM=mo,t.ca=t=>"background"===t.type,t.cb=t=>"custom"===t.type,t.cc=L,t.cd=function(t,e,i){const r=C(e.x-i.x,e.y-i.y),n=C(t.x-i.x,t.y-i.y);var o,s;return Q(Math.atan2(r[0]*n[1]-r[1]*n[0],(o=r)[0]*(s=n)[0]+o[1]*s[1]))},t.ce=D,t.cf=function(t,e){return et[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.cg=function(t,e){return tt[e]&&"touches"in t},t.ch=function(t){return tt[t]||et[t]},t.ci=function(t,e,i){var r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t},t.cj=function(t,e){const{x:i,y:r}=hu.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)},t.ck=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cl=class extends jo{},t.cm=hd,t.co=function(t){return t.message===it},t.cp=function(t,e,i,r,n,o){const s=Pe.fromString(t),a=oh.fromFeature(s,e);return sh(a,gh(a,i*Uc,r*Uc,o,{},n))},t.cq=at,t.cr=function(t,e){nt.REGISTERED_PROTOCOLS[t]=e},t.cs=function(t){delete nt.REGISTERED_PROTOCOLS[t]},t.ct=qr,t.cu=function(t,e){const i={};for(let r=0;r<t.length;r++){const n=e&&e[t[r].id]||hn(t[r]);e&&(e[t[r].id]=n);let o=i[n];o||(o=i[n]=[]),o.push(t[r])}const r=[];for(const t in i)r.push(i[t]);return r},t.cv=Hn,t.cw=_u,t.cx=xu,t.cy=eh,t.cz=function(e){var i,r,n,o,s;e.bucket.createArrays(),e.bucket.tilePixelRatio=I/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const a=e.bucket.layers[0],l=a.layout,c=a.metadata,h=a._unevaluatedLayout._values,u={layoutIconSize:h["icon-size"].possiblyEvaluate(new go(e.bucket.zoom+1),e.canonical),layoutTextSize:h["text-size"].possiblyEvaluate(new go(e.bucket.zoom+1),e.canonical),textMaxSize:h["text-size"].possiblyEvaluate(new go(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;u.compositeTextSizes=[h["text-size"].possiblyEvaluate(new go(t),e.canonical),h["text-size"].possiblyEvaluate(new go(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;u.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new go(t),e.canonical),h["icon-size"].possiblyEvaluate(new go(i),e.canonical)]}const d=l.get("text-line-height")*Uc,p="viewport"!==l.get("text-rotation-alignment")&&"point"!==l.get("symbol-placement"),f=l.get("text-keep-upright"),m=l.get("text-size");for(const h of e.bucket.features){const g=l.get("text-font").evaluate(h,{},e.canonical).join(","),_=m.evaluate(h,{},e.canonical),y=u.layoutTextSize.evaluate(h,{},e.canonical),x=u.layoutIconSize.evaluate(h,{},e.canonical),v={horizontal:{},vertical:void 0},b=h.text;let w,T=[0,0];if(b){const r=b.toString(),n=null!==(i=null==c?void 0:c["text-letter-spacing-correction"])&&void 0!==i?i:0,o=(l.get("text-letter-spacing").evaluate(h,{},e.canonical)+n)*Uc,s=ro(r)?o:0,u=l.get("text-anchor").evaluate(h,{},e.canonical),m=Gu(a,h,e.canonical);if(!m){const t=l.get("text-radial-offset").evaluate(h,{},e.canonical);T=t?$u(u,[t*Uc,Zu]):l.get("text-offset").evaluate(h,{},e.canonical).map((t=>t*Uc))}let x=p?"center":l.get("text-justify").evaluate(h,{},e.canonical);const w="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(h,{},e.canonical)*Uc:1/0,P=()=>{e.bucket.allowVerticalPlacement&&io(r)&&(v.vertical=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,"left",s,T,t.W.vertical,!0,y,_))};if(!p&&m){const i=new Set;if("auto"===x)for(let t=0;t<m.values.length;t+=2)i.add(qu(m.values[t]));else i.add(x);let r=!1;for(const n of i)if(!v.horizontal[n])if(r)v.horizontal[n]=v.horizontal[0];else{const i=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,"center",n,s,T,t.W.horizontal,!1,y,_);i&&(v.horizontal[n]=i,r=1===i.positionedLines.length)}P()}else{"auto"===x&&(x=qu(u));const i=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,x,s,T,t.W.horizontal,!1,y,_);i&&(v.horizontal[x]=i),P(),io(r)&&p&&f&&(v.vertical=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,x,s,T,t.W.vertical,!1,y,_))}}let P=!1;if(h.icon&&h.icon.name){const t=e.imageMap[h.icon.name];if(t){w=Ph(e.imagePositions[h.icon.name],l.get("icon-offset").evaluate(h,{},e.canonical),l.get("icon-anchor").evaluate(h,{},e.canonical)),P=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=P:e.bucket.sdfIcons!==P&&Z("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer");const i=null!==(n=null===(r=h.properties)||void 0===r?void 0:r["icon-rotate"])&&void 0!==n?n:l.get("icon-rotate").constantOr(1),a=null!==(s=null===(o=h.properties)||void 0===o?void 0:o["icon-size"])&&void 0!==s?s:l.get("icon-size").constantOr(1);t.pixelRatio===e.bucket.pixelRatio&&0===i&&1===a||(e.bucket.iconsNeedLinear=!0)}}const M=Xu(v.horizontal)||v.vertical;e.bucket.iconsInText=!!M&&M.iconsInText,(M||w)&&Wu(e.bucket,h,v,w,e.imageMap,u,y,x,T,P,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},t.d=ht,t.e=B,t.f=t=>e(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=ot,t.h=t=>new Promise(((e,i)=>{const r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=H}))},r.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."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):H})),t.i=G,t.j=(t,e)=>ct(B(t,{type:"json"}),e),t.k=ft,t.l=pt,t.m=ct,t.n=(t,e)=>ct(B(t,{type:"arrayBuffer"}),e),t.o=function(t){return new qc(t).readFields(Hc,[])},t.p=Jc,t.q=Za,t.r=Eo,t.s=J,t.t=Vn,t.u=eo,t.v=gt,t.w=Z,t.x=Gn,t.y=Nn,t.z=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}}})),i("worker",["./shared"],(function(t){class e{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,i){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.bA(i);e._featureFilter=t.ao(e.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=t.cu(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const e=t.map((t=>this._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(e)}}}class i{constructor(e){const i={},r=[];for(const t in e){const n=e[t],o=i[t]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),o[t]={rect:i,metrics:e.metrics}}}const{w:n,h:o}=t.p(r),s=new t.q({width:n||1,height:o||1});for(const r in e){const n=e[r];for(const e in n){const o=n[+e];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[r][e].rect;t.q.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}t.cv("GlyphAtlas",i);class r{constructor(e){this.tileID=new t.ae(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=[]}parse(e,r,o,s,a){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.am;const l=new t.cw(Object.keys(e.layers).sort()),c=new t.cx(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:o,subdivisionGranularity:a},d=r.familiesBySource[this.source];for(const i in d){const r=e.layers[i];if(!r)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let t=0;t<r.length;t++){const e=r.feature(t),n=c.getId(e,i);a.push({feature:e,id:n,index:t,sourceLayerIndex:s})}for(const e of d[i]){const i=e[0];i.source!==this.source&&t.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.minzoom&&this.zoom<Math.floor(i.minzoom)||i.maxzoom&&this.zoom>=i.maxzoom||"none"!==i.visibility&&(n(e,this.zoom,o),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map((t=>t.id))))}}const p=t.bF(u.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const t=new AbortController;this.inFlightDependencies.push(t),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const m=Object.keys(u.iconDependencies);let g=Promise.resolve({});if(m.length){const t=new AbortController;this.inFlightDependencies.push(t),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},t)}const _=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(_.length){const t=new AbortController;this.inFlightDependencies.push(t),y=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[x,v,b]=yield Promise.all([f,g,y]),w=new i(x),T=new t.cy(v,b);for(const e in h){const i=h[e];i instanceof t.an?(n(i.layers,this.zoom,o),t.cz({bucket:i,glyphMap:x,glyphPositions:w.positions,imageMap:v,imagePositions:T.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):i.hasPattern&&(i instanceof t.cA||i instanceof t.cB||i instanceof t.cC)&&(n(i.layers,this.zoom,o),i.addFeatures(u,this.tileID.canonical,T.patternPositions))}return this.status="done",{buckets:Object.values(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:w.image,imageAtlas:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?v:null,glyphPositions:this.returnDependencies?w.positions:null}}))}}function n(e,i,r){const n=new t.C(i);for(const t of e)t.recalculate(n,r)}class o{constructor(t,e,i){this.actor=t,this.layerIndex=e,this.availableImages=i,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const r=yield t.n(e.request,i);try{return{vectorTile:new t.cD.VectorTile(new t.cE(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires}}catch(t){const i=new Uint8Array(r.data);let n=`Unable to parse the tile at ${e.request.url}, `;throw n+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.message}`,new Error(n)}}))}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid,n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.cF(e.request),o=new r(e);this.loading[i]=o;const s=new AbortController;o.abort=s;try{const r=yield this.loadVectorTile(e,s);if(delete this.loading[i],!r)return null;const a=r.rawData,l={};r.expires&&(l.expires=r.expires),r.cacheControl&&(l.cacheControl=r.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}o.vectorTile=r.vectorTile;const h=o.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);this.loaded[i]=o,this.fetching[i]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const e=yield h;return t.e({rawTileData:a.slice(0)},e,l,c)}finally{delete this.fetching[i]}}catch(t){throw delete this.loading[i],o.status="done",this.loaded[i]=o,t}}))}reloadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[i];if(r.showCollisionBoxes=e.showCollisionBoxes,"parsing"===r.status){const n=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:e,cacheControl:r,resourceTiming:s}=this.fetching[i];delete this.fetching[i],o=t.e({rawTileData:e.slice(0)},n,r,s)}else o=n;return o}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){const t=this.loading,i=e.uid;t&&t[i]&&t[i].abort&&(t[i].abort.abort(),delete t[i])}))}removeTile(e){return t._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]}))}}class s{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:i,encoding:r,rawImageData:n,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=e,c=n.width+2,h=n.height+2,u=t.b(n)?new t.R({width:c,height:h},yield t.cG(n,-1,-1,c,h)):n,d=new t.cH(i,u,r,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d}))}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}var a,l,c=function(){if(l)return a;function t(t,i){if(0!==t.length){e(t[0],i);for(var r=1;r<t.length;r++)e(t[r],!i)}}function e(t,e){for(var i=0,r=0,n=0,o=t.length,s=o-1;n<o;s=n++){var a=(t[n][0]-t[s][0])*(t[s][1]+t[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}return l=1,a=function e(i,r){var n,o=i&&i.type;if("FeatureCollection"===o)for(n=0;n<i.features.length;n++)e(i.features[n],r);else if("GeometryCollection"===o)for(n=0;n<i.geometries.length;n++)e(i.geometries[n],r);else if("Feature"===o)e(i.geometry,r);else if("Polygon"===o)t(i.coordinates,r);else if("MultiPolygon"===o)for(n=0;n<i.coordinates.length;n++)t(i.coordinates[n],r);return i}}(),h=t.cI(c);const u=t.cD.VectorTileFeature.prototype.toGeoJSON;class d{constructor(e){this._feature=e,this.extent=t.af,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.P(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return u.call(this,t,e,i)}}class p{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.af,this.length=e.length,this._features=e}feature(t){return new d(this._features[t])}}var f,m,g,_={exports:{}},y=function(){if(g)return _.exports;g=1;var e=t.cL(),i=function(){if(m)return f;m=1;var e=t.cJ(),i=t.cK().VectorTileFeature;function r(t,e){this.options=e||{},this.features=t,this.length=t.length}function n(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return f=r,r.prototype.feature=function(t){return new n(this.features[t],this.options.extent)},n.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i<t.length;i++){for(var r=t[i],n=[],o=0;o<r.length;o++)n.push(new e(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},n.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<t.length;o++)for(var s=t[o],a=0;a<s.length;a++){var l=s[a];e=Math.min(e,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[e,r,i,n]},n.prototype.toGeoJSON=i.prototype.toGeoJSON,f}();function r(t){var i=new e;return function(t,e){for(var i in t.layers)e.writeMessage(3,n,t.layers[i])}(t,i),i.finish()}function n(t,e){var i;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<t.length;i++)r.feature=t.feature(i),e.writeMessage(2,o,r);var n=r.keys;for(i=0;i<n.length;i++)e.writeStringField(3,n[i]);var s=r.values;for(i=0;i<s.length;i++)e.writeMessage(4,h,s[i])}function o(t,e){var i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,s,t),e.writeVarintField(3,i.type),e.writeMessage(4,c,i)}function s(t,e){var i=t.feature,r=t.keys,n=t.values,o=t.keycache,s=t.valuecache;for(var a in i.properties){var l=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),o[a]=c=r.length-1),e.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,d=s[u];void 0===d&&(n.push(l),s[u]=d=n.length-1),e.writeVarint(d)}}}function a(t,e){return(e<<3)+(7&t)}function l(t){return t<<1^t>>31}function c(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,s=i.length,c=0;c<s;c++){var h=i[c],u=1;1===r&&(u=h.length),e.writeVarint(a(1,u));for(var d=3===r?h.length-1:h.length,p=0;p<d;p++){1===p&&1!==r&&e.writeVarint(a(2,d-1));var f=h[p].x-n,m=h[p].y-o;e.writeVarint(l(f)),e.writeVarint(l(m)),n+=f,o+=m}3===r&&e.writeVarint(a(7,1))}}function h(t,e){var i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}return _.exports=r,_.exports.fromVectorTileJs=r,_.exports.fromGeojsonVt=function(t,e){e=e||{};var n={};for(var o in t)n[o]=new i(t[o].features,e),n[o].name=o,n[o].version=e.version,n[o].extent=e.extent;return r({layers:n})},_.exports.GeoJSONWrapper=i,_.exports}(),x=t.cI(y);const v={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},b=Math.fround||(w=new Float32Array(1),t=>(w[0]=+t,w[0]));var w;const T=3,P=5,M=6;class S{constructor(t){this.options=Object.assign(Object.create(v),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:r}=this.options;e&&console.time("total time");const n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;const o=[];for(let e=0;e<t.length;e++){const i=t[e];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,s=b(A(r)),a=b(E(n));o.push(s,a,1/0,e,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[r+1]=this._createTree(o);e&&console.timeEnd(n);for(let t=r;t>=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,o],e),s=this.getClusters([-180,r,n,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(A(i),E(o),A(n),E(r)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+P]>1?C(l,e,this.clusterProps):this.points[l[e+T]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(e*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+P]>1?C(o,i,this.clusterProps):this.points[o[i+T]])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((e-a)/n,l,(e+1+a)/n,c),r.data,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(t,o.cluster_id,i,r,n):n<r?n++:t.push(e),t.length===i)break}return n}_createTree(e){const i=new t.aF(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)i.add(e[t],e[t+1]);return i.finish(),i.data=e,i}_addTileFeatures(t,e,i,r,n,o){for(const s of t){const t=s*this.stride,a=e[t+P]>1;let l,c,h;if(a)l=I(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+T]];l=i.properties;const[r,n]=i.geometry.coordinates;c=A(r),h=E(n)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;d=a||this.options.generateId?e[t+T]:this.points[e[t+T]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=e)continue;a[i+2]=e;const r=a[i],h=a[i+1],u=t.within(a[i],a[i+1],s),d=a[i+P];let p=d;for(const t of u){const i=t*c;a[i+2]>e&&(p+=a[i+P])}if(p>d&&p>=o){let t,o=r*d,s=h*d,f=-1;const m=(i/c<<5)+(e+1)+this.points.length;for(const r of u){const l=r*c;if(a[l+2]<=e)continue;a[l+2]=e;const h=a[l+P];o+=a[l]*h,s+=a[l+1]*h,a[l+4]=m,n&&(t||(t=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(t)),n(t,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let t=0;t<c;t++)l.push(a[i+t]);if(p>1)for(const t of u){const i=t*c;if(!(a[i+2]<=e)){a[i+2]=e;for(let t=0;t<c;t++)l.push(a[i+t])}}}}return l}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+P]>1){const r=this.clusterProps[t[e+M]];return i?Object.assign({},r):r}const r=this.points[t[e+T]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function C(t,e,i){return{type:"Feature",id:t[e+T],properties:I(t,e,i),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),k(t[e+1])]}};var r}function I(t,e,i){const r=t[e+P],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=t[e+M],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+T],point_count:r,point_count_abbreviated:n})}function A(t){return t/360+.5}function E(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function k(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function z(t,e,i,r){let n=r;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let r=e+3;r<i;r+=3){const e=L(t[r],t[r+1],l,c,h,u);if(e>n)s=r,n=e;else if(e===n){const t=Math.abs(r-o);t<a&&(s=r,a=t)}}n>r&&(s-e>3&&z(t,e,s,r),t[s+2]=n,i-s>3&&z(t,s,i,r))}function L(t,e,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const l=((t-i)*s+(e-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return s=t-i,a=e-r,s*s+a*a}function D(t,e,i,r){const n={id:null==t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)R(n,i);else if("Polygon"===e)R(n,i[0]);else if("MultiLineString"===e)for(const t of i)R(n,t);else if("MultiPolygon"===e)for(const t of i)R(n,t[0]);return n}function R(t,e){for(let i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function F(t,e,i,r){if(!e.geometry)return;const n=e.geometry.coordinates;if(n&&0===n.length)return;const o=e.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);let a=[],l=e.id;if(i.promoteId?l=e.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)B(n,a);else if("MultiPoint"===o)for(const t of n)B(t,a);else if("LineString"===o)O(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(const i of n)a=[],O(i,a,s,!1),t.push(D(l,"LineString",a,e.properties));return}j(n,a,s,!1)}else if("Polygon"===o)j(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const n of e.geometry.geometries)F(t,{id:l,geometry:n,properties:e.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of n){const e=[];j(t,e,s,!0),a.push(e)}}t.push(D(l,o,a,e.properties))}function B(t,e){e.push(N(t[0]),V(t[1]),0)}function O(t,e,i,r){let n,o,s=0;for(let i=0;i<t.length;i++){const a=N(t[i][0]),l=V(t[i][1]);e.push(a,l,0),i>0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=e.length-3;e[2]=1,z(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function j(t,e,i,r){for(let n=0;n<t.length;n++){const o=[];O(t[n],o,i,r),e.push(o)}}function N(t){return t/360+.5}function V(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function U(t,e,i,r,n,o,s,a){if(r/=e,o>=(i/=e)&&s<r)return t;if(s<i||o>=r)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===n?e.minX:e.minY,c=0===n?e.maxX:e.maxY;if(s>=i&&c<r){l.push(e);continue}if(c<i||s>=r)continue;let h=[];if("Point"===o||"MultiPoint"===o)Z(t,h,i,r,n);else if("LineString"===o)$(t,h,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)q(t,h,i,r,n,!1);else if("Polygon"===o)q(t,h,i,r,n,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];q(e,t,i,r,n,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(D(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(D(e.id,o,h,e.tags))}}return l.length?l:null}function Z(t,e,i,r,n){for(let o=0;o<t.length;o+=3){const s=t[o+n];s>=i&&s<=r&&W(e,t[o],t[o+1],t[o+2])}}function $(t,e,i,r,n,o,s){let a=G(t);const l=0===n?H:X;let c,h,u=t.start;for(let d=0;d<t.length-3;d+=3){const p=t[d],f=t[d+1],m=t[d+2],g=t[d+3],_=t[d+4],y=0===n?p:f,x=0===n?g:_;let v=!1;s&&(c=Math.sqrt(Math.pow(p-g,2)+Math.pow(f-_,2))),y<i?x>i&&(h=l(a,p,f,g,_,i),s&&(a.start=u+c*h)):y>r?x<r&&(h=l(a,p,f,g,_,r),s&&(a.start=u+c*h)):W(a,p,f,m),x<i&&y>=i&&(h=l(a,p,f,g,_,i),v=!0),x>r&&y<=r&&(h=l(a,p,f,g,_,r),v=!0),!o&&v&&(s&&(a.end=u+c*h),e.push(a),a=G(t)),s&&(u+=c)}let d=t.length-3;const p=t[d],f=t[d+1],m=0===n?p:f;m>=i&&m<=r&&W(a,p,f,t[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&W(a,a[0],a[1],a[2]),a.length&&e.push(a)}function G(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function q(t,e,i,r,n,o){for(const s of t)$(s,e,i,r,n,o,!1)}function W(t,e,i,r){t.push(e,i,r)}function H(t,e,i,r,n,o){const s=(o-e)/(r-e);return W(t,o,i+(n-i)*s,1),s}function X(t,e,i,r,n,o){const s=(o-i)/(n-i);return W(t,e+(r-e)*s,o,1),s}function K(t,e){const i=[];for(let r=0;r<t.length;r++){const n=t[r],o=n.type;let s;if("Point"===o||"MultiPoint"===o||"LineString"===o)s=Y(n.geometry,e);else if("MultiLineString"===o||"Polygon"===o){s=[];for(const t of n.geometry)s.push(Y(t,e))}else if("MultiPolygon"===o){s=[];for(const t of n.geometry){const i=[];for(const r of t)i.push(Y(r,e));s.push(i)}}i.push(D(n.id,o,s,n.tags))}return i}function Y(t,e){const i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(let r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function J(t,e){if(t.transformed)return t;const i=1<<t.z,r=t.x,n=t.y;for(const o of t.features){const t=o.geometry,s=o.type;if(o.geometry=[],1===s)for(let s=0;s<t.length;s+=2)o.geometry.push(Q(t[s],t[s+1],e,i,r,n));else for(let s=0;s<t.length;s++){const a=[];for(let o=0;o<t[s].length;o+=2)a.push(Q(t[s][o],t[s][o+1],e,i,r,n));o.geometry.push(a)}}return t.transformed=!0,t}function Q(t,e,i,r,n,o){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-o))]}function tt(t,e,i,r,n){const o=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)et(s,e,o,n);return s}function et(t,e,i,r){const n=e.geometry,o=e.type,s=[];if(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),"Point"===o||"MultiPoint"===o)for(let e=0;e<n.length;e+=3)s.push(n[e],n[e+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)it(s,n,t,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(let e=0;e<n.length;e++)it(s,n[e],t,i,"Polygon"===o,0===e);else if("MultiPolygon"===o)for(let e=0;e<n.length;e++){const r=n[e];for(let e=0;e<r.length;e++)it(s,r[e],t,i,!0,0===e)}if(s.length){let i=e.tags||null;if("LineString"===o&&r.lineMetrics){i={};for(const t in e.tags)i[t]=e.tags[t];i.mapbox_clip_start=n.start/n.size,i.mapbox_clip_end=n.end/n.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:i};null!==e.id&&(a.id=e.id),t.features.push(a)}}function it(t,e,i,r,n,o){const s=r*r;if(r>0&&e.size<(n?s:r))return void(i.numPoints+=e.length/3);const a=[];for(let t=0;t<e.length;t+=3)(0===r||e[t+2]>s)&&(i.numSimplified++,a.push(e[t],e[t+1])),i.numPoints++;n&&function(t,e){let i=0;for(let e=0,r=t.length,n=r-2;e<r;n=e,e+=2)i+=(t[e]-t[n])*(t[e+1]+t[n+1]);if(i>0===e)for(let e=0,i=t.length;e<i/2;e+=2){const r=t[e],n=t[e+1];t[e]=t[i-2-e],t[e+1]=t[i-1-e],t[i-2-e]=r,t[i-1-e]=n}}(a,o),t.push(a)}const rt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class nt{constructor(t,e){const i=(e=this.options=function(t,e){for(const i in e)t[i]=e[i];return t}(Object.create(rt),e)).debug;if(i&&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.");let r=function(t,e){const i=[];if("FeatureCollection"===t.type)for(let r=0;r<t.features.length;r++)F(i,t.features[r],e,r);else F(i,"Feature"===t.type?t:{geometry:t},e);return i}(t,e);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(t,e){const i=e.buffer/e.extent;let r=t;const n=U(t,1,-1-i,i,0,-1,2,e),o=U(t,1,1-i,2+i,0,-1,2,e);return(n||o)&&(r=U(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=K(n,1).concat(r)),o&&(r=r.concat(K(o,-1)))),r}(r,e),r.length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,i,r,n,o,s){const a=[t,e,i,r],l=this.options,c=l.debug;for(;a.length;){r=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();const h=1<<e,u=ot(e,i,r);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=tt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(d.source=t,null==n){if(e===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===n)continue;if(null!=n){const t=n-e;if(i!==o>>t||r!==s>>t)continue}}if(d.source=null,0===t.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,y=null,x=null,v=null,b=U(t,h,i-p,i+m,0,d.minX,d.maxX,l),w=U(t,h,i+f,i+g,0,d.minX,d.maxX,l);t=null,b&&(_=U(b,h,r-p,r+m,1,d.minY,d.maxY,l),y=U(b,h,r+f,r+g,1,d.minY,d.maxY,l),b=null),w&&(x=U(w,h,r-p,r+m,1,d.minY,d.maxY,l),v=U(w,h,r+f,r+g,1,d.minY,d.maxY,l),w=null),c>1&&console.timeEnd("clipping"),a.push(_||[],e+1,2*i,2*r),a.push(y||[],e+1,2*i,2*r+1),a.push(x||[],e+1,2*i+1,2*r),a.push(v||[],e+1,2*i+1,2*r+1)}}getTile(t,e,i){t=+t,e=+e,i=+i;const r=this.options,{extent:n,debug:o}=r;if(t<0||t>24)return null;const s=1<<t,a=ot(t,e=e+s&s-1,i);if(this.tiles[a])return J(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",t,e,i);let l,c=t,h=e,u=i;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[ot(c,h,u)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?J(this.tiles[a],n):null):null}}function ot(t,e,i){return 32*((1<<t)*i+e)+t}function st(t,e){return e?t.properties[e]:t.id}function at(t,e){if(null==t)return!0;if("Feature"===t.type)return null!=st(t,e);if("FeatureCollection"===t.type){const i=new Set;for(const r of t.features){const t=st(r,e);if(null==t)return!1;if(i.has(t))return!1;i.add(t)}return!0}return!1}function lt(t,e){const i=new Map;if(null==t);else if("Feature"===t.type)i.set(st(t,e),t);else for(const r of t.features)i.set(st(r,e),r);return i}class ct extends o{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const i=this._geoJSONIndex.getTile(t.z,t.x,t.y);if(!i)return null;const r=new p(i.features);let n=x(r);return 0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),{vectorTile:r,rawData:n.buffer}}))}loadData(e){return t._(this,void 0,void 0,(function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const r=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.cF(e.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest),this._geoJSONIndex=e.cluster?new S(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[o,s]=i[e],a=t.ct(s),l=t.ct("string"==typeof o?[o,["accumulated"],["get",e]]:o);r[e]=a.value,n[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(o,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)o.accumulated=t[e],t[e]=n[e].evaluate(o,s)},e}(e)).load((yield this._pendingData).features):(n=yield this._pendingData,new nt(n,e.geojsonVtOptions)),this.loaded={};const i={};if(r){const t=r.finish();t&&(i.resourceTiming={},i.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}return i}catch(e){if(delete this._pendingRequest,t.co(e))return{abandoned:!0};throw e}var n}))}getData(){return t._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded;return e&&e[t.uid]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){let r=yield this.loadGeoJSON(e,i);if(delete this._pendingRequest,"object"!=typeof r)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(h(r,!0),e.filter){const i=t.ct(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const n=r.features.filter((t=>i.value.evaluate({zoom:0},t)));r={type:"FeatureCollection",features:n}}return r}))}loadGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){const{promoteId:r}=e;if(e.request){const n=yield t.j(e.request,i);return this._dataUpdateable=at(n.data,r)?lt(n.data,r):void 0,n.data}if("string"==typeof e.data)try{const t=JSON.parse(e.data);return this._dataUpdateable=at(t,r)?lt(t,r):void 0,t}catch(t){throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}if(!e.dataDiff)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${e.source}`);return function(t,e,i){var r,n,o,s;if(e.removeAll&&t.clear(),e.remove)for(const i of e.remove)t.delete(i);if(e.add)for(const r of e.add){const e=st(r,i);null!=e&&t.set(e,r)}if(e.update)for(const i of e.update){let e=t.get(i.id);if(null==e)continue;const a=!i.removeAllProperties&&((null===(r=i.removeProperties)||void 0===r?void 0:r.length)>0||(null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0);if((i.newGeometry||i.removeAllProperties||a)&&(e=Object.assign({},e),t.set(i.id,e),a&&(e.properties=Object.assign({},e.properties))),i.newGeometry&&(e.geometry=i.newGeometry),i.removeAllProperties)e.properties={};else if((null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0)for(const t of i.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0)for(const{key:t,value:r}of i.addOrUpdateProperties)e.properties[t]=r}}(this._dataUpdateable,e.dataDiff,r),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(e){return t._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset)}}class ht{constructor(e){this.self=e,this.actor=new t.H(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=t.cr,this.self.removeProtocol=t.cs,this.self.registerRTLTextPlugin=e=>{t.cM.setMethods(e)},this.actor.registerMessageHandler("LDT",((t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e))),this.actor.registerMessageHandler("RDT",((e,i)=>t._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,i.source).removeTile(i)})))),this.actor.registerMessageHandler("GCEZ",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterExpansionZoom(i)})))),this.actor.registerMessageHandler("GCC",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterChildren(i)})))),this.actor.registerMessageHandler("GCL",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterLeaves(i)})))),this.actor.registerMessageHandler("LD",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e))),this.actor.registerMessageHandler("GD",((t,e)=>this._getWorkerSource(t,e.type,e.source).getData())),this.actor.registerMessageHandler("LT",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e))),this.actor.registerMessageHandler("RT",((t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e))),this.actor.registerMessageHandler("AT",((t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e))),this.actor.registerMessageHandler("RMT",((t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e))),this.actor.registerMessageHandler("RS",((e,i)=>t._(this,void 0,void 0,(function*(){if(!this.workerSources[e]||!this.workerSources[e][i.type]||!this.workerSources[e][i.type][i.source])return;const t=this.workerSources[e][i.type][i.source];delete this.workerSources[e][i.type][i.source],void 0!==t.removeSource&&t.removeSource(i)})))),this.actor.registerMessageHandler("RM",(e=>t._(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e]})))),this.actor.registerMessageHandler("SR",((e,i)=>t._(this,void 0,void 0,(function*(){this.referrer=i})))),this.actor.registerMessageHandler("SRPS",((t,e)=>this._syncRTLPluginState(t,e))),this.actor.registerMessageHandler("IS",((e,i)=>t._(this,void 0,void 0,(function*(){this.self.importScripts(i)})))),this.actor.registerMessageHandler("SI",((t,e)=>this._setImages(t,e))),this.actor.registerMessageHandler("UL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(i.layers,i.removedIds)})))),this.actor.registerMessageHandler("SL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(i)}))))}_setImages(e,i){return t._(this,void 0,void 0,(function*(){this.availableImages[e]=i;for(const t in this.workerSources[e]){const r=this.workerSources[e][t];for(const t in r)r[t].availableImages=i}}))}_syncRTLPluginState(e,i){return t._(this,void 0,void 0,(function*(){return yield t.cM.syncState(i,this.self.importScripts)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let i=this.layerIndexes[t];return i||(i=this.layerIndexes[t]=new e),i}_getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={sendAsync:(e,i)=>(e.targetMapId=t,this.actor.sendAsync(e,i))};switch(e){case"vector":this.workerSources[t][e][i]=new o(r,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][i]=new ct(r,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][i]=new this.externalWorkerSourceTypes[e](r,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][i]}_getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new s),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new ht(self)),ht})),i("index",["exports","./shared"],(function(t,e){var i="5.4.0-mc.6";function r(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let n,o;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(t,i,r){const n=requestAnimationFrame((t=>{o(),i(t)})),{unsubscribe:o}=e.s(t.signal,"abort",(()=>{o(),cancelAnimationFrame(n),r(e.c())}),!1)},frameAsync(t){return new Promise(((e,i)=>{this.frame(t,e,i)}))},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(n||(n=document.createElement("a")),n.href=t,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)}};class a{static testProp(t){if(!a.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in a.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){a.docStyle&&a.selectProp&&(a.userSelect=a.docStyle[a.selectProp],a.docStyle[a.selectProp]="none")}static enableDrag(){a.docStyle&&a.selectProp&&(a.docStyle[a.selectProp]=a.userSelect)}static setTransform(t,e){t.style[a.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",a.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",a.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",a.suppressClickInternal,!0)}),0)}static getScale(t,e){const i=t.getBoundingClientRect();return{x:(i.width/t.offsetWidth||1)*e,y:(i.height/t.offsetHeight||1)*e,boundingClientRect:i}}static getPoint(t,i,r){const n=i.boundingClientRect;return new e.P((r.clientX-n.left)/i.x-t.clientLeft,(r.clientY-n.top)/i.y-t.clientTop)}static mousePos(t,e,i){const r=a.getScale(t,i);return a.getPoint(t,r,e)}static touchPos(t,e,i){const r=[],n=a.getScale(t,i);for(let i=0;i<e.length;i++)r.push(a.getPoint(t,n,e[i]));return r}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const e=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),i=e.querySelectorAll("script");for(const t of i)t.remove();return a.clean(e),e.innerHTML}static isPossiblyDangerous(t,e){const i=e.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!i.includes("javascript:")&&!i.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const e=t.children;for(const t of e)a.removeAttributes(t),a.clean(t)}static removeAttributes(t){for(const{name:e,value:i}of t.attributes)a.isPossiblyDangerous(e,i)&&t.removeAttribute(e)}}a.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,a.selectProp=a.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),a.transformProp=a.testProp(["transform","WebkitTransform"]);const l={supported:!1,testSupport:function(t){!u&&h&&(d?p(t):c=t)}};let c,h,u=!1,d=!1;function p(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,h),t.isContextLost())return;l.supported=!0}catch(t){}t.deleteTexture(e),u=!0}var f;"undefined"!=typeof document&&(h=document.createElement("img"),h.onload=()=>{c&&p(c),c=null,d=!0},h.onerror=()=>{u=!0,c=null},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let i,r,n,o;t.resetRequestQueue=()=>{i=[],r=0,n=0,o={}},t.addThrottleControl=t=>{const e=n++;return o[e]=t,e},t.removeThrottleControl=t=>{delete o[t],a()},t.getImage=(t,r,n=!0)=>new Promise(((o,s)=>{l.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"}),i.push({abortController:r,requestParameters:t,supportImageRefresh:n,state:"queued",onError:t=>{s(t)},onSuccess:t=>{o(t)}}),a()}));const s=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:i,supportImageRefresh:n,onError:o,onSuccess:s,abortController:l}=t,h=!1===n&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0));r++;const u=h?c(i,l):e.m(i,l);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?e.f(d):e.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(e){delete t.abortController,o(e)}finally{r--,a()}var d})),a=()=>{const t=(()=>{for(const t of Object.keys(o))if(o[t]())return!0;return!1})()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=r;e<t&&i.length>0;e++){const t=i.shift();t.abortController.signal.aborted?e--:s(t)}},c=(t,i)=>new Promise(((r,n)=>{const o=new Image,s=t.url,a=t.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!e.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{o.src="",n(e.c())})),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,r({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||n(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."))},o.src=s}))}(f||(f={})),f.resetRequestQueue();class m{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function g(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:r,url:n}of t){const t=`${r}${n}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:r,url:n}))}}return e}function _(t,e,i){try{const r=new URL(t);return r.pathname+=`${e}${i}`,r.toString()}catch(e){throw new Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function y(t,i,r,n){return e._(this,void 0,void 0,(function*(){const o=g(t),a=r>1?"@2x":"",l={},c={};for(const{id:t,url:r}of o){const o=i.transformRequest(_(r,a,".json"),"SpriteJSON");l[t]=e.j(o,n);const s=i.transformRequest(_(r,a,".png"),"SpriteImage");c[t]=f.getImage(s,n)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(t,i){return e._(this,void 0,void 0,(function*(){const e={};for(const r in t){e[r]={};const n=s.getImageCanvasContext((yield i[r]).data),o=(yield t[r]).data;for(const t in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,id:g}=o[t];e[r][t]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:n},id:g}}}return e}))}(l,c)}))}class x{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,i,r){const{width:n,height:o}=t,s=!(this.size&&this.size[0]===n&&this.size[1]===o||r),{context:a}=this,{gl:l}=a;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[n,o],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,n,o,0,this.format,l.UNSIGNED_BYTE,t.data);else{const{x:i,y:s}=r||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,i,s,n,o,l.RGBA,l.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,e,i){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),t!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}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 v(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class b extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.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:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,i){let r=!0;const n=i.data||i.spriteData;return this._validateStretch(i.stretchX,n&&n.width)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,n&&n.height)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){if(!t)return!0;if(4!==t.length)return!1;const i=e.spriteData,r=i&&i.width||e.data.width,n=i&&i.height||e.data.height;return!(t[0]<0||r<t[0]||t[1]<0||n<t[1]||t[2]<0||r<t[2]||t[3]<0||n<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,e,i=!0){const r=this.getImage(t);if(i&&(r.data.width!==e.data.width||r.data.height!==e.data.height))throw new Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=r.version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((e,i)=>{let r=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(r=!1);this.isLoaded()||r?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){const i={};for(const r of t){let t=this.getImage(r);t||(this.fire(new e.l("styleimagemissing",{id:r})),t=this.getImage(r)),t?i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const i=this.patterns[t],r=this.getImage(t);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new e.I(i,r);this.patterns[t]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new x(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:r}=e.p(t),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],r=i.x+1,o=i.y+1,s=this.getImage(t).data,a=s.width,l=s.height;e.R.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),e.R.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),e.R.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),e.R.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),e.R.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),v(t)&&this.updateImage(i,t)}}}const w=1e20;function T(t,e,i,r,n,o,s,a,l){for(let c=e;c<e+r;c++)P(t,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)P(t,c*o+e,1,r,s,a,l)}function P(t,e,i,r,n,o,s){o[0]=0,s[0]=-1e20,s[1]=w,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=o[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;t[e+a*i]=n[r]+c*c}}class M{constructor(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}}setURL(t){this.url=t}getGlyphs(t){return e._(this,void 0,void 0,(function*(){const e=[];for(const i in t)for(const r of t[i])e.push(this._getAndCacheGlyphsPromise(i,r));const i=yield Promise.all(e),r={};for(const{stack:t,id:e,glyph:n}of i)r[t]||(r[t]={}),r[t][e]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};return r}))}getGlyphMap(t,e){const i=e.map((e=>{var i;return{id:e,glyph:null===(i=this.entries[t])||void 0===i?void 0:i.glyphs[e]}})),r={[t]:{}};for(const{id:e,glyph:n}of i)r[t][e]=n&&{metrics:n.metrics};return r}_getAndCacheGlyphsPromise(t,i){return e._(this,void 0,void 0,(function*(){let e=this.entries[t];e||(e=this.entries[t]={glyphs:{},requests:{},ranges:{}});let r=e.glyphs[i];if(void 0!==r)return{stack:t,id:i,glyph:r};if(r=this._tinySDF(e,t,i),r)return e.glyphs[i]=r,{stack:t,id:i,glyph:r};const n=Math.floor(i/256);if(256*n>65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[n])return{stack:t,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[n]){const i=M.loadGlyphRange(t,n,this.url,this.requestManager);e.requests[n]=i}const o=yield e.requests[n];for(const t in o)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=o[+t]);return e.ranges[n]=!0,{stack:t,id:i,glyph:o[i]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(t))||e.u["CJK Unified Ideographs"](t)||e.u["Hangul Syllables"](t)||e.u.Hiragana(t)||e.u.Katakana(t)||e.u["CJK Symbols and Punctuation"](t)||e.u["Halfwidth and Fullwidth Forms"](t))}_tinySDF(t,i,r){const n=this.localIdeographFontFamily;if(!n)return;if(!this._doesCharSupportLocalGlyph(r))return;let o=t.tinySDF;if(!o){let e="400";/bold/i.test(i)?e="900":/medium/i.test(i)?e="500":/light/i.test(i)&&(e="200"),o=t.tinySDF=new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:n,fontWeight:e})}const s=o.draw(String.fromCharCode(r));return{id:r,bitmap:new e.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}M.loadGlyphRange=function(t,i,r,n){return e._(this,void 0,void 0,(function*(){const o=256*i,s=o+255,a=n.transformRequest(r.replace("{fontstack}",t).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield e.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const t of e.o(l.data))c[t.id]=t;return c}))},M.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(w,0,u),g.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)_[r]=0,g[r]=w;else{const t=.5-i;_[r]=t>0?t*t:0,g[r]=t<0?t*t:0}}T(_,0,0,c,h,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(_[t])-Math.sqrt(g[t]);d[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return p}};class S{constructor(){this.specification=e.v.light.position}possiblyEvaluate(t,i){return e.z(t.expression.evaluate(i))}interpolate(t,i,r){return{x:e.B.number(t.x,i.x,r),y:e.B.number(t.y,i.y,r),z:e.B.number(t.z,i.z,r)}}}let C;class I extends e.E{constructor(t){super(),C=C||new e.r({anchor:new e.D(e.v.light.anchor),position:new S,color:new e.D(e.v.light.color),intensity:new e.D(e.v.light.intensity)}),this._transitionable=new e.T(C),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.t,t,i))for(const e in t){const i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}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,i,r){return(!r||!1!==r.validate)&&e.x(this,t.call(e.y,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.v}))}}const A=new e.r({"sky-color":new e.D(e.v.sky["sky-color"]),"horizon-color":new e.D(e.v.sky["horizon-color"]),"fog-color":new e.D(e.v.sky["fog-color"]),"fog-ground-blend":new e.D(e.v.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.v.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.v.sky["atmosphere-blend"])});class E extends e.E{constructor(t){super(),this._transitionable=new e.T(A),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.C(0))}setSky(t,i={}){if(!this._validate(e.F,t,i)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const e in t){const i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r={}){return!1!==(null==r?void 0:r.validate)&&e.x(this,t.call(e.y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class k{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let o=0,s=t[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(r+1);if(s.isDash){const t=r-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+d*d);this.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let n=0,o=t[n];for(let e=0;e<this.width;e++){e/o.right>1&&(o=t[++n]);const i=Math.abs(e-o.left),s=Math.abs(e-o.right),a=Math.min(i,s);this.data[r+e]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(t,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return e.w("LineAtlas out of space"),null;let o=0;for(let e=0;e<t.length;e++)o+=t[e];if(0!==o){const e=this.width/o,n=this.getDashRanges(t,this.width,e);i?this.addRoundDash(n,e,r):this.addRegularDash(n)}const s={y:(this.nextRow+r+.5)/this.height,height:2*r/this.height,width:o};return this.nextRow+=n,this.dirty=!0,s}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}const z="maplibre_preloaded_worker_pool";class L{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<L.workerCount;)this.workers.push(new Worker(e.a.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[z]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(s.hardwareConcurrency/2);let R,F;function B(){return R||(R=new L),R}L.workerCount=e.G(globalThis)?Math.max(Math.min(D,3),1):1;class O{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let t=0;t<r.length;t++){const n=new e.H(r[t],i);n.name=`Worker ${t}`,this.actors.push(n)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,e){const i=[];for(const r of this.actors)i.push(r.sendAsync({type:t,data:e}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((t=>{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e)}}function j(){return F||(F=new O(B(),e.J),F.registerMessageHandler("GR",((t,i,r)=>e.m(i,r)))),F}class N{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.K(t,0,1);let i=1,r=this._distances[i];const n=t*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,s=this._distances[o],a=r-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function V(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class U{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(t,e,i,r,n,o){this.circleCells[n].push(o)}_query(t,e,i,r,n,o,s){if(i<0||t>this.width||r<0||e>this.height)return[];const a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)a.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];a.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,a,{hitTest:n,overlapMode:o,seenUids:{box:{},circle:{}}},s);return a}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,n,o){return this._query(t,e,i,r,!0,n,o).length>0}hitTestCircle(t,e,i,r,n){const o=t-i,s=t+i,a=e-i,l=e+i;if(s<0||o>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(t,e,i,r,n,o,s,a){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(t<=n[u+2]&&e<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!a||a(d))&&(!c||!V(h,d.overlapMode))&&(o.push({key:d,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const d=this.circleCells[n];if(null!==d){const n=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!a||a(d))&&(!c||!V(h,d.overlapMode))){const t=n[u],e=n[u+1],i=n[u+2];if(o.push({key:d,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,o,s,a){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(r))&&!V(h,r.overlapMode))return o.push(!0),!0}}const d=this.circleCells[n];if(null!==d){const t=this.circles;for(const e of d)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!V(h,r.overlapMode))return o.push(!0),!0}}}_forEachCell(t,e,i,r,n,o,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+d,o,s,a))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,e,i,r,n,o){const s=r-t,a=n-e,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}function Z(t,i,n){const o=e.L();if(!t){const{vecSouth:t,vecEast:e}=G(i),n=r();n[0]=e[0],n[1]=e[1],n[2]=t[0],n[3]=t[1],s=n,(d=(l=(a=n)[0])*(u=a[3])-(h=a[2])*(c=a[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),o[0]=n[0],o[1]=n[1],o[4]=n[2],o[5]=n[3]}var s,a,l,c,h,u,d;return e.M(o,o,[1/n,1/n,1]),o}function $(t,i,r,n){if(t){const t=e.L();if(!i){const{vecSouth:e,vecEast:i}=G(r);t[0]=i[0],t[1]=i[1],t[4]=e[0],t[5]=e[1]}return e.M(t,t,[n,n,1]),t}return r.pixelsToClipSpaceMatrix}function G(t){const i=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),n=Math.cos(t.pitchInRadians),o=Math.cos(t.bearingInRadians),s=Math.sin(t.bearingInRadians),a=e.S();a[0]=-o*n*r-s*i,a[1]=-s*n*r+o*i;const l=e.U(a);l<1e-9?e.V(a):e.X(a,a,1/l);const c=e.S();c[0]=o*n*i-s*r,c[1]=s*n*i+o*r;const h=e.U(c);return h<1e-9?e.V(c):e.X(c,c,1/h),{vecEast:c,vecSouth:a}}function q(t,i,r,n){let o;n?(o=[t,i,n(t,i),1],e.Z(o,o,r)):(o=[t,i,0,1],ct(o,o,r));const s=o[3];return{point:new e.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function W(t,e){return.5+t/e*.5}function H(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function X(t,i,r,n,o,s,a,l,c,h,u,d,p){const f=r?t.textSizeData:t.iconSizeData,m=e.N(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();const y=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b=!1;for(let r=0;r<x.length;r++){const w=x.get(r);if(w.hidden||w.writingMode===e.W.vertical&&!b){lt(w.numGlyphs,_);continue}b=!1;const T=new e.P(w.anchorX,w.anchorY),P={getElevation:p,pitchedLabelPlaneMatrix:n,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:T,unwrappedTileID:c,width:h,height:u,translation:d},M=rt(w.anchorX,w.anchorY,P);if(!H(M.point,g)){lt(w.numGlyphs,_);continue}const S=W(i.transform.cameraToCenterDistance,M.signedDistanceFromCamera),C=e.O(f,m,w),I=s?C*i.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/S:C*S,A=J({projectionContext:P,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:I,flip:!1,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l});b=A.useVertical,(A.notEnoughRoom||b||A.needsFlipping&&J({projectionContext:P,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:I,flip:!0,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l}).notEnoughRoom)&<(w.numGlyphs,_)}r?t.text.dynamicLayoutVertexBuffer.updateData(_):t.icon.dynamicLayoutVertexBuffer.updateData(_)}function K(t,e,i,r,n,o,s,a){const l=o.glyphStartIndex+o.numGlyphs,c=o.lineStartIndex,h=o.lineStartIndex+o.lineLength,u=e.getoffsetX(o.glyphStartIndex),d=e.getoffsetX(l-1),p=st(t*u,i,r,n,o.segment,c,h,a,s);if(!p)return null;const f=st(t*d,i,r,n,o.segment,c,h,a,s);return f?a.projectionCache.anyProjectionOccluded?null:{first:p,last:f}:null}function Y(t,i,r,n){return t===e.W.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(t===e.W.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function J(t){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=t,d=o/24,p=n.lineOffsetX*d,f=n.lineOffsetY*d;let m;if(n.numGlyphs>1){const t=n.glyphStartIndex+n.numGlyphs,e=n.lineStartIndex,o=n.lineStartIndex+n.lineLength,c=K(d,l,p,f,s,n,u,i);if(!c)return{notEnoughRoom:!0};const g=it(c.first.point.x,c.first.point.y,i,r),_=it(c.last.point.x,c.last.point.y,i,r);if(a&&!s){const t=Y(n.writingMode,g,_,h);if(t)return t}m=[c.first];for(let r=n.glyphStartIndex+1;r<t-1;r++)m.push(st(d*l.getoffsetX(r),p,f,s,n.segment,e,o,i,u));m.push(c.last)}else{if(a&&!s){const t=et(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,o=n.lineStartIndex+n.segment+1,s=new e.P(i.lineVertexArray.getx(o),i.lineVertexArray.gety(o)),a=et(s.x,s.y,i),l=a.signedDistanceFromCamera>0?a.point:Q(i.tileAnchorPoint,s,t,1,i),c=it(t.x,t.y,i,r),u=it(l.x,l.y,i,r),d=Y(n.writingMode,c,u,h);if(d)return d}const t=st(d*l.getoffsetX(n.glyphStartIndex),p,f,s,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,u);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[t]}for(const t of m)e.Y(c,t.point,t.angle);return{}}function Q(t,e,i,r,n){const o=t.add(t.sub(e)._unit()),s=et(o.x,o.y,n).point,a=i.sub(s);return i.add(a._mult(r/a.mag()))}function tt(t,i,r){const n=i.projectionCache;if(n.projections[t])return n.projections[t];const o=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),s=et(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return n.projections[t]=s.point,n.anyProjectionOccluded=n.anyProjectionOccluded||s.isOccluded,s.point;const a=t-r.direction;return Q(0===r.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function et(t,e,i){const r=t+i.translation[0],n=e+i.translation[1];let o;return i.pitchWithMap?(o=q(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function it(t,i,r,n){if(r.pitchWithMap){const o=[t,i,0,1];return e.Z(o,o,n),r.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],r.unwrappedTileID,r.getElevation).point}return{x:t/r.width*2-1,y:i/r.height*2-1}}function rt(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function nt(t,e,i){return t._unit()._perp()._mult(e*i)}function ot(t,i,r,n,o,s,a,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const h=r.add(i);if(t+c.direction<n||t+c.direction>=o)return l.projectionCache.offsets[t]=h,h;const u=tt(t+c.direction,l,c),d=nt(u.sub(r),a,c.direction),p=r.add(d),f=u.add(d);return l.projectionCache.offsets[t]=e.$(s,h,p,f)||h,l.projectionCache.offsets[t]}function st(t,e,i,r,n,o,s,a,l){const c=r?t-e:t+e;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,p=h>0?o+n:o+n+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=et(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,y=0,x=0;const v=Math.abs(c),b=[];let w;for(;y+x<=v;){if(p+=h,p<o||p>=s)return null;y+=x,_=g,m=f;const t={absOffsetX:v,direction:h,distanceFromAnchor:y,previousVertex:_};if(g=tt(p,a,t),0===i)b.push(_),w=g.sub(_);else{let e;const r=g.sub(_);e=0===r.mag()?nt(tt(p+h,a,t).sub(g),i,h):nt(r,i,h),m||(m=_.add(e)),f=ot(p,e,g,o,s,m,i,a,t),b.push(m),w=f.sub(m)}x=w.mag()}const T=w._mult((v-y)/x)._add(m||_),P=u+Math.atan2(g.y-_.y,g.x-_.x);return b.push(T),{point:T,angle:l?P:0,path:b}}const at=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function lt(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(at,3*t)}}function ct(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const ht=100;class ut{constructor(t,e=[],i=1,r=new U(t.width+200,t.height+200,25),n=new U(t.width+200,t.height+200,25)){this.transform=t,this.grid=r,this.ignoredGrid=n,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+ht,this.screenBottomBoundary=t.height+ht,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6;for(let t=0;t<e.length;t++){const r=e[t];this.grid.insert(`label-free-area-${t}`,r[0]/i+ht,r[1]/i+ht,r[2]/i+ht,r[3]/i+ht)}}placeCollisionBox(t,e,i,r,n,o,s,a,l,c,h,u){const d=this.projectAndGetPerspectiveRatio(t.anchorPointX+a[0],t.anchorPointY+a[1],n,c,u),p=i*d.perspectiveRatio;let f;if(o||s)f=this._projectCollisionBox(t,p,r,n,o,s,a,d,c,h,u);else{const e=d.x+(h?h.x*p:0),i=d.y+(h?h.y*p:0);f={allPointsOccluded:!1,box:[e+t.x1*p,i+t.y1*p,e+t.x2*p,i+t.y2*p]}}const[m,g,_,y]=f.box,x=o?f.allPointsOccluded:d.isOccluded;let v=x;return v||(v=d.perspectiveRatio<this.perspectiveRatioCutoff),v||(v=!this.isInsideGrid(m,g,_,y)),v||"always"!==e&&this.grid.hitTest(m,g,_,y,e,l)?{box:[m,g,_,y],placeable:!1,offscreen:!1,occluded:x}:{box:[m,g,_,y],placeable:!0,offscreen:this.isOffscreen(m,g,_,y),occluded:x}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],g=new e.P(i.anchorX,i.anchorY),_=this.getPerspectiveRatio(g.x,g.y,s,f),y=(c?o*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,s)/_:o*_)/e.a5,x={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:r,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:p},v=K(y,n,i.lineOffsetX*y,i.lineOffsetY*y,!1,i,!1,x);let b=!1,w=!1,T=!0;if(v){const i=.5*u*_+d,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new N,s=v.first,a=v.last;let p=[];for(let t=s.path.length-1;t>=1;t--)p.push(s.path[t]);for(let t=1;t<a.path.length;t++)p.push(a.path[t]);const f=2.5*i;if(c){const t=this.projectPathToScreenSpace(p,x);p=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let g=[];if(p.length>0){const t=p[0].clone(),i=p[0].clone();for(let e=1;e<p.length;e++)t.x=Math.min(t.x,p[e].x),t.y=Math.min(t.y,p[e].y),i.x=Math.max(i.x,p[e].x),i.y=Math.max(i.y,p[e].y);g=t.x>=r.x&&i.x<=n.x&&t.y>=r.y&&i.y<=n.y?[p]:i.x<r.x||t.x>n.x||i.y<r.y||t.y>n.y?[]:e.a0([p],r.x,r.y,n.x,n.y)}for(const e of g){o.reset(e,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let e=0;e<r;e++){const n=e/Math.max(r-1,1),s=o.lerp(n),a=s.x+ht,c=s.y+ht;m.push(a,c,i,0);const u=a-i,d=c-i,p=a+i,f=c+i;if(T=T&&this.isOffscreen(u,d,p,f),w=w||this.isInsideGrid(u,d,p,f),"always"!==t&&this.grid.hitTestCircle(a,c,i,t,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||_<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}projectPathToScreenSpace(t,i){const r=function(t,i){const r=e.L();return e.Q(r,i.pitchedLabelPlaneMatrix),t.map((t=>{const e=q(t.x,t.y,r,i.getElevation),n=i.transform.projectTileCoordinates(e.point.x,e.point.y,i.unwrappedTileID,i.getElevation);return n.point.x=(.5*n.point.x+.5)*i.width,n.point.y=(.5*-n.point.y+.5)*i.height,n}))}(t,i);return function(t){let e=0,i=0,r=0,n=0;for(let o=0;o<t.length;o++)t[o].isOccluded?(r=o+1,n=0):(n++,n>i&&(i=n,e=r));return t.slice(e,e+i)}(r)}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.P(a.x+ht,a.y+ht);r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),i.push(t)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const t of a){const r=t.key;if(void 0===r.bucketInstanceId||void 0===r.featureIndex)continue;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.a1(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,e,i,r,n,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e};for(let e=0;e<t.length;e+=4)s.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,i,r,n,o){if(o){let r;n?(r=[t,i,n(t,i),1],e.Z(r,r,o)):(r=[t,i,0,1],ct(r,r,o));const s=r[3];return{x:(r[0]/s+1)/2*this.transform.width+ht,y:(-r[1]/s+1)/2*this.transform.height+ht,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s*.5,isOccluded:!1,signedDistanceFromCamera:s}}{const e=this.transform.projectTileCoordinates(t,i,r,n);return{x:(e.point.x+1)/2*this.transform.width+ht,y:(1-e.point.y)/2*this.transform.height+ht,perspectiveRatio:.5+this.transform.cameraToCenterDistance/e.signedDistanceFromCamera*.5,isOccluded:e.isOccluded,signedDistanceFromCamera:e.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,r){const n=this.transform.projectTileCoordinates(t,e,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(t,e,i,r){return i<ht||t>=this.screenRightBoundary||r<ht||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=e.a2([]);return e.a3(t,t,[-100,-100,0]),t}_projectCollisionBox(t,i,r,n,o,s,a,l,c,h,u){let d=1,p=0,f=0,m=1;const g=t.anchorPointX+a[0],_=t.anchorPointY+a[1];if(s&&!o){const t=this.projectAndGetPerspectiveRatio(g+1,_,n,c,u),e=t.x-l.x,i=Math.atan((t.y-l.y)/e)+(e<0?Math.PI:0),r=Math.sin(i),o=Math.cos(i);d=o,p=r,f=-r,m=o}else if(!s&&o){const t=G(this.transform);d=t.vecEast[0],p=t.vecEast[1],f=t.vecSouth[0],m=t.vecSouth[1]}let y=l.x,x=l.y,v=i;o&&(y=g,x=_,v=Math.pow(2,-(this.transform.zoom-r.overscaledZ)),v*=this.transform.getPitchedTextCorrection(g,_,n),h||(v*=e.K(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(y+=d*h.x*v+f*h.y*v,x+=p*h.x*v+m*h.y*v);const b=t.x1*v,w=t.x2*v,T=(b+w)/2,P=t.y1*v,M=t.y2*v,S=(P+M)/2,C=[{offsetX:b,offsetY:P},{offsetX:T,offsetY:P},{offsetX:w,offsetY:P},{offsetX:w,offsetY:S},{offsetX:w,offsetY:M},{offsetX:T,offsetY:M},{offsetX:b,offsetY:M},{offsetX:b,offsetY:S}];let I=[];for(const{offsetX:t,offsetY:i}of C)I.push(new e.P(y+d*t+f*i,x+p*t+m*i));let A=!1;if(o){const t=I.map((t=>this.projectAndGetPerspectiveRatio(t.x,t.y,n,c,u)));A=t.some((t=>!t.isOccluded)),I=t.map((t=>new e.P(t.x,t.y)))}else A=!0;return{box:e.a4(I),allPointsOccluded:!A}}}function dt(t,i){const r=e.L();return e.a3(r,r,[1,1,0]),e.M(r,r,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?e.a6(r,r,t.calculatePosMatrix(i.toUnwrapped())):r}function pt(t,e,i,r,n,o,s){var a;const l=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,e,t.id),c=o.maxPitchScaleFactor(),h=t.tilesIn(r,c,l,null==n?void 0:n.skipGeoCheck);h.sort(ft);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,n,o,c,dt(t.transform,r.tileID),s?(t,e)=>s(r.tileID,t,e):void 0)});return function(t,e){for(const i in t)for(const r of t[i])mt(r,e);return t}(function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in t){const r=t[i],n=o[i]=o[i]||{},s=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,s.push(t))}}return e}(u),t)}function ft(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function mt(t,e){const i=t.feature,r=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}function gt(t,i,r){const{glyphCircles:n,placedBoxes:o,anchorAngles:s,variableAnchors:a}=t.style.placement,l=i.bucketInstanceId,c=r.featureIndex;if(l in n&&c in n[l]){const t=n[l][c],i=s[l][c];let o=0;r.feature.paths=[],t.forEach((t=>{let n=[];const s=t.length/4;for(let e=0;e<s;e++)n.push(t[4*e]-ht),n.push(t[4*e+1]-ht);const a=n.length/2;if(n[0]>n[n.length-2]){const t=[];for(let e=1;e<=a;e++)t.push(n[2*(a-e)]),t.push(n[2*(a-e)+1]);n=t}if(1===a){const t=i[o],s=new e.P(n[0],n[1]);let a=new e.P(n[0]-20,n[1]),l=new e.P(n[0]+20,n[1]);a=a.rotateAround(t,s),l=l.rotateAround(t,s),r.feature.paths.push([a.x,a.y,l.x,l.y])}else{const t=_t(n[2],n[3],n[0],n[1],20);void 0!==t&&(n[0]=t.x,n[1]=t.y);const e=n.length,i=_t(n[e-4],n[e-3],n[e-2],n[e-1],20);void 0!==i&&(n[e-2]=i.x,n[e-1]=i.y),r.feature.paths.push(n)}o++}))}if(l in o&&c in o[l]){const t=o[l][c];r.feature.iconBoxes=[],r.feature.textBoxes=[],t.forEach((t=>{const{purpose:e,coords:i}=t;("icon"===e?r.feature.iconBoxes:r.feature.textBoxes).push(i.map((t=>t-ht)))}))}if(l in s&&c in s[l]){const t=s[l][c];r.feature.angles=[],t.forEach((t=>{r.feature.angles.push(180*t/Math.PI)}))}l in a&&c in a[l]&&(r.feature["placement-anchor"]=a[l][c])}function _t(t,e,i,r,n){if(t===i&&e===r)return;const o=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-r,2)),s=(n+o)/o;return{x:t+(i-t)*s,y:e+(r-e)*s}}function yt(t,i,r){return e._(this,void 0,void 0,(function*(){let n=t;if(t.url?n=(yield e.j(i.transformRequest(t.url,"Source"),r)).data:yield s.frameAsync(r),!n)return null;const o=e.a7(e.e(n,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(o.vectorLayerIds=n.vector_layers.map((t=>t.id))),o}))}class xt{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?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 e.a8?new e.a8(t.lng,t.lat):e.a8.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.a8?new e.a8(t.lng,t.lat):e.a8.convert(t),this}extend(t){const i=this._sw,r=this._ne;let n,o;if(t instanceof e.a8)n=t,o=t;else{if(!(t instanceof xt))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(xt.convert(t)):this.extend(e.a8.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.a8.convert(t)):this;if(n=t._sw,o=t._ne,!n||!o)return this}return i||r?(i.lng=Math.min(n.lng,i.lng),i.lat=Math.min(n.lat,i.lat),r.lng=Math.max(o.lng,r.lng),r.lat=Math.max(o.lat,r.lat)):(this._sw=new e.a8(n.lng,n.lat),this._ne=new e.a8(o.lng,o.lat)),this}getCenter(){return new e.a8((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 e.a8(this.getWest(),this.getNorth())}getSouthEast(){return new e.a8(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:i,lat:r}=e.a8.convert(t);let n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){return t instanceof xt?t:t?new xt(t):t}static fromLngLat(t,i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*t.lat);return new xt(new e.a8(t.lng-n,t.lat-r),new e.a8(t.lng+n,t.lat+r))}adjustAntiMeridian(){const t=new e.a8(this._sw.lng,this._sw.lat),i=new e.a8(this._ne.lng,this._ne.lat);return new xt(t,t.lng>i.lng?new e.a8(i.lng+360,i.lat):i)}}class vt{constructor(t,e,i){this.bounds=xt.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[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 i=Math.pow(2,t.z),r=Math.floor(e.aa(this.bounds.getWest())*i),n=Math.floor(e.a9(this.bounds.getNorth())*i),o=Math.ceil(e.aa(this.bounds.getEast())*i),s=Math.ceil(e.a9(this.bounds.getSouth())*i);return t.x>=r&&t.x<o&&t.y>=n&&t.y<s}}class bt extends e.E{constructor(t,i,r,n){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.e(this,e.a7(i,["url","scheme","tileSize","promoteId"])),this._options=e.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n)}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield yt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t&&(e.e(this,t),t.bounds&&(this.tileBounds=new vt(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new e.k(t))}}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),i={request:this.map._requestManager.transformRequest(e,"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()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i}}))}else t.actor=this.dispatcher.getActor(),r="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class wt extends e.E{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.a7(i,["url","scheme","tileSize"]))}load(){return e._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield yt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(e.e(this,i),i.bounds&&(this.tileBounds=new vt(i.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this.fire(new e.k(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme);t.abortController=new AbortController;try{const i=yield f.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const e=this.map.painter.context,r=e.gl,n=i.data;t.texture=this.map.painter.getTileTexture(n.width),t.texture?t.texture.update(n,{useMipmap:!0}):(t.texture=new x(e,n,r.RGBA,{useMipmap:!0}),t.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class Tt extends wt{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield f.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const n=e.b(r)&&e.ab()?r:yield this.readImageNow(r),o={type:this.type,uid:t.uid,source:this.id,rawImageData:n,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:o});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0}t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.ac()){const i=t.width+2,r=t.height+2;try{return new e.R({width:i,height:r},yield e.ad(t,-1,-1,i,r))}catch(t){}}return s.getImageData(t,1)}))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.ae(t.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.ae(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new e.ae(t.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}class Pt extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=e.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&e.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=e.e({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:e.af,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.af,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(t){return t*(e.af/this.tileSize)}load(){return e._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}getData(){return e._(this,void 0,void 0,(function*(){const t=e.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getCoordinatesFromGeometry(t){return"GeometryCollection"===t.type?t.geometries.map((t=>t.coordinates)).flat(1/0):t.coordinates.flat(1/0)}getBounds(){return e._(this,void 0,void 0,(function*(){const t=new xt,e=yield this.getData();let i;switch(e.type){case"FeatureCollection":i=e.features.map((t=>this.getCoordinatesFromGeometry(t.geometry))).flat(1/0);break;case"Feature":i=this.getCoordinatesFromGeometry(e.geometry);break;default:i=this.getCoordinatesFromGeometry(e)}if(0==i.length)return t;for(let e=0;e<i.length-1;e+=2)t.extend([i[e],i[e+1]]);return t}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(void 0!==t.clusterRadius&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,e,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}_updateWorkerData(t){return e._(this,void 0,void 0,(function*(){const i=e.e({type:this.type},this.workerOptions);t?i.dataDiff=t:"string"==typeof this._data?(i.request=this.map._requestManager.transformRequest(s.resolveURL(this._data),"Source"),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new e.l("dataloading",{dataType:"source"}));try{const t=yield this.actor.sendAsync({type:"LD",data:i});if(this._pendingLoads--,this._removed||t.abandoned)return void this.fire(new e.l("dataabort",{dataType:"source"}));let r=null;t.resourceTiming&&t.resourceTiming[this.id]&&(r=t.resourceTiming[this.id].slice(0));const n={dataType:"source"};this._collectResourceTiming&&r&&r.length>0&&e.e(n,{resourceTiming:r}),this.fire(new e.l("data",Object.assign(Object.assign({},n),{sourceDataType:"metadata"}))),this.fire(new e.l("data",Object.assign(Object.assign({},n),{sourceDataType:"content"})))}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.l("dataabort",{dataType:"source"}));this.fire(new e.k(t))}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={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()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const r=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class Mt extends e.E{constructor(t,e,i,r){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield f.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,this.fire(new e.k(t))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const i=t.map(e.ag.fromLngLat);var r;return this.tileID=function(t){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y);const s=Math.max(n-i,o-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new e.ai(a,Math.floor((i+n)/2*l),Math.floor((r+o)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((t=>this.tileID.getTilePoint(t)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture||(this.texture=new x(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y);const s={};for(let t=0;t<=e.ah;t++){const e=Math.pow(2,t),a=Math.floor(i*e),l=Math.floor(r*e),c=Math.floor(n*e),h=Math.floor(o*e);s[t]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:h}}return s}}class St extends Mt{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.aj(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.k(t))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.k(new e.ak(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new x(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Ct extends Mt{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.k(new e.ak(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.k(new e.ak(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.k(new e.ak(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.k(new e.ak(`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 e.k(new e.ak(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new x(i,this.canvas,r.RGBA,{premultiply:!0});let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const It={},At=t=>{switch(t){case"geojson":return Pt;case"image":return Mt;case"raster":return wt;case"raster-dem":return Tt;case"vector":return bt;case"video":return St;case"canvas":return Ct}return It[t]},Et="RTLPluginLoaded";class kt extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.l(Et))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let zt=null;function Lt(){return zt||(zt=new kt),zt}class Dt{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.al(),this.uses=0,this.tileSize=i,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 e=t+this.timeAdded;e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,i,r){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(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.an){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.an&&i.hasRTLText){this.hasRTLText=!0,Lt().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new e.am}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 e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new x(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new x(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,s,a,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:h},t,e,i):{}}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.ao(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<s.length;i++){const n=s.feature(i);if(a.needGeometry){const t=e.ap(n,!0);if(!a.filter(new e.C(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.C(this.tileID.overscaledZ),n))continue;const d=r.getId(n,o),p=new e.aq(n,l,c,h,d);p.tile=u,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.ar(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const r=this.expirationTime-i;r?this.expirationTime=t+Math.max(r,3e4):e=!0}else e=!0;e?(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,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const i=this.latestFeatureIndex.loadVTLayers();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const n=this.buckets[r],o=n.layers[0].sourceLayer||"_geojsonTileLayer",s=i[o],a=t[o];if(!s||!a||0===Object.keys(a).length)continue;n.update(a,s,this.imageAtlas&&this.imageAtlas.patternPositions||{});const l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(n)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<s.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=s.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class Rt{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}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 e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Ft{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const n=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,i){const r=String(i),n=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.e(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}r[t]=r[t]||{},e.e(r[t],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].setFeatureState(r,i)}}const Bt=89.25;function Ot(t,i){const r=e.K(i.lat,-85.051129,e.au);return new e.P(e.aa(i.lng)*t,e.a9(r)*t)}function jt(t,i){return new e.ag(i.x/t,i.y/t).toLngLat()}function Nt(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(e.as(90-t.pitch)),Math.tan(e.as(Bt-t.pitch)))}function Vt(t,i){const r=t.canonical,n=i/e.at(r.z),o=r.x+Math.pow(2,r.z)*t.wrap,s=e.a2(new Float64Array(16));return e.a3(s,s,[o*n,r.y*n,0]),e.M(s,s,[n/e.af,n/e.af,1]),s}function Ut(t,i,r,n,o){const s=e.ag.fromLngLat(t,i),a=o*e.av(1,t.lat),l=a*Math.cos(e.as(r)),c=Math.sqrt(a*a-l*l),h=c*Math.sin(e.as(-n)),u=c*Math.cos(e.as(-n));return new e.ag(s.x+h,s.y+u,s.z+l)}function Zt(t,e,i){const r=e.intersectsFrustum(t);if(!i)return r;const n=e.intersectsPlane(i);return 0===r||0===n?0:2===r&&2===n?2:1}function $t(t,e,i){let r=0;const n=(i-e)/10;for(let o=0;o<10;o++)r+=n*Math.pow(Math.cos(e+(o+.5)/10*(i-e)),t);return r}function Gt(t,i){return function(r,n,o,s,a){const l=2*((t-1)/e.aw(Math.cos(e.as(Bt-a))/Math.cos(e.as(Bt)))-1),c=Math.acos(o/s),h=2*$t(l-1,0,e.as(a/2)),u=Math.min(e.as(Bt),c+e.as(a/2)),d=$t(l-1,Math.min(u,c-e.as(a/2)),u),p=Math.atan(n/o),f=Math.hypot(n,o);let m=r;return m+=e.aw(s/f/Math.max(.5,Math.cos(e.as(a/2)))),m+=l*e.aw(Math.cos(p))/2,m-=e.aw(Math.max(1,d/h/i))/2,m}}const qt=Gt(9.314,3);function Wt(t,i){const r=(i.roundZoom?Math.round:Math.floor)(t.zoom+e.aw(t.tileSize/i.tileSize));return Math.max(0,r)}function Ht(t,i){const r=t.getCameraFrustum(),n=t.getClippingPlane(),o=t.screenPointToMercatorCoordinate(t.getCameraPoint()),s=e.ag.fromLngLat(t.center,t.elevation);o.z=s.z+Math.cos(t.pitchInRadians)*t.cameraToCenterDistance/t.worldSize;const a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,i),c=Wt(t,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:t.maxZoom,d=Math.min(Math.max(0,c),u),p=Math.pow(2,d),f=[p*o.x,p*o.y,0],m=[p*s.x,p*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),_=Math.abs(s.z-o.z),y=Math.hypot(g,_),x=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),v=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)v.push(x(-t)),v.push(x(t));for(v.push(x(0));v.length>0;){const p=v.pop(),g=p.x,x=p.y;let w=p.fullyVisible;const T={x:g,y:x,z:p.zoom},P=a.getTileAABB(T,p.wrap,t.elevation,i);if(!w){const t=Zt(r,P,n);if(0===t)continue;w=2===t}const M=a.distanceToTile2d(o.x,o.y,T,P);let S=c;l&&(S=(i.calculateTileZoom||qt)(t.zoom+e.aw(t.tileSize/i.tileSize),M,_,y,t.fov)),S=(i.roundZoom?Math.round:Math.floor)(S),S=Math.max(0,S);const C=Math.min(S,u);if(p.wrap=a.getWrap(s,T,p.wrap),p.zoom>=C){if(p.zoom<h)continue;const t=d-p.zoom,r=f[0]-.5-(g<<t),n=f[1]-.5-(x<<t),o=i.reparseOverscaled?Math.max(p.zoom,S):p.zoom;b.push({tileID:new e.ae(p.zoom===u?o:p.zoom,p.wrap,p.zoom,g,x),distanceSq:e.ax([m[0]-.5-g,m[1]-.5-x]),tileDistanceToCamera:Math.sqrt(r*r+n*n)})}else for(let t=0;t<4;t++)v.push({zoom:p.zoom+1,x:(g<<1)+t%2,y:(x<<1)+(t>>1),wrap:p.wrap,fullyVisible:w})}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}class Xt extends e.E{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,r)=>{const n=new(At(e.type))(t,e,i,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return n})(t,e,i,this),this._tiles={},this._cache=new Rt(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ft,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)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)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,i,r){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,i,r)}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.k(i,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.l("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 e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Kt).map((t=>t.key))}getRenderableIds(t){const i=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&i.push(this._tiles[e]);return t?i.sort(((t,i)=>{const r=t.tileID,n=i.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new e.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Kt).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(t){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)(t||"errored"!==this._tiles[e].state)&&this._reloadTile(e,"reloading")}}_reloadTile(t,i){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i))}))}_tileLoaded(t,i,r){t.timeAdded=s.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.l("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]||t[a.canonical.key]){r[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,r=Math.ceil(t.height/this._source.tileSize)+1,n=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(o)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t])}}_updateCoveredAndRetainedTiles(t,e,i,r,n,o){const a={},l={},c=Object.keys(t),h=s.now();for(const i of c){const r=t[i],n=this._tiles[i];if(!n||0!==n.fadeEndTime&&n.fadeEndTime<=h)continue;const o=this.findLoadedParent(r,e),s=this.findLoadedSibling(r),c=o||s||null;c&&(this._addTile(c.tileID),a[c.tileID.key]=c.tileID),l[i]=r}this._retainLoadedChildren(l,r,i,t);for(const e in a)t[e]||(this._coveredTiles[e]=!0,t[e]=a[e]);if(o){const e={},i={};for(const t of n)this._tiles[t.key].hasData()?e[t.key]=t:i[t.key]=t;for(const r in i){const n=i[r].children(this._source.maxzoom);this._tiles[n[0].key]&&this._tiles[n[1].key]&&this._tiles[n[2].key]&&this._tiles[n[3].key]&&(e[n[0].key]=t[n[0].key]=n[0],e[n[1].key]=t[n[1].key]=n[1],e[n[2].key]=t[n[2].key]=n[2],e[n[3].key]=t[n[3].key]=n[3],delete i[r])}for(const r in i){const n=i[r],o=this.findLoadedParent(n,this._source.minzoom),s=this.findLoadedSibling(n),a=o||s||null;if(a){e[a.tileID.key]=t[a.tileID.key]=a.tileID;for(const t in e)e[t].isChildOf(a.tileID)&&delete e[t]}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0)}}update(t,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ae(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=Ht(t,{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:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=Wt(t,this._source),o=Math.max(n-Xt.maxOverzooming,this._source.minzoom),s=Math.max(n+Xt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of r)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}r=r.concat(Object.values(t))}const a=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new e.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,n);Yt(this._source.type)&&this._updateCoveredAndRetainedTiles(l,o,s,n,r,i);for(const t in l)this._tiles[t].clearFadeHold();const c=e.ay(this._tiles,l);for(const t of c){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var i;const r={},n={},o=Math.max(e-Xt.maxOverzooming,this._source.minzoom),s=Math.max(e+Xt.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);r[i.key]=i,t.hasData()||e<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,e,s,r);for(const s of t){let t=this._tiles[s.key];if(t.hasData())continue;if(e+1>this._source.maxzoom){const t=s.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){r[t.key]=t;continue}}else{const t=s.children(this._source.maxzoom);if(4===t.length&&r[t[0].key]&&r[t[1].key]&&r[t[2].key]&&r[t[3].key])continue}let a=t.wasRequested();for(let e=s.overscaledZ-1;e>=o;--e){const o=s.scaledTo(e);if(n[o.key])break;if(n[o.key]=!0,t=this.getTile(o),!t&&a&&(t=this._addTile(o)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||a)&&(r[o.key]=o),a=t.wasRequested(),e)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,i=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const r=i;return i||(i=new Dt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._tiles[t.key]=i,r||this._source.fire(new e.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(t.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,i,r,n){const o=[],s=this.transform;if(!s)return o;const a=r?s.getCameraQueryGeometry(t):t,l=t.map((t=>s.screenPointToMercatorCoordinate(t,this.terrain))),c=a.map((t=>s.screenPointToMercatorCoordinate(t,this.terrain))),h=this.getIds();let u=1/0,d=1/0,p=-1/0,f=-1/0;for(const t of c)u=Math.min(u,t.x),d=Math.min(d,t.y),p=Math.max(p,t.x),f=Math.max(f,t.y);for(let t=0;t<h.length;t++){const r=this._tiles[h[t]];if(r.holdingForFade())continue;const a=s.getCoveringTilesDetailsProvider().allowWorldCopies()?r.tileID:r.tileID.unwrapTo(0),m=Math.pow(2,s.zoom-r.tileID.overscaledZ),g=i*r.queryPadding*e.af/r.tileSize/m,_=[a.getTilePoint(new e.ag(u,d)),a.getTilePoint(new e.ag(p,f))];if(n||_[0].x-g<e.af&&_[0].y-g<e.af&&_[1].x+g>=0&&_[1].y+g>=0){const t=l.map((t=>a.getTilePoint(t))),e=c.map((t=>a.getTilePoint(t)));o.push({tile:r,tileID:a,queryGeometry:t,cameraQueryGeometry:e,scale:m})}}return o}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));return this.transform&&this.transform.populateCache(e),e}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type)){const t=s.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function Kt(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Yt(t){return"raster"===t||"image"===t||"video"===t}Xt.maxOverzooming=10,Xt.maxUnderzooming=3;class Jt{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Qt{constructor(t,e,i,r,n){this.text=new Jt(t?t.text:null,e,i,n),this.icon=new Jt(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class te{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class ee{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class ie{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 e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function re(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.aE(t);return new e.P(-(s-.5)*i+n[0]*o,-(a-.5)*r+n[1]*o)}class ne{constructor(t,e,i,r,n,o,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new ut(this.transform,o,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ie(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.glyphCircles={},this.placedBoxes={},this.anchorAngles={},this.variableAnchors={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,r)=>e.getElevation(t,i,r):null}getBucketParts(t,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=r.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.af,d=r.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=e.az(r,1,this.transform.zoom,this.transform.detailLevel),m=e.aA(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),g=e.aA(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Z(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ee(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const y={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:e.N(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:y})}attemptAnchorPlacement(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v){const b=e.aB[t.textAnchor],w=[t.textOffset0,t.textOffset1],T=re(b,r,n,w,o),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,a,s,g,u.predicate,x,T,v);if((!y||this.collisionIndex.placeCollisionBox(y,d,l,c,h,a,s,_,u.predicate,x,T,v).placeable)&&P.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:w,width:r,height:n,anchor:b,textBoxScale:o,prevAnchor:t},this.markUsedJustification(f,b,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(t,i,r){const{bucket:n,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=t.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=e.aC(o,"text-overlap","text-allow-overlap"),y="always"===_,x=e.aC(o,"icon-overlap","icon-allow-overlap"),v="always"===x,b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="none"!==o.get("icon-text-fit"),P="viewport-y"===o.get("symbol-z-order"),M=y&&(v||!n.hasIconData()||g),S=v&&(y||!n.hasTextData()||m);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d);const C=this.retainedQueryData[n.bucketInstanceId].tileID,I=this._getTerrainElevationFunc(C),A=this.transform.getFastPathSimpleProjectionMatrix(C),E=(t,d,v)=>{var P,E;if(i[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new te(!1,!1,!1));let k=!1,z=!1,L=!0,D=null,R={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,N=0,V=0,U=0;d.textFeatureIndex?N=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(N=t.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const Z=d.textBox;if(Z){const i=i=>{let r=e.W.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(n,r,t))}return r},o=(i,r)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of n.writingModes)if(t===e.W.vertical?(R=r(),F=R):R=i(),R&&R.placeable)break}else R=i()},c=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===c){const r=(e,i)=>{const r=this.collisionIndex.placeCollisionBox(e,_,h,C,l,w,b,s,f.predicate,I,void 0,A);return r&&r.placeable&&(this.markUsedOrientation(n,i,t),this.placedOrientations[t.crossTileID]=i),r};o((()=>r(Z,e.W.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?r(i,e.W.vertical):{box:null,offscreen:null}})),i(R&&R.placeable)}else{let p=e.aB[null===(E=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[t.crossTileID])||void 0===E?void 0:E.anchor];const m=(i,o,d)=>{const m=i.x2-i.x1,g=i.y2-i.y1,y=t.textBoxScale,v=T&&"never"===x?o:null;let P=null,M="never"===_?1:2,S="never";p&&M++;for(let r=0;r<M;r++){for(let r=c;r<u;r++){const o=n.textAnchorOffsets.get(r);if(p&&o.textAnchor!==p)continue;const c=this.attemptAnchorPlacement(o,i,m,g,y,b,w,h,C,l,f,S,t,n,d,s,a,v,I);if(c&&(P=c.placedGlyphBoxes,P&&P.placeable))return k=!0,D=c.shift,this.addVariableAnchor(n.bucketInstanceId,N,e.aB[o.textAnchor]),P}p?p=null:S=_}return r&&!P&&(P={box:this.collisionIndex.placeCollisionBox(Z,"always",h,C,l,w,b,s,f.predicate,I,void 0,A).box,offscreen:!1,placeable:!1,occluded:!1}),P};o((()=>m(Z,d.iconBox,e.W.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&(!R||!R.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,e.W.vertical):{box:null,occluded:!0,offscreen:null}})),R&&(k=R.placeable,L=R.offscreen);const g=i(R&&R.placeable);if(!k&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,g))}}}if(B=R,k=B&&B.placeable,L=B&&B.offscreen,t.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),a=e.O(n.textSizeData,p,i),h=o.get("text-padding");O=this.collisionIndex.placeCollisionCircles(_,i,n.lineVertexArray,n.glyphOffsetArray,a,l,c,r,w,f.predicate,t.collisionCircleDiameter,h,s,I),O.circles.length&&O.collisionDetected&&!r&&e.w("Collisions detected, but collision boxes are not shown"),k=y||O.circles.length>0&&!O.collisionDetected,L=L&&O.offscreen}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,x,h,C,l,w,b,a,f.predicate,I,T&&D?D:void 0,A);F&&F.placeable&&d.verticalIconBox?(j=t(d.verticalIconBox),z=j.placeable):(j=t(d.iconBox),z=j.placeable),L=L&&j.offscreen}const $=m||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=g||0===t.numIconVertices;$||G?G?$||(z=z&&k):k=z&&k:z=k=z&&k;const q=z&&j.placeable;if(k&&B.placeable&&(F&&F.placeable&&V?this.collisionIndex.insertCollisionBox(B.box,_,o.get("text-ignore-placement"),n.bucketInstanceId,V,f.ID):(this.collisionIndex.insertCollisionBox(B.box,_,o.get("text-ignore-placement"),n.bucketInstanceId,N,f.ID),this.addPlacedBox(n.bucketInstanceId,N,B.box,"text"))),q&&(this.collisionIndex.insertCollisionBox(j.box,x,o.get("icon-ignore-placement"),n.bucketInstanceId,U,f.ID),this.addPlacedBox(n.bucketInstanceId,U,j.box,"icon")),(k||z)&&this.addAnchorAngle(n.bucketInstanceId,N,t.angle),O&&k&&(this.collisionIndex.insertCollisionCircles(O.circles,_,o.get("text-ignore-placement"),n.bucketInstanceId,N,f.ID),L||this.addGlyphCircles(n.bucketInstanceId,N,O.circles)),r&&this.storeCollisionData(n.bucketInstanceId,v,d,B,j,O),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new te((k||M)&&!(null==B?void 0:B.occluded),(z||S)&&!(null==j?void 0:j.occluded),L||n.justReloaded),i[t.crossTileID]=!0};if(P){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=n.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){const i=e[t];E(n.symbolInstances.get(i),n.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)E(n.symbolInstances.get(e),n.collisionArrays[e],e);n.justReloaded=!1}storeCollisionData(t,e,i,r,n,o){if(i.textBox||i.iconBox){let o,s;this.collisionBoxArrays.has(t)?o=this.collisionBoxArrays.get(t):(o=new Map,this.collisionBoxArrays.set(t,o)),o.has(e)?s=o.get(e):(s={text:null,icon:null},o.set(e,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=n.box)}if(o){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<o.circles.length;t+=4)e.push(o.circles[t+0]-ht),e.push(o.circles[t+1]-ht),e.push(o.circles[t+2]),e.push(o.collisionDetected?1:0)}}markUsedJustification(t,i,r,n){let o;o=n===e.W.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[e.aD(i)];const s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:r.crossTileID)}markUsedOrientation(t,i,r){const n=i===e.W.horizontal||i===e.W.horizontalOnly?i:0,o=i===e.W.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},o=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=n[t];o?(this.opacities[t]=new Qt(o,r,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new Qt(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new Qt(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(t,i,r,n){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 o=t.layers[0],s=o.layout,a=new Qt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new Qt(null,0,l&&(c||!t.hasIconData()||s.get("icon-optional")),c&&(l||!t.hasTextData()||s.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const m=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices=t.hasVisibleVertices||i!==fe},g=this.collisionBoxArrays.get(t.bucketInstanceId);for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:o,numVerticalGlyphVertices:s,crossTileID:l}=n;let c=this.opacities[l];r[l]?c=a:c||(c=f,this.opacities[l]=c),r[l]=!0;const _=n.numIconVertices>0,y=this.placedOrientations[n.crossTileID],x=y===e.W.vertical,v=y===e.W.horizontal||y===e.W.horizontalOnly;if(o>0||s>0){const e=pe(c.text);m(t.text,o,x?fe:e),m(t.text,s,v?fe:e);const i=c.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||x?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(t,r.anchor,n,y);const a=this.placedOrientations[n.crossTileID];a&&(this.markUsedJustification(t,"left",n,a),this.markUsedOrientation(t,a,n))}if(_){const e=pe(c.icon),i=!(p&&n.verticalPlacedIconSymbolIndex&&x);n.placedIconSymbolIndex>=0&&(m(t.icon,n.numIconVertices,i?e:fe),t.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=c.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,n.numVerticalIconVertices,i?fe:e),t.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=g&&g.has(i)?g.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0);if(r.textBox||r.verticalTextBox){let e=!0;if(h){const t=this.variableOffsets[l];t?(i=re(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):e=!1}if(r.textBox||r.verticalTextBox){let n;r.textBox&&(n=x),r.verticalTextBox&&(n=v),oe(t.textCollisionBox.collisionVertexArray,c.text.placed,!e||n,b.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){const e=Boolean(!v&&r.verticalIconBox);let n;r.iconBox&&(n=e),r.verticalIconBox&&(n=!e),oe(t.iconCollisionBox.collisionVertexArray,c.icon.placed,n,b.icon,p?i.x:0,p?i.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),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`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return 0===this.fadeDuration?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,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}addGlyphCircles(t,e,i){t in this.glyphCircles||(this.glyphCircles[t]={}),e in this.glyphCircles[t]||(this.glyphCircles[t][e]=[]),this.glyphCircles[t][e].push(i)}addPlacedBox(t,e,i,r){t in this.placedBoxes||(this.placedBoxes[t]={}),e in this.placedBoxes[t]||(this.placedBoxes[t][e]=[]),this.placedBoxes[t][e].push({purpose:r,coords:i})}addAnchorAngle(t,e,i){t in this.anchorAngles||(this.anchorAngles[t]={}),e in this.anchorAngles[t]||(this.anchorAngles[t][e]=[]),this.anchorAngles[t][e].push(i)}addVariableAnchor(t,e,i){t in this.variableAnchors||(this.variableAnchors[t]={}),this.variableAnchors[t][e]=i}}function oe(t,e,i,r,n,o){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-ht,a=r[1]-ht,l=r[2]-ht,c=r[3]-ht;t.emplaceBack(e?1:0,i?1:0,n||0,o||0,s,a),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,l,a),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,l,c),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,s,c)}const se=Math.pow(2,25),ae=Math.pow(2,24),le=Math.pow(2,17),ce=Math.pow(2,16),he=Math.pow(2,9),ue=Math.pow(2,8),de=Math.pow(2,1);function pe(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*se+e*ae+i*le+e*ce+i*he+e*ue+i*de+e}const fe=0;class me{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(o,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<o.length;)if(e.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class ge{constructor(t,e,i,r,n,o,s,a,l,c){this.placement=new ne(t,e,o,s,a,l,c),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=s.now(),n=()=>!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new me(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const _e=512/e.af/2;class ye{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};const n=new Map;for(let t=0;t<i.length;t++){const e=i.get(t),r=e.key,o=n.get(r);o?o.push(e):n.set(r,[e])}for(const[t,i]of n){const r={positions:i.map((t=>({x:Math.floor(t.anchorX*_e),y:Math.floor(t.anchorY*_e)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(r.positions.length>128){const t=new e.aF(r.positions.length,16,Uint16Array);for(const{x:e,y:i}of r.positions)t.add(e,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,i){const{x:r,y:n,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=_e/Math.pow(2,l-o),h=(a*e.af+t.anchorY)*c,u=n*e.af*_e;return{x:Math.floor((s*e.af+t.anchorX)*c-r*e.af*_e),y:Math.floor(h-u)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const o=t.get(n);if(o.crossTileID)continue;const s=this._symbolsByKey[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,e);if(s.index){const t=s.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(const e of t){const t=s.crossTileIDs[e];if(!i[t]){i[t]=!0,o.crossTileID=t;break}}}else if(s.positions)for(let t=0;t<s.positions.length;t++){const e=s.positions[t],n=s.crossTileIDs[t];if(Math.abs(e.x-a.x)<=r&&Math.abs(e.y-a.y)<=r&&!i[n]){i[n]=!0,o.crossTileID=n;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class xe{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ve{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,r)}else{const o=n[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new ye(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i of e.getCrossTileIDsLists())for(const e of i)delete this.usedCrossTileIDs[t][e]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class be{constructor(){this.layerIndexes={},this.crossTileIDs=new xe,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new ve);let n=!1;const o={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(n=!0),o[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(n=!0),n}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var we="void main() {fragColor=vec4(1.0);}";const Te={prelude:Pe("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 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\n);}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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform 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;\n#endif\nconst 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) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 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;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 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;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Pe("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Pe("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Pe("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Pe("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;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);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:Pe("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;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));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}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;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Pe(we,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Pe("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Pe("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out 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:Pe("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Pe("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {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;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Pe("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Pe(we,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Pe("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Pe("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Pe("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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=projectTile(a_pos+u_fill_translate,a_pos);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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=projectTile(a_pos+u_fill_translate,a_pos);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:Pe("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat 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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=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:Pe("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*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:Pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(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));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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:Pe("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(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);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Pe("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Pe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Pe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat 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=texture(u_image,v_tex_a).a;float sdfdist_b=texture(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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;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;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_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:Pe("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Pe("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Pe("#define SDF_PX 8.0\nuniform 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;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat 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=texture(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);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Pe("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform 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;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Pe("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Pe("in 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() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Pe("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Pe("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Pe("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Pe("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Pe(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/in ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(n):n,a={};return{fragmentSource:t=t.replace(i,((t,e,i,r,n)=>(a[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return a[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class Me{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Se=e.aG([{name:"a_pos",type:"Int16",components:2}]);const Ce="#define PROJECTION_MERCATOR",Ie="mercator";class Ae{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ie}get shaderDefine(){return Ce}get shaderPreludeCode(){return Te.projectionMercator}get vertexShaderPreludeCode(){return Te.projectionMercator.vertexSource}get subdivisionGranularity(){return e.aH.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,i,r,n,o){if(this._cachedMesh)return this._cachedMesh;const s=new e.aI;s.emplaceBack(0,0),s.emplaceBack(e.af,0),s.emplaceBack(0,e.af),s.emplaceBack(e.af,e.af);const a=t.createVertexBuffer(s,Se.members),l=e.aJ.simpleSegment(0,0,4,2),c=new e.aK;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=t.createIndexBuffer(c);return this._cachedMesh=new Me(a,h,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Ee{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.B.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.B.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.B.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.B.number(t.right,i.right,r)),this}getCenter(t,i){const r=e.K((this.left+t-this.right)/2,0,t),n=e.K((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Ee(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ke(t,e){if(!t.renderWorldCopies||t.lngRange)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function ze(t){return Math.max(0,Math.floor(t))}class Le{constructor(t,i,r,n,o,s){this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==n?0:n,this._maxPitch=null==o?60:o,this.setMaxBounds(),this._width=0,this._height=0,this._center=new e.a8(0,0),this._elevation=0,this._zoom=0,this._tileZoom=ze(this._zoom),this._scale=e.at(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ee,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0,this._detailLevel=0,this._rasterAlignment=!0}apply(t,i,r){this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=ze(this._zoom),this._scale=e.at(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Ee(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!r&&t.autoCalculateNearFarZ,this._detailLevel=t.detailLevel,i&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(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 e.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const i=e.aL(t,-180,180)*Math.PI/180;var n,o,s,a,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),n=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],h=o[3],u=Math.sin(s),d=Math.cos(s),n[0]=a*d+c*u,n[1]=l*d+h*u,n[2]=a*-u+c*d,n[3]=l*-u+h*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const i=e.K(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return e.aM(this._fovInRadians)}setFov(t){t=e.K(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=e.as(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const i=this.getConstrained(this._center,t).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=e.at(i),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get detailLevel(){return this._detailLevel}setDetailLevel(t){if((t=Math.round(e.K(t,-3,3)))===this._detailLevel)return;const i=this._detailLevel;this._detailLevel=t,this.setZoom(this.zoom+this.detailLevel-i)}get rasterAlignment(){return this._rasterAlignment}setRasterAlignment(t){this._rasterAlignment=t}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(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)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,e){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=e,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}resize(t,e,i=!0){this._width=t,this._height=e,i&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new xt([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,e.au])}getConstrained(t,e){return this._callbacks.getConstrained(t,e)}getCameraQueryGeometry(t,i){if(1===i.length)return[i[0],t];{let r=t.x,n=t.y,o=t.x,s=t.y;for(const t of i)r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y);return[new e.P(r,n),new e.P(o,n),new e.P(o,s),new e.P(r,s),new e.P(r,n)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(e),this.setZoom(i),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=e.a2(new Float64Array(16));e.M(t,t,[this._width/2,-this._height/2,1]),e.a3(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=e.a2(new Float64Array(16)),e.M(t,t,[1,-1,1]),e.a3(t,t,[-1,-1,0]),e.M(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height*2**this._detailLevel}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,i,r,n){const o=void 0!==r?r:this.bearing,s=n=void 0!==n?n:this.pitch,a=e.ag.fromLngLat(t,i),l=-Math.cos(e.as(s)),c=Math.sin(e.as(s)),h=c*Math.sin(e.as(o)),u=-c*Math.cos(e.as(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=e.aN(1,a.y),y=0;do{if(y+=1,y>10)break;g=f/_,m=new e.ag(a.x+h*g,a.y+u*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:e.aw(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const i=e.av(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,n=e.ag.fromLngLat(this.center,this.elevation),o=Ut(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=t;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),e.aN(o.z,n.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=e.av(1,this.center.lat)*this.worldSize;return Ut(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const i=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/i,t.canonical.y/i,1/i/e.af,1/i/e.af]}}class De{constructor(t,i){this.min=t,this.max=i,this.center=e.aO([],e.aP([],this.min,this.max),.5)}quadrant(t){const i=[t%2==0,t<2],r=e.aQ(this.min),n=e.aQ(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new De(r,n)}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]}intersectsFrustum(t){let e=!0;for(let i=0;i<t.planes.length;i++){const r=this.intersectsPlane(t.planes[i]);if(0===r)return 0;1===r&&(e=!1)}return e?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let e=t[3],i=t[3];for(let r=0;r<3;r++)t[r]>0?(e+=t[r]*this.min[r],i+=t[r]*this.max[r]):(i+=t[r]*this.min[r],e+=t[r]*this.max[r]);return e>=0?2:i<0?0:1}}class Re{distanceToTile2d(t,e,i,r){const n=r.distanceX([t,e]),o=r.distanceY([t,e]);return Math.hypot(n,o)}getWrap(t,e,i){return i}getTileAABB(t,i,r,n){var o,s;let a=r,l=r;if(n.terrain){const c=new e.ae(t.z,i,t.z,t.x,t.y),h=n.terrain.getMinMaxElevation(c);a=null!==(o=h.minElevation)&&void 0!==o?o:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r}const c=1<<t.z;return new De([i+t.x/c,t.y/c,a],[i+(t.x+1)/c,(t.y+1)/c,l])}allowVariableZoom(t,i){const r=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,n=e.K(78.5-r/2,0,60);return!!i.terrain||t.pitch>n}allowWorldCopies(){return!0}recalculateCache(){}}class Fe{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(t,i=1,r=0){const n=Math.pow(2,r),o=[[-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((r=>{const o=1/(r=e.Z([],r,t))[3]/i*n;return e.aR(r,r,[o,o,1/r[3],o])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const i=e.aS([],o[t[0]],o[t[1]]),r=e.aS([],o[t[2]],o[t[1]]),n=e.aT([],e.aU([],i,r)),s=-e.aV(n,o[t[1]]);return n.concat(s)})),a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const t of o)for(let e=0;e<3;e++)a[e]=Math.min(a[e],t[e]),l[e]=Math.max(l[e],t[e]);return new Fe(o,s,new De(a,l))}}class Be{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t,e){}constructor(t,e,i,r,n){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)},t,e,i,r,n),this._coveringTilesDetailsProvider=new Re}clone(){const t=new Be;return t.apply(this),t}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const i=[new e.aW(0,t)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new e.P(0,0)),n=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new e.P(0,this._helper._height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new e.aW(r,t))}return i}getCameraFrustum(){return Fe.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLatZoom(e,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,i){const r=e.av(this.elevation,this.center.lat),n=this.screenPointToMercatorCoordinateAtZ(i,r),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=e.ag.fromLngLat(t),a=new e.ag(s.x-(n.x-o.x),s.y-(n.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(e.ag.fromLngLat(t),i.getElevationForLngLatZoom(t,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(e.ag.fromLngLat(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,i){const r=i||0,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.Z(n,n,this._pixelMatrixInverse),e.Z(o,o,this._pixelMatrixInverse);const s=n[3],a=o[3],l=n[1]/s,c=o[1]/a,h=n[2]/s,u=o[2]/a,d=h===u?0:(r-h)/(u-h);return new e.ag(e.B.number(n[0]/s,o[0]/a,d)/this.worldSize,e.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){const n=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.Z(n,n,r),new e.P(n[0]/n[3],n[1]/n[3])}getBounds(){const t=Math.max(0,this._helper._height/2-Nt(this));return(new xt).extend(this.screenPointToLocation(new e.P(0,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new e.P(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=e.pointCoordinate(t):t.y>this.height/2-Nt(this)}calculatePosMatrix(t,i=!1,r){var n;const o=null!==(n=t.key)&&void 0!==n?n:e.aX(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const t=s.get(o);return r?t.f32:t.f64}const a=Vt(t,this.worldSize);e.a6(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),r?l.f32:l.f64}calculateFogMatrix(t){const i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const n=Vt(t,this.worldSize);return e.a6(n,this._fogMatrix,n),r.set(i,new Float32Array(n)),r.get(i)}getConstrained(t,i){i=e.K(+i,this.minZoom,this.maxZoom);const r={center:new e.a8(t.lng,t.lat),zoom:i};let n=this._helper._lngRange;this._helper._renderWorldCopies||null!==n||(n=[-179.9999999999,180-1e-10]);const o=this.tileSize*e.at(r.zoom);let s=0,a=o,l=0,c=o,h=0,u=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const t=this._helper._latRange;s=e.a9(t[1])*o,a=e.a9(t[0])*o,a-s<p&&(h=p/(a-s))}n&&(l=e.aL(e.aa(n[0])*o,0,o),c=e.aL(e.aa(n[1])*o,0,o),c<l&&(c+=o),c-l<d&&(u=d/(c-l)));const{x:f,y:m}=Ot(o,t);let g,_;const y=Math.max(u||0,h||0);if(y){const t=new e.P(u?(c+l)/2:f,h?(a+s)/2:m);return r.center=jt(o,t).wrap(),r.zoom+=e.aw(y),r}if(this._helper._latRange){const t=p/2;m-t<s&&(_=s+t),m+t>a&&(_=a-t)}if(n){const t=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=e.aL(f,t-o/2,t+o/2));const r=d/2;i-r<l&&(g=l+r),i+r>c&&(g=c-r)}if(void 0!==g||void 0!==_){const t=new e.P(null!=g?g:f,null!=_?_:m);r.center=jt(o,t).wrap()}return r}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}_calculateNearFarZIfNeeded(t,i,r){if(!this._helper.autoCalculateNearFarZ)return;const n=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=t-n*this._helper._pixelPerMeter/Math.cos(i),s=n<0?o:t,a=Math.PI/2+this.pitchInRadians,l=e.as(this.fov)*(Math.abs(Math.cos(e.as(this.roll)))*this.height+Math.abs(Math.sin(e.as(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(e.K(Math.PI-a-l,.01,Math.PI-.01)),h=Nt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=e.as(.75),p=u>d?2*u*(.5+r.y/(2*h)):d,f=Math.sin(p)*s/Math.sin(e.K(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,i=Ot(this.worldSize,this.center),r=i.x,n=i.y;this._helper._pixelPerMeter=e.av(1,this.center.lat)*this.worldSize;const o=e.as(Math.min(this.pitch,Bt)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,t),a=new Float64Array(16),e.aY(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),e.Q(this._invProjMatrix,a),a[8]=2*-t.x/this._helper._width,a[9]=2*t.y/this._helper._height,this._projectionMatrix=e.aZ(a),e.M(a,a,[1,-1,1]),e.a3(a,a,[0,0,-this._helper.cameraToCenterDistance]),e.a_(a,a,-this.rollInRadians),e.a$(a,a,this.pitchInRadians),e.a_(a,a,-this.bearingInRadians),e.a3(a,a,[-r,-n,0]),this._mercatorMatrix=e.M([],a,[this.worldSize,this.worldSize,this.worldSize]),e.M(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=e.a6(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),this._viewProjMatrix=a,this._invViewProjMatrix=e.Q([],a);const l=[0,0,-1,1];if(e.Z(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),e.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,e.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),e.a3(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),e.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),e.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),e.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),e.a3(this._fogMatrix,this._fogMatrix,[-r,-n,0]),e.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),e.a3(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=e.a6(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),this._helper.rasterAlignment){const t=this._helper._width%2/2,i=this._helper._height%2/2,o=Math.cos(this.bearingInRadians),s=Math.sin(-this.bearingInRadians),l=r-Math.round(r)+o*t+s*i,c=n-Math.round(n)+o*i+s*t,h=new Float64Array(a);e.a3(h,h,[l>.5?l-1:l,c>.5?c-1:c,0]),this._alignedProjMatrix=h,a=e.Q(new Float64Array(16),this._pixelMatrix)}else this._alignedProjMatrix=new Float64Array(a);if(!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.Z(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=e.av(1,this.center.lat)*this.worldSize;return Ut(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,i){const r=e.ag.fromLngLat(t),n=[r.x*this.worldSize,r.y*this.worldSize,i,1];return e.Z(n,n,this._viewProjMatrix),n[2]/n[3]}getProjectionData(t){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=t,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:s||e.b0(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return e.aQ(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,i,r,n){const o=this.calculatePosMatrix(r);let s;n?(s=[t,i,n(t,i),1],e.Z(s,s,o)):(s=[t,i,0,1],ct(s,s,o));const a=s[3];return{point:new e.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(t){for(const e of t)this.calculatePosMatrix(e)}getMatrixForModel(t,i){const r=e.ag.fromLngLat(t,i),n=r.meterInMercatorCoordinateUnits(),o=e.b1();return e.a3(o,o,[r.x,r.y,r.z]),e.a_(o,o,Math.PI),e.a$(o,o,Math.PI/2),e.M(o,o,[-n,n,n]),o}getProjectionDataForCustomLayer(t=!0){const i=new e.ae(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),n=Vt(i,this.worldSize);e.a6(n,this._viewProjMatrix,n),r.tileMercatorCoords=[0,0,1,1];const o=[e.af,e.af,this.worldSize/this._helper.pixelsPerMeter],s=e.b2();return e.M(s,n,o),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function Oe(){e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function je(t){if(t.useSlerp)if(t.k<1){const i=e.b3(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=e.b3(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),n=new Float64Array(4);e.b4(n,i,r,t.k);const o=e.b5(n);t.tr.setRoll(o.roll),t.tr.setPitch(o.pitch),t.tr.setBearing(o.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(e.B.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(e.B.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(e.B.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ne(t,i,r,n,o){const s=o.padding,a=Ot(o.worldSize,r.getNorthWest()),l=Ot(o.worldSize,r.getNorthEast()),c=Ot(o.worldSize,r.getSouthEast()),h=Ot(o.worldSize,r.getSouthWest()),u=e.as(-n),d=a.rotate(u),p=l.rotate(u),f=c.rotate(u),m=h.rotate(u),g=new e.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new e.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),y=g.sub(_),x=(o.width-(s.left+s.right+i.left+i.right))/y.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/y.y;if(v<0||x<0)return void Oe();const b=Math.min(e.aw(o.scale*Math.min(x,v)),t.maxZoom),w=e.P.convert(t.offset),T=new e.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(e.as(n)),P=w.add(T).mult(o.scale/e.at(b));return{center:jt(o.worldSize,a.add(c).div(2).sub(P)),zoom:b,bearing:n}}class Ve{get useGlobeControls(){return!1}handlePanInertia(t,e){return{easingOffset:t,easingCenter:e.center}}handleMapControlsRollPitchBearingZoom(t,e){t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta),t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta)}handleMapControlsPan(t,e,i){t.around.distSqr(e.centerPoint)<.01||e.setLocationAtPoint(i,t.around)}cameraForBoxAndBearing(t,e,i,r,n){return Ne(t,e,i,r,n)}handleJumpToCenterZoom(t,i){t.zoom!==(void 0!==i.zoom?+i.zoom:t.zoom)&&t.setZoom(+i.zoom),void 0!==i.center&&t.setCenter(e.a8.convert(i.center))}handleEaseTo(t,i){const r=t.zoom,n=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},a=void 0!==i.zoom,l=!t.isPaddingEqual(i.padding);let c=!1;const h=a?+i.zoom:t.zoom;let u=t.centerPoint.add(i.offsetAsPoint);const d=t.screenPointToLocation(u),{center:p,zoom:f}=t.getConstrained(e.a8.convert(i.center||d),null!=h?h:r);ke(t,p);const m=Ot(t.worldSize,d),g=Ot(t.worldSize,p).sub(m),_=e.at(f-r);return c=f!==r,{easeFunc:a=>{if(c&&t.setZoom(e.B.number(r,f,a)),e.b6(o,s)||je({startEulerAngles:o,endEulerAngles:s,tr:t,k:a,useSlerp:o.roll!=s.roll}),l&&(t.interpolatePadding(n,i.padding,a),u=t.centerPoint.add(i.offsetAsPoint)),i.around)t.setLocationAtPoint(i.around,i.aroundPoint);else{const i=e.at(t.zoom-r),n=f>r?Math.min(2,_):Math.max(.5,_),o=Math.pow(n,1-a),s=jt(t.worldSize,m.add(g.mult(a*o)).mult(i));t.setLocationAtPoint(t.renderWorldCopies?s.wrap():s,u)}},isZooming:c,elevationCenter:p}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.zoom,o=t.getConstrained(e.a8.convert(i.center||i.locationAtOffset),r?+i.zoom:n),s=o.center,a=o.zoom;ke(t,s);const l=Ot(t.worldSize,i.locationAtOffset),c=Ot(t.worldSize,s).sub(l),h=c.mag(),u=e.at(a-n);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,n,a),o=t.getConstrained(s,r).zoom;d=e.at(o-n)}return{easeFunc:(i,r,o,h)=>{t.setZoom(1===i?a:n+e.aw(r));const u=1===i?s:jt(t.worldSize,l.add(c.mult(o)).mult(r));t.setLocationAtPoint(t.renderWorldCopies?u.wrap():u,h)},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class Ue{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}Ue.Replace=[1,0],Ue.disabled=new Ue(Ue.Replace,e.b7.transparent,[!1,!1,!1,!1]),Ue.unblended=new Ue(Ue.Replace,e.b7.transparent,[!0,!0,!0,!0]),Ue.alphaBlended=new Ue([1,771],e.b7.transparent,[!0,!0,!0,!0]);const Ze=2305;class $e{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}$e.disabled=new $e(!1,1029,Ze),$e.backCCW=new $e(!0,1029,Ze),$e.frontCCW=new $e(!0,1028,Ze);class Ge{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Ge.ReadOnly=!1,Ge.ReadWrite=!0,Ge.disabled=new Ge(519,Ge.ReadOnly,[0,1]);const qe=7680;class We{constructor(t,e,i,r,n,o){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}We.disabled=new We({func:519,mask:0},0,0,qe,qe,qe);const He=new WeakMap;function Xe(t){var e;if(He.has(t))return He.get(t);{const i=null===(e=t.getParameter(t.VERSION))||void 0===e?void 0:e.startsWith("WebGL 2.0");return He.set(t,i),i}}class Ke{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const i=t.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const n=new e.aI;n.emplaceBack(-1,-1),n.emplaceBack(2,-1),n.emplaceBack(-1,2);const o=new e.aK;o.emplaceBack(0,1,2),this._fullscreenTriangle=new Me(i.createVertexBuffer(n,Se.members),i.createIndexBuffer(o),e.aJ.simpleSegment(0,0,n.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Xe(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,e){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,e),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,e=t.gl;t.activeTexture.set(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,i){const r=this._cachedRenderContext.context,n=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:e.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,n.TRIANGLES,Ge.disabled,We.disabled,Ue.unblended,$e.disabled,((t,e)=>({u_input:t,u_output_expected:e}))(t,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Xe(n)){n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.readBuffer(n.COLOR_ATTACHMENT0),n.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null);const t=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);n.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:t}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Xe(t)){const i=t.clientWaitSync(this._readbackQueue.sync,0,0);if(i===t.WAIT_FAILED)return e.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ke._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let e=0;return e+=t[0]/256,e+=t[1]/65536,e+=t[2]/16777216,t[3]<127&&(e=-e),e/128}}const Ye=e.af/128;function Je(t,i){const r=void 0!==t.granularity?Math.max(t.granularity,1):1,n=r+(t.generateBorders?2:0),o=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),s=n+1,a=o+1,l=t.generateBorders?-1:0,c=t.generateBorders||t.extendToNorthPole?-1:0,h=r+(t.generateBorders?1:0),u=r+(t.generateBorders||t.extendToSouthPole?1:0),d=s*a,p=n*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=u;i++)for(let n=l;n<=h;n++){let o=n/r*e.af;-1===n&&(o=-64),n===r+1&&(o=e.af+Ye);let s=i/r*e.af;-1===i&&(s=t.extendToNorthPole?e.b9:-64),i===r+1&&(s=t.extendToSouthPole?e.ba:e.af+Ye),g[_++]=o,g[_++]=s}const y=m?new Uint32Array(p):new Uint16Array(p);let x=0;for(let t=0;t<o;t++)for(let e=0;e<n;e++){const i=e+1+t*s,r=e+(t+1)*s,n=e+1+(t+1)*s;y[x++]=e+t*s,y[x++]=r,y[x++]=i,y[x++]=i,y[x++]=r,y[x++]=n}return{vertices:g.buffer.slice(0),indices:y.buffer.slice(0),uses32bitIndices:m}}const Qe=new e.aH({fill:new e.bb(128,2),line:new e.bb(512,0),tile:new e.bb(128,32),stencil:new e.bb(128,1),circle:3});class ti{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Te.projectionGlobe}get vertexShaderPreludeCode(){return Te.projectionMercator.vertexSource}get subdivisionGranularity(){return Qe}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new Ke(t));const i=e.a9(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,n=this._errorMeasurement.updateErrorLoop(i,r),o=s.now();n!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=n,this._errorMeasurementLastChangeTime=o);const a=Math.min(Math.max((o-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=e.bc(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,e.bd(a))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,r,n){const o=("stencil"===n?Qe.stencil:Qe.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:o,generateBorders:i,extendToNorthPole:0===e.y&&r,extendToSouthPole:e.y===(1<<e.z)-1&&r})}_getMesh(t,i){const r=this._getMeshKey(i);if(r in this._tileMeshCache)return this._tileMeshCache[r];const n=function(t,i){const r=Je(i,"16bit"),n=e.aI.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),o=e.aK.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Me(t.createVertexBuffer(n,Se.members),t.createIndexBuffer(o),e.aJ.simpleSegment(0,0,n.length,o.length))}(t,i);return this._tileMeshCache[r]=n,n}recalculate(t){}hasTransition(){const t=s.now();let e=!1;return e=e||(t-this._errorMeasurementLastChangeTime)/1e3<.7,e=e||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,e}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const ei=new e.r({type:new e.D(e.v.projection.type)});class ii extends e.E{constructor(t){super(),this._transitionable=new e.T(ei),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.C(0)),this._mercatorProjection=new Ae,this._verticalPerspectiveProjection=new ti}get transitionState(){const t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof e.be){if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,e,i,r,n){return this.currentProjection.getMeshFromTileID(t,e,i,r,n)}setProjection(t){this._transitionable.setValue("type",(null==t?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function ri(t){const e=si(t.worldSize,t.center.lat);return 2*Math.PI*e}function ni(t,i,r,n,o){const s=1/(1<<o),a=i/e.af*s+n*s,l=e.bg((t/e.af*s+r*s)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,h=Math.cos(c),u=new Float64Array(3);return u[0]=Math.sin(l)*h,u[1]=Math.sin(c),u[2]=Math.cos(l)*h,u}function oi(t){return function(t,e){const i=Math.cos(e),r=new Float64Array(3);return r[0]=Math.sin(t)*i,r[1]=Math.sin(e),r[2]=Math.cos(t)*i,r}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function si(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function ai(t){const i=Math.asin(t[1])/Math.PI*180,r=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(r>1e-6){const n=t[0]/r,o=Math.acos(t[2]/r),s=(n>0?o:-o)/Math.PI*180;return new e.a8(e.aL(s,-180,180),i)}return new e.a8(0,i)}function li(t){return Math.cos(t*Math.PI/180)}function ci(t,i){const r=li(t),n=li(i);return e.aw(n/r)}function hi(t,i){const r=t.rotate(i.bearingInRadians),n=i.zoom+ci(i.center.lat,0),o=e.bc(1/li(i.center.lat),1/li(Math.min(Math.abs(i.center.lat),60)),e.bf(n,7,3,0,1)),s=360/ri({worldSize:i.worldSize,center:{lat:i.center.lat}});return new e.a8(i.center.lng-r.x*s*o,e.K(i.center.lat+r.y*s,-85.051129,e.au))}function ui(t){const e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function di(t,i,r,n){const o=t.lat+r*n;if(Math.abs(r)>1){const s=(Math.sign(t.lat+r)!==Math.sign(t.lat)?-Math.abs(t.lat):Math.abs(t.lat))*Math.PI/180,a=Math.abs(t.lat+r)*Math.PI/180,l=ui(s+n*(a-s)),c=ui(s),h=ui(a);return new e.a8(t.lng+i*((l-c)/(h-c)),o)}return new e.a8(t.lng+i*n,o)}class pi{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=t}recalculateCache(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileAABB(t,e,i,r){const n=`${t.z}_${t.x}_${t.y}`,o=this._cache.get(n);if(o)return o;const s=this._cachePrevious.get(n);if(s)return this._cache.set(n,s),s;const a=this._aabbFactory(t,e,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}function fi(t,e,i){const r=t-e;return r<0?-r:Math.max(0,r-i)}function mi(t,e,i,r,n){const o=t-i;let s;return s=o<0?Math.min(-o,1+o-n):o>1?Math.min(Math.max(o-n,0),1-o):0,Math.max(s,fi(e,r,n))}class gi{constructor(){this._aabbCache=new pi(this._computeTileAABB)}recalculateCache(){this._aabbCache.recalculateCache()}distanceToTile2d(t,e,i,r){const n=1<<i.z,o=1/n,s=i.x/n,a=i.y/n;let l=2;return l=Math.min(l,mi(t,e,s,a,o)),l=Math.min(l,mi(t,e,s+.5,-a-o,o)),l=Math.min(l,mi(t,e,s+.5,2-a-o,o)),l}getWrap(t,e,i){const r=1<<e.z,n=1/r,o=e.x/r,s=fi(t.x,o,n),a=fi(t.x,o-1,n),l=fi(t.x,o+1,n),c=Math.min(s,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(t,e){return Wt(t,e)>4}allowWorldCopies(){return!1}getTileAABB(t,e,i,r){return this._aabbCache.getTileAABB(t,e,i,r)}_computeTileAABB(t,i,r,n){if(t.z<=0)return new De([-1,-1,-1],[1,1,1]);if(1===t.z)return new De([0===t.x?-1:0,0===t.y?0:-1,-1],[0===t.x?0:1,0===t.y?1:0,1]);{const i=[ni(0,0,t.x,t.y,t.z),ni(e.af,0,t.x,t.y,t.z),ni(e.af,e.af,t.x,t.y,t.z),ni(0,e.af,t.x,t.y,t.z)],r=[1,1,1],n=[-1,-1,-1];for(const t of i)for(let e=0;e<3;e++)r[e]=Math.min(r[e],t[e]),n[e]=Math.max(n[e],t[e]);if(0===t.y||t.y===(1<<t.z)-1){const e=[0,0===t.y?1:-1,0];for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),n[t]=Math.max(n[t],e[t])}return new De(r,n)}}}class _i{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e){this._helper.resize(t,e)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(){this._cachedClippingPlane=e.bk(),this._projectionMatrix=e.b1(),this._globeViewProjMatrix32f=e.b0(),this._globeViewProjMatrixNoCorrection=e.b1(),this._globeViewProjMatrixNoCorrectionInverted=e.b1(),this._globeProjMatrixInverted=e.b1(),this._cameraPosition=e.bh(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)}),this._coveringTilesDetailsProvider=new gi}clone(){const t=new _i;return t.apply(this),t}apply(t,e){this._globeLatitudeErrorCorrectionRadians=e||0,this._helper.apply(t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=e.bh();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:e,applyGlobeMatrix:i}=t,r=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const i=this.pitchInRadians,r=this.cameraToCenterDistance/t,n=Math.sin(i)*r,o=Math.cos(i)*r+1,s=1/Math.sqrt(n*n+o*o)*1;let a=-n,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const h=[0,a,l];e.bl(h,h,[0,0,0],-this.bearingInRadians),e.bm(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),e.bn(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/e.bo(h);return e.aO(h,h,u),[...h,-s*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(oi(t))}transformLightDirection(t){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,n=Math.cos(r),o=[Math.sin(i)*n,Math.sin(r),Math.cos(i)*n],s=[o[2],0,-o[0]],a=[0,0,0];e.aU(a,s,o),e.aT(s,s),e.aT(a,a);const l=[0,0,0];return e.aT(l,[s[0]*t[0]+a[0]*t[1]+o[0]*t[2],s[1]*t[0]+a[1]*t[1]+o[1]*t[2],s[2]*t[0]+a[2]*t[1]+o[2]*t[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,i,r){const n=function(t,i,r){const n=1/(1<<r.z);return new e.ag(t/e.af*n+r.x*n,i/e.af*n+r.y*n)}(t,i,r.canonical),o=(s=n.y,[e.bg(n.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI]);var s;return this.getCircleRadiusCorrection()/Math.cos(o[1])}projectTileCoordinates(t,i,r,n){const o=r.canonical,s=ni(t,i,o.x,o.y,o.z),a=1+(n?n(t,i):0)/e.bu,l=[s[0]*a,s[1]*a,s[2]*a,1];e.Z(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]<0;return{point:new e.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=si(this.worldSize,this.center.lat),i=e.b2(),r=e.b2();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),e.aY(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const n=this.centerOffset;i[8]=2*-n.x/this._helper._width,i[9]=2*n.y/this._helper._height,this._projectionMatrix=e.aZ(i),this._globeProjMatrixInverted=e.b2(),e.Q(this._globeProjMatrixInverted,i),e.a3(i,i,[0,0,-this.cameraToCenterDistance]),e.a_(i,i,this.rollInRadians),e.a$(i,i,-this.pitchInRadians),e.a_(i,i,this.bearingInRadians),e.a3(i,i,[0,0,-t]);const o=e.bh();o[0]=t,o[1]=t,o[2]=t,e.a$(r,i,this.center.lat*Math.PI/180),e.bp(r,r,-this.center.lng*Math.PI/180),e.M(r,r,o),this._globeViewProjMatrixNoCorrection=r,e.a$(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),e.bp(i,i,-this.center.lng*Math.PI/180),e.M(i,i,o),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=e.b2(),e.Q(this._globeViewProjMatrixNoCorrectionInverted,r);const s=e.bh();this._cameraPosition=e.bh(),this._cameraPosition[2]=this.cameraToCenterDistance/t,e.bl(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),e.bm(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),e.bl(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),e.aP(this._cameraPosition,this._cameraPosition,[0,0,1]),e.bm(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),e.bn(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const a=e.aZ(this._globeViewProjMatrixNoCorrectionInverted);e.M(a,a,[1,1,-1]),this._cachedFrustum=Fe.fromInvProjectionMatrix(a)}calculateFogMatrix(t){e.w("calculateFogMatrix is not supported on globe projection.");const i=e.b2();return e.a2(i),i}getVisibleUnwrappedCoordinates(t){return[new e.aW(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&e.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const r=oi(t);e.aO(r,r,1+i/e.bu);const n=e.bk();return e.Z(n,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),n[2]/n[3]}populateCache(t){}getBounds(){const t=.5*this.width,i=.5*this.height,r=[new e.P(0,0),new e.P(t,0),new e.P(this.width,0),new e.P(this.width,i),new e.P(this.width,this.height),new e.P(t,this.height),new e.P(0,this.height),new e.P(0,i)],n=[];for(const t of r)n.push(this.unprojectScreenPoint(t));let o=0,s=0,a=0,l=0;const c=this.center;for(const t of n){const i=e.bq(c.lng,t.lng),r=e.bq(c.lat,t.lat);i<s&&(s=i),i>o&&(o=i),r<l&&(l=r),r>a&&(a=r)}const h=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new xt(h)}getConstrained(t,i){const r=e.K(t.lat,-85.051129,e.au),n=e.K(+i,this.minZoom+ci(0,r),this.maxZoom);return{center:new e.a8(t.lng,r),zoom:n}}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,i){const r=oi(this.unprojectScreenPoint(i)),n=oi(t),o=e.bh();e.br(o);const s=e.bh();e.bn(s,r,o,-this.center.lng*Math.PI/180),e.bm(s,s,o,this.center.lat*Math.PI/180);const a=n[0]*n[0]+n[2]*n[2],l=s[0]*s[0];if(a<l)return;const c=Math.sqrt(a-l),h=-c,u=e.bs(n[0],n[2],s[0],c),d=e.bs(n[0],n[2],s[0],h),p=e.bh();e.bn(p,n,o,-u);const f=e.bs(p[1],p[2],s[1],s[2]),m=e.bh();e.bn(m,n,o,-d);const g=e.bs(m[1],m[2],s[1],s[2]),_=.5*Math.PI,y=f>=-_&&f<=_,x=g>=-_&&g<=_;let v,b;if(y&&x){const t=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;e.bv(u,t)+e.bv(f,i)<e.bv(d,t)+e.bv(g,i)?(v=u,b=f):(v=d,b=g)}else if(y)v=u,b=f;else{if(!x)return;v=d,b=g}const w=v/Math.PI*180,T=b/Math.PI*180,P=this.center.lat;this.setCenter(new e.a8(w,e.K(T,-90,90))),this.setZoom(this.zoom+ci(P,this.center.lat))}locationToScreenPoint(t,i){const r=oi(t);if(i){const n=i.getElevationForLngLatZoom(t,this._helper._tileZoom);e.aO(r,r,1+n/e.bu)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){const i=e.bk();return e.Z(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new e.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(e)return e}return e.ag.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(t,e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(t){const i=e.bk();i[0]=t.x/this.width*2-1,i[1]=-1*(t.y/this.height*2-1),i[2]=1,i[3]=1,e.Z(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const r=e.bh();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];const n=e.bh();return e.aT(n,r),n}isSurfacePointVisible(t){const e=this._cachedClippingPlane;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const i=e.bk();return e.Z(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(t,i){const r=e.aV(t,i),n=e.bh(),o=e.bh();e.aO(o,i,r),e.aS(n,t,o);const s=1-e.aV(n,n);if(s<0)return null;const a=e.aV(t,t)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=a/l,h=l;return{tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(t){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),n=this.rayPlanetIntersection(i,r);if(n){const t=e.bh();e.aP(t,i,[r[0]*n.tMin,r[1]*n.tMin,r[2]*n.tMin]);const o=e.bh();return e.aT(o,t),ai(o)}const o=this._cachedClippingPlane,s=o[0]*r[0]+o[1]*r[1]+o[2]*r[2],a=-e.bt(o,i)/s,l=e.bh();if(a>0)e.aP(l,i,[r[0]*a,r[1]*a,r[2]*a]);else{const t=e.bh();e.aP(t,i,[2*r[0],2*r[1],2*r[2]]);const n=e.bt(this._cachedClippingPlane,t);e.aS(l,t,[this._cachedClippingPlane[0]*n,this._cachedClippingPlane[1]*n,this._cachedClippingPlane[2]*n])}const c=function(t){const i=e.bh();return i[0]=t[0]*-t[3],i[1]=t[1]*-t[3],i[2]=t[2]*-t[3],{center:i,radius:Math.sqrt(1-t[3]*t[3])}}(o);return ai(function(t,i,r){const n=e.bh();e.aS(n,r,t);const o=e.bh();return e.bi(o,t,n,i/e.bj(n)),o}(c.center,c.radius,l))}getMatrixForModel(t,i){const r=e.a8.convert(t),n=1/e.bu,o=e.b1();return e.bp(o,o,r.lng/180*Math.PI),e.a$(o,o,-r.lat/180*Math.PI),e.a3(o,o,[0,0,1+i/e.bu]),e.a$(o,o,.5*Math.PI),e.M(o,o,[n,n,n]),o}getProjectionDataForCustomLayer(t=!0){const i=this.getProjectionData({overscaledTileID:new e.ae(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}}class yi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t,e){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)}),this._globeness=1,this._mercatorTransform=new Be,this._verticalPerspectiveTransform=new _i}clone(){const t=new yi;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this),t}apply(t){this._helper.apply(t),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const e=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:e.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:e.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return e.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return e.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){const n=this._mercatorTransform.getPitchedTextCorrection(t,i,r),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r);return e.bc(n,o,this._globeness)}projectTileCoordinates(t,e,i,r){return this.currentTransform.projectTileCoordinates(t,e,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}getConstrained(t,e){return this.currentTransform.getConstrained(t,e)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(t,e),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,e){return this.currentTransform.getMatrixForModel(t,e)}getProjectionDataForCustomLayer(t=!0){const e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class xi{get useGlobeControls(){return!0}handlePanInertia(t,i){const r=hi(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new e.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){const r=t.around,n=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);const o=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=e.bq(i.center.lng,n.lng),l=a/(Math.abs(a/180)+1),c=e.bq(i.center.lat,n.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*e.aV(u,h),p=e.bh();e.aP(p,u,[h[0]*d,h[1]*d,h[2]*d]);const f=e.bo(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=si(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=e.bf(g,.9,.5,1,.25),y=(1-e.at(-s))*Math.min(m,_),x=i.center.lat,v=i.zoom,b=new e.a8(i.center.lng+l*y,e.K(i.center.lat+c*y,-85.051129,e.au));i.setLocationAtPoint(n,r);const w=i.center,T=e.bf(Math.abs(a),45,85,0,1),P=e.bf(g,.75,.35,0,1),M=Math.pow(Math.max(T,P),.25),S=e.bq(w.lng,b.lng),C=e.bq(w.lat,b.lat);i.setCenter(new e.a8(w.lng+S*M,w.lat+C*M).wrap()),i.setZoom(v+ci(x,i.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;const r=e.center.lat,n=e.zoom;e.setCenter(hi(t.panDelta,e).wrap()),e.setZoom(n+ci(r,e.center.lat))}cameraForBoxAndBearing(t,i,r,n,o){const s=Ne(t,i,r,n,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,h=(o.height-i.bottom)/o.height*-2+1,u=e.bq(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),p=u?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+.5*e.bq(d,p),_=f+.5*e.bq(f,m),y=o.clone();y.setCenter(s.center),y.setBearing(s.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(s.zoom);const x=y.modelViewProjectionMatrix,v=[oi(r.getNorthWest()),oi(r.getNorthEast()),oi(r.getSouthWest()),oi(r.getSouthEast()),oi(new e.a8(p,_)),oi(new e.a8(d,_)),oi(new e.a8(g,f)),oi(new e.a8(g,m))],b=oi(s.center);let w=Number.POSITIVE_INFINITY;for(const t of v)a<0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"x",a))),l>0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"x",l))),c>0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"y",c))),h<0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=y.zoom+e.aw(w),s;Oe()}handleJumpToCenterZoom(t,i){const r=t.center.lat,n=t.getConstrained(i.center?e.a8.convert(i.center):t.center,t.zoom).center;t.setCenter(n.wrap());const o=void 0!==i.zoom?+i.zoom:t.zoom+ci(r,n.lat);t.zoom!==o&&t.setZoom(o)}handleEaseTo(t,i){const r=t.zoom,n=t.center,o=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},a={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},l=void 0!==i.zoom,c=!t.isPaddingEqual(i.padding);let h=!1;const u=i.center?e.a8.convert(i.center):n,d=t.getConstrained(u,r).center;ke(t,d);const p=t.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+ci(n.lat,u.lat)),p.setBearing(i.bearing);const f=new e.P(e.K(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.K(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+ci(n.lat,m.lat),_=r+ci(n.lat,0),y=g+ci(m.lat,0),x=e.bq(n.lng,m.lng),v=e.bq(n.lat,m.lat),b=e.at(y-_);return h=g!==r,{easeFunc:r=>{if(e.b6(s,a)||je({startEulerAngles:s,endEulerAngles:a,tr:t,k:r,useSlerp:s.roll!=a.roll}),c&&t.interpolatePadding(o,i.padding,r),i.around)e.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{const e=y>_?Math.min(2,b):Math.max(.5,b),i=Math.pow(e,1-r),o=di(n,x,v,r*i);t.setCenter(o.wrap())}if(h){const i=e.B.number(_,y,r)+ci(0,t.center.lat);t.setZoom(i)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.center,o=t.zoom,s=t.padding,a=!t.isPaddingEqual(i.padding),l=t.getConstrained(e.a8.convert(i.center||i.locationAtOffset),o).center,c=r?+i.zoom:t.zoom+ci(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new e.P(e.K(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.K(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,u);const d=h.center;ke(t,d);const p=function(t,i,r){const n=oi(i),o=oi(r),s=e.aV(n,o),a=Math.acos(s),l=ri(t);return a/(2*Math.PI)*l}(t,n,d),f=o+ci(n.lat,0),m=c+ci(d.lat,0),g=e.at(m-f);let _;if("number"==typeof i.minZoom){const r=+i.minZoom+ci(d.lat,0),n=Math.min(r,f,m)+ci(0,d.lat),o=t.getConstrained(d,n).zoom+ci(d.lat,0);_=e.at(o-f)}const y=e.bq(n.lng,d.lng),x=e.bq(n.lat,d.lat);return{easeFunc:(r,o,l,h)=>{const u=di(n,y,x,l);a&&t.interpolatePadding(s,i.padding,r);const p=1===r?d:u;t.setCenter(p.wrap());const m=f+e.aw(o);t.setZoom(1===r?c:m+ci(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(t,e,i,r,n){const o="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],l=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],h=e[0]*s[0]+e[1]*s[1]+e[2]*s[2];return c+n*l===a+n*h||s[3]*(a-c)+o[3]*(h-l)+a*h==c*l?null:(c+o[3]-n*h-n*s[3])/(c-a-n*h+n*l)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}}class vi{constructor(t){this._globe=t,this._mercatorCameraHelper=new Ve,this._verticalPerspectiveCameraHelper=new xi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,e){return this.currentHelper.handlePanInertia(t,e)}handleMapControlsRollPitchBearingZoom(t,e){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,e)}handleMapControlsPan(t,e,i){this.currentHelper.handleMapControlsPan(t,e,i)}cameraForBoxAndBearing(t,e,i,r,n){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,n)}handleJumpToCenterZoom(t,e){this.currentHelper.handleJumpToCenterZoom(t,e)}handleEaseTo(t,e){return this.currentHelper.handleEaseTo(t,e)}handleFlyTo(t,e){return this.currentHelper.handleFlyTo(t,e)}}const bi=(t,i)=>e.x(t,i&&i.filter((t=>"source.canvas"!==t.identifier))),wi=e.bw();class Ti extends e.E{constructor(t,i={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload()}},this.map=t,this.dispatcher=new O(B(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new M(t._requestManager,i.localIdeographFontFamily),this.lineAtlas=new k(256,512),this.crossTileSymbolIndex=new be,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.bx,this._loaded=!1,this._availableImages=[],this._labelFreeAreas=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.by()),Lt().on(Et,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const n=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;e.j(n,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,i,r)})).catch((t=>{this._loadStyleRequest=null,t&&!o.signal.aborted&&this.fire(new e.k(t))}))}loadJSON(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,r)})).catch((()=>{}))}loadEmpty(){this.fire(new e.l("dataloading",{dataType:"style"})),this._load(wi,{validate:!1})}_load(t,i,r){var n,o;const s=i.transformStyle?i.transformStyle(r,t):t;if(!i.validate||!bi(this,e.y(s))){this._loaded=!0,this.stylesheet=s;for(const t in s.sources)this.addSource(t,s.sources[t],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(n=this.stylesheet.projection)||void 0===n?void 0:n.type)||"mercator"),this.sky=new E(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new e.l("data",{dataType:"style"})),this.fire(new e.l("style.load"))}}_createLayers(){const t=e.bz(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const i of t){const t=e.bA(i);t.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=t}}_loadSprite(t,i=!1,r=void 0){let n;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,y(t,this.map._requestManager,this.map.getPixelRatio()*this.map.getScale(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const r=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of r)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const r in t[e]){const n="default"===e?r:`${e}:${r}`;this._spritesImagesIds[e].push(n),n in this.imageManager.images?this.imageManager.updateImage(n,t[e][r],!1):this.imageManager.addImage(n,t[e][r]),i&&(this._changedImages[n]=!0)}}})).catch((t=>{this._spriteRequest=null,n=t,this.fire(new e.k(n))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"})),r&&r(n)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}_validateLayer(t){const i=this.sourceCaches[t.source];if(!i)return;const r=t.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.k(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(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,i=!1){const r=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?e.bB(r):r);const n=[];for(const o of t)if(r[o]){const t=i?e.bB(r[o]):r[o];n.push(t)}return n}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){var t,e,i;if(null===(t=this.light)||void 0===t?void 0:t.hasTransition())return!0;if(null===(e=this.sky)||void 0===e?void 0:e.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.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 i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const r={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];r[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in r){const i=this.sourceCaches[t];!!r[t]!=!!i.used&&i.fire(new e.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,i&&this.fire(new e.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].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,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){var r;this._checkLoaded();const n=this.serialize();if(t=i.transformStyle?i.transformStyle(n,t):t,(null===(r=i.validate)||void 0===r||r)&&bi(this,e.y(t)))return!1;(t=e.bB(t)).layers=e.bz(t.layers);const o=e.bC(n,t),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const t of s.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],i=[];for(const r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setTransition":e.push((()=>{}));break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}addImages(t){for(const e in t)this.getImage(e)&&this.imageManager.removeImage(e),this.imageManager.addImage(e,t[e]),this._changedImages[e]=!0;return this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"})),this}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.y.source,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.sourceCaches[t]=new Xt(t,i,this.dispatcher);n.style=this,n.setEventedParent(this,(()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:t}))),n.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.k(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],i.fire(new e.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this.getLayer(n))return void this.fire(new e.k(new Error(`Layer "${n}" already exists on this map.`)));let o;if("custom"===t.type){if(bi(this,e.bD(t)))return;o=e.bA(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(n,t.source),t=e.bB(t),t=e.e(t,{source:n})),this._validate(e.y.layer,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.bA(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new e.k(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o,this._removedLayers[n]&&o.source&&"custom"!==o.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new e.k(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(n,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.k(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}setLayersOrder(t){this._checkLoaded(),this._order=t.filter((t=>void 0!==this._layers[t])),this._layerOrderChanged=!0}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,r){this._checkLoaded();const n=this.getLayer(t);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new e.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,i,r={}){this._checkLoaded();const n=this.getLayer(t);if(n){if(!e.bE(n.filter,i))return null==i?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(e.y.filter,`layers.${n.id}.filter`,i,null,r)||(n.filter=e.bB(i),this._updateLayer(n)))}else this.fire(new e.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.bB(this.getLayer(t).filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const o=this.getLayer(t);o?e.bE(o.getLayoutProperty(i),r)||(o.setLayoutProperty(i,r,n),this._updateLayer(o)):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,i){const r=this.getLayer(t);if(r)return r.getLayoutProperty(i);this.fire(new e.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,r,n={}){this._checkLoaded();const o=this.getLayer(t);o?e.bE(o.getPaintProperty(i),r)||(o.setPaintProperty(i,r,n)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&n?this.fire(new e.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||n?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(n,t.id,i)):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this.sourceCaches[r];if(void 0===n)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.getSource().type,s="vector"===o?t.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.k(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(s,t.id,i):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.sourceCaches[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,t.id)):void this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.bF(this.sourceCaches,(t=>t.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,n=this.stylesheet;return e.bG({version:n.version,name:n.name,metadata:n.metadata,light:n.light,sky:n.sky,center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,sprite:n.sprite,glyphs:n.glyphs,transition:n.transition,projection:n.projection,sources:t,layers:i,terrain:r},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(e(o)){i[o]=n;for(const e of t){const t=e[o];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(e(s))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<o)break;n.push(e),r.pop()}else for(const e of t){const t=e[s];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(t,i,r){i&&i.filter&&this._validate(e.y.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new e.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:a});for(const e in this.sourceCaches)i.layers&&!n[e]||o.push(pt(this.sourceCaches[e],this._layers,s,t,l,r,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));return this.placement&&o.push(function(t,e,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(ft);for(const r of c){const o=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],e,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const e in o){const n=a[e]=a[e]||[],s=o[e];s.sort(((t,e)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(t.featureIndex);return i.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const o of s)n.push(o),gt(i[t[e].source],r,o)}}return function(t,e,i){for(const r in t)for(const n of t[r])mt(n,i[e[r].source]);return t}(a,t,i)}(this._layers,s,this.sourceCaches,t,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[t];return r?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const o=i[t],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,e))}return r}(r,i):[]}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.bE(t[i],r[i])){n=!0;break}if(!n)return;const o={now:s.now(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(o)}getProjection(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.sky}setSky(t,i={}){this._checkLoaded();const r=this.getSky();let n=!1;if(!t&&!r)return;if(t&&!r)n=!0;else if(!t&&r)n=!0;else for(const i in t)if(!e.bE(t[i],r[i])){n=!0;break}if(!n)return;const o={now:s.now(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,i),this.sky.updateTransitions(o)}_setProjectionInternal(t){const i=function(t){if(Array.isArray(t)){const e=new ii({type:t});return{projection:e,transform:new yi,cameraHelper:new vi(e)}}switch(t){case"mercator":return{projection:new Ae,transform:new Be,cameraHelper:new Ve};case"globe":{const t=new ii({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:t,transform:new yi,cameraHelper:new vi(t)}}case"vertical-perspective":return{projection:new ti,transform:new _i,cameraHelper:new xi};default:return e.w(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Ae,transform:new Be,cameraHelper:new Ve}}}(t);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const t in this.sourceCaches)this.sourceCaches[t].reload()}_validate(t,i,r,n,o={}){return(!o||!1!==o.validate)&&bi(this,t.call(e.y,e.e({key:i,style:this.serialize(),value:r,styleSpec:e.v},n)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Lt().off(Et,this._rtlPluginLoaded);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,e,i,r,n=!1){let o=!1,a=!1;const l={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this.sourceCaches[i.source];l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((n=n||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),t.zoom))&&(this.pauseablePlacement=new ge(t,this.map.terrain,this._order,n,e,i,r,this.placement,this._labelFreeAreas,this.map.getScale()),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t}))}getGlyphs(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.y.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,i,r={},n){this._checkLoaded();const o=[{id:t,url:i}],s=[...g(this.stylesheet.sprite),...o];this._validate(e.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,n))}removeSprite(t){this._checkLoaded();const i=g(this.stylesheet.sprite);if(i.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}else this.fire(new e.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(t,i={},r){this._checkLoaded(),t&&this._validate(e.y.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}setLabelFreeAreas(t){return!e.bH(t,this._labelFreeAreas)&&(this._labelFreeAreas=t,!0)}}var Pi=e.aG([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Mi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,o,s,a,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,r,n,o,s,a,l):(t.bindVertexArray.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind())}freshBind(t,e,i,r,n,o,s,a){const l=t.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a,e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);o&&o.enableAttributes(h,t),s&&s.enableAttributes(h,t),a&&a.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),a&&(a.bind(),a.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Si=(t,i,r,n,o)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):e.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:r?r.calculateFogBlendOpacity(n):0,u_horizon_color:r?r.properties.get("horizon-color"):e.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Ci={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ii(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class Ai{constructor(t,i,r,n,o,s,a,l){const c=t.gl;this.program=c.createProgram();const h=Ii(i.staticAttributes),u=r?r.getBinderAttributes():[],d=h.concat(u),p=Te.prelude.staticUniforms?Ii(Te.prelude.staticUniforms):[],f=a.staticUniforms?Ii(a.staticUniforms):[],m=i.staticUniforms?Ii(i.staticUniforms):[],g=r?r.getBinderUniforms():[],_=p.concat(f).concat(m).concat(g),y=[];for(const t of _)y.indexOf(t)<0&&y.push(t);const x=r?r.defines():[];Xe(c)&&x.unshift("#version 300 es"),o&&x.push("#define OVERDRAW_INSPECTOR;"),s&&x.push("#define TERRAIN3D;"),l&&x.push(l);let v=x.concat(Te.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),b=x.concat(Te.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");Xe(c)||(v=function(t){return t.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(v),b=function(t){return t.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(b));const w=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(w,v),c.compileShader(w),!c.getShaderParameter(w,c.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${c.getShaderInfoLog(w)}`);c.attachShader(this.program,w);const T=c.createShader(c.VERTEX_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(T,b),c.compileShader(T),!c.getShaderParameter(T,c.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${c.getShaderInfoLog(T)}`);c.attachShader(this.program,T),this.attributes={};const P={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(c.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(c.linkProgram(this.program),!c.getProgramParameter(this.program,c.LINK_STATUS))throw new Error(`Program failed to link: ${c.getProgramInfoLog(this.program)}`);c.deleteShader(T),c.deleteShader(w);for(let t=0;t<y.length;t++){const e=y[t];if(e&&!P[e]){const t=c.getUniformLocation(this.program,e);t&&(P[e]=t)}}this.fixedUniforms=n(t,P),this.terrainUniforms=((t,i)=>({u_depth:new e.bI(t,i.u_depth),u_terrain:new e.bI(t,i.u_terrain),u_terrain_dim:new e.b8(t,i.u_terrain_dim),u_terrain_matrix:new e.bK(t,i.u_terrain_matrix),u_terrain_unpack:new e.bL(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.b8(t,i.u_terrain_exaggeration)}))(t,P),this.projectionUniforms=((t,i)=>({u_projection_matrix:new e.bK(t,i.u_projection_matrix),u_projection_tile_mercator_coords:new e.bL(t,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new e.bL(t,i.u_projection_clipping_plane),u_projection_transition:new e.b8(t,i.u_projection_transition),u_projection_fallback_matrix:new e.bK(t,i.u_projection_fallback_matrix)}))(t,P),this.binderUniforms=r?r.getUniforms(t,P):[]}draw(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y){const x=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(o),a){t.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,a.depthTexture),t.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,a.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(a[t])}if(l)for(const t in l)this.projectionUniforms[Ci[t]].set(l[t]);if(s)for(const t in this.fixedUniforms)this.fixedUniforms[t].set(s[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:f});let v=0;switch(e){case x.LINES:v=2;break;case x.TRIANGLES:v=3;break;case x.LINE_STRIP:v=1}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new Mi)).bind(t,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,g,_,y),x.drawElements(e,i.primitiveLength*v,x.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Ei(t,i,r){const n=1/e.az(r,1,i.transform.tileZoom,i.transform.detailLevel),o=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(r.tileID.canonical.x+r.tileID.wrap*o),l=s*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[n,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const ki=(t,i,r,n)=>{const o=t.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=e.bO();"viewport"===o.properties.get("anchor")&&e.bP(l,t.transform.bearingInRadians),e.bQ(a,a,l);const c=t.transform.transformLightDirection(a),h=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},zi=(t,i,r,n,o,s,a)=>e.e(ki(t,i,r,n),Ei(s,t,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Li=(t,i,r,n)=>e.e(Ei(i,t,r),{u_fill_translate:n}),Di=(t,e)=>({u_world:t,u_fill_translate:e}),Ri=(t,i,r,n,o)=>e.e(Li(t,i,r,o),{u_world:n}),Fi=(t,i,r,n,o)=>{const s=t.transform;let a,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const t=e.az(i,1,s.zoom,s.detailLevel);a=!0,l=[t,t],c=t/(e.af*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:n}},Bi=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Oi=t=>({u_viewport_size:[t.width,t.height]}),ji=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Ni=(t,i,r,n,o)=>{const s=e.az(t,1,i,r)/(e.af*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:e.az(t,1,i,r),u_intensity:n,u_globe_extrude_scale:s}},Vi=(t,i,r,n)=>{const o=e.L();e.bR(o,0,t.width,t.height,0,0,1);const s=t.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:n,u_opacity:i.paint.get("heatmap-opacity")}},Ui=(t,e,i)=>{const r=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),o=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s+=t.transform.bearingInRadians),{u_image:0,u_latrange:$i(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:r,u_highlight:n,u_accent:o}},Zi=(t,i)=>{const r=i.stride,n=e.L();return e.bR(n,0,e.af,-8192,0,0,1),e.a3(n,n,[0,-8192,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}};function $i(t,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new e.ag(0,n/r).toLngLat().lat,new e.ag(0,(n+1)/r).toLngLat().lat]}const Gi=(t,i,r,n)=>{const o=t.transform;return{u_translation:Ki(t,i,r),u_ratio:n/e.az(i,1,o.zoom,o.detailLevel),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},qi=(t,i,r,n,o)=>e.e(Gi(t,i,r,n),{u_image:0,u_image_height:o}),Wi=(t,i,r,n,o)=>{const s=t.transform,a=Xi(i,s);return{u_translation:Ki(t,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:n/e.az(i,1,s.zoom,s.detailLevel),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Hi=(t,i,r,n,o,s)=>{const a=t.lineAtlas,l=Xi(i,t.transform),c="round"===r.layout.get("line-cap"),h=a.getDash(o.from,c),u=a.getDash(o.to,c),d=h.width*s.fromScale,p=u.width*s.toScale;return e.e(Gi(t,i,r,n),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/p,-u.height/2],u_sdfgamma:a.width/(256*Math.min(d,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Xi(t,i){return 1/e.az(t,1,i.tileZoom,i.detailLevel)}function Ki(t,i,r){return e.aA(t.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Yi=(t,e,i,r,n)=>{return{u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=r.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Ji(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var o,s};function Ji(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Qi=(t,e,i,r,n,o,s,a,l,c,h,u,d)=>{const p=s.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:o,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},tr=(t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>{const m=a.transform;return e.e(Qi(t,i,r,n,o,s,a,l,c,h,u,d,f),{u_gamma_scale:n?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},er=(t,i,r,n,o,s,a,l,c,h,u,d,p)=>e.e(tr(t,i,r,n,o,s,a,l,c,h,!0,u,0,p),{u_texsize_icon:d,u_texture_icon:1}),ir=(t,e)=>({u_opacity:t,u_color:e}),rr=(t,i,r,n,o)=>e.e(function(t,i,r,n){const o=r.imageManager.getPattern(t.from.toString()),s=r.imageManager.getPattern(t.to.toString()),{width:a,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,n.tileID.overscaledZ),h=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(n.tileID.canonical.x+n.tileID.wrap*c),d=h*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/e.az(n,1,r.transform.tileZoom,r.transform.detailLevel),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,o,i,n),{u_opacity:t}),nr=(t,e)=>{},or={fillExtrusion:(t,i)=>({u_lightpos:new e.bM(t,i.u_lightpos),u_lightpos_globe:new e.bM(t,i.u_lightpos_globe),u_lightintensity:new e.b8(t,i.u_lightintensity),u_lightcolor:new e.bM(t,i.u_lightcolor),u_vertical_gradient:new e.b8(t,i.u_vertical_gradient),u_opacity:new e.b8(t,i.u_opacity),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillExtrusionPattern:(t,i)=>({u_lightpos:new e.bM(t,i.u_lightpos),u_lightpos_globe:new e.bM(t,i.u_lightpos_globe),u_lightintensity:new e.b8(t,i.u_lightintensity),u_lightcolor:new e.bM(t,i.u_lightcolor),u_vertical_gradient:new e.b8(t,i.u_vertical_gradient),u_height_factor:new e.b8(t,i.u_height_factor),u_opacity:new e.b8(t,i.u_opacity),u_fill_translate:new e.bN(t,i.u_fill_translate),u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade)}),fill:(t,i)=>({u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillPattern:(t,i)=>({u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillOutline:(t,i)=>({u_world:new e.bN(t,i.u_world),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillOutlinePattern:(t,i)=>({u_world:new e.bN(t,i.u_world),u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade),u_fill_translate:new e.bN(t,i.u_fill_translate)}),circle:(t,i)=>({u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_scale_with_map:new e.bI(t,i.u_scale_with_map),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_extrude_scale:new e.bN(t,i.u_extrude_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_globe_extrude_scale:new e.b8(t,i.u_globe_extrude_scale),u_translate:new e.bN(t,i.u_translate)}),collisionBox:(t,i)=>({u_pixel_extrude_scale:new e.bN(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_viewport_size:new e.bN(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.bJ(t,i.u_color),u_overlay:new e.bI(t,i.u_overlay),u_overlay_scale:new e.b8(t,i.u_overlay_scale)}),depth:nr,clippingMask:nr,heatmap:(t,i)=>({u_extrude_scale:new e.b8(t,i.u_extrude_scale),u_intensity:new e.b8(t,i.u_intensity),u_globe_extrude_scale:new e.b8(t,i.u_globe_extrude_scale)}),heatmapTexture:(t,i)=>({u_matrix:new e.bK(t,i.u_matrix),u_world:new e.bN(t,i.u_world),u_image:new e.bI(t,i.u_image),u_color_ramp:new e.bI(t,i.u_color_ramp),u_opacity:new e.b8(t,i.u_opacity)}),hillshade:(t,i)=>({u_image:new e.bI(t,i.u_image),u_latrange:new e.bN(t,i.u_latrange),u_light:new e.bN(t,i.u_light),u_shadow:new e.bJ(t,i.u_shadow),u_highlight:new e.bJ(t,i.u_highlight),u_accent:new e.bJ(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.bK(t,i.u_matrix),u_image:new e.bI(t,i.u_image),u_dimension:new e.bN(t,i.u_dimension),u_zoom:new e.b8(t,i.u_zoom),u_unpack:new e.bL(t,i.u_unpack)}),line:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_image:new e.bI(t,i.u_image),u_image_height:new e.b8(t,i.u_image_height)}),linePattern:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_texsize:new e.bN(t,i.u_texsize),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_image:new e.bI(t,i.u_image),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade)}),lineSDF:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_patternscale_a:new e.bN(t,i.u_patternscale_a),u_patternscale_b:new e.bN(t,i.u_patternscale_b),u_sdfgamma:new e.b8(t,i.u_sdfgamma),u_image:new e.bI(t,i.u_image),u_tex_y_a:new e.b8(t,i.u_tex_y_a),u_tex_y_b:new e.b8(t,i.u_tex_y_b),u_mix:new e.b8(t,i.u_mix)}),raster:(t,i)=>({u_tl_parent:new e.bN(t,i.u_tl_parent),u_scale_parent:new e.b8(t,i.u_scale_parent),u_buffer_scale:new e.b8(t,i.u_buffer_scale),u_fade_t:new e.b8(t,i.u_fade_t),u_opacity:new e.b8(t,i.u_opacity),u_image0:new e.bI(t,i.u_image0),u_image1:new e.bI(t,i.u_image1),u_brightness_low:new e.b8(t,i.u_brightness_low),u_brightness_high:new e.b8(t,i.u_brightness_high),u_saturation_factor:new e.b8(t,i.u_saturation_factor),u_contrast_factor:new e.b8(t,i.u_contrast_factor),u_spin_weights:new e.bM(t,i.u_spin_weights),u_coords_top:new e.bL(t,i.u_coords_top),u_coords_bottom:new e.bL(t,i.u_coords_bottom)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texture:new e.bI(t,i.u_texture),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texture:new e.bI(t,i.u_texture),u_gamma_scale:new e.b8(t,i.u_gamma_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_is_halo:new e.bI(t,i.u_is_halo),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texsize_icon:new e.bN(t,i.u_texsize_icon),u_texture:new e.bI(t,i.u_texture),u_texture_icon:new e.bI(t,i.u_texture_icon),u_gamma_scale:new e.b8(t,i.u_gamma_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_is_halo:new e.bI(t,i.u_is_halo),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),background:(t,i)=>({u_opacity:new e.b8(t,i.u_opacity),u_color:new e.bJ(t,i.u_color)}),backgroundPattern:(t,i)=>({u_opacity:new e.b8(t,i.u_opacity),u_image:new e.bI(t,i.u_image),u_pattern_tl_a:new e.bN(t,i.u_pattern_tl_a),u_pattern_br_a:new e.bN(t,i.u_pattern_br_a),u_pattern_tl_b:new e.bN(t,i.u_pattern_tl_b),u_pattern_br_b:new e.bN(t,i.u_pattern_br_b),u_texsize:new e.bN(t,i.u_texsize),u_mix:new e.b8(t,i.u_mix),u_pattern_size_a:new e.bN(t,i.u_pattern_size_a),u_pattern_size_b:new e.bN(t,i.u_pattern_size_b),u_scale_a:new e.b8(t,i.u_scale_a),u_scale_b:new e.b8(t,i.u_scale_b),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.b8(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_texture:new e.bI(t,i.u_texture),u_ele_delta:new e.b8(t,i.u_ele_delta),u_fog_matrix:new e.bK(t,i.u_fog_matrix),u_fog_color:new e.bJ(t,i.u_fog_color),u_fog_ground_blend:new e.b8(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.b8(t,i.u_fog_ground_blend_opacity),u_horizon_color:new e.bJ(t,i.u_horizon_color),u_horizon_fog_blend:new e.b8(t,i.u_horizon_fog_blend),u_is_globe_mode:new e.b8(t,i.u_is_globe_mode)}),terrainDepth:(t,i)=>({u_ele_delta:new e.b8(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_texture:new e.bI(t,i.u_texture),u_terrain_coords_id:new e.b8(t,i.u_terrain_coords_id),u_ele_delta:new e.b8(t,i.u_ele_delta)}),projectionErrorMeasurement:(t,i)=>({u_input:new e.b8(t,i.u_input),u_output_expected:new e.b8(t,i.u_output_expected)}),atmosphere:(t,i)=>({u_sun_pos:new e.bM(t,i.u_sun_pos),u_atmosphere_blend:new e.b8(t,i.u_atmosphere_blend),u_globe_position:new e.bM(t,i.u_globe_position),u_globe_radius:new e.b8(t,i.u_globe_radius),u_inv_proj_matrix:new e.bK(t,i.u_inv_proj_matrix)}),sky:(t,i)=>({u_sky_color:new e.bJ(t,i.u_sky_color),u_horizon_color:new e.bJ(t,i.u_horizon_color),u_horizon:new e.bN(t,i.u_horizon),u_horizon_normal:new e.bN(t,i.u_horizon_normal),u_sky_horizon_blend:new e.b8(t,i.u_sky_horizon_blend),u_sky_blend:new e.b8(t,i.u_sky_blend)})};class sr{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ar={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class lr{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.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 e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=e.attributes[n.name];void 0!==o&&t.vertexAttribPointer(o,n.components,t[ar[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class cr{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 hr extends cr{getDefault(){return e.b7.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class ur extends cr{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class dr extends cr{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class pr extends cr{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class fr extends cr{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class mr extends cr{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class gr extends cr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class _r extends cr{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class yr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class xr extends cr{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class vr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class br extends cr{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class wr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Tr extends cr{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Pr extends cr{getDefault(){return e.b7.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Mr extends cr{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Sr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Cr extends cr{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Ir extends cr{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Ar extends cr{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Er extends cr{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class kr extends cr{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class zr extends cr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Lr extends cr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Dr extends cr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Rr extends cr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Fr extends cr{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Br extends cr{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;const i=this.gl;Xe(i)?i.bindVertexArray(t):null===(e=i.getExtension("OES_vertex_array_object"))||void 0===e||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Or extends cr{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class jr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Nr extends cr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Vr extends cr{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class Ur extends Vr{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Zr extends Vr{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class $r extends Vr{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const Gr="Framebuffer is not complete";class qr{constructor(t,e,i,r,n){this.context=t,this.width=e,this.height=i;const o=t.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new Ur(t,s),r)this.depthAttachment=n?new $r(t,s):new Zr(t,s);else if(n)throw new Error("Stencil cannot be set without depth");if(o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE)throw new Error(Gr)}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class Wr{constructor(t){var e,i;if(this.gl=t,this.clearColor=new hr(this),this.clearDepth=new ur(this),this.clearStencil=new dr(this),this.colorMask=new pr(this),this.depthMask=new fr(this),this.stencilMask=new mr(this),this.stencilFunc=new gr(this),this.stencilOp=new _r(this),this.stencilTest=new yr(this),this.depthRange=new xr(this),this.depthTest=new vr(this),this.depthFunc=new br(this),this.blend=new wr(this),this.blendFunc=new Tr(this),this.blendColor=new Pr(this),this.blendEquation=new Mr(this),this.cullFace=new Sr(this),this.cullFaceSide=new Cr(this),this.frontFace=new Ir(this),this.program=new Ar(this),this.activeTexture=new Er(this),this.viewport=new kr(this),this.bindFramebuffer=new zr(this),this.bindRenderbuffer=new Lr(this),this.bindTexture=new Dr(this),this.bindVertexBuffer=new Rr(this),this.bindElementBuffer=new Fr(this),this.bindVertexArray=new Br(this),this.pixelStoreUnpack=new Or(this),this.pixelStoreUnpackPremultiplyAlpha=new jr(this),this.pixelStoreUnpackFlipY=new Nr(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),Xe(t)){this.HALF_FLOAT=t.HALF_FLOAT;const r=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(e=t.RGBA16F)&&void 0!==e?e:null==r?void 0:r.RGBA16F_EXT,this.RGB16F=null!==(i=t.RGB16F)&&void 0!==i?i:null==r?void 0:r.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.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,e){return new sr(this,t,e)}createVertexBuffer(t,e,i){return new lr(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i,r){return new qr(this,t,e,i,r)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?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){e.bE(t.blendFunction,Ue.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 Xe(this.gl)?this.gl.createVertexArray():null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;return Xe(this.gl)?this.gl.deleteVertexArray(t):null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let Hr;function Xr(t,i,r,n,o){const s=t.context,a=t.transform,l=s.gl,c=t.useProgram("collisionBox"),h=[];let u=0,d=0;for(let e=0;e<n.length;e++){const p=n[e],f=i.getTile(p).getBucket(r);if(!f)continue;const m=o?f.textCollisionBox:f.iconCollisionBox,g=f.collisionCircleArray;g.length>0&&(h.push({circleArray:g,circleOffset:d,coord:p}),u+=g.length/4,d=u),m&&c.draw(s,l.LINES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Bi(t.transform),t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!h.length)return;const p=t.useProgram("collisionCircle"),f=new e.bS;f.resize(4*u),f._trim();let m=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],o=t.circleArray[i+2],s=t.circleArray[i+3];f.emplace(m++,r,n,o,s,0),f.emplace(m++,r,n,o,s,1),f.emplace(m++,r,n,o,s,2),f.emplace(m++,r,n,o,s,3)}(!Hr||Hr.length<2*u)&&(Hr=function(t){const i=2*t,r=new e.bU;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(u));const g=s.createIndexBuffer(Hr,!0),_=s.createVertexBuffer(f,e.bT.members,!0);for(const i of h){const n=Oi(t.transform);p.draw(s,l.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,n,t.style.map.terrain&&t.style.map.terrain.getTerrainData(i.coord),null,r.id,_,g,e.aJ.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}_.destroy(),g.destroy()}const Kr=e.a2(new Float32Array(16));function Yr(t,i,r,n,o,s){const{horizontalAlign:a,verticalAlign:l}=e.aE(t);return new e.P((-(a-.5)*i/o+n[0])*s,(-(l-.5)*r/o+n[1])*s)}function Jr(t,i,r,n,o,s){const a=i.tileAnchorPoint.add(new e.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let t=n.mult(s);r||(t=t.rotate(-o));const e=a.add(t);return q(e.x,e.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(r){const e=et(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(t),r=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(n.rotate(r))}return t.add(n)}function Qr(t,i,r,n,o,s,a,l,c,h,u,d){const p=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,g={};f.clear();for(let m=0;m<p.length;m++){const _=p.get(m),y=_.hidden||!_.crossTileID||t.allowVerticalPlacement&&!_.placedOrientation?null:n[_.crossTileID];if(y){const n=new e.P(_.anchorX,_.anchorY),p={getElevation:d,width:o.width,height:o.height,pitchedLabelPlaneMatrix:s,pitchWithMap:r,transform:o,tileAnchorPoint:n,translation:h,unwrappedTileID:u},m=r?rt(n.x,n.y,p):et(n.x,n.y,p),x=W(o.cameraToCenterDistance,m.signedDistanceFromCamera);let v=e.O(t.textSizeData,l,_)*x/e.a5;r&&(v*=t.tilePixelRatio/a);const{width:b,height:w,anchor:T,textOffset:P,textBoxScale:M}=y,S=Yr(T,b,w,P,M,v),C=o.getPitchedTextCorrection(n.x+h[0],n.y+h[1],u),I=Jr(m.point,p,i,S,-o.bearingInRadians,C),A=t.allowVerticalPlacement&&_.placedOrientation===e.W.vertical?Math.PI/2:0;for(let t=0;t<_.numGlyphs;t++)e.Y(f,I,A);c&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:I,angle:A})}else lt(_.numGlyphs,f)}if(c){m.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const r=i.get(t);if(r.hidden)lt(r.numGlyphs,m);else{const i=g[t];if(i)for(let t=0;t<r.numGlyphs;t++)e.Y(m,i.shiftedAnchor,i.angle);else lt(r.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function tn(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function en(t,i,r,n,o,s,a,l,c,h,u,d,p){const f=t.context,m=f.gl,g=t.transform,_="map"===l,y="map"===c,x="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),v=_&&!y&&!x,b=!r.layout.get("symbol-sort-key").isConstant();let w=!1;const T=t.getDepthModeForSublayer(0,Ge.ReadOnly),P=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),M=[],S=g.getCircleRadiusCorrection();for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c)continue;const u=o?c.text:c.icon;if(!u||!u.segments.get().length||!u.hasVisibleVertices)continue;const d=u.programConfigurations.get(r.id),f=o||c.sdfIcons,T=o?c.textSizeData:c.iconSizeData,C=y||0!==g.pitch,I=t.useProgram(tn(f,o,c),d),A=e.N(T,g.zoom),E=t.style.map.terrain&&t.style.map.terrain.getTerrainData(l);let k,z,L,D,R=[0,0],F=null;o?(z=n.glyphAtlasTexture,L=m.LINEAR,k=n.glyphAtlasTexture.size,c.iconsInText&&(R=n.imageAtlasTexture.size,F=n.imageAtlasTexture,D=C||t.options.rotating||t.options.zooming||"composite"===T.kind||"camera"===T.kind?m.LINEAR:m.NEAREST)):(z=n.imageAtlasTexture,L=f||t.options.rotating||t.options.zooming||!g.rasterAlignment||c.iconsNeedLinear||C?m.LINEAR:m.NEAREST,k=n.imageAtlasTexture.size);const B=e.az(n,1,t.transform.zoom,t.transform.detailLevel),O=Z(_,t.transform,B),j=e.L();e.Q(j,O);const N=$(y,_,t.transform,B),V=e.aA(g,n,s,a),U=g.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),G=P&&c.hasTextData(),q="none"!==r.layout.get("icon-text-fit")&&G&&c.hasIconData();if(x){const e=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(l,e,i):null,i="map"===r.layout.get("text-rotation-alignment");X(c,t,o,O,j,y,h,i,l.toUnwrapped(),g.width,g.height,V,e)}const W=o&&P||q,H=x||W?Kr:y?O:t.transform.clipSpaceToPixelsMatrix,K=f&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let Y;Y=f?c.iconsInText?er(T.kind,A,v,y,x,W,t,H,N,V,k,R,S):tr(T.kind,A,v,y,x,W,t,H,N,V,o,k,0,S):Qi(T.kind,A,v,y,x,W,t,H,N,V,o,k,S);const J={program:I,buffers:u,uniformValues:Y,projectionData:U,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:L,atlasInterpolationIcon:D,isSDF:f,hasHalo:K};if(b&&c.canOverlap){w=!0;const t=u.segments.get();for(const i of t)M.push({segments:new e.aJ([i]),sortKey:i.sortKey,state:J,terrainData:E})}else M.push({segments:u.segments,sortKey:0,state:J,terrainData:E})}w&&M.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of M){const i=e.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,rn(i.buffers,e.segments,r,t,i.program,T,u,d,n,i.projectionData,e.terrainData)),n.u_is_halo=0}rn(i.buffers,e.segments,r,t,i.program,T,u,d,i.uniformValues,i.projectionData,e.terrainData)}}function rn(t,e,i,r,n,o,s,a,l,c,h){const u=r.context;n.draw(u,u.gl.TRIANGLES,o,s,a,$e.backCCW,l,h,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function nn(t,i,r,n,o){const s=t.context,a=s.gl,l=We.disabled,c=new Ue([a.ONE,a.ONE],e.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=n.key;let d=r.heatmapFbos.get(u);d||(d=sn(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:e.b7.transparent});const p=h.programConfigurations.get(r.id),f=t.useProgram("heatmap",p,!o),m=t.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=t.style.map.terrain.getTerrainData(n);f.draw(s,a.TRIANGLES,Ge.disabled,l,c,$e.disabled,Ni(i,t.transform.zoom,t.transform.detailLevel,r.paint.get("heatmap-intensity"),1),g,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,t.transform.zoom,p)}function on(t,e,i,r,n){const o=t.context,s=o.gl,a=t.transform;o.setColorMode(t.colorModeForRenderPass());const l=an(o,e),c=i.key,h=e.heatmapFbos.get(c);if(!h)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});t.useProgram("heatmapTexture").draw(o,s.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Vi(t,e,0,1),null,u,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),h.destroy(),e.heatmapFbos.delete(c)}function sn(t,e,i){var r,n;const o=t.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(r=t.HALF_FLOAT)&&void 0!==r?r:o.UNSIGNED_BYTE,l=null!==(n=t.RGBA16F)&&void 0!==n?n:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,e,i,0,o.RGBA,a,null);const c=t.createFramebuffer(e,i,!1,!1);return c.colorAttachment.set(s),c}function an(t,e){return e.colorRampTexture||(e.colorRampTexture=new x(t,e.colorRamp,t.gl.RGBA)),e.colorRampTexture}function ln(t,e,i,r,n){if(!i||!r||!r.imageAtlas)return;const o=r.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const t=n.getPaintProperty(e);s=o[t],a=o[t]}s&&a&&t.setConstantPatternPositions(s,a)}function cn(t,i,r,n,o,s,a,l){const c=t.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),p=r.getCrossfadeParameters();let f,m,g,_,y;const x=t.transform,v=r.paint.get("fill-translate"),b=r.paint.get("fill-translate-anchor");a?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const w=u.constantOr(null);for(const u of n){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const P=T.getBucket(r);if(!P)continue;const M=P.programConfigurations.get(r.id),S=t.useProgram(m,M),C=t.style.map.terrain&&t.style.map.terrain.getTerrainData(u);d&&(t.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),M.updatePaintBuffers(p)),ln(M,h,w,T,r);const I=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),A=e.aA(x,T,v,b);if(a){_=P.indexBuffer2,y=P.segments2;const e=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===m&&d?Ri(t,p,T,e,A):Di(e,A)}else _=P.indexBuffer,y=P.segments,g=d?Li(t,p,T,A):{u_fill_translate:A};let E;if("translucent"===t.renderPass&&l){const[e]=t.getStencilConfigForOverlapAndUpdateStencilID(n);E=e[u.overscaledZ]}else E=t.stencilModeForClipping(u);S.draw(t.context,f,o,E,s,$e.backCCW,g,C,I,r.id,P.layoutVertexBuffer,_,y,r.paint,t.transform.zoom,M)}}function hn(t,i,r,n,o,s,a,l){const c=t.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),p=d.constantOr(1),f=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),_=t.transform;for(const d of n){const n=i.getTile(d),y=n.getBucket(r);if(!y)continue;const x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(d),v=y.programConfigurations.get(r.id),b=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(f));const w=_.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});ln(v,u,g,n,r);const T=e.aA(_,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),M=p?zi(t,P,m,T,d,f,n):ki(t,P,m,T);b.draw(c,c.gl.TRIANGLES,o,s,a,$e.backCCW,M,x,w,r.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,r.paint,t.transform.zoom,v,t.style.map.terrain&&y.centroidVertexBuffer)}}function un(t,e,i,r,n,o,s,a,l){var c;const h=t.style.projection,u=t.context,d=t.transform,p=u.gl,f=t.useProgram("hillshade"),m=!t.options.moving;for(const g of r){const r=e.getTile(g),_=r.fbo;if(!_)continue;const y=h.getMeshFromTileID(u,g.canonical,a,!0,"raster"),x=null===(c=t.style.map.terrain)||void 0===c?void 0:c.getTerrainData(g);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,_.colorAttachment.get());const v=d.getProjectionData({overscaledTileID:g,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(u,p.TRIANGLES,o,n[g.overscaledZ],s,$e.backCCW,Ui(t,r,i),x,v,i.id,y.vertexBuffer,y.indexBuffer,y.segments)}}const dn=[new e.P(0,0),new e.P(e.af,0),new e.P(e.af,e.af),new e.P(0,e.af)];function pn(t,e,i,r,n,o,s,a,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=t.context,d=u.gl,p=t.useProgram("raster"),f=t.transform,m=t.style.projection,g=t.colorModeForRenderPass(),_=!t.options.moving;for(const y of r){const r=t.getDepthModeForSublayer(y.overscaledZ-h,1===i.paint.get("raster-opacity")?Ge.ReadWrite:Ge.ReadOnly,d.LESS),x=e.getTile(y);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const v=e.findLoadedParent(y,0),b=e.findLoadedSibling(y),w=fn(x,v||b||null,e,i,t.transform,t.style.map.terrain);let T,P;const M="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(M,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),v?(v.texture.bind(M,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,v.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(M,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const S=t.style.map.terrain&&t.style.map.terrain.getTerrainData(y),C=f.getProjectionData({overscaledTileID:y,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),I=Yi(P||[0,0],T||1,w,i,a),A=m.getMeshFromTileID(u,y.canonical,o,s,"raster");p.draw(u,d.TRIANGLES,r,n?n[y.overscaledZ]:We.disabled,g,l?$e.frontCCW:$e.backCCW,I,S,C,i.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function fn(t,i,r,n,o,a){const l=n.paint.get("raster-fade-duration");if(!a&&l>0){const n=s.now(),a=(n-t.timeAdded)/l,c=i?(n-i.timeAdded)/l:-1,h=r.getSource(),u=Wt(o,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=d&&t.refreshedUponExpiration?1:e.K(d?a:1-c,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const mn=new e.b7(1,0,0,1),gn=new e.b7(0,1,0,1),_n=new e.b7(0,0,1,1),yn=new e.b7(1,0,1,1),xn=new e.b7(0,1,1,1);function vn(t,e,i,r){wn(t,0,e+i/2,t.transform.width,i,r)}function bn(t,e,i,r){wn(t,e-i/2,0,i,t.transform.height,r)}function wn(t,e,i,r,n,o){const s=t.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Tn(t,i,r){const n=t.context,o=n.gl,s=t.useProgram("debug"),a=Ge.disabled,l=We.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r);n.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/t.transform.zoom)*.5;let g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${g} ${p}kB`);const _=t.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(n,o.TRIANGLES,a,l,Ue.alphaBlended,$e.disabled,ji(e.b7.transparent,m),null,_,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(n,o.LINE_STRIP,a,l,c,$e.disabled,ji(e.b7.red),u,_,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Pn(t,e,i,r){const{isRenderingGlobe:n}=r,o=t.context,s=o.gl,a=t.transform,l=t.colorModeForRenderPass(),c=t.getDepthModeFor3D(),h=t.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,t.width,t.height]);for(const r of i){const i=e.getTerrainMesh(r.tileID),u=t.renderToTexture.getTexture(r),d=e.getTerrainData(r.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const p=e.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=Si(p,f,t.style.sky,a.pitch,n),g=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(o,s.TRIANGLES,c,We.disabled,l,$e.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Mn(t,i){if(!i.mesh){const r=new e.aI;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const n=new e.aK;n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),i.mesh=new Me(t.createVertexBuffer(r,Se.members),t.createIndexBuffer(n),e.aJ.simpleSegment(0,0,r.length,n.length))}return i.mesh}class Sn{constructor(t,i){this.context=new Wr(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.a2(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Xt.maxUnderzooming+Xt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new be}resize(t,e,i,r){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i*r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,i=new e.aI;i.emplaceBack(0,0),i.emplaceBack(e.af,0),i.emplaceBack(0,e.af),i.emplaceBack(e.af,e.af),this.tileExtentBuffer=t.createVertexBuffer(i,Se.members),this.tileExtentSegments=e.aJ.simpleSegment(0,0,4,2);const r=new e.aI;r.emplaceBack(0,0),r.emplaceBack(e.af,0),r.emplaceBack(0,e.af),r.emplaceBack(e.af,e.af),this.debugBuffer=t.createVertexBuffer(r,Se.members),this.debugSegments=e.aJ.simpleSegment(0,0,4,5);const n=new e.bZ;n.emplaceBack(0,0,0,0),n.emplaceBack(e.af,0,e.af,0),n.emplaceBack(0,e.af,0,e.af),n.emplaceBack(e.af,e.af,e.af,e.af),this.rasterBoundsBuffer=t.createVertexBuffer(n,Pi.members),this.rasterBoundsSegments=e.aJ.simpleSegment(0,0,4,2);const o=new e.aI;o.emplaceBack(0,0),o.emplaceBack(e.af,0),o.emplaceBack(0,e.af),o.emplaceBack(e.af,e.af),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(o,Se.members),this.rasterBoundsSegmentsPosOnly=e.aJ.simpleSegment(0,0,4,5);const s=new e.aI;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Se.members),this.viewportSegments=e.aJ.simpleSegment(0,0,4,2);const a=new e.b_;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(a);const l=new e.aK;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new We({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new Me(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=e.L();e.bR(r,0,this.width,this.height,0,0,1),e.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const n={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,Ge.disabled,this.stencilClearMode,Ue.disabled,$e.disabled,null,null,n,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ue.disabled),r.setDepthMode(Ge.disabled);const n={};for(const t of e)n[t.key]=this.nextStencilID++;this._renderTileMasks(n,e,i,!0),this._renderTileMasks(n,e,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(t,e,i,r){const n=this.context,o=n.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of e){const e=t[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(n,o.TRIANGLES,Ge.disabled,new We({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),Ue.disabled,i?$e.disabled:$e.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}_renderTilesDepthBuffer(){const t=this.context,e=t.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ht(r,{tileSize:r.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(t,e.TRIANGLES,o,We.disabled,Ue.disabled,$e.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new We({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new We({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let i=0;i<n;i++)t[i+r]=new We({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:We.disabled},i]}stencilConfigForOverlapTwoPass(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const t={},o={};for(let i=0;i<n;i++)t[i+r]=new We({func:e.GREATER,mask:255},n+1+i,255,e.KEEP,e.KEEP,e.REPLACE),o[i+r]=new We({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*n+1,[t,o,i]}return this.nextStencilID=3,[{[r]:new We({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new We({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Ue([t.CONSTANT_COLOR,t.ONE],new e.b7(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Ue.unblended:Ue.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return Ge.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Ge(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new Ge(this.context.gl.LEQUAL,Ge.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){var r,n;this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(s.now()),this.imageManager.beginFrame();const o=this.style._order,a=this.style.sourceCaches,l={},c={},h={},u={isRenderingToTexture:!1,isRenderingGlobe:(null===(r=t.projection)||void 0===r?void 0:r.transitionState)>0};for(const t in a){const e=a[t];e.used&&e.prepare(this.context),l[t]=e.getVisibleCoordinates(!1),c[t]=l[t].slice().reverse(),h[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<o.length;t++)if(this.style._layers[o[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const t of o){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=c[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,a[e.source],e,i,u)}if(null===(n=this.style.projection)||void 0===n||n.updateGPUdependent({context:this.context,useProgram:t=>this.useProgram(t)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.b7.black:e.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(t,e){const i=t.context,r=i.gl,n=((t,e,i)=>{const r=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),o=Nt(e),s=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-o*n)*i,(e.height/2+o*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:s}})(e,t.style.map.transform,t.pixelRatio),o=new Ge(r.LEQUAL,Ge.ReadWrite,[0,1]),s=We.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),c=Mn(i,e);l.draw(i,r.TRIANGLES,o,s,a,$e.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[o[this.currentLayer]],e=a[t.source],i=l[t.source];this._renderTileClippingMasks(t,i,!1),this.renderLayer(this,e,t,i,u)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const t=this.style._layers[o[this.currentLayer]],e=a[t.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(t,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===t.type?h:c)[t.source];this._renderTileClippingMasks(t,l[t.source],!1),this.renderLayer(this,e,t,i,u)}if(u.isRenderingGlobe&&function(t,i,r){const n=t.context,o=n.gl,s=t.useProgram("atmosphere"),a=new Ge(o.LEQUAL,Ge.ReadOnly,[0,1]),l=t.transform,c=function(t,i){const r=t.properties.get("position"),n=[-r.x,-r.y,-r.z],o=e.a2(new Float64Array(16));return"map"===t.properties.get("anchor")&&(e.a_(o,o,i.rollInRadians),e.a$(o,o,-i.pitchInRadians),e.a_(o,o,i.bearingInRadians),e.a$(o,o,i.center.lat*Math.PI/180),e.bp(o,o,-i.center.lng*Math.PI/180)),e.bY(n,n,o),n}(r,t.transform),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;const d=si(l.worldSize,l.center.lat),p=l.inverseProjectionMatrix,f=new Float64Array(4);f[3]=1,e.Z(f,f,l.modelViewProjectionMatrix),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1,e.Z(f,f,p),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1;const m=((t,e,i,r,n)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(c,u,[f[0],f[1],f[2]],d,p),g=Mn(n,i);s.draw(n,o.TRIANGLES,a,We.disabled,Ue.alphaBlended,$e.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const t=function(t,e){let i=null;const r=Object.values(t._layers).flatMap((i=>i.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),n=r.filter((t=>"vector"===t.getSource().type)),o=r.filter((t=>"vector"!==t.getSource().type)),s=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};return n.forEach((t=>s(t))),i||o.forEach((t=>s(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let r=0;r<i.length;r++)Tn(t,e,i[r])}(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;vn(t,t.transform.height-(e.top||0),3,mn),vn(t,e.bottom||0,3,gn),bn(t,e.left||0,3,_n),bn(t,t.transform.width-(e.right||0),3,yn);const i=t.transform.centerPoint;!function(t,e,i,r){wn(t,e-1,i-10,2,20,r),wn(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,xn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const i=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let n=this.terrainFacilitator.dirty;n||(n=t?!e.b$(i,r):!e.c0(i,r)),n||(n=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),n&&(e.c1(i,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){const r=t.context,n=r.gl,o=t.transform,s=Ue.unblended,a=new Ge(n.LEQUAL,Ge.ReadWrite,[0,1]),l=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.b7.transparent,depth:1});for(const t of l){const e=i.getTerrainMesh(t.tileID),l=i.getTerrainData(t.tileID),h=o.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(o.zoom)};c.draw(r,n.TRIANGLES,a,We.disabled,s,$e.backCCW,u,l,h,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){const r=t.context,n=r.gl,o=t.transform,s=Ue.unblended,a=new Ge(n.LEQUAL,Ge.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),h=t.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.b7.transparent,depth:1}),i.coordsIndex=[];for(const t of c){const e=i.getTerrainMesh(t.tileID),c=i.getTerrainData(t.tileID);r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(o.zoom)},d=o.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(r,n.TRIANGLES,a,We.disabled,s,$e.backCCW,u,c,d,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),i.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,r,n,o){r.isHidden(this.transform.zoom)||("background"===r.type||"custom"===r.type||(n||[]).length)&&(this.id=r.id,e.c2(r)?function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:a}=s,l=We.disabled,c=t.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,r,n,o,s,a,l,c){const h=i.transform,u=i.style.map.terrain,d="map"===o,p="map"===s;for(const o of t){const t=n.getTile(o),s=t.getBucket(r);if(!s||!s.text||!s.text.segments.get().length)continue;const f=e.N(s.textSizeData,h.zoom),m=e.az(t,1,i.transform.zoom,i.transform.detailLevel),g=Z(d,i.transform,m),_="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(f){const i=Math.pow(2,h.zoom-t.tileID.overscaledZ),r=u?(t,e)=>u.getElevation(o,t,e):null;Qr(s,d,p,c,h,g,i,f,_,e.aA(h,t,a,l),o.toUnwrapped(),r)}}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&en(t,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,a),0!==r.paint.get("text-opacity").constantOr(1)&&en(t,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(Xr(t,i,r,n,!0),Xr(t,i,r,n,!1))}(t,i,r,n,this.style.placement.variableOffsets,o):e.c3(r)?function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:s}=o,a=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=t.context,d=u.gl,p=t.transform,f=t.getDepthModeForSublayer(0,Ge.ReadOnly),m=We.disabled,g=t.colorModeForRenderPass(),_=[],y=p.getCircleRadiusCorrection();for(let o=0;o<n.length;o++){const a=n[o],l=i.getTile(a),c=l.getBucket(r);if(!c)continue;const u=r.paint.get("circle-translate"),d=r.paint.get("circle-translate-anchor"),f=e.aA(p,l,u,d),m=c.programConfigurations.get(r.id),g=t.useProgram("circle",m),x=c.layoutVertexBuffer,v=c.indexBuffer,b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),w={programConfiguration:m,program:g,layoutVertexBuffer:x,indexBuffer:v,uniformValues:Fi(t,l,r,f,y),terrainData:b,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!s,applyTerrainMatrix:!0})};if(h){const t=c.segments.get();for(const i of t)_.push({segments:new e.aJ([i]),sortKey:i.sortKey,state:w})}else _.push({segments:c.segments,sortKey:0,state:w})}h&&_.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of _){const{programConfiguration:i,program:n,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=e.state;n.draw(u,d.TRIANGLES,f,m,g,$e.backCCW,a,l,c,r.id,o,s,e.segments,r.paint,t.transform.zoom,i)}}(t,i,r,n,o):e.c4(r)?function(t,i,r,n,o){if(0===r.paint.get("heatmap-opacity"))return;const s=t.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(t.style.map.terrain){for(const e of n){const n=i.getTile(e);i.hasRenderableParent(e)||("offscreen"===t.renderPass?nn(t,n,r,e,l):"translucent"===t.renderPass&&on(t,r,e,a,l))}s.viewport.set([0,0,t.width,t.height])}else"offscreen"===t.renderPass?function(t,i,r,n){const o=t.context,s=o.gl,a=t.transform,l=We.disabled,c=new Ue([s.ONE,s.ONE],e.b7.transparent,[!0,!0,!0,!0]);(function(t,i,r){const n=t.gl;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,i.width/4,i.height/4]);let o=r.heatmapFbos.get(e.bV);o?(n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),t.bindFramebuffer.set(o.framebuffer)):(o=sn(t,i.width/4,i.height/4),r.heatmapFbos.set(e.bV,o))})(o,t,r),o.clear({color:e.b7.transparent});for(let e=0;e<n.length;e++){const h=n[e];if(i.hasRenderableParent(h))continue;const u=i.getTile(h),d=u.getBucket(r);if(!d)continue;const p=d.programConfigurations.get(r.id),f=t.useProgram("heatmap",p),m=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),g=a.getCircleRadiusCorrection();f.draw(o,s.TRIANGLES,Ge.disabled,l,c,$e.backCCW,Ni(u,a.zoom,a.detailLevel,r.paint.get("heatmap-intensity"),g),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,a.zoom,p)}o.viewport.set([0,0,t.width,t.height])}(t,i,r,n):"translucent"===t.renderPass&&function(t,i){const r=t.context,n=r.gl;r.setColorMode(t.colorModeForRenderPass());const o=i.heatmapFbos.get(e.bV);o&&(r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1),an(r,i).bind(n.LINEAR,n.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(r,n.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Vi(t,i,0,1),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom))}(t,r)}(t,i,r,n,o):e.c5(r)?function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:s}=o,a=r.paint.get("line-opacity"),l=r.paint.get("line-width");if(0===a.constantOr(1)||0===l.constantOr(1))return;const c=t.getDepthModeForSublayer(0,Ge.ReadOnly),h=t.colorModeForRenderPass(),u=r.paint.get("line-dasharray"),d=r.paint.get("line-pattern"),p=d.constantOr(1),f=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),g=p?"linePattern":u?"lineSDF":f?"lineGradient":"line",_=t.context,y=_.gl,v=t.transform;let b=!0;for(const o of n){const a=i.getTile(o);if(p&&!a.patternsLoaded())continue;const l=a.getBucket(r);if(!l)continue;const w=l.programConfigurations.get(r.id),T=t.context.program.get(),P=t.useProgram(g,w),M=b||P.program!==T,S=t.style.map.terrain&&t.style.map.terrain.getTerrainData(o),C=d.constantOr(null);if(C&&a.imageAtlas){const t=a.imageAtlas,e=t.patternPositions[C.to.toString()],i=t.patternPositions[C.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const I=v.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),A=v.getPixelScale(),E=p?Wi(t,a,r,A,m):u?Hi(t,a,r,A,u,m):f?qi(t,a,r,A,l.lineClipsArray.length):Gi(t,a,r,A);if(p)_.activeTexture.set(y.TEXTURE0),a.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),w.updatePaintBuffers(m);else if(u&&(M||t.lineAtlas.dirty))_.activeTexture.set(y.TEXTURE0),t.lineAtlas.bind(_);else if(f){const n=l.gradients[r.id];let s=n.texture;if(r.gradientVersion!==n.version){let a=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;a=e.K(e.bW(l.maxLineLength/e.af*1024*n),256,_.maxTextureSize)}n.gradient=e.bX({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:a,image:n.gradient||void 0,clips:l.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new x(_,n.gradient,y.RGBA),n.version=r.gradientVersion,s=n.texture}_.activeTexture.set(y.TEXTURE0),s.bind(r.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}let k;if(s){const[e]=t.getStencilConfigForOverlapAndUpdateStencilID(n);k=e[o.overscaledZ]}else k=t.stencilModeForClipping(o);P.draw(_,y.TRIANGLES,c,k,h,$e.disabled,E,S,I,r.id,l.layoutVertexBuffer,l.indexBuffer,l.segments,r.paint,t.transform.zoom,w,l.layoutVertexBuffer2),b=!1}}(t,i,r,n,o):e.c6(r)?function(t,i,r,n,o){const s=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:l}=o,c=t.colorModeForRenderPass(),h=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===s.constantOr(e.b7.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.getDepthModeForSublayer(1,"opaque"===t.renderPass?Ge.ReadWrite:Ge.ReadOnly);cn(t,i,r,n,e,c,!1,l)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=t.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Ge.ReadOnly);cn(t,i,r,n,e,c,!0,l)}}(t,i,r,n,o):e.c7(r)?function(t,e,i,r,n){const o=i.paint.get("fill-extrusion-opacity");if(0===o)return;const{isRenderingToTexture:s}=n;if("translucent"===t.renderPass){const n=new Ge(t.context.gl.LEQUAL,Ge.ReadWrite,t.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))hn(t,e,i,r,n,We.disabled,Ue.disabled,s),hn(t,e,i,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),s);else{const o=t.colorModeForRenderPass();hn(t,e,i,r,n,We.disabled,o,s)}}}(t,i,r,n,o):e.c8(r)?function(t,e,i,r,n){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=n,s=t.context,a=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,Ge.ReadOnly),c=t.colorModeForRenderPass();if("offscreen"===t.renderPass)!function(t,e,i,r,n,o,s){const a=t.context,l=a.gl;for(const c of i){const i=e.getTile(c),h=i.dem;if(!h||!h.data)continue;if(!i.needsHillshadePrepare)continue;const u=h.dim,d=h.stride,p=h.getPixels();if(a.activeTexture.set(l.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(d),i.demTexture){const t=i.demTexture;t.update(p,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new x(a,p,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);a.activeTexture.set(l.TEXTURE0);let f=i.fbo;if(!f){const t=new x(a,{width:u,height:u,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),f=i.fbo=a.createFramebuffer(u,u,!0,!1),f.colorAttachment.set(t.texture)}a.bindFramebuffer.set(f.framebuffer),a.viewport.set([0,0,u,u]),t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,$e.disabled,Zi(i.tileID,h),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}}(t,e,r,i,l,We.disabled,c),s.viewport.set([0,0,t.width,t.height]);else if("translucent"===t.renderPass)if(a){const[n,s,a]=t.stencilConfigForOverlapTwoPass(r);un(t,e,i,a,n,l,c,!1,o),un(t,e,i,a,s,l,c,!0,o)}else{const[n,s]=t.getStencilConfigForOverlapAndUpdateStencilID(r);un(t,e,i,s,n,l,c,!1,o)}}(t,i,r,n,o):e.c9(r)?function(t,e,i,r,n){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const{isRenderingToTexture:o}=n,s=e.getSource(),a=t.style.projection.useSubdivision;if(s instanceof Mt)pn(t,e,i,r,null,!1,!1,s.tileCoords,s.flippedWindingOrder,o);else if(a){const[n,s,a]=t.stencilConfigForOverlapTwoPass(r);pn(t,e,i,a,n,!1,!0,dn,!1,o),pn(t,e,i,a,s,!0,!0,dn,!1,o)}else{const[n,s]=t.getStencilConfigForOverlapAndUpdateStencilID(r);pn(t,e,i,s,n,!1,!0,dn,!1,o)}}(t,i,r,n,o):e.ca(r)?function(t,e,i,r,n){const o=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const{isRenderingToTexture:a}=n,l=t.context,c=l.gl,h=t.style.projection,u=t.transform,d=u.tileSize,p=i.paint.get("background-pattern");if(t.isPatternMissing(p))return;const f=!p&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==f)return;const m=We.disabled,g=t.getDepthModeForSublayer(0,"opaque"===f?Ge.ReadWrite:Ge.ReadOnly),_=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),x=r||Ht(u,{tileSize:d,terrain:t.style.map.terrain});p&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context));const v=i.getCrossfadeParameters();for(const e of x){const r=u.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),n=p?rr(s,t,p,{tileID:e,tileSize:d},v):ir(s,o),f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e),x=h.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,c.TRIANGLES,g,m,_,$e.backCCW,n,f,r,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}(t,0,r,n,o):e.cb(r)&&function(t,e,i,r){const{isRenderingGlobe:n}=r,o=t.context,s=i.implementation,a=t.style.projection,l=t.transform,c=l.getProjectionDataForCustomLayer(n),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},u=s.renderingMode?s.renderingMode:"2d";if("offscreen"===t.renderPass){const e=s.prerender;e&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),e.call(s,o.gl,h),o.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(We.disabled);const e="3d"===u?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,Ge.ReadOnly);o.setDepthMode(e),s.render(o.gl,h),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}(t,0,r,o))}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,n=this.style.projection,o=t+(e?e.cacheKey:"")+`/${i?Ie:n.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[o]||(this.cache[o]=new Ai(this.context,Te[t],e,or[t],this._showOverdrawInspector,r,i?Te.projectionMercator:n.shaderPreludeCode,i?Ce:n.shaderDefine)),this.cache[o]}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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new x(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}function Cn(t,e){let i,r=!1,n=null,o=null;const s=()=>{n=null,r&&(t.apply(o,i),n=setTimeout(s,e),r=!1)};return(...t)=>(r=!0,o=this,i=t,n||s(),n)}class In{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(!this._isValidHash(t))return!1;const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let i=e;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${e}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=Cn(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),o=Math.round(e.lng*n)/n,s=Math.round(e.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new e.a8(+t[2],+t[1])}catch(t){return!1}const i=+t[0],r=+(t[3]||0),n=+(t[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&n>=this._map.getMinPitch()&&n<=this._map.getMaxPitch()}}const An={linearity:.3,easing:e.cc(0,0,.3,1)},En=e.e({deceleration:2500,maxSpeed:1400},An),kn=e.e({deceleration:20,maxSpeed:1400},An),zn=e.e({deceleration:1e3,maxSpeed:360},An),Ln=e.e({deceleration:1e3,maxSpeed:90},An),Dn=e.e({deceleration:1e3,maxSpeed:360},An);class Rn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=s.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,i.roll+=t.rollDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=Bn(i.pan.mag(),r,e.e({},En,t||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);n.center=a.easingCenter,n.offset=a.easingOffset,Fn(n,o)}if(i.zoom){const t=Bn(i.zoom,r,kn);n.zoom=this._map.transform.zoom+t.amount,Fn(n,t)}if(i.bearing){const t=Bn(i.bearing,r,zn);n.bearing=this._map.transform.bearing+e.K(t.amount,-179,179),Fn(n,t)}if(i.pitch){const t=Bn(i.pitch,r,Ln);n.pitch=this._map.transform.pitch+t.amount,Fn(n,t)}if(i.roll){const t=Bn(i.roll,r,Dn);n.roll=this._map.transform.roll+e.K(t.amount,-179,179),Fn(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(n,{noMoveStart:!0})}}function Fn(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function Bn(t,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=e.K(t*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class On extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,n={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);const o=a.mousePos(i.getCanvas(),r,i.getScale()),s=i.unproject(o);super(t,e.e({point:o,lngLat:s,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class jn extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){const n="touchend"===t?r.changedTouches:r.touches,o=a.touchPos(i.getCanvasContainer(),n,i.getScale()),s=o.map((t=>i.unproject(t))),l=o.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new e.P(0,0));super(t,{points:o,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}}class Nn extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Vn{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Nn(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new On(t.type,this._map,t))}mouseup(t){this._map.fire(new On(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new On(t.type,this._map,t))}dblclick(t){return this._firePreventable(new On(t.type,this._map,t))}mouseover(t){this._map.fire(new On(t.type,this._map,t))}mouseout(t){this._map.fire(new On(t.type,this._map,t))}touchstart(t){return this._firePreventable(new jn(t.type,this._map,t))}touchmove(t){this._map.fire(new jn(t.type,this._map,t))}touchend(t){this._map.fire(new jn(t.type,this._map,t))}touchcancel(t){this._map.fire(new jn(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Un{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new On(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new On("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new On(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zn{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.screenPointToLocation(e.P.convert(t),this._map.terrain)}}class $n{constructor(t,e){this._map=t,this._tr=new Zn(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(a.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=a.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y);a.setTransform(this._box,`translate(${n}px,${s}px)`),this._box.style.width=o-n+"px",this._box.style.height=l-s+"px"}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const r=this._startPos,n=i;if(this.reset(),a.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.l("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.l(t,{originalEvent:i}))}}function Gn(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class qn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Gn(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Gn(i,e);for(const t in this.touches){const e=r[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Wn{constructor(t){this.singleTap=new qn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Hn{constructor(t){this._tr=new Zn(t),this._zoomIn=new Wn({numTouches:1,numTaps:2}),this._zoomOut=new Wn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i),o=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(n)},{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 Xn{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 e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.rollDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(e)?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const r=Array.isArray(e)?e[0]:e;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&a.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 Kn={0:1,2:2};class Yn{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const e=a.mouseButton(t);this._eventButton=e}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){const i=Kn[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return a.mouseButton(t)===this._eventButton}}class Jn{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_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)}}class Qn{constructor(t=new Yn({checkCorrectEvent:()=>!0}),e=new Jn){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):"undefined"!=typeof TouchEvent&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.startMove(t)),(t=>this.oneFingerTouchMoveStateManager.startMove(t)))}endMove(t){this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.endMove(t)),(t=>this.oneFingerTouchMoveStateManager.endMove(t)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidStartEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidMoveEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidEndEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t)))}}const to=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};class eo{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active){if(!this._shouldBePrevented(i.length))return t.preventDefault(),this._calculateTransform(t,e,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);const n=Gn(r,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(o._add(e),s._add(e.sub(i)),a++,n[t]=e)}if(this._touches=n,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class io{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,n]=this._firstTwoTouches,o=ro(i,e,r),s=ro(i,e,n);if(!o||!s)return;const a=this._aroundCenter?null:o.add(s).div(2);return this._move([o,s],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=ro(i,e,r),s=ro(i,e,n);o&&s||(this._active&&a.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function ro(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function no(t,e){return Math.log(t/e)/Math.LN2}class oo extends io{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(no(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:no(this._distance,i),pinchAround:e}}}function so(t,e){return 180*t.angleWith(e)/Math.PI}class ao extends io{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,e,i){const r=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:so(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=so(t,this._startVector);return Math.abs(i)<e}}function lo(t){return Math.abs(t.y)>Math.abs(t.x)}class co extends io{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,lo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return lo(t)&&lo(e)&&o}}const ho={panStep:100,bearingStep:15,pitchStep:10};class uo{constructor(t){this._tr=new Zn(t);const e=ho;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:po,zoom:e?Math.round(a.zoom)+e*(t.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.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 po(t){return t*(2-t)}const fo=4.000244140625;class mo{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new Zn(t),this._triggerRenderFrame=e,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||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%fo==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,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 i=a.mousePos(this._map.getCanvas(),t,this._map.getScale()),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(e.a8.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>fo?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n="number"!=typeof this._targetZoom?t.scale:e.at(this._targetZoom);this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,e.aw(n*r))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?t.zoom:this._targetZoom,r=this._startZoom,n=this._easing;let o,a=!1;if("wheel"===this._type&&r&&n){const t=s.now()-this._lastWheelEventTime,l=Math.min((t+5)/200,1),c=n(l);o=e.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ce;if(this._prevEase){const t=this._prevEase,r=(s.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,a=Math.sqrt(.0729-o*o);i=e.cc(o,a,.25,1)}return this._prevEase={start:s.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class go{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 _o{constructor(t){this._tr=new Zn(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class yo{constructor(){this._tap=new Wn({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,e,i){if(!this._swipePoint)if(this._tapTime){const r=e[0],n=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(r)<30;n&&o?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xo{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}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 vo{constructor(t,e,i,r){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class bo{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class wo{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=a.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(a.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new e.l("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const To=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;class Po extends e.l{}function Mo(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}class So{constructor(t,i){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,i)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},o={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||t.type]){if(e.cf(t,i||t.type)){const e=a.mousePos(this._map.getCanvas(),t,this._map.getScale());u=c[i||t.type](t,e)}else if(e.cg(t,i||t.type)){const e=this._getMapTouches(t.touches),r=a.touchPos(this._map.getCanvas(),e,this._map.getScale());u=c[i||t.type](t,r,e)}else e.ch(i||t.type)||(u=c[i||t.type](t));this.mergeHandlerResult(n,o,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(s[l]=c)}const l={};for(const t in this._previousActiveHandlers)s[t]||(l[t]=r);this._previousActiveHandlers=s,(Object.keys(l).length||Mo(n))&&(this._changes.push([n,o,l]),this._triggerRenderFrame()),(Object.keys(s).length||Mo(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=n;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Rn(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)a.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)a.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new Vn(i,t));const n=i.boxZoom=new $n(i,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();const o=i.cooperativeGestures=new wo(i,t.cooperativeGestures);this._add("cooperativeGestures",o),t.cooperativeGestures&&o.enable();const s=new Hn(i),l=new _o(i);i.doubleClickZoom=new go(l,s),this._add("tapZoom",s),this._add("clickZoom",l),t.interactive&&t.doubleClickZoom&&i.doubleClickZoom.enable();const c=new yo;this._add("tapDragZoom",c);const h=i.touchPitch=new co(i);this._add("touchPitch",h),t.interactive&&t.touchPitch&&i.touchPitch.enable(t.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:t,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:n=100,rotateDegreesPerPixelMoved:o=.8},s){const l=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)&&!t.ctrlKey});return new Xn({clickTolerance:i,move:(t,i)=>{const a=s();if(r&&Math.abs(a.y-t.y)>n)return{bearingDelta:e.cd(new e.P(t.x,i.y),i,a)};let l=(i.x-t.x)*o;return r&&i.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:l,enable:t,assignEvents:to})}(t,u),p=function({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5}){const r=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)});return new Xn({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:to})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){const n=new Yn({checkCorrectEvent:t=>2===a.mouseButton(t)&&t.ctrlKey});return new Xn({clickTolerance:e,move:(t,e)=>{const n=r();let o=(e.x-t.x)*i;return e.y<n.y&&(o=-o),{rollDelta:o}},moveStateManager:n,enable:t,assignEvents:to})}(t,u);i.dragRotate=new vo(t,d,p,f),this._add("mouseRotate",d,["mousePitch"]),this._add("mousePitch",p,["mouseRotate","mouseRoll"]),this._add("mouseRoll",f,["mousePitch"]),t.interactive&&t.dragRotate&&i.dragRotate.enable();const m=function({enable:t,clickTolerance:e}){const i=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&!t.ctrlKey});return new Xn({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:to})}(t),g=new eo(t,i);i.dragPan=new xo(r,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&i.dragPan.enable(t.dragPan);const _=new ao,y=new oo;i.touchZoomRotate=new bo(r,y,_,c),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",y,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&i.touchZoomRotate.enable(t.touchZoomRotate);const x=i.scrollZoom=new mo(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),t.interactive&&t.scrollZoom&&i.scrollZoom.enable(t.scrollZoom);const v=i.keyboard=new uo(i);this._add("keyboard",v),t.interactive&&t.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Un(i))}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.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 Boolean(To(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.e(t,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),n.rollDelta&&(t.rollDelta=(t.rollDelta||0)+n.rollDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(i,o),e.e(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,n=r._getTransformForUpdate(),o=r.terrain;if(!(Mo(t)||o&&this._terrainMovement))return this._fireEvents(e,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=t;void 0!==d&&(u=d),u=u||r.transform.centerPoint,o&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const f=u.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(s?u.sub(s):u);o?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,n),this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(p,n,f):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,n,f))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,n),this._map.cameraHelper.handleMapControlsPan(p,n,f)),r._applyUpdatedTransform(n),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,i,r){const n=To(this._eventsInProgress),o=To(t),a={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(a[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in a)this._fireEvent(t,a[t]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=i[e]||r,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const h=To(this._eventsInProgress),u=(n||o)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(t)}if(r&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&s.prefersReducedMotion?(this._map.fire(new e.l("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:c})),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.l(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Po("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Co extends e.E{constructor(t,e,i){super(),this._renderFrameCallback=()=>{const t=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this.cameraHelper=e,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,e){t.apply(this.transform),this.transform=t,this.cameraHelper=e}getCenter(){return new e.a8(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,e){return this.jumpTo({elevation:t},e),this}getCenterClampedToGround(){return!1}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.e({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,r){return this.easeTo(e.e({zoom:t},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,i){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)).fire(new e.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,r){return this.easeTo(e.e({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,roll:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}getRoll(){return this.transform.roll}setRoll(t,e){return this.jumpTo({roll:t},e),this}cameraForBounds(t,e){t=xt.convert(t).adjustAntiMeridian();const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,r,n){const o={top:0,bottom:0,right:0,left:0};if("number"==typeof(n=e.e({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},n)).padding){const t=n.padding;n.padding={top:t,bottom:t,right:t,left:t}}const s=e.e(o,n.padding);n.padding=s;const a=this.transform,l=new xt(t,i);return this.cameraHelper.cameraForBoxAndBearing(n,s,l,r,a)}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,r,n,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(e.P.convert(t)),this.transform.screenPointToLocation(e.P.convert(i)),r,n),n,o)}_fitInternal(t,i,r){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(t,i){this.stop();const r=this._getTransformForUpdate();let n=!1,o=!1,s=!1;const a=r.zoom;this.cameraHelper.handleJumpToCenterZoom(r,t);const l=r.zoom!==a;return"elevation"in t&&r.elevation!==+t.elevation&&r.setElevation(+t.elevation),"bearing"in t&&r.bearing!==+t.bearing&&(n=!0,r.setBearing(+t.bearing)),"pitch"in t&&r.pitch!==+t.pitch&&(o=!0,r.setPitch(+t.pitch)),"roll"in t&&r.roll!==+t.roll&&(s=!0,r.setRoll(+t.roll)),null==t.padding||r.isPaddingEqual(t.padding)||r.setPadding(t.padding),this._applyUpdatedTransform(r),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)),l&&this.fire(new e.l("zoomstart",i)).fire(new e.l("zoom",i)).fire(new e.l("zoomend",i)),n&&this.fire(new e.l("rotatestart",i)).fire(new e.l("rotate",i)).fire(new e.l("rotateend",i)),o&&this.fire(new e.l("pitchstart",i)).fire(new e.l("pitch",i)).fire(new e.l("pitchend",i)),s&&this.fire(new e.l("rollstart",i)).fire(new e.l("roll",i)).fire(new e.l("rollend",i)),this.fire(new e.l("moveend",i))}calculateCameraOptionsFromTo(t,i,r,n=0){const o=e.ag.fromLngLat(t,i),s=e.ag.fromLngLat(r,n),a=s.x-o.x,l=s.y-o.y,c=s.z-o.z,h=Math.hypot(a,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(a,l),d=e.aw(this.transform.cameraToCenterDistance/h/this.transform.tileSize),p=180*Math.atan2(a,-l)/Math.PI;let f=180*Math.acos(u/h)/Math.PI;return f=c<0?90-f:90+f,{center:s.toLngLat(),elevation:n,zoom:d,pitch:f,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n){const o=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,r);return{center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:i,pitch:r,roll:n}}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.ce},t)).animate||!t.essential&&s.prefersReducedMotion)&&(t.duration=0);const r=this._getTransformForUpdate(),n=this.getBearing(),o=r.pitch,a=r.roll,l="bearing"in t?this._normalizeBearing(t.bearing,n):n,c="pitch"in t?+t.pitch:o,h="roll"in t?this._normalizeBearing(t.roll,a):a,u="padding"in t?t.padding:r.padding,d=e.P.convert(t.offset);let p,f;t.around&&(p=e.a8.convert(t.around),f=r.locationToScreenPoint(p));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:l,pitch:c,roll:h,padding:u,around:p,aroundPoint:f,offsetAsPoint:d,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||n!==l,this._pitching=this._pitching||c!==o,this._rolling=this._rolling||h!==a,this._padding=!r.isPaddingEqual(u),this._zooming=this._zooming||g.isZooming,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,m),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((e=>{g.easeFunc(e),this.terrain&&!t.freezeElevation&&this._updateElevation(e),this._applyUpdatedTransform(r),this._fireMoveEvents(i)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,i||r.moving||this.fire(new e.l("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.l("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.l("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.l("pitchstart",t)),this._rolling&&!r.rolling&&this.fire(new e.l("rollstart",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.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.setElevation(e.B.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const e=t.getCameraLngLat(),i=t.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<r){const i=this.calculateCameraOptionsFromTo(e,r,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(t){const e=[];if(e.push((t=>this._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const i=t.clone();for(const t of e){const e=i.clone(),{center:r,zoom:n,roll:o,pitch:s,bearing:a,elevation:l}=t(e);r&&e.setCenter(r),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==o&&e.setRoll(o),void 0!==s&&e.setPitch(s),void 0!==a&&e.setBearing(a),i.apply(e)}this.transform.apply(i)}_fireMoveEvents(t){this.fire(new e.l("move",t)),this._zooming&&this.fire(new e.l("zoom",t)),this._rotating&&this.fire(new e.l("rotate",t)),this._pitching&&this.fire(new e.l("pitch",t)),this._rolling&&this.fire(new e.l("roll",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new e.l("zoomend",t)),n&&this.fire(new e.l("rotateend",t)),o&&this.fire(new e.l("pitchend",t)),s&&this.fire(new e.l("rollend",t)),this.fire(new e.l("moveend",t))}flyTo(t,i){if(!t.essential&&s.prefersReducedMotion){const r=e.a7(t,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.ce},t);const r=this._getTransformForUpdate(),n=r.bearing,o=r.pitch,a=r.roll,l=r.padding,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:o,u="roll"in t?this._normalizeBearing(t.roll,a):a,d="padding"in t?t.padding:r.padding,p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:p,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let _=t.curve;const y=Math.max(r.width,r.height),x=y/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(y/g.scaleOfMinZoom/v*2));const b=_*_;function w(t){const e=(x*x-y*y+(t?-1:1)*b*b*v*v)/(2*(t?x:y)*b*v);return Math.log(Math.sqrt(e*e+1)-e)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function P(t){return(Math.exp(t)+Math.exp(-t))/2}const M=w(!1);let S=function(t){return P(M)/P(M+_*t)},C=function(t){return y*((P(M)*(T(e=M+_*t)/P(e))-T(M))/b)/v;var e},I=(w(!0)-M)/_;if(Math.abs(v)<2e-6||!isFinite(I)){if(Math.abs(y-x)<1e-6)return this.easeTo(t,i);const e=x<y?-1:1;I=Math.abs(Math.log(x/y))/_,C=()=>0,S=t=>Math.exp(e*_*t)}return t.duration="duration"in t?+t.duration:1e3*I/("screenSpeed"in t?+t.screenSpeed/_:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=h!==o,this._rolling=u!==a,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((s=>{const m=s*I,_=1/S(m),y=C(m);this._rotating&&r.setBearing(e.B.number(n,c,s)),this._pitching&&r.setPitch(e.B.number(o,h,s)),this._rolling&&r.setRoll(e.B.number(a,u,s)),this._padding&&(r.interpolatePadding(l,d,s),f=r.centerPoint.add(p)),g.easeFunc(s,_,y,f),this.terrain&&!t.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){t=e.aL(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.a8.convert(t),this.transform.tileZoom):null}}const Io={compact:!0,customAttribution:void 0};class Ao{constructor(t=Io){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._updateAttributions()):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?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._updateAttributions()},this._extendAttribution=t=>{t.preventDefault(),this._extended=!0,this._updateAttributions()},this._shrinkAttribution=t=>{t.preventDefault(),this._extended=!1,this._updateAttributions()},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._extendButton=a.create("a","maplibregl-attrib-others"),this._extendButton.setAttribute("href","#"),this._extendButton.addEventListener("click",this._extendAttribution),this._extendButton.innerHTML="| Show more",this._shrinkButton=a.create("a","maplibregl-attrib-others"),this._shrinkButton.setAttribute("href","#"),this._shrinkButton.addEventListener("click",this._shrinkAttribution),this._shrinkButton.innerHTML="| Show less",this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.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(){a.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._extended=void 0,this._extendButton=void 0,this._shrinkButton=void 0,this._attribHTML=void 0,this._attribCount=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const i in e){const r=e[i];if(r.used||r.usedForTerrain){const e=r.getSource();if("string"==typeof e.attribution){const i=e.attribution.split("|").map((t=>t.trim()));for(const e of i)t.indexOf(e)<0&&t.push(e)}}}const i='<a href="https://mapcreator.io" target="_blank">© Mapcreator</a>';t.indexOf(i)<0&&t.push(i),t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}));for(const e of["OpenStreetMap","Mapcreator"]){const i=t.findIndex((t=>t.includes(e)));if(-1!==i&&0!==i){const e=t[i];t.splice(i,1),t.unshift(e)}}let r;r=t.length<=2||this._extended?t.join(" "):t.slice(0,2).join(" "),r===this._attribHTML&&t.length===this._attribCount||(this._attribHTML=r,this._attribCount=t.length,t.length?(this._innerContainer.innerHTML=a.sanitize(r),t.length>2&&(this._innerContainer.innerHTML+=" ",this._innerContainer.appendChild(this._extended?this._shrinkButton:this._extendButton)),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._map.fire("attributionchange"),this._editLink=null)}}class Eo{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.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=a.create("div","maplibregl-ctrl");const e=a.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ko{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var zo=e.aG([{name:"a_pos3d",type:"Int16",components:3}]);class Lo extends e.E{constructor(t){super(),this._lastTilesetChange=s.now(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];const r={};for(const n of Ht(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float64Array(16),e.bR(n.terrainRttPosMatrix32f,0,e.af,e.af,0,0,1),this._tiles[n.key]=new Dt(n,this.tileSize),this._lastTilesetChange=s.now());for(const t in this._tiles)r[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,e){return e?this._getTerrainCoordsForTileRanges(t,e):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID,o=t.clone(),s=e.b2();if(n.canonical.equals(t.canonical))e.bR(s,0,e.af,e.af,0,0,1);else if(n.canonical.isChildOf(t.canonical)){const i=n.canonical.z-t.canonical.z,r=n.canonical.x-(n.canonical.x>>i<<i),o=n.canonical.y-(n.canonical.y>>i<<i),a=e.af>>i;e.bR(s,0,a,a,0,0,1),e.a3(s,s,[-r*a,-o*a,0])}else{if(!t.canonical.isChildOf(n.canonical))continue;{const i=t.canonical.z-n.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),o=t.canonical.y-(t.canonical.y>>i<<i),a=e.af>>i;e.bR(s,0,e.af,e.af,0,0,1),e.a3(s,s,[r*a,o*a,0]),e.M(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[r]=o}return i}_getTerrainCoordsForTileRanges(t,i){const r={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=t.clone(),a=e.b2();if(o.canonical.z===t.canonical.z){const i=t.canonical.x-o.canonical.x,r=t.canonical.y-o.canonical.y;e.bR(a,0,e.af,e.af,0,0,1),e.a3(a,a,[i*e.af,r*e.af,0])}else if(o.canonical.z>t.canonical.z){const i=o.canonical.z-t.canonical.z,r=o.canonical.x-(o.canonical.x>>i<<i),n=o.canonical.y-(o.canonical.y>>i<<i),s=t.canonical.x-(o.canonical.x>>i),l=t.canonical.y-(o.canonical.y>>i),c=e.af>>i;e.bR(a,0,c,c,0,0,1),e.a3(a,a,[-r*c+s*e.af,-n*c+l*e.af,0])}else{const i=t.canonical.z-o.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),n=t.canonical.y-(t.canonical.y>>i<<i),s=(t.canonical.x>>i)-o.canonical.x,l=(t.canonical.y>>i)-o.canonical.y,c=e.af<<i;e.bR(a,0,c,c,0,0,1),e.a3(a,a,[r*e.af+s*c,n*e.af+l*c,0])}s.terrainRttPosMatrix32f=new Float32Array(a),r[n]=s}return r}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let n=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!n||!n.dem)&&e)for(;r>=i.minzoom&&(!n||!n.dem);)n=this.sourceCache.getTileByID(t.scaledTo(r--).key);return n}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){return e[t.canonical.z]&&t.canonical.x>=e[t.canonical.z].minTileX&&t.canonical.x<=e[t.canonical.z].maxTileX&&t.canonical.y>=e[t.canonical.z].minTileY&&t.canonical.y<=e[t.canonical.z].maxTileY}}class Do{constructor(t,e,i){this._meshCache={},this.painter=t,this.sourceCache=new Lo(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,r,n=e.af){var o;if(!(i>=0&&i<n&&r>=0&&r<n))return 0;const s=this.getTerrainData(t),a=null===(o=s.tile)||void 0===o?void 0:o.dem;if(!a)return 0;const l=e.ci([],[i/n*e.af,r/n*e.af],s.u_terrain_matrix),c=[l[0]*a.dim,l[1]*a.dim],h=Math.floor(c[0]),u=Math.floor(c[1]),d=c[0]-h,p=c[1]-u;return a.get(h,u)*(1-d)*(1-p)+a.get(h+1,u)*d*(1-p)+a.get(h,u+1)*(1-d)*p+a.get(h+1,u+1)*d*p}getElevationForLngLatZoom(t,i){if(!e.cj(i,t.wrap()))return 0;const{tileID:r,mercatorX:n,mercatorY:o}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(r,n%e.af,o%e.af,e.af)}getElevation(t,i,r,n=e.af){return this.getDEMElevation(t,i,r,n)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new x(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new x(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.a2([])}const i=this.sourceCache.getSourceTile(t,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const t=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new x(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const r=i&&i+i.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){const r=this.sourceCache.sourceCache._source.maxzoom;let n=t.canonical.z-i.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=r?n=t.canonical.z-r:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=t.canonical.x-(t.canonical.x>>n<<n),s=t.canonical.y-(t.canonical.y>>n<<n),a=e.ck(new Float64Array(16),[1/(e.af<<n),1/(e.af<<n),0]);e.a3(a,a,[o*e.af,s*e.af,0]),this._demMatrixCache[t.key]={matrix:a,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(t){const e=this.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new x(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new x(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,e+=4)i[e+0]=255&r,i[e+1]=255&t,i[e+2]=r>>8<<4|t>>8,i[e+3]=0;const r=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new x(t,r,t.gl.RGBA,{premultiply:!1});return n.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,n=r.gl,o=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),n.readPixels(o,a-s-1,1,1,n.RGBA,n.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,p=(1<<u.tileID.canonical.z)*d;return new e.ag((u.tileID.canonical.x*d+l)/p+u.tileID.wrap,(u.tileID.canonical.y*d+c)/p,this.getElevation(u.tileID,l,c,d))}depthAtPoint(t){const e=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){var i;const r=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,n=r&&0===t.canonical.y,o=r&&t.canonical.y===(1<<t.canonical.z)-1,s=`m_${n?"n":""}_${o?"s":""}`;if(this._meshCache[s])return this._meshCache[s];const a=this.painter.context,l=new e.cl,c=new e.aK,h=this.meshSize,u=e.af/h,d=h*h;for(let t=0;t<=h;t++)for(let e=0;e<=h;e++)l.emplaceBack(e*u,t*u,0);for(let t=0;t<d;t+=h+1)for(let e=0;e<h;e++)c.emplaceBack(e+t,h+e+t+1,h+e+t+2),c.emplaceBack(e+t,h+e+t+2,e+t+1);const p=l.length,f=p+(h+1),m=(h+1)*h,g=n?e.b9:0,_=n?0:1,y=o?e.ba:e.af,x=o?0:1;for(let t=0;t<=h;t++)l.emplaceBack(t*u,g,_);for(let t=0;t<=h;t++)l.emplaceBack(t*u,y,x);for(let t=0;t<h;t++)c.emplaceBack(m+t,f+t,f+t+1),c.emplaceBack(m+t,f+t+1,m+t+1),c.emplaceBack(0+t,p+t+1,p+t),c.emplaceBack(0+t,0+t+1,p+t+1);const v=l.length,b=v+2*(h+1);for(const t of[0,1])for(let i=0;i<=h;i++)for(const r of[0,1])l.emplaceBack(t*e.af,i*u,r);for(let t=0;t<2*h;t+=2)c.emplaceBack(v+t,v+t+1,v+t+3),c.emplaceBack(v+t,v+t+3,v+t+2),c.emplaceBack(b+t,b+t+3,b+t+1),c.emplaceBack(b+t,b+t+2,b+t+3);const w=new Me(a.createVertexBuffer(l,zo.members),a.createIndexBuffer(c),e.aJ.simpleSegment(0,0,l.length,c.length));return this._meshCache[s]=w,w}getMeshFrameDelta(t){return 2*Math.PI*e.bu/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,e){var i;const{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(t,e);return null!==(i=this.getMinMaxElevation(r).minElevation)&&void 0!==i?i:0}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){const r=e.ag.fromLngLat(t.wrap()),n=(1<<i)*e.af,o=r.x*n,s=r.y*n,a=Math.floor(o/e.af),l=Math.floor(s/e.af);return{tileID:new e.ae(i,0,i,a,l),mercatorX:o,mercatorY:s}}}class Ro{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new x(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((e=>t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];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)&&!1===this._objects.some((t=>!t.inUse))}}const Fo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Bo{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Ro(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsAscending={};for(const e in t.sourceCaches){this._coordsAscending[e]={};const i=t.sourceCaches[e].getVisibleCoordinates(),r=t.sourceCaches[e].getSource(),n=r instanceof Mt?r.terrainTileRanges:null;for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t,n);for(const t in i)this._coordsAscending[e][t]||(this._coordsAscending[e][t]=[]),this._coordsAscending[e][t].push(i[t])}}this._coordsAscendingStr={};for(const e of t._order){const i=t._layers[e],r=i.source;if(Fo[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const t in this._coordsAscending[r])this._coordsAscendingStr[r][t]=this._coordsAscending[r][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsAscendingStr){const i=this._coordsAscendingStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t,i){if(t.isHidden(this.painter.transform.zoom))return!1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),n=t.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Fo[n]&&(this._prevType&&Fo[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!s))return!0;if(Fo[this._prevType]||Fo[n]&&s){this._prevType=n;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const n of this._renderableTiles){if(this.pool.isFull()&&(Pn(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(n),n.rtt[t]){const e=this.pool.getObjectForId(n.rtt[t].id);if(e.stamp===n.rtt[t].stamp){this.pool.useObject(e);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),n.rtt[t]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:e.b7.transparent,stencil:0}),o.currentStencilSource=void 0;for(let t=0;t<i.length;t++){const e=o.style._layers[i[t]],a=e.source?this._coordsAscending[e.source][n.tileID.key]:[n.tileID];o.context.viewport.set([0,0,s.fbo.width,s.fbo.height]),o._renderTileClippingMasks(e,a,!0),o.renderLayer(o,o.style.sourceCaches[e.source],e,a,r),e.source&&(n.rttCoords[e.source]=this._coordsAscendingStr[e.source][n.tileID.key])}}return Pn(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),Fo[n]}return!1}}const Oo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},jo=i,No={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Io,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],scale:1,cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},Vo={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Uo{constructor(t,i,r=!1){this.mousedown=t=>{this.startMove(t,a.mousePos(this.element,t,this.map.getScale())),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,a.mousePos(this.element,t,this.map.getScale()))},this.mouseup=t=>{this._rotatePitchHanlder.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,t.targetTouches,this.map.getScale())[0],this.startMove(t,this._startPos),a.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,t.targetTouches,this.map.getScale())[0],this.move(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&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._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const n=new Qn;this._rotatePitchHanlder=new Xn({clickTolerance:3,move:(t,n)=>{const o=i.getBoundingClientRect(),s=new e.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:e.cd(new e.P(t.x,n.y),n,s),pitchDelta:r?-.5*(n.y-t.y):void 0}},moveStateManager:n,enable:!0,assignEvents:()=>{}}),this.map=t,a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchcancel",this.reset)}startMove(t,e){this._rotatePitchHanlder.dragStart(t,e),a.disableDrag()}move(t,e){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHanlder.dragMove(t,e)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const t=this.element;a.removeEventListener(t,"mousedown",this.mousedown),a.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend),a.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend)}}let Zo;function $o(t,i,r,n=!1){if(n||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==t?void 0:t.wrap();const o=new e.a8(t.lng,t.lat);if(t=new e.a8(t.lng,t.lat),i){const n=new e.a8(t.lng-360,t.lat),o=new e.a8(t.lng+360,t.lat),s=r.locationToScreenPoint(t).distSqr(i);r.locationToScreenPoint(n).distSqr(i)<s?t=n:r.locationToScreenPoint(o).distSqr(i)<s&&(t=o)}for(;Math.abs(t.lng-r.center.lng)>180;){const e=r.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:o}const Go={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 qo(t,e,i){const r=t.classList;for(const t in Go)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}class Wo extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._lngLat=$o(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),a.setTransform(this._element,`${Go[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.l("dragstart"))),this.fire(new e.l("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),"active"===this._state&&this.fire(new e.l("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=a.create("div");const i=a.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${n}px`),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const o=a.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=a.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=a.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{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 t of c){const e=a.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const h=a.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=a.createNS("http://www.w3.org/2000/svg","path");u.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"),h.appendChild(u);const d=a.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=a.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=a.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=a.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=a.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=a.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),qo(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",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),a.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.a8.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 e=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-13.5,-1*(e-i)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const t=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==t&&(this._element.style.opacity=t))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const n=this._map,o=n.terrain.depthAtPoint(this._pos),s=n.terrain.getElevationForLngLatZoom(this._lngLat,n.transform.tileZoom);if(n.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return void(this._element.style.opacity=this._opacity);const a=-this._offset.y/n.transform.pixelsPerMeter,l=Math.sin(n.getPitch()*Math.PI/180)*a,c=n.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),h=n.transform.lngLatToCameraDepth(this._lngLat,s+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.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&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return(void 0===this._opacity||void 0===t&&void 0===e)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Ho={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Xo=0,Ko=!1;const Yo={maxWidth:100,unit:"metric"};function Jo(t,e,i){const r=i&&i.maxWidth||100,n=t._container.clientHeight/2,o=t._container.clientWidth/2,s=t.unproject([o-r/2,n]),a=t.unproject([o+r/2,n]),l=Math.round(t.project(a).x-t.project(s).x),c=Math.min(r,l,t._container.clientWidth),h=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Qo(e,c,i/5280,t._getUIString("ScaleControl.Miles")):Qo(e,c,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?Qo(e,c,h/1852,t._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Qo(e,c,h/1e3,t._getUIString("ScaleControl.Kilometers")):Qo(e,c,h,t._getUIString("ScaleControl.Meters"))}function Qo(t,e,i,r){const n=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(n/i)+"px",t.innerHTML=`${n} ${r}`}const ts={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},es=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function is(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return is(new e.P(0,0))}const rs=i;t.AJAXError=e.cq,t.Event=e.l,t.Evented=e.E,t.LngLat=e.a8,t.MercatorCoordinate=e.ag,t.Point=e.P,t.addProtocol=e.cr,t.config=e.a,t.createExpression=e.ct,t.removeProtocol=e.cs,t.AttributionControl=Ao,t.BoxZoomHandler=$n,t.CanvasSource=Ct,t.CooperativeGesturesHandler=wo,t.DoubleClickZoomHandler=go,t.DragPanHandler=xo,t.DragRotateHandler=vo,t.EdgeInsets=Ee,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.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(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){a.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=a.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);a.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_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 e.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},t.GeoJSONSource=Pt,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.l("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&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const i=new e.a8(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.e({bearing:n},this.options.fitBoundsOptions),s=xt.fromLngLat(i,r);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const i=new e.a8(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).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(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Ko)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=a.create("button","maplibregl-ctrl-geolocate",this._container),a.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=a.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Wo({element:this._dotElement}),this._circleElement=a.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Wo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.l("trackuserlocationend")),this.fire(new e.l("userlocationlostfocus")))}))}},this.options=e.e({},Ho,t)}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==Zo&&!t)return Zo;if(void 0===window.navigator.permissions)return Zo=!!window.navigator.geolocation,Zo;try{const t=yield window.navigator.permissions.query({name:"geolocation"});Zo="denied"!==t.state}catch(t){Zo=!!window.navigator.geolocation}return Zo}))}().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),a.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Xo=0,Ko=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.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 t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),r=e.distanceTo(i),n=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}trigger(){if(!this._setup)return e.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 e.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Xo--,Ko=!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 e.l("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 e.l("trackuserlocationstart")),this.fire(new e.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Xo++,Xo>1?(t={maximumAge:6e5,timeout:0},Ko=!0):(t=this.options.positionOptions,Ko=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}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)}},t.GlobeControl=class{constructor(){this._toggleProjection=()=>{var t;const e=null===(t=this._map.getProjection())||void 0===t?void 0:t.type;this._map.setProjection("mercator"!==e&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var t;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(t=this._map.getProjection())||void 0===t?void 0:t.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=a.create("button","maplibregl-ctrl-globe",this._container),a.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},t.Hash=In,t.ImageSource=Mt,t.KeyboardHandler=uo,t.LngLatBounds=xt,t.LogoControl=Eo,t.Map=class extends Co{constructor(t){var i,r;e.cm.mark(e.cn.create);const n=Object.assign(Object.assign(Object.assign({},No),t),{canvasContextAttributes:Object.assign(Object.assign({},No.canvasContextAttributes),t.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Be,s=new Ve;if(void 0!==n.minZoom&&o.setMinZoom(n.minZoom),void 0!==n.maxZoom&&o.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&o.setMinPitch(n.minPitch),void 0!==n.maxPitch&&o.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&o.setRenderWorldCopies(n.renderWorldCopies),super(o,s,{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ko,this._controls=[],this._mapId=e.al(),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.l("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.l("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=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},Oo),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this._dynamicScale=n.scale,this._imageQueueHandle=f.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(n.transformRequest),"string"==typeof n.container){if(this._container=document.getElementById(n.container),!this._container)throw new Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.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})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=Cn((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new So(this,n),this._hash=n.hash&&new In("string"==typeof n.hash&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,e.e({},n.fitBoundsOptions,{duration:0}))));const a="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,a),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style?this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}):null===n.style&&this._lazyInitEmptyStyle(),n.attributionControl&&this.addControl(new Ao("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Eo,n.logoPosition),this.on("style.load",(()=>{if(a||this._resizeTransform(),this.transform.unmodified){const t=e.a7(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.l(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.l(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.l("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(t,i=!0){const[r,n]=this._containerDimensions(),o=this.getScale(),s=this._getClampedPixelRatio(r,n);if(this._resizeCanvas(r,n,s),this.painter.resize(r,n,s,o),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(r,n);this._resizeCanvas(r,n,e),this.painter.resize(r,n,e,o)}this._resizeTransform(i);const a=!this._moving;return a&&(this.stop(),this.fire(new e.l("movestart",t)).fire(new e.l("move",t))),this.fire(new e.l("resize",t)),a&&this.fire(new e.l("moveend",t)),this}_resizeTransform(t=!0){var e;const[i,r]=this._containerDimensions(),n=this.getScale(),o=i/n,s=r/n;this.transform.resize(o,s,t),null===(e=this._requestedCameraState)||void 0===e||e.resize(o,s,t)}_getClampedPixelRatio(t,e){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),o=t*n,s=e*n;return Math.min(o>i?i/o:1,s>r?r/s:1)*n}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getScale(){return this._dynamicScale}setScale(t){this._dynamicScale=t,this.resize()}getDetailLevel(){return this.transform.detailLevel}setDetailLevel(t){this.transform.setDetailLevel(t),this._update()}getRasterAlignment(){return this.transform.rasterAlignment}setRasterAlignment(t){this.transform.setRasterAlignment(t),this._update()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(xt.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.setMinZoom(t),this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.setMaxZoom(t),this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.setMinPitch(t),this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>180)throw new Error("maxPitch must be less than or equal to 180");if(t>=this.transform.minPitch)return this.transform.setMaxPitch(t),this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.setRenderWorldCopies(t),this._update()}project(t){return this.transform.locationToScreenPoint(e.a8.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this.terrain)}projectWithScaleCorrection(t){return this.project(t).mult(this.getScale())}unprojectWithScaleCorrection(t){return this.unproject(e.P.convert(t).div(this.getScale()))}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t))),s=0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new On(t,this,n.originalEvent,{features:s}))):r=!1};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t)));(0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new On(t,this,n.originalEvent)))},o=e=>{r&&(r=!1,i.call(this,new On(t,this,e.originalEvent)))};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),n=0!==r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:e,listener:i,delegates:{[t]:r}}}}_saveDelegatedListener(t,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(e)}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners||!this._delegatedListeners[t])return;const r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){const n=r[t];if(n.listener===i&&n.layers.length===e.length&&n.layers.every((t=>e.includes(t)))){for(const t in n.delegates)this.off(t,n.delegates[t]);return void r.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);this._saveDelegatedListener(t,n);for(const t in n.delegates)this.on(t,n.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,r,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);for(const e in n.delegates){const o=n.delegates[e];n.delegates[e]=(...e)=>{this._removeDelegatedListener(t,r,i),o(...e)}}this._saveDelegatedListener(t,n);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,i){if(!this.style)return[];let r;const n=t instanceof e.P||Array.isArray(t),o=n?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(n?{}:t)||{},o instanceof e.P||"number"==typeof o[0])r=[e.P.convert(o)];else{const t=e.P.convert(o[0]),i=e.P.convert(o[1]);r=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){var i,r;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Ti(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,n):this.style.loadJSON(t,e,n),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ti(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){const r=this._requestManager.transformRequest(t,"Style");e.j(r,new AbortController).then((t=>{this._updateDiff(t.data,i)})).catch((t=>{t&&this.fire(new e.k(t))}))}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(r){e.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.k(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.sourceCaches[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===t.source&&e.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 Do(this.painter,i,t),this.painter.renderToTexture=new Bo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=e=>{var i;"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=e.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(e.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.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new e.l("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}setSourceTileLodParams(t,e,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=Gt(Math.max(1,t),Math.max(1,e))}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=Gt(Math.max(1,t),Math.max(1,e));return this._update(!0),this}addImage(t,i,r={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.k(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:r,height:s,data:d}=i,p=i;return this.style.addImage(t,{data:new e.R({width:r,height:s},new Uint8Array(d)),pixelRatio:n,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,t),this}}{const{width:r,height:d,data:p}=s.getImageData(i);this.style.addImage(t,{data:new e.R({width:r,height:d},p),pixelRatio:n,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:o,version:0})}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return this.fire(new e.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||e.b(i)?s.getImageData(i):i,{width:o,height:a,data:l}=n;if(void 0===o||void 0===a)return this.fire(new e.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||a!==r.data.height)return this.fire(new e.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||e.b(i));return r.data.replace(l,c),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.k(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}addImages(t){this.style.addImages(t)}loadImage(t){return f.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayersOrder(t){return this._lazyInitEmptyStyle(),this.style.setLayersOrder(t),this._update(!0)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}loadSprite(t){return y(t,this._requestManager,this.getPixelRatio()*this.getScale(),new AbortController).then((t=>{var e;return null!==(e=t.default)&&void 0!==e?e:{}}))}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=a.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=a.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=a.create("div","maplibregl-control-container",t),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{o[t]=a.create("div",`maplibregl-ctrl-${t} `,n)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,t):this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t),!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Sn(i,this.transform),l.testSupport(i)}migrateProjection(t,i){super.migrateProjection(t,i),this.painter.transform=t,this.fire(new e.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){var i,r,n,o,a;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=s.now();this.style.zoomHistory.update(t,i);const r=new e.C(t,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(h=!0,this._crossFadingFactor=n),this.style.update(r)}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(n=this.style.projection)||void 0===n||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(a=this.style.projection)||void 0===a?void 0:a.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new e.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.cm.mark(e.cn.load),this.fire(new e.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,e.cm.mark(e.cn.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),f.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),a.remove(this._canvasContainer),a.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),e.cm.clearMetrics(),this._removed=!0,this.fire(new e.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(t=>{e.cm.frame(t),this._frameRequest=null;try{this._render(t)}catch(t){if(!e.co(t)&&!function(t){return t.message===Gr}(t))throw t}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return jo}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}setLabelFreeAreas(t){this.style.setLabelFreeAreas(t)&&this.triggerRepaint()}getGlyphMap(t,e){const i=this.style.glyphManager,r=new Set;for(let e=0;e<t.length;e++)r.add(t.charCodeAt(e));return i.getGlyphMap(e,Array.from(r))}getLineBreaks(t,i,r,n,o,s=this.getGlyphMap(t,i)){return e.cp(t,i,r,n,o,s).map((({text:t})=>t))}},t.MapMouseEvent=On,t.MapTouchEvent=jn,t.MapWheelEvent=Nn,t.Marker=Wo,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},Vo,t),this._container=a.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}))),a.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}))),a.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=a.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,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.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Uo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){a.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.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=a.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0)},this.remove=()=>(this._content&&a.remove(this._content),this._container&&(a.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.l("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=a.create("div","maplibregl-popup",this._map.getContainer()),this._tip=a.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=$o(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const e=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=is(this.options.offset);if(!i){const t=this._container.offsetWidth,n=this._container.offsetHeight;let o;o=e.y+r.bottom.y<n?["top"]:e.y>this._map.transform.height-n?["bottom"]:[],e.x<t/2?o.push("left"):e.x>this._map.transform.width-t/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let n=e.add(r[i]);this.options.subpixelPositioning||(n=n.round()),a.setTransform(this._container,`${Go[i]} translate(${n.x}px,${n.y}px)`),qo(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(ts),t)}addTo(t){return this._map&&this.remove(),this._map=t,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 e.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.a8.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=a.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=a.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(es);t&&t.focus()}},t.RasterDEMTileSource=Tt,t.RasterTileSource=wt,t.ScaleControl=class{constructor(t){this._onMove=()=>{Jo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Jo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Yo),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){a.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=mo,t.Style=Ti,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=a.create("button","maplibregl-ctrl-terrain",this._container),a.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(){a.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=co,t.TwoFingersTouchRotateHandler=ao,t.TwoFingersTouchZoomHandler=oo,t.TwoFingersTouchZoomRotateHandler=bo,t.VectorTileSource=bt,t.VideoSource=St,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,(function*(){if(At(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{It[t]=e})(t,i)})),t.clearPrewarmedResources=function(){const t=R;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(z),R=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()"))},t.createTileMesh=Je,t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return Lt().getRTLTextPluginStatus()},t.getVersion=function(){return rs},t.getWorkerCount=function(){return L.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return j().broadcast("IS",t)},t.prewarm=function(){B().acquire(z)},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setRTLTextPlugin=function(t,e){return Lt().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){L.workerCount=t},t.setWorkerUrl=function(t){e.a.WORKER_URL=t}})),t}()},296:function(t){t.exports=JSON.parse('{"loadingSettings":"Cargando configuración","errorLoadingSettings":"Error al cargar la configuración","loadCandidates":"Cargando los datos del candidato","errorLoadingCandidates":"Error al cargar los datos de los candidatos","loadingResults":"Cargando los resultados","errorLoadingResults":"Error al cargar los resultados","updatedOn":"Actualizado el {date} a las {time}","checkingForData":"Comprobando nuevos datos en {time}"}')},427:function(t){t.exports=JSON.parse('{"loadingSettings":"Instellingen aan het laden","errorLoadingSettings":"Fout bij het laden van de instellingen","loadCandidates":"Kandidaat data aan het laden","errorLoadingCandidates":"Fout bij het laden van kandidaat data","loadingResults":"Resultaten aan het laden","errorLoadingResults":"Fout bij het laden van de resultaten","updatedOn":"Geüpdatet op {date} om {time}","checkingForData":"Controleren op nieuwe data over: {time}"}')},435:function(t){t.exports=JSON.parse('{"goBack":"Retour en arrière","notice":"Utilisez deux doigts pour déplacer la carte"}')},485:function(t){t.exports=JSON.parse('{"loadingSettings":"Caricamento impostazioni","errorLoadingSettings":"Errore caricamento impostazioni","loadCandidates":"Caricamento dati candidato","errorLoadingCandidates":"Errore caricamento dati candidato","loadingResults":"Caricamento risultati","errorLoadingResults":"Errore caricamento risultati","updatedOn":"Aggiornato il {date} alle {time}","checkingForData":"Controllo nuovi dati in: {time}"}')},508:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},510:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},513:function(t){t.exports=JSON.parse('{"goBack":"Zurück","notice":"Verwenden Sie zwei Finger um die Karte zu bewegen"}')},554:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Stemmer","reporting":"{percentage}% optalt","ev":"VM","electoralVotes":"Valgmænd","unknown":"Ukendt"}')},648:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for { interpolate }","allResults":"All results","candidateList":"Candidate list"}')},655:function(t){t.exports=JSON.parse('{"loadingSettings":"Chargement des paramètres","errorLoadingSettings":"Erreur lors du chargement des paramètres","loadCandidates":"Chargement des données du candidat","errorLoadingCandidates":"Erreur de chargement des candidats","loadingResults":"Chargement des résultats","errorLoadingResults":"Erreur de chargement des résultats","updatedOn":"{date} à {time} ","checkingForData":"mise à jour dans : {time}"}')},656:function(t,e){var i,r,n;r=[],i=function(){function t(t,e){for(var i in t)t.hasOwnProperty(i)&&e(i,t[i])}function e(){var i={},r="en",n=/{{\s*(\w+)\s*}}/g,o={en:{pluralizeTo:"count",getVariationIndex:function(t){return 1===t?0:1}}};function s(t,e,n){var o=(n=n||{}).locale||r,c=n.registry||i,h=c[o]&&c[o][t];return void 0===h?s.whenUndefined(t,o):Array.isArray(h)?a(t,h,e,o,n.pluralizeTo):l(h,e)}function a(t,e,i,r,n){var s=o[r],a=Object.keys(i),c=1===a.length?a[0]:n||s.pluralizeTo,h=parseFloat(i[c]);if(isNaN(h))throw new Error('Tranlation pluralization missing parameters on key "'+t+'"');return l(e[s.getVariationIndex(h)],i)}function l(t,e){return e?t.replace(n,(function(t,i){return e.hasOwnProperty(i)?e[i]:t})):t}return s.add=function(e,n,o){return i[n=n||r]=i[n]||{},t(e,(function(t,e){var r=o?o+"."+t:t,a=typeof e;Array.isArray(e)||"string"===a||"number"===a?i[n][r]=e:s.add(e,n,r)})),this},s.setLocale=function(t){return r=t,this},s.getLocale=function(){return r},s.interpolateWith=function(t){return n=t,this},s.setPluralizationRule=function(t,e,i){return o[t]={pluralizeTo:i&&i.pluralizeTo||"count",getVariationIndex:e},this},s.whenUndefined=function(t,e){return t},s.clear=function(){return i={},this},s.createRegistry=function(){return e()},s}return e()},void 0===(n="function"==typeof i?i.apply(e,r):i)||(t.exports=n)},743:function(t){t.exports=JSON.parse('{"goBack":"Gå tilbage","notice":"Brug to fingre til at navigere i kortet"}')},768:function(t){t.exports=JSON.parse('{"party":"Partei","votes":"Stimmen","reporting":"Wahlbeteiligung {percentage}%","ev":"WL","electoralVotes":"Wahlleute","unknown":"Unbekannt"}')},794:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},803:function(t){t.exports=JSON.parse('{"loadingSettings":"Henter indstillinger","errorLoadingSettings":"Fejl i indstillinger","loadCandidates":"Henter data om kandidat","errorLoadingCandidates":"Fejl i kandidatens data","loadingResults":"Henter resultat","errorLoadingResults":"Fejl i resultater","updatedOn":"Opdateret {date} kl. {time}","checkingForData":"Opdaterer resultat om: {time}"}')},845:function(t,e,i){var r={"./da_DK/frElections2022.json":988,"./da_DK/fullscreen.json":743,"./da_DK/usElectionsFixedPopup.json":554,"./da_DK/usElectionsUpdater.json":803,"./de_DE/frElections2022.json":173,"./de_DE/fullscreen.json":513,"./de_DE/usElectionsFixedPopup.json":768,"./de_DE/usElectionsUpdater.json":241,"./en_GB/frElections2022.json":648,"./en_GB/fullscreen.json":883,"./en_GB/geoLocation.json":160,"./en_GB/placeholder.json":915,"./en_GB/search.json":794,"./en_GB/usElectionsFixedPopup.json":158,"./en_GB/usElectionsUpdater.json":55,"./es_ES/frElections2022.json":508,"./es_ES/fullscreen.json":919,"./es_ES/usElectionsFixedPopup.json":130,"./es_ES/usElectionsUpdater.json":296,"./fr_FR/frElections2022.json":968,"./fr_FR/fullscreen.json":435,"./fr_FR/usElectionsFixedPopup.json":134,"./fr_FR/usElectionsUpdater.json":655,"./it_IT/frElections2022.json":510,"./it_IT/fullscreen.json":53,"./it_IT/usElectionsFixedPopup.json":852,"./it_IT/usElectionsUpdater.json":485,"./nl_NL/frElections2022.json":140,"./nl_NL/fullscreen.json":903,"./nl_NL/usElectionsFixedPopup.json":34,"./nl_NL/usElectionsUpdater.json":427};function n(t){var e=o(t);return i(e)}function o(t){if(!i.o(r,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r[t]}n.keys=function(){return Object.keys(r)},n.resolve=o,t.exports=n,n.id=845},852:function(t){t.exports=JSON.parse('{"party":"Partito","votes":"Voti","reporting":"{percentage}% Copertura","ev":"V.E.","electoralVotes":"Voti Elettorali","unknown":"Sconosciuto"}')},883:function(t){t.exports=JSON.parse('{"goBack":"Go back","notice":"Use two fingers to move the map"}')},903:function(t){t.exports=JSON.parse('{"goBack":"Ga terug","notice":"Gebruik twee vingers om de kaart te bewegen"}')},915:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')},919:function(t){t.exports=JSON.parse('{"goBack":"Vuelve atrás","notice":"Usa dos dedos para mover el mapa"}')},968:function(t){t.exports=JSON.parse('{"showMore":"Voir plus","showLess":"Voir moins","tapFor":"Résutats de {alternative}","allResults":"Tous les résultats","candidateList":"Liste des candidats"}')},988:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,i),o.exports}function r(t,e=void 0){return e||(e=window.location.href),new URL(e).searchParams.get(t)}i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function n(t){let e=t.split("").map((t=>t.charCodeAt(0))).reduce(((t,e)=>(t^=e)+(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)),2166136261);return e^=e<<3,e+=e>>5,e^=e<<4,e+=e>>17,e^=e<<25,e+=e>>6,`0000000${(e>>>0).toString(16)}`.substr(-8)}let o;function s(){return void 0!==o&&("bleeding"===o||"development"===o)}function a(){return void 0!==o&&"beta"===o}function l(){try{return window.self!==window.top}catch(t){return!0}}class c{mapOptions;options;_favicon;constructor(t,e){this.mapOptions={...this.constructor.defaultMapOptions,...e},this.options={...this.constructor.defaultOptions,...t},this.options.libraryMode||(this.updateTitle(),this.updateFavicon())}static get defaultMapOptions(){return{container:document.getElementsByClassName("map")[0],attributionControl:!1,style:null}}static get defaultOptions(){return{noBounds:"true"===r("noBounds"),language:navigator.language||navigator.userLanguage}}updateTitle(){const t=document.querySelector("title");t.innerText=`${this.title} – ${t.innerText}`}updateFavicon(){this._favicon=document.createElement("link"),this._favicon.setAttribute("href",this.favicon),this._favicon.setAttribute("rel","shortcut icon"),this._favicon.parentElement!==document.head&&document.head.appendChild(this._favicon)}get favicon(){throw new Error("Unimplemented")}get title(){return"Unimplemented"}}var h=i(264);const u=Object.freeze({THREE:"ISO 639-2/B",API:"ISO 639-2/B",TWO:"ISO 639-1",MAPLIBRE_COMPAT:"ISO 639-1",ENDONYM:"name",NAME:"name",LOCALE:"locale",i18n:"locale"});var d=u;const p=Object.freeze([{[u.TWO]:"en",[u.THREE]:"eng",[u.ENDONYM]:"English",[u.LOCALE]:"en_GB"},{[u.TWO]:"da",[u.THREE]:"dan",[u.ENDONYM]:"Dansk",[u.LOCALE]:"da_DK"},{[u.TWO]:"nl",[u.THREE]:"dut",[u.ENDONYM]:"Nederlands",[u.LOCALE]:"nl_NL"},{[u.TWO]:"fi",[u.THREE]:"fin",[u.ENDONYM]:"Suomi",[u.LOCALE]:"fi_FI"},{[u.TWO]:"fr",[u.THREE]:"fre",[u.ENDONYM]:"Francais",[u.LOCALE]:"fr_FR"},{[u.TWO]:"de",[u.THREE]:"ger",[u.ENDONYM]:"Deutsch",[u.LOCALE]:"de_DE"},{[u.TWO]:"it",[u.THREE]:"ita",[u.ENDONYM]:"Italiano",[u.LOCALE]:"it_IT"},{[u.TWO]:"no",[u.THREE]:"nor",[u.ENDONYM]:"Norsk",[u.LOCALE]:"nn_NO"},{[u.TWO]:"pl",[u.THREE]:"pol",[u.ENDONYM]:"Polski",[u.LOCALE]:"pl_PL"},{[u.TWO]:"pt",[u.THREE]:"por",[u.ENDONYM]:"Portugues",[u.LOCALE]:"pt_PT"},{[u.TWO]:"es",[u.THREE]:"spa",[u.ENDONYM]:"Espanol",[u.LOCALE]:"es_ES"},{[u.TWO]:"sv",[u.THREE]:"swe",[u.ENDONYM]:"Svenska",[u.LOCALE]:"sv_SE"},{[u.TWO]:"ja",[u.THREE]:"jpn",[u.ENDONYM]:"日本語",[u.LOCALE]:"ja_JP"},{[u.TWO]:"zh",[u.THREE]:"chi",[u.ENDONYM]:"汉语",[u.LOCALE]:"zh_CN"},{[u.TWO]:"ru",[u.THREE]:"rus",[u.ENDONYM]:"Русский",[u.LOCALE]:"ru_RU"},{[u.TWO]:"uk",[u.THREE]:"ukr",[u.ENDONYM]:"Украї́нська",[u.LOCALE]:"uk_UK"},{[u.TWO]:"lv",[u.THREE]:"lav",[u.ENDONYM]:"Latviešu valoda",[u.LOCALE]:"lv-LV"},{[u.TWO]:"kk",[u.THREE]:"kaz",[u.ENDONYM]:"қазақша",[u.LOCALE]:"kk-KZ"},{[u.TWO]:"ar",[u.THREE]:"ara",[u.ENDONYM]:"Arabic",[u.LOCALE]:"ar_SA"},{[u.TWO]:"native",[u.THREE]:"native",[u.ENDONYM]:"Native",[u.LOCALE]:"native"}]);function f(t,e=u.MAPLIBRE_COMPAT){return(p.find((e=>Object.values(e).some((e=>e===t))))||p[0])[e]}var m={get id(){return r("id")},get accessToken(){return r("access-token")||document.querySelector("meta[name=mc-access-token]")?.getAttribute("content")},get debug(){return"true"===r("debug")},get productionJob(){return"true"===r("debug")||!s},vectorApiUrl:"https://vapi.mc-cdn.io/",get objectUrl(){return this.id?this.accessToken?this.productionJob?a()?`https://cdn.beta.mapcreator.io/jobs/${this.id}.json`:`https://cdn.mapcreator.io/jobs/${this.id}.json`:`https://cdn.bleeding.mapcreator.io/jobs/${this.id}.json`:`https://dynamic.maps4news.com/${this.id}/map.json`:location.href.replace(/(\/|\/[^/]+\.[^/.]+)?$/,"/map.json")}},g=i(656);var _=new class{fallbackLocale;constructor(t,e=void 0){g.interpolateWith(/{\s*(\w+)\s*}/g);for(const[t,e]of Object.entries(this._loadLocaleMessages()))g.add(e,t);this.locale=t,this.fallbackLocale=e??t}get locale(){return g.getLocale()}set locale(t){g.setLocale(t)}get localeMaplibreCompat(){return this.locale.substr(0,2)}get localeWithPreferredRegion(){return navigator.languages.find((t=>t.startsWith(`${this.localeMaplibreCompat}-`)))?.replace("-","_")??this.locale}t(t,e={interpolate:void 0},i=this.locale){const r=g(t,e,{locale:i});return t===r?i===this.fallbackLocale?t:g(t,e,{locale:this.fallbackLocale}):r}_loadLocaleMessages(){const t=i(845),e={};for(const i of t.keys()){const r=i.match(/\/([a-z_/]+)\/([a-z0-9-_]+)\./i);if(!r?.length)continue;const n=r[1].split("/");let o=e;for(const t of n)o.hasOwnProperty(t)||(o[t]={}),o=o[t];o[r[2]]=t(i)}return e}}("en_GB");function y(t){return t/180*Math.PI}function x(t){return 180*t/Math.PI}function v(t,e){const i=Math.PI/180,r=t.lat*i,n=e.lat*i,o=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-t.lng)*i);return 6371e3*Math.acos(Math.min(o,1))}function b(t,e=null){return t=t.replace("maps4news.com","mapcreator.io"),s()?t=(t=t.replace(/vapi\.(mc-cdn|mapcreator)/,"vapi.bleeding.$1")).replace("://cdn.mapcreator.io/live-data-layers/live/","://cdn.mapcreator.io/live-data-layers/bleeding/"):a()&&(t=t.replace(/vapi\.(mc-cdn|mapcreator)/,"vapi.beta.$1")),e&&/vapi\..*(mc-cdn|mapcreator)\.io/.test(t)&&(t=`${t}?access_token=${e}`),t}function w(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}function T(t){if(t=t.trim(),/^\$?[\w\-_]+$/.test(t))return t;return(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/.exec(t)||[])[1]}function P(t,e,i){if(t===e)return i;const r={millimeter:1,centimeter:.1,meter:.001,kilometer:1e-6,foot:.00328084,mile:6.21371e-7,nauticalMile:5.39957e-7,inch:.0393701,pixel:2.8346472,pica:.236222};return i/r[t]*r[e]}const M={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function S(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:w((e=t).id),properties:{id:e.id,"line-width":e.lineWidth??3,"line-color":e.lineColor??"#000000","line-style":e.lineStyle??"solid"},geometry:{type:"LineString",coordinates:e.geometry}};var e}))}});for(const r in M)e.models.some((t=>(t.lineStyle??"solid")===r))&&t.addLayer({id:`${e.id}-${r}`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},filter:["==",["get","line-style"],r],paint:{"line-width":["get","line-width"],"line-color":["get","line-color"],"line-dasharray":M[r]}},i);t.addLayer({id:`${e.id}-clickable`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},paint:{"line-width":["max",["get","line-width"],15],"line-opacity":0}},i)}var C=6371008.8;Math.PI;function I(t,e,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=e||{},r.geometry=t,r}function A(t,e,i={}){for(const e of t){if(e.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(e[e.length-1].length!==e[0].length)throw new Error("First and last Position are not equivalent.");for(let t=0;t<e[e.length-1].length;t++)if(e[e.length-1][t]!==e[0][t])throw new Error("First and last Position are not equivalent.")}return I({type:"Polygon",coordinates:t},e,i)}function E(t,e,i={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return I({type:"LineString",coordinates:t},e,i)}function k(t,e={}){const i={type:"FeatureCollection"};return e.id&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.features=t,i}function z(t,e,i={}){return I({type:"MultiLineString",coordinates:t},e,i)}function L(t,e,i={}){return I({type:"MultiPolygon",coordinates:t},e,i)}function D(t,e,i){if(null!==t)for(var r,n,o,s,a,l,c,h,u=0,d=0,p=t.type,f="FeatureCollection"===p,m="Feature"===p,g=f?t.features.length:1,_=0;_<g;_++){a=(h=!!(c=f?t.features[_].geometry:m?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<a;y++){var x=0,v=0;if(null!==(s=h?c.geometries[y]:c)){l=s.coordinates;var b=s.type;switch(u=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,d,_,x,v))return!1;d++,x++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],d,_,x,v))return!1;d++,"MultiPoint"===b&&x++}"LineString"===b&&x++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-u;n++){if(!1===e(l[r][n],d,_,x,v))return!1;d++}"MultiLineString"===b&&x++,"Polygon"===b&&v++}"Polygon"===b&&x++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(v=0,n=0;n<l[r].length;n++){for(o=0;o<l[r][n].length-u;o++){if(!1===e(l[r][n][o],d,_,x,v))return!1;d++}v++}x++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(!1===D(s.geometries[r],e,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function R(t,e){var i,r,n,o,s,a,l,c,h,u,d=0,p="FeatureCollection"===t.type,f="Feature"===t.type,m=p?t.features.length:1;for(i=0;i<m;i++){for(a=p?t.features[i].geometry:f?t.geometry:t,c=p?t.features[i].properties:f?t.properties:{},h=p?t.features[i].bbox:f?t.bbox:void 0,u=p?t.features[i].id:f?t.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,n=0;n<s;n++)if(null!==(o=l?a.geometries[n]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,d,c,h,u))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],d,c,h,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,d,c,h,u))return!1;d++}}function F(t,e){(e=e||{}).iterations=e.iterations||1;const{iterations:i}=e,r=[];if(!t)throw new Error("inputPolys is required");return R(t,(function(t,e,n){if("Polygon"===t.type){let e=[[]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=A(e).geometry),B(n,i),e=i.slice(0)}r.push(A(e,n))}else{if("MultiPolygon"!==t.type)throw new Error("geometry is invalid, must be Polygon or MultiPolygon");{let e=[[[]]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=L(e).geometry),O(n,i),e=i.slice(0)}r.push(L(e,n))}}})),k(r)}function B(t,e){var i,r;D(t,(function(t,n,o,s,a){if(r!==a)e.push([]);else{var l=i[0],c=i[1],h=t[0],u=t[1];e[a].push([.75*l+.25*h,.75*c+.25*u]),e[a].push([.25*l+.75*h,.25*c+.75*u])}i=t,r=a}),!1),e.forEach((function(t){t.push(t[0])}))}function O(t,e){let i,r,n;D(t,(function(t,o,s,a,l){if(r!==a)e.push([[]]);else if(n!==l)e[a].push([]);else{var c=i[0],h=i[1],u=t[0],d=t[1];e[a][l].push([.75*c+.25*u,.75*h+.25*d]),e[a][l].push([.25*c+.75*u,.25*h+.75*d])}i=t,r=a,n=l}),!1),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function j(t,e){var i,r,n,o,s,a,l;for(r=1;r<=8;r*=2){for(i=[],o=!(V(n=t[t.length-1],e)&r),s=0;s<t.length;s++)(l=!(V(a=t[s],e)&r))!==o&&i.push(N(n,a,r,e)),l&&i.push(a),n=a,o=l;if(!(t=i).length)break}return i}function N(t,e,i,r){return 8&i?[t[0]+(e[0]-t[0])*(r[3]-t[1])/(e[1]-t[1]),r[3]]:4&i?[t[0]+(e[0]-t[0])*(r[1]-t[1])/(e[1]-t[1]),r[1]]:2&i?[r[2],t[1]+(e[1]-t[1])*(r[2]-t[0])/(e[0]-t[0])]:1&i?[r[0],t[1]+(e[1]-t[1])*(r[0]-t[0])/(e[0]-t[0])]:null}function V(t,e){var i=0;return t[0]<e[0]?i|=1:t[0]>e[2]&&(i|=2),t[1]<e[1]?i|=4:t[1]>e[3]&&(i|=8),i}function U(t,e){const i=[];for(const r of t){const t=j(r,e);t.length>0&&(t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]||t.push(t[0]),t.length>=4&&i.push(t))}return i}var Z=function(t,e){const i="Feature"===(r=t).type?r.geometry:r;var r;const n=i.type,o="Feature"===t.type?t.properties:{};let s=i.coordinates;switch(n){case"LineString":case"MultiLineString":{const t=[];return"LineString"===n&&(s=[s]),s.forEach((i=>{!function(t,e,i){var r,n,o,s=t.length,a=V(t[0],e),l=[];let c,h;for(i||(i=[]),r=1;r<s;r++){for(c=t[r-1],h=t[r],n=o=V(h,e);;){if(!(a|n)){l.push(c),n!==o?(l.push(h),r<s-1&&(i.push(l),l=[])):r===s-1&&l.push(h);break}if(a&n)break;a?(c=N(c,h,a,e),a=V(c,e)):(h=N(c,h,n,e),n=V(h,e))}a=o}l.length&&i.push(l)}(i,e,t)})),1===t.length?E(t[0],o):z(t,o)}case"Polygon":return A(U(s,e),o);case"MultiPolygon":return L(s.map((t=>U(t,e))),o);default:throw new Error("geometry "+n+" not supported")}};function $(t,e){const i=[],r=2*Math.PI/100;for(let n=0;n<100;n++)i.push(q(t,e,n*r));if(function(t,e){return v(t,{lng:0,lat:90})/1e3<e}(t,e)){const t=i[0],e=i[i.length-1],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.push([r,n]),i.push([r,90]),i.push([r+360,90]),i.push([r+360,n])}if(function(t,e){return v(t,{lng:0,lat:-90})/1e3<e}(t,e)){const t=i[49],e=i[50],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.splice(50,0,[r+360,n],[r+360,-90],[r,-90],[r,n])}return i.push(i[0]),i}function G(t,e,i){const r=[],n=e/100;for(let e=0;e<=100;e++)r.push(q(t,e*n,y(i)));const o=[-1/0,-85.051129,1/0,85.051129];return Z(E(r),o).geometry.coordinates}function q(t,e,i){const r=e/6378.1,n=y(t.lng),o=y(t.lat),s=Math.asin(Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(i));return[x(n+Math.atan2(Math.sin(i)*Math.sin(r)*Math.cos(o),Math.cos(r)-Math.sin(o)*Math.sin(s))),x(s)]}function W(t){const{polygonType:e}=t,i="number"==typeof t.anchorPoints?.[0]?.[0]?[t.anchorPoints]:t.anchorPoints;return"smooth"===e?F(A(i),{iterations:4}).features?.[0]?.geometry?.coordinates??i.slice():i.slice()}function H(t,e){return`${t}-${n(`${e.vectorUrl}/${e.sourceLayerId}`)}`}function X(t){return`custom-area-${n(t.vectorUrl)}`}function K(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i){const r=void 0!==t.fillPattern?i.getMaplibreImageKey(e[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":r,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":t.radiusLineColor??"#000000","radius-line-width":t.radiusLineWidth??0},geometry:{type:"GeometryCollection",geometries:[{type:"Polygon",coordinates:[$(t.center,t.radius)]},{type:"LineString",coordinates:G(t.center,t.radius,t.radiusLineBearing??0)}]}}}(t,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"circle","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-radius-line`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["all",["==",["geometry-type"],"LineString"],["get","radius-line-enabled"]],paint:{"line-color":["get","radius-line-color"],"line-width":["get","radius-line-width"]}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}function Y(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i,r){const n=void 0!==t.fillPattern?r.getMaplibreImageKey(i[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":n},geometry:{type:"Polygon",coordinates:W(t)}}}(t,e.id,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"polygon","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}let J;const Q="Roboto-Regular";function tt(t,e,i){const r=void 0!==t.svg?i.getMaplibreImageKey(e[t.svg],J*(t.iconScale??1)):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"mc-image-key":r,"icon-anchor":t.iconAnchor??"center","icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":t.iconScale??1,text:t.text,"text-anchor":t.textAnchor??"center","text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":t.textSize??16,"text-color":t.textColor??"#000000","text-halo-color":t.textHaloColor??"#000000","text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??"center"},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}}}function et(){return navigator.userAgent.toLowerCase().indexOf("mobile")>=0}function it(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[2]),t[3]=Math.max(t[3],e[3])}function rt(t){const e=Array.from(t.querySelectorAll("[mol_embed]"));0===e.length&&e.push(t);const i=document.body.contains(t);i||document.body.appendChild(t);const r=t.getBoundingClientRect(),n=e.map((t=>{const{x:e,y:i,width:r,height:n}=t.getBoundingClientRect();return[e,i,e+r,i+n]}));i||document.body.removeChild(t);const o=function(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)it(e,i);return e}(n);var s,a,l;return s=o,a=-r.x,l=-r.y,s[0]+=a,s[1]+=l,s[2]+=a,s[3]+=l,function(t){t[0]=Math.round(t[0]),t[1]=Math.round(t[1]),t[2]=Math.round(t[2]),t[3]=Math.round(t[3])}(o),o}async function nt(t,e,i){if(void 0!==window.InstallTrigger||t.length<2e6)try{return await function(t,e,i){const r=new Image;return r.width=e,r.height=i,new Promise(((e,i)=>{r.onload=()=>e(r),r.onerror=()=>i(new Error("Failed to quickly generate image from svg")),r.src=`data:image/svg+xml;base64,${btoa(t)}`}))}(t,e,i)}catch(t){}return async function(t,e,i){const r=new Image;r.width=e,r.height=i;const n=URL.createObjectURL(t);try{await new Promise(((t,e)=>{r.onload=()=>t(),r.onerror=()=>e(new Error("Failed to safely generate image from svg")),r.src=n}))}finally{URL.revokeObjectURL(n)}return r}(new Blob([t],{type:"image/svg+xml"}),e,i)}class ot{map;domParser;keyCache;infoCache;constructor(t){this.map=t,this.domParser=new DOMParser,this.keyCache=new Map,this.infoCache=new Map}getSvgInfo(t){if(!this.infoCache.has(t)){const e=this.domParser.parseFromString(t,"image/svg+xml").firstElementChild,i=e.width.baseVal.value,r=e.height.baseVal.value,n=rt(e),o=function(t,e,i){const r={},n={};if([,r.x=e/2,r.y=i/2]=(/mol_svganchor="\s*(-?[\d.]+)\s+(-?[\d.]+)\s*"/i.exec(t)||[]).map(Number.parseFloat),[,n.x=0,n.y=0,n.width=e,n.height=i]=(/view-?box="\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*"/i.exec(t)||[]).map(Number.parseFloat),!n.width||!n.height)return[0,0];const o=e/n.width,s=i/n.height;return[Math.round(-o*(r.x-n.x)+e/2),Math.round(-s*(r.y-n.y)+i/2)]}(t,i,r);this.infoCache.set(t,{ownOffset:o,bbox:n,svgElement:e,size:[i,r]})}return this.infoCache.get(t)}getMaplibreImageKey(t,e){const i=`${t}_${e}`;if(!this.keyCache.has(i)){const{size:r}=this.getSvgInfo(t),o=Math.max(r[0]*e,1),s=Math.max(r[1]*e,1),a=`mc-image-${n(i)}`;nt(t,o,s).then((t=>{this.map.addImage(a,t,{pixelRatio:e})})).catch((t=>console.log(t))),this.keyCache.set(i,a)}return this.keyCache.get(i)}}var st='<svg width="20" height="20" viewBox="0 0 40 40" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 4.167 1.667 35.834h36.667z" stroke-width="2" stroke-linejoin="round"/><path d="M20 29.167v.834m0-14.167.007 8.333" stroke-width="2" stroke-linecap="round"/></svg>\n';function at(t){const{src:e,allowFullscreen:i,loop:r}=t;let n,o;if(e.includes("/embed/"))n=e;else if(e.includes("youtu.be")){if(o=e.split("/").pop(),!o)return null;n=`https://www.youtube.com/embed/${o}`}else{const t=/v=([-\w]+)/gm.exec(e);n=`https://www.youtube.com/embed/${t?.[1]??e}`}const s=[];if(i||s.push("fs=0"),r&&o&&s.push(`loop=1&playlist=${o.split("?")[0]}`),n=function(t){const e=new URL(t),i=e.searchParams.get("t");if(!i)return t;let r=0;const n=/^((\d+)m)?((\d+)s)?$/;if(/^\d+$/.test(i))r=parseInt(i,10);else{const t=i.match(n);if(t){r=60*parseInt(t[2]||"0",10)+parseInt(t[4]||"0",10)}}r>0&&(e.searchParams.delete("t"),e.searchParams.set("start",String(r)));return e.toString()}(n),n=n.replace(/([?&])si=[^&]+(&)?/,((t,e,i)=>"?"!==e||i?"?"===e&&i?"?":i?"&":"":"")),s.length){const t=n.includes("?")?"&":"?";n+=`${t}${s.join("&")}`}return n}const lt=/>\$(.+?)</gi,ct=/<span\s+class="mention"\s+data-mention-id="[^"]*">(.*?)<\/span>/gim,ht=/(\S+?)\s*=\s*"\$([^"]+?)"/g,ut=/youtube\.com\/embed\/\$([^"'<>\\]+)/gi;function dt(t,e,i,r){const n=t?`<div class="text-content">${t}</div>`:"";let o="";return"video"===e?.type?o=r?function(t,e){t.startsWith("$")&&(t=pt(e[t.slice(1)]));return`\n <div class="youtube-placeholder">\n <img src="https://img.youtube.com/vi/${T(t)}/hqdefault.jpg" />\n <div class="popup-alert">\n <div class="alert-icon">${st}</div>\n <div>${_.t("placeholder.videoAlert")}</div>\n </div>\n </div>\n `}(e.src,i):`<div data-youtube-video><iframe src="${at(e)}" width="100%" height="300" style="border: none" allowfullscreen ></iframe></div>`:"image"===e?.type&&(o=`<div class="image-container ${e.fullWidth?"fullwidth":""}"><img src="${e.src}" alt="${e.alt??""}" /></div>`),e&&"image"===e.type&&e.href&&(o=`<a href=${ft(e.href)} target="_blank" rel="noopener noreferrer">${o}</a>`),function(t,e){if(!t)return"";return t=t.replace(/placeholder="[^"]+"/,""),t=t.replace(/onerror="[^"]+"/,""),t=t.replace(ut,((t,i)=>{const r=pt(e[i]);return r?`youtube.com/embed/${T(r)}?`:""})),t=t.replace(ht,((t,i,r)=>{const n=pt(e[r]);return["src","href"].includes(i)&&!n?"":["src","href"].includes(i)?/^(mailto:|tel:|ftp:|data:|http:\/\/|https:\/\/)/i.test(n)?` ${i}="${n}"`:` ${i}="${ft(n)}"`:` ${i}="${n}"`})),t=t.replace(lt,((t,i)=>`>${pt(e[i])}<`)),t=t.replace(ct,((t,e)=>e)),t}(`${o}${n}`,i)}function pt(t){return null==t?"":"object"==typeof t?t.w??"":String(t)}function ft(t){return/^https?:\/\//i.test(t)?t:`https://${t}`}const mt=["area","circle","dot","line","marker","polygon"];class gt{data;customGroupIds;constructor(t){this.data={area:{},circle:{},dot:{},line:{},marker:{},polygon:{}};for(const e of mt)for(const i of t.registry.models[e]??[]){this.data[e][i.id]={};for(const t of i.models)this.data[e][i.id][t.id]=t}const{beforeWaters:e,beforeBoundaries:i,beforeNames:r,beforeNone:n}=t.registry.slots;this.customGroupIds=[...e,...i,...r,...n].map((t=>t.groupId))}getModel(t){const e=String(t.properties?.id),i=t.layer.metadata?.["mc-group-id"],r=t.layer.metadata?.["mc-model-type"];if(void 0!==i&&void 0!==e&&void 0!==r)return this.data[r]?.[i]?.[e]}getPopupElements(){const t=[],e=["circle","dot","line","marker","polygon"];for(const i of this.customGroupIds)for(const r of e){const e=this.data[r]?.[i];if(e)for(const[r,n]of Object.entries(e))(n.popup||n.popupMedia)&&t.push({groupId:i,modelId:r,popup:n.popup,popupMedia:n.popupMedia,lngLat:n.lngLat,center:n.center,radius:n.radius,anchorPoints:n.anchorPoints,dataBindings:n.dataBindings})}return t.reverse()}}class _t{map;popupElements;highlightLayerId;markerLayerIds;constructor(t,e){this.map=t,this.popupElements=e,this.markerLayerIds=this.map.getStyle().layers.filter((t=>t.id.startsWith("custom-marker"))).map((t=>t.id))}highlight(t,e){if(this.deselect(),!t)return;const{groupId:i,modelId:r}=t,n=this.popupElements.filter((t=>t.groupId===i));n.length>1&&i.startsWith("custom-marker")&&this.highlightGroupedMarker(i,r,n),i.startsWith("custom-polygon")||i.startsWith("custom-circle")?this.highlightPolygon(i,r):i.startsWith("custom-line")?this.highlightLine(i,r):i.startsWith("custom-marker")&&this.fadeOtherMarkers(i),this.repositionMap(t,e)}deselect(){this.highlightLayerId&&this.map.getLayer(this.highlightLayerId)&&this.map.removeLayer(this.highlightLayerId),this.highlightLayerId=void 0,this.markerLayerIds.forEach((t=>{this.map.setPaintProperty(t,"icon-opacity",1),this.map.setPaintProperty(t,"text-opacity",1)}))}highlightGroupedMarker(t,e,i){const r=this.markerLayerIds.find((e=>e.startsWith(t)));r&&(this.map.setPaintProperty(r,"icon-opacity",["case",["boolean",["feature-state","highlighted"],!1],1,.3]),this.map.setPaintProperty(r,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],1,.3]),i.forEach((i=>{this.map.setFeatureState({source:t,id:w(i.modelId)},{highlighted:i.modelId===e})})))}highlightPolygon(t,e){const i=this.map.getLayer(`${t}-outline`);if(i){const r=`${i.id}-highlight`;this.map.addLayer({id:r,type:"line",source:i.source,layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["+",["get","outline-width"],10],"line-color":["get","outline-color"],"line-blur":["+",["get","outline-width"],6]},filter:["all",["==",["geometry-type"],"Polygon"],["==",["id"],w(e)]]},t),this.highlightLayerId=r}}highlightLine(t,e){const i=t.endsWith("-clickable")?t:`${t}-clickable`,r=this.map.getLayer(i);if(!r)return;const n=`${i}-highlight`;this.map.addLayer({id:n,type:"line",source:r.source,layout:{"line-cap":"round"},paint:{"line-width":["+",["get","line-width"],10],"line-color":["get","line-color"],"line-blur":["+",["get","line-width"],6]},filter:["==",["id"],w(e)]},i),this.highlightLayerId=n}fadeOtherMarkers(t){this.markerLayerIds.filter((e=>!e.startsWith(t))).forEach((t=>{this.map.setPaintProperty(t,"icon-opacity",.3),this.map.setPaintProperty(t,"text-opacity",.3)}))}repositionMap(t,e){let i,r=20;void 0!==t.lngLat?(i=new h.LngLatBounds(t.lngLat,t.lngLat),r=40):void 0!==t.anchorPoints?i=this.getElementBounds(this.flattenCoordinates(t.anchorPoints)):void 0!==t.center&&void 0!==t.radius&&(i=this.getElementBounds($(t.center,t.radius)));const n=document.querySelector(".mc-popup");if(n){const t=new ResizeObserver((()=>{i&&this.panToElement(i,r,e),t.disconnect()}));t.observe(n)}}getElementBounds(t){const e=new h.LngLatBounds(t[0],t[0]);for(const i of t)e.extend(i);return e}flattenCoordinates(t){return Array.isArray(t[0][0])?t.flat():t}panToElement(t,e,i){const r=this.map.projectWithScaleCorrection(t.getSouthWest()),n=this.map.projectWithScaleCorrection(t.getNorthEast()),o=this.map.getContainer().clientWidth,s=this.map.getContainer().clientHeight,a=o>600,l=document.querySelector(".mc-popup")?.getBoundingClientRect(),c=l?.width??0;let h=l?.height??0;a||(h=Math.min(h,s/2));const u=s-r.y>h+e,d=r.x>e+("bottomLeft"===i&&a&&!u?c:0),p=n.x<o-e-("bottomRight"===i&&a&&!u?c:0),f=n.y>e,m=a?r.y<s-e:u;if(!(d&&p&&f&&m)){let l=0,g=0;if(d?p||(l=n.x-(o-e-("bottomRight"===i&&a&&!u?c:0))):l=r.x-e-("bottomLeft"===i&&a&&!u?c:0),f){if(!m){const t=a?e:e+h;g=r.y-(s-t)}}else g=n.y-e;const _=this.map.projectWithScaleCorrection(this.map.getCenter()),y=[_.x+l,_.y+g],x=this.map.unprojectWithScaleCorrection(y);n.x-r.x+2*e<o&&r.y-n.y+2*e<s?this.map.easeTo({center:x,duration:500}):this.map.fitBounds(t,{padding:e,maxZoom:this.map.getZoom(),duration:500,linear:!0})}}}class yt{map;interactivityType="click";popupPosition="bottomLeft";mapContainer;popupContainer;feature;currentFeatureId;currentModelId;popupElements=[];language="en";promoteIdCache=new Map;publication;floatingPopup;registry;highlightManager;exportPreview;restrictMapMovement;center;constructor(t,e){this.map=t,this.exportPreview=e,this.mapContainer=this.map.getContainer(),this.popupContainer=document.createElement("div"),this.popupContainer.classList.add("popup-container"),this.popupContainer.classList.add("scrollbar"),this.map.on("mousemove",(t=>this.onMouseMove(t))),this.map.on("click",(t=>this.onClick(t)))}setJobObject(t){this.registry=new gt(t)}setParams(t,e,i,r,n){this.interactivityType=t,this.popupPosition=e,this.language=i,this.restrictMapMovement=r,this.center=n}setPublication(t){this.publication=t}setpopupElements(){this.popupElements=this.registry.getPopupElements()}setHighlightManager(){this.highlightManager=new _t(this.map,this.registry.getPopupElements())}onMouseMove(t){this.feature=this.getInteractiveFeature(t),this.feature?(this.map.getCanvas().style.cursor="pointer","hover"===this.interactivityType&&this.feature.id!==this.currentFeatureId&&this.addPopup(t)):(this.map.getCanvas().style.cursor="","hover"===this.interactivityType&&(this.hidePopup(),this.floatingPopup?.remove()))}onClick(t){("hover"!==this.interactivityType||et())&&(this.feature=this.getInteractiveFeature(t),this.currentModelId=this.feature?.properties?.id,!this.feature||this.mapContainer.contains(this.popupContainer)&&this.feature?.id===this.currentFeatureId?(this.hidePopup(),this.highlightManager.highlight(void 0,this.popupPosition)):(this.addPopup(t),this.highlightManager.highlight(this.getPopupElementFromFeature(this.feature),this.popupPosition)))}getPopupElementFromFeature(t){return this.popupElements.find((e=>e.modelId===t.properties.id))}getInteractiveFeature(t){return this.map.queryRenderedFeatures(t.point).find((t=>{if(Object.keys(t.layer.metadata??{}).some((t=>t.startsWith("mc-interactivity-template"))))return!0;const e=this.registry.getModel(t);return!!(e?.popup??e?.popupMedia)}))}addPopup(t){if(!this.feature)return;this.floatingPopup?.remove();const e=Number(this.feature.id);this.currentFeatureId=isNaN(e)?this.feature.id:e;const i=this.getTemplate(this.feature);if(i){if(this.popupContainer.innerHTML=i,"click"===this.interactivityType&&("mapElement"!==this.popupPosition||this.mapContainer.clientWidth<600)&&void 0!==this.popupElements.find((t=>t.modelId===this.feature?.properties.id))&&this.addPopupControls(),"mapElement"!==this.popupPosition){const t="bottomLeft"===this.popupPosition?"bottom-left":"bottom-right";return this.popupContainer.classList.add(t,"hide-pointer"),l()&&this.popupContainer.classList.add("embed"),void this.mapContainer.appendChild(this.popupContainer)}if("Point"===this.feature.geometry.type)this.addFloatingPopup(i,this.feature.geometry.coordinates);else{const{lng:e,lat:r}=this.map.unproject(t.point);this.addFloatingPopup(i,[e,r])}}}addFloatingPopup(t,e){const i=this.restrictMapMovement?this.getAnchor(e):void 0;let r="410px",n="desktop";const o=this.map.getContainer().clientWidth;o<600&&l()||o<220?(r="160px",n="mobile-embed"):o<600?(r="210px",n="mobile"):(l()||o<644)&&(r="310px",n="desktop-small"),this.floatingPopup=new h.Popup({anchor:i,maxWidth:r,closeButton:!1,offset:10}).setLngLat(e).setHTML(t).addTo(this.map);const s=document.querySelector(".maplibregl-popup-content");s&&s.classList.add(n)}getAnchor(t){const e=this.map.projectWithScaleCorrection(t),i=this.map.getContainer().clientWidth,r=this.map.getContainer().clientHeight;let n,o;return n=e.y<.33*r?"top":e.y>.66*r?"bottom":"center",o=e.x<.33*i?"left":e.x>.66*i?"right":"center","center"===n&&"center"===o?"bottom":"center"===n?o:"center"===o?n:`${n}-${o}`}hidePopup(){this.popupContainer&&(this.popupContainer.remove(),this.feature=void 0,this.currentFeatureId=void 0),this.restrictMapMovement&&this.center&&this.map.easeTo({center:this.center})}getTemplate(t){const{layer:e}=t;let i,r="";const n=this.registry.getModel(t),o=n?.popup||n?.popupMedia,s=o&&!n.popupMedia?"text-only":"";if(o)i=dt(n.popup,n.popupMedia,n.dataBindings??{},this.exportPreview);else{r="data-layer";const n=[];this.publication&&(n.push(`:${this.publication}-${this.language}`),n.push(`:${this.publication}-:en`)),n.push(`:${this.language}`),n.push(":en"),n.push("");for(const r of n){const n=e.metadata?.[`mc-interactivity-template${r}`];if(n){i=this.fillDatalayerTemplate(t,n,r);break}}}if(void 0!==i)return`<div class="popup-scroll-wrapper"><div class="mc-popup ${r} ${s}">${i}</div></div>`}addPopupControls(){this.popupContainer.classList.remove("text-only","has-cycle-buttons");const t=document.createElement("div");t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="currentColor"><path d="M.21.71a.714.714 0 0 1 1.011 0l3.78 3.78L8.778.71a.715.715 0 0 1 1.013 1.01L6.01 5.501l3.78 3.778a.715.715 0 0 1-1.01 1.012L5 6.51l-3.779 3.78A.716.716 0 0 1 .21 9.28L3.99 5.5.21 1.721A.714.714 0 0 1 .21.71"/></svg>\n',t.classList.add("mc-popup-button","close"),t.addEventListener("click",(()=>this.hidePopup())),this.popupContainer.appendChild(t),this.popupContainer.classList.add("has-close-button");const e=this.popupElements.find((t=>t.modelId===this.currentModelId));if(e?.popupMedia||this.popupContainer.classList.add("text-only"),this.popupElements.length<2)return;const i=document.createElement("div");i.innerHTML='<svg width="31" height="31" viewBox="0 0 31 31" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="m12.223 15.5 4.281 4.4a.814.814 0 1 0 1.167-1.134L14.493 15.5l3.178-3.266a.814.814 0 1 0-1.167-1.135z"/></svg>\n',i.classList.add("mc-popup-button","prev"),i.addEventListener("click",(()=>this.cyclePopups(!1))),this.popupContainer.appendChild(i);const r=document.createElement("div");r.innerHTML='<svg width="31" height="31" viewBox="0 0 31 31" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="m18.777 15.5-4.281 4.4a.814.814 0 1 1-1.167-1.134l3.178-3.266-3.178-3.266a.814.814 0 1 1 1.167-1.135z"/></svg>\n',r.classList.add("mc-popup-button","next"),r.addEventListener("click",(()=>this.cyclePopups())),this.popupContainer.appendChild(r),this.popupContainer.classList.add("has-cycle-buttons")}fillDatalayerTemplate(t,e,i){const r="data-mention-id",n=(new DOMParser).parseFromString(e,"text/html").body;for(const e of n.querySelectorAll(`[${r}]`)){const n=this.getProperty(t,e.getAttribute(r),i);void 0!==n&&(e.innerText=n)}return n.innerHTML}getProperty(t,e,i){if(!e)return;const r=e.endsWith(":en")?[e.replace(":en",i),e]:[e];for(const e of r){const i=t.properties[e]??this.getVectorProperty(t,e);if(void 0!==i)return i}}getVectorProperty(t,e){let i=this.promoteIdCache.get(t.source);void 0===i&&(i=this.map.getSource(t.source)?.serialize().promoteId||"id",this.promoteIdCache.set(t.source,i));try{const r=t.properties[i];return t.layer.metadata.properties[e][r]}catch(t){return}}cyclePopups(t=!0){const e=this.popupElements?.findIndex((t=>t.modelId===this.currentModelId));if(-1!==e){let i=0;i=t?e===this.popupElements.length-1?0:e+1:0===e?this.popupElements.length-1:e-1;const r=this.popupElements?.[i];this.highlightManager.highlight(r,this.popupPosition);const n=dt(r.popup,r.popupMedia,r.dataBindings??{},this.exportPreview),o=r.popupMedia?"":"text-only",s=this.popupContainer;this.popupContainer.remove(),s.innerHTML=`<div class="popup-scroll-wrapper"><div class="mc-popup ${o}">${n}</div></div>`,this.mapContainer.appendChild(s),this.currentModelId=r.modelId,this.addPopupControls(),this.currentFeatureId=void 0}}}function xt(t,e,i){return"en"!==i&&"native"!==i&&(i=f(i,d.TWO)),"native"===i?["get","name"]:"mc-base"===t&&["lines","points","places","labelcentroid"].includes(e??"")?["coalesce",["get",`name:${i}`],["case",["has","name_is_latin"],["get","name"],["get","name:en"]]]:["coalesce",["get",`name:${i}`],["get","name:en"],["get","name"]]}async function vt(t,e,i){const r=t.map((t=>b(`${m.vectorApiUrl}styles/${t}.json`,i))).map((t=>fetch(t).then((t=>t.json())))),n=await Promise.all(r);await Promise.all(n.map((t=>async function(t,e){for(const i in t.sources)void 0===e.getSource(i)&&e.addSource(i,t.sources[i]);if(void 0!==t.sprite){const i=b(t.sprite);await async function(t,e){try{const i=`${e}.json?access_token=${m.accessToken}`,r=`${e}.png?access_token=${m.accessToken}`,[n,o]=await Promise.all([fetch(i),fetch(r)]);if(!n.ok||!o.ok)throw new Error(`Failed to load sprite from ${e}`);const s=await n.json(),a=await o.blob(),l=await new Promise(((t,e)=>{const i=new Image;i.onload=()=>t(i),i.onerror=t=>e(t),i.src=URL.createObjectURL(a)})),c=document.createElement("canvas"),h=c.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("Failed to get canvas context");for(const[e,i]of Object.entries(s)){if(t.hasImage(e))continue;const{x:r,y:n,width:o,height:s,pixelRatio:a}=i;c.width=o*a,c.height=s*a,h.clearRect(0,0,c.width,c.height),h.drawImage(l,r,n,o,s,0,0,c.width,c.height);const u=h.getImageData(0,0,c.width,c.height);t.addImage(e,u,{pixelRatio:a})}}catch(t){console.error(t)}}(e,i)}for(const i of t.layers){void 0!==e.getLayer(i.id)&&e.removeLayer(i.id);const t=i.metadata?.["mc-add-before"]??"mc-before-none";e.addLayer(i,t)}}(t,e))))}function bt(t){const e=document.createElement("button");return e.className=t.className,e.innerHTML=`${t.content}`,e.addEventListener("click",t.onClick),e}function wt(t){return bt({type:"button",className:"control-button fullscreen-control-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M4.774 6.44a.556.556 0 0 1 .832.734l-.047.052L2.897 9.89h1.436a.555.555 0 0 1 .065 1.107L4.333 11H1.556a.556.556 0 0 1-.552-.49L1 10.443V7.667a.556.556 0 0 1 1.107-.065l.004.065v1.436l2.663-2.662ZM10.444 1a.555.555 0 0 1 .552.49l.004.066v2.777a.556.556 0 0 1-1.107.065l-.004-.065V2.897L7.226 5.559a.556.556 0 0 1-.832-.733l.047-.052L9.103 2.11H7.667a.556.556 0 0 1-.065-1.107L7.667 1h2.777Z"/></svg>\n',onClick:()=>{const e=t.getContainer();if(Boolean(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled))!function(t){return document.fullscreenElement===t||document.webkitFullscreenElement===t||document.mozFullScreenElement===t||document.msFullscreenElement===t}(e)?function(t){t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}(e):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();else{let t=document.location.href;t+=t.includes("?")?"&":"?",t+="close-tab",window.open(t,"_blank")}}})}const Tt=t=>{t.getSource("location-circle")||t.addSource("location-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.getSource("location-dot")||t.addSource("location-dot",{type:"geojson",data:{type:"Feature",geometry:{type:"Point",coordinates:[]},properties:{}}}),t.getLayer("location-circle")||t.addLayer({id:"location-circle",type:"fill",source:"location-circle",layout:{},paint:{"fill-color":"#349CF2","fill-opacity":.15,"fill-outline-color":"#005196"}},"mc-before-names"),t.getLayer("location-dot")||t.addLayer({id:"location-dot",type:"symbol",source:"location-dot",layout:{"icon-padding":0},paint:{"icon-opacity":1},metadata:{"mc-name":"location dot","mc-skip-load":!0}},"mc-before-names"),(t=>{const e=2*window.devicePixelRatio,i=new ot(t).getMaplibreImageKey('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><circle cx="16" cy="16" r="10" fill="#349CF2"/><circle cx="16" cy="16" r="9" stroke="#fff" stroke-width="2"/></g><defs><filter id="a" x="0" y="0" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="4"/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_15_3175"/><feBlend in="SourceGraphic" in2="effect1_dropShadow_15_3175" result="shape"/></filter></defs></svg>\n',e);t.setLayoutProperty("location-dot","icon-image",i)})(t)};function Pt(t){let e=!1;const i=t=>{const i=document.querySelector(".geolocation-button"),r=i?.querySelector(".geolocation-icon"),n=i?.querySelector(".locating-icon");r&&n&&(r.classList.toggle("active",!t),n.classList.toggle("active",t)),e=t},r=e=>{const{longitude:r,latitude:n,accuracy:o}=e.coords,s=[r,n];t.easeTo?t.easeTo({center:s,zoom:19,duration:1e3}):t.setCenter&&t.setCenter(s);const a=t.getSource("location-circle");a&&a.setData(((t,e,i)=>{const r=i/1e3,n=[],o=r/(111.32*Math.cos(e*Math.PI/180)),s=r/110.574;for(let i=0;i<64;i++){const r=i/64*(2*Math.PI),a=o*Math.cos(r),l=s*Math.sin(r);n.push([t+a,e+l])}return n.push(n[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[n]}}]}})(r,n,o/2)),((t,e,i)=>{const r=t.getSource("location-dot");r&&r.setData({type:"Feature",geometry:{type:"Point",coordinates:[e,i]},properties:{}})})(t,r,n),t.once("moveend",(()=>i(!1)))},n=t=>{console.error("Geolocation error:",t),i(!1)};return bt({type:"button",className:"control-button geolocation-button",content:'\n <div class="location-icon geolocation-icon active"><svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.571.875V0h.858v.875a5.143 5.143 0 0 1 4.696 4.696H12v.858h-.875a5.143 5.143 0 0 1-4.696 4.696V12H5.57v-.875A5.143 5.143 0 0 1 .875 6.429H0V5.57h.875A5.143 5.143 0 0 1 5.571.875Zm0 .86a4.286 4.286 0 0 0-3.835 3.836h.835v.858h-.835a4.286 4.286 0 0 0 3.835 3.835V9.43h.858v.835a4.285 4.285 0 0 0 3.835-3.835H9.43v-.86h.835A4.285 4.285 0 0 0 6.43 1.736v.835h-.86v-.835Zm-.177 3.659a.857.857 0 1 1 1.212 1.212.857.857 0 0 1-1.212-1.212Z"/></svg>\n</div>\n <div class="location-icon locating-icon"><svg width="34" viewBox="5 5 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#343A40"><path d="M15.016 22.656a5.797 5.797 0 0 1-1.016-.46c-2.858-1.65-3.846-5.338-2.196-8.196 1.65-2.858 5.338-3.846 8.196-2.196 2.858 1.65 3.846 5.338 2.196 8.196-.2.346-.434.673-.694.962l2.933 2.72A10.1 10.1 0 0 0 25.66 22c2.75-4.763 1.103-10.91-3.66-13.66S11.09 7.237 8.34 12 7.237 22.91 12 25.66a9.61 9.61 0 0 0 1.635.748l1.381-3.752Z"/><path d="m11.01 17.183-3.999.06a10.051 10.051 0 0 0 6.427 9.097l1.484-3.714a6.025 6.025 0 0 1-3.913-5.443Zm13.284 5.183 1-1.732-2.598-1.5-1 1.732 2.598 1.5Zm-3.428-10.062 1.5-2.598-1.732-1-1.5 2.598 1.732 1Zm-9.562 2.562 1-1.732-2.598-1.5-1 1.732 2.598 1.5Z"/><path d="m13.366 25.294 1.5-2.598-1.732-1-1.5 2.598 1.732 1Z"/></g><defs><clipPath id="a"><path fill="#fff" d="m33.393 12.607-12 20.784-20.785-12 12-20.784z"/></clipPath></defs></svg>\n</div>\n ',onClick:()=>{if(!e){if(t.getSource("location-circle")||Tt(t),i(!0),!navigator.geolocation)return(()=>{const t=document.querySelector(".map"),e=document.createElement("div");e.classList.add("location-notification"),e.textContent="Geolocation is not available",t?.appendChild(e),setTimeout((()=>{t?.removeChild(e)}),3e3)})(),void i(!1);navigator.geolocation.getCurrentPosition(r,n,{maximumAge:6e4,timeout:5e3})}}})}function Mt(t,e,i){const r=document.createElement("div");r.className="web-control";const n=t.buttons.flatMap((t=>"zoom"===t?["zoomIn","zoomOut"]:t));return(et()?n.filter((t=>"zoomIn"!==t&&"zoomOut"!==t)):n).forEach((t=>{let n;if("zoomIn"===t)n=function(t){return bt({type:"button",className:"control-button zoom-in-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.714H6.714V11H5.286V6.714H1V5.286h4.286V1h1.428v4.286H11v1.428Z"/></svg>\n',onClick:()=>t.zoomIn()})}(e);else if("zoomOut"===t)n=function(t){return bt({type:"button",className:"control-button zoom-out-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.144H1v-1h10v1Z"/></svg>\n',onClick:()=>t.zoomOut()})}(e);else if("fullscreen"===t)n=wt(e);else if("geolocation"===t)n=Pt(e);else{if("refresh"!==t)return;n=function(t,e){return bt({type:"button",className:"control-button refresh-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.155 1.146A.546.546 0 0 1 6.53 1c.14 0 .275.053.375.146l1.588 1.5c.1.094.155.221.155.354 0 .132-.056.26-.155.353l-1.588 1.5a.546.546 0 0 1-.373.14.545.545 0 0 1-.37-.146.487.487 0 0 1-.154-.349.486.486 0 0 1 .148-.352L6.84 3.5H6c-1.878 0-3.441 1.476-3.441 3.25S4.122 10 6 10s3.441-1.476 3.441-3.25c0-.133.056-.26.155-.354a.546.546 0 0 1 .375-.146c.14 0 .275.053.374.146.1.094.155.221.155.354C10.5 9.076 8.463 11 6 11S1.5 9.076 1.5 6.75 3.537 2.5 6 2.5h.84l-.685-.647A.486.486 0 0 1 6 1.5c0-.133.056-.26.155-.354Z"/></svg>\n',onClick:()=>{const i=t.getContainer();let r=0;if(i.clientWidth>0&&i.clientHeight>0){const t=Math.min(i.clientWidth/e.width,i.clientHeight/e.height);r=Math.log(t)/Math.LN2}t.easeTo({center:e.center,zoom:e.zoom-e.detailLevel+r,pitch:e.pitch,bearing:e.rotation})}})}(e,i.initialPosition)}r.appendChild(n)})),r}class St extends c{map;svgCache;popupManager;constructor(t={},e={}){super(t,e),this.mapOptions.transformRequest||(this.mapOptions.transformRequest=t=>({url:t=b(t,this.mapOptions.mcAccessToken)})),this.map=new h.Map(this.mapOptions),this.map.getContainer().classList.add("mapcreatorgl-map"),this.svgCache=new ot(this.map),this.popupManager=new yt(this.map,this.mapOptions.exportPreview??!1)}static get defaultMapOptions(){return{...super.defaultMapOptions,attributionControl:!1,mcAccessToken:m.accessToken,maxBounds:[-1/0,-90,1/0,90]}}static get defaultOptions(){return{...super.defaultOptions}}get favicon(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAAAFBlWElmTU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAtKADAAQAAAABAAAAtAAAAABECLhnAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAE/ElEQVR4Ae3dTU4jVxgFUAMt0XFCoizBU7OE7H8FSJ6yC+eHH6cKQYsMeJ2B7w1POZZKLvPc332cukY9KdhsPAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAIHN5gICge8InL6z/mmWt9vt5nK3260bThzpb/Tse97v9+mLd/Y9p5Fnm38524btl8BIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbToBhZ7uktnwSEChRzrWphNQ6OkumQ2PBBR6pGNtOgGFnu6S2fBIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbTqBL9Pt2IbbAtP8ZoDj8bjxE7pdD3lRAYWO8hreFlDotri8qIBCR3kNbwsodFtcXlRAoaO8hrcFFLotLi8qoNBRXsPbAgrdFpcXFVDoKK/hbQGFbovLiwoodJTX8LaAQrfF5UUFFDrKa3hbQKHb4vKiAgod5TW8LaDQbXF5UQGFjvIa3hZQ6La4vKiAQkd5DW8LKHRbXF5UYOa7vs9+N/LhcIhiG54X8BM6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKArM/Le+i0z/36jT6fTtb6pfXFycPruEQn/2K/Qf7+/29vb5bQv7/f7tdH3+czn+en3+/fV8ff3Hu/O39fX5YTne/s16/rb2sHxoHtfXl5eXL+fvXj++nj8sH6b1/Gk5Hpb3rc8va+v5+ri6unq8vr5+UuhF0uNjgcPh8NHi9bKwHjcfvaH99e12u/F/6La6vKiAQkd5DW8LKHRbXF5UQKGjvIa3BRS6LS4vKqDQUV7D2wIK3RaXFxVQ6Civ4W0BhW6Ly4sKKHSU1/C2gEK3xeVFBRQ6ymt4W0Ch2+LyogIKHeU1vC2g0G1xeVEBhY7yGt4WUOi2uLyogEJHeQ1vCyh0W1xeVECho7yGtwW+LHfy/nZzc/N1uYv2ejm+LnfX/rAc2+fn55fnZUM/LsdP745flvP1xsifX49fX5//8eG4u7tbvuzxXmC3271/eZbz+/v7s8wZDPn2awwG7/kUS8fjcXPWzS4fiHXey7F8KJ4+xXdpEwQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBA4N8I/A1O6KkX0GDoIwAAAABJRU5ErkJggg=="}get title(){return"Mapcreator Next"}async load(t){const{map:e,export:i,registry:r,web:n,adornments:o}=t,{language:s,zoom:a,pitch:c,rotation:u,center:p,layerInfo:g}=e,{models:y,slots:x,svgs:v}=r;_.locale=f(s,d.LOCALE);const w=f(s,d.TWO);document.body.parentElement.lang=w,this.loadFontFaces(),this.map.resize();const T={duration:0};this.map.setPitch(c,T),this.map.setBearing(u,T);const M=P(i.unit,"pixel",i.size[0]),S=P(i.unit,"pixel",i.size[1]),C=this.map?.getContainer();let I=0;if(C.clientWidth>0&&C.clientHeight>0){const t=Math.min(C.clientWidth/M,C.clientHeight/S);I=Math.log(t)/Math.LN2}if(this.map.setZoom(a-e.detailLevel+I,T),this.map.setCenter(p,T),this.map.addControl(new h.AttributionControl({compact:!1})),l()&&this.map.cooperativeGestures.enable(),o&&function(t,e,i){let r=document.getElementById("adornments-container");r||(r=document.createElement("div"),r.id="adornments-container",r.className="adornments-container",e.getContainer().appendChild(r)),r.innerHTML="",t.forEach((t=>{if("copyright"!==t.type)if("custom"===t.type&&t.svg){const e=document.createElement("div");e.className="adornment",e.innerHTML=t.svg,r.appendChild(e)}else if("webControls"===t.type&&t.buttons){const n=Mt(t,e,i);r.appendChild(n)}}))}(o,this.map,{initialPosition:{center:p,zoom:a,pitch:c,rotation:u,detailLevel:e.detailLevel,width:M,height:S}}),this.popupManager.setJobObject(t),n){const{restrictMapMovement:t,interactivityType:e,popupPosition:i}=n;t&&(this.map.boxZoom.disable(),this.map.doubleClickZoom.disable(),this.map.dragPan.disable(),this.map.dragRotate.disable(),this.map.keyboard.disable(),this.map.scrollZoom.disable(),this.map.touchPitch.disable(),this.map.touchZoomRotate.disable()),this.popupManager.setParams(e,i,w,t,p)}const A=`${m.vectorApiUrl}styles/${t.meta.mapstyleSet}.json`,E=await fetch(b(A,this.mapOptions.mcAccessToken)).then((t=>t.json()));this.setLayerVisibility(E,g),this.map.once("style.load",(async()=>{this.options.libraryMode||this.setCustomStyle(this.map.getStyle().metadata.customCssFilePath),function(t,e){for(const i of e.getStyle().layers){if("symbol"!==i.type||i.id.startsWith("custom-")||i.id.startsWith("gl-"))continue;const r=i.layout&&i.layout["text-field"];i["source-layer"]&&Array.isArray(r)&&"coalesce"===r[0]&&!r.find((t=>"name:abbr"===t[1]))&&e.setLayoutProperty(i.id,"text-field",xt(i.source,i["source-layer"],t),{validate:!1})}}(s,this.map),await vt(t.meta.layers??[],this.map,this.mapOptions.mcAccessToken),this.addModels(y,x,v),this.popupManager.setPublication(E.metadata?.publication),this.popupManager.setpopupElements(),this.popupManager.setHighlightManager()})),this.map.setStyle(null),this.map.setStyle(E)}loadFontFaces(){if(!this.mapOptions.mcAccessToken)return;const t=a()?"b-":"",e=`${b(m.vectorApiUrl)}/stylesheets/ff-${t}${this.mapOptions.mcAccessToken}.css?access_token=${this.mapOptions.mcAccessToken}`,i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",e),i.setAttribute("type","text/css"),document.head.appendChild(i)}setCustomStyle(t){if(document.getElementById("custom-style")?.remove(),!t)return;let e;(t=b(t,this.mapOptions.mcAccessToken)).startsWith("http")?(e=document.createElement("link"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",t.replace(/https?:/,""))):(e=document.createElement("style"),e.appendChild(document.createTextNode(t))),e.setAttribute("id","custom-style"),e.setAttribute("type","text/css"),document.head.appendChild(e)}setLayerVisibility(t,e){for(const i of e){if(i.id.startsWith("custom"))continue;const e=t.layers.find((t=>t.id===i.id));void 0!==e&&void 0!==i.visibility&&e.layout&&(e.layout.visibility=i.visibility?"visible":"none")}}addModels(t,e,i){const{beforeNone:r,beforeNames:n,beforeBoundaries:o,beforeWaters:s}=e;r.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-none")})),n.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-names")})),o.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-boundaries")})),s.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-waters")}))}addModelsByType(t,e,i,r){if("marker"===e.type){const n=t.marker?.find((t=>t.id===e.groupId));n&&function(t,e,i,r,n){const o=[],s=new Set,a=new Set;J=window.devicePixelRatio*t.getScale();const l=["match",["get","text-font"]];for(const t of e.models)(t.visible??1)&&o.push(tt(t,r,n)),s.add(t.textFont),a.add(t.textLineHeight??1.2);if(Array.from(s).length>0){for(const t of Array.from(s))l.push(t,["literal",[t,Q]]);l.push(["literal",[Q]])}t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:o}}),a.forEach((r=>{t.addLayer({id:`${e.id}-${r}`,type:"symbol",source:e.id,metadata:{"mc-model-type":"marker","mc-group-id":e.id},layout:{"icon-allow-overlap":!e.collisionDetection,"icon-ignore-placement":!e.collisionDetection,"text-allow-overlap":!e.collisionDetection,"text-ignore-placement":!e.collisionDetection,"icon-image":["get","mc-image-key"],"icon-anchor":["get","icon-anchor"],"icon-size":["get","icon-size"],"icon-rotate":["get","icon-rotate"],"icon-offset":["get","icon-offset"],"text-field":"{text}","text-font":l,"text-max-width":["get","text-max-width"],"text-offset":["get","text-offset"],"text-rotate":["get","text-rotate"],"text-size":["get","text-size"],"text-anchor":["get","text-anchor"],"text-letter-spacing":["get","text-letter-spacing"],"text-line-height":r,"text-justify":["get","text-justify"]},paint:{"text-color":["get","text-color"],"text-halo-color":["get","text-halo-color"],"text-halo-width":["get","text-halo-width"]},filter:["==",["get","text-line-height"],r]},i)}))}(this.map,n,r,i,this.svgCache)}else if("polygon"===e.type){const n=t.polygon?.find((t=>t.id===e.groupId));n&&Y(this.map,n,r,i,this.svgCache)}else if("circle"===e.type){const n=t.circle?.find((t=>t.id===e.groupId));n&&K(this.map,n,r,i,this.svgCache)}else if("line"===e.type){const i=t.line?.find((t=>t.id===e.groupId));i&&S(this.map,i,r)}else if("dot"===e.type){const i=t.dot?.find((t=>t.id===e.groupId));i&&function(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:(e=t).id,properties:{id:e.id,"circle-radius":e.radius,"circle-color":e.fillColor??"#000000"},geometry:{type:"Point",coordinates:[e.center.lng,e.center.lat]}};var e}))}}),t.addLayer({id:e.id,type:"circle",source:e.id,metadata:{"mc-model-type":"dot","mc-group-id":e.id},paint:{"circle-color":["get","circle-color"],"circle-radius":["get","circle-radius"]}},i)}(this.map,i,r)}else if("area"===e.type){const n=t.area?.find((t=>t.id===e.groupId));n&&function(t,e,i,r,n,o){const s=new Map,a=new Map;for(const t of e.models){const i=t.id,o=e.id,l=[],c=X(t),h=H(o,t),u=a.get(h)??{model:t,modelIds:l,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{}};if(t.visible??1){u.modelIds.push(Number(i));const e=void 0!==t.fillPattern?n.getMaplibreImageKey(r[t.fillPattern],2*window.devicePixelRatio):null;u.modelIdToFillColor[i]=t.fillColor??"#ffffff",u.modelIdToFillPattern[i]=e,u.modelIdToOutlineColor[i]=t.outlineColor??"#000000"}s.set(c,t),a.set(h,u)}for(const e of s.keys())t.addSource(e,{type:"vector",url:`${o}${s.get(e).vectorUrl}`});for(const r of a.keys()){const{model:n}=a.get(r),{sourceLayerId:o}=n,s=X(n);t.addLayer({id:r,type:"fill",source:s,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-color":"#ffffff","fill-outline-color":"#000000"}},i),t.addLayer({id:`${r}-pattern`,type:"fill",source:s,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-pattern":["get","fill-pattern"]},layout:{visibility:"visible"}},i)}a.forEach(((e,i)=>{const{modelIds:r,modelIdToFillColor:n,modelIdToFillPattern:o,modelIdToOutlineColor:s}=e;t.setFilter(i,["in","id",...r]),t.setPaintProperty(i,"fill-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",n]]),t.setPaintProperty(i,"fill-outline-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",s]]),t.setFilter(`${i}-pattern`,["to-boolean",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]]]),t.setPaintProperty(`${i}-pattern`,"fill-pattern",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]])}))}(this.map,n,r,i,this.svgCache,m.vectorApiUrl)}}}async function Ct(t){const{jobId:e,container:i,accessToken:r,env:n,exportPreview:s}=t;!function(t){o=t}(n);let a="";"development"===n||"bleeding"===n?a=".bleeding":"beta"===n&&(a=".beta");const l=t.job??await fetch(`https://cdn${a}.mapcreator.io/jobs/${e}.json?access_token=${r}`).then((t=>t.json())),c=new St({libraryMode:!0},{mcAccessToken:r,container:i,exportPreview:s});return await c.load(l),c.map}export{Ct as init};
|