naksha-components-react 4.4.0 → 4.4.3
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/cjs/index.js +60 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +7 -0
- package/package.json +13 -13
- package/dist/esm/chunk-Y5JLKQX5.js +0 -1
- package/dist/esm/mapbox-gl-3PNS6OSM.js +0 -960
|
@@ -1,960 +0,0 @@
|
|
|
1
|
-
import{e as Om,j as _p}from"./chunk-Y5JLKQX5.js";var Um=Om((au,lu)=>{_p();(function(gn,oo){typeof au=="object"&&typeof lu<"u"?lu.exports=oo():typeof define=="function"&&define.amd?define(oo):(gn=typeof globalThis<"u"?globalThis:gn||self,gn.mapboxgl=oo())})(au,function(){"use strict";var gn,oo,Bc;function Rc(a,ji){if(!gn)gn=ji;else if(!oo)oo=ji;else{var Ar="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+gn+")(sharedChunk); ("+oo+")(sharedChunk); self.onerror = null;",yi={};gn(yi),Bc=ji(yi),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(Bc.workerUrl=window.URL.createObjectURL(new Blob([Ar],{type:"text/javascript"})))}}Rc(["exports"],function(a){"use strict";var ji="2.7.0",Ar=yi;function yi(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=r,this.p2y=n}yi.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},yi.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},yi.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},yi.prototype.solveCurveX=function(t,e){var r,n,s,l,u;for(e===void 0&&(e=1e-6),s=t,u=0;u<8;u++){if(l=this.sampleCurveX(s)-t,Math.abs(l)<e)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=l/p}if((s=t)<(r=0))return r;if(s>(n=1))return n;for(;r<n;){if(l=this.sampleCurveX(s),Math.abs(l-t)<e)return s;t>l?r=s:n=s,s=.5*(n-r)+r}return s},yi.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var Ce=qe;function qe(t,e){this.x=t,this.y=e}qe.prototype={clone:function(){return new qe(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,r=t.y-this.y;return e*e+r*r},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),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),s=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},qe.convert=function(t){return t instanceof qe?t:Array.isArray(t)?new qe(t[0],t[1]):t};var me=typeof self<"u"?self:{},Mi=1e-6,Dt=typeof Float32Array<"u"?Float32Array:Array;function so(){var t=new Dt(9);return Dt!=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 ui(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 ao(t,e,r){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],b=e[9],I=e[10],A=e[11],k=e[12],D=e[13],U=e[14],$=e[15],H=r[0],Y=r[1],J=r[2],Q=r[3];return t[0]=H*n+Y*p+J*v+Q*k,t[1]=H*s+Y*m+J*b+Q*D,t[2]=H*l+Y*g+J*I+Q*U,t[3]=H*u+Y*x+J*A+Q*$,t[4]=(H=r[4])*n+(Y=r[5])*p+(J=r[6])*v+(Q=r[7])*k,t[5]=H*s+Y*m+J*b+Q*D,t[6]=H*l+Y*g+J*I+Q*U,t[7]=H*u+Y*x+J*A+Q*$,t[8]=(H=r[8])*n+(Y=r[9])*p+(J=r[10])*v+(Q=r[11])*k,t[9]=H*s+Y*m+J*b+Q*D,t[10]=H*l+Y*g+J*I+Q*U,t[11]=H*u+Y*x+J*A+Q*$,t[12]=(H=r[12])*n+(Y=r[13])*p+(J=r[14])*v+(Q=r[15])*k,t[13]=H*s+Y*m+J*b+Q*D,t[14]=H*l+Y*g+J*I+Q*U,t[15]=H*u+Y*x+J*A+Q*$,t}function pr(t,e,r){var n,s,l,u,p,m,g,x,v,b,I,A,k=r[0],D=r[1],U=r[2];return e===t?(t[12]=e[0]*k+e[4]*D+e[8]*U+e[12],t[13]=e[1]*k+e[5]*D+e[9]*U+e[13],t[14]=e[2]*k+e[6]*D+e[10]*U+e[14],t[15]=e[3]*k+e[7]*D+e[11]*U+e[15]):(s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],b=e[9],I=e[10],A=e[11],t[0]=n=e[0],t[1]=s,t[2]=l,t[3]=u,t[4]=p,t[5]=m,t[6]=g,t[7]=x,t[8]=v,t[9]=b,t[10]=I,t[11]=A,t[12]=n*k+p*D+v*U+e[12],t[13]=s*k+m*D+b*U+e[13],t[14]=l*k+g*D+I*U+e[14],t[15]=u*k+x*D+A*U+e[15]),t}function Ai(t,e,r){var n=r[0],s=r[1],l=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*l,t[9]=e[9]*l,t[10]=e[10]*l,t[11]=e[11]*l,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function yn(t,e,r){var n=Math.sin(r),s=Math.cos(r),l=e[4],u=e[5],p=e[6],m=e[7],g=e[8],x=e[9],v=e[10],b=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]=l*s+g*n,t[5]=u*s+x*n,t[6]=p*s+v*n,t[7]=m*s+b*n,t[8]=g*s-l*n,t[9]=x*s-u*n,t[10]=v*s-p*n,t[11]=b*s-m*n,t}function Ji(t,e,r){var n=Math.sin(r),s=Math.cos(r),l=e[0],u=e[1],p=e[2],m=e[3],g=e[8],x=e[9],v=e[10],b=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]=l*s-g*n,t[1]=u*s-x*n,t[2]=p*s-v*n,t[3]=m*s-b*n,t[8]=l*n+g*s,t[9]=u*n+x*s,t[10]=p*n+v*s,t[11]=m*n+b*s,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Yr=ao;function lo(){var t=new Dt(3);return Dt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Jr(t){var e=new Dt(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function is(t){return Math.hypot(t[0],t[1],t[2])}function fr(t,e,r){var n=new Dt(3);return n[0]=t,n[1]=e,n[2]=r,n}function co(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function xn(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function vn(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function ua(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Qi(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Ci(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function bn(t,e){var r=e[0],n=e[1],s=e[2],l=r*r+n*n+s*s;return l>0&&(l=1/Math.sqrt(l)),t[0]=e[0]*l,t[1]=e[1]*l,t[2]=e[2]*l,t}function er(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function wn(t,e,r){var n=e[0],s=e[1],l=e[2],u=r[0],p=r[1],m=r[2];return t[0]=s*m-l*p,t[1]=l*u-n*m,t[2]=n*p-s*u,t}function nt(t,e,r){var n=e[0],s=e[1],l=e[2],u=r[3]*n+r[7]*s+r[11]*l+r[15];return t[0]=(r[0]*n+r[4]*s+r[8]*l+r[12])/(u=u||1),t[1]=(r[1]*n+r[5]*s+r[9]*l+r[13])/u,t[2]=(r[2]*n+r[6]*s+r[10]*l+r[14])/u,t}function rs(t,e,r){var n=r[0],s=r[1],l=r[2],u=e[0],p=e[1],m=e[2],g=s*m-l*p,x=l*u-n*m,v=n*p-s*u,b=s*v-l*x,I=l*g-n*v,A=n*x-s*g,k=2*r[3];return x*=k,v*=k,I*=2,A*=2,t[0]=u+(g*=k)+(b*=2),t[1]=p+x+I,t[2]=m+v+A,t}var Qr,en=xn,da=vn,Tn=is;function tr(t,e,r){var n=e[0],s=e[1],l=e[2],u=e[3];return t[0]=r[0]*n+r[4]*s+r[8]*l+r[12]*u,t[1]=r[1]*n+r[5]*s+r[9]*l+r[13]*u,t[2]=r[2]*n+r[6]*s+r[10]*l+r[14]*u,t[3]=r[3]*n+r[7]*s+r[11]*l+r[15]*u,t}function ho(){var t=new Dt(4);return Dt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ns(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function os(t,e,r){r*=.5;var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(r),m=Math.cos(r);return t[0]=n*m+u*p,t[1]=s*m+l*p,t[2]=l*m-s*p,t[3]=u*m-n*p,t}function uo(t,e){return t[0]===e[0]&&t[1]===e[1]}lo(),Qr=new Dt(4),Dt!=Float32Array&&(Qr[0]=0,Qr[1]=0,Qr[2]=0,Qr[3]=0),lo(),fr(1,0,0),fr(0,1,0),ho(),ho(),so(),function(){var t;t=new Dt(2),Dt!=Float32Array&&(t[0]=0,t[1]=0)}();let ss=Math.PI/180,En=180/Math.PI;function Je(t){return t*ss}function xi(t){return t*En}let tn=[[0,0],[1,0],[1,1],[0,1]];function po(t){if(t<=0)return 0;if(t>=1)return 1;let e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function fo(t,e,r,n){let s=new Ar(t,e,r,n);return function(l){return s.solve(l)}}let mo=fo(.25,.1,.25,1);function mt(t,e,r){return Math.min(r,Math.max(e,t))}function Cr(t,e,r){return(r=mt((r-t)/(e-t),0,1))*r*(3-2*r)}function mr(t,e,r){let n=r-e,s=((t-e)%n+n)%n+e;return s===e?r:s}function rn(t,e,r){if(!t.length)return r(null,[]);let n=t.length,s=new Array(t.length),l=null;t.forEach((u,p)=>{e(u,(m,g)=>{m&&(l=m),s[p]=g,--n==0&&r(l,s)})})}function Sn(t){let e=[];for(let r in t)e.push(t[r]);return e}function Lt(t,...e){for(let r of e)for(let n in r)t[n]=r[n];return t}let _o=1;function go(){return _o++}function yo(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function zi(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function as(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function In(t,e){t.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function Mn(t,e){return t.indexOf(e,t.length-e.length)!==-1}function zr(t,e,r){let n={};for(let s in t)n[s]=e.call(r||this,t[s],s,t);return n}function An(t,e,r){let n={};for(let s in t)e.call(r||this,t[s],s,t)&&(n[s]=t[s]);return n}function ki(t){return Array.isArray(t)?t.map(ki):typeof t=="object"&&t?zr(t,ki):t}let ls={};function zt(t){ls[t]||(typeof console<"u"&&console.warn(t),ls[t]=!0)}function Pi(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function Cn(t){let e=0;for(let r,n,s=0,l=t.length,u=l-1;s<l;u=s++)r=t[s],n=t[u],e+=(n.x-r.x)*(r.y+n.y);return e}function ir(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function zn(t){let e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,n,s,l)=>{let u=s||l;return e[n]=!u||u.toLowerCase(),""}),e["max-age"]){let r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}let nn,_r,Gi,kr=null;function rr(t){if(kr==null){let e=t.navigator?t.navigator.userAgent:null;kr=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return kr}function kn(t){try{let e=me[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}let vi={now:()=>Gi!==void 0?Gi:me.performance.now(),setNow(t){Gi=t},restoreNow(){Gi=void 0},frame(t){let e=me.requestAnimationFrame(t);return{cancel:()=>me.cancelAnimationFrame(e)}},getImageData(t,e=0){let r=me.document.createElement("canvas"),n=r.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return r.width=t.width,r.height=t.height,n.drawImage(t,0,0,t.width,t.height),n.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:t=>(nn||(nn=me.document.createElement("a")),nn.href=t,nn.href),get devicePixelRatio(){return me.devicePixelRatio},get prefersReducedMotion(){return!!me.matchMedia&&(_r==null&&(_r=me.matchMedia("(prefers-reduced-motion: reduce)")),_r.matches)}},O,S={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(O==null){let t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{O=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):t}catch{O=t}}return O},get EVENTS_URL(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},C={supported:!1,testSupport:function(t){!W&&V&&(ee?te(t):F=t)}},F,V,W=!1,ee=!1;function te(t){let e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,V),t.isContextLost())return;C.supported=!0}catch{}t.deleteTexture(e),W=!0}me.document&&(V=me.document.createElement("img"),V.onload=function(){F&&te(F),F=null,ee=!0},V.onerror=function(){W=!0,F=null},V.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let K="01",re="NO_ACCESS_TOKEN";function ue(t){return t.indexOf("mapbox:")===0}function pe(t){return S.API_URL_REGEX.test(t)}let ye=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Le(t){let e=t.match(ye);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function Oe(t){let e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function Ue(t){if(!t)return null;let e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(me.atob(e[1]).split("").map(r=>"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Ne{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){let r=Ue(S.ACCESS_TOKEN),n="";return n=r&&r.u?me.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(s,l)=>String.fromCharCode(Number("0x"+l)))):S.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){let e=kn("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{let s=me.localStorage.getItem(r);s&&(this.eventData=JSON.parse(s));let l=me.localStorage.getItem(n);l&&(this.anonId=l)}catch{zt("Unable to read from LocalStorage")}}saveEventData(){let e=kn("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{me.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&me.localStorage.setItem(r,JSON.stringify(this.eventData))}catch{zt("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,r,n,s){if(!S.EVENTS_URL)return;let l=Le(S.EVENTS_URL);l.params.push(`access_token=${s||S.ACCESS_TOKEN||""}`);let u={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:ji,skuId:K,userId:this.anonId},p=r?Lt(u,r):u,m={url:Oe(l),headers:{"Content-Type":"text/plain"},body:JSON.stringify([p])};this.pendingRequest=or(m,g=>{this.pendingRequest=null,n(g),this.saveEventData(),this.processRequests(s)})}queueRequest(e,r){this.queue.push(e),this.processRequests(r)}}let Ke=new class extends Ne{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){S.EVENTS_URL&&S.ACCESS_TOKEN&&Array.isArray(t)&&t.some(r=>ue(r)||pe(r))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let e=Ue(S.ACCESS_TOKEN),r=e?e.u:S.ACCESS_TOKEN,n=r!==this.eventData.tokenU;as(this.anonId)||(this.anonId=yo(),n=!0);let s=this.queue.shift();if(this.eventData.lastSuccess){let l=new Date(this.eventData.lastSuccess),u=new Date(s),p=(s-this.eventData.lastSuccess)/864e5;n=n||p>=1||p<-1||l.getDate()!==u.getDate()}else n=!0;if(!n)return this.processRequests();this.postEvent(s,{"enabled.telemetry":!1},l=>{l||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)},t)}},wt=Ke.postTurnstileEvent.bind(Ke),Et=new class extends Ne{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,r,n){this.skuToken=e,this.errorCb=n,S.EVENTS_URL&&(r||S.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(re)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;let{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),as(this.anonId)||(this.anonId=yo()),this.postEvent(r,{skuToken:this.skuToken},n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t))}},yt=Et.postMapLoadEvent.bind(Et),St=new class extends Ne{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,r,n){if(!S.API_URL||!S.SESSION_PATH)return;let s=Le(S.API_URL+S.SESSION_PATH);s.params.push(`sku=${e||""}`),s.params.push(`access_token=${n||S.ACCESS_TOKEN||""}`);let l={url:Oe(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Fc(l,u=>{this.pendingRequest=null,r(u),this.saveEventData(),this.processRequests(n)})}getSessionAPI(t,e,r,n){this.skuToken=e,this.errorCb=n,S.SESSION_PATH&&S.API_URL&&(r||S.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(re)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;let{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t)}},Pr=St.getSessionAPI.bind(St),gr=new Set,ti="mapbox-tiles",nr,cs,dl=500,pa=50;function xo(){me.caches&&!nr&&(nr=me.caches.open(ti))}function fa(t){let e=t.indexOf("?");return e<0?t:t.slice(0,e)}let hs=1/0,us={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(us);class vo extends Error{constructor(e,r,n){r===401&&pe(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=r,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}let ma=ir()?()=>self.worker&&self.worker.referrer:()=>(me.location.protocol==="blob:"?me.parent:me).location.href,Zi=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(ma())&&!/^\w+:/.test(r))){if(me.fetch&&me.Request&&me.AbortController&&me.Request.prototype.hasOwnProperty("signal"))return function(n,s){let l=new me.AbortController,u=new me.Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:ma(),signal:l.signal}),p=!1,m=!1,g=(x=u.url).indexOf("sku=")>0&&pe(x);var x;n.type==="json"&&u.headers.set("Accept","application/json");let v=(I,A,k)=>{if(m)return;if(I&&I.message!=="SecurityError"&&zt(I),A&&k)return b(A);let D=Date.now();me.fetch(u).then(U=>{if(U.ok){let $=g?U.clone():null;return b(U,$,D)}return s(new vo(U.statusText,U.status,n.url))}).catch(U=>{U.code!==20&&s(new Error(U.message))})},b=(I,A,k)=>{(n.type==="arrayBuffer"?I.arrayBuffer():n.type==="json"?I.json():I.text()).then(D=>{m||(A&&k&&function(U,$,H){if(xo(),!nr)return;let Y={status:$.status,statusText:$.statusText,headers:new me.Headers};$.headers.forEach((Q,he)=>Y.headers.set(he,Q));let J=zn($.headers.get("Cache-Control")||"");J["no-store"]||(J["max-age"]&&Y.headers.set("Expires",new Date(H+1e3*J["max-age"]).toUTCString()),new Date(Y.headers.get("Expires")).getTime()-H<42e4||function(Q,he){if(cs===void 0)try{new Response(new ReadableStream),cs=!0}catch{cs=!1}cs?he(Q.body):Q.blob().then(he)}($,Q=>{let he=new me.Response(Q,Y);xo(),nr&&nr.then(le=>le.put(fa(U.url),he)).catch(le=>zt(le.message))}))}(u,A,k),p=!0,s(null,D,I.headers.get("Cache-Control"),I.headers.get("Expires")))}).catch(D=>{m||s(new Error(D.message))})};return g?function(I,A){if(xo(),!nr)return A(null);let k=fa(I.url);nr.then(D=>{D.match(k).then(U=>{let $=function(H){if(!H)return!1;let Y=new Date(H.headers.get("Expires")||0),J=zn(H.headers.get("Cache-Control")||"");return Y>Date.now()&&!J["no-cache"]}(U);D.delete(k),$&&D.put(k,U.clone()),A(null,U,$)}).catch(A)}).catch(A)}(u,v):v(null,null),{cancel:()=>{m=!0,p||l.abort()}}}(t,e);if(ir()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(n,s){let l=new me.XMLHttpRequest;l.open(n.method||"GET",n.url,!0),n.type==="arrayBuffer"&&(l.responseType="arraybuffer");for(let u in n.headers)l.setRequestHeader(u,n.headers[u]);return n.type==="json"&&(l.responseType="text",l.setRequestHeader("Accept","application/json")),l.withCredentials=n.credentials==="include",l.onerror=()=>{s(new Error(l.statusText))},l.onload=()=>{if((l.status>=200&&l.status<300||l.status===0)&&l.response!==null){let u=l.response;if(n.type==="json")try{u=JSON.parse(l.response)}catch(p){return s(p)}s(null,u,l.getResponseHeader("Cache-Control"),l.getResponseHeader("Expires"))}else s(new vo(l.statusText,l.status,n.url))},l.send(n.body),{cancel:()=>l.abort()}}(t,e)},bo=function(t,e){return Zi(Lt(t,{type:"arrayBuffer"}),e)},or=function(t,e){return Zi(Lt(t,{method:"POST"}),e)},Fc=function(t,e){return Zi(Lt(t,{method:"GET"}),e)};function pl(t){let e=me.document.createElement("a");return e.href=t,e.protocol===me.document.location.protocol&&e.host===me.document.location.host}let Pn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=",Dn,wo;Dn=[],wo=0;let fl=function(t,e){if(C.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),wo>=S.MAX_PARALLEL_IMAGE_REQUESTS){let l={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return Dn.push(l),l}wo++;let r=!1,n=()=>{if(!r)for(r=!0,wo--;Dn.length&&wo<S.MAX_PARALLEL_IMAGE_REQUESTS;){let l=Dn.shift(),{requestParameters:u,callback:p,cancelled:m}=l;m||(l.cancel=fl(u,p).cancel)}},s=bo(t,(l,u,p,m)=>{n(),l?e(l):u&&(me.createImageBitmap?function(g,x){let v=new me.Blob([new Uint8Array(g)],{type:"image/png"});me.createImageBitmap(v).then(b=>{x(null,b)}).catch(b=>{x(new Error(`Could not load image because of ${b.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(g,x)=>e(g,x,p,m)):function(g,x){let v=new me.Image,b=me.URL;v.onload=()=>{x(null,v),b.revokeObjectURL(v.src),v.onload=null,me.requestAnimationFrame(()=>{v.src=Pn})},v.onerror=()=>x(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."));let I=new me.Blob([new Uint8Array(g)],{type:"image/png"});v.src=g.byteLength?b.createObjectURL(I):Pn}(u,(g,x)=>e(g,x,p,m)))});return{cancel:()=>{s.cancel(),n()}}};function ml(t,e,r){r[t]&&r[t].indexOf(e)!==-1||(r[t]=r[t]||[],r[t].push(e))}function ds(t,e,r){if(r&&r[t]){let n=r[t].indexOf(e);n!==-1&&r[t].splice(n,1)}}class Dr{constructor(e,r={}){Lt(this,r),this.type=e}}class ps extends Dr{constructor(e,r={}){super("error",Lt({error:e},r))}}class Lr{on(e,r){return this._listeners=this._listeners||{},ml(e,r,this._listeners),this}off(e,r){return ds(e,r,this._listeners),ds(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ml(e,r,this._oneTimeListeners),this):new Promise(n=>this.once(e,n))}fire(e,r){typeof e=="string"&&(e=new Dr(e,r||{}));let n=e.type;if(this.listens(n)){e.target=this;let s=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(let p of s)p.call(this,e);let l=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(let p of l)ds(n,p,this._oneTimeListeners),p.call(this,e);let u=this._eventedParent;u&&(Lt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),u.fire(e))}else e instanceof ps&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var se=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"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"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"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":true,"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":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"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":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"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_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"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":true,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"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":true,"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":false,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"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":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"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_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"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":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"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 Ae{constructor(e,r,n,s){this.message=(e?`${e}: `:"")+n,s&&(this.identifier=s),r!=null&&r.__line__&&(this.line=r.__line__)}}function _l(t){let e=t.value;return e?[new Ae(t.key,e,"constants have been deprecated as of v8")]:[]}function Br(t,...e){for(let r of e)for(let n in r)t[n]=r[n];return t}function Ft(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function yr(t){if(Array.isArray(t))return t.map(yr);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let r in t)e[r]=yr(t[r]);return e}return Ft(t)}class sr extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class fs{constructor(e,r=[]){this.parent=e,this.bindings={};for(let[n,s]of r)this.bindings[n]=s}concat(e){return new fs(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let Rr={kind:"null"},Me={kind:"number"},et={kind:"string"},We={kind:"boolean"},ar={kind:"color"},Ln={kind:"object"},He={kind:"value"},To={kind:"collator"},Fr={kind:"formatted"},Eo={kind:"resolvedImage"};function Di(t,e){return{kind:"array",itemType:t,N:e}}function kt(t){if(t.kind==="array"){let e=kt(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}let Oc=[Rr,Me,et,We,ar,Fr,Ln,Di(He),Eo];function di(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!di(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(let r of Oc)if(!di(r,e))return null}}return`Expected ${kt(t)} but found ${kt(e)} instead.`}function ms(t,e){return e.some(r=>r.kind===t.kind)}function Bn(t,e){return e.some(r=>r==="null"?t===null:r==="array"?Array.isArray(t):r==="object"?t&&!Array.isArray(t)&&typeof t=="object":r===typeof t)}function Rn(t){var e={exports:{}};return t(e,e.exports),e.exports}var Fn=Rn(function(t,e){var r={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 n(p){return(p=Math.round(p))<0?0:p>255?255:p}function s(p){return n(p[p.length-1]==="%"?parseFloat(p)/100*255:parseInt(p))}function l(p){return(m=p[p.length-1]==="%"?parseFloat(p)/100:parseFloat(p))<0?0:m>1?1:m;var m}function u(p,m,g){return g<0?g+=1:g>1&&(g-=1),6*g<1?p+(m-p)*g*6:2*g<1?m:3*g<2?p+(m-p)*(2/3-g)*6:p}try{e.parseCSSColor=function(p){var m,g=p.replace(/ /g,"").toLowerCase();if(g in r)return r[g].slice();if(g[0]==="#")return g.length===4?(m=parseInt(g.substr(1),16))>=0&&m<=4095?[(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1]:null:g.length===7&&(m=parseInt(g.substr(1),16))>=0&&m<=16777215?[(16711680&m)>>16,(65280&m)>>8,255&m,1]:null;var x=g.indexOf("("),v=g.indexOf(")");if(x!==-1&&v+1===g.length){var b=g.substr(0,x),I=g.substr(x+1,v-(x+1)).split(","),A=1;switch(b){case"rgba":if(I.length!==4)return null;A=l(I.pop());case"rgb":return I.length!==3?null:[s(I[0]),s(I[1]),s(I[2]),A];case"hsla":if(I.length!==4)return null;A=l(I.pop());case"hsl":if(I.length!==3)return null;var k=(parseFloat(I[0])%360+360)%360/360,D=l(I[1]),U=l(I[2]),$=U<=.5?U*(D+1):U+D-U*D,H=2*U-$;return[n(255*u(H,$,k+1/3)),n(255*u(H,$,k)),n(255*u(H,$,k-1/3)),A];default:return null}}return null}}catch{}});class lt{constructor(e,r,n,s=1){this.r=e,this.g=r,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof lt)return e;if(typeof e!="string")return;let r=Fn.parseCSSColor(e);return r?new lt(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){let[e,r,n,s]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(n)},${s})`}toArray(){let{r:e,g:r,b:n,a:s}=this;return s===0?[0,0,0,0]:[255*e/s,255*r/s,255*n/s,s]}}lt.black=new lt(0,0,0,1),lt.white=new lt(1,1,1,1),lt.transparent=new lt(0,0,0,0),lt.red=new lt(1,0,0,1),lt.blue=new lt(0,0,1,1);class _s{constructor(e,r,n){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class _a{constructor(e,r,n,s,l){this.text=e.normalize?e.normalize():e,this.image=r,this.scale=n,this.fontStack=s,this.textColor=l}}class $e{constructor(e){this.sections=e}static fromString(e){return new $e([new _a(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof $e?e:$e.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){let e=["format"];for(let r of this.sections){if(r.image){e.push(["image",r.image.name]);continue}e.push(r.text);let n={};r.fontStack&&(n["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(n["font-scale"]=r.scale),r.textColor&&(n["text-color"]=["rgba"].concat(r.textColor.toArray())),e.push(n)}return e}}class Li{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Li({name:e,available:!1}):null}serialize(){return["image",this.name]}}function gl(t,e,r,n){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?n===void 0||typeof n=="number"&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof n=="number"?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function gs(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof lt||t instanceof _s||t instanceof $e||t instanceof Li)return!0;if(Array.isArray(t)){for(let e of t)if(!gs(e))return!1;return!0}if(typeof t=="object"){for(let e in t)if(!gs(t[e]))return!1;return!0}return!1}function Ut(t){if(t===null)return Rr;if(typeof t=="string")return et;if(typeof t=="boolean")return We;if(typeof t=="number")return Me;if(t instanceof lt)return ar;if(t instanceof _s)return To;if(t instanceof $e)return Fr;if(t instanceof Li)return Eo;if(Array.isArray(t)){let e=t.length,r;for(let n of t){let s=Ut(n);if(r){if(r===s)continue;r=He;break}r=s}return Di(r||He,e)}return Ln}function So(t){let e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof lt||t instanceof $e||t instanceof Li?t.toString():JSON.stringify(t)}class Or{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!gs(e[1]))return r.error("invalid value");let n=e[1],s=Ut(n),l=r.expectedType;return s.kind!=="array"||s.N!==0||!l||l.kind!=="array"||typeof l.N=="number"&&l.N!==0||(s=l),new Or(s,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof lt?["rgba"].concat(this.value.toArray()):this.value instanceof $e?this.value.serialize():this.value}}class Wt{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let ys={string:et,number:Me,boolean:We,object:Ln};class Bi{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n,s=1,l=e[0];if(l==="array"){let p,m;if(e.length>2){let g=e[1];if(typeof g!="string"||!(g in ys)||g==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);p=ys[g],s++}else p=He;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);m=e[2],s++}n=Di(p,m)}else n=ys[l];let u=[];for(;s<e.length;s++){let p=r.parse(e[s],s,He);if(!p)return null;u.push(p)}return new Bi(n,u)}evaluate(e){for(let r=0;r<this.args.length;r++){let n=this.args[r].evaluate(e);if(!di(this.type,Ut(n)))return n;if(r===this.args.length-1)throw new Wt(`Expected value to be of type ${kt(this.type)}, but found ${kt(Ut(n))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=this.type,r=[e.kind];if(e.kind==="array"){let n=e.itemType;if(n.kind==="string"||n.kind==="number"||n.kind==="boolean"){r.push(n.kind);let s=e.N;(typeof s=="number"||this.args.length>1)&&r.push(s)}}return r.concat(this.args.map(n=>n.serialize()))}}class lr{constructor(e){this.type=Fr,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n=e[1];if(!Array.isArray(n)&&typeof n=="object")return r.error("First argument must be an image or text section.");let s=[],l=!1;for(let u=1;u<=e.length-1;++u){let p=e[u];if(l&&typeof p=="object"&&!Array.isArray(p)){l=!1;let m=null;if(p["font-scale"]&&(m=r.parse(p["font-scale"],1,Me),!m))return null;let g=null;if(p["text-font"]&&(g=r.parse(p["text-font"],1,Di(et)),!g))return null;let x=null;if(p["text-color"]&&(x=r.parse(p["text-color"],1,ar),!x))return null;let v=s[s.length-1];v.scale=m,v.font=g,v.textColor=x}else{let m=r.parse(e[u],1,He);if(!m)return null;let g=m.type.kind;if(g!=="string"&&g!=="value"&&g!=="null"&&g!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");l=!0,s.push({content:m,scale:null,font:null,textColor:null})}}return new lr(s)}evaluate(e){return new $e(this.sections.map(r=>{let n=r.content.evaluate(e);return Ut(n)===Eo?new _a("",n,null,null,null):new _a(So(n),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(let r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}serialize(){let e=["format"];for(let r of this.sections){e.push(r.content.serialize());let n={};r.scale&&(n["font-scale"]=r.scale.serialize()),r.font&&(n["text-font"]=r.font.serialize()),r.textColor&&(n["text-color"]=r.textColor.serialize()),e.push(n)}return e}}class on{constructor(e){this.type=Eo,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");let n=r.parse(e[1],1,et);return n?new on(n):r.error("No image name provided.")}evaluate(e){let r=this.input.evaluate(e),n=Li.fromString(r);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(r)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}let Uc={"to-boolean":We,"to-color":ar,"to-number":Me,"to-string":et};class cr{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n=e[0];if((n==="to-boolean"||n==="to-string")&&e.length!==2)return r.error("Expected one argument.");let s=Uc[n],l=[];for(let u=1;u<e.length;u++){let p=r.parse(e[u],u,He);if(!p)return null;l.push(p)}return new cr(s,l)}evaluate(e){if(this.type.kind==="boolean")return Boolean(this.args[0].evaluate(e));if(this.type.kind==="color"){let r,n;for(let s of this.args){if(r=s.evaluate(e),n=null,r instanceof lt)return r;if(typeof r=="string"){let l=e.parseColor(r);if(l)return l}else if(Array.isArray(r)&&(n=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:gl(r[0],r[1],r[2],r[3]),!n))return new lt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Wt(n||`Could not parse color from value '${typeof r=="string"?r:String(JSON.stringify(r))}'`)}if(this.type.kind==="number"){let r=null;for(let n of this.args){if(r=n.evaluate(e),r===null)return 0;let s=Number(r);if(!isNaN(s))return s}throw new Wt(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?$e.fromString(So(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?Li.fromString(So(this.args[0].evaluate(e))):So(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new lr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new on(this.args[0]).serialize();let e=[`to-${this.type.kind}`];return this.eachChild(r=>{e.push(r.serialize())}),e}}let yl=["Unknown","Point","LineString","Polygon"];class xl{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?yl[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){let e=this.featureDistanceData.center,r=this.featureDistanceData.scale,{x:n,y:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*r-e[0])+this.featureDistanceData.bearing[1]*(s*r-e[1])}return 0}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=lt.parse(e)),r}}class bi{constructor(e,r,n,s){this.name=e,this.type=r,this._evaluate=n,this.args=s}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,r){let n=e[0],s=bi.definitions[n];if(!s)return r.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);let l=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=u.filter(([g])=>!Array.isArray(g)||g.length===e.length-1),m=null;for(let[g,x]of p){m=new bs(r.registry,r.path,null,r.scope);let v=[],b=!1;for(let I=1;I<e.length;I++){let A=e[I],k=Array.isArray(g)?g[I-1]:g.type,D=m.parse(A,1+v.length,k);if(!D){b=!0;break}v.push(D)}if(!b)if(Array.isArray(g)&&g.length!==v.length)m.error(`Expected ${g.length} arguments, but found ${v.length} instead.`);else{for(let I=0;I<v.length;I++){let A=Array.isArray(g)?g[I]:g.type,k=v[I];m.concat(I+1).checkSubtype(A,k.type)}if(m.errors.length===0)return new bi(n,l,x,v)}}if(p.length===1)r.errors.push(...m.errors);else{let g=(p.length?p:u).map(([v])=>{return b=v,Array.isArray(b)?`(${b.map(kt).join(", ")})`:`(${kt(b.type)}...)`;var b}).join(" | "),x=[];for(let v=1;v<e.length;v++){let b=r.parse(e[v],1+x.length);if(!b)return null;x.push(kt(b.type))}r.error(`Expected arguments of type ${g}, but found (${x.join(", ")}) instead.`)}return null}static register(e,r){bi.definitions=r;for(let n in r)e[n]=bi}}class Io{constructor(e,r,n){this.type=To,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");let n=e[1];if(typeof n!="object"||Array.isArray(n))return r.error("Collator options argument must be an object.");let s=r.parse(n["case-sensitive"]!==void 0&&n["case-sensitive"],1,We);if(!s)return null;let l=r.parse(n["diacritic-sensitive"]!==void 0&&n["diacritic-sensitive"],1,We);if(!l)return null;let u=null;return n.locale&&(u=r.parse(n.locale,1,et),!u)?null:new Io(s,l,u)}evaluate(e){return new _s(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){let e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}let Ur=8192;function xs(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 Mo(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function vl(t,e){let r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(r*s*Ur),Math.round(n*s*Ur)]}function bl(t,e,r){let n=t[0]-e[0],s=t[1]-e[1],l=t[0]-r[0],u=t[1]-r[1];return n*u-l*s==0&&n*l<=0&&s*u<=0}function ga(t,e){let r=!1;for(let u=0,p=e.length;u<p;u++){let m=e[u];for(let g=0,x=m.length;g<x-1;g++){if(bl(t,m[g],m[g+1]))return!1;(s=m[g])[1]>(n=t)[1]!=(l=m[g+1])[1]>n[1]&&n[0]<(l[0]-s[0])*(n[1]-s[1])/(l[1]-s[1])+s[0]&&(r=!r)}}var n,s,l;return r}function wl(t,e){for(let r=0;r<e.length;r++)if(ga(t,e[r]))return!0;return!1}function ya(t,e,r,n){let s=n[0]-r[0],l=n[1]-r[1],u=(t[0]-r[0])*l-s*(t[1]-r[1]),p=(e[0]-r[0])*l-s*(e[1]-r[1]);return u>0&&p<0||u<0&&p>0}function Vc(t,e,r){for(let g of r)for(let x=0;x<g.length-1;++x)if((p=[(u=g[x+1])[0]-(l=g[x])[0],u[1]-l[1]])[0]*(m=[(s=e)[0]-(n=t)[0],s[1]-n[1]])[1]-p[1]*m[0]!=0&&ya(n,s,l,u)&&ya(l,u,n,s))return!0;var n,s,l,u,p,m;return!1}function Tl(t,e){for(let r=0;r<t.length;++r)if(!ga(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(Vc(t[r],t[r+1],e))return!1;return!0}function Nc(t,e){for(let r=0;r<e.length;r++)if(Tl(t,e[r]))return!0;return!1}function xa(t,e,r){let n=[];for(let s=0;s<t.length;s++){let l=[];for(let u=0;u<t[s].length;u++){let p=vl(t[s][u],r);xs(e,p),l.push(p)}n.push(l)}return n}function El(t,e,r){let n=[];for(let s=0;s<t.length;s++){let l=xa(t[s],e,r);n.push(l)}return n}function va(t,e,r,n){if(t[0]<r[0]||t[0]>r[2]){let s=.5*n,l=t[0]-r[0]>s?-n:r[0]-t[0]>s?n:0;l===0&&(l=t[0]-r[2]>s?-n:r[2]-t[0]>s?n:0),t[0]+=l}xs(e,t)}function Sl(t,e,r,n){let s=Math.pow(2,n.z)*Ur,l=[n.x*Ur,n.y*Ur],u=[];for(let p of t)for(let m of p){let g=[m.x+l[0],m.y+l[1]];va(g,e,r,s),u.push(g)}return u}function Il(t,e,r,n){let s=Math.pow(2,n.z)*Ur,l=[n.x*Ur,n.y*Ur],u=[];for(let m of t){let g=[];for(let x of m){let v=[x.x+l[0],x.y+l[1]];xs(e,v),g.push(v)}u.push(g)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(let m of u)for(let g of m)va(g,e,r,s)}var p;return u}class sn{constructor(e,r){this.type=We,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(gs(e[1])){let n=e[1];if(n.type==="FeatureCollection")for(let s=0;s<n.features.length;++s){let l=n.features[s].geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new sn(n,n.features[s].geometry)}else if(n.type==="Feature"){let s=n.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new sn(n,n.geometry)}else if(n.type==="Polygon"||n.type==="MultiPolygon")return new sn(n,n)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,n){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=r.canonicalID();if(n.type==="Polygon"){let p=xa(n.coordinates,l,u),m=Sl(r.geometry(),s,l,u);if(!Mo(s,l))return!1;for(let g of m)if(!ga(g,p))return!1}if(n.type==="MultiPolygon"){let p=El(n.coordinates,l,u),m=Sl(r.geometry(),s,l,u);if(!Mo(s,l))return!1;for(let g of m)if(!wl(g,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,n){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=r.canonicalID();if(n.type==="Polygon"){let p=xa(n.coordinates,l,u),m=Il(r.geometry(),s,l,u);if(!Mo(s,l))return!1;for(let g of m)if(!Tl(g,p))return!1}if(n.type==="MultiPolygon"){let p=El(n.coordinates,l,u),m=Il(r.geometry(),s,l,u);if(!Mo(s,l))return!1;for(let g of m)if(!Nc(g,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function On(t){if(t instanceof bi&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof sn)return!1;let e=!0;return t.eachChild(r=>{e&&!On(r)&&(e=!1)}),e}function Ao(t){if(t instanceof bi&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(r=>{e&&!Ao(r)&&(e=!1)}),e}function Co(t,e){if(t instanceof bi&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild(n=>{r&&!Co(n,e)&&(r=!1)}),r}class vs{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let n=e[1];return r.scope.has(n)?new vs(n,r.scope.get(n)):r.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class bs{constructor(e,r=[],n,s=new fs,l=[]){this.registry=e,this.path=r,this.key=r.map(u=>`[${u}]`).join(""),this.scope=s,this.errors=l,this.expectedType=n}parse(e,r,n,s,l={}){return r?this.concat(r,n,s)._parse(e,l):this._parse(e,l)}_parse(e,r){function n(s,l,u){return u==="assert"?new Bi(l,[s]):u==="coerce"?new cr(l,[s]):s}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let s=e[0];if(typeof s!="string")return this.error(`Expression name must be a string, but found ${typeof s} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let l=this.registry[s];if(l){let u=l.parse(e,this);if(!u)return null;if(this.expectedType){let p=this.expectedType,m=u.type;if(p.kind!=="string"&&p.kind!=="number"&&p.kind!=="boolean"&&p.kind!=="object"&&p.kind!=="array"||m.kind!=="value")if(p.kind!=="color"&&p.kind!=="formatted"&&p.kind!=="resolvedImage"||m.kind!=="value"&&m.kind!=="string"){if(this.checkSubtype(p,m))return null}else u=n(u,p,r.typeAnnotation||"coerce");else u=n(u,p,r.typeAnnotation||"assert")}if(!(u instanceof Or)&&u.type.kind!=="resolvedImage"&&ws(u)){let p=new xl;try{u=new Or(u.type,u.evaluate(p))}catch(m){return this.error(m.message),null}}return u}return this.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,n){let s=typeof e=="number"?this.path.concat(e):this.path,l=n?this.scope.concat(n):this.scope;return new bs(this.registry,s,r||null,l,this.errors)}error(e,...r){let n=`${this.key}${r.map(s=>`[${s}]`).join("")}`;this.errors.push(new sr(n,e))}checkSubtype(e,r){let n=di(e,r);return n&&this.error(n),n}}function ws(t){if(t instanceof vs)return ws(t.boundExpression);if(t instanceof bi&&t.name==="error"||t instanceof Io||t instanceof sn)return!1;let e=t instanceof cr||t instanceof Bi,r=!0;return t.eachChild(n=>{r=e?r&&ws(n):r&&n instanceof Or}),!!r&&On(t)&&Co(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function zo(t,e){let r=t.length-1,n,s,l=0,u=r,p=0;for(;l<=u;)if(p=Math.floor((l+u)/2),n=t[p],s=t[p+1],n<=e){if(p===r||e<s)return p;l=p+1}else{if(!(n>e))throw new Wt("Input is not a number.");u=p-1}return 0}class ko{constructor(e,r,n){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(let[s,l]of n)this.labels.push(s),this.outputs.push(l)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");let n=r.parse(e[1],1,Me);if(!n)return null;let s=[],l=null;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let u=1;u<e.length;u+=2){let p=u===1?-1/0:e[u],m=e[u+1],g=u,x=u+1;if(typeof p!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',g);if(s.length&&s[s.length-1][0]>=p)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',g);let v=r.parse(m,x,l);if(!v)return null;l=l||v.type,s.push([p,v])}return new ko(l,n,s)}evaluate(e){let r=this.labels,n=this.outputs;if(r.length===1)return n[0].evaluate(e);let s=this.input.evaluate(e);if(s<=r[0])return n[0].evaluate(e);let l=r.length;return s>=r[l-1]?n[l-1].evaluate(e):n[zo(r,s)].evaluate(e)}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e=["step",this.input.serialize()];for(let r=0;r<this.labels.length;r++)r>0&&e.push(this.labels[r]),e.push(this.outputs[r].serialize());return e}}function pt(t,e,r){return t*(1-r)+e*r}var Ts=Object.freeze({__proto__:null,number:pt,color:function(t,e,r){return new lt(pt(t.r,e.r,r),pt(t.g,e.g,r),pt(t.b,e.b,r),pt(t.a,e.a,r))},array:function(t,e,r){return t.map((n,s)=>pt(n,e[s],r))}});let Ml=.95047,Po=1.08883,ba=4/29,Es=6/29,Al=3*Es*Es,jc=Math.PI/180,Gc=180/Math.PI;function Ss(t){return t>.008856451679035631?Math.pow(t,1/3):t/Al+ba}function Is(t){return t>Es?t*t*t:Al*(t-ba)}function Ms(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Do(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Cl(t){let e=Do(t.r),r=Do(t.g),n=Do(t.b),s=Ss((.4124564*e+.3575761*r+.1804375*n)/Ml),l=Ss((.2126729*e+.7151522*r+.072175*n)/1);return{l:116*l-16,a:500*(s-l),b:200*(l-Ss((.0193339*e+.119192*r+.9503041*n)/Po)),alpha:t.a}}function zl(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Is(e),r=Ml*Is(r),n=Po*Is(n),new lt(Ms(3.2404542*r-1.5371385*e-.4985314*n),Ms(-.969266*r+1.8760108*e+.041556*n),Ms(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function Zc(t,e,r){let n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}let Lo={forward:Cl,reverse:zl,interpolate:function(t,e,r){return{l:pt(t.l,e.l,r),a:pt(t.a,e.a,r),b:pt(t.b,e.b,r),alpha:pt(t.alpha,e.alpha,r)}}},Bo={forward:function(t){let{l:e,a:r,b:n}=Cl(t),s=Math.atan2(n,r)*Gc;return{h:s<0?s+360:s,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){let e=t.h*jc,r=t.c;return zl({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:Zc(t.h,e.h,r),c:pt(t.c,e.c,r),l:pt(t.l,e.l,r),alpha:pt(t.alpha,e.alpha,r)}}};var kl=Object.freeze({__proto__:null,lab:Lo,hcl:Bo});class pi{constructor(e,r,n,s,l){this.type=e,this.operator=r,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(let[u,p]of l)this.labels.push(u),this.outputs.push(p)}static interpolationFactor(e,r,n,s){let l=0;if(e.name==="exponential")l=As(r,e.base,n,s);else if(e.name==="linear")l=As(r,1,n,s);else if(e.name==="cubic-bezier"){let u=e.controlPoints;l=new Ar(u[0],u[1],u[2],u[3]).solve(As(r,1,n,s))}return l}static parse(e,r){let[n,s,l,...u]=e;if(!Array.isArray(s)||s.length===0)return r.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){let g=s[1];if(typeof g!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:g}}else{if(s[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(s[0])}`,1,0);{let g=s.slice(1);if(g.length!==4||g.some(x=>typeof x!="number"||x<0||x>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:g}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(l=r.parse(l,2,Me),!l)return null;let p=[],m=null;n==="interpolate-hcl"||n==="interpolate-lab"?m=ar:r.expectedType&&r.expectedType.kind!=="value"&&(m=r.expectedType);for(let g=0;g<u.length;g+=2){let x=u[g],v=u[g+1],b=g+3,I=g+4;if(typeof x!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',b);if(p.length&&p[p.length-1][0]>=x)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',b);let A=r.parse(v,I,m);if(!A)return null;m=m||A.type,p.push([x,A])}return m.kind==="number"||m.kind==="color"||m.kind==="array"&&m.itemType.kind==="number"&&typeof m.N=="number"?new pi(m,n,s,l,p):r.error(`Type ${kt(m)} is not interpolatable.`)}evaluate(e){let r=this.labels,n=this.outputs;if(r.length===1)return n[0].evaluate(e);let s=this.input.evaluate(e);if(s<=r[0])return n[0].evaluate(e);let l=r.length;if(s>=r[l-1])return n[l-1].evaluate(e);let u=zo(r,s),p=pi.interpolationFactor(this.interpolation,s,r[u],r[u+1]),m=n[u].evaluate(e),g=n[u+1].evaluate(e);return this.operator==="interpolate"?Ts[this.type.kind.toLowerCase()](m,g,p):this.operator==="interpolate-hcl"?Bo.reverse(Bo.interpolate(Bo.forward(m),Bo.forward(g),p)):Lo.reverse(Lo.interpolate(Lo.forward(m),Lo.forward(g),p))}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);let r=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)r.push(this.labels[n],this.outputs[n].serialize());return r}}function As(t,e,r,n){let s=n-r,l=t-r;return s===0?0:e===1?l/s:(Math.pow(e,l)-1)/(Math.pow(e,s)-1)}class an{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let n=null,s=r.expectedType;s&&s.kind!=="value"&&(n=s);let l=[];for(let p of e.slice(1)){let m=r.parse(p,1+l.length,n,void 0,{typeAnnotation:"omit"});if(!m)return null;n=n||m.type,l.push(m)}let u=s&&l.some(p=>di(s,p.type));return new an(u?He:n,l)}evaluate(e){let r,n=null,s=0;for(let l of this.args){if(s++,n=l.evaluate(e),n&&n instanceof Li&&!n.available&&(r||(r=n),n=null,s===this.args.length))return r;if(n!==null)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=["coalesce"];return this.eachChild(r=>{e.push(r.serialize())}),e}}class Cs{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let n=[];for(let l=1;l<e.length-1;l+=2){let u=e[l];if(typeof u!="string")return r.error(`Expected string, but found ${typeof u} instead.`,l);if(/[^a-zA-Z0-9_]/.test(u))return r.error("Variable names must contain only alphanumeric characters or '_'.",l);let p=r.parse(e[l+1],l+1);if(!p)return null;n.push([u,p])}let s=r.parse(e[e.length-1],e.length-1,r.expectedType,n);return s?new Cs(n,s):null}outputDefined(){return this.result.outputDefined()}serialize(){let e=["let"];for(let[r,n]of this.bindings)e.push(r,n.serialize());return e.push(this.result.serialize()),e}}class wa{constructor(e,r,n){this.type=e,this.index=r,this.input=n}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,Me),s=r.parse(e[2],2,Di(r.expectedType||He));return n&&s?new wa(s.type.itemType,n,s):null}evaluate(e){let r=this.index.evaluate(e),n=this.input.evaluate(e);if(r<0)throw new Wt(`Array index out of bounds: ${r} < 0.`);if(r>=n.length)throw new Wt(`Array index out of bounds: ${r} > ${n.length-1}.`);if(r!==Math.floor(r))throw new Wt(`Array index must be an integer, but found ${r} instead.`);return n[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ta{constructor(e,r){this.type=We,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,He),s=r.parse(e[2],2,He);return n&&s?ms(n.type,[We,et,Me,Rr,He])?new Ta(n,s):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${kt(n.type)} instead`):null}evaluate(e){let r=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!Bn(r,["boolean","string","number","null"]))throw new Wt(`Expected first argument to be of type boolean, string, number or null, but found ${kt(Ut(r))} instead.`);if(!Bn(n,["string","array"]))throw new Wt(`Expected second argument to be of type array or string, but found ${kt(Ut(n))} instead.`);return n.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class $i{constructor(e,r,n){this.type=Me,this.needle=e,this.haystack=r,this.fromIndex=n}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,He),s=r.parse(e[2],2,He);if(!n||!s)return null;if(!ms(n.type,[We,et,Me,Rr,He]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${kt(n.type)} instead`);if(e.length===4){let l=r.parse(e[3],3,Me);return l?new $i(n,s,l):null}return new $i(n,s)}evaluate(e){let r=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Bn(r,["boolean","string","number","null"]))throw new Wt(`Expected first argument to be of type boolean, string, number or null, but found ${kt(Ut(r))} instead.`);if(!Bn(n,["string","array"]))throw new Wt(`Expected second argument to be of type array or string, but found ${kt(Ut(n))} instead.`);if(this.fromIndex){let s=this.fromIndex.evaluate(e);return n.indexOf(r,s)}return n.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){let e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class zs{constructor(e,r,n,s,l,u){this.inputType=e,this.type=r,this.input=n,this.cases=s,this.outputs=l,this.otherwise=u}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let n,s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);let l={},u=[];for(let g=2;g<e.length-1;g+=2){let x=e[g],v=e[g+1];Array.isArray(x)||(x=[x]);let b=r.concat(g);if(x.length===0)return b.error("Expected at least one branch label.");for(let A of x){if(typeof A!="number"&&typeof A!="string")return b.error("Branch labels must be numbers or strings.");if(typeof A=="number"&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return b.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof A=="number"&&Math.floor(A)!==A)return b.error("Numeric branch labels must be integer values.");if(n){if(b.checkSubtype(n,Ut(A)))return null}else n=Ut(A);if(l[String(A)]!==void 0)return b.error("Branch labels must be unique.");l[String(A)]=u.length}let I=r.parse(v,g,s);if(!I)return null;s=s||I.type,u.push(I)}let p=r.parse(e[1],1,He);if(!p)return null;let m=r.parse(e[e.length-1],e.length-1,s);return m?p.type.kind!=="value"&&r.concat(1).checkSubtype(n,p.type)?null:new zs(n,s,p,l,u,m):null}evaluate(e){let r=this.input.evaluate(e);return(Ut(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),n=[],s={};for(let u of r){let p=s[this.cases[u]];p===void 0?(s[this.cases[u]]=n.length,n.push([this.cases[u],[u]])):n[p][1].push(u)}let l=u=>this.inputType.kind==="number"?Number(u):u;for(let[u,p]of n)e.push(p.length===1?l(p[0]):p.map(l)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}class Vr{constructor(e,r,n){this.type=e,this.branches=r,this.otherwise=n}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let n;r.expectedType&&r.expectedType.kind!=="value"&&(n=r.expectedType);let s=[];for(let u=1;u<e.length-1;u+=2){let p=r.parse(e[u],u,We);if(!p)return null;let m=r.parse(e[u+1],u+1,n);if(!m)return null;s.push([p,m]),n=n||m.type}let l=r.parse(e[e.length-1],e.length-1,n);return l?new Vr(n,s,l):null}evaluate(e){for(let[r,n]of this.branches)if(r.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[r,n]of this.branches)e(r),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["case"];return this.eachChild(r=>{e.push(r.serialize())}),e}}class Ro{constructor(e,r,n,s){this.type=e,this.input=r,this.beginIndex=n,this.endIndex=s}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,He),s=r.parse(e[2],2,Me);if(!n||!s)return null;if(!ms(n.type,[Di(He),et,He]))return r.error(`Expected first argument to be of type array or string, but found ${kt(n.type)} instead`);if(e.length===4){let l=r.parse(e[3],3,Me);return l?new Ro(n.type,n,s,l):null}return new Ro(n.type,n,s)}evaluate(e){let r=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Bn(r,["string","array"]))throw new Wt(`Expected first argument to be of type array or string, but found ${kt(Ut(r))} instead.`);if(this.endIndex){let s=this.endIndex.evaluate(e);return r.slice(n,s)}return r.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){let e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Pl(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function ks(t,e,r,n){return n.compare(e,r)===0}function Nr(t,e,r){let n=t!=="=="&&t!=="!=";return class gp{constructor(l,u,p){this.type=We,this.lhs=l,this.rhs=u,this.collator=p,this.hasUntypedArgument=l.type.kind==="value"||u.type.kind==="value"}static parse(l,u){if(l.length!==3&&l.length!==4)return u.error("Expected two or three arguments.");let p=l[0],m=u.parse(l[1],1,He);if(!m)return null;if(!Pl(p,m.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${kt(m.type)}'.`);let g=u.parse(l[2],2,He);if(!g)return null;if(!Pl(p,g.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${kt(g.type)}'.`);if(m.type.kind!==g.type.kind&&m.type.kind!=="value"&&g.type.kind!=="value")return u.error(`Cannot compare types '${kt(m.type)}' and '${kt(g.type)}'.`);n&&(m.type.kind==="value"&&g.type.kind!=="value"?m=new Bi(g.type,[m]):m.type.kind!=="value"&&g.type.kind==="value"&&(g=new Bi(m.type,[g])));let x=null;if(l.length===4){if(m.type.kind!=="string"&&g.type.kind!=="string"&&m.type.kind!=="value"&&g.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(x=u.parse(l[3],3,To),!x)return null}return new gp(m,g,x)}evaluate(l){let u=this.lhs.evaluate(l),p=this.rhs.evaluate(l);if(n&&this.hasUntypedArgument){let m=Ut(u),g=Ut(p);if(m.kind!==g.kind||m.kind!=="string"&&m.kind!=="number")throw new Wt(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${m.kind}, ${g.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){let m=Ut(u),g=Ut(p);if(m.kind!=="string"||g.kind!=="string")return e(l,u,p)}return this.collator?r(l,u,p,this.collator.evaluate(l)):e(l,u,p)}eachChild(l){l(this.lhs),l(this.rhs),this.collator&&l(this.collator)}outputDefined(){return!0}serialize(){let l=[t];return this.eachChild(u=>{l.push(u.serialize())}),l}}}let Dl=Nr("==",function(t,e,r){return e===r},ks),Ea=Nr("!=",function(t,e,r){return e!==r},function(t,e,r,n){return!ks(0,e,r,n)}),Sa=Nr("<",function(t,e,r){return e<r},function(t,e,r,n){return n.compare(e,r)<0}),Ll=Nr(">",function(t,e,r){return e>r},function(t,e,r,n){return n.compare(e,r)>0}),Ia=Nr("<=",function(t,e,r){return e<=r},function(t,e,r,n){return n.compare(e,r)<=0}),Bl=Nr(">=",function(t,e,r){return e>=r},function(t,e,r,n){return n.compare(e,r)>=0});class Ps{constructor(e,r,n,s,l){this.type=et,this.number=e,this.locale=r,this.currency=n,this.minFractionDigits=s,this.maxFractionDigits=l}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");let n=r.parse(e[1],1,Me);if(!n)return null;let s=e[2];if(typeof s!="object"||Array.isArray(s))return r.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=r.parse(s.locale,1,et),!l))return null;let u=null;if(s.currency&&(u=r.parse(s.currency,1,et),!u))return null;let p=null;if(s["min-fraction-digits"]&&(p=r.parse(s["min-fraction-digits"],1,Me),!p))return null;let m=null;return s["max-fraction-digits"]&&(m=r.parse(s["max-fraction-digits"],1,Me),!m)?null:new Ps(n,l,u,p,m)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){let e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Ds{constructor(e){this.type=Me,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=r.parse(e[1],1);return n?n.type.kind!=="array"&&n.type.kind!=="string"&&n.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${kt(n.type)} instead.`):new Ds(n):null}evaluate(e){let r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Wt(`Expected value to be of type string or array, but found ${kt(Ut(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){let e=["length"];return this.eachChild(r=>{e.push(r.serialize())}),e}}let qi={"==":Dl,"!=":Ea,">":Ll,"<":Sa,">=":Bl,"<=":Ia,array:Bi,at:wa,boolean:Bi,case:Vr,coalesce:an,collator:Io,format:lr,image:on,in:Ta,"index-of":$i,interpolate:pi,"interpolate-hcl":pi,"interpolate-lab":pi,length:Ds,let:Cs,literal:Or,match:zs,number:Bi,"number-format":Ps,object:Bi,slice:Ro,step:ko,string:Bi,"to-boolean":cr,"to-color":cr,"to-number":cr,"to-string":cr,var:vs,within:sn};function Ma(t,[e,r,n,s]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);let l=s?s.evaluate(t):1,u=gl(e,r,n,l);if(u)throw new Wt(u);return new lt(e/255*l,r/255*l,n/255*l,l)}function Aa(t,e){return t in e}function Fo(t,e){let r=e[t];return r===void 0?null:r}function jr(t){return{type:t}}function Rl(t){return{result:"success",value:t}}function xr(t){return{result:"error",value:t}}function Un(t){return t["property-type"]==="data-driven"||t["property-type"]==="cross-faded-data-driven"}function Fl(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Ca(t){return!!t.expression&&t.expression.interpolated}function ht(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}function Ls(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Bs(t){return t}function Oo(t,e){let r=e.type==="color",n=t.stops&&typeof t.stops[0][0]=="object",s=n||!(n||t.property!==void 0),l=t.type||(Ca(e)?"exponential":"interval");if(r&&((t=Br({},t)).stops&&(t.stops=t.stops.map(g=>[g[0],lt.parse(g[1])])),t.default=lt.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!kl[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let u,p,m;if(l==="exponential")u=Ol;else if(l==="interval")u=$c;else if(l==="categorical"){u=Rs,p=Object.create(null);for(let g of t.stops)p[g[0]]=g[1];m=typeof t.stops[0][0]}else{if(l!=="identity")throw new Error(`Unknown function type "${l}"`);u=qc}if(n){let g={},x=[];for(let I=0;I<t.stops.length;I++){let A=t.stops[I],k=A[0].zoom;g[k]===void 0&&(g[k]={zoom:k,type:t.type,property:t.property,default:t.default,stops:[]},x.push(k)),g[k].stops.push([A[0].value,A[1]])}let v=[];for(let I of x)v.push([g[I].zoom,Oo(g[I],e)]);let b={name:"linear"};return{kind:"composite",interpolationType:b,interpolationFactor:pi.interpolationFactor.bind(void 0,b),zoomStops:v.map(I=>I[0]),evaluate:({zoom:I},A)=>Ol({stops:v,base:t.base},e,I).evaluate(I,A)}}if(s){let g=l==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:g,interpolationFactor:pi.interpolationFactor.bind(void 0,g),zoomStops:t.stops.map(x=>x[0]),evaluate:({zoom:x})=>u(t,e,x,p,m)}}return{kind:"source",evaluate(g,x){let v=x&&x.properties?x.properties[t.property]:void 0;return v===void 0?ii(t.default,e.default):u(t,e,v,p,m)}}}function ii(t,e,r){return t!==void 0?t:e!==void 0?e:r!==void 0?r:void 0}function Rs(t,e,r,n,s){return ii(typeof r===s?n[r]:void 0,t.default,e.default)}function $c(t,e,r){if(ht(r)!=="number")return ii(t.default,e.default);let n=t.stops.length;if(n===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];let s=zo(t.stops.map(l=>l[0]),r);return t.stops[s][1]}function Ol(t,e,r){let n=t.base!==void 0?t.base:1;if(ht(r)!=="number")return ii(t.default,e.default);let s=t.stops.length;if(s===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[s-1][0])return t.stops[s-1][1];let l=zo(t.stops.map(x=>x[0]),r),u=function(x,v,b,I){let A=I-b,k=x-b;return A===0?0:v===1?k/A:(Math.pow(v,k)-1)/(Math.pow(v,A)-1)}(r,n,t.stops[l][0],t.stops[l+1][0]),p=t.stops[l][1],m=t.stops[l+1][1],g=Ts[e.type]||Bs;if(t.colorSpace&&t.colorSpace!=="rgb"){let x=kl[t.colorSpace];g=(v,b)=>x.reverse(x.interpolate(x.forward(v),x.forward(b),u))}return typeof p.evaluate=="function"?{evaluate(...x){let v=p.evaluate.apply(void 0,x),b=m.evaluate.apply(void 0,x);if(v!==void 0&&b!==void 0)return g(v,b,u)}}:g(p,m,u)}function qc(t,e,r){return e.type==="color"?r=lt.parse(r):e.type==="formatted"?r=$e.fromString(r.toString()):e.type==="resolvedImage"?r=Li.fromString(r.toString()):ht(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0),ii(r,t.default,e.default)}bi.register(qi,{error:[{kind:"error"},[et],(t,[e])=>{throw new Wt(e.evaluate(t))}],typeof:[et,[He],(t,[e])=>kt(Ut(e.evaluate(t)))],"to-rgba":[Di(Me,4),[ar],(t,[e])=>e.evaluate(t).toArray()],rgb:[ar,[Me,Me,Me],Ma],rgba:[ar,[Me,Me,Me,Me],Ma],has:{type:We,overloads:[[[et],(t,[e])=>Aa(e.evaluate(t),t.properties())],[[et,Ln],(t,[e,r])=>Aa(e.evaluate(t),r.evaluate(t))]]},get:{type:He,overloads:[[[et],(t,[e])=>Fo(e.evaluate(t),t.properties())],[[et,Ln],(t,[e,r])=>Fo(e.evaluate(t),r.evaluate(t))]]},"feature-state":[He,[et],(t,[e])=>Fo(e.evaluate(t),t.featureState||{})],properties:[Ln,[],t=>t.properties()],"geometry-type":[et,[],t=>t.geometryType()],id:[He,[],t=>t.id()],zoom:[Me,[],t=>t.globals.zoom],pitch:[Me,[],t=>t.globals.pitch||0],"distance-from-center":[Me,[],t=>t.distanceFromCenter()],"heatmap-density":[Me,[],t=>t.globals.heatmapDensity||0],"line-progress":[Me,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Me,[],t=>t.globals.skyRadialProgress||0],accumulated:[He,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[Me,jr(Me),(t,e)=>{let r=0;for(let n of e)r+=n.evaluate(t);return r}],"*":[Me,jr(Me),(t,e)=>{let r=1;for(let n of e)r*=n.evaluate(t);return r}],"-":{type:Me,overloads:[[[Me,Me],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Me],(t,[e])=>-e.evaluate(t)]]},"/":[Me,[Me,Me],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Me,[Me,Me],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Me,[],()=>Math.LN2],pi:[Me,[],()=>Math.PI],e:[Me,[],()=>Math.E],"^":[Me,[Me,Me],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Me,[Me],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Me,[Me],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Me,[Me],(t,[e])=>Math.log(e.evaluate(t))],log2:[Me,[Me],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Me,[Me],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Me,[Me],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Me,[Me],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Me,[Me],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Me,[Me],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Me,[Me],(t,[e])=>Math.atan(e.evaluate(t))],min:[Me,jr(Me),(t,e)=>Math.min(...e.map(r=>r.evaluate(t)))],max:[Me,jr(Me),(t,e)=>Math.max(...e.map(r=>r.evaluate(t)))],abs:[Me,[Me],(t,[e])=>Math.abs(e.evaluate(t))],round:[Me,[Me],(t,[e])=>{let r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Me,[Me],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Me,[Me],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[We,[et,He],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[We,[He],(t,[e])=>t.id()===e.value],"filter-type-==":[We,[et],(t,[e])=>t.geometryType()===e.value],"filter-<":[We,[et,He],(t,[e,r])=>{let n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n<s}],"filter-id-<":[We,[He],(t,[e])=>{let r=t.id(),n=e.value;return typeof r==typeof n&&r<n}],"filter->":[We,[et,He],(t,[e,r])=>{let n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n>s}],"filter-id->":[We,[He],(t,[e])=>{let r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[We,[et,He],(t,[e,r])=>{let n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[We,[He],(t,[e])=>{let r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[We,[et,He],(t,[e,r])=>{let n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[We,[He],(t,[e])=>{let r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[We,[He],(t,[e])=>e.value in t.properties()],"filter-has-id":[We,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[We,[Di(et)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[We,[Di(He)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[We,[et,Di(He)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[We,[et,Di(He)],(t,[e,r])=>function(n,s,l,u){for(;l<=u;){let p=l+u>>1;if(s[p]===n)return!0;s[p]>n?u=p-1:l=p+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:We,overloads:[[[We,We],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[jr(We),(t,e)=>{for(let r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:We,overloads:[[[We,We],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[jr(We),(t,e)=>{for(let r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[We,[We],(t,[e])=>!e.evaluate(t)],"is-supported-script":[We,[et],(t,[e])=>{let r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[et,[et],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[et,[et],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[et,jr(He),(t,e)=>e.map(r=>So(r.evaluate(t))).join("")],"resolved-locale":[et,[To],(t,[e])=>e.evaluate(t).resolvedLocale()]});class za{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new xl,this._defaultValue=r?function(n){return n.type==="color"&&Ls(n.default)?new lt(0,0,0,0):n.type==="color"?lt.parse(n.default)||null:n.default===void 0?null:n.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,n,s,l,u,p,m){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=n,this._evaluator.canonical=s,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null,this.expression.evaluate(this._evaluator)}evaluate(e,r,n,s,l,u,p,m){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=n||null,this._evaluator.canonical=s,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null;try{let g=this.expression.evaluate(this._evaluator);if(g==null||typeof g=="number"&&g!=g)return this._defaultValue;if(this._enumValues&&!(g in this._enumValues))throw new Wt(`Expected value to be one of ${Object.keys(this._enumValues).map(x=>JSON.stringify(x)).join(", ")}, but found ${JSON.stringify(g)} instead.`);return g}catch(g){return this._warningHistory[g.message]||(this._warningHistory[g.message]=!0,typeof console<"u"&&console.warn(g.message)),this._defaultValue}}}function Vn(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in qi}function Uo(t,e){let r=new bs(qi,[],e?function(s){let l={color:ar,string:et,number:Me,enum:et,boolean:We,formatted:Fr,resolvedImage:Eo};return s.type==="array"?Di(l[s.value]||He,s.length):l[s.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Rl(new za(n,e)):xr(r.errors)}class Vo{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!Ao(r.expression)}evaluateWithoutErrorHandling(e,r,n,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,r,n,s,l,u)}evaluate(e,r,n,s,l,u){return this._styleExpression.evaluate(e,r,n,s,l,u)}}class ka{constructor(e,r,n,s){this.kind=e,this.zoomStops=n,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!Ao(r.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,r,n,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,r,n,s,l,u)}evaluate(e,r,n,s,l,u){return this._styleExpression.evaluate(e,r,n,s,l,u)}interpolationFactor(e,r,n){return this.interpolationType?pi.interpolationFactor(this.interpolationType,e,r,n):0}}function Ul(t,e){if((t=Uo(t,e)).result==="error")return t;let r=t.value.expression,n=On(r);if(!n&&!Un(e))return xr([new sr("","data expressions not supported")]);let s=Co(r,["zoom","pitch","distance-from-center"]);if(!s&&!Fl(e))return xr([new sr("","zoom expressions not supported")]);let l=Fs(r);return l||s?l instanceof sr?xr([l]):l instanceof pi&&!Ca(e)?xr([new sr("",'"interpolate" expressions cannot be used with this property')]):Rl(l?new ka(n?"camera":"composite",t.value,l.labels,l instanceof pi?l.interpolation:void 0):new Vo(n?"constant":"source",t.value)):xr([new sr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Nn{constructor(e,r){this._parameters=e,this._specification=r,Br(this,Oo(this._parameters,this._specification))}static deserialize(e){return new Nn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Fs(t){let e=null;if(t instanceof Cs)e=Fs(t.result);else if(t instanceof an){for(let r of t.args)if(e=Fs(r),e)break}else(t instanceof ko||t instanceof pi)&&t.input instanceof bi&&t.input.name==="zoom"&&(e=t);return e instanceof sr||t.eachChild(r=>{let n=Fs(r);n instanceof sr?e=n:!e&&n?e=new sr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new sr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function Ri(t){let e=t.key,r=t.value,n=t.valueSpec||{},s=t.objectElementValidators||{},l=t.style,u=t.styleSpec,p=[],m=ht(r);if(m!=="object")return[new Ae(e,r,`object expected, ${m} found`)];for(let g in r){let x=g.split(".")[0],v=n[x]||n["*"],b;if(s[x])b=s[x];else if(n[x])b=Ht;else if(s["*"])b=s["*"];else{if(!n["*"]){p.push(new Ae(e,r[g],`unknown property "${g}"`));continue}b=Ht}p=p.concat(b({key:(e&&`${e}.`)+g,value:r[g],valueSpec:v,style:l,styleSpec:u,object:r,objectKey:g},r))}for(let g in n)s[g]||n[g].required&&n[g].default===void 0&&r[g]===void 0&&p.push(new Ae(e,r,`missing required property "${g}"`));return p}function Pa(t){let e=t.value,r=t.valueSpec,n=t.style,s=t.styleSpec,l=t.key,u=t.arrayElementValidator||Ht;if(ht(e)!=="array")return[new Ae(l,e,`array expected, ${ht(e)} found`)];if(r.length&&e.length!==r.length)return[new Ae(l,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new Ae(l,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let p={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum};s.$version<7&&(p.function=r.function),ht(r.value)==="object"&&(p=r.value);let m=[];for(let g=0;g<e.length;g++)m=m.concat(u({array:e,arrayIndex:g,value:e[g],valueSpec:p,style:n,styleSpec:s,key:`${l}[${g}]`}));return m}function Vl(t){let e=t.key,r=t.value,n=t.valueSpec,s=ht(r);if(s==="number"&&r!=r&&(s="NaN"),s!=="number")return[new Ae(e,r,`number expected, ${s} found`)];if("minimum"in n){let l=n.minimum;if(ht(n.minimum)==="array"&&(l=n.minimum[t.arrayIndex]),r<l)return[new Ae(e,r,`${r} is less than the minimum value ${l}`)]}if("maximum"in n){let l=n.maximum;if(ht(n.maximum)==="array"&&(l=n.maximum[t.arrayIndex]),r>l)return[new Ae(e,r,`${r} is greater than the maximum value ${l}`)]}return[]}function Os(t){let e=t.valueSpec,r=Ft(t.value.type),n,s,l,u={},p=r!=="categorical"&&t.value.property===void 0,m=!p,g=ht(t.value.stops)==="array"&&ht(t.value.stops[0])==="array"&&ht(t.value.stops[0][0])==="object",x=Ri({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(I){if(r==="identity")return[new Ae(I.key,I.value,'identity function may not have a "stops" property')];let A=[],k=I.value;return A=A.concat(Pa({key:I.key,value:k,valueSpec:I.valueSpec,style:I.style,styleSpec:I.styleSpec,arrayElementValidator:v})),ht(k)==="array"&&k.length===0&&A.push(new Ae(I.key,k,"array must have at least one stop")),A},default:function(I){return Ht({key:I.key,value:I.value,valueSpec:e,style:I.style,styleSpec:I.styleSpec})}}});return r==="identity"&&p&&x.push(new Ae(t.key,t.value,'missing required property "property"')),r==="identity"||t.value.stops||x.push(new Ae(t.key,t.value,'missing required property "stops"')),r==="exponential"&&t.valueSpec.expression&&!Ca(t.valueSpec)&&x.push(new Ae(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(m&&!Un(t.valueSpec)?x.push(new Ae(t.key,t.value,"property functions not supported")):p&&!Fl(t.valueSpec)&&x.push(new Ae(t.key,t.value,"zoom functions not supported"))),r!=="categorical"&&!g||t.value.property!==void 0||x.push(new Ae(t.key,t.value,'"property" property is required')),x;function v(I){let A=[],k=I.value,D=I.key;if(ht(k)!=="array")return[new Ae(D,k,`array expected, ${ht(k)} found`)];if(k.length!==2)return[new Ae(D,k,`array length 2 expected, length ${k.length} found`)];if(g){if(ht(k[0])!=="object")return[new Ae(D,k,`object expected, ${ht(k[0])} found`)];if(k[0].zoom===void 0)return[new Ae(D,k,"object stop key must have zoom")];if(k[0].value===void 0)return[new Ae(D,k,"object stop key must have value")];if(l&&l>Ft(k[0].zoom))return[new Ae(D,k[0].zoom,"stop zoom values must appear in ascending order")];Ft(k[0].zoom)!==l&&(l=Ft(k[0].zoom),s=void 0,u={}),A=A.concat(Ri({key:`${D}[0]`,value:k[0],valueSpec:{zoom:{}},style:I.style,styleSpec:I.styleSpec,objectElementValidators:{zoom:Vl,value:b}}))}else A=A.concat(b({key:`${D}[0]`,value:k[0],valueSpec:{},style:I.style,styleSpec:I.styleSpec},k));return Vn(yr(k[1]))?A.concat([new Ae(`${D}[1]`,k[1],"expressions are not allowed in function stops.")]):A.concat(Ht({key:`${D}[1]`,value:k[1],valueSpec:e,style:I.style,styleSpec:I.styleSpec}))}function b(I,A){let k=ht(I.value),D=Ft(I.value),U=I.value!==null?I.value:A;if(n){if(k!==n)return[new Ae(I.key,U,`${k} stop domain type must match previous stop domain type ${n}`)]}else n=k;if(k!=="number"&&k!=="string"&&k!=="boolean")return[new Ae(I.key,U,"stop domain value must be a number, string, or boolean")];if(k!=="number"&&r!=="categorical"){let $=`number expected, ${k} found`;return Un(e)&&r===void 0&&($+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ae(I.key,U,$)]}return r!=="categorical"||k!=="number"||isFinite(D)&&Math.floor(D)===D?r!=="categorical"&&k==="number"&&s!==void 0&&D<s?[new Ae(I.key,U,"stop domain values must appear in ascending order")]:(s=D,r==="categorical"&&D in u?[new Ae(I.key,U,"stop domain values must be unique")]:(u[D]=!0,[])):[new Ae(I.key,U,`integer expected, found ${D}`)]}}function vr(t){let e=(t.expressionContext==="property"?Ul:Uo)(yr(t.value),t.valueSpec);if(e.result==="error")return e.value.map(n=>new Ae(`${t.key}${n.key}`,t.value,n.message));let r=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!r.outputDefined())return[new Ae(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Ao(r))return[new Ae(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return Da(r,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!Co(r,["zoom","feature-state"]))return[new Ae(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!On(r))return[new Ae(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Da(t,e){let r=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(let s of e.valueSpec.expression.parameters)r.delete(s);if(r.size===0)return[];let n=[];return t instanceof bi&&r.has(t.name)?[new Ae(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild(s=>{n.push(...Da(s,e))}),n)}function Us(t){let e=t.key,r=t.value,n=t.valueSpec,s=[];return Array.isArray(n.values)?n.values.indexOf(Ft(r))===-1&&s.push(new Ae(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(n.values).indexOf(Ft(r))===-1&&s.push(new Ae(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),s}function Vs(t){if(t===!0||t===!1)return!0;if(!Array.isArray(t)||t.length===0)return!1;switch(t[0]){case"has":return t.length>=2&&t[1]!=="$id"&&t[1]!=="$type";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(let e of t.slice(1))if(!Vs(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Ns(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Vs(t)||(t=Gs(t));let r=t,n=!0;try{n=function(g){if(!jn(g))return g;let x=yr(g);return Nl(x),x=js(x),x}(r)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
|
|
2
|
-
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
|
|
3
|
-
and paste the contents of this message in the report.
|
|
4
|
-
Thank you!
|
|
5
|
-
Filter Expression:
|
|
6
|
-
${JSON.stringify(r,null,2)}
|
|
7
|
-
`)}let s=se[`filter_${e}`],l=Uo(n,s),u=null;if(l.result==="error")throw new Error(l.value.map(g=>`${g.key}: ${g.message}`).join(", "));u=(g,x,v)=>l.value.evaluate(g,x,{},v);let p=null,m=null;if(n!==r){let g=Uo(r,s);if(g.result==="error")throw new Error(g.value.map(x=>`${x.key}: ${x.message}`).join(", "));p=(x,v,b,I,A)=>g.value.evaluate(x,v,{},b,void 0,void 0,I,A),m=!On(g.value.expression)}return u=u,{filter:u,dynamicFilter:p||void 0,needGeometry:La(n),needFeature:!!m}}function js(t){if(!Array.isArray(t))return t;let e=function(r){if(Xc.has(r[0])){for(let n=1;n<r.length;n++)if(jn(r[n]))return!0}return r}(t);return e===!0?e:e.map(r=>js(r))}function Nl(t){let e=!1,r=[];if(t[0]==="case"){for(let n=1;n<t.length-1;n+=2)e=e||jn(t[n]),r.push(t[n+1]);r.push(t[t.length-1])}else if(t[0]==="match"){e=e||jn(t[1]);for(let n=2;n<t.length-1;n+=2)r.push(t[n+1]);r.push(t[t.length-1])}else if(t[0]==="step"){e=e||jn(t[1]);for(let n=1;n<t.length-1;n+=2)r.push(t[n+1])}e&&(t.length=0,t.push("any",...r));for(let n=1;n<t.length;n++)Nl(t[n])}function jn(t){if(!Array.isArray(t))return!1;if((e=t[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let r=1;r<t.length;r++)if(jn(t[r]))return!0;return!1}let Xc=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Wc(t,e){return t<e?-1:t>e?1:0}function La(t){if(!Array.isArray(t))return!1;if(t[0]==="within")return!0;for(let e=1;e<t.length;e++)if(La(t[e]))return!0;return!1}function Gs(t){if(!t)return!0;let e=t[0];return t.length<=1?e!=="any":e==="=="?Ba(t[1],t[2],"=="):e==="!="?Zs(Ba(t[1],t[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Ba(t[1],t[2],e):e==="any"?(r=t.slice(1),["any"].concat(r.map(Gs))):e==="all"?["all"].concat(t.slice(1).map(Gs)):e==="none"?["all"].concat(t.slice(1).map(Gs).map(Zs)):e==="in"?jl(t[1],t.slice(2)):e==="!in"?Zs(jl(t[1],t.slice(2))):e==="has"?Gl(t[1]):e==="!has"?Zs(Gl(t[1])):e!=="within"||t;var r}function Ba(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function jl(t,e){if(e.length===0)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(r=>typeof r!=typeof e[0])?["filter-in-large",t,["literal",e.sort(Wc)]]:["filter-in-small",t,["literal",e]]}}function Gl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Zs(t){return["!",t]}function Ra(t){if(Vs(yr(t.value))){let e=yr(t.layerType);return vr(Br({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${e||"fill"}`]}))}return Zl(t)}function Zl(t){let e=t.value,r=t.key;if(ht(e)!=="array")return[new Ae(r,e,`array expected, ${ht(e)} found`)];let n=t.styleSpec,s,l=[];if(e.length<1)return[new Ae(r,e,"filter array must have at least 1 element")];switch(l=l.concat(Us({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),Ft(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ft(e[1])==="$type"&&l.push(new Ae(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&l.push(new Ae(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=ht(e[1]),s!=="string"&&l.push(new Ae(`${r}[1]`,e[1],`string expected, ${s} found`)));for(let u=2;u<e.length;u++)s=ht(e[u]),Ft(e[1])==="$type"?l=l.concat(Us({key:`${r}[${u}]`,value:e[u],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):s!=="string"&&s!=="number"&&s!=="boolean"&&l.push(new Ae(`${r}[${u}]`,e[u],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let u=1;u<e.length;u++)l=l.concat(Zl({key:`${r}[${u}]`,value:e[u],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":s=ht(e[1]),e.length!==2?l.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="string"&&l.push(new Ae(`${r}[1]`,e[1],`string expected, ${s} found`));break;case"within":s=ht(e[1]),e.length!==2?l.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="object"&&l.push(new Ae(`${r}[1]`,e[1],`object expected, ${s} found`))}return l}function No(t,e){let r=t.key,n=t.style,s=t.styleSpec,l=t.value,u=t.objectKey,p=s[`${e}_${t.layerType}`];if(!p)return[];let m=u.match(/^(.*)-transition$/);if(e==="paint"&&m&&p[m[1]]&&p[m[1]].transition)return Ht({key:r,value:l,valueSpec:s.transition,style:n,styleSpec:s});let g=t.valueSpec||p[u];if(!g)return[new Ae(r,l,`unknown property "${u}"`)];let x;if(ht(l)==="string"&&Un(g)&&!g.tokens&&(x=/^{([^}]+)}$/.exec(l)))return[new Ae(r,l,`"${u}" does not support interpolation syntax
|
|
8
|
-
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(x[1])} }\`.`)];let v=[];return t.layerType==="symbol"&&(u==="text-field"&&n&&!n.glyphs&&v.push(new Ae(r,l,'use of "text-field" requires a style "glyphs" property')),u==="text-font"&&Ls(yr(l))&&Ft(l.type)==="identity"&&v.push(new Ae(r,l,'"text-font" does not support identity functions'))),v.concat(Ht({key:t.key,value:l,valueSpec:g,style:n,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:u}))}function $l(t){return No(t,"paint")}function ql(t){return No(t,"layout")}function jo(t){let e=[],r=t.value,n=t.key,s=t.style,l=t.styleSpec;r.type||r.ref||e.push(new Ae(n,r,'either "type" or "ref" is required'));let u=Ft(r.type),p=Ft(r.ref);if(r.id){let m=Ft(r.id);for(let g=0;g<t.arrayIndex;g++){let x=s.layers[g];Ft(x.id)===m&&e.push(new Ae(n,r.id,`duplicate layer id "${r.id}", previously used at line ${x.id.__line__}`))}}if("ref"in r){let m;["type","source","source-layer","filter","layout"].forEach(g=>{g in r&&e.push(new Ae(n,r[g],`"${g}" is prohibited for ref layers`))}),s.layers.forEach(g=>{Ft(g.id)===p&&(m=g)}),m?m.ref?e.push(new Ae(n,r.ref,"ref cannot reference another ref layer")):u=Ft(m.type):e.push(new Ae(n,r.ref,`ref layer "${p}" not found`))}else if(u!=="background"&&u!=="sky")if(r.source){let m=s.sources&&s.sources[r.source],g=m&&Ft(m.type);m?g==="vector"&&u==="raster"?e.push(new Ae(n,r.source,`layer "${r.id}" requires a raster source`)):g==="raster"&&u!=="raster"?e.push(new Ae(n,r.source,`layer "${r.id}" requires a vector source`)):g!=="vector"||r["source-layer"]?g==="raster-dem"&&u!=="hillshade"?e.push(new Ae(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):u!=="line"||!r.paint||!r.paint["line-gradient"]||g==="geojson"&&m.lineMetrics||e.push(new Ae(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ae(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ae(n,r.source,`source "${r.source}" not found`))}else e.push(new Ae(n,r,'missing required property "source"'));return e=e.concat(Ri({key:n,value:r,valueSpec:l.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Ht({key:`${n}.type`,value:r.type,valueSpec:l.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:m=>Ra(Br({layerType:u},m)),layout:m=>Ri({layer:r,key:m.key,value:m.value,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":g=>ql(Br({layerType:u},g))}}),paint:m=>Ri({layer:r,key:m.key,value:m.value,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":g=>$l(Br({layerType:u},g))}})}})),e}function Gn(t){let e=t.value,r=t.key,n=ht(e);return n!=="string"?[new Ae(r,e,`string expected, ${n} found`)]:[]}let Fa={promoteId:function({key:t,value:e}){if(ht(e)==="string")return Gn({key:t,value:e});{let r=[];for(let n in e)r.push(...Gn({key:`${t}.${n}`,value:e[n]}));return r}}};function Xl(t){let e=t.value,r=t.key,n=t.styleSpec,s=t.style;if(!e.type)return[new Ae(r,e,'"type" is required')];let l=Ft(e.type),u;switch(l){case"vector":case"raster":case"raster-dem":return u=Ri({key:r,value:e,valueSpec:n[`source_${l.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Fa}),u;case"geojson":if(u=Ri({key:r,value:e,valueSpec:n.source_geojson,style:s,styleSpec:n,objectElementValidators:Fa}),e.cluster)for(let p in e.clusterProperties){let[m,g]=e.clusterProperties[p],x=typeof m=="string"?[m,["accumulated"],["get",p]]:m;u.push(...vr({key:`${r}.${p}.map`,value:g,expressionContext:"cluster-map"})),u.push(...vr({key:`${r}.${p}.reduce`,value:x,expressionContext:"cluster-reduce"}))}return u;case"video":return Ri({key:r,value:e,valueSpec:n.source_video,style:s,styleSpec:n});case"image":return Ri({key:r,value:e,valueSpec:n.source_image,style:s,styleSpec:n});case"canvas":return[new Ae(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Us({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,styleSpec:n})}}function Oa(t){let e=t.value,r=t.styleSpec,n=r.light,s=t.style,l=[],u=ht(e);if(e===void 0)return l;if(u!=="object")return l=l.concat([new Ae("light",e,`object expected, ${u} found`)]),l;for(let p in e){let m=p.match(/^(.*)-transition$/);l=l.concat(m&&n[m[1]]&&n[m[1]].transition?Ht({key:p,value:e[p],valueSpec:r.transition,style:s,styleSpec:r}):n[p]?Ht({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:r}):[new Ae(p,e[p],`unknown property "${p}"`)])}return l}function Ua(t){let e=t.value,r=t.key,n=t.style,s=t.styleSpec,l=s.terrain,u=[],p=ht(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Ae("terrain",e,`object expected, ${p} found`)]),u;for(let m in e){let g=m.match(/^(.*)-transition$/);u=u.concat(g&&l[g[1]]&&l[g[1]].transition?Ht({key:m,value:e[m],valueSpec:s.transition,style:n,styleSpec:s}):l[m]?Ht({key:m,value:e[m],valueSpec:l[m],style:n,styleSpec:s}):[new Ae(m,e[m],`unknown property "${m}"`)])}if(e.source){let m=n.sources&&n.sources[e.source],g=m&&Ft(m.type);m?g!=="raster-dem"&&u.push(new Ae(r,e.source,`terrain cannot be used with a source of type ${g}, it only be used with a "raster-dem" source type`)):u.push(new Ae(r,e.source,`source "${e.source}" not found`))}else u.push(new Ae(r,e,'terrain is missing required property "source"'));return u}function Va(t){let e=t.value,r=t.style,n=t.styleSpec,s=n.fog,l=[],u=ht(e);if(e===void 0)return l;if(u!=="object")return l=l.concat([new Ae("fog",e,`object expected, ${u} found`)]),l;for(let p in e){let m=p.match(/^(.*)-transition$/);l=l.concat(m&&s[m[1]]&&s[m[1]].transition?Ht({key:p,value:e[p],valueSpec:n.transition,style:r,styleSpec:n}):s[p]?Ht({key:p,value:e[p],valueSpec:s[p],style:r,styleSpec:n}):[new Ae(p,e[p],`unknown property "${p}"`)])}return l}let Na={"*":()=>[],array:Pa,boolean:function(t){let e=t.value,r=t.key,n=ht(e);return n!=="boolean"?[new Ae(r,e,`boolean expected, ${n} found`)]:[]},number:Vl,color:function(t){let e=t.key,r=t.value,n=ht(r);return n!=="string"?[new Ae(e,r,`color expected, ${n} found`)]:Fn.parseCSSColor(r)===null?[new Ae(e,r,`color expected, "${r}" found`)]:[]},constants:_l,enum:Us,filter:Ra,function:Os,layer:jo,object:Ri,source:Xl,light:Oa,terrain:Ua,fog:Va,string:Gn,formatted:function(t){return Gn(t).length===0?[]:vr(t)},resolvedImage:function(t){return Gn(t).length===0?[]:vr(t)},projection:function(t){let e=t.value,r=t.styleSpec,n=r.projection,s=t.style,l=[],u=ht(e);if(u==="object")for(let p in e)l=l.concat(Ht({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:r}));else u!=="string"&&(l=l.concat([new Ae("projection",e,`object or string expected, ${u} found`)]));return l}};function Ht(t){let e=t.value,r=t.valueSpec,n=t.styleSpec;return r.expression&&Ls(Ft(e))?Os(t):r.expression&&Vn(yr(e))?vr(t):r.type&&Na[r.type]?Na[r.type](t):Ri(Br({},t,{valueSpec:r.type?n[r.type]:r}))}function ja(t){let e=t.value,r=t.key,n=Gn(t);return n.length||(e.indexOf("{fontstack}")===-1&&n.push(new Ae(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&n.push(new Ae(r,e,'"glyphs" url must include a "{range}" token'))),n}function br(t,e=se){let r=[];return r=r.concat(Ht({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:ja,"*":()=>[]}})),t.constants&&(r=r.concat(_l({key:"constants",value:t.constants,style:t,styleSpec:e}))),Wl(r)}function Wl(t){return[].concat(t).sort((e,r)=>e.line-r.line)}function Xi(t){return function(...e){return Wl(t.apply(this,e))}}br.source=Xi(Xl),br.light=Xi(Oa),br.terrain=Xi(Ua),br.fog=Xi(Va),br.layer=Xi(jo),br.filter=Xi(Ra),br.paintProperty=Xi($l),br.layoutProperty=Xi(ql);let Zn=br,$n=Zn.light,Hc=Zn.fog,Ga=Zn.paintProperty,Kc=Zn.layoutProperty;function Hl(t,e){let r=!1;if(e&&e.length)for(let n of e)t.fire(new ps(new Error(n.message))),r=!0;return r}var Go=ai;function ai(t,e,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(r=s[2]);for(var l=0;l<this.d*this.d;l++){var u=s[3+l],p=s[3+l+1];n.push(u===p?null:s.subarray(u,p))}var m=s[3+n.length+1];this.keys=s.subarray(s[3+n.length],m),this.bboxes=s.subarray(m),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var g=0;g<this.d*this.d;g++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=r,this.scale=e/t,this.uid=0;var x=r/e*t;this.min=-x,this.max=t+x}ai.prototype.insert=function(t,e,r,n,s){this._forEachCell(e,r,n,s,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(s)},ai.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},ai.prototype._insertCell=function(t,e,r,n,s,l){this.cells[s].push(l)},ai.prototype.query=function(t,e,r,n,s){var l=this.min,u=this.max;if(t<=l&&e<=l&&u<=r&&u<=n&&!s)return Array.prototype.slice.call(this.keys);var p=[];return this._forEachCell(t,e,r,n,this._queryCell,p,{},s),p},ai.prototype._queryCell=function(t,e,r,n,s,l,u,p){var m=this.cells[s];if(m!==null)for(var g=this.keys,x=this.bboxes,v=0;v<m.length;v++){var b=m[v];if(u[b]===void 0){var I=4*b;(p?p(x[I+0],x[I+1],x[I+2],x[I+3]):t<=x[I+2]&&e<=x[I+3]&&r>=x[I+0]&&n>=x[I+1])?(u[b]=!0,l.push(g[b])):u[b]=!1}}},ai.prototype._forEachCell=function(t,e,r,n,s,l,u,p){for(var m=this._convertToCellCoord(t),g=this._convertToCellCoord(e),x=this._convertToCellCoord(r),v=this._convertToCellCoord(n),b=m;b<=x;b++)for(var I=g;I<=v;I++){var A=this.d*I+b;if((!p||p(this._convertFromCellCoord(b),this._convertFromCellCoord(I),this._convertFromCellCoord(b+1),this._convertFromCellCoord(I+1)))&&s.call(this,t,e,r,n,A,l,u,p))return}},ai.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},ai.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},ai.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,r=0,n=0;n<this.cells.length;n++)r+=this.cells[n].length;var s=new Int32Array(e+r+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var l=e,u=0;u<t.length;u++){var p=t[u];s[3+u]=l,s.set(p,l),l+=p.length}return s[3+t.length]=l,s.set(this.keys,l),s[3+t.length+1]=l+=this.keys.length,s.set(this.bboxes,l),l+=this.bboxes.length,s.buffer};let{ImageData:Zo,ImageBitmap:qn}=me,$o={};function ke(t,e,r={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),$o[t]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}ke("Object",Object),Go.serialize=function(t,e){let r=t.toArrayBuffer();return e&&e.push(r),{buffer:r}},Go.deserialize=function(t){return new Go(t.buffer)},ke("Grid",Go),ke("Color",lt),ke("Error",Error),ke("ResolvedImage",Li),ke("StylePropertyFunction",Nn),ke("StyleExpression",za,{omit:["_evaluator"]}),ke("ZoomDependentExpression",ka),ke("ZoomConstantExpression",Vo),ke("CompoundExpression",bi,{omit:["_evaluate"]});for(let t in qi)qi[t]._classRegistryKey||ke(`Expression_${t}`,qi[t]);function Xn(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&t.constructor.name==="ArrayBuffer")}function Kl(t){return qn&&t instanceof qn}function qo(t,e){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Xn(t)||Kl(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){let r=t;return e&&e.push(r.buffer),r}if(t instanceof Zo)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){let r=[];for(let n of t)r.push(qo(n,e));return r}if(typeof t=="object"){let r=t.constructor,n=r._classRegistryKey;if(!n)throw new Error("can't serialize object of unregistered class");let s=r.serialize?r.serialize(t,e):{};if(!r.serialize){for(let l in t){if(!t.hasOwnProperty(l)||$o[n].omit.indexOf(l)>=0)continue;let u=t[l];s[l]=$o[n].shallow.indexOf(l)>=0?u:qo(u,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return n!=="Object"&&(s.$name=n),s}throw new Error("can't serialize object of type "+typeof t)}function Gr(t){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Xn(t)||Kl(t)||ArrayBuffer.isView(t)||t instanceof Zo)return t;if(Array.isArray(t))return t.map(Gr);if(typeof t=="object"){let e=t.$name||"Object",{klass:r}=$o[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);let n=Object.create(r.prototype);for(let s of Object.keys(t)){if(s==="$name")continue;let l=t[s];n[s]=$o[e].shallow.indexOf(s)>=0?l:Gr(l)}return n}throw new Error("can't deserialize object of type "+typeof t)}class c{constructor(){this.first=!0}update(e,r){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=n,!0))}}let i=t=>t>=1536&&t<=1791,o=t=>t>=1872&&t<=1919,h=t=>t>=2208&&t<=2303,d=t=>t>=11904&&t<=12031,f=t=>t>=12032&&t<=12255,_=t=>t>=12272&&t<=12287,y=t=>t>=12288&&t<=12351,w=t=>t>=12352&&t<=12447,T=t=>t>=12448&&t<=12543,E=t=>t>=12544&&t<=12591,M=t=>t>=12704&&t<=12735,z=t=>t>=12736&&t<=12783,B=t=>t>=12784&&t<=12799,P=t=>t>=12800&&t<=13055,R=t=>t>=13056&&t<=13311,q=t=>t>=13312&&t<=19903,L=t=>t>=19968&&t<=40959,G=t=>t>=40960&&t<=42127,Z=t=>t>=42128&&t<=42191,N=t=>t>=44032&&t<=55215,j=t=>t>=63744&&t<=64255,X=t=>t>=64336&&t<=65023,ie=t=>t>=65040&&t<=65055,oe=t=>t>=65072&&t<=65103,Ee=t=>t>=65104&&t<=65135,xe=t=>t>=65136&&t<=65279,ge=t=>t>=65280&&t<=65519;function ae(t){for(let e of t)if(de(e.charCodeAt(0)))return!0;return!1}function ne(t){for(let e of t)if(!_e(e.charCodeAt(0)))return!1;return!0}function _e(t){return!(i(t)||o(t)||h(t)||X(t)||xe(t))}function de(t){return!(t!==746&&t!==747&&(t<4352||!(M(t)||E(t)||oe(t)&&!(t>=65097&&t<=65103)||j(t)||R(t)||d(t)||z(t)||!(!y(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||q(t)||L(t)||P(t)||(e=>e>=12592&&e<=12687)(t)||(e=>e>=43360&&e<=43391)(t)||(e=>e>=55216&&e<=55295)(t)||(e=>e>=4352&&e<=4607)(t)||N(t)||w(t)||_(t)||(e=>e>=12688&&e<=12703)(t)||f(t)||B(t)||T(t)&&t!==12540||!(!ge(t)||t===65288||t===65289||t===65293||t>=65306&&t<=65310||t===65339||t===65341||t===65343||t>=65371&&t<=65503||t===65507||t>=65512&&t<=65519)||!(!Ee(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(e=>e>=5120&&e<=5759)(t)||(e=>e>=6320&&e<=6399)(t)||ie(t)||(e=>e>=19904&&e<=19967)(t)||G(t)||Z(t))))}function Be(t){return!(de(t)||function(e){return!!((r=>r>=128&&r<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(r=>r>=8192&&r<=8303)(e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||(r=>r>=8448&&r<=8527)(e)||(r=>r>=8528&&r<=8591)(e)||(r=>r>=8960&&r<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||(r=>r>=9216&&r<=9279)(e)&&e!==9251||(r=>r>=9280&&r<=9311)(e)||(r=>r>=9312&&r<=9471)(e)||(r=>r>=9632&&r<=9727)(e)||(r=>r>=9728&&r<=9983)(e)&&!(e>=9754&&e<=9759)||(r=>r>=11008&&r<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||y(e)||T(e)||(r=>r>=57344&&r<=63743)(e)||oe(e)||Ee(e)||ge(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(t))}function Ve(t){return t>=1424&&t<=2303||X(t)||xe(t)}function Xe(t,e){return!(!e&&Ve(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(r=>r>=6016&&r<=6143)(t))}function Te(t){for(let e of t)if(Ve(e.charCodeAt(0)))return!0;return!1}let Re="deferred",Ge="loading",ft="loaded",xt=null,je="unavailable",Ye=null,It=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(je="error"),xt&&xt(t)};function $t(){fi.fire(new Dr("pluginStateChange",{pluginStatus:je,pluginURL:Ye}))}let fi=new Lr,Fi=function(){return je},Wi=function(){if(je!==Re||!Ye)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");je=Ge,$t(),Ye&&bo({url:Ye},t=>{t?It(t):(je=ft,$t())})},ot={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>je===ft||ot.applyArabicShaping!=null,isLoading:()=>je===Ge,setState(t){je=t.pluginStatus,Ye=t.pluginURL},isParsed:()=>ot.applyArabicShaping!=null&&ot.processBidirectionalText!=null&&ot.processStyledBidirectionalText!=null,getPluginURL:()=>Ye};class Ze{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new c,this.transition={},this.pitch=0)}isSupportedScript(e){return function(r,n){for(let s of r)if(!Xe(s.charCodeAt(0),n))return!1;return!0}(e,ot.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,r=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class tt{constructor(e,r){this.property=e,this.value=r,this.expression=function(n,s){if(Ls(n))return new Nn(n,s);if(Vn(n)){let l=Ul(n,s);if(l.result==="error")throw new Error(l.value.map(u=>`${u.key}: ${u.message}`).join(", "));return l.value}{let l=n;return typeof n=="string"&&s.type==="color"&&(l=lt.parse(n)),{kind:"constant",evaluate:()=>l}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,n){return this.property.possiblyEvaluate(this,e,r,n)}}class Bt{constructor(e){this.property=e,this.value=new tt(e,void 0)}transitioned(e,r){return new Tt(this.property,this.value,r,Lt({},e.transition,this.transition),e.now)}untransitioned(){return new Tt(this.property,this.value,null,{},0)}}class wi{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return ki(this._values[e].value.value)}setValue(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Bt(this._values[e].property)),this._values[e].value=new tt(this._values[e].property,r===null?void 0:ki(r))}getTransition(e){return ki(this._values[e].transition)}setTransition(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Bt(this._values[e].property)),this._values[e].transition=ki(r)||void 0}serialize(){let e={};for(let r of Object.keys(this._values)){let n=this.getValue(r);n!==void 0&&(e[r]=n);let s=this.getTransition(r);s!==void 0&&(e[`${r}-transition`]=s)}return e}transitioned(e,r){let n=new Ti(this._properties);for(let s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,r._values[s]);return n}untransitioned(){let e=new Ti(this._properties);for(let r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Tt{constructor(e,r,n,s,l){let u=s.delay||0,p=s.duration||0;l=l||0,this.property=e,this.value=r,this.begin=l+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,r,n){let s=e.now||0,l=this.value.possiblyEvaluate(e,r,n),u=this.prior;if(u){if(s>this.end)return this.prior=null,l;if(this.value.isDataDriven())return this.prior=null,l;if(s<this.begin)return u.possiblyEvaluate(e,r,n);{let p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,r,n),l,po(p))}}return l}}class Ti{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,n){let s=new ln(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,r,n);return s}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Xo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return ki(this._values[e].value)}setValue(e,r){this._values[e]=new tt(this._values[e].property,r===null?void 0:ki(r))}serialize(){let e={};for(let r of Object.keys(this._values)){let n=this.getValue(r);n!==void 0&&(e[r]=n)}return e}possiblyEvaluate(e,r,n){let s=new ln(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,r,n);return s}}class mi{constructor(e,r,n){this.property=e,this.value=r,this.parameters=n}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,n,s){return this.property.evaluate(this.value,this.parameters,e,r,n,s)}}class ln{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Pe{constructor(e){this.specification=e}possiblyEvaluate(e,r){return e.expression.evaluate(r)}interpolate(e,r,n){let s=Ts[this.specification.type];return s?s(e,r,n):e}}class Fe{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,n,s){return new mi(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},n,s)}:e.expression,r)}interpolate(e,r,n){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new mi(this,{kind:"constant",value:void 0},e.parameters);let s=Ts[this.specification.type];return s?new mi(this,{kind:"constant",value:s(e.value.value,r.value.value,n)},e.parameters):e}evaluate(e,r,n,s,l,u){return e.kind==="constant"?e.value:e.evaluate(r,n,s,l,u)}}class Kt extends Fe{possiblyEvaluate(e,r,n,s){if(e.value===void 0)return new mi(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){let l=e.expression.evaluate(r,null,{},n,s),u=e.property.specification.type==="resolvedImage"&&typeof l!="string"?l.name:l,p=this._calculate(u,u,u,r);return new mi(this,{kind:"constant",value:p},r)}if(e.expression.kind==="camera"){let l=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new mi(this,{kind:"constant",value:l},r)}return new mi(this,e.expression,r)}evaluate(e,r,n,s,l,u){if(e.kind==="source"){let p=e.evaluate(r,n,s,l,u);return this._calculate(p,p,p,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},n,s),e.evaluate({zoom:Math.floor(r.zoom)},n,s),e.evaluate({zoom:Math.floor(r.zoom)+1},n,s),r):e.value}_calculate(e,r,n,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:e,to:r,other:n}:{from:n,to:r,other:e}}interpolate(e){return e}}class cn{constructor(e){this.specification=e}possiblyEvaluate(e,r,n,s){if(e.value!==void 0){if(e.expression.kind==="constant"){let l=e.expression.evaluate(r,null,{},n,s);return this._calculate(l,l,l,r)}return this._calculate(e.expression.evaluate(new Ze(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Ze(Math.floor(r.zoom),r)),e.expression.evaluate(new Ze(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,n,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:n,to:r}}interpolate(e){return e}}class Zr{constructor(e){this.specification=e}possiblyEvaluate(e,r,n,s){return!!e.expression.evaluate(r,null,{},n,s)}interpolate(){return!1}}class ri{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in e){let n=e[r];n.specification.overridable&&this.overridableProperties.push(r);let s=this.defaultPropertyValues[r]=new tt(n,void 0),l=this.defaultTransitionablePropertyValues[r]=new Bt(n);this.defaultTransitioningPropertyValues[r]=l.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=s.possiblyEvaluate({})}}}function cu(t,e){return 256*(t=mt(Math.floor(t),0,255))+mt(Math.floor(e),0,255)}ke("DataDrivenProperty",Fe),ke("DataConstantProperty",Pe),ke("CrossFadedDataDrivenProperty",Kt),ke("CrossFadedProperty",cn),ke("ColorRampProperty",Zr);let xp={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Za{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Vt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Pt(t,e=1){let r=0,n=0;return{members:t.map(s=>{let l=xp[s.type].BYTES_PER_ELEMENT,u=r=hu(r,Math.max(e,l)),p=s.components||1;return n=Math.max(n,l),r+=l*p,{name:s.name,type:s.type,components:p,offset:u}}),size:hu(r,Math.max(n,e)),alignment:e}}function hu(t,e){return Math.ceil(t/e)*e}class $s extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.int16[s+0]=r,this.int16[s+1]=n,e}}$s.prototype.bytesPerElement=4,ke("StructArrayLayout2i4",$s);class qs extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,r,n,s)}emplace(e,r,n,s,l){let u=4*e;return this.int16[u+0]=r,this.int16[u+1]=n,this.int16[u+2]=s,this.int16[u+3]=l,e}}qs.prototype.bytesPerElement=8,ke("StructArrayLayout4i8",qs);class Yc extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,l,u,p)}emplace(e,r,n,s,l,u,p,m){let g=6*e,x=12*e,v=3*e;return this.int16[g+0]=r,this.int16[g+1]=n,this.uint8[x+4]=s,this.uint8[x+5]=l,this.uint8[x+6]=u,this.uint8[x+7]=p,this.float32[v+2]=m,e}}Yc.prototype.bytesPerElement=12,ke("StructArrayLayout2i4ub1f12",Yc);class Xs extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let l=3*e;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=s,e}}Xs.prototype.bytesPerElement=12,ke("StructArrayLayout3f12",Xs);class Wn extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m,g,x){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,n,s,l,u,p,m,g,x)}emplace(e,r,n,s,l,u,p,m,g,x,v){let b=10*e;return this.uint16[b+0]=r,this.uint16[b+1]=n,this.uint16[b+2]=s,this.uint16[b+3]=l,this.uint16[b+4]=u,this.uint16[b+5]=p,this.uint16[b+6]=m,this.uint16[b+7]=g,this.uint16[b+8]=x,this.uint16[b+9]=v,e}}Wn.prototype.bytesPerElement=20,ke("StructArrayLayout10ui20",Wn);class Yl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m){let g=this.length;return this.resize(g+1),this.emplace(g,e,r,n,s,l,u,p,m)}emplace(e,r,n,s,l,u,p,m,g){let x=8*e;return this.uint16[x+0]=r,this.uint16[x+1]=n,this.uint16[x+2]=s,this.uint16[x+3]=l,this.uint16[x+4]=u,this.uint16[x+5]=p,this.uint16[x+6]=m,this.uint16[x+7]=g,e}}Yl.prototype.bytesPerElement=16,ke("StructArrayLayout8ui16",Yl);class Jc extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D){let U=this.length;return this.resize(U+1),this.emplace(U,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D)}emplace(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U){let $=16*e;return this.int16[$+0]=r,this.int16[$+1]=n,this.int16[$+2]=s,this.int16[$+3]=l,this.uint16[$+4]=u,this.uint16[$+5]=p,this.uint16[$+6]=m,this.uint16[$+7]=g,this.int16[$+8]=x,this.int16[$+9]=v,this.int16[$+10]=b,this.int16[$+11]=I,this.int16[$+12]=A,this.int16[$+13]=k,this.int16[$+14]=D,this.int16[$+15]=U,e}}Jc.prototype.bytesPerElement=32,ke("StructArrayLayout4i4ui4i4i32",Jc);class Qc extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Qc.prototype.bytesPerElement=4,ke("StructArrayLayout1ul4",Qc);class eh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m,g,x,v,b,I){let A=this.length;return this.resize(A+1),this.emplace(A,e,r,n,s,l,u,p,m,g,x,v,b,I)}emplace(e,r,n,s,l,u,p,m,g,x,v,b,I,A){let k=20*e,D=10*e;return this.int16[k+0]=r,this.int16[k+1]=n,this.int16[k+2]=s,this.int16[k+3]=l,this.int16[k+4]=u,this.float32[D+3]=p,this.float32[D+4]=m,this.float32[D+5]=g,this.float32[D+6]=x,this.int16[k+14]=v,this.uint32[D+8]=b,this.uint16[k+18]=I,this.uint16[k+19]=A,e}}eh.prototype.bytesPerElement=40,ke("StructArrayLayout5i4f1i1ul2ui40",eh);class Jl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,l,u,p)}emplace(e,r,n,s,l,u,p,m){let g=8*e;return this.int16[g+0]=r,this.int16[g+1]=n,this.int16[g+2]=s,this.int16[g+4]=l,this.int16[g+5]=u,this.int16[g+6]=p,this.int16[g+7]=m,e}}Jl.prototype.bytesPerElement=16,ke("StructArrayLayout3i2i2i16",Jl);class th extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,r,n,s,l)}emplace(e,r,n,s,l,u){let p=4*e,m=8*e;return this.float32[p+0]=r,this.float32[p+1]=n,this.float32[p+2]=s,this.int16[m+6]=l,this.int16[m+7]=u,e}}th.prototype.bytesPerElement=16,ke("StructArrayLayout2f1f2i16",th);class ih extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,r,n,s)}emplace(e,r,n,s,l){let u=12*e,p=3*e;return this.uint8[u+0]=r,this.uint8[u+1]=n,this.float32[p+1]=s,this.float32[p+2]=l,e}}ih.prototype.bytesPerElement=12,ke("StructArrayLayout2ub2f12",ih);class Hi extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let l=3*e;return this.uint16[l+0]=r,this.uint16[l+1]=n,this.uint16[l+2]=s,e}}Hi.prototype.bytesPerElement=6,ke("StructArrayLayout3ui6",Hi);class rh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J){let Q=this.length;return this.resize(Q+1),this.emplace(Q,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J)}emplace(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J,Q){let he=30*e,le=15*e,Se=60*e;return this.int16[he+0]=r,this.int16[he+1]=n,this.int16[he+2]=s,this.float32[le+2]=l,this.float32[le+3]=u,this.uint16[he+8]=p,this.uint16[he+9]=m,this.uint32[le+5]=g,this.uint32[le+6]=x,this.uint32[le+7]=v,this.uint16[he+16]=b,this.uint16[he+17]=I,this.uint16[he+18]=A,this.float32[le+10]=k,this.float32[le+11]=D,this.uint8[Se+48]=U,this.uint8[Se+49]=$,this.uint8[Se+50]=H,this.uint32[le+13]=Y,this.int16[he+28]=J,this.uint8[Se+58]=Q,e}}rh.prototype.bytesPerElement=60,ke("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",rh);class nh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J,Q,he,le,Se,be,ce,we,Ie,fe){let ze=this.length;return this.resize(ze+1),this.emplace(ze,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J,Q,he,le,Se,be,ce,we,Ie,fe)}emplace(e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D,U,$,H,Y,J,Q,he,le,Se,be,ce,we,Ie,fe,ze){let De=38*e,rt=19*e;return this.int16[De+0]=r,this.int16[De+1]=n,this.int16[De+2]=s,this.float32[rt+2]=l,this.float32[rt+3]=u,this.int16[De+8]=p,this.int16[De+9]=m,this.int16[De+10]=g,this.int16[De+11]=x,this.int16[De+12]=v,this.int16[De+13]=b,this.uint16[De+14]=I,this.uint16[De+15]=A,this.uint16[De+16]=k,this.uint16[De+17]=D,this.uint16[De+18]=U,this.uint16[De+19]=$,this.uint16[De+20]=H,this.uint16[De+21]=Y,this.uint16[De+22]=J,this.uint16[De+23]=Q,this.uint16[De+24]=he,this.uint16[De+25]=le,this.uint16[De+26]=Se,this.uint16[De+27]=be,this.uint16[De+28]=ce,this.uint32[rt+15]=we,this.float32[rt+16]=Ie,this.float32[rt+17]=fe,this.float32[rt+18]=ze,e}}nh.prototype.bytesPerElement=76,ke("StructArrayLayout3i2f6i15ui1ul3f76",nh);class Ql extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Ql.prototype.bytesPerElement=4,ke("StructArrayLayout1f4",Ql);class oh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let l=3*e;return this.int16[l+0]=r,this.int16[l+1]=n,this.int16[l+2]=s,e}}oh.prototype.bytesPerElement=6,ke("StructArrayLayout3i6",oh);class $a extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,l,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,l,u,p)}emplace(e,r,n,s,l,u,p,m){let g=7*e;return this.float32[g+0]=r,this.float32[g+1]=n,this.float32[g+2]=s,this.float32[g+3]=l,this.float32[g+4]=u,this.float32[g+5]=p,this.float32[g+6]=m,e}}$a.prototype.bytesPerElement=28,ke("StructArrayLayout7f28",$a);class sh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,r,n,s)}emplace(e,r,n,s,l){let u=6*e;return this.uint32[3*e+0]=r,this.uint16[u+2]=n,this.uint16[u+3]=s,this.uint16[u+4]=l,e}}sh.prototype.bytesPerElement=12,ke("StructArrayLayout1ul3ui12",sh);class Hn extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.uint16[s+0]=r,this.uint16[s+1]=n,e}}Hn.prototype.bytesPerElement=4,ke("StructArrayLayout2ui4",Hn);class ec extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}ec.prototype.bytesPerElement=2,ke("StructArrayLayout1ui2",ec);class tc extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.float32[s+0]=r,this.float32[s+1]=n,e}}tc.prototype.bytesPerElement=8,ke("StructArrayLayout2f8",tc);class ah extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,r,n,s)}emplace(e,r,n,s,l){let u=4*e;return this.float32[u+0]=r,this.float32[u+1]=n,this.float32[u+2]=s,this.float32[u+3]=l,e}}ah.prototype.bytesPerElement=16,ke("StructArrayLayout4f16",ah);class uu extends Za{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}uu.prototype.size=40;class lh extends eh{get(e){return new uu(this,e)}}ke("CollisionBoxArray",lh);class du extends Za{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}du.prototype.size=60;class pu extends rh{get(e){return new du(this,e)}}ke("PlacedSymbolArray",pu);class fu extends Za{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}fu.prototype.size=76;class mu extends nh{get(e){return new fu(this,e)}}ke("SymbolInstanceArray",mu);class _u extends Ql{getoffsetX(e){return this.float32[1*e+0]}}ke("GlyphOffsetArray",_u);class gu extends oh{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ke("SymbolLineVertexArray",gu);class yu extends Za{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}yu.prototype.size=12;class xu extends sh{get(e){return new yu(this,e)}}ke("FeatureIndexArray",xu);class vu extends Za{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}vu.prototype.size=4;class bu extends Hn{get(e){return new vu(this,e)}}ke("FillExtrusionCentroidArray",bu);let vp=Pt([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),bp=Pt([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var wu=Rn(function(t){t.exports=function(e,r){var n,s,l,u,p,m,g,x;for(s=e.length-(n=3&e.length),l=r,p=3432918353,m=461845907,x=0;x<s;)g=255&e.charCodeAt(x)|(255&e.charCodeAt(++x))<<8|(255&e.charCodeAt(++x))<<16|(255&e.charCodeAt(++x))<<24,++x,l=27492+(65535&(u=5*(65535&(l=(l^=g=(65535&(g=(g=(65535&g)*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*m+(((g>>>16)*m&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,n){case 3:g^=(255&e.charCodeAt(x+2))<<16;case 2:g^=(255&e.charCodeAt(x+1))<<8;case 1:l^=g=(65535&(g=(g=(65535&(g^=255&e.charCodeAt(x)))*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*m+(((g>>>16)*m&65535)<<16)&4294967295}return l^=e.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0}}),wp=Rn(function(t){t.exports=function(e,r){for(var n,s=e.length,l=r^s,u=0;s>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24))+((1540483477*(n>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&e.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0}}),qa=wu,Tp=wp;qa.murmur3=wu,qa.murmur2=Tp;class ic{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,n,s){this.ids.push(Tu(e)),this.positions.push(r,n,s)}getPositions(e){let r=Tu(e),n=0,s=this.ids.length-1;for(;n<s;){let u=n+s>>1;this.ids[u]>=r?s=u:n=u+1}let l=[];for(;this.ids[n]===r;)l.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return l}static serialize(e,r){let n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return ch(n,s,0,n.length-1),r&&r.push(n.buffer,s.buffer),{ids:n,positions:s}}static deserialize(e){let r=new ic;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Tu(t){let e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:qa(String(t))}function ch(t,e,r,n){for(;r<n;){let s=t[r+n>>1],l=r-1,u=n+1;for(;;){do l++;while(t[l]<s);do u--;while(t[u]>s);if(l>=u)break;rc(t,l,u),rc(e,3*l,3*u),rc(e,3*l+1,3*u+1),rc(e,3*l+2,3*u+2)}u-r<n-u?(ch(t,e,r,u),r=u+1):(ch(t,e,u+1,n),n=u)}}function rc(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}ke("FeaturePositionMap",ic);class hn{constructor(e,r){this.gl=e.gl,this.location=r}}class nc extends hn{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Eu extends hn{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Su extends hn{constructor(e,r){super(e,r),this.current=lt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}let Ep=new Float32Array(16),Sp=new Float32Array(9),Ip=new Float32Array(4);function hh(t){return[cu(255*t.r,255*t.g),cu(255*t.b,255*t.a)]}class Xa{constructor(e,r,n){this.value=e,this.uniformNames=r.map(s=>`u_${s}`),this.type=n}setUniform(e,r,n){e.set(n.constantOr(this.value))}getBinding(e,r,n){return this.type==="color"?new Su(e,r):new nc(e,r)}}class Ws{constructor(e,r){this.uniformNames=r.map(n=>`u_${n}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,r,n,s){let l=s==="u_pattern_to"||s==="u_dash_to"?this.patternTo:s==="u_pattern_from"||s==="u_dash_from"?this.patternFrom:s==="u_pixel_ratio_to"?this.pixelRatioTo:s==="u_pixel_ratio_from"?this.pixelRatioFrom:null;l&&e.set(l)}getBinding(e,r,n){return n==="u_pattern_from"||n==="u_pattern_to"||n==="u_dash_from"||n==="u_dash_to"?new Eu(e,r):new nc(e,r)}}class un{constructor(e,r,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(l=>({name:`a_${l}`,type:"Float32",components:n==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,r,n,s,l,u){let p=this.paintVertexArray.length,m=this.expression.evaluate(new Ze(0),r,{},l,s,u);this.paintVertexArray.resize(e),this._setPaintValue(p,e,m)}updatePaintArray(e,r,n,s,l){let u=this.expression.evaluate({zoom:0},n,s,void 0,l);this._setPaintValue(e,r,u)}_setPaintValue(e,r,n){if(this.type==="color"){let s=hh(n);for(let l=e;l<r;l++)this.paintVertexArray.emplace(l,s[0],s[1])}else{for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class wr{constructor(e,r,n,s,l,u){this.expression=e,this.uniformNames=r.map(p=>`u_${p}_t`),this.type=n,this.useIntegerZoom=s,this.zoom=l,this.maxValue=0,this.paintVertexAttributes=r.map(p=>({name:`a_${p}`,type:"Float32",components:n==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,r,n,s,l,u){let p=this.expression.evaluate(new Ze(this.zoom),r,{},l,s,u),m=this.expression.evaluate(new Ze(this.zoom+1),r,{},l,s,u),g=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(g,e,p,m)}updatePaintArray(e,r,n,s,l){let u=this.expression.evaluate({zoom:this.zoom},n,s,void 0,l),p=this.expression.evaluate({zoom:this.zoom+1},n,s,void 0,l);this._setPaintValue(e,r,u,p)}_setPaintValue(e,r,n,s){if(this.type==="color"){let l=hh(n),u=hh(s);for(let p=e;p<r;p++)this.paintVertexArray.emplace(p,l[0],l[1],u[0],u[1])}else{for(let l=e;l<r;l++)this.paintVertexArray.emplace(l,n,s);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){let n=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=mt(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);e.set(s)}getBinding(e,r,n){return new nc(e,r)}}class Kn{constructor(e,r,n,s,l,u,p){this.expression=e,this.type=n,this.useIntegerZoom=s,this.zoom=l,this.layerId=p,this.paintVertexAttributes=(n==="array"?bp:vp).members;for(let m=0;m<r.length;++m);this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,r,n){let s=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(s,e,r.patterns&&r.patterns[this.layerId],n)}updatePaintArray(e,r,n,s,l,u){this._setPaintValues(e,r,n.patterns&&n.patterns[this.layerId],u)}_setPaintValues(e,r,n,s){if(!s||!n)return;let{min:l,mid:u,max:p}=n,m=s[l],g=s[u],x=s[p];if(m&&g&&x)for(let v=e;v<r;v++)this._setPaintValue(this.zoomInPaintVertexArray,v,g,m),this._setPaintValue(this.zoomOutPaintVertexArray,v,g,x)}_setPaintValue(e,r,n,s){e.emplace(r,n.tl[0],n.tl[1],n.br[0],n.br[1],s.tl[0],s.tl[1],s.br[0],s.br[1],n.pixelRatio,s.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class dn{constructor(e,r,n=()=>!0){this.binders={},this._buffers=[];let s=[];for(let l in e.paint._values){if(!n(l))continue;let u=e.paint.get(l);if(!(u instanceof mi&&Un(u.property.specification)))continue;let p=Ap(l,e.type),m=u.value,g=u.property.specification.type,x=u.property.useIntegerZoom,v=u.property.specification["property-type"],b=v==="cross-faded"||v==="cross-faded-data-driven",I=String(l)==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(m.kind!=="constant"||I)if(m.kind==="source"||I||b){let A=Iu(l,g,"source");this.binders[l]=b?new Kn(m,p,g,x,r,A,e.id):new un(m,p,g,A),s.push(`/a_${l}`)}else{let A=Iu(l,g,"composite");this.binders[l]=new wr(m,p,g,x,r,A),s.push(`/z_${l}`)}else this.binders[l]=b?new Ws(m.value,p):new Xa(m.value,p,g),s.push(`/u_${l}`)}this.cacheKey=s.sort().join("")}getMaxValue(e){let r=this.binders[e];return r instanceof un||r instanceof wr?r.maxValue:0}populatePaintArrays(e,r,n,s,l,u){for(let p in this.binders){let m=this.binders[p];(m instanceof un||m instanceof wr||m instanceof Kn)&&m.populatePaintArray(e,r,n,s,l,u)}}setConstantPatternPositions(e,r){for(let n in this.binders){let s=this.binders[n];s instanceof Ws&&s.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,n,s,l,u){let p=!1;for(let m in e){let g=r.getPositions(m);for(let x of g){let v=n.feature(x.index);for(let b in this.binders){let I=this.binders[b];if((I instanceof un||I instanceof wr||I instanceof Kn)&&I.expression.isStateDependent===!0){let A=s.paint.get(b);I.expression=A.value,I.updatePaintArray(x.start,x.end,v,e[m],l,u),p=!0}}}}return p}defines(){let e=[];for(let r in this.binders){let n=this.binders[r];(n instanceof Xa||n instanceof Ws)&&e.push(...n.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getBinderAttributes(){let e=[];for(let r in this.binders){let n=this.binders[r];if(n instanceof un||n instanceof wr||n instanceof Kn)for(let s=0;s<n.paintVertexAttributes.length;s++)e.push(n.paintVertexAttributes[s].name)}return e}getBinderUniforms(){let e=[];for(let r in this.binders){let n=this.binders[r];if(n instanceof Xa||n instanceof Ws||n instanceof wr)for(let s of n.uniformNames)e.push(s)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){let n=[];for(let s in this.binders){let l=this.binders[s];if(l instanceof Xa||l instanceof Ws||l instanceof wr){for(let u of l.uniformNames)if(r[u]){let p=l.getBinding(e,r[u],u);n.push({name:u,property:s,binding:p})}}}return n}setUniforms(e,r,n,s){for(let{name:l,property:u,binding:p}of r)this.binders[u].setUniform(p,s,n.get(u),l)}updatePaintBuffers(e){this._buffers=[];for(let r in this.binders){let n=this.binders[r];if(e&&n instanceof Kn){let s=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;s&&this._buffers.push(s)}else(n instanceof un||n instanceof wr)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let r in this.binders){let n=this.binders[r];(n instanceof un||n instanceof wr||n instanceof Kn)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let r=this.binders[e];(r instanceof un||r instanceof wr||r instanceof Kn)&&r.destroy()}}}class Wo{constructor(e,r,n=()=>!0){this.programConfigurations={};for(let s of e)this.programConfigurations[s.id]=new dn(s,r,n);this.needsUpload=!1,this._featureMap=new ic,this._bufferOffset=0}populatePaintArrays(e,r,n,s,l,u,p){for(let m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,r,s,l,u,p);r.id!==void 0&&this._featureMap.add(r.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,n,s,l){for(let u of n)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,r,u,s,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}let Mp={"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"],"line-dasharray":["dash_to","dash_from"]};function Ap(t,e){return Mp[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}let Cp={"line-pattern":{source:Wn,composite:Wn},"fill-pattern":{source:Wn,composite:Wn},"fill-extrusion-pattern":{source:Wn,composite:Wn},"line-dasharray":{source:Yl,composite:Yl}},zp={color:{source:tc,composite:ah},number:{source:Ql,composite:tc}};function Iu(t,e,r){let n=Cp[t];return n&&n[r]||zp[e][r]}ke("ConstantBinder",Xa),ke("CrossFadedConstantBinder",Ws),ke("SourceExpressionBinder",un),ke("CrossFadedCompositeBinder",Kn),ke("CompositeExpressionBinder",wr),ke("ProgramConfiguration",dn,{omit:["_buffers"]}),ke("ProgramConfigurationSet",Wo);let oc="-transition";class Tr extends Lr{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=(e=e).metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Xo(r.layout)),r.paint)){this._transitionablePaint=new wi(r.paint);for(let n in e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(let n in e.layout)this.setLayoutProperty(n,e.layout[n],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ln(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,n={}){r!=null&&this._validate(Kc,`layers.${this.id}.layout.${e}`,e,r,n)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return Mn(e,oc)?this._transitionablePaint.getTransition(e.slice(0,-oc.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,n={}){if(r!=null&&this._validate(Ga,`layers.${this.id}.paint.${e}`,e,r,n))return!1;if(Mn(e,oc))return this._transitionablePaint.setTransition(e.slice(0,-oc.length),r||void 0),!1;{let s=this._transitionablePaint._values[e],l=s.property.specification["property-type"]==="cross-faded-data-driven",u=s.value.isDataDriven(),p=s.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);let m=this._transitionablePaint._values[e].value;return m.isDataDriven()||u||l||this._handleOverridablePaintPropertyUpdate(e,p,m)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,r,n){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),An(e,(r,n)=>!(r===void 0||n==="layout"&&!Object.keys(r).length||n==="paint"&&!Object.keys(r).length))}_validate(e,r,n,s,l={}){return(!l||l.validate!==!1)&&Hl(this,e.call(Zn,{key:r,layerType:this.type,objectKey:n,value:s,styleSpec:se,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let r=this.paint.get(e);if(r instanceof mi&&Un(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Ns(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}let kp=Pt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Pp}=kp;class Nt{constructor(e=[]){this.segments=e}prepareSegment(e,r,n,s){let l=this.segments[this.segments.length-1];return e>Nt.MAX_VERTEX_ARRAY_LENGTH&&zt(`Max vertices per segment is ${Nt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!l||l.vertexLength+e>Nt.MAX_VERTEX_ARRAY_LENGTH||l.sortKey!==s)&&(l={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},s!==void 0&&(l.sortKey=s),this.segments.push(l)),l}get(){return this.segments}destroy(){for(let e of this.segments)for(let r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,n,s){return new Nt([{vertexOffset:e,primitiveOffset:r,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}Nt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ke("SegmentVector",Nt);var Qe=8192;class Ho{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof _t?new _t(e.lng,e.lat):_t.convert(e),this}setSouthWest(e){return this._sw=e instanceof _t?new _t(e.lng,e.lat):_t.convert(e),this}extend(e){let r=this._sw,n=this._ne,s,l;if(e instanceof _t)s=e,l=e;else{if(!(e instanceof Ho))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Ho.convert(e)):this.extend(_t.convert(e)):this;if(s=e._sw,l=e._ne,!s||!l)return this}return r||n?(r.lng=Math.min(s.lng,r.lng),r.lat=Math.min(s.lat,r.lat),n.lng=Math.max(l.lng,n.lng),n.lat=Math.max(l.lat,n.lat)):(this._sw=new _t(s.lng,s.lat),this._ne=new _t(l.lng,l.lat)),this}getCenter(){return new _t((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 _t(this.getWest(),this.getNorth())}getSouthEast(){return new _t(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(e){let{lng:r,lat:n}=_t.convert(e),s=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}static convert(e){return!e||e instanceof Ho?e:new Ho(e)}}let Mu=63710088e-1;class _t{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new _t(mr(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let r=Math.PI/180,n=this.lat*r,s=e.lat*r,l=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*r);return Mu*Math.acos(Math.min(l,1))}toBounds(e=0){let r=360*e/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new Ho(new _t(this.lng-n,this.lat-r),new _t(this.lng+n,this.lat+r))}static convert(e){if(e instanceof _t)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new _t(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new _t(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}let Au=2*Math.PI*Mu;function Cu(t){return Au*Math.cos(t*Math.PI/180)}function Hs(t){return(180+t)/360}function Ks(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Er(t,e){return t/Cu(e)}function pn(t){return 360*t-180}function hr(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function zu(t,e){return t*Cu(hr(e))}let $r=85.051129;class sc{constructor(e,r,n=0){this.x=+e,this.y=+r,this.z=+n}static fromLngLat(e,r=0){let n=_t.convert(e);return new sc(Hs(n.lng),Ks(n.lat),Er(r,n.lat))}toLngLat(){return new _t(pn(this.x),hr(this.y))}toAltitude(){return zu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Au*(e=hr(this.y),1/Math.cos(e*Math.PI/180));var e}}function uh(t,e,r,n,s,l,u,p,m){let g=(e+n)/2,x=(r+s)/2,v=new Ce(g,x);p(v),function(b,I,A,k,D,U){let $=A-D,H=k-U;return Math.abs((k-I)*$-(A-b)*H)/Math.hypot($,H)}(v.x,v.y,l.x,l.y,u.x,u.y)>=m?(uh(t,e,r,g,x,l,v,p,m),uh(t,g,x,n,s,v,u,p,m)):t.push(u)}function Dp(t,e,r){let n=[],s,l,u;for(let p of t){let{x:m,y:g}=p;e(p),u?uh(n,s,l,m,g,u,p,e,r):n.push(p),s=m,l=g,u=p}return n}let dh=Math.pow(2,14)-1,ku=-dh-1;function Lp(t,e){let r=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=mt(r,ku,dh),t.y=mt(n,ku,dh),(r<t.x||r>t.x+1||n<t.y||n>t.y+1)&&zt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function fn(t,e,r){let n=t.loadGeometry(),s=t.extent,l=Qe/s;if(e&&r&&r.projection.isReprojectedInTileSpace){let u=1<<e.z,{scale:p,x:m,y:g,projection:x}=r,v=b=>{let I=pn((e.x+b.x/s)/u),A=hr((e.y+b.y/s)/u),k=x.project(I,A);b.x=(k.x*p-m)*s,b.y=(k.y*p-g)*s};for(let b=0;b<n.length;b++)if(t.type!==1)n[b]=Dp(n[b],v,1);else{let I=[];for(let A of n[b])A.x<0||A.x>=s||A.y<0||A.y>=s||(v(A),I.push(A));n[b]=I}}for(let u of n)for(let p of u)Lp(p,l);return n}function Ko(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?fn(t):[]}}function ac(t,e,r,n,s){t.emplaceBack(2*e+(n+1)/2,2*r+(s+1)/2)}class ph{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new $s,this.indexArray=new Hi,this.segments=new Nt,this.programConfigurations=new Wo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,n,s){let l=this.layers[0],u=[],p=null;l.type==="circle"&&(p=l.layout.get("circle-sort-key"));for(let{feature:m,id:g,index:x,sourceLayerIndex:v}of e){let b=this.layers[0]._featureFilter.needGeometry,I=Ko(m,b);if(!this.layers[0]._featureFilter.filter(new Ze(this.zoom),I,n))continue;let A=p?p.evaluate(I,{},n):void 0,k={id:g,properties:m.properties,type:m.type,sourceLayerIndex:v,index:x,geometry:b?I.geometry:fn(m,n,s),patterns:{},sortKey:A};u.push(k)}p&&u.sort((m,g)=>m.sortKey-g.sortKey);for(let m of u){let{geometry:g,index:x,sourceLayerIndex:v}=m,b=e[x].feature;this.addFeature(m,g,x,r.availableImages,n),r.featureIndex.insert(b,g,x,v,this.index)}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Pp),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,n,s,l){for(let u of r)for(let p of u){let m=p.x,g=p.y;if(m<0||m>=Qe||g<0||g>=Qe)continue;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),v=x.vertexLength;ac(this.layoutVertexArray,m,g,-1,-1),ac(this.layoutVertexArray,m,g,1,-1),ac(this.layoutVertexArray,m,g,1,1),ac(this.layoutVertexArray,m,g,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,l)}}function Pu(t,e){for(let r=0;r<t.length;r++)if(Ys(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(Ys(t,e[r]))return!0;return!!fh(t,e)}function Bp(t,e,r){return!!Ys(t,e)||!!mh(e,t,r)}function Du(t,e){if(t.length===1)return Bu(e,t[0]);for(let r=0;r<e.length;r++){let n=e[r];for(let s=0;s<n.length;s++)if(Ys(t,n[s]))return!0}for(let r=0;r<t.length;r++)if(Bu(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(fh(t,e[r]))return!0;return!1}function Rp(t,e,r){if(t.length>1){if(fh(t,e))return!0;for(let n=0;n<e.length;n++)if(mh(e[n],t,r))return!0}for(let n=0;n<t.length;n++)if(mh(t[n],e,r))return!0;return!1}function fh(t,e){if(t.length===0||e.length===0)return!1;for(let r=0;r<t.length-1;r++){let n=t[r],s=t[r+1];for(let l=0;l<e.length-1;l++)if(Fp(n,s,e[l],e[l+1]))return!0}return!1}function Fp(t,e,r,n){return Pi(t,r,n)!==Pi(e,r,n)&&Pi(t,e,r)!==Pi(t,e,n)}function mh(t,e,r){let n=r*r;if(e.length===1)return t.distSqr(e[0])<n;for(let s=1;s<e.length;s++)if(Lu(t,e[s-1],e[s])<n)return!0;return!1}function Lu(t,e,r){let n=e.distSqr(r);if(n===0)return t.distSqr(e);let s=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/n;return t.distSqr(s<0?e:s>1?r:r.sub(e)._mult(s)._add(e))}function Bu(t,e){let r,n,s,l=!1;for(let u=0;u<t.length;u++){r=t[u];for(let p=0,m=r.length-1;p<r.length;m=p++)n=r[p],s=r[m],n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(l=!l)}return l}function Ys(t,e){let r=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){let l=t[n],u=t[s];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(r=!r)}return r}function Ru(t,e,r,n,s){for(let u of t)if(e<=u.x&&r<=u.y&&n>=u.x&&s>=u.y)return!0;let l=[new Ce(e,r),new Ce(e,s),new Ce(n,s),new Ce(n,r)];if(t.length>2){for(let u of l)if(Ys(t,u))return!0}for(let u=0;u<t.length-1;u++)if(Op(t[u],t[u+1],l))return!0;return!1}function Op(t,e,r){let n=r[0],s=r[2];if(t.x<n.x&&e.x<n.x||t.x>s.x&&e.x>s.x||t.y<n.y&&e.y<n.y||t.y>s.y&&e.y>s.y)return!1;let l=Pi(t,e,r[0]);return l!==Pi(t,e,r[1])||l!==Pi(t,e,r[2])||l!==Pi(t,e,r[3])}function Js(t,e,r){let n=e.paint.get(t).value;return n.kind==="constant"?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function lc(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Fu(t,e,r,n,s){if(!e[0]&&!e[1])return t;let l=Ce.convert(e)._mult(s);r==="viewport"&&l._rotate(-n);let u=[];for(let p=0;p<t.length;p++)u.push(t[p].sub(l));return u}function Ou(t,e,r,n){let s=Ce.convert(t)._mult(n);return e==="viewport"&&s._rotate(-r),s}ke("CircleBucket",ph,{omit:["layers"]});let Up=new ri({"circle-sort-key":new Fe(se.layout_circle["circle-sort-key"])});var Vp={paint:new ri({"circle-radius":new Fe(se.paint_circle["circle-radius"]),"circle-color":new Fe(se.paint_circle["circle-color"]),"circle-blur":new Fe(se.paint_circle["circle-blur"]),"circle-opacity":new Fe(se.paint_circle["circle-opacity"]),"circle-translate":new Pe(se.paint_circle["circle-translate"]),"circle-translate-anchor":new Pe(se.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Pe(se.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Pe(se.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Fe(se.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Fe(se.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Fe(se.paint_circle["circle-stroke-opacity"])}),layout:Up};class _h{constructor(e,r){this.points=e,this.planes=r}static fromInvProjectionMatrix(e,r,n,s){let l=Math.pow(2,n),u=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(m=>{let g=tr([],m,e),x=1/g[3]/r*l;return function(v,b,I){return v[0]=b[0]*I[0],v[1]=b[1]*I[1],v[2]=b[2]*I[2],v[3]=b[3]*I[3],v}(g,g,[x,x,s?1/g[3]:x,x])}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(m=>{let g=bn([],wn([],en([],u[m[0]],u[m[1]]),en([],u[m[2]],u[m[1]]))),x=-er(g,u[m[1]]);return g.concat(x)});return new _h(u,p)}}class Sr{constructor(e,r){this.min=e,this.max=r,this.center=Qi([],co([],this.min,this.max),.5)}quadrant(e){let r=[e%2==0,e<2],n=Jr(this.min),s=Jr(this.max);for(let l=0;l<r.length;l++)n[l]=r[l]?this.min[l]:this.center[l],s[l]=r[l]?this.center[l]:this.max[l];return s[2]=this.max[2],new Sr(n,s)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){let e=this.min,r=this.max;return[[e[0],e[1],e[2]],[r[0],e[1],e[2]],[r[0],r[1],e[2]],[e[0],r[1],e[2]],[e[0],e[1],r[2]],[r[0],e[1],r[2]],[r[0],r[1],r[2]],[e[0],r[1],r[2]]]}intersects(e){let r=this.getCorners(),n=!0;for(let s=0;s<e.planes.length;s++){let l=e.planes[s],u=0;for(let p=0;p<r.length;p++)u+=er(l,r[p])+l[3]>=0;if(u===0)return 0;u!==r.length&&(n=!1)}if(n)return 2;for(let s=0;s<3;s++){let l=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let p=0;p<e.points.length;p++){let m=e.points[p][s]-this.min[s];l=Math.min(l,m),u=Math.max(u,m)}if(u<0||l>this.max[s]-this.min[s])return 0}return 1}}function Uu(t,e,r,n,s,l,u,p,m){if(l&&t.queryGeometry.isAboveHorizon)return!1;l&&(m*=t.pixelToTileUnitsFactor);for(let g of e)for(let x of g){let v=x.add(p),b=s&&r.elevation?r.elevation.exaggeration()*s.getElevationAt(v.x,v.y,!0):0,I=l?v:Np(v,b,n),A=l?t.tilespaceRays.map(D=>Gp(D,b)):t.queryGeometry.screenGeometry,k=tr([],[x.x,x.y,b,1],n);if(!u&&l?m*=k[3]/r.cameraToCenterDistance:u&&!l&&(m*=r.cameraToCenterDistance/k[3]),Bp(A,I,m))return!0}return!1}function Np(t,e,r){let n=tr([],[t.x,t.y,e,1],r);return new Ce(n[0]/n[3],n[1]/n[3])}let Vu=fr(0,0,0),jp=fr(0,0,1);function Gp(t,e){let r=lo();return Vu[2]=e,t.intersectsPlane(Vu,jp,r),new Ce(r[0],r[1])}class Nu extends ph{}function gh(t,{width:e,height:r},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*r*n)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=s,t}function ju(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;let s=gh({},{width:e,height:r},n);yh(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=s.data}function yh(t,e,r,n,s,l){if(s.width===0||s.height===0)return e;if(s.width>t.width||s.height>t.height||r.x>t.width-s.width||r.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");let u=t.data,p=e.data;for(let m=0;m<s.height;m++){let g=((r.y+m)*t.width+r.x)*l,x=((n.y+m)*e.width+n.x)*l;for(let v=0;v<s.width*l;v++)p[x+v]=u[g+v]}return e}ke("HeatmapBucket",Nu,{omit:["layers"]});class Yn{constructor(e,r){gh(this,e,1,r)}resize(e){ju(this,e,1)}clone(){return new Yn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,n,s,l){yh(e,r,n,s,l,1)}}class Ki{constructor(e,r){gh(this,e,4,r)}resize(e){ju(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Ki({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,n,s,l){yh(e,r,n,s,l,4)}}ke("AlphaImage",Yn),ke("RGBAImage",Ki);var Zp={paint:new ri({"heatmap-radius":new Fe(se.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Fe(se.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Pe(se.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zr(se.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Pe(se.paint_heatmap["heatmap-opacity"])})};function xh(t){let e={},r=t.resolution||256,n=t.clips?t.clips.length:1,s=t.image||new Ki({width:r,height:n}),l=(u,p,m)=>{e[t.evaluationKey]=m;let g=t.expression.evaluate(e);s.data[u+p+0]=Math.floor(255*g.r/g.a),s.data[u+p+1]=Math.floor(255*g.g/g.a),s.data[u+p+2]=Math.floor(255*g.b/g.a),s.data[u+p+3]=Math.floor(255*g.a)};if(t.clips)for(let u=0,p=0;u<n;++u,p+=4*r)for(let m=0,g=0;m<r;m++,g+=4){let x=m/(r-1),{start:v,end:b}=t.clips[u];l(p,g,v*(1-x)+b*x)}else for(let u=0,p=0;u<r;u++,p+=4)l(0,p,u/(r-1));return s}var $p={paint:new ri({"hillshade-illumination-direction":new Pe(se.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Pe(se.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Pe(se.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Pe(se.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Pe(se.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Pe(se.paint_hillshade["hillshade-accent-color"])})};let qp=Pt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Xp}=qp;var cc=hc,Wp=hc;function hc(t,e,r){r=r||2;var n,s,l,u,p,m,g,x=e&&e.length,v=x?e[0]*r:t.length,b=Gu(t,0,v,r,!0),I=[];if(!b||b.next===b.prev)return I;if(x&&(b=function(k,D,U,$){var H,Y,J,Q=[];for(H=0,Y=D.length;H<Y;H++)(J=Gu(k,D[H]*$,H<Y-1?D[H+1]*$:k.length,$,!1))===J.next&&(J.steiner=!0),Q.push(rf(J));for(Q.sort(Qp),H=0;H<Q.length;H++)U=Jn(U=ef(Q[H],U),U.next);return U}(t,e,b,r)),t.length>80*r){n=l=t[0],s=u=t[1];for(var A=r;A<v;A+=r)(p=t[A])<n&&(n=p),(m=t[A+1])<s&&(s=m),p>l&&(l=p),m>u&&(u=m);g=(g=Math.max(l-n,u-s))!==0?1/g:0}return Wa(b,I,r,n,s,g),I}function Gu(t,e,r,n,s){var l,u;if(s===wh(t,e,r,n)>0)for(l=e;l<r;l+=n)u=qu(l,t[l],t[l+1],u);else for(l=r-n;l>=e;l-=n)u=qu(l,t[l],t[l+1],u);return u&&uc(u,u.next)&&(Ka(u),u=u.next),u}function Jn(t,e){if(!t)return t;e||(e=t);var r,n=t;do if(r=!1,n.steiner||!uc(n,n.next)&&jt(n.prev,n,n.next)!==0)n=n.next;else{if(Ka(n),(n=e=n.prev)===n.next)break;r=!0}while(r||n!==e);return e}function Wa(t,e,r,n,s,l,u){if(t){!u&&l&&function(x,v,b,I){var A=x;do A.z===null&&(A.z=vh(A.x,A.y,v,b,I)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next;while(A!==x);A.prevZ.nextZ=null,A.prevZ=null,function(k){var D,U,$,H,Y,J,Q,he,le=1;do{for(U=k,k=null,Y=null,J=0;U;){for(J++,$=U,Q=0,D=0;D<le&&(Q++,$=$.nextZ);D++);for(he=le;Q>0||he>0&&$;)Q!==0&&(he===0||!$||U.z<=$.z)?(H=U,U=U.nextZ,Q--):(H=$,$=$.nextZ,he--),Y?Y.nextZ=H:k=H,H.prevZ=Y,Y=H;U=$}Y.nextZ=null,le*=2}while(J>1)}(A)}(t,n,s,l);for(var p,m,g=t;t.prev!==t.next;)if(p=t.prev,m=t.next,l?Kp(t,n,s,l):Hp(t))e.push(p.i/r),e.push(t.i/r),e.push(m.i/r),Ka(t),t=m.next,g=m.next;else if((t=m)===g){u?u===1?Wa(t=Yp(Jn(t),e,r),e,r,n,s,l,2):u===2&&Jp(t,e,r,n,s,l):Wa(Jn(t),e,r,n,s,l,1);break}}}function Hp(t){var e=t.prev,r=t,n=t.next;if(jt(e,r,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(Qs(e.x,e.y,r.x,r.y,n.x,n.y,s.x,s.y)&&jt(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function Kp(t,e,r,n){var s=t.prev,l=t,u=t.next;if(jt(s,l,u)>=0)return!1;for(var p=s.x>l.x?s.x>u.x?s.x:u.x:l.x>u.x?l.x:u.x,m=s.y>l.y?s.y>u.y?s.y:u.y:l.y>u.y?l.y:u.y,g=vh(s.x<l.x?s.x<u.x?s.x:u.x:l.x<u.x?l.x:u.x,s.y<l.y?s.y<u.y?s.y:u.y:l.y<u.y?l.y:u.y,e,r,n),x=vh(p,m,e,r,n),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=x;){if(v!==t.prev&&v!==t.next&&Qs(s.x,s.y,l.x,l.y,u.x,u.y,v.x,v.y)&&jt(v.prev,v,v.next)>=0||(v=v.prevZ,b!==t.prev&&b!==t.next&&Qs(s.x,s.y,l.x,l.y,u.x,u.y,b.x,b.y)&&jt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v!==t.prev&&v!==t.next&&Qs(s.x,s.y,l.x,l.y,u.x,u.y,v.x,v.y)&&jt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b!==t.prev&&b!==t.next&&Qs(s.x,s.y,l.x,l.y,u.x,u.y,b.x,b.y)&&jt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Yp(t,e,r){var n=t;do{var s=n.prev,l=n.next.next;!uc(s,l)&&Zu(s,n,n.next,l)&&Ha(s,l)&&Ha(l,s)&&(e.push(s.i/r),e.push(n.i/r),e.push(l.i/r),Ka(n),Ka(n.next),n=t=l),n=n.next}while(n!==t);return Jn(n)}function Jp(t,e,r,n,s,l){var u=t;do{for(var p=u.next.next;p!==u.prev;){if(u.i!==p.i&&nf(u,p)){var m=$u(u,p);return u=Jn(u,u.next),m=Jn(m,m.next),Wa(u,e,r,n,s,l),void Wa(m,e,r,n,s,l)}p=p.next}u=u.next}while(u!==t)}function Qp(t,e){return t.x-e.x}function ef(t,e){var r=function(l,u){var p,m=u,g=l.x,x=l.y,v=-1/0;do{if(x<=m.y&&x>=m.next.y&&m.next.y!==m.y){var b=m.x+(x-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(b<=g&&b>v){if(v=b,b===g){if(x===m.y)return m;if(x===m.next.y)return m.next}p=m.x<m.next.x?m:m.next}}m=m.next}while(m!==u);if(!p)return null;if(g===v)return p;var I,A=p,k=p.x,D=p.y,U=1/0;m=p;do g>=m.x&&m.x>=k&&g!==m.x&&Qs(x<D?g:v,x,k,D,x<D?v:g,x,m.x,m.y)&&(I=Math.abs(x-m.y)/(g-m.x),Ha(m,l)&&(I<U||I===U&&(m.x>p.x||m.x===p.x&&tf(p,m)))&&(p=m,U=I)),m=m.next;while(m!==A);return p}(t,e);if(!r)return e;var n=$u(r,t),s=Jn(r,r.next);return Jn(n,n.next),e===r?s:e}function tf(t,e){return jt(t.prev,t,e.prev)<0&&jt(e.next,t,t.next)<0}function vh(t,e,r,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function rf(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Qs(t,e,r,n,s,l,u,p){return(s-u)*(e-p)-(t-u)*(l-p)>=0&&(t-u)*(n-p)-(r-u)*(e-p)>=0&&(r-u)*(l-p)-(s-u)*(n-p)>=0}function nf(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(r,n){var s=r;do{if(s.i!==r.i&&s.next.i!==r.i&&s.i!==n.i&&s.next.i!==n.i&&Zu(s,s.next,r,n))return!0;s=s.next}while(s!==r);return!1}(t,e)&&(Ha(t,e)&&Ha(e,t)&&function(r,n){var s=r,l=!1,u=(r.x+n.x)/2,p=(r.y+n.y)/2;do s.y>p!=s.next.y>p&&s.next.y!==s.y&&u<(s.next.x-s.x)*(p-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==r);return l}(t,e)&&(jt(t.prev,t,e.prev)||jt(t,e.prev,e))||uc(t,e)&&jt(t.prev,t,t.next)>0&&jt(e.prev,e,e.next)>0)}function jt(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function uc(t,e){return t.x===e.x&&t.y===e.y}function Zu(t,e,r,n){var s=pc(jt(t,e,r)),l=pc(jt(t,e,n)),u=pc(jt(r,n,t)),p=pc(jt(r,n,e));return s!==l&&u!==p||!(s!==0||!dc(t,r,e))||!(l!==0||!dc(t,n,e))||!(u!==0||!dc(r,t,n))||!(p!==0||!dc(r,e,n))}function dc(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function pc(t){return t>0?1:t<0?-1:0}function Ha(t,e){return jt(t.prev,t,t.next)<0?jt(t,e,t.next)>=0&&jt(t,t.prev,e)>=0:jt(t,e,t.prev)<0||jt(t,t.next,e)<0}function $u(t,e){var r=new bh(t.i,t.x,t.y),n=new bh(e.i,e.x,e.y),s=t.next,l=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,n.next=r,r.prev=n,l.next=n,n.prev=l,n}function qu(t,e,r,n){var s=new bh(t,e,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Ka(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 bh(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function wh(t,e,r,n){for(var s=0,l=e,u=r-n;l<r;l+=n)s+=(t[u]-t[l])*(t[l+1]+t[u+1]),u=l;return s}function of(t,e,r,n,s){Xu(t,e,r||0,n||t.length-1,s||sf)}function Xu(t,e,r,n,s){for(;n>r;){if(n-r>600){var l=n-r+1,u=e-r+1,p=Math.log(l),m=.5*Math.exp(2*p/3),g=.5*Math.sqrt(p*m*(l-m)/l)*(u-l/2<0?-1:1);Xu(t,e,Math.max(r,Math.floor(e-u*m/l+g)),Math.min(n,Math.floor(e+(l-u)*m/l+g)),s)}var x=t[e],v=r,b=n;for(Ya(t,r,e),s(t[n],x)>0&&Ya(t,r,n);v<b;){for(Ya(t,v,b),v++,b--;s(t[v],x)<0;)v++;for(;s(t[b],x)>0;)b--}s(t[r],x)===0?Ya(t,r,b):Ya(t,++b,n),b<=e&&(r=b+1),e<=b&&(n=b-1)}}function Ya(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function sf(t,e){return t<e?-1:t>e?1:0}function Th(t,e){let r=t.length;if(r<=1)return[t];let n=[],s,l;for(let u=0;u<r;u++){let p=Cn(t[u]);p!==0&&(t[u].area=Math.abs(p),l===void 0&&(l=p<0),l===p<0?(s&&n.push(s),s=[t[u]]):s.push(t[u]))}if(s&&n.push(s),e>1)for(let u=0;u<n.length;u++)n[u].length<=e||(of(n[u],e,1,n[u].length-1,af),n[u]=n[u].slice(0,e));return n}function af(t,e){return e.area-t.area}function Eh(t,e,r){let n=r.patternDependencies,s=!1;for(let l of e){let u=l.paint.get(`${t}-pattern`);u.isConstant()||(s=!0);let p=u.constantOr(null);p&&(s=!0,n[p.to]=!0,n[p.from]=!0)}return s}function Sh(t,e,r,n,s){let l=s.patternDependencies;for(let u of e){let p=u.paint.get(`${t}-pattern`).value;if(p.kind!=="constant"){let m=p.evaluate({zoom:n-1},r,{},s.availableImages),g=p.evaluate({zoom:n},r,{},s.availableImages),x=p.evaluate({zoom:n+1},r,{},s.availableImages);m=m&&m.name?m.name:m,g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,l[m]=!0,l[g]=!0,l[x]=!0,r.patterns[u.id]={min:m,mid:g,max:x}}}return r}hc.deviation=function(t,e,r,n){var s=e&&e.length,l=Math.abs(wh(t,0,s?e[0]*r:t.length,r));if(s)for(var u=0,p=e.length;u<p;u++)l-=Math.abs(wh(t,e[u]*r,u<p-1?e[u+1]*r:t.length,r));var m=0;for(u=0;u<n.length;u+=3){var g=n[u]*r,x=n[u+1]*r,v=n[u+2]*r;m+=Math.abs((t[g]-t[v])*(t[x+1]-t[g+1])-(t[g]-t[x])*(t[v+1]-t[g+1]))}return l===0&&m===0?0:Math.abs((m-l)/l)},hc.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},n=0,s=0;s<t.length;s++){for(var l=0;l<t[s].length;l++)for(var u=0;u<e;u++)r.vertices.push(t[s][l][u]);s>0&&r.holes.push(n+=t[s-1].length)}return r},cc.default=Wp;class fc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $s,this.indexArray=new Hi,this.indexArray2=new Hn,this.programConfigurations=new Wo(e.layers,e.zoom),this.segments=new Nt,this.segments2=new Nt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,n,s){this.hasPattern=Eh("fill",this.layers,r);let l=this.layers[0].layout.get("fill-sort-key"),u=[];for(let{feature:p,id:m,index:g,sourceLayerIndex:x}of e){let v=this.layers[0]._featureFilter.needGeometry,b=Ko(p,v);if(!this.layers[0]._featureFilter.filter(new Ze(this.zoom),b,n))continue;let I=l?l.evaluate(b,{},n,r.availableImages):void 0,A={id:m,properties:p.properties,type:p.type,sourceLayerIndex:x,index:g,geometry:v?b.geometry:fn(p,n,s),patterns:{},sortKey:I};u.push(A)}l&&u.sort((p,m)=>p.sortKey-m.sortKey);for(let p of u){let{geometry:m,index:g,sourceLayerIndex:x}=p;if(this.hasPattern){let v=Sh("fill",this.layers,p,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(p,m,g,n,{},r.availableImages);r.featureIndex.insert(e[g].feature,m,g,x,this.index)}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}addFeatures(e,r,n,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xp),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,n,s,l,u=[]){for(let p of Th(r,500)){let m=0;for(let A of p)m+=A.length;let g=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],b=[];for(let A of p){if(A.length===0)continue;A!==p[0]&&b.push(v.length/2);let k=this.segments2.prepareSegment(A.length,this.layoutVertexArray,this.indexArray2),D=k.vertexLength;this.layoutVertexArray.emplaceBack(A[0].x,A[0].y),this.indexArray2.emplaceBack(D+A.length-1,D),v.push(A[0].x),v.push(A[0].y);for(let U=1;U<A.length;U++)this.layoutVertexArray.emplaceBack(A[U].x,A[U].y),this.indexArray2.emplaceBack(D+U-1,D+U),v.push(A[U].x),v.push(A[U].y);k.vertexLength+=A.length,k.primitiveLength+=A.length}let I=cc(v,b);for(let A=0;A<I.length;A+=3)this.indexArray.emplaceBack(x+I[A],x+I[A+1],x+I[A+2]);g.vertexLength+=m,g.primitiveLength+=I.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s)}}ke("FillBucket",fc,{omit:["layers","patternFeatures"]});let lf=new ri({"fill-sort-key":new Fe(se.layout_fill["fill-sort-key"])});var cf={paint:new ri({"fill-antialias":new Pe(se.paint_fill["fill-antialias"]),"fill-opacity":new Fe(se.paint_fill["fill-opacity"]),"fill-color":new Fe(se.paint_fill["fill-color"]),"fill-outline-color":new Fe(se.paint_fill["fill-outline-color"]),"fill-translate":new Pe(se.paint_fill["fill-translate"]),"fill-translate-anchor":new Pe(se.paint_fill["fill-translate-anchor"]),"fill-pattern":new Kt(se.paint_fill["fill-pattern"])}),layout:lf};let hf=Pt([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),uf=Pt([{name:"a_centroid_pos",components:2,type:"Uint16"}]),{members:df}=hf;var Wu=ea;function ea(t,e,r,n,s){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=s,t.readFields(pf,this,e)}function pf(t,e,r){t==1?e.id=r.readVarint():t==2?function(n,s){for(var l=n.readVarint()+n.pos;n.pos<l;){var u=s._keys[n.readVarint()],p=s._values[n.readVarint()];s.properties[u]=p}}(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function ff(t){for(var e,r,n=0,s=0,l=t.length,u=l-1;s<l;u=s++)n+=((r=t[u]).x-(e=t[s]).x)*(e.y+r.y);return n}ea.types=["Unknown","Point","LineString","Polygon"],ea.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,r=t.readVarint()+t.pos,n=1,s=0,l=0,u=0,p=[];t.pos<r;){if(s<=0){var m=t.readVarint();n=7&m,s=m>>3}if(s--,n===1||n===2)l+=t.readSVarint(),u+=t.readSVarint(),n===1&&(e&&p.push(e),e=[]),e.push(new Ce(l,u));else{if(n!==7)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&p.push(e),p},ea.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,s=0,l=0,u=1/0,p=-1/0,m=1/0,g=-1/0;t.pos<e;){if(n<=0){var x=t.readVarint();r=7&x,n=x>>3}if(n--,r===1||r===2)(s+=t.readSVarint())<u&&(u=s),s>p&&(p=s),(l+=t.readSVarint())<m&&(m=l),l>g&&(g=l);else if(r!==7)throw new Error("unknown command "+r)}return[u,m,p,g]},ea.prototype.toGeoJSON=function(t,e,r){var n,s,l=this.extent*Math.pow(2,r),u=this.extent*t,p=this.extent*e,m=this.loadGeometry(),g=ea.types[this.type];function x(I){for(var A=0;A<I.length;A++){var k=I[A];I[A]=[360*(k.x+u)/l-180,360/Math.PI*Math.atan(Math.exp((180-360*(k.y+p)/l)*Math.PI/180))-90]}}switch(this.type){case 1:var v=[];for(n=0;n<m.length;n++)v[n]=m[n][0];x(m=v);break;case 2:for(n=0;n<m.length;n++)x(m[n]);break;case 3:for(m=function(I){var A=I.length;if(A<=1)return[I];for(var k,D,U=[],$=0;$<A;$++){var H=ff(I[$]);H!==0&&(D===void 0&&(D=H<0),D===H<0?(k&&U.push(k),k=[I[$]]):k.push(I[$]))}return k&&U.push(k),U}(m),n=0;n<m.length;n++)for(s=0;s<m[n].length;s++)x(m[n][s])}m.length===1?m=m[0]:g="Multi"+g;var b={type:"Feature",geometry:{type:g,coordinates:m},properties:this.properties};return"id"in this&&(b.id=this.id),b};var Hu=Ku;function Ku(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(mf,this,e),this.length=this._features.length}function mf(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(function(n){for(var s=null,l=n.readVarint()+n.pos;n.pos<l;){var u=n.readVarint()>>3;s=u===1?n.readString():u===2?n.readFloat():u===3?n.readDouble():u===4?n.readVarint64():u===5?n.readVarint():u===6?n.readSVarint():u===7?n.readBoolean():null}return s}(r))}function _f(t,e,r){if(t===3){var n=new Hu(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}Ku.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 Wu(this._pbf,e,this.extent,this._keys,this._values)};var Yo={VectorTile:function(t,e){this.layers=t.readFields(_f,{},e)},VectorTileFeature:Wu,VectorTileLayer:Hu};let gf=Yo.VectorTileFeature.types,yf=Math.pow(2,13);function Ja(t,e,r,n,s,l,u,p){t.emplaceBack((e<<1)+u,(r<<1)+l,(Math.floor(n*yf)<<1)+s,Math.round(p))}class Yu{constructor(){this.acc=new Ce(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Ce(e.x,e.y),this.max=new Ce(e.x,e.y))}append(e,r){this.currentPolyCount.edges++,this.acc._add(e);let n=!!this.borders,s=this.min,l=this.max;e.x<s.x?(s.x=e.x,n=!0):e.x>l.x&&(l.x=e.x,n=!0),e.y<s.y?(s.y=e.y,n=!0):e.y>l.y&&(l.y=e.y,n=!0),((e.x===0||e.x===Qe)&&e.x===r.x)!=((e.y===0||e.y===Qe)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r)}checkBorderIntersection(e,r){r.x<0!=e.x<0&&this.addBorderIntersection(0,pt(r.y,e.y,(0-r.x)/(e.x-r.x))),r.x>Qe!=e.x>Qe&&this.addBorderIntersection(1,pt(r.y,e.y,(Qe-r.x)/(e.x-r.x))),r.y<0!=e.y<0&&this.addBorderIntersection(2,pt(r.x,e.x,(0-r.y)/(e.y-r.y))),r.y>Qe!=e.y>Qe&&this.addBorderIntersection(3,pt(r.x,e.x,(Qe-r.y)/(e.y-r.y)))}addBorderIntersection(e,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);let n=this.borders[e];r<n[0]&&(n[0]=r),r>n[1]&&(n[1]=r)}processBorderOverlap(e,r){if(e.x===r.x){if(e.y===r.y)return;let n=e.x===0?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,e.y)}else{let n=e.y===0?2:3;this.addBorderIntersection(n,r.x),this.addBorderIntersection(n,e.x)}}centroid(){let e=this.polyCount.reduce((r,n)=>r+n.edges,0);return e!==0?this.acc.div(e)._round():new Ce(0,0)}span(){return new Ce(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,r)=>e+ +(r[0]!==Number.MAX_VALUE),0)}}class Ih{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new qs,this.centroidVertexArray=new bu,this.indexArray=new Hi,this.programConfigurations=new Wo(e.layers,e.zoom),this.segments=new Nt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.enableTerrain=e.enableTerrain}populate(e,r,n,s){this.features=[],this.hasPattern=Eh("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(l){let u=Math.exp(Math.PI*(1-l.y/(1<<l.z)*2));return 80150034*u/(u*u+1)/Qe/(1<<l.z)}(n);for(let{feature:l,id:u,index:p,sourceLayerIndex:m}of e){let g=this.layers[0]._featureFilter.needGeometry,x=Ko(l,g);if(!this.layers[0]._featureFilter.filter(new Ze(this.zoom),x,n))continue;let v={id:u,sourceLayerIndex:m,index:p,geometry:g?x.geometry:fn(l,n,s),properties:l.properties,type:l.type,patterns:{}},b=this.layoutVertexArray.length;this.hasPattern?this.features.push(Sh("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,p,n,{},r.availableImages),r.featureIndex.insert(l,v.geometry,p,m,this.index,b)}this.sortBorders()}addFeatures(e,r,n,s){for(let l of this.features){let{geometry:u}=l;this.addFeature(l,u,l.index,r,n,s)}this.sortBorders()}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,df),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,uf.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,n,s,l,u){let p=this.enableTerrain?new Yu:null;for(let g of Th(r,500)){let x=0,v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);if(g.length===0||(m=g[0]).every(D=>D.x<=0)||m.every(D=>D.x>=Qe)||m.every(D=>D.y<=0)||m.every(D=>D.y>=Qe))continue;for(let D=0;D<g.length;D++){let U=g[D];if(U.length===0)continue;x+=U.length;let $=0;p&&p.startRing(U[0]);for(let H=0;H<U.length;H++){let Y=U[H];if(H>=1){let J=U[H-1];if(!xf(Y,J)){p&&p.append(Y,J),v.vertexLength+4>Nt.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let Q=Y.sub(J)._perp(),he=Q.x/(Math.abs(Q.x)+Math.abs(Q.y)),le=Q.y>0?1:0,Se=J.dist(Y);$+Se>32768&&($=0),Ja(this.layoutVertexArray,Y.x,Y.y,he,le,0,0,$),Ja(this.layoutVertexArray,Y.x,Y.y,he,le,0,1,$),$+=Se,Ja(this.layoutVertexArray,J.x,J.y,he,le,0,0,$),Ja(this.layoutVertexArray,J.x,J.y,he,le,0,1,$);let be=v.vertexLength;this.indexArray.emplaceBack(be,be+2,be+1),this.indexArray.emplaceBack(be+1,be+2,be+3),v.vertexLength+=4,v.primitiveLength+=2}}}}if(v.vertexLength+x>Nt.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(x,this.layoutVertexArray,this.indexArray)),gf[e.type]!=="Polygon")continue;let b=[],I=[],A=v.vertexLength;for(let D=0;D<g.length;D++){let U=g[D];if(U.length!==0){U!==g[0]&&I.push(b.length/2);for(let $=0;$<U.length;$++){let H=U[$];Ja(this.layoutVertexArray,H.x,H.y,0,0,1,1,0),b.push(H.x),b.push(H.y),p&&p.currentPolyCount.top++}}}let k=cc(b,I);for(let D=0;D<k.length;D+=3)this.indexArray.emplaceBack(A+k[D],A+k[D+2],A+k[D+1]);v.primitiveLength+=k.length/3,v.vertexLength+=x}var m;if(p&&p.polyCount.length>0){if(p.borders){p.vertexArrayOffset=this.centroidVertexArray.length;let g=p.borders,x=this.featuresOnBorder.push(p)-1;for(let v=0;v<4;v++)g[v][0]!==Number.MAX_VALUE&&this.borders[v].push(x)}this.encodeCentroid(p.borders?void 0:p.centroid(),p)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((r,n)=>this.featuresOnBorder[r].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,r,n=!0){let s,l;if(e)if(e.y!==0){let p=r.span()._mult(this.tileToMeter);s=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(p.x/10)),l=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(p.y/10))}else s=Math.ceil(7*(e.x+450)),l=0;else s=0,l=+n;let u=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(let p of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*p.edges+p.top);for(let m=0;m<2*p.edges;m++)this.centroidVertexArray.emplace(u++,0,l),this.centroidVertexArray.emplace(u++,s,l);for(let m=0;m<p.top;m++)this.centroidVertexArray.emplace(u++,s,l)}}}function xf(t,e){return t.x===e.x&&(t.x<0||t.x>Qe)||t.y===e.y&&(t.y<0||t.y>Qe)}ke("FillExtrusionBucket",Ih,{omit:["layers","features"]}),ke("PartMetadata",Yu);var vf={paint:new ri({"fill-extrusion-opacity":new Pe(se["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Fe(se["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Pe(se["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Pe(se["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Kt(se["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Fe(se["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Fe(se["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Pe(se["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Qa(t,e){return t.x*e.x+t.y*e.y}function Ju(t,e){if(t.length===1){let r=0,n=e[r++],s;for(;!s||n.equals(s);)if(s=e[r++],!s)return 1/0;for(;r<e.length;r++){let l=e[r],u=t[0],p=s.sub(n),m=l.sub(n),g=u.sub(n),x=Qa(p,p),v=Qa(p,m),b=Qa(m,m),I=Qa(g,p),A=Qa(g,m),k=x*b-v*v,D=(b*I-v*A)/k,U=(x*A-v*I)/k,$=n.z*(1-D-U)+s.z*D+l.z*U;if(isFinite($))return $}return 1/0}{let r=1/0;for(let n of e)r=Math.min(r,n.z);return r}}function Qu(t){let e=new Ce(t[0],t[1]);return e.z=t[2],e}function bf(t,e,r,n,s,l,u,p){let m=u*s.getElevationAt(t,e,!0,!0),g=l[0]!==0,x=g?l[1]===0?u*(l[0]/7-450):u*function(v,b,I){let A=Math.floor(b[0]/8),k=Math.floor(b[1]/8),D=10*(b[0]-8*A),U=10*(b[1]-8*k),$=v.getElevationAt(A,k,!0,!0),H=v.getMeterToDEM(I),Y=Math.floor(.5*(D*H-1)),J=Math.floor(.5*(U*H-1)),Q=v.tileCoordToPixel(A,k),he=2*Y+1,le=2*J+1,Se=function(ze,De,rt,bt,st){return[ze.getElevationAtPixel(De,rt,!0),ze.getElevationAtPixel(De+st,rt,!0),ze.getElevationAtPixel(De,rt+st,!0),ze.getElevationAtPixel(De+bt,rt+st,!0)]}(v,Q.x-Y,Q.y-J,he,le),be=Math.abs(Se[0]-Se[1]),ce=Math.abs(Se[2]-Se[3]),we=Math.abs(Se[0]-Se[2])+Math.abs(Se[1]-Se[3]),Ie=Math.min(.25,.5*H*(be+ce)/he),fe=Math.min(.25,.5*H*we/le);return $+Math.max(Ie*D,fe*U)}(s,l,p):m;return{base:m+(r===0)?-1:r,top:g?Math.max(x+n,m+r+2):m+n}}let wf=Pt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Tf}=wf,Ef=Pt([{name:"a_packed",components:3,type:"Float32"}]),{members:Sf}=Ef,If=Yo.VectorTileFeature.types,Mf=Math.cos(Math.PI/180*37.5);class mc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new Yc,this.layoutVertexArray2=new Xs,this.indexArray=new Hi,this.programConfigurations=new Wo(e.layers,e.zoom),this.segments=new Nt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,n,s){this.hasPattern=Eh("line",this.layers,r);let l=this.layers[0].layout.get("line-sort-key"),u=[];for(let{feature:x,id:v,index:b,sourceLayerIndex:I}of e){let A=this.layers[0]._featureFilter.needGeometry,k=Ko(x,A);if(!this.layers[0]._featureFilter.filter(new Ze(this.zoom),k,n))continue;let D=l?l.evaluate(k,{},n):void 0,U={id:v,properties:x.properties,type:x.type,sourceLayerIndex:I,index:b,geometry:A?k.geometry:fn(x,n,s),patterns:{},sortKey:D};u.push(U)}l&&u.sort((x,v)=>x.sortKey-v.sortKey);let{lineAtlas:p,featureIndex:m}=r,g=this.addConstantDashes(p);for(let x of u){let{geometry:v,index:b,sourceLayerIndex:I}=x;if(g&&this.addFeatureDashes(x,p),this.hasPattern){let A=Sh("line",this.layers,x,this.zoom,r);this.patternFeatures.push(A)}else this.addFeature(x,v,b,n,p.positions,r.availableImages);m.insert(e[b].feature,v,b,I,this.index)}}addConstantDashes(e){let r=!1;for(let n of this.layers){let s=n.paint.get("line-dasharray").value,l=n.layout.get("line-cap").value;if(s.kind!=="constant"||l.kind!=="constant")r=!0;else{let u=l.value,p=s.value;if(!p)continue;e.addDash(p.from,u),e.addDash(p.to,u),p.other&&e.addDash(p.other,u)}}return r}addFeatureDashes(e,r){let n=this.zoom;for(let s of this.layers){let l=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if(l.kind==="constant"&&u.kind==="constant")continue;let p,m,g,x,v,b;if(l.kind==="constant"){let D=l.value;if(!D)continue;p=D.other||D.to,m=D.to,g=D.from}else p=l.evaluate({zoom:n-1},e),m=l.evaluate({zoom:n},e),g=l.evaluate({zoom:n+1},e);u.kind==="constant"?x=v=b=u.value:(x=u.evaluate({zoom:n-1},e),v=u.evaluate({zoom:n},e),b=u.evaluate({zoom:n+1},e)),r.addDash(p,x),r.addDash(m,v),r.addDash(g,b);let I=r.getKey(p,x),A=r.getKey(m,v),k=r.getKey(g,b);e.patterns[s.id]={min:I,mid:A,max:k}}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}addFeatures(e,r,n,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Sf)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Tf),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,n,s,l,u){let p=this.layers[0].layout,m=p.get("line-join").evaluate(e,{}),g=p.get("line-cap").evaluate(e,{}),x=p.get("line-miter-limit"),v=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(let b of r)this.addLine(b,e,m,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s)}addLine(e,r,n,s,l,u){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let U=0;U<e.length-1;U++)this.totalDistance+=e[U].dist(e[U+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let p=If[r.type]==="Polygon",m=e.length;for(;m>=2&&e[m-1].equals(e[m-2]);)m--;let g=0;for(;g<m-1&&e[g].equals(e[g+1]);)g++;if(m<(p?3:2))return;n==="bevel"&&(l=1.05);let x=this.overscaling<=16?122880/(512*this.overscaling):0,v=this.segments.prepareSegment(10*m,this.layoutVertexArray,this.indexArray),b,I,A,k,D;this.e1=this.e2=-1,p&&(b=e[m-2],D=e[g].sub(b)._unit()._perp());for(let U=g;U<m;U++){if(A=U===m-1?p?e[g+1]:void 0:e[U+1],A&&e[U].equals(A))continue;D&&(k=D),b&&(I=b),b=e[U],D=A?A.sub(b)._unit()._perp():k,k=k||D;let $=k.add(D);$.x===0&&$.y===0||$._unit();let H=k.x*D.x+k.y*D.y,Y=$.x*D.x+$.y*D.y,J=Y!==0?1/Y:1/0,Q=2*Math.sqrt(2-2*Y),he=Y<Mf&&I&&A,le=k.x*D.y-k.y*D.x>0;if(he&&U>g){let ce=b.dist(I);if(ce>2*x){let we=b.sub(b.sub(I)._mult(x/ce)._round());this.updateDistance(I,we),this.addCurrentVertex(we,k,0,0,v),I=we}}let Se=I&&A,be=Se?n:p?"butt":s;if(Se&&be==="round"&&(J<u?be="miter":J<=2&&(be="fakeround")),be==="miter"&&J>l&&(be="bevel"),be==="bevel"&&(J>2&&(be="flipbevel"),J<l&&(be="miter")),I&&this.updateDistance(I,b),be==="miter")$._mult(J),this.addCurrentVertex(b,$,0,0,v);else if(be==="flipbevel"){if(J>100)$=D.mult(-1);else{let ce=J*k.add(D).mag()/k.sub(D).mag();$._perp()._mult(ce*(le?-1:1))}this.addCurrentVertex(b,$,0,0,v),this.addCurrentVertex(b,$.mult(-1),0,0,v)}else if(be==="bevel"||be==="fakeround"){let ce=-Math.sqrt(J*J-1),we=le?ce:0,Ie=le?0:ce;if(I&&this.addCurrentVertex(b,k,we,Ie,v),be==="fakeround"){let fe=Math.round(180*Q/Math.PI/20);for(let ze=1;ze<fe;ze++){let De=ze/fe;if(De!==.5){let bt=De-.5;De+=De*bt*(De-1)*((1.0904+H*(H*(3.55645-1.43519*H)-3.2452))*bt*bt+(.848013+H*(.215638*H-1.06021)))}let rt=D.sub(k)._mult(De)._add(k)._unit()._mult(le?-1:1);this.addHalfVertex(b,rt.x,rt.y,!1,le,0,v)}}A&&this.addCurrentVertex(b,D,-we,-Ie,v)}else if(be==="butt")this.addCurrentVertex(b,$,0,0,v);else if(be==="square"){let ce=I?1:-1;I||this.addCurrentVertex(b,$,ce,ce,v),this.addCurrentVertex(b,$,0,0,v),I&&this.addCurrentVertex(b,$,ce,ce,v)}else be==="round"&&(I&&(this.addCurrentVertex(b,k,0,0,v),this.addCurrentVertex(b,k,1,1,v,!0)),A&&(this.addCurrentVertex(b,D,-1,-1,v,!0),this.addCurrentVertex(b,D,0,0,v)));if(he&&U<m-1){let ce=b.dist(A);if(ce>2*x){let we=b.add(A.sub(b)._mult(x/ce)._round());this.updateDistance(b,we),this.addCurrentVertex(we,D,0,0,v),b=we}}}}addCurrentVertex(e,r,n,s,l,u=!1){let p=r.y*s-r.x,m=-r.y-r.x*s;this.addHalfVertex(e,r.x+r.y*n,r.y-r.x*n,u,!1,n,l),this.addHalfVertex(e,p,m,u,!0,-s,l)}addHalfVertex({x:e,y:r},n,s,l,u,p,m){this.layoutVertexArray.emplaceBack((e<<1)+(l?1:0),(r<<1)+(u?1:0),Math.round(63*n)+128,Math.round(63*s)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);let g=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,g),m.primitiveLength++),u?this.e2=g:this.e1=g}updateScaledDistance(){if(this.lineClips){let e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}ke("LineBucket",mc,{omit:["layers","patternFeatures"]});let Af=new ri({"line-cap":new Fe(se.layout_line["line-cap"]),"line-join":new Fe(se.layout_line["line-join"]),"line-miter-limit":new Pe(se.layout_line["line-miter-limit"]),"line-round-limit":new Pe(se.layout_line["line-round-limit"]),"line-sort-key":new Fe(se.layout_line["line-sort-key"])});var ed={paint:new ri({"line-opacity":new Fe(se.paint_line["line-opacity"]),"line-color":new Fe(se.paint_line["line-color"]),"line-translate":new Pe(se.paint_line["line-translate"]),"line-translate-anchor":new Pe(se.paint_line["line-translate-anchor"]),"line-width":new Fe(se.paint_line["line-width"]),"line-gap-width":new Fe(se.paint_line["line-gap-width"]),"line-offset":new Fe(se.paint_line["line-offset"]),"line-blur":new Fe(se.paint_line["line-blur"]),"line-dasharray":new Kt(se.paint_line["line-dasharray"]),"line-pattern":new Kt(se.paint_line["line-pattern"]),"line-gradient":new Zr(se.paint_line["line-gradient"])}),layout:Af};let td=new class extends Fe{possiblyEvaluate(t,e){return e=new Ze(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=Lt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}(ed.paint.properties["line-width"].specification);function id(t,e){return e>0?e+2*t:t}td.useIntegerZoom=!0;let Cf=Pt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),zf=Pt([{name:"a_projected_pos",components:3,type:"Float32"}],4);Pt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let kf=Pt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Pf=Pt([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Pt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);let rd=Pt([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Df=Pt([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Pt([{name:"triangle",components:3,type:"Uint16"}]),Pt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"},{type:"Uint8",name:"flipState"}]),Pt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Pt([{type:"Float32",name:"offsetX"}]),Pt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var oi=24;let qr=128;function Mh(t,e){let{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Ze(t+1))};if(r.kind==="source")return{kind:"source"};{let{zoomStops:n,interpolationType:s}=r,l=0;for(;l<n.length&&n[l]<=t;)l++;l=Math.max(0,l-1);let u=l;for(;u<n.length&&n[u]<t+1;)u++;u=Math.min(n.length-1,u);let p=n[l],m=n[u];return r.kind==="composite"?{kind:"composite",minZoom:p,maxZoom:m,interpolationType:s}:{kind:"camera",minZoom:p,maxZoom:m,minSize:r.evaluate(new Ze(p)),maxSize:r.evaluate(new Ze(m)),interpolationType:s}}}function _c(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:s}){return t.kind==="source"?n/qr:t.kind==="composite"?pt(n/qr,s/qr,r):e}function ta(t,e){let r=0,n=0;if(t.kind==="constant")n=t.layoutSize;else if(t.kind!=="source"){let{interpolationType:s,minZoom:l,maxZoom:u}=t,p=s?mt(pi.interpolationFactor(s,e,l,u),0,1):0;t.kind==="camera"?n=pt(t.minSize,t.maxSize,p):r=p}return{uSizeT:r,uSize:n}}var Lf=Object.freeze({__proto__:null,getSizeData:Mh,evaluateSizeForFeature:_c,evaluateSizeForZoom:ta,SIZE_PACK_FACTOR:qr});function Bf(t,e,r){return t.sections.forEach(n=>{n.text=function(s,l,u){let p=l.layout.get("text-transform").evaluate(u,{});return p==="uppercase"?s=s.toLocaleUpperCase():p==="lowercase"&&(s=s.toLocaleLowerCase()),ot.applyArabicShaping&&(s=ot.applyArabicShaping(s)),s}(n.text,e,r)}),t}let el={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function Rf(t){return t==="\uFE36"||t==="\uFE48"||t==="\uFE38"||t==="\uFE44"||t==="\uFE42"||t==="\uFE3E"||t==="\uFE3C"||t==="\uFE3A"||t==="\uFE18"||t==="\uFE40"||t==="\uFE10"||t==="\uFE13"||t==="\uFE14"||t==="\uFF40"||t==="\uFFE3"||t==="\uFE11"||t==="\uFE12"}function Ff(t){return t==="\uFE35"||t==="\uFE47"||t==="\uFE37"||t==="\uFE43"||t==="\uFE41"||t==="\uFE3D"||t==="\uFE3B"||t==="\uFE39"||t==="\uFE17"||t==="\uFE3F"}var nd=function(t,e,r,n,s){var l,u,p=8*s-n-1,m=(1<<p)-1,g=m>>1,x=-7,v=r?s-1:0,b=r?-1:1,I=t[e+v];for(v+=b,l=I&(1<<-x)-1,I>>=-x,x+=p;x>0;l=256*l+t[e+v],v+=b,x-=8);for(u=l&(1<<-x)-1,l>>=-x,x+=n;x>0;u=256*u+t[e+v],v+=b,x-=8);if(l===0)l=1-g;else{if(l===m)return u?NaN:1/0*(I?-1:1);u+=Math.pow(2,n),l-=g}return(I?-1:1)*u*Math.pow(2,l-n)},od=function(t,e,r,n,s,l){var u,p,m,g=8*l-s-1,x=(1<<g)-1,v=x>>1,b=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:l-1,A=n?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,u=x):(u=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-u))<1&&(u--,m*=2),(e+=u+v>=1?b/m:b*Math.pow(2,1-v))*m>=2&&(u++,m/=2),u+v>=x?(p=0,u=x):u+v>=1?(p=(e*m-1)*Math.pow(2,s),u+=v):(p=e*Math.pow(2,v-1)*Math.pow(2,s),u=0));s>=8;t[r+I]=255&p,I+=A,p/=256,s-=8);for(u=u<<s|p,g+=s;g>0;t[r+I]=255&u,I+=A,u/=256,g-=8);t[r+I-A]|=128*k},tl=vt;function vt(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}vt.Varint=0,vt.Fixed64=1,vt.Bytes=2,vt.Fixed32=5;var Ah=4294967296,sd=1/Ah,ad=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function mn(t){return t.type===vt.Bytes?t.readVarint()+t.pos:t.pos+1}function ia(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function ld(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var s=r.pos-1;s>=t;s--)r.buf[s+n]=r.buf[s]}function Of(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Uf(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Vf(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Nf(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function jf(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function Gf(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function Zf(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function $f(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function qf(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function gc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function ra(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function cd(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Xf(t,e,r){e.glyphs=[],t===1&&r.readMessage(Wf,e)}function Wf(t,e,r){if(t===3){let{id:n,bitmap:s,width:l,height:u,left:p,top:m,advance:g}=r.readMessage(Hf,{});e.glyphs.push({id:n,bitmap:new Yn({width:l+6,height:u+6},s),metrics:{width:l,height:u,left:p,top:m,advance:g}})}else t===4?e.ascender=r.readSVarint():t===5&&(e.descender=r.readSVarint())}function Hf(t,e,r){t===1?e.id=r.readVarint():t===2?e.bitmap=r.readBytes():t===3?e.width=r.readVarint():t===4?e.height=r.readVarint():t===5?e.left=r.readSVarint():t===6?e.top=r.readSVarint():t===7&&(e.advance=r.readVarint())}function Ch(t){let e=0,r=0;for(let u of t)e+=u.w*u.h,r=Math.max(r,u.w);t.sort((u,p)=>p.h-u.h);let n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}],s=0,l=0;for(let u of t)for(let p=n.length-1;p>=0;p--){let m=n[p];if(!(u.w>m.w||u.h>m.h)){if(u.x=m.x,u.y=m.y,l=Math.max(l,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===m.w&&u.h===m.h){let g=n.pop();p<n.length&&(n[p]=g)}else u.h===m.h?(m.x+=u.w,m.w-=u.w):u.w===m.w?(m.y+=u.h,m.h-=u.h):(n.push({x:m.x+u.w,y:m.y,w:m.w-u.w,h:u.h}),m.y+=u.h,m.h-=u.h);break}}return{w:s,h:l,fill:e/(s*l)||0}}vt.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),s=n>>3,l=this.pos;this.type=7&n,t(s,e,this),this.pos===l&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=gc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=cd(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=gc(this.buf,this.pos)+gc(this.buf,this.pos+4)*Ah;return this.pos+=8,t},readSFixed64:function(){var t=gc(this.buf,this.pos)+cd(this.buf,this.pos+4)*Ah;return this.pos+=8,t},readFloat:function(){var t=nd(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=nd(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(s,l,u){var p,m,g=u.buf;if(p=(112&(m=g[u.pos++]))>>4,m<128||(p|=(127&(m=g[u.pos++]))<<3,m<128)||(p|=(127&(m=g[u.pos++]))<<10,m<128)||(p|=(127&(m=g[u.pos++]))<<17,m<128)||(p|=(127&(m=g[u.pos++]))<<24,m<128)||(p|=(1&(m=g[u.pos++]))<<31,m<128))return ia(s,p,l);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[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&&ad?function(r,n,s){return ad.decode(r.subarray(n,s))}(this.buf,e,t):function(r,n,s){for(var l="",u=n;u<s;){var p,m,g,x=r[u],v=null,b=x>239?4:x>223?3:x>191?2:1;if(u+b>s)break;b===1?x<128&&(v=x):b===2?(192&(p=r[u+1]))==128&&(v=(31&x)<<6|63&p)<=127&&(v=null):b===3?(m=r[u+2],(192&(p=r[u+1]))==128&&(192&m)==128&&((v=(15&x)<<12|(63&p)<<6|63&m)<=2047||v>=55296&&v<=57343)&&(v=null)):b===4&&(m=r[u+2],g=r[u+3],(192&(p=r[u+1]))==128&&(192&m)==128&&(192&g)==128&&((v=(15&x)<<18|(63&p)<<12|(63&m)<<6|63&g)<=65535||v>=1114112)&&(v=null)),v===null?(v=65533,b=1):v>65535&&(v-=65536,l+=String.fromCharCode(v>>>10&1023|55296),v=56320|1023&v),l+=String.fromCharCode(v),u+=b}return l}(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!==vt.Bytes)return t.push(this.readVarint(e));var r=mn(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==vt.Bytes)return t.push(this.readSVarint());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==vt.Bytes)return t.push(this.readBoolean());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==vt.Bytes)return t.push(this.readFloat());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==vt.Bytes)return t.push(this.readDouble());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==vt.Bytes)return t.push(this.readFixed32());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==vt.Bytes)return t.push(this.readSFixed32());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==vt.Bytes)return t.push(this.readFixed64());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==vt.Bytes)return t.push(this.readSFixed64());var e=mn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===vt.Varint)for(;this.buf[this.pos++]>127;);else if(e===vt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===vt.Fixed32)this.pos+=4;else{if(e!==vt.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 r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),ra(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),ra(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),ra(this.buf,-1&t,this.pos),ra(this.buf,Math.floor(t*sd),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),ra(this.buf,-1&t,this.pos),ra(this.buf,Math.floor(t*sd),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,r){var n,s;if(e>=0?(n=e%4294967296|0,s=e/4294967296|0):(s=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(l,u,p){p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,p.buf[p.pos]=127&(l>>>=7)}(n,0,r),function(l,u){var p=(7&l)<<4;u.buf[u.pos++]|=p|((l>>>=3)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l)))))}(s,r)}(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(n,s,l){for(var u,p,m=0;m<s.length;m++){if((u=s.charCodeAt(m))>55295&&u<57344){if(!p){u>56319||m+1===s.length?(n[l++]=239,n[l++]=191,n[l++]=189):p=u;continue}if(u<56320){n[l++]=239,n[l++]=191,n[l++]=189,p=u;continue}u=p-55296<<10|u-56320|65536,p=null}else p&&(n[l++]=239,n[l++]=191,n[l++]=189,p=null);u<128?n[l++]=u:(u<2048?n[l++]=u>>6|192:(u<65536?n[l++]=u>>12|224:(n[l++]=u>>18|240,n[l++]=u>>12&63|128),n[l++]=u>>6&63|128),n[l++]=63&u|128)}return l}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&ld(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),od(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),od(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 r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&ld(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,vt.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Of,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Uf,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,jf,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Vf,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Nf,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Gf,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Zf,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,$f,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,qf,e)},writeBytesField:function(t,e){this.writeTag(t,vt.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,vt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,vt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,vt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,vt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,vt.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,vt.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,vt.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,vt.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,vt.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class zh{constructor(e,{pixelRatio:r,version:n,stretchX:s,stretchY:l,content:u}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=s,this.stretchY=l,this.content=u,this.version=n}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 displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class hd{constructor(e,r){let n={},s={};this.haveRenderCallbacks=[];let l=[];this.addImages(e,n,l),this.addImages(r,s,l);let{w:u,h:p}=Ch(l),m=new Ki({width:u||1,height:p||1});for(let g in e){let x=e[g],v=n[g].paddedRect;Ki.copy(x.data,m,{x:0,y:0},{x:v.x+1,y:v.y+1},x.data)}for(let g in r){let x=r[g],v=s[g].paddedRect,b=v.x+1,I=v.y+1,A=x.data.width,k=x.data.height;Ki.copy(x.data,m,{x:0,y:0},{x:b,y:I},x.data),Ki.copy(x.data,m,{x:0,y:k-1},{x:b,y:I-1},{width:A,height:1}),Ki.copy(x.data,m,{x:0,y:0},{x:b,y:I+k},{width:A,height:1}),Ki.copy(x.data,m,{x:A-1,y:0},{x:b-1,y:I},{width:1,height:k}),Ki.copy(x.data,m,{x:0,y:0},{x:b+A,y:I},{width:1,height:k})}this.image=m,this.iconPositions=n,this.patternPositions=s}addImages(e,r,n){for(let s in e){let l=e[s],u={x:0,y:0,w:l.data.width+2,h:l.data.height+2};n.push(u),r[s]=new zh(u,l),l.hasRenderCallback&&this.haveRenderCallbacks.push(s)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),r)}patchUpdatedImage(e,r,n){if(!e||!r||e.version===r.version)return;e.version=r.version;let[s,l]=e.tl;n.update(r.data,void 0,{x:s,y:l})}}ke("ImagePosition",zh),ke("ImageAtlas",hd);let Yi={horizontal:1,vertical:2,horizontalOnly:3};class il{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){let n=new il;return n.scale=e||1,n.fontStack=r,n}static forImage(e){let r=new il;return r.imageName=e,r}}class na{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){let n=new na;for(let s=0;s<e.sections.length;s++){let l=e.sections[s];l.image?n.addImageSection(l):n.addTextSection(l,r)}return n}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(r,n){let s="";for(let l=0;l<r.length;l++){let u=r.charCodeAt(l+1)||null,p=r.charCodeAt(l-1)||null;s+=!n&&(u&&Be(u)&&!el[r[l+1]]||p&&Be(p)&&!el[r[l-1]])||!el[r[l]]?r[l]:el[r[l]]}return s}(this.text,e)}trim(){let e=0;for(let n=0;n<this.text.length&&yc[this.text.charCodeAt(n)];n++)e++;let r=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&yc[this.text.charCodeAt(n)];n--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){let n=new na;return n.text=this.text.substring(e,r),n.sectionIndex=this.sectionIndex.slice(e,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(il.forText(e.scale,e.fontStack||r));let n=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(n)}addImageSection(e){let r=e.image?e.image.name:"";if(r.length===0)return void zt("Can't add FormattedSection with an empty image.");let n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(il.forImage(r)),this.sectionIndex.push(this.sections.length-1)):zt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function kh(t,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k){let D=na.fromFeature(t,s),U;v===Yi.vertical&&D.verticalizePunctuation(b);let{processBidirectionalText:$,processStyledBidirectionalText:H}=ot;if($&&D.sections.length===1){U=[];let Q=$(D.toString(),Ph(D,g,l,e,n,I,A));for(let he of Q){let le=new na;le.text=he,le.sections=D.sections;for(let Se=0;Se<he.length;Se++)le.sectionIndex.push(0);U.push(le)}}else if(H){U=[];let Q=H(D.text,D.sectionIndex,Ph(D,g,l,e,n,I,A));for(let he of Q){let le=new na;le.text=he[0],le.sectionIndex=he[1],le.sections=D.sections,U.push(le)}}else U=function(Q,he){let le=[],Se=Q.text,be=0;for(let ce of he)le.push(Q.substring(be,ce)),be=ce;return be<Se.length&&le.push(Q.substring(be,Se.length)),le}(D,Ph(D,g,l,e,n,I,A));let Y=[],J={positionedLines:Y,text:D.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:v,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Q,he,le,Se,be,ce,we,Ie,fe,ze,De,rt){let bt=0,st=0,at=0,ve=Ie==="right"?1:Ie==="left"?0:.5,ut=!1;for(let dt of be){let it=dt.getSections();for(let At of it){if(At.imageName)continue;let Zt=he[At.fontStack];if(Zt&&(ut=Zt.ascender!==void 0&&Zt.descender!==void 0,!ut))break}if(!ut)break}let ct=0;for(let dt of be){dt.trim();let it=dt.getMaxScale(),At=(it-1)*oi,Zt={positionedGlyphs:[],lineOffset:0};Q.positionedLines[ct]=Zt;let Ot=Zt.positionedGlyphs,qt=0;if(!dt.length()){st+=ce,++ct;continue}let si=0,Si=0;for(let Mt=0;Mt<dt.length();Mt++){let Jt=dt.getSection(Mt),dr=dt.getSectionIndex(Mt),ni=dt.getCharCode(Mt),gt=Jt.scale,Qt=null,Ct=null,ci=null,Xt=oi,hi=0,_i=!(fe===Yi.horizontal||!De&&!de(ni)||De&&(yc[ni]||(Gt=ni,i(Gt)||o(Gt)||h(Gt)||X(Gt)||xe(Gt))));if(Jt.imageName){let gi=Se[Jt.imageName];if(!gi)continue;ci=Jt.imageName,Q.iconsInText=Q.iconsInText||!0,Ct=gi.paddedRect;let ei=gi.displaySize;gt=gt*oi/rt,Qt={width:ei[0],height:ei[1],left:1,top:-3,advance:_i?ei[1]:ei[0],localGlyph:!1},hi=ut?-Qt.height*gt:it*oi-17-ei[1]*gt,Xt=Qt.advance;let Mr=(_i?ei[0]:ei[1])*gt-oi*it;Mr>0&&Mr>qt&&(qt=Mr)}else{let gi=le[Jt.fontStack];if(!gi)continue;gi[ni]&&(Ct=gi[ni]);let ei=he[Jt.fontStack];if(!ei)continue;let Mr=ei.glyphs[ni];if(!Mr)continue;if(Qt=Mr.metrics,Xt=ni!==8203?oi:0,ut){let ha=ei.ascender!==void 0?Math.abs(ei.ascender):0,cl=ei.descender!==void 0?Math.abs(ei.descender):0,hl=(ha+cl)*gt;si<hl&&(si=hl,Si=(ha-cl)/2*gt),hi=-ha*gt}else hi=(it-gt)*oi-17}_i?(Q.verticalizable=!0,Ot.push({glyph:ni,imageName:ci,x:bt,y:st+hi,vertical:_i,scale:gt,localGlyph:Qt.localGlyph,fontStack:Jt.fontStack,sectionIndex:dr,metrics:Qt,rect:Ct}),bt+=Xt*gt+ze):(Ot.push({glyph:ni,imageName:ci,x:bt,y:st+hi,vertical:_i,scale:gt,localGlyph:Qt.localGlyph,fontStack:Jt.fontStack,sectionIndex:dr,metrics:Qt,rect:Ct}),bt+=Qt.advance*gt+ze)}Ot.length!==0&&(at=Math.max(bt-ze,at),ut?md(Ot,ve,qt,Si,ce*it/2):md(Ot,ve,qt,0,ce/2)),bt=0;let Ii=ce*it+qt;Zt.lineOffset=Math.max(qt,At),st+=Ii,++ct}var Gt;let Rt=st,{horizontalAlign:Yt,verticalAlign:li}=Dh(we);(function(dt,it,At,Zt,Ot,qt){let si=(it-At)*Ot,Si=-qt*Zt;for(let Ii of dt)for(let Mt of Ii.positionedGlyphs)Mt.x+=si,Mt.y+=Si})(Q.positionedLines,ve,Yt,li,at,Rt),Q.top+=-li*Rt,Q.bottom=Q.top+Rt,Q.left+=-Yt*at,Q.right=Q.left+at,Q.hasBaseline=ut}(J,e,r,n,U,u,p,m,v,g,b,k),!function(Q){for(let he of Q)if(he.positionedGlyphs.length!==0)return!1;return!0}(Y)&&J}let yc={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Kf={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 ud(t,e,r,n,s,l){if(e.imageName){let u=n[e.imageName];return u?u.displaySize[0]*e.scale*oi/l+s:0}{let u=r[e.fontStack],p=u&&u.glyphs[t];return p?p.metrics.advance*e.scale+s:0}}function dd(t,e,r,n){let s=Math.pow(t-e,2);return n?t<e?s/2:2*s:s+Math.abs(r)*r}function Yf(t,e,r){let n=0;return t===10&&(n-=1e4),r&&(n+=150),t!==40&&t!==65288||(n+=50),e!==41&&e!==65289||(n+=50),n}function pd(t,e,r,n,s,l){let u=null,p=dd(e,r,s,l);for(let m of n){let g=dd(e-m.x,r,s,l)+m.badness;g<=p&&(u=m,p=g)}return{index:t,x:e,priorBreak:u,badness:p}}function fd(t){return t?fd(t.priorBreak).concat(t.index):[]}function Ph(t,e,r,n,s,l,u){if(l!=="point")return[];if(!t)return[];let p=[],m=function(b,I,A,k,D,U){let $=0;for(let H=0;H<b.length();H++){let Y=b.getSection(H);$+=ud(b.getCharCode(H),Y,k,D,I,U)}return $/Math.max(1,Math.ceil($/A))}(t,e,r,n,s,u),g=t.text.indexOf("\u200B")>=0,x=0;for(let b=0;b<t.length();b++){let I=t.getSection(b),A=t.getCharCode(b);if(yc[A]||(x+=ud(A,I,n,s,e,u)),b<t.length()-1){let k=!((v=A)<11904||!(M(v)||E(v)||oe(v)||j(v)||R(v)||d(v)||z(v)||y(v)||q(v)||L(v)||P(v)||ge(v)||w(v)||_(v)||f(v)||B(v)||T(v)||ie(v)||Z(v)||G(v)));(Kf[A]||k||I.imageName)&&p.push(pd(b+1,x,m,p,Yf(A,t.getCharCode(b+1),k&&g),!1))}}var v;return fd(pd(t.length(),x,m,p,0,!0))}function Dh(t){let e=.5,r=.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":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function md(t,e,r,n,s){if(!(e||r||n||s))return;let l=t.length-1,u=t[l],p=(u.x+u.metrics.advance*u.scale)*e;for(let m=0;m<=l;m++)t[m].x-=p,t[m].y+=r+n+s}function Jf(t,e,r){let{horizontalAlign:n,verticalAlign:s}=Dh(r),l=e[0]-t.displaySize[0]*n,u=e[1]-t.displaySize[1]*s;return{image:t,top:u,bottom:u+t.displaySize[1],left:l,right:l+t.displaySize[0]}}function _d(t,e,r,n,s,l){let u=t.image,p;if(u.content){let D=u.content,U=u.pixelRatio||1;p=[D[0]/U,D[1]/U,u.displaySize[0]-D[2]/U,u.displaySize[1]-D[3]/U]}let m=e.left*l,g=e.right*l,x,v,b,I;r==="width"||r==="both"?(I=s[0]+m-n[3],v=s[0]+g+n[1]):(I=s[0]+(m+g-u.displaySize[0])/2,v=I+u.displaySize[0]);let A=e.top*l,k=e.bottom*l;return r==="height"||r==="both"?(x=s[1]+A-n[0],b=s[1]+k+n[2]):(x=s[1]+(A+k-u.displaySize[1])/2,b=x+u.displaySize[1]),{image:u,top:x,right:v,bottom:b,left:I,collisionPadding:p}}class _n extends Ce{constructor(e,r,n,s,l){super(e,r),this.angle=s,this.z=n,l!==void 0&&(this.segment=l)}clone(){return new _n(this.x,this.y,this.z,this.angle,this.segment)}}function gd(t,e,r,n,s){if(e.segment===void 0)return!0;let l=e,u=e.segment+1,p=0;for(;p>-r/2;){if(u--,u<0)return!1;p-=t[u].dist(l),l=t[u]}p+=t[u].dist(t[u+1]),u++;let m=[],g=0;for(;p<r/2;){let x=t[u],v=t[u+1];if(!v)return!1;let b=t[u-1].angleTo(x)-x.angleTo(v);for(b=Math.abs((b+3*Math.PI)%(2*Math.PI)-Math.PI),m.push({distance:p,angleDelta:b}),g+=b;p-m[0].distance>n;)g-=m.shift().angleDelta;if(g>s)return!1;u++,p+=x.dist(v)}return!0}function yd(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function xd(t,e,r){return t?.6*e*r:0}function vd(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Qf(t,e,r,n,s,l){let u=xd(r,s,l),p=vd(r,n)*l,m=0,g=yd(t)/2;for(let x=0;x<t.length-1;x++){let v=t[x],b=t[x+1],I=v.dist(b);if(m+I>g){let A=(g-m)/I,k=pt(v.x,b.x,A),D=pt(v.y,b.y,A),U=new _n(k,D,0,b.angleTo(v),x);return!u||gd(t,U,p,u,e)?U:void 0}m+=I}}function em(t,e,r,n,s,l,u,p,m){let g=xd(n,l,u),x=vd(n,s),v=x*u,b=t[0].x===0||t[0].x===m||t[0].y===0||t[0].y===m;return e-v<e/4&&(e=v+e/4),bd(t,b?e/2*p%e:(x/2+2*l)*u*p%e,e,g,r,v,b,!1,m)}function bd(t,e,r,n,s,l,u,p,m){let g=l/2,x=yd(t),v=0,b=e-r,I=[];for(let A=0;A<t.length-1;A++){let k=t[A],D=t[A+1],U=k.dist(D),$=D.angleTo(k);for(;b+r<v+U;){b+=r;let H=(b-v)/U,Y=pt(k.x,D.x,H),J=pt(k.y,D.y,H);if(Y>=0&&Y<m&&J>=0&&J<m&&b-g>=0&&b+g<=x){let Q=new _n(Y,J,0,$,A);Q._round(),n&&!gd(t,Q,l,n,s)||I.push(Q)}}v+=U}return p||I.length||u||(I=bd(t,v/2,r,n,s,l,u,!0,m)),I}function wd(t,e,r,n,s){let l=[];for(let u=0;u<t.length;u++){let p=t[u],m;for(let g=0;g<p.length-1;g++){let x=p[g],v=p[g+1];x.x<e&&v.x<e||(x.x<e?x=new Ce(e,x.y+(e-x.x)/(v.x-x.x)*(v.y-x.y))._round():v.x<e&&(v=new Ce(e,x.y+(e-x.x)/(v.x-x.x)*(v.y-x.y))._round()),x.y<r&&v.y<r||(x.y<r?x=new Ce(x.x+(r-x.y)/(v.y-x.y)*(v.x-x.x),r)._round():v.y<r&&(v=new Ce(x.x+(r-x.y)/(v.y-x.y)*(v.x-x.x),r)._round()),x.x>=n&&v.x>=n||(x.x>=n?x=new Ce(n,x.y+(n-x.x)/(v.x-x.x)*(v.y-x.y))._round():v.x>=n&&(v=new Ce(n,x.y+(n-x.x)/(v.x-x.x)*(v.y-x.y))._round()),x.y>=s&&v.y>=s||(x.y>=s?x=new Ce(x.x+(s-x.y)/(v.y-x.y)*(v.x-x.x),s)._round():v.y>=s&&(v=new Ce(x.x+(s-x.y)/(v.y-x.y)*(v.x-x.x),s)._round()),m&&x.equals(m[m.length-1])||(m=[x],l.push(m)),m.push(v)))))}}return l}ke("Anchor",_n);let rl=1e20;function Td(t,e,r,n,s,l,u,p,m){for(let g=e;g<e+n;g++)Ed(t,r*l+g,l,s,u,p,m);for(let g=r;g<r+s;g++)Ed(t,g*l+e,1,n,u,p,m)}function Ed(t,e,r,n,s,l,u){l[0]=0,u[0]=-rl,u[1]=rl,s[0]=t[e];for(let p=1,m=0,g=0;p<n;p++){s[p]=t[e+p*r];let x=p*p;do{let v=l[m];g=(s[p]-s[v]+x-v*v)/(p-v)/2}while(g<=u[m]&&--m>-1);m++,l[m]=p,u[m]=g,u[m+1]=rl}for(let p=0,m=0;p<n;p++){for(;u[m+1]<p;)m++;let g=l[m],x=p-g;t[e+p*r]=s[g]+x*x}}let Lh={none:0,ideographs:1,all:2};class oa{constructor(e,r,n){this.requestManager=e,this.localGlyphMode=r,this.localFontFamily=n,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,r){let n=[];for(let s in e)for(let l of e[s])n.push({stack:s,id:l});rn(n,({stack:s,id:l},u)=>{let p=this.entries[s];p||(p=this.entries[s]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let m=p.glyphs[l];if(m!==void 0)return void u(null,{stack:s,id:l,glyph:m});if(m=this._tinySDF(p,s,l),m)return p.glyphs[l]=m,void u(null,{stack:s,id:l,glyph:m});let g=Math.floor(l/256);if(256*g>65535)return void u(new Error("glyphs > 65535 not supported"));if(p.ranges[g])return void u(null,{stack:s,id:l,glyph:m});let x=p.requests[g];x||(x=p.requests[g]=[],oa.loadGlyphRange(s,g,this.url,this.requestManager,(v,b)=>{if(b){p.ascender=b.ascender,p.descender=b.descender;for(let I in b.glyphs)this._doesCharSupportLocalGlyph(+I)||(p.glyphs[+I]=b.glyphs[+I]);p.ranges[g]=!0}for(let I of x)I(v,b);delete p.requests[g]})),x.push((v,b)=>{v?u(v):b&&u(null,{stack:s,id:l,glyph:b.glyphs[l]||null})})},(s,l)=>{if(s)r(s);else if(l){let u={};for(let{stack:p,id:m,glyph:g}of l)u[p]===void 0&&(u[p]={}),u[p].glyphs===void 0&&(u[p].glyphs={}),u[p].glyphs[m]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics},u[p].ascender=this.entries[p].ascender,u[p].descender=this.entries[p].descender;r(null,u)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Lh.none&&(this.localGlyphMode===Lh.all?!!this.localFontFamily:!!this.localFontFamily&&(L(e)||N(e)||w(e)||T(e))||y(e))}_tinySDF(e,r,n){let s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let l=e.tinySDF;if(!l){let k="400";/bold/i.test(r)?k="900":/medium/i.test(r)?k="500":/light/i.test(r)&&(k="200"),l=e.tinySDF=new oa.TinySDF({fontFamily:s,fontWeight:k,fontSize:48,buffer:6,radius:16}),l.fontWeight=k}if(this.localGlyphs[l.fontWeight][n])return this.localGlyphs[l.fontWeight][n];let u=String.fromCharCode(n),{data:p,width:m,height:g,glyphWidth:x,glyphHeight:v,glyphLeft:b,glyphTop:I,glyphAdvance:A}=l.draw(u);return this.localGlyphs[l.fontWeight][n]={id:n,bitmap:new Yn({width:m,height:g},p),metrics:{width:x/2,height:v/2,left:b/2,top:I/2-27,advance:A/2,localGlyph:!0}}}}function Sd(t,e,r,n){let s=[],l=t.image,u=l.pixelRatio,p=l.paddedRect.w-2,m=l.paddedRect.h-2,g=t.right-t.left,x=t.bottom-t.top,v=l.stretchX||[[0,p]],b=l.stretchY||[[0,m]],I=(ce,we)=>ce+we[1]-we[0],A=v.reduce(I,0),k=b.reduce(I,0),D=p-A,U=m-k,$=0,H=A,Y=0,J=k,Q=0,he=D,le=0,Se=U;if(l.content&&n){let ce=l.content;$=xc(v,0,ce[0]),Y=xc(b,0,ce[1]),H=xc(v,ce[0],ce[2]),J=xc(b,ce[1],ce[3]),Q=ce[0]-$,le=ce[1]-Y,he=ce[2]-ce[0]-H,Se=ce[3]-ce[1]-J}let be=(ce,we,Ie,fe)=>{let ze=vc(ce.stretch-$,H,g,t.left),De=bc(ce.fixed-Q,he,ce.stretch,A),rt=vc(we.stretch-Y,J,x,t.top),bt=bc(we.fixed-le,Se,we.stretch,k),st=vc(Ie.stretch-$,H,g,t.left),at=bc(Ie.fixed-Q,he,Ie.stretch,A),ve=vc(fe.stretch-Y,J,x,t.top),ut=bc(fe.fixed-le,Se,fe.stretch,k),ct=new Ce(ze,rt),Gt=new Ce(st,rt),Rt=new Ce(st,ve),Yt=new Ce(ze,ve),li=new Ce(De/u,bt/u),dt=new Ce(at/u,ut/u),it=e*Math.PI/180;if(it){let Ot=Math.sin(it),qt=Math.cos(it),si=[qt,-Ot,Ot,qt];ct._matMult(si),Gt._matMult(si),Yt._matMult(si),Rt._matMult(si)}let At=ce.stretch+ce.fixed,Zt=we.stretch+we.fixed;return{tl:ct,tr:Gt,bl:Yt,br:Rt,tex:{x:l.paddedRect.x+1+At,y:l.paddedRect.y+1+Zt,w:Ie.stretch+Ie.fixed-At,h:fe.stretch+fe.fixed-Zt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:li,pixelOffsetBR:dt,minFontScaleX:he/u/g,minFontScaleY:Se/u/x,isSDF:r}};if(n&&(l.stretchX||l.stretchY)){let ce=Id(v,D,A),we=Id(b,U,k);for(let Ie=0;Ie<ce.length-1;Ie++){let fe=ce[Ie],ze=ce[Ie+1];for(let De=0;De<we.length-1;De++)s.push(be(fe,we[De],ze,we[De+1]))}}else s.push(be({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:m+1}));return s}function xc(t,e,r){let n=0;for(let s of t)n+=Math.max(e,Math.min(r,s[1]))-Math.max(e,Math.min(r,s[0]));return n}function Id(t,e,r){let n=[{fixed:-1,stretch:0}];for(let[s,l]of t){let u=n[n.length-1];n.push({fixed:s-u.stretch,stretch:u.stretch}),n.push({fixed:s-u.stretch,stretch:u.stretch+(l-s)})}return n.push({fixed:e+1,stretch:r}),n}function vc(t,e,r,n){return t/e*r+n}function bc(t,e,r,n){return t-e*r/n}function tm(t,e,r,n){let s=e+t.positionedLines[n].lineOffset;return n===0?r+s/2:r+(s+(e+t.positionedLines[n-1].lineOffset))/2}oa.loadGlyphRange=function(t,e,r,n,s){let l=256*e,u=l+255,p=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${l}-${u}`),us.Glyphs);bo(p,(m,g)=>{if(m)s(m);else if(g){let x={},v=function(b){return new tl(b).readFields(Xf,{})}(g);for(let b of v.glyphs)x[b.id]=b;s(null,{glyphs:x,ascender:v.ascender,descender:v.descender})}})},oa.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:l="normal",fontStyle:u="normal"}){this.buffer=e,this.cutoff=n,this.radius=r;let p=this.size=t+4*e,m=this._createCanvas(p),g=this.ctx=m.getContext("2d",{willReadFrequently:!0});g.font=`${u} ${l} ${t}px ${s}`,g.textBaseline="alphabetic",g.textAlign="left",g.fillStyle="black",this.gridOuter=new Float64Array(p*p),this.gridInner=new Float64Array(p*p),this.f=new Float64Array(p),this.z=new Float64Array(p+1),this.v=new Uint16Array(p)}_createCanvas(t){let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:l}=this.ctx.measureText(t),u=Math.floor(r),p=Math.min(this.size-this.buffer,Math.ceil(l-s)),m=Math.min(this.size-this.buffer,Math.ceil(r)+Math.ceil(n)),g=p+2*this.buffer,x=m+2*this.buffer,v=g*x,b=new Uint8ClampedArray(v),I={data:b,width:g,height:x,glyphWidth:p,glyphHeight:m,glyphTop:u,glyphLeft:0,glyphAdvance:e};if(p===0||m===0)return I;let{ctx:A,buffer:k,gridInner:D,gridOuter:U}=this;A.clearRect(k,k,p,m),A.fillText(t,k,k+u+1);let $=A.getImageData(k,k,p,m);U.fill(rl,0,v),D.fill(0,0,v);for(let H=0;H<m;H++)for(let Y=0;Y<p;Y++){let J=$.data[4*(H*p+Y)+3]/255;if(J===0)continue;let Q=(H+k)*g+Y+k;if(J===1)U[Q]=0,D[Q]=rl;else{let he=.5-J;U[Q]=he>0?he*he:0,D[Q]=he<0?he*he:0}}Td(U,0,0,g,x,g,this.f,this.v,this.z),Td(D,k,k,p,m,g,this.f,this.v,this.z);for(let H=0;H<v;H++){let Y=Math.sqrt(U[H])-Math.sqrt(D[H]);b[H]=Math.round(255-255*(Y/this.radius+this.cutoff))}return I}};class im{constructor(e=[],r=rm){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:r,compare:n}=this,s=r[e];for(;e>0;){let l=e-1>>1,u=r[l];if(n(s,u)>=0)break;r[e]=u,e=l}r[e]=s}_down(e){let{data:r,compare:n}=this,s=this.length>>1,l=r[e];for(;e<s;){let u=1+(e<<1),p=r[u],m=u+1;if(m<this.length&&n(r[m],p)<0&&(u=m,p=r[m]),n(p,l)>=0)break;r[e]=p,e=u}r[e]=l}}function rm(t,e){return t<e?-1:t>e?1:0}function nm(t,e=1,r=!1){let n=1/0,s=1/0,l=-1/0,u=-1/0,p=t[0];for(let I=0;I<p.length;I++){let A=p[I];(!I||A.x<n)&&(n=A.x),(!I||A.y<s)&&(s=A.y),(!I||A.x>l)&&(l=A.x),(!I||A.y>u)&&(u=A.y)}let m=Math.min(l-n,u-s),g=m/2,x=new im([],om);if(m===0)return new Ce(n,s);for(let I=n;I<l;I+=m)for(let A=s;A<u;A+=m)x.push(new sa(I+g,A+g,g,t));let v=function(I){let A=0,k=0,D=0,U=I[0];for(let $=0,H=U.length,Y=H-1;$<H;Y=$++){let J=U[$],Q=U[Y],he=J.x*Q.y-Q.x*J.y;k+=(J.x+Q.x)*he,D+=(J.y+Q.y)*he,A+=3*he}return new sa(k/A,D/A,0,I)}(t),b=x.length;for(;x.length;){let I=x.pop();(I.d>v.d||!v.d)&&(v=I,r&&console.log("found best %d after %d probes",Math.round(1e4*I.d)/1e4,b)),I.max-v.d<=e||(g=I.h/2,x.push(new sa(I.p.x-g,I.p.y-g,g,t)),x.push(new sa(I.p.x+g,I.p.y-g,g,t)),x.push(new sa(I.p.x-g,I.p.y+g,g,t)),x.push(new sa(I.p.x+g,I.p.y+g,g,t)),b+=4)}return r&&(console.log(`num probes: ${b}`),console.log(`best distance: ${v.d}`)),v.p}function om(t,e){return e.max-t.max}function sa(t,e,r,n){this.p=new Ce(t,e),this.h=r,this.d=function(s,l){let u=!1,p=1/0;for(let m=0;m<l.length;m++){let g=l[m];for(let x=0,v=g.length,b=v-1;x<v;b=x++){let I=g[x],A=g[b];I.y>s.y!=A.y>s.y&&s.x<(A.x-I.x)*(s.y-I.y)/(A.y-I.y)+I.x&&(u=!u),p=Math.min(p,Lu(s,I,A))}}return(u?1:-1)*Math.sqrt(p)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}let Bh=Number.POSITIVE_INFINITY,sm=Math.sqrt(2);function Md(t,e){return e[1]!==Bh?function(r,n,s){let l=0,u=0;switch(n=Math.abs(n),s=Math.abs(s),r){case"top-right":case"top-left":case"top":u=s-7;break;case"bottom-right":case"bottom-left":case"bottom":u=7-s}switch(r){case"top-right":case"bottom-right":case"right":l=-n;break;case"top-left":case"bottom-left":case"left":l=n}return[l,u]}(t,e[0],e[1]):function(r,n){let s=0,l=0;n<0&&(n=0);let u=n/sm;switch(r){case"top-right":case"top-left":l=u-7;break;case"bottom-right":case"bottom-left":l=7-u;break;case"bottom":l=7-n;break;case"top":l=n-7}switch(r){case"top-right":case"bottom-right":s=-u;break;case"top-left":case"bottom-left":s=u;break;case"left":s=n;break;case"right":s=-n}return[s,l]}(t,e[0])}function am(t,e,r,n,s,l,u,p,m,g){t.createArrays(),t.tilePixelRatio=Qe/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;let x=t.layers[0].layout,v=t.layers[0]._unevaluatedLayout._values,b={};if(t.textSizeData.kind==="composite"){let{minZoom:k,maxZoom:D}=t.textSizeData;b.compositeTextSizes=[v["text-size"].possiblyEvaluate(new Ze(k),p),v["text-size"].possiblyEvaluate(new Ze(D),p)]}if(t.iconSizeData.kind==="composite"){let{minZoom:k,maxZoom:D}=t.iconSizeData;b.compositeIconSizes=[v["icon-size"].possiblyEvaluate(new Ze(k),p),v["icon-size"].possiblyEvaluate(new Ze(D),p)]}b.layoutTextSize=v["text-size"].possiblyEvaluate(new Ze(m+1),p),b.layoutIconSize=v["icon-size"].possiblyEvaluate(new Ze(m+1),p),b.textMaxSize=v["text-size"].possiblyEvaluate(new Ze(18),p);let I=x.get("text-rotation-alignment")==="map"&&x.get("symbol-placement")!=="point",A=x.get("text-size");for(let k of t.features){let D=x.get("text-font").evaluate(k,{},p).join(","),U=A.evaluate(k,{},p),$=b.layoutTextSize.evaluate(k,{},p),H=(b.layoutIconSize.evaluate(k,{},p),{horizontal:{},vertical:void 0}),Y=k.text,J,Q=[0,0];if(Y){let Se=Y.toString(),be=x.get("text-letter-spacing").evaluate(k,{},p)*oi,ce=x.get("text-line-height").evaluate(k,{},p)*oi,we=ne(Se)?be:0,Ie=x.get("text-anchor").evaluate(k,{},p),fe=x.get("text-variable-anchor");if(!fe){let at=x.get("text-radial-offset").evaluate(k,{},p);Q=at?Md(Ie,[at*oi,Bh]):x.get("text-offset").evaluate(k,{},p).map(ve=>ve*oi)}let ze=I?"center":x.get("text-justify").evaluate(k,{},p),De=x.get("symbol-placement"),rt=De==="point",bt=De==="point"?x.get("text-max-width").evaluate(k,{},p)*oi:0,st=at=>{t.allowVerticalPlacement&&ae(Se)&&(H.vertical=kh(Y,e,r,s,D,bt,ce,Ie,at,we,Q,Yi.vertical,!0,De,$,U))};if(!I&&fe){let at=ze==="auto"?fe.map(ut=>Rh(ut)):[ze],ve=!1;for(let ut=0;ut<at.length;ut++){let ct=at[ut];if(!H.horizontal[ct])if(ve)H.horizontal[ct]=H.horizontal[0];else{let Gt=kh(Y,e,r,s,D,bt,ce,"center",ct,we,Q,Yi.horizontal,!1,De,$,U);Gt&&(H.horizontal[ct]=Gt,ve=Gt.positionedLines.length===1)}}st("left")}else{if(ze==="auto"&&(ze=Rh(Ie)),rt||x.get("text-writing-mode").indexOf("horizontal")>=0||!ae(Se)){let at=kh(Y,e,r,s,D,bt,ce,Ie,ze,we,Q,Yi.horizontal,!1,De,$,U);at&&(H.horizontal[ze]=at)}st(De==="point"?"left":ze)}}let he=!1;if(k.icon&&k.icon.name){let Se=n[k.icon.name];Se&&(J=Jf(s[k.icon.name],x.get("icon-offset").evaluate(k,{},p),x.get("icon-anchor").evaluate(k,{},p)),he=Se.sdf,t.sdfIcons===void 0?t.sdfIcons=Se.sdf:t.sdfIcons!==Se.sdf&&zt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Se.pixelRatio!==t.pixelRatio||x.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}let le=Cd(H.horizontal)||H.vertical;t.iconsInText||(t.iconsInText=!!le&&le.iconsInText),(le||J)&&lm(t,k,H,J,n,b,$,0,Q,he,u,p,g)}l&&t.generateCollisionDebugBuffers(m,t.collisionBoxArray)}function Rh(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 lm(t,e,r,n,s,l,u,p,m,g,x,v,b){let I=l.textMaxSize.evaluate(e,{},v);I===void 0&&(I=u);let A=t.layers[0].layout,k=A.get("icon-offset").evaluate(e,{},v),D=Cd(r.horizontal)||r.vertical,U=u/24,$=t.tilePixelRatio*I/24,H=t.tilePixelRatio*A.get("symbol-spacing"),Y=A.get("text-padding")*t.tilePixelRatio,J=A.get("icon-padding")*t.tilePixelRatio,Q=Je(A.get("text-max-angle")),he=A.get("text-rotation-alignment")==="map"&&A.get("symbol-placement")!=="point",le=A.get("icon-rotation-alignment")==="map"&&A.get("symbol-placement")!=="point",Se=A.get("symbol-placement"),be=H/2,ce=A.get("icon-text-fit"),we;n&&ce!=="none"&&(t.allowVerticalPlacement&&r.vertical&&(we=_d(n,r.vertical,ce,A.get("icon-text-fit-padding"),k,U)),D&&(n=_d(n,D,ce,A.get("icon-text-fit-padding"),k,U)));let Ie=(fe,ze,De)=>{if(ze.x<0||ze.x>=Qe||ze.y<0||ze.y>=Qe)return;let{x:rt,y:bt,z:st}=b.projectTilePoint(ze.x,ze.y,De),at=new _n(rt,bt,st,0,void 0);(function(ve,ut,ct,Gt,Rt,Yt,li,dt,it,At,Zt,Ot,qt,si,Si,Ii,Mt,Jt,dr,ni,gt,Qt,Ct,ci,Xt){let hi=ve.addToLineVertexArray(ut,Gt),_i,gi,ei,Mr,ha,cl,hl,hp=0,up=0,dp=0,pp=0,tu=-1,iu=-1,Kr={},fp=qa(""),ru=0,nu=0;if(it._unevaluatedLayout.getValue("text-radial-offset")===void 0?[ru,nu]=it.layout.get("text-offset").evaluate(gt,{},Xt).map(Vi=>Vi*oi):(ru=it.layout.get("text-radial-offset").evaluate(gt,{},Xt)*oi,nu=Bh),ve.allowVerticalPlacement&&Rt.vertical){let Vi=Rt.vertical;if(Si)cl=Fh(Vi),dt&&(hl=Fh(dt));else{let Ni=it.layout.get("text-rotate").evaluate(gt,{},Xt)+90;ei=wc(At,ct,ut,Zt,Ot,qt,Vi,si,Ni,Ii),dt&&(Mr=wc(At,ct,ut,Zt,Ot,qt,dt,Jt,Ni))}}if(Yt){let Vi=it.layout.get("icon-rotate").evaluate(gt,{},Xt),Ni=it.layout.get("icon-text-fit")!=="none",ul=Sd(Yt,Vi,Ct,Ni),su=dt?Sd(dt,Vi,Ct,Ni):void 0;gi=wc(At,ct,ut,Zt,Ot,qt,Yt,Jt,Vi),hp=4*ul.length;let mp=ve.iconSizeData,ts=null;mp.kind==="source"?(ts=[qr*it.layout.get("icon-size").evaluate(gt,{},Xt)],ts[0]>Qn&&zt(`${ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):mp.kind==="composite"&&(ts=[qr*Qt.compositeIconSizes[0].evaluate(gt,{},Xt),qr*Qt.compositeIconSizes[1].evaluate(gt,{},Xt)],(ts[0]>Qn||ts[1]>Qn)&&zt(`${ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),ve.addSymbols(ve.icon,ul,ts,ni,dr,gt,!1,ct,ut,hi.lineStartIndex,hi.lineLength,-1,ci,Xt),tu=ve.icon.placedSymbolArray.length-1,su&&(up=4*su.length,ve.addSymbols(ve.icon,su,ts,ni,dr,gt,Yi.vertical,ct,ut,hi.lineStartIndex,hi.lineLength,-1,ci,Xt),iu=ve.icon.placedSymbolArray.length-1)}for(let Vi in Rt.horizontal){let Ni=Rt.horizontal[Vi];_i||(fp=qa(Ni.text),Si?ha=Fh(Ni):_i=wc(At,ct,ut,Zt,Ot,qt,Ni,si,it.layout.get("text-rotate").evaluate(gt,{},Xt),Ii));let ul=Ni.positionedLines.length===1;if(dp+=Ad(ve,ct,ut,Ni,li,it,Si,gt,Ii,hi,Rt.vertical?Yi.horizontal:Yi.horizontalOnly,ul?Object.keys(Rt.horizontal):[Vi],Kr,tu,Qt,ci,Xt),ul)break}Rt.vertical&&(pp+=Ad(ve,ct,ut,Rt.vertical,li,it,Si,gt,Ii,hi,Yi.vertical,["vertical"],Kr,iu,Qt,ci,Xt));let no=-1,ou=(Vi,Ni)=>Vi?Math.max(Vi,Ni):Ni;no=ou(ha,no),no=ou(cl,no),no=ou(hl,no);let Fm=no>-1?1:0;ve.glyphOffsetArray.length>=eo.MAX_GLYPHS&&zt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),gt.sortKey!==void 0&&ve.addToSortKeyRanges(ve.symbolInstances.length,gt.sortKey),ve.symbolInstances.emplaceBack(ct.x,ct.y,ct.z,ut.x,ut.y,Kr.right>=0?Kr.right:-1,Kr.center>=0?Kr.center:-1,Kr.left>=0?Kr.left:-1,Kr.vertical>=0?Kr.vertical:-1,tu,iu,fp,_i!==void 0?_i:ve.collisionBoxArray.length,_i!==void 0?_i+1:ve.collisionBoxArray.length,ei!==void 0?ei:ve.collisionBoxArray.length,ei!==void 0?ei+1:ve.collisionBoxArray.length,gi!==void 0?gi:ve.collisionBoxArray.length,gi!==void 0?gi+1:ve.collisionBoxArray.length,Mr||ve.collisionBoxArray.length,Mr?Mr+1:ve.collisionBoxArray.length,Zt,dp,pp,hp,up,Fm,0,ru,nu,no)})(t,ze,at,fe,r,n,s,we,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,Y,he,m,0,J,le,k,e,l,g,x,v)};if(Se==="line")for(let fe of wd(e.geometry,0,0,Qe,Qe)){let ze=em(fe,H,Q,r.vertical||D,n,24,$,t.overscaling,Qe);for(let De of ze){let rt=D;rt&&cm(t,rt.text,be,De)||Ie(fe,De,v)}}else if(Se==="line-center"){for(let fe of e.geometry)if(fe.length>1){let ze=Qf(fe,Q,r.vertical||D,n,24,$);ze&&Ie(fe,ze,v)}}else if(e.type==="Polygon")for(let fe of Th(e.geometry,0)){let ze=nm(fe,16);Ie(fe[0],new _n(ze.x,ze.y,0,0,void 0),v)}else if(e.type==="LineString")for(let fe of e.geometry)Ie(fe,new _n(fe[0].x,fe[0].y,0,0,void 0),v);else if(e.type==="Point")for(let fe of e.geometry)for(let ze of fe)Ie([ze],new _n(ze.x,ze.y,0,0,void 0),v)}let Qn=32640;function Ad(t,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k,D){let U=function(Y,J,Q,he,le,Se,be,ce){let we=[];if(J.positionedLines.length===0)return we;let Ie=he.layout.get("text-rotate").evaluate(Se,{})*Math.PI/180,fe=function(st){let at=st[0],ve=st[1],ut=at*ve;return ut>0?[at,-ve]:ut<0?[-at,ve]:at===0?[ve,at]:[ve,-at]}(Q),ze=Math.abs(J.top-J.bottom);for(let st of J.positionedLines)ze-=st.lineOffset;let De=J.positionedLines.length,rt=ze/De,bt=J.top-Q[1];for(let st=0;st<De;++st){let at=J.positionedLines[st];bt=tm(J,rt,bt,st);for(let ve of at.positionedGlyphs){if(!ve.rect)continue;let ut=ve.rect||{},ct=4,Gt=!0,Rt=1,Yt=0;if(ve.imageName){let Ct=be[ve.imageName];if(!Ct)continue;if(Ct.sdf){zt("SDF images are not supported in formatted text and will be ignored.");continue}Gt=!1,Rt=Ct.pixelRatio,ct=1/Rt}let li=(le||ce)&&ve.vertical,dt=ve.metrics.advance*ve.scale/2,it=ve.metrics,At=ve.rect;if(At===null)continue;ce&&J.verticalizable&&(Yt=ve.imageName?dt-ve.metrics.width*ve.scale/2:0);let Zt=le?[ve.x+dt,ve.y]:[0,0],Ot=[0,0],qt=[0,0],si=!1;le||(li?(qt=[ve.x+dt+fe[0],ve.y+fe[1]-Yt],si=!0):Ot=[ve.x+dt+Q[0],ve.y+Q[1]-Yt]);let Si=At.w*ve.scale/(Rt*(ve.localGlyph?2:1)),Ii=At.h*ve.scale/(Rt*(ve.localGlyph?2:1)),Mt,Jt,dr,ni;if(li){let Ct=ve.y-bt,ci=new Ce(-dt,dt-Ct),Xt=-Math.PI/2,hi=new Ce(...qt);Mt=new Ce(-dt+Ot[0],Ot[1]),Mt._rotateAround(Xt,ci)._add(hi),Mt.x+=-Ct+dt,Mt.y-=(it.left-ct)*ve.scale;let _i=ve.imageName?it.advance*ve.scale:oi*ve.scale,gi=String.fromCharCode(ve.glyph);Rf(gi)?Mt.x+=(1-ct)*ve.scale:Ff(gi)?Mt.x+=_i-it.height*ve.scale+(-ct-1)*ve.scale:Mt.x+=ve.imageName||it.width+2*ct===At.w&&it.height+2*ct===At.h?(_i-Ii)/2:(_i-(it.height+2*ct)*ve.scale)/2,Jt=new Ce(Mt.x,Mt.y-Si),dr=new Ce(Mt.x+Ii,Mt.y),ni=new Ce(Mt.x+Ii,Mt.y-Si)}else{let Ct=(it.left-ct)*ve.scale-dt+Ot[0],ci=(-it.top-ct)*ve.scale+Ot[1],Xt=Ct+Si,hi=ci+Ii;Mt=new Ce(Ct,ci),Jt=new Ce(Xt,ci),dr=new Ce(Ct,hi),ni=new Ce(Xt,hi)}if(Ie){let Ct;Ct=le?new Ce(0,0):si?new Ce(fe[0],fe[1]):new Ce(Q[0],Q[1]),Mt._rotateAround(Ie,Ct),Jt._rotateAround(Ie,Ct),dr._rotateAround(Ie,Ct),ni._rotateAround(Ie,Ct)}let gt=new Ce(0,0),Qt=new Ce(0,0);we.push({tl:Mt,tr:Jt,bl:dr,br:ni,tex:ut,writingMode:J.writingMode,glyphOffset:Zt,sectionIndex:ve.sectionIndex,isSDF:Gt,pixelOffsetTL:gt,pixelOffsetBR:Qt,minFontScaleX:0,minFontScaleY:0})}}return we}(0,n,m,l,u,p,s,t.allowVerticalPlacement),$=t.textSizeData,H=null;$.kind==="source"?(H=[qr*l.layout.get("text-size").evaluate(p,{},D)],H[0]>Qn&&zt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):$.kind==="composite"&&(H=[qr*A.compositeTextSizes[0].evaluate(p,{},D),qr*A.compositeTextSizes[1].evaluate(p,{},D)],(H[0]>Qn||H[1]>Qn)&&zt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,U,H,m,u,p,x,e,r,g.lineStartIndex,g.lineLength,I,k,D);for(let Y of v)b[Y]=t.text.placedSymbolArray.length-1;return 4*U.length}function Cd(t){for(let e in t)return t[e];return null}function wc(t,e,r,n,s,l,u,p,m,g){let x=u.top,v=u.bottom,b=u.left,I=u.right,A=u.collisionPadding;if(A&&(b-=A[0],x-=A[1],I+=A[2],v+=A[3]),m){let k=new Ce(b,x),D=new Ce(I,x),U=new Ce(b,v),$=new Ce(I,v),H=Je(m),Y=new Ce(0,0);g&&(Y=new Ce(g[0],g[1])),k._rotateAround(H,Y),D._rotateAround(H,Y),U._rotateAround(H,Y),$._rotateAround(H,Y),b=Math.min(k.x,D.x,U.x,$.x),I=Math.max(k.x,D.x,U.x,$.x),x=Math.min(k.y,D.y,U.y,$.y),v=Math.max(k.y,D.y,U.y,$.y)}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,b,x,I,v,p,n,s,l),t.length-1}function Fh(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);let e=t.bottom-t.top;return e>0?Math.max(10,e):null}function cm(t,e,r,n){let s=t.compareText;if(e in s){let l=s[e];for(let u=l.length-1;u>=0;u--)if(n.dist(l[u])<r)return!0}else s[e]=[];return s[e].push(n),!1}let hm=Yo.VectorTileFeature.types,um=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Tc(t,e,r,n,s,l,u,p,m,g,x,v,b,I,A,k){let D=x?Math.min(Qn,Math.round(x[0])):0,U=x?Math.min(Qn,Math.round(x[1])):0;t.emplaceBack(e,r,Math.round(32*u),Math.round(32*p),m,g,(D<<1)+(v?1:0),U,16*b,16*I,256*A,256*k,n,s,l,0)}function Oh(t,e,r){t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r)}function dm(t){for(let e of t.sections)if(Te(e.text))return!0;return!1}class Uh{constructor(e){this.layoutVertexArray=new Jc,this.indexArray=new Hi,this.programConfigurations=e,this.segments=new Nt,this.dynamicLayoutVertexArray=new Xs,this.opacityVertexArray=new Qc,this.placedSymbolArray=new pu}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,n,s){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cf.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,zf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,um,!0),this.opacityVertexBuffer.itemSize=1),(n||s)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ke("SymbolBuffers",Uh);class Vh{constructor(e,r,n){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new n,this.segments=new Nt,this.collisionVertexArray=new ih,this.collisionVertexArrayExt=new Xs}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,kf.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Pf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ke("CollisionBuffers",Vh);class eo{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ui([]),this.placementViewportMatrix=ui([]);let r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Mh(this.zoom,r["text-size"]),this.iconSizeData=Mh(this.zoom,r["icon-size"]);let n=this.layers[0].layout,s=n.get("symbol-sort-key"),l=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey=l!=="viewport-y"&&s.constantOr(1)!==void 0,this.sortFeaturesByY=(l==="viewport-y"||l==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(u=>Yi[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID}createArrays(){this.text=new Uh(new Wo(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Uh(new Wo(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new _u,this.lineVertexArray=new gu,this.symbolInstances=new mu}calculateGlyphDependencies(e,r,n,s,l){for(let u=0;u<e.length;u++)if(r[e.charCodeAt(u)]=!0,s&&l){let p=el[e.charAt(u)];p&&(r[p.charCodeAt(0)]=!0)}}populate(e,r,n,s){let l=this.layers[0],u=l.layout,p=u.get("text-font"),m=u.get("text-field"),g=u.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof $e&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,b=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;let I=r.iconDependencies,A=r.glyphDependencies,k=r.availableImages,D=new Ze(this.zoom);for(let{feature:U,id:$,index:H,sourceLayerIndex:Y}of e){let J=l._featureFilter.needGeometry,Q=Ko(U,J);if(!l._featureFilter.filter(D,Q,n))continue;let he,le;if(J||(Q.geometry=fn(U,n,s)),x){let be=l.getValueAndResolveTokens("text-field",Q,n,k),ce=$e.factory(be);dm(ce)&&(this.hasRTLText=!0),(!this.hasRTLText||Fi()==="unavailable"||this.hasRTLText&&ot.isParsed())&&(he=Bf(ce,l,Q))}if(v){let be=l.getValueAndResolveTokens("icon-image",Q,n,k);le=be instanceof Li?be:Li.fromString(be)}if(!he&&!le)continue;let Se=this.sortFeaturesByKey?b.evaluate(Q,{},n):void 0;if(this.features.push({id:$,text:he,icon:le,index:H,sourceLayerIndex:Y,geometry:Q.geometry,properties:U.properties,type:hm[U.type],sortKey:Se}),le&&(I[le.name]=!0),he){let be=p.evaluate(Q,{},n).join(","),ce=u.get("text-rotation-alignment")==="map"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Yi.vertical)>=0;for(let we of he.sections)if(we.image)I[we.image.name]=!0;else{let Ie=ae(he.toString()),fe=we.fontStack||be,ze=A[fe]=A[fe]||{};this.calculateGlyphDependencies(we.text,ze,ce,this.allowVerticalPlacement,Ie)}}}u.get("symbol-placement")==="line"&&(this.features=function(U){let $={},H={},Y=[],J=0;function Q(be){Y.push(U[be]),J++}function he(be,ce,we){let Ie=H[be];return delete H[be],H[ce]=Ie,Y[Ie].geometry[0].pop(),Y[Ie].geometry[0]=Y[Ie].geometry[0].concat(we[0]),Ie}function le(be,ce,we){let Ie=$[ce];return delete $[ce],$[be]=Ie,Y[Ie].geometry[0].shift(),Y[Ie].geometry[0]=we[0].concat(Y[Ie].geometry[0]),Ie}function Se(be,ce,we){let Ie=we?ce[0][ce[0].length-1]:ce[0][0];return`${be}:${Ie.x}:${Ie.y}`}for(let be=0;be<U.length;be++){let ce=U[be],we=ce.geometry,Ie=ce.text?ce.text.toString():null;if(!Ie){Q(be);continue}let fe=Se(Ie,we),ze=Se(Ie,we,!0);if(fe in H&&ze in $&&H[fe]!==$[ze]){let De=le(fe,ze,we),rt=he(fe,ze,Y[De].geometry);delete $[fe],delete H[ze],H[Se(Ie,Y[rt].geometry,!0)]=rt,Y[De].geometry=null}else fe in H?he(fe,ze,we):ze in $?le(fe,ze,we):(Q(be),$[fe]=J-1,H[ze]=J-1)}return Y.filter(be=>be.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((U,$)=>U.sortKey-$.sortKey)}update(e,r,n,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,n,s),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,n,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){let n=this.lineVertexArray.length;if(e.segment!==void 0){let s=e.dist(r[e.segment+1]),l=e.dist(r[e.segment]),u={};for(let p=e.segment+1;p<r.length;p++)u[p]={x:r[p].x,y:r[p].y,tileUnitDistanceFromAnchor:s},p<r.length-1&&(s+=r[p+1].dist(r[p]));for(let p=e.segment||0;p>=0;p--)u[p]={x:r[p].x,y:r[p].y,tileUnitDistanceFromAnchor:l},p>0&&(l+=r[p-1].dist(r[p]));for(let p=0;p<r.length;p++){let m=u[p];this.lineVertexArray.emplaceBack(m.x,m.y,m.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,r,n,s,l,u,p,m,g,x,v,b,I,A){let k=e.indexArray,D=e.layoutVertexArray,U=e.segments.prepareSegment(4*r.length,D,k,this.canOverlap?u.sortKey:void 0),$=this.glyphOffsetArray.length,H=U.vertexLength,Y=this.allowVerticalPlacement&&p===Yi.vertical?Math.PI/2:0,J=u.text&&u.text.sections;for(let Q=0;Q<r.length;Q++){let{tl:he,tr:le,bl:Se,br:be,tex:ce,pixelOffsetTL:we,pixelOffsetBR:Ie,minFontScaleX:fe,minFontScaleY:ze,glyphOffset:De,isSDF:rt,sectionIndex:bt}=r[Q],st=U.vertexLength,at=De[1];Tc(D,m.x,m.y,m.z,g.x,g.y,he.x,at+he.y,ce.x,ce.y,n,rt,we.x,we.y,fe,ze),Tc(D,m.x,m.y,m.z,g.x,g.y,le.x,at+le.y,ce.x+ce.w,ce.y,n,rt,Ie.x,we.y,fe,ze),Tc(D,m.x,m.y,m.z,g.x,g.y,Se.x,at+Se.y,ce.x,ce.y+ce.h,n,rt,we.x,Ie.y,fe,ze),Tc(D,m.x,m.y,m.z,g.x,g.y,be.x,at+be.y,ce.x+ce.w,ce.y+ce.h,n,rt,Ie.x,Ie.y,fe,ze),Oh(e.dynamicLayoutVertexArray,m,Y),k.emplaceBack(st,st+1,st+2),k.emplaceBack(st+1,st+2,st+3),U.vertexLength+=4,U.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(De[0]),Q!==r.length-1&&bt===r[Q+1].sectionIndex||e.programConfigurations.populatePaintArrays(D.length,u,u.index,{},I,A,J&&J[bt])}e.placedSymbolArray.emplaceBack(m.x,m.y,m.z,g.x,g.y,$,this.glyphOffsetArray.length-$,H,x,v,g.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],p,0,!1,0,b,0)}_commitLayoutVertex(e,r,n,s,l,u,p){e.emplaceBack(r,n,s,l,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,r,n,s,l,u,p){let m=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),g=m.vertexLength,x=p.tileAnchorX,v=p.tileAnchorY;for(let I=0;I<4;I++)n.collisionVertexArray.emplaceBack(0,0,0,0);n.collisionVertexArrayExt.emplaceBack(r,-e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(r,e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(r,e.padding,e.padding),n.collisionVertexArrayExt.emplaceBack(r,-e.padding,e.padding),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,x,v,new Ce(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,x,v,new Ce(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,x,v,new Ce(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,x,v,new Ce(e.x1,e.y2)),m.vertexLength+=4;let b=n.indexArray;b.emplaceBack(g,g+1),b.emplaceBack(g+1,g+2),b.emplaceBack(g+2,g+3),b.emplaceBack(g+3,g),m.primitiveLength+=4}_addTextDebugCollisionBoxes(e,r,n,s,l,u){for(let p=s;p<l;p++){let m=n.get(p),g=this.getSymbolInstanceTextSize(e,u,r,p);this._addCollisionDebugVertices(m,g,this.textCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,r,n,s,l,u){for(let p=s;p<l;p++){let m=n.get(p),g=this.getSymbolInstanceIconSize(e,r,p);this._addCollisionDebugVertices(m,g,this.iconCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Vh(Jl,rd.members,Hn),this.iconCollisionBox=new Vh(Jl,rd.members,Hn);let n=ta(this.iconSizeData,e),s=ta(this.textSizeData,e);for(let l=0;l<this.symbolInstances.length;l++){let u=this.symbolInstances.get(l);this._addTextDebugCollisionBoxes(s,e,r,u.textBoxStartIndex,u.textBoxEndIndex,u),this._addTextDebugCollisionBoxes(s,e,r,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,r,u.iconBoxStartIndex,u.iconBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,r,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u)}}getSymbolInstanceTextSize(e,r,n,s){let l=this.text.placedSymbolArray.get(r.rightJustifiedTextSymbolIndex>=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:s),u=_c(this.textSizeData,e,l)/oi;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,r,n){let s=this.icon.placedSymbolArray.get(n),l=_c(this.iconSizeData,e,s);return this.tilePixelRatio*l}_commitDebugCollisionVertexUpdate(e,r,n){e.emplaceBack(r,-n,-n),e.emplaceBack(r,n,-n),e.emplaceBack(r,n,n),e.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(e,r,n,s,l,u){for(let p=s;p<l;p++){let m=n.get(p),g=this.getSymbolInstanceTextSize(e,u,r,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,g,m.padding)}}_updateIconDebugCollisionBoxes(e,r,n,s,l){for(let u=s;u<l;u++){let p=n.get(u),m=this.getSymbolInstanceIconSize(e,r,u);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,m,p.padding)}}updateCollisionDebugBuffers(e,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let n=ta(this.iconSizeData,e),s=ta(this.textSizeData,e);for(let l=0;l<this.symbolInstances.length;l++){let u=this.symbolInstances.get(l);this._updateTextDebugCollisionBoxes(s,e,r,u.textBoxStartIndex,u.textBoxEndIndex,u),this._updateTextDebugCollisionBoxes(s,e,r,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._updateIconDebugCollisionBoxes(n,e,r,u.iconBoxStartIndex,u.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(n,e,r,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,r,n,s,l,u,p,m,g){let x={};for(let v=r;v<n;v++){let b=e.get(v);x.textBox={x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,padding:b.padding,projectedAnchorX:b.projectedAnchorX,projectedAnchorY:b.projectedAnchorY,projectedAnchorZ:b.projectedAnchorZ,tileAnchorX:b.tileAnchorX,tileAnchorY:b.tileAnchorY},x.textFeatureIndex=b.featureIndex;break}for(let v=s;v<l;v++){let b=e.get(v);x.verticalTextBox={x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,padding:b.padding,projectedAnchorX:b.projectedAnchorX,projectedAnchorY:b.projectedAnchorY,projectedAnchorZ:b.projectedAnchorZ,tileAnchorX:b.tileAnchorX,tileAnchorY:b.tileAnchorY},x.verticalTextFeatureIndex=b.featureIndex;break}for(let v=u;v<p;v++){let b=e.get(v);x.iconBox={x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,padding:b.padding,projectedAnchorX:b.projectedAnchorX,projectedAnchorY:b.projectedAnchorY,projectedAnchorZ:b.projectedAnchorZ,tileAnchorX:b.tileAnchorX,tileAnchorY:b.tileAnchorY},x.iconFeatureIndex=b.featureIndex;break}for(let v=m;v<g;v++){let b=e.get(v);x.verticalIconBox={x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,padding:b.padding,projectedAnchorX:b.projectedAnchorX,projectedAnchorY:b.projectedAnchorY,projectedAnchorZ:b.projectedAnchorZ,tileAnchorX:b.tileAnchorX,tileAnchorY:b.tileAnchorY},x.verticalIconFeatureIndex=b.featureIndex;break}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){let n=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){let n=e.placedSymbolArray.get(r),s=n.vertexStartIndex+4*n.numGlyphs;for(let l=n.vertexStartIndex;l<s;l+=4)e.indexArray.emplaceBack(l,l+1,l+2),e.indexArray.emplaceBack(l+1,l+2,l+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let r=Math.sin(e),n=Math.cos(e),s=[],l=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);let m=this.symbolInstances.get(p);s.push(0|Math.round(r*m.tileAnchorX+n*m.tileAnchorY)),l.push(m.featureIndex)}return u.sort((p,m)=>s[p]-s[m]||l[m]-l[p]),u}addToSortKeyRanges(e,r){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let r of this.symbolInstanceIndexes){let n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((s,l,u)=>{s>=0&&u.indexOf(s)===l&&this.addIndicesForPlacedSymbol(this.text,s)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ke("SymbolBucket",eo,{omit:["layers","collisionBoxArray","features","compareText"]}),eo.MAX_GLYPHS=65535,eo.addDynamicAttributes=Oh;let pm=new ri({"symbol-placement":new Pe(se.layout_symbol["symbol-placement"]),"symbol-spacing":new Pe(se.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Pe(se.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fe(se.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Pe(se.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Pe(se.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Pe(se.layout_symbol["icon-ignore-placement"]),"icon-optional":new Pe(se.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Pe(se.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fe(se.layout_symbol["icon-size"]),"icon-text-fit":new Pe(se.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Pe(se.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fe(se.layout_symbol["icon-image"]),"icon-rotate":new Fe(se.layout_symbol["icon-rotate"]),"icon-padding":new Pe(se.layout_symbol["icon-padding"]),"icon-keep-upright":new Pe(se.layout_symbol["icon-keep-upright"]),"icon-offset":new Fe(se.layout_symbol["icon-offset"]),"icon-anchor":new Fe(se.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Pe(se.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Pe(se.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Pe(se.layout_symbol["text-rotation-alignment"]),"text-field":new Fe(se.layout_symbol["text-field"]),"text-font":new Fe(se.layout_symbol["text-font"]),"text-size":new Fe(se.layout_symbol["text-size"]),"text-max-width":new Fe(se.layout_symbol["text-max-width"]),"text-line-height":new Fe(se.layout_symbol["text-line-height"]),"text-letter-spacing":new Fe(se.layout_symbol["text-letter-spacing"]),"text-justify":new Fe(se.layout_symbol["text-justify"]),"text-radial-offset":new Fe(se.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Pe(se.layout_symbol["text-variable-anchor"]),"text-anchor":new Fe(se.layout_symbol["text-anchor"]),"text-max-angle":new Pe(se.layout_symbol["text-max-angle"]),"text-writing-mode":new Pe(se.layout_symbol["text-writing-mode"]),"text-rotate":new Fe(se.layout_symbol["text-rotate"]),"text-padding":new Pe(se.layout_symbol["text-padding"]),"text-keep-upright":new Pe(se.layout_symbol["text-keep-upright"]),"text-transform":new Fe(se.layout_symbol["text-transform"]),"text-offset":new Fe(se.layout_symbol["text-offset"]),"text-allow-overlap":new Pe(se.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Pe(se.layout_symbol["text-ignore-placement"]),"text-optional":new Pe(se.layout_symbol["text-optional"])});var Nh={paint:new ri({"icon-opacity":new Fe(se.paint_symbol["icon-opacity"]),"icon-color":new Fe(se.paint_symbol["icon-color"]),"icon-halo-color":new Fe(se.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fe(se.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fe(se.paint_symbol["icon-halo-blur"]),"icon-translate":new Pe(se.paint_symbol["icon-translate"]),"icon-translate-anchor":new Pe(se.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fe(se.paint_symbol["text-opacity"]),"text-color":new Fe(se.paint_symbol["text-color"],{runtimeType:ar,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fe(se.paint_symbol["text-halo-color"]),"text-halo-width":new Fe(se.paint_symbol["text-halo-width"]),"text-halo-blur":new Fe(se.paint_symbol["text-halo-blur"]),"text-translate":new Pe(se.paint_symbol["text-translate"]),"text-translate-anchor":new Pe(se.paint_symbol["text-translate-anchor"])}),layout:pm};class zd{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Rr,this.defaultValue=e}evaluate(e){if(e.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ke("FormatSectionOverride",zd,{omit:["defaultValue"]});class Ec extends Tr{constructor(e){super(e,Nh)}recalculate(e,r){super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));let n=this.layout.get("text-writing-mode");if(n){let s=[];for(let l of n)s.indexOf(l)<0&&s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,r,n,s){let l=this.layout.get(e).evaluate(r,{},n,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||Vn(u.value)||!l?l:function(p,m){return m.replace(/{([^{}]+)}/g,(g,x)=>x in p?String(p[x]):"")}(r.properties,l)}createBucket(e){return new eo(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let e of Nh.paint.overridableProperties){if(!Ec.hasPaintOverride(this.layout,e))continue;let r=this.paint.get(e),n=new zd(r),s=new za(n,r.property.specification),l=null;l=r.value.kind==="constant"||r.value.kind==="source"?new Vo("source",s):new ka("composite",s,r.value.zoomStops,r.value._interpolationType),this.paint._values[e]=new mi(r.property,l,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&Ec.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){let n=e.get("text-field"),s=Nh.paint.properties[r],l=!1,u=p=>{for(let m of p)if(s.overrides&&s.overrides.hasOverride(m))return void(l=!0)};if(n.value.kind==="constant"&&n.value.value instanceof $e)u(n.value.value.sections);else if(n.value.kind==="source"){let p=g=>{l||(g instanceof Or&&Ut(g.value)===Fr?u(g.value.sections):g instanceof lr?u(g.sections):g.eachChild(p))},m=n.value;m._styleExpression&&p(m._styleExpression.expression)}return l}getProgramConfiguration(e){return new dn(this,e)}}var fm={paint:new ri({"background-color":new Pe(se.paint_background["background-color"]),"background-pattern":new cn(se.paint_background["background-pattern"]),"background-opacity":new Pe(se.paint_background["background-opacity"])})},mm={paint:new ri({"raster-opacity":new Pe(se.paint_raster["raster-opacity"]),"raster-hue-rotate":new Pe(se.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Pe(se.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Pe(se.paint_raster["raster-brightness-max"]),"raster-saturation":new Pe(se.paint_raster["raster-saturation"]),"raster-contrast":new Pe(se.paint_raster["raster-contrast"]),"raster-resampling":new Pe(se.paint_raster["raster-resampling"]),"raster-fade-duration":new Pe(se.paint_raster["raster-fade-duration"])})};class _m extends Tr{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var gm={paint:new ri({"sky-type":new Pe(se.paint_sky["sky-type"]),"sky-atmosphere-sun":new Pe(se.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Pe(se.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Pe(se.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Pe(se.paint_sky["sky-gradient-radius"]),"sky-gradient":new Zr(se.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Pe(se.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Pe(se.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Pe(se.paint_sky["sky-opacity"])})};function jh(t,e,r){let n=fr(0,0,1),s=ns(ho());return function(l,u,p){p*=.5;var m=u[0],g=u[1],x=u[2],v=u[3],b=Math.sin(p),I=Math.cos(p);l[0]=m*I-x*b,l[1]=g*I+v*b,l[2]=x*I+m*b,l[3]=v*I-g*b}(s,s,r?-Je(t)+Math.PI:Je(t)),os(s,s,-Je(e)),rs(n,n,s),bn(n,n)}let ym={circle:class extends Tr{constructor(t){super(t,Vp)}createBucket(t){return new ph(t)}queryRadius(t){let e=t;return Js("circle-radius",this,e)+Js("circle-stroke-width",this,e)+lc(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,n,s,l,u,p){let m=Ou(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),g=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return Uu(t,n,l,u,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",m,g)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new dn(this,t)}},heatmap:class extends Tr{createBucket(t){return new Nu(t)}constructor(t){super(t,Zp),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=xh({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(t){return Js("heatmap-radius",this,t)}queryIntersectsFeature(t,e,r,n,s,l,u,p){let m=this.paint.get("heatmap-radius").evaluate(e,r);return Uu(t,n,l,u,p,!0,!0,new Ce(0,0),m)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new dn(this,t)}},hillshade:class extends Tr{constructor(t){super(t,$p)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new dn(this,t)}},fill:class extends Tr{constructor(t){super(t,cf)}getProgramIds(){let t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getProgramConfiguration(t){return new dn(this,t)}recalculate(t,e){super.recalculate(t,e);let r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new fc(t)}queryRadius(){return lc(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,n,s,l){return!t.queryGeometry.isAboveHorizon&&Du(Fu(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends Tr{constructor(t){super(t,vf)}createBucket(t){return new Ih(t)}queryRadius(){return lc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new dn(this,t)}queryIntersectsFeature(t,e,r,n,s,l,u,p,m){let g=Ou(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,r),v=this.paint.get("fill-extrusion-base").evaluate(e,r),b=[0,0],I=p&&l.elevation,A=l.elevation?l.elevation.exaggeration():1;if(I){let U=t.tile.getBucket(this).centroidVertexArray,$=m+1;if($<U.length){let H=U.get($);b[0]=H.a_centroid_pos0,b[1]=H.a_centroid_pos1}}if(b[0]===0&&b[1]===1)return!1;let k=function(U,$,H,Y,J,Q,he,le,Se){return Q?function(be,ce,we,Ie,fe,ze,De,rt,bt){let st=[],at=[],ve=[0,0,0,1];for(let ut of be){let ct=[],Gt=[];for(let Rt of ut){let Yt=Rt.x+Ie.x,li=Rt.y+Ie.y,dt=bf(Yt,li,ce,we,ze,De,rt,bt);ve[0]=Yt,ve[1]=li,ve[2]=dt.base,ve[3]=1,tr(ve,ve,fe),ve[3]=Math.max(ve[3],1e-5);let it=Qu([ve[0]/ve[3],ve[1]/ve[3],ve[2]/ve[3]]);ve[0]=Yt,ve[1]=li,ve[2]=dt.top,ve[3]=1,tr(ve,ve,fe),ve[3]=Math.max(ve[3],1e-5);let At=Qu([ve[0]/ve[3],ve[1]/ve[3],ve[2]/ve[3]]);ct.push(it),Gt.push(At)}st.push(ct),at.push(Gt)}return[st,at]}(U,$,H,Y,J,Q,he,le,Se):function(be,ce,we,Ie,fe){let ze=[],De=[],rt=fe[8]*ce,bt=fe[9]*ce,st=fe[10]*ce,at=fe[11]*ce,ve=fe[8]*we,ut=fe[9]*we,ct=fe[10]*we,Gt=fe[11]*we;for(let Rt of be){let Yt=[],li=[];for(let dt of Rt){let it=dt.x+Ie.x,At=dt.y+Ie.y,Zt=fe[0]*it+fe[4]*At+fe[12],Ot=fe[1]*it+fe[5]*At+fe[13],qt=fe[2]*it+fe[6]*At+fe[14],si=fe[3]*it+fe[7]*At+fe[15],Si=Zt+rt,Ii=Ot+bt,Mt=qt+st,Jt=Math.max(si+at,1e-5),dr=Zt+ve,ni=Ot+ut,gt=qt+ct,Qt=Math.max(si+Gt,1e-5),Ct=new Ce(Si/Jt,Ii/Jt);Ct.z=Mt/Jt,Yt.push(Ct);let ci=new Ce(dr/Qt,ni/Qt);ci.z=gt/Qt,li.push(ci)}ze.push(Yt),De.push(li)}return[ze,De]}(U,$,H,Y,J)}(n,v,x,g,u,I?p:null,b,A,l.center.lat),D=t.queryGeometry;return function(U,$,H){let Y=1/0;Du(H,$)&&(Y=Ju(H,$[0]));for(let J=0;J<$.length;J++){let Q=$[J],he=U[J];for(let le=0;le<Q.length-1;le++){let Se=Q[le],be=[Se,Q[le+1],he[le+1],he[le],Se];Pu(H,be)&&(Y=Math.min(Y,Ju(H,be)))}}return Y!==1/0&&Y}(k[0],k[1],D.isPointQuery()?D.screenBounds:D.screenGeometry)}},line:class extends Tr{constructor(t){super(t,ed),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){let e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof ko,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"]=td.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new mc(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new dn(this,t)}queryRadius(t){let e=t,r=id(Js("line-width",this,e),Js("line-gap-width",this,e)),n=Js("line-offset",this,e);return r/2+Math.abs(n)+lc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,s,l){if(t.queryGeometry.isAboveHorizon)return!1;let u=Fu(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),p=t.pixelToTileUnitsFactor/2*id(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),m=this.paint.get("line-offset").evaluate(e,r);return m&&(n=function(g,x){let v=[],b=new Ce(0,0);for(let I=0;I<g.length;I++){let A=g[I],k=[];for(let D=0;D<A.length;D++){let U=A[D-1],$=A[D],H=A[D+1],Y=D===0?b:$.sub(U)._unit()._perp(),J=D===A.length-1?b:H.sub($)._unit()._perp(),Q=Y._add(J)._unit();Q._mult(1/(Q.x*J.x+Q.y*J.y)),k.push(Q._mult(x)._add($))}v.push(k)}return v}(n,m*t.pixelToTileUnitsFactor)),function(g,x,v){for(let b=0;b<x.length;b++){let I=x[b];if(g.length>=3){for(let A=0;A<I.length;A++)if(Ys(g,I[A]))return!0}if(Rp(g,I,v))return!0}return!1}(u,n,p)}isTileClipped(){return!0}},symbol:Ec,background:class extends Tr{constructor(t){super(t,fm)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Tr{constructor(t){super(t,mm)}getProgramIds(){return["raster"]}},sky:class extends Tr{constructor(t){super(t,gm),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="sky-gradient"?this._updateColorRamp():t!=="sky-atmosphere-sun"&&t!=="sky-atmosphere-halo-color"&&t!=="sky-atmosphere-color"&&t!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=xh({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){let e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}}getCenter(t,e){let r=this.paint.get("sky-type");if(r==="atmosphere"){let n=this.paint.get("sky-atmosphere-sun"),s=!n,l=t.style.light,u=l.properties.get("position");return s&&l.properties.get("anchor")==="viewport"&&zt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?jh(u.azimuthal,90-u.polar,e):jh(n[0],90-n[1],e)}if(r==="gradient"){let n=this.paint.get("sky-gradient-center");return jh(n[0],90-n[1],e)}}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let t=this.paint.get("sky-type");return t==="atmosphere"?["skyboxCapture","skybox"]:t==="gradient"?["skyboxGradient"]:null}}},{HTMLImageElement:kd,HTMLCanvasElement:Pd,HTMLVideoElement:Dd,ImageData:Ld,ImageBitmap:Sc}=me;class Ic{constructor(e,r,n,s){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(r,s)}update(e,r,n){let{width:s,height:l}=e,{context:u}=this,{gl:p}=u;if(p.bindTexture(p.TEXTURE_2D,this.texture),u.pixelStoreUnpackFlipY.set(!1),u.pixelStoreUnpack.set(1),u.pixelStoreUnpackPremultiplyAlpha.set(this.format===p.RGBA&&(!r||r.premultiply!==!1)),n||this.size&&this.size[0]===s&&this.size[1]===l){let{x:m,y:g}=n||{x:0,y:0};e instanceof kd||e instanceof Pd||e instanceof Dd||e instanceof Ld||Sc&&e instanceof Sc?p.texSubImage2D(p.TEXTURE_2D,0,m,g,p.RGBA,p.UNSIGNED_BYTE,e):p.texSubImage2D(p.TEXTURE_2D,0,m,g,s,l,p.RGBA,p.UNSIGNED_BYTE,e.data)}else this.size=[s,l],e instanceof kd||e instanceof Pd||e instanceof Dd||e instanceof Ld||Sc&&e instanceof Sc?p.texImage2D(p.TEXTURE_2D,0,this.format,this.format,p.UNSIGNED_BYTE,e):p.texImage2D(p.TEXTURE_2D,0,this.format,s,l,0,this.format,p.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(r&&r.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&p.generateMipmap(p.TEXTURE_2D)}bind(e,r){let{context:n}=this,{gl:s}=n;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_NEAREST:e),this.filter=e),r!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r),this.wrap=r)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Gh{constructor(e,r){this.width=e,this.height=r,this.nextRow=0,this.image=new Yn({width:e,height:r}),this.positions={},this.uploaded=!1}getDash(e,r){let n=this.getKey(e,r);return this.positions[n]}trim(){let e=this.width,r=this.height=zi(this.nextRow);this.image.resize({width:e,height:r})}getKey(e,r){return e.join(",")+r}getDashRanges(e,r,n){let s=[],l=e.length%2==1?-e[e.length-1]*n:0,u=e[0]*n,p=!0;s.push({left:l,right:u,isDash:p,zeroLength:e[0]===0});let m=e[0];for(let g=1;g<e.length;g++){p=!p;let x=e[g];l=m*n,m+=x,u=m*n,s.push({left:l,right:u,isDash:p,zeroLength:x===0})}return s}addRoundDash(e,r,n){let s=r/2;for(let l=-n;l<=n;l++){let u=this.width*(this.nextRow+n+l),p=0,m=e[p];for(let g=0;g<this.width;g++){g/m.right>1&&(m=e[++p]);let x=Math.abs(g-m.left),v=Math.abs(g-m.right),b=Math.min(x,v),I,A=l/n*(s+1);if(m.isDash){let k=s-Math.abs(A);I=Math.sqrt(b*b+k*k)}else I=s-Math.sqrt(b*b+A*A);this.image.data[u+g]=Math.max(0,Math.min(255,I+128))}}}addRegularDash(e,r){for(let m=e.length-1;m>=0;--m){let g=e[m],x=e[m+1];g.zeroLength?e.splice(m,1):x&&x.isDash===g.isDash&&(x.left=g.left,e.splice(m,1))}let n=e[0],s=e[e.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);let l=this.width*this.nextRow,u=0,p=e[u];for(let m=0;m<this.width;m++){m/p.right>1&&(p=e[++u]);let g=Math.abs(m-p.left),x=Math.abs(m-p.right),v=Math.min(g,x);this.image.data[l+m]=Math.max(0,Math.min(255,(p.isDash?v:-v)+r+128))}}addDash(e,r){let n=this.getKey(e,r);if(this.positions[n])return this.positions[n];let s=r==="round",l=s?7:0,u=2*l+1;if(this.nextRow+u>this.height)return zt("LineAtlas out of space"),null;e.length===0&&e.push(1);let p=0;for(let x=0;x<e.length;x++)e[x]<0&&(zt("Negative value is found in line dasharray, replacing values with 0"),e[x]=0),p+=e[x];if(p!==0){let x=this.width/p,v=this.getDashRanges(e,this.width,x);s?this.addRoundDash(v,x,l):this.addRegularDash(v,r==="square"?.5*x:0)}let m=this.nextRow+l;this.nextRow+=u;let g={tl:[m,l],br:[p,0]};return this.positions[n]=g,g}}ke("LineAtlas",Gh);class xm{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}let vm=me.performance;function Bd(t){let e=t?t.url.toString():void 0;return vm.getEntriesByName(e)}class bm{constructor(){this.tasks={},this.taskQueue=[],In(["process"],this),this.invoker=new xm(this.process),this.nextId=0}add(e,r){let n=this.nextId++,s=function({type:l,isSymbolTile:u,zoom:p}){return p=p||0,l==="message"?0:l!=="maybePrepare"||u?l!=="parseTile"||u?l==="parseTile"&&u?300-p:l==="maybePrepare"&&u?400-p:500:200-p:100-p}(r);if(s===0){ir();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:r,priority:s,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){ir();try{if(this.taskQueue=this.taskQueue.filter(n=>!!this.tasks[n]),!this.taskQueue.length)return;let e=this.pick();if(e===null)return;let r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}finally{}}pick(){let e=null,r=1/0;for(let s=0;s<this.taskQueue.length;s++){let l=this.tasks[this.taskQueue[s]];l.priority<r&&(r=l.priority,e=s)}if(e===null)return null;let n=this.taskQueue[e];return this.taskQueue.splice(e,1),n}remove(){this.invoker.remove()}}function Rd(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Mc{constructor(e,r,n){this.z=e,this.x=r,this.y=n,this.key=nl(0,e,e,r,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r){let n=function(l,u,p){var m=Rd(256*l,256*(u=Math.pow(2,p)-u-1),p),g=Rd(256*(l+1),256*(u+1),p);return m[0]+","+m[1]+","+g[0]+","+g[1]}(this.x,this.y,this.z),s=function(l,u,p){let m,g="";for(let x=l;x>0;x--)m=1<<x-1,g+=(u&m?1:0)+(p&m?2:0);return g}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String(r==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Zh{constructor(e,r){this.wrap=e,this.canonical=r,this.key=nl(e,r.z,r.z,r.x,r.y)}}class Ei{constructor(e,r,n,s,l){this.overscaledZ=e,this.wrap=r,this.canonical=new Mc(n,+s,+l),this.key=r===0&&e===n?this.canonical.key:nl(r,e,n,s,l)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){let r=this.canonical.z-e;return e>this.canonical.z?new Ei(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Ei(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r=!0){if(this.overscaledZ===e&&r)return this.key;if(e>this.canonical.z)return nl(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y);{let n=this.canonical.z-e;return nl(this.wrap*+r,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;let r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new Ei(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new Ei(r,this.wrap,r,n,s),new Ei(r,this.wrap,r,n+1,s),new Ei(r,this.wrap,r,n,s+1),new Ei(r,this.wrap,r,n+1,s+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Ei(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Ei(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Zh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function nl(t,e,r,n,s){let l=1<<Math.min(r,22),u=l*(s%l)+n%l;return t&&r<22&&(u+=l*l*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*u+r)+(e-r)}ke("CanonicalTileID",Mc),ke("OverscaledTileID",Ei,{omit:["projMatrix"]});class aa{constructor(e,r,n){this.func=e,this.mask=r,this.range=n}}aa.ReadOnly=!1,aa.ReadWrite=!0,aa.disabled=new aa(519,aa.ReadOnly,[0,1]);let $h=7680;class qh{constructor(e,r,n,s,l,u){this.test=e,this.ref=r,this.mask=n,this.fail=s,this.depthFail=l,this.pass=u}}qh.disabled=new qh({func:519,mask:0},0,0,$h,$h,$h);class Xr{constructor(e,r,n){this.blendFunction=e,this.blendColor=r,this.mask=n}}Xr.Replace=[1,0],Xr.disabled=new Xr(Xr.Replace,lt.transparent,[!1,!1,!1,!1]),Xr.unblended=new Xr(Xr.Replace,lt.transparent,[!0,!0,!0,!0]),Xr.alphaBlended=new Xr([1,771],lt.transparent,[!0,!0,!0,!0]);let Xh=1029,Wh=2305;class Ir{constructor(e,r,n){this.enable=e,this.mode=r,this.frontFace=n}}Ir.disabled=new Ir(!1,Xh,Wh),Ir.backCCW=new Ir(!0,Xh,Wh),Ir.backCW=new Ir(!0,Xh,2304),Ir.frontCW=new Ir(!0,1028,2304),Ir.frontCCW=new Ir(!0,1028,Wh);class Fd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){let n=e[r];this._stringToNumber[n]=r,this._numberToString[r]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class Od{constructor(e,r,n,s,l){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=n,e._y=s,this.properties=e.properties,this.id=l}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class wm{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,n){let s=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][s]=this.stateChanges[e][s]||{},Lt(this.stateChanges[e][s],n),this.deletedStates[e]===null){this.deletedStates[e]={};for(let l in this.state[e])l!==s&&(this.deletedStates[e][l]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][s]===null){this.deletedStates[e][s]={};for(let l in this.state[e][s])n[l]||(this.deletedStates[e][s][l]=null)}else for(let l in n)this.deletedStates[e]&&this.deletedStates[e][s]&&this.deletedStates[e][s][l]===null&&delete this.deletedStates[e][s][l]}removeFeatureState(e,r,n){if(this.deletedStates[e]===null)return;let s=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&r!==void 0)this.deletedStates[e][s]!==null&&(this.deletedStates[e][s]=this.deletedStates[e][s]||{},this.deletedStates[e][s][n]=null);else if(r!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][s])for(n in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][n]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null}getState(e,r){let n=String(r),s=Lt({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let l=this.deletedStates[e][r];if(l===null)return{};for(let u in l)delete s[u]}return s}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){let n={};for(let s in this.stateChanges){this.state[s]=this.state[s]||{};let l={};for(let u in this.stateChanges[s])this.state[s][u]||(this.state[s][u]={}),Lt(this.state[s][u],this.stateChanges[s][u]),l[u]=this.state[s][u];n[s]=l}for(let s in this.deletedStates){this.state[s]=this.state[s]||{};let l={};if(this.deletedStates[s]===null)for(let u in this.state[s])l[u]={},this.state[s][u]={};else for(let u in this.deletedStates[s]){if(this.deletedStates[s][u]===null)this.state[s][u]={};else for(let p of Object.keys(this.deletedStates[s][u]))delete this.state[s][u][p];l[u]=this.state[s][u]}n[s]=n[s]||{},Lt(n[s],l)}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length!==0)for(let s in e)e[s].setFeatureState(n,r)}}class Ud{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,r){let n=this.toIdx(e,r);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,r){return this.leaves[this.toIdx(e,r)]}toIdx(e,r){return r*this.size+e}}function Vd(t,e,r,n){let s=0,l=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(n[u])<1e-15){if(r[u]<t[u]||r[u]>e[u])return null}else{let p=1/n[u],m=(t[u]-r[u])*p,g=(e[u]-r[u])*p;if(m>g){let x=m;m=g,g=x}if(m>s&&(s=m),g<l&&(l=g),s>l)return null}return s}function Nd(t,e,r,n,s,l,u,p,m,g,x){let v=n-t,b=s-e,I=l-r,A=u-t,k=p-e,D=m-r,U=x[1]*D-x[2]*k,$=x[2]*A-x[0]*D,H=x[0]*k-x[1]*A,Y=v*U+b*$+I*H;if(Math.abs(Y)<1e-15)return null;let J=1/Y,Q=g[0]-t,he=g[1]-e,le=g[2]-r,Se=(Q*U+he*$+le*H)*J;if(Se<0||Se>1)return null;let be=he*I-le*b,ce=le*v-Q*I,we=Q*b-he*v,Ie=(x[0]*be+x[1]*ce+x[2]*we)*J;return Ie<0||Se+Ie>1?null:(A*be+k*ce+D*we)*J}function jd(t,e,r){return(t-e)/(r-e)}function Gd(t,e,r,n,s,l,u,p,m){let g=1<<r,x=l-n,v=u-s,b=(t+1)/g*x+n,I=(e+0)/g*v+s,A=(e+1)/g*v+s;p[0]=(t+0)/g*x+n,p[1]=I,m[0]=b,m[1]=A}class Zd{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;let r=function(l){let u=Math.ceil(Math.log2(l.dim/8)),p=[],m=Math.ceil(Math.pow(2,u)),g=1/m,x=(I,A,k,D,U)=>{let $=D?1:0,H=(I+1)*k-$,Y=A*k,J=(A+1)*k-$;U[0]=I*k,U[1]=Y,U[2]=H,U[3]=J},v=new Ud(m),b=[];for(let I=0;I<m*m;I++){x(I%m,Math.floor(I/m),g,!1,b);let A=to(b[0],b[1],l),k=to(b[2],b[1],l),D=to(b[2],b[3],l),U=to(b[0],b[3],l);v.minimums.push(Math.min(A,k,D,U)),v.maximums.push(Math.max(A,k,D,U)),v.leaves.push(1)}for(p.push(v),m/=2;m>=1;m/=2){let I=p[p.length-1];v=new Ud(m);for(let A=0;A<m*m;A++){x(A%m,Math.floor(A/m),2,!0,b);let k=I.getElevation(b[0],b[1]),D=I.getElevation(b[2],b[1]),U=I.getElevation(b[2],b[3]),$=I.getElevation(b[0],b[3]),H=I.isLeaf(b[0],b[1]),Y=I.isLeaf(b[2],b[1]),J=I.isLeaf(b[2],b[3]),Q=I.isLeaf(b[0],b[3]),he=Math.min(k.min,D.min,U.min,$.min),le=Math.max(k.max,D.max,U.max,$.max),Se=H&&Y&&J&&Q;v.maximums.push(le),v.minimums.push(he),v.leaves.push(le-he<=5&&Se?1:0)}p.push(v)}return p}(this.dem),n=r.length-1,s=r[n];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(r,0,0,n,0)}raycastRoot(e,r,n,s,l,u,p=1){return Vd([e,r,-100],[n,s,this.maximums[0]*p],l,u)}raycast(e,r,n,s,l,u,p=1){if(!this.nodeCount)return null;let m=this.raycastRoot(e,r,n,s,l,u,p);if(m==null)return null;let g=[],x=[],v=[],b=[],I=[{idx:0,t:m,nodex:0,nodey:0,depth:0}];for(;I.length>0;){let{idx:A,t:k,nodex:D,nodey:U,depth:$}=I.pop();if(this.leaves[A]){Gd(D,U,$,e,r,n,s,v,b);let Y=1<<$,J=(D+0)/Y,Q=(D+1)/Y,he=(U+0)/Y,le=(U+1)/Y,Se=to(J,he,this.dem)*p,be=to(Q,he,this.dem)*p,ce=to(Q,le,this.dem)*p,we=to(J,le,this.dem)*p,Ie=Nd(v[0],v[1],Se,b[0],v[1],be,b[0],b[1],ce,l,u),fe=Nd(b[0],b[1],ce,v[0],b[1],we,v[0],v[1],Se,l,u),ze=Math.min(Ie!==null?Ie:Number.MAX_VALUE,fe!==null?fe:Number.MAX_VALUE);if(ze!==Number.MAX_VALUE)return ze;{let De=Ci([],l,u,k);if($d(Se,be,we,ce,jd(De[0],v[0],b[0]),jd(De[1],v[1],b[1]))>=De[2])return k}continue}let H=0;for(let Y=0;Y<this._siblingOffset.length;Y++){Gd((D<<1)+this._siblingOffset[Y][0],(U<<1)+this._siblingOffset[Y][1],$+1,e,r,n,s,v,b),v[2]=-100,b[2]=this.maximums[this.childOffsets[A]+Y]*p;let J=Vd(v,b,l,u);if(J!=null){let Q=J;g[Y]=Q;let he=!1;for(let le=0;le<H&&!he;le++)Q>=g[x[le]]&&(x.splice(le,0,Y),he=!0);he||(x[H]=Y),H++}}for(let Y=0;Y<H;Y++){let J=x[Y];I.push({idx:this.childOffsets[A]+J,t:g[J],nodex:(D<<1)+this._siblingOffset[J][0],nodey:(U<<1)+this._siblingOffset[J][1],depth:$+1})}}return null}_addNode(e,r,n){return this.minimums.push(e),this.maximums.push(r),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,r,n,s,l){if(e[s].isLeaf(r,n)===1)return;this.childOffsets[l]||(this.childOffsets[l]=this.nodeCount);let u=s-1,p=e[u],m,g=0;for(let x=0;x<this._siblingOffset.length;x++){let v=2*r+this._siblingOffset[x][0],b=2*n+this._siblingOffset[x][1],I=p.getElevation(v,b),A=p.isLeaf(v,b),k=this._addNode(I.min,I.max,A);A&&(g|=1<<x),m||(m=k)}for(let x=0;x<this._siblingOffset.length;x++)g&1<<x||this._construct(e,2*r+this._siblingOffset[x][0],2*n+this._siblingOffset[x][1],u,m+x)}}function $d(t,e,r,n,s,l){return pt(pt(t,r,l),pt(e,n,l),s)}function to(t,e,r){let n=r.dim,s=mt(t*n-.5,0,n-1),l=mt(e*n-.5,0,n-1),u=Math.floor(s),p=Math.floor(l),m=Math.min(u+1,n-1),g=Math.min(p+1,n-1);return $d(r.get(u,p),r.get(m,p),r.get(u,g),r.get(m,g),s-u,l-p)}let qd={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Ac{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,r,n,s=!1,l=!1){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(n&&n!=="mapbox"&&n!=="terrarium")return zt(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;let u=this.dim=r.height-2;if(this.data=new Uint32Array(r.data.buffer),this.encoding=n||"mapbox",this.borderReady=s,!s){for(let p=0;p<u;p++)this.data[this._idx(-1,p)]=this.data[this._idx(0,p)],this.data[this._idx(u,p)]=this.data[this._idx(u-1,p)],this.data[this._idx(p,-1)]=this.data[this._idx(p,0)],this.data[this._idx(p,u)]=this.data[this._idx(p,u-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(u,-1)]=this.data[this._idx(u-1,0)],this.data[this._idx(-1,u)]=this.data[this._idx(0,u-1)],this.data[this._idx(u,u)]=this.data[this._idx(u-1,u-1)],l&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new Zd(this)}get(e,r,n=!1){let s=new Uint8Array(this.data.buffer);n&&(e=mt(e,-1,this.dim),r=mt(r,-1,this.dim));let l=4*this._idx(e,r);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(s[l],s[l+1],s[l+2])}static getUnpackVector(e){return qd[e]}get unpackVector(){return qd[this.encoding]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}_unpackMapbox(e,r,n){return(256*e*256+256*r+n)/10-1e4}_unpackTerrarium(e,r,n){return 256*e+r+n/256-32768}static pack(e,r){let n=[0,0,0,0],s=Ac.getUnpackVector(r),l=Math.floor((e+s[3])/s[2]);return n[2]=l%256,l=Math.floor(l/256),n[1]=l%256,l=Math.floor(l/256),n[0]=l,n}getPixels(){return new Ki({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=r*this.dim,l=r*this.dim+this.dim,u=n*this.dim,p=n*this.dim+this.dim;switch(r){case-1:s=l-1;break;case 1:l=s+1}switch(n){case-1:u=p-1;break;case 1:p=u+1}let m=-r*this.dim,g=-n*this.dim;for(let x=u;x<p;x++)for(let v=s;v<l;v++)this.data[this._idx(v,x)]=e.data[this._idx(v+m,x+g)]}onDeserialize(){this._tree&&(this._tree.dem=this)}}ke("DEMData",Ac),ke("DemMinMaxQuadTree",Zd,{omit:["dem"]});class Tm{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(let e in this.data)for(let r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,n){let s=e.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);let l={value:r,timeout:void 0};if(n!==void 0&&(l.timeout=setTimeout(()=>{this.remove(e,l)},n)),this.data[s].push(l),this.order.push(s),this.order.length>this.max){let u=this._getAndRemoveByKey(this.order[0]);u&&this.onRemove(u)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){let r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;let n=e.wrapped().key,s=r===void 0?0:this.data[n].indexOf(r),l=this.data[n][s];return this.data[n].splice(s,1),l.timeout&&clearTimeout(l.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(l.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(e){let r=[];for(let n in this.data)for(let s of this.data[n])e(s.value)||r.push(s);for(let n of r)this.remove(n.value.tileID,n)}}class Jo extends Lr{constructor(e,r,n){super(),this.id=e,this._onlySymbols=n,r.on("data",s=>{s.dataType==="source"&&s.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&s.dataType==="source"&&s.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new Tm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new wm}onAdd(e){this.map=e,this._minTileCacheSize=e?e._minTileCacheSize:null,this._maxTileCacheSize=e?e._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(let e in this._tiles){let r=this._tiles[e];if(r.state!=="loaded"&&r.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,r){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,r)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let r in this._tiles){let n=this._tiles[r];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return Sn(this._tiles).map(e=>e.tileID).sort(Xd).map(e=>e.key)}getRenderableIds(e){let r=[];for(let n in this._tiles)this._isIdRenderable(+n,e)&&r.push(this._tiles[n]);return e?r.sort((n,s)=>{let l=n.tileID,u=s.tileID,p=new Ce(l.canonical.x,l.canonical.y)._rotate(this.transform.angle),m=new Ce(u.canonical.x,u.canonical.y)._rotate(this.transform.angle);return l.overscaledZ-u.overscaledZ||m.y-p.y||m.x-p.x}).map(n=>n.tileID.key):r.map(n=>n.tileID).sort(Xd).map(n=>n.key)}hasRenderableParent(e){let r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,r){let n=this._tiles[e];n&&(n.state!=="loading"&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,e,r)))}_tileLoaded(e,r,n,s){if(s)if(e.state="errored",s.status!==404)this._source.fire(new ps(s,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){let l=this.map.painter.terrain;this.update(this.transform,l.getScaledDemTileSize(),!0),l.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=vi.now(),n==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Dr("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){let r=this.getRenderableIds();for(let s=0;s<r.length;s++){let l=r[s];if(e.neighboringTiles&&e.neighboringTiles[l]){let u=this.getTileByID(l);n(e,u),n(u,e)}}function n(s,l){if(!s.dem||s.dem.borderReady)return;s.needsHillshadePrepare=!0,s.needsDEMTextureUpload=!0;let u=l.tileID.canonical.x-s.tileID.canonical.x,p=l.tileID.canonical.y-s.tileID.canonical.y,m=Math.pow(2,s.tileID.canonical.z),g=l.tileID.key;u===0&&p===0||Math.abs(p)>1||(Math.abs(u)>1&&(Math.abs(u+m)===1?u+=m:Math.abs(u-m)===1&&(u-=m)),l.dem&&s.dem&&(s.dem.backfillBorder(l.dem,u,p),s.neighboringTiles&&s.neighboringTiles[g]&&(s.neighboringTiles[g].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,n,s){for(let l in this._tiles){let u=this._tiles[l];if(s[l]||!u.hasData()||u.tileID.overscaledZ<=r||u.tileID.overscaledZ>n)continue;let p=u.tileID;for(;u&&u.tileID.overscaledZ>r+1;){let g=u.tileID.scaledTo(u.tileID.overscaledZ-1);u=this._tiles[g.key],u&&u.hasData()&&(p=g)}let m=p;for(;m.overscaledZ>r;)if(m=m.scaledTo(m.overscaledZ-1),e[m.key]){s[p.key]=p;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){let n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let n=e.overscaledZ-1;n>=r;n--){let s=e.scaledTo(n),l=this._getLoadedTile(s);if(l)return l}}_getLoadedTile(e){let r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,r){r=r||this._source.tileSize;let n=Math.ceil(e.width/r)+1,s=Math.ceil(e.height/r)+1,l=Math.floor(n*s*5),u=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,l):l,p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,u):u;this._cache.setMaxSize(p)}handleWrapJump(e){let r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,r){let n={};for(let s in this._tiles){let l=this._tiles[s];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+r),n[l.tileID.key]=l}this._tiles=n;for(let s in this._timers)clearTimeout(this._timers[s]),delete this._timers[s];for(let s in this._tiles)this._setTileReloadTimer(+s,this._tiles[s])}}update(e,r,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let s;this.updateCacheSize(e,r),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(p=>new Ei(p.canonical.z,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y)):(s=e.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter(p=>this._source.hasTile(p)))):s=[];let l=this._updateRetainedTiles(s);if(Wd(this._source.type)&&s.length!==0){let p={},m={},g=Object.keys(l);for(let v of g){let b=l[v],I=this._tiles[v];if(!I||I.fadeEndTime&&I.fadeEndTime<=vi.now())continue;let A=this.findLoadedParent(b,Math.max(b.overscaledZ-Jo.maxOverzooming,this._source.minzoom));A&&(this._addTile(A.tileID),p[A.tileID.key]=A.tileID),m[v]=b}let x=s[s.length-1].overscaledZ;for(let v in this._tiles){let b=this._tiles[v];if(l[v]||!b.hasData())continue;let I=b.tileID;for(;I.overscaledZ>x;){I=I.scaledTo(I.overscaledZ-1);let A=this._tiles[I.key];if(A&&A.hasData()&&m[I.key]){l[v]=b.tileID;break}}}for(let v in p)l[v]||(this._coveredTiles[v]=!0,l[v]=p[v])}for(let p in l)this._tiles[p].clearFadeHold();let u=function(p,m){let g=[];for(let x in p)x in m||g.push(x);return g}(this._tiles,l);for(let p of u){let m=this._tiles[p];m.hasSymbolBuckets&&!m.holdingForFade()?m.setHoldDuration(this.map._fadeDuration):m.hasSymbolBuckets&&!m.symbolFadeFinished()||this._removeTile(+p)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){let r={};if(e.length===0)return r;let n={},s=e.reduce((g,x)=>Math.min(g,x.overscaledZ),1/0),l=e[0].overscaledZ,u=Math.max(l-Jo.maxOverzooming,this._source.minzoom),p=Math.max(l+Jo.maxUnderzooming,this._source.minzoom),m={};for(let g of e){let x=this._addTile(g);r[g.key]=g,x.hasData()||s<this._source.maxzoom&&(m[g.key]=g)}this._retainLoadedChildren(m,s,p,r);for(let g of e){let x=this._tiles[g.key];if(x.hasData())continue;if(g.canonical.z>=this._source.maxzoom){let b=g.children(this._source.maxzoom)[0],I=this.getTile(b);if(I&&I.hasData()){r[b.key]=b;continue}}else{let b=g.children(this._source.maxzoom);if(r[b[0].key]&&r[b[1].key]&&r[b[2].key]&&r[b[3].key])continue}let v=x.wasRequested();for(let b=g.overscaledZ-1;b>=u;--b){let I=g.scaledTo(b);if(n[I.key]||(n[I.key]=!0,x=this.getTile(I),!x&&v&&(x=this._addTile(I)),x&&(r[I.key]=I,v=x.wasRequested(),x.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let r=[],n,s=this._tiles[e].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){n=this._loadedParentTiles[s.key];break}r.push(s.key);let l=s.scaledTo(s.overscaledZ-1);if(n=this._getLoadedTile(l),n)break;s=l}for(let l of r)this._loadedParentTiles[l]=n}}_addTile(e){let r=this._tiles[e.key];if(r)return r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));let n=Boolean(r);if(!n){let s=this.map?this.map.painter:null,l=this._source.type==="raster"||this._source.type==="raster-dem";r=new Kh(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,s,l),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))}return r?(r.uses++,this._tiles[e.key]=r,n||this._source.fire(new Dr("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let n=r.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){let r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&r.state!=="reloading"?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(e,r,n){let s=[],l=this.transform;if(!l)return s;for(let u in this._tiles){let p=this._tiles[u];if(n&&p.clearQueryDebugViz(),p.holdingForFade())continue;let m=e.containsTile(p,l,r);m&&s.push(m)}return s}getVisibleCoordinates(e){let r=this.getRenderableIds(e).map(n=>this._tiles[n].tileID);for(let n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(Wd(this._source.type))for(let e in this._tiles){let r=this._tiles[e];if(r.fadeEndTime!==void 0&&r.fadeEndTime>=vi.now())return!0}return!1}setFeatureState(e,r,n){this._state.updateState(e=e||"_geojsonTileLayer",r,n)}removeFeatureState(e,r,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,n)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,n){let s=this._tiles[e];s&&s.setDependencies(r,n)}reloadTilesForDependencies(e,r){for(let n in this._tiles)this._tiles[n].hasDependency(e,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,r))}_preloadTiles(e,r){let n=new Map,s=Array.isArray(e)?e:[e],l=this.map.painter.terrain,u=this.usedForTerrain&&l?l.getScaledDemTileSize():this._source.tileSize;for(let g of s){let x=g.coveringTiles({tileSize:u,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(let v of x)n.set(v.key,v);this.usedForTerrain&&g.updateElevation(!1)}let p=Array.from(n.values()),m=this._source.type==="raster"||this._source.type==="raster-dem";rn(p,(g,x)=>{let v=new Kh(g,this._source.tileSize*g.overscaleFactor(),this.transform.tileZoom,this.map.painter,m);this._loadTile(v,b=>{this._source.type==="raster-dem"&&v.dem&&this._backfillDEM(v),x(b,v)})},r)}}function Xd(t,e){let r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Wd(t){return t==="raster"||t==="image"||t==="video"}Jo.maxOverzooming=10,Jo.maxUnderzooming=3;class Cc{constructor(e,r,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(e,r,n){let s=n||e.findDEMTileFor(r);if(!s||!s.dem)return;let l=s.dem,u=s.tileID,p=1<<r.canonical.z-u.canonical.z;return new Cc(s,s.tileSize/Qe/p,[(r.canonical.x/p-u.canonical.x)*l.dim,(r.canonical.y/p-u.canonical.y)*l.dim])}tileCoordToPixel(e,r){let n=r*this._scale+this._offset[1],s=Math.floor(e*this._scale+this._offset[0]),l=Math.floor(n);return new Ce(s,l)}getElevationAt(e,r,n,s){let l=e*this._scale+this._offset[0],u=r*this._scale+this._offset[1],p=Math.floor(l),m=Math.floor(u),g=this._dem;return s=!!s,n?pt(pt(g.get(p,m,s),g.get(p,m+1,s),u-m),pt(g.get(p+1,m,s),g.get(p+1,m+1,s),u-m),l-p):g.get(p,m,s)}getElevationAtPixel(e,r,n){return this._dem.get(e,r,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Er(1,e)*this._dem.stride}}class Hd{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Go(Qe,16,0),this.featureIndexArray=new xu,this.promoteId=r}insert(e,r,n,s,l,u=0){let p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,l,u);let m=this.grid;for(let g=0;g<r.length;g++){let x=r[g],v=[1/0,1/0,-1/0,-1/0];for(let b=0;b<x.length;b++){let I=x[b];v[0]=Math.min(v[0],I.x),v[1]=Math.min(v[1],I.y),v[2]=Math.max(v[2],I.x),v[3]=Math.max(v[3],I.y)}v[0]<Qe&&v[1]<Qe&&v[2]>=0&&v[3]>=0&&m.insert(p,v[0],v[1],v[2],v[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yo.VectorTile(new tl(this.rawTileData)).layers,this.sourceLayerCoder=new Fd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(let e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,r,n,s){this.loadVTLayers();let l=e.params||{},u=Ns(l.filter),p=e.tileResult,m=e.transform,g=p.bufferedTilespaceBounds,x=this.grid.query(g.min.x,g.min.y,g.max.x,g.max.y,(A,k,D,U)=>Ru(p.bufferedTilespaceGeometry,A,k,D,U));x.sort(Em);let v=null;m.elevation&&x.length>0&&(v=Cc.create(m.elevation,this.tileID));let b={},I;for(let A=0;A<x.length;A++){let k=x[A];if(k===I)continue;I=k;let D=this.featureIndexArray.get(k),U=null;this.loadMatchingFeature(b,D,u,l.layers,l.availableImages,r,n,s,($,H,Y,J=0)=>(U||(U=fn($,this.tileID.canonical,e.tileTransform)),H.queryIntersectsFeature(p,$,Y,U,this.z,e.transform,e.pixelPosMatrix,v,J)))}return b}loadMatchingFeature(e,r,n,s,l,u,p,m,g){let{featureIndex:x,bucketIndex:v,sourceLayerIndex:b,layoutVertexArrayOffset:I}=r,A=this.bucketLayerIDs[v];if(s&&!function($,H){for(let Y=0;Y<$.length;Y++)if(H.indexOf($[Y])>=0)return!0;return!1}(s,A))return;let k=this.sourceLayerCoder.decode(b),D=this.vtLayers[k].feature(x);if(n.needGeometry){let $=Ko(D,!0);if(!n.filter(new Ze(this.tileID.overscaledZ),$,this.tileID.canonical))return}else if(!n.filter(new Ze(this.tileID.overscaledZ),D))return;let U=this.getId(D,k);for(let $=0;$<A.length;$++){let H=A[$];if(s&&s.indexOf(H)<0)continue;let Y=u[H];if(!Y)continue;let J={};U!==void 0&&m&&(J=m.getState(Y.sourceLayer||"_geojsonTileLayer",U));let Q=Lt({},p[H]);Q.paint=Kd(Q.paint,Y.paint,D,J,l),Q.layout=Kd(Q.layout,Y.layout,D,J,l);let he=!g||g(D,Y,J,I);if(!he)continue;let le=new Od(D,this.z,this.x,this.y,U);le.layer=Q;let Se=e[H];Se===void 0&&(Se=e[H]=[]),Se.push({featureIndex:x,feature:le,intersectionZ:he})}}lookupSymbolFeatures(e,r,n,s,l,u,p,m){let g={};this.loadVTLayers();let x=Ns(l);for(let v of e)this.loadMatchingFeature(g,{bucketIndex:n,sourceLayerIndex:s,featureIndex:v,layoutVertexArrayOffset:0},x,u,p,m,r);return g}loadFeature(e){let{featureIndex:r,sourceLayerIndex:n}=e;this.loadVTLayers();let s=this.sourceLayerCoder.decode(n),l=this.vtFeatures[s];if(l[r])return l[r];let u=this.vtLayers[s].feature(r);return l[r]=u,u}hasLayer(e){for(let r of this.bucketLayerIDs)for(let n of r)if(e===n)return!0;return!1}getId(e,r){let n=e.id;return this.promoteId&&(n=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof n=="boolean"&&(n=Number(n))),n}}function Kd(t,e,r,n,s){return zr(t,(l,u)=>{let p=e instanceof ln?e.get(u):null;return p&&p.evaluate?p.evaluate(r,n,s):p})}function Em(t,e){return e-t}ke("FeatureIndex",Hd,{omit:["rawTileData","sourceLayerCoder"]});var Sm=Pt([{name:"a_pos",type:"Int16",components:2}]);let ur=32,Wr=33,io=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,r=0,n=0,s=0,l=0,u=0,p=0;for(1&e?s=l=u=ur:r=n=p=ur;(e>>=1)>1;){let g=r+s>>1,x=n+l>>1;1&e?(s=r,l=n,r=u,n=p):(r=s,n=l,s=u,l=p),u=g,p=x}let m=4*t;io[m+0]=r,io[m+1]=n,io[m+2]=s,io[m+3]=l}let Hr=new Uint16Array(2178),ro=new Uint8Array(1089),zc=new Uint16Array(1089);function Yd(t){return t===0?-.03125:t===32?.03125:0}var Hh=Pt([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);let Jd={type:2,extent:Qe,loadGeometry:()=>[[new Ce(0,0),new Ce(8193,0),new Ce(8193,8193),new Ce(0,8193),new Ce(0,0)]]};class Kh{constructor(e,r,n,s,l){this.tileID=e,this.uid=go(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=l,this.expiredRequestCount=0,this.state="loading",s&&s.transform&&(this.projection=s.transform.projection)}registerFadeDuration(e){let r=e+this.timeAdded;r<vi.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=la(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,r,n){if(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(s,l){let u={};if(!l)return u;for(let p of s){let m=p.layerIds.map(g=>l.getLayer(g)).filter(Boolean);if(m.length!==0){p.layers=m,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map(g=>m.filter(x=>x.id===g)[0]));for(let g of m)u[g.id]=p}}return u}(e.buckets,r.style),this.hasSymbolBuckets=!1;for(let s in this.buckets){let l=this.buckets[s];if(l instanceof eo){if(this.hasSymbolBuckets=!0,!n)break;l.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let s in this.buckets){let l=this.buckets[s];if(l instanceof eo&&l.hasRTLText){this.hasRTLText=!0,ot.isLoading()||ot.isLoaded()||Fi()!=="deferred"||Wi();break}}this.queryPadding=0;for(let s in this.buckets){let l=this.buckets[s];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(s).queryRadius(l))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new lh}unloadVectorData(){if(this.hasData()){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(let n in this.buckets){let s=this.buckets[n];s.uploadPending()&&s.upload(e)}let r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ic(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ic(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ic(e,this.lineAtlas.image,r.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,r,n,s,l,u,p,m){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:s,pixelPosMatrix:p,transform:u,params:l,tileTransform:this.tileTransform},e,r,n):{}}querySourceFeatures(e,r){let n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;let s=n.loadVTLayers(),l=r?r.sourceLayer:"",u=s._geojsonTileLayer||s[l];if(!u)return;let p=Ns(r&&r.filter),{z:m,x:g,y:x}=this.tileID.canonical,v={z:m,x:g,y:x};for(let b=0;b<u.length;b++){let I=u.feature(b);if(p.needGeometry){let D=Ko(I,!0);if(!p.filter(new Ze(this.tileID.overscaledZ),D,this.tileID.canonical))continue}else if(!p.filter(new Ze(this.tileID.overscaledZ),I))continue;let A=n.getId(I,l),k=new Od(I,m,g,x,A);k.tile=v,e.push(k)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let r=this.expirationTime;if(e.cacheControl){let n=zn(e.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let n=Date.now(),s=!1;if(this.expirationTime>n)s=!1;else if(r)if(this.expirationTime<r)s=!0;else{let l=this.expirationTime-r;l?this.expirationTime=n+Math.max(l,3e4):s=!0}else s=!0;s?(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(e,r){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0||!r)return;let n=this.latestFeatureIndex.loadVTLayers(),s=r.style.listImages();for(let l in this.buckets){if(!r.style.hasLayer(l))continue;let u=this.buckets[l],p=u.layers[0].sourceLayer||"_geojsonTileLayer",m=n[p],g=e[p];if(!m||!g||Object.keys(g).length===0)continue;if(u.update(g,m,s,this.imageAtlas&&this.imageAtlas.patternPositions||{}),u instanceof mc||u instanceof fc){let v=r.style._getSourceCache(u.layers[0].source);r._terrain&&r._terrain.enabled&&v&&u.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(v.id,this.tileID)}let x=r&&r.style&&r.style.getLayer(l);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<vi.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=vi.now()+e}setDependencies(e,r){let n={};for(let s of r)n[s]=!0;this.dependencies[e]=n}hasDependency(e,r){for(let n of e){let s=this.dependencies[n];if(s){for(let l of r)if(s[l])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,r){if(!r||r.name==="mercator"||this._tileDebugBuffer)return;let n=fn(Jd,this.tileID.canonical,this.tileTransform)[0],s=new $s,l=new ec;for(let u=0;u<n.length;u++){let{x:p,y:m}=n[u];s.emplaceBack(p,m),l.emplaceBack(u)}l.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(l),this._tileDebugBuffer=e.createVertexBuffer(s,Hh.members),this._tileDebugSegments=Nt.simpleSegment(0,0,s.length,l.length)}_makeTileBoundsBuffers(e,r){if(this._tileBoundsBuffer||!r||r.name==="mercator")return;let n=fn(Jd,this.tileID.canonical,this.tileTransform)[0],s,l;if(this.isRaster){let u=function(p,m){let g=la(p,m),x=Math.pow(2,p.z);for(let D=0;D<Wr;D++)for(let U=0;U<Wr;U++){let $=pn((p.x+(U+Yd(U))/ur)/x),H=hr((p.y+(D+Yd(D))/ur)/x),Y=m.project($,H),J=D*Wr+U;Hr[2*J+0]=Math.round((Y.x*g.scale-g.x)*Qe),Hr[2*J+1]=Math.round((Y.y*g.scale-g.y)*Qe)}ro.fill(0),zc.fill(0);for(let D=2045;D>=0;D--){let U=4*D,$=io[U+0],H=io[U+1],Y=io[U+2],J=io[U+3],Q=$+Y>>1,he=H+J>>1,le=Q+he-H,Se=he+$-Q,be=H*Wr+$,ce=J*Wr+Y,we=he*Wr+Q,Ie=Math.hypot((Hr[2*be+0]+Hr[2*ce+0])/2-Hr[2*we+0],(Hr[2*be+1]+Hr[2*ce+1])/2-Hr[2*we+1])>=16;if(ro[we]=ro[we]||(Ie?1:0),D<1022){let fe=(H+Se>>1)*Wr+($+le>>1),ze=(J+Se>>1)*Wr+(Y+le>>1);ro[we]=ro[we]||ro[fe]||ro[ze]}}let v=new qs,b=new Hi,I=0;function A(D,U){let $=U*Wr+D;return zc[$]===0&&(v.emplaceBack(Hr[2*$+0],Hr[2*$+1],D*Qe/ur,U*Qe/ur),zc[$]=++I),zc[$]-1}function k(D,U,$,H,Y,J){let Q=D+$>>1,he=U+H>>1;if(Math.abs(D-Y)+Math.abs(U-J)>1&&ro[he*Wr+Q])k(Y,J,D,U,Q,he),k($,H,Y,J,Q,he);else{let le=A(D,U),Se=A($,H),be=A(Y,J);b.emplaceBack(le,Se,be)}}return k(0,0,ur,ur,ur,0),k(ur,ur,0,0,0,ur),{vertices:v,indices:b}}(this.tileID.canonical,r);s=u.vertices,l=u.indices}else{s=new qs,l=new Hi;for(let{x:p,y:m}of n)s.emplaceBack(p,m,0,0);let u=cc(s.int16,void 0,4);for(let p=0;p<u.length;p+=3)l.emplaceBack(u[p],u[p+1],u[p+2])}this._tileBoundsBuffer=e.createVertexBuffer(s,Hh.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(l),this._tileBoundsSegments=Nt.simpleSegment(0,0,s.length,l.length)}}let Im=Pt([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),Mm=Pt([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Qd}=Im;function Qo(t,e){let r=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,s=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),l=Math.sin(r)*s/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01)),u=Math.sin(t._pitch)*l+s;return Math.min(1.01*u,s*(1/t._horizonShift))}let Yh=Qe/Math.PI/2,Oi=-Yh,Ui=Yh,Am=[new Sr([Oi,Oi,Oi],[Ui,Ui,Ui]),new Sr([Oi,Oi,Oi],[0,0,Ui]),new Sr([0,Oi,Oi],[Ui,0,Ui]),new Sr([Oi,0,Oi],[0,Ui,Ui]),new Sr([0,0,Oi],[Ui,Ui,Ui])];function kc(t){if(t.z<=1)return Am[t.z+2*t.y+t.x];let[e,r]=ep(t),n=[Pc(e[0],e[1]),Pc(e[0],r[1]),Pc(r[0],e[1]),Pc(r[0],r[1])],s=[Ui,Ui,Ui],l=[Oi,Oi,Oi];for(let u of n)s[0]=Math.min(s[0],u[0]),s[1]=Math.min(s[1],u[1]),s[2]=Math.min(s[2],u[2]),l[0]=Math.max(l[0],u[0]),l[1]=Math.max(l[1],u[1]),l[2]=Math.max(l[2],u[2]);return new Sr(s,l)}function ep(t){let e=Math.pow(2,t.z),r=t.x/e,n=(t.x+1)/e,s=(t.y+1)/e;return[[hr(t.y/e),pn(r)],[hr(s),pn(n)]]}function Jh(t,e,r,n){return r=Je(r),n||(n=Yh),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function Pc(t,e,r){return Jh(Math.cos(Je(t)),Math.sin(Je(t)),e,r)}function tp(t){return 16383/Math.max(...en([],t.max,t.min))}function ip(t){let e=ui(new Float64Array(16)),r=1/tp(t);return pr(e,e,t.min),Ai(e,e,[r,r,r]),e}function rp(t,e,r){let n=e/(2*Math.PI),s=function(u){let p=Qe/(2*Math.PI);return u/(2*Math.PI)/p}(e);if(!r){let u=mt(t.center.lat,-85.051129,$r);r=[Hs(t.center.lng)*e,Ks(u)*e]}let l=ui(new Float64Array(16));return pr(l,l,[r[0],r[1],-n]),Ai(l,l,[s,s,s]),yn(l,l,Je(-t._center.lat)),Ji(l,l,Je(-t._center.lng)),l}class Qh{constructor(e){let r=this._createGridIndices();this.gridIndexBuffer=e.createIndexBuffer(r,!0),this.gridSegments=Nt.simpleSegment(0,0,4225,8192);let n=this._createPoleTriangleIndices();this.poleIndexBuffer=e.createIndexBuffer(n,!0),this.poleSegments=Nt.simpleSegment(0,0,66,64);let s=new $a;s.emplaceBack(-1,1,1,0,0,0,0),s.emplaceBack(1,1,1,0,0,1,0),s.emplaceBack(1,-1,1,0,0,1,1),s.emplaceBack(-1,-1,1,0,0,0,1);let l=new Hi;l.emplaceBack(0,1,2),l.emplaceBack(2,3,0),this.atmosphereVertexBuffer=e.createVertexBuffer(s,Mm.members),this.atmosphereIndexBuffer=e.createIndexBuffer(l),this.atmosphereSegments=Nt.simpleSegment(0,0,4,2)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleSegments.destroy(),this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}static createPoleTriangleVertices(e,r,n){let s=new $a,l=r/Math.PI/2;s.emplaceBack(0,-l,0,0,0,.5,n?0:1);let u=360/e,p=Math.cos(Je(85)),m=Math.sin(Je(85));for(let x=0;x<=64;x++){let v=x/64,b=Jh(p,m,0*(1-(g=v))+u*g,l);s.emplaceBack(b[0],b[1],b[2],0,0,v,n?0:1)}var g;return s}_createPoleTriangleIndices(){let e=new Hi;for(let r=0;r<=64;r++)e.emplaceBack(0,r+1,r+2);return e}static createGridVertices(e){let r=Math.pow(2,e.z),n=(m,g,x)=>m*(1-x)+g*x,[s,l]=ep(e),u=new $a,p=function(m){let g=ui(new Float64Array(16)),x=tp(m);var v,b;return Ai(g,g,[x,x,x]),pr(g,g,((v=[])[0]=-(b=m.min)[0],v[1]=-b[1],v[2]=-b[2],v)),g}(kc(e));u.reserve(4096);for(let m=0;m<65;m++){let g=n(s[0],l[0],m/64),x=Ks(g),v=x*r-e.y,b=Math.sin(Je(g)),I=Math.cos(Je(g));for(let A=0;A<65;A++){let k=A/64,D=n(s[1],l[1],k),U=Jh(I,b,D);nt(U,U,p);let $=Hs(D);u.emplaceBack(U[0],U[1],U[2],$,x,k,v)}}return u}_createGridIndices(){let e=new Hi,r=(n,s)=>{let l=65*s+n;e.emplaceBack(l+1,l,l+65),e.emplaceBack(l+65,l+65+1,l+1)};for(let n=0;n<64;n++)for(let s=0;s<64;s++)r(s,n);return e}getWirefameBuffer(e){if(!this.wireframeSegments){let r=this._createWireframeGrid();this.wireframeIndexBuffer=e.createIndexBuffer(r),this.wireframeSegments=Nt.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){let e=new Hn,r=(n,s)=>{let l=65*s+n;e.emplaceBack(l,l+1),e.emplaceBack(l,l+65),e.emplaceBack(l,l+65+1)};for(let n=0;n<64;n++)for(let s=0;s<64;s++)r(s,n);return e}}function la(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};let r=Math.pow(2,-t.z),n=t.x*r,s=(t.x+1)*r,l=t.y*r,u=(t.y+1)*r,p=pn(n),m=pn(s),g=hr(l),x=hr(u),v=e.project(p,g),b=e.project(m,g),I=e.project(m,x),A=e.project(p,x),k=Math.min(v.x,b.x,I.x,A.x),D=Math.min(v.y,b.y,I.y,A.y),U=Math.max(v.x,b.x,I.x,A.x),$=Math.max(v.y,b.y,I.y,A.y),H=r/16;function Y(Q,he,le,Se,be,ce){let we=(le+be)/2,Ie=(Se+ce)/2,fe=e.project(pn(we),hr(Ie)),ze=Math.max(0,k-fe.x,D-fe.y,fe.x-U,fe.y-$);k=Math.min(k,fe.x),U=Math.max(U,fe.x),D=Math.min(D,fe.y),$=Math.max($,fe.y),ze>H&&(Y(Q,fe,le,Se,we,Ie),Y(fe,he,we,Ie,be,ce))}Y(v,b,n,l,s,l),Y(b,I,s,l,s,u),Y(I,A,s,u,n,u),Y(A,v,n,u,n,l),k-=H,D-=H,U+=H,$+=H;let J=1/Math.max(U-k,$-D);return{scale:J,x:k*J,y:D*J,x2:U*J,y2:$*J,projection:e}}class np{constructor(e){let r={},n=[];for(let p in e){let m=e[p],g=r[p]={};for(let x in m.glyphs){let v=m.glyphs[+x];if(!v||v.bitmap.width===0||v.bitmap.height===0)continue;let b=v.metrics.localGlyph?2:1,I={x:0,y:0,w:v.bitmap.width+2*b,h:v.bitmap.height+2*b};n.push(I),g[x]=I}}let{w:s,h:l}=Ch(n),u=new Yn({width:s||1,height:l||1});for(let p in e){let m=e[p];for(let g in m.glyphs){let x=m.glyphs[+g];if(!x||x.bitmap.width===0||x.bitmap.height===0)continue;let v=r[p][g],b=x.metrics.localGlyph?2:1;Yn.copy(x.bitmap,u,{x:0,y:0},{x:v.x+b,y:v.y+b},x.bitmap)}}this.image=u,this.positions=r}}ke("GlyphAtlas",np);class Cm{constructor(e){this.tileID=new Ei(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,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.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=la(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,r,n,s,l){this.status="parsing",this.data=e,this.collisionBoxArray=new lh;let u=new Fd(Object.keys(e.layers).sort()),p=new Hd(this.tileID,this.promoteId);p.bucketLayerIDs=[];let m={},g=new Gh(256,256),x={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:g,availableImages:n},v=r.familiesBySource[this.source];for(let J in v){let Q=e.layers[J];if(!Q)continue;let he=!1,le=!1;for(let ce of v[J])ce[0].type==="symbol"?he=!0:le=!0;if(this.isSymbolTile===!0&&!he||this.isSymbolTile===!1&&!le)continue;Q.version===1&&zt(`Vector tile source "${this.source}" layer "${J}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let Se=u.encode(J),be=[];for(let ce=0;ce<Q.length;ce++){let we=Q.feature(ce),Ie=p.getId(we,J);be.push({feature:we,id:Ie,index:ce,sourceLayerIndex:Se})}for(let ce of v[J]){let we=ce[0];this.isSymbolTile!==void 0&&we.type==="symbol"!==this.isSymbolTile||we.minzoom&&this.zoom<Math.floor(we.minzoom)||we.maxzoom&&this.zoom>=we.maxzoom||we.visibility!=="none"&&(eu(ce,this.zoom,n),(m[we.id]=we.createBucket({index:p.bucketLayerIDs.length,layers:ce,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Se,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(be,x,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(ce.map(Ie=>Ie.id)))}}let b,I,A,k;g.trim();let D={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},U=zr(x.glyphDependencies,J=>Object.keys(J).map(Number));Object.keys(U).length?s.send("getGlyphs",{uid:this.uid,stacks:U},(J,Q)=>{b||(b=J,I=Q,Y.call(this))},void 0,!1,D):I={};let $=Object.keys(x.iconDependencies);$.length?s.send("getImages",{icons:$,source:this.source,tileID:this.tileID,type:"icons"},(J,Q)=>{b||(b=J,A=Q,Y.call(this))},void 0,!1,D):A={};let H=Object.keys(x.patternDependencies);function Y(){if(b)return l(b);if(I&&A&&k){let J=new np(I),Q=new hd(A,k);for(let he in m){let le=m[he];le instanceof eo?(eu(le.layers,this.zoom,n),am(le,I,J.positions,A,Q.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),le.projection=this.projection.name):le.hasPattern&&(le instanceof mc||le instanceof fc||le instanceof Ih)&&(eu(le.layers,this.zoom,n),le.addFeatures(x,this.tileID.canonical,Q.patternPositions,n))}this.status="done",l(null,{buckets:Sn(m).filter(he=>!he.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:J.image,lineAtlas:g,imageAtlas:Q,glyphMap:this.returnDependencies?I:null,iconMap:this.returnDependencies?A:null,glyphPositions:this.returnDependencies?J.positions:null})}}H.length?s.send("getImages",{icons:H,source:this.source,tileID:this.tileID,type:"patterns"},(J,Q)=>{b||(b=J,k=Q,Y.call(this))},void 0,!1,D):k={},Y.call(this)}}function eu(t,e,r){let n=new Ze(e);for(let s of t)s.recalculate(n,r)}class op{constructor(e){this.entries={},this.scheduler=e}request(e,r,n,s){let l=this.entries[e]=this.entries[e]||{callbacks:[]};if(l.result){let[u,p]=l.result;return this.scheduler?this.scheduler.add(()=>{s(u,p)},r):s(u,p),()=>{}}return l.callbacks.push(s),l.cancel||(l.cancel=n((u,p)=>{l.result=[u,p];for(let m of l.callbacks)this.scheduler?this.scheduler.add(()=>{m(u,p)},r):m(u,p);setTimeout(()=>delete this.entries[e],3e3)})),()=>{l.result||(l.callbacks=l.callbacks.filter(u=>u!==s),l.callbacks.length||(l.cancel(),delete this.entries[e]))}}}function sp(t,e,r){let n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},s=>{let l=bo(t.request,(u,p,m,g)=>{u?s(u):p&&s(null,{vectorTile:r?void 0:new Yo.VectorTile(new tl(p)),rawData:p,cacheControl:m,expires:g})});return()=>{l.cancel(),s()}},e)}let zm=ui(new Float64Array(16));class es{constructor(e,r){this._tr=e,this._worldSize=r}createInversionMatrix(){return zm}createTileMatrix(e){let r,n,s,l=e.canonical,u=ui(new Float64Array(16)),p=this._tr.projection;if(p.isReprojectedInTileSpace){let m=la(l,p);r=1,n=m.x+e.wrap*m.scale,s=m.y,Ai(u,u,[r/m.scale,r/m.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(l.z),n=(l.x+Math.pow(2,l.z)*e.wrap)*r,s=l.y*r;return pr(u,u,[n,s,0]),Ai(u,u,[r/Qe,r/Qe,1]),u}pointCoordinate(e,r,n){let s=this._tr.horizonLineFromTop(!1),l=new Ce(e,Math.max(s,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(l,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var km={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&uo(this.parallels,this.constants.parallels))return;let t=Math.sin(Je(this.parallels[0])),e=(t+Math.sin(Je(this.parallels[1])))/2,r=1+t*(2*e-t),n=Math.sqrt(r)/e;this.constants={n:e,c:r,r0:n,parallels:this.parallels}},project(t,e){this.initializeConstants();let r=Je(t-this.center[0]),n=Je(e),{n:s,c:l,r0:u}=this.constants,p=Math.sqrt(l-2*s*Math.sin(n))/s;return{x:p*Math.sin(r*s),y:p*Math.cos(r*s)-u,z:0}},unproject(t,e){this.initializeConstants();let{n:r,c:n,r0:s}=this.constants,l=s+e,u=Math.atan2(t,Math.abs(l))*Math.sign(l);l*r<0&&(u-=Math.PI*Math.sign(t)*Math.sign(l));let p=Je(this.center[0])*r;u=mr(u,-Math.PI-p,Math.PI-p);let m=xi(u/r)+this.center[0],g=Math.asin(mt((n-(t*t+l*l)*r*r)/(2*r),-1,1)),x=mt(xi(g),-85.051129,$r);return new _t(m,x)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)};let ol=1.340264,sl=-.081106,al=893e-6,ll=.003796,Dc=Math.sqrt(3)/2;var Pm={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;let r=Math.asin(Dc*Math.sin(e)),n=r*r,s=n*n*n;return{x:.5*(t*Math.cos(r)/(Dc*(ol+3*sl*n+s*(7*al+9*ll*n)))/Math.PI+.5),y:1-.5*(r*(ol+sl*n+s*(al+ll*n))/Math.PI+1),z:0}},unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=r*r,s=n*n*n;for(let g,x,v,b=0;b<12&&(x=r*(ol+sl*n+s*(al+ll*n))-e,v=ol+3*sl*n+s*(7*al+9*ll*n),g=x/v,r=mt(r-g,-Math.PI/3,Math.PI/3),n=r*r,s=n*n*n,!(Math.abs(g)<1e-12));++b);let l=Dc*t*(ol+3*sl*n+s*(7*al+9*ll*n))/Math.cos(r),u=Math.asin(Math.sin(r)/Dc),p=mt(180*l/Math.PI,-180,180),m=mt(180*u/Math.PI,-85.051129,$r);return new _t(p,m)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)},Dm={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(t,e)=>({x:.5+t/360,y:.5-e/360,z:0}),unproject(t,e){let r=360*(t-.5),n=mt(360*(.5-e),-85.051129,$r);return new _t(r,n)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)};let ca=Math.PI/2;function Lc(t){return Math.tan((ca+t)/2)}var Lm={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&uo(this.parallels,this.constants.parallels))return;let t=Je(this.parallels[0]),e=Je(this.parallels[1]),r=Math.cos(t),n=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(Lc(e)/Lc(t)),s=r*Math.pow(Lc(t),n)/n;this.constants={n,f:s,parallels:this.parallels}},project(t,e){this.initializeConstants(),e=Je(e),t=Je(t-this.center[0]);let r=1e-6,{n,f:s}=this.constants;s>0?e<-ca+r&&(e=-ca+r):e>ca-r&&(e=ca-r);let l=s/Math.pow(Lc(e),n),u=l*Math.sin(n*t),p=s-l*Math.cos(n*t);return{x:.5*(u/Math.PI+.5),y:1-.5*(p/Math.PI+.5),z:0}},unproject(t,e){this.initializeConstants(),t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;let{n:r,f:n}=this.constants,s=n-e,l=Math.sign(s),u=Math.sign(r)*Math.sqrt(t*t+s*s),p=Math.atan2(t,Math.abs(s))*l;s*r<0&&(p-=Math.PI*Math.sign(t)*l);let m=mt(xi(p/r)+this.center[0],-180,180),g=mt(xi(2*Math.atan(Math.pow(n/u,1/r))-ca),-85.051129,$r);return new _t(m,g)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)},Bm={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(t,e)=>({x:Hs(t),y:Ks(e),z:0}),unproject(t,e){let r=pn(t),n=hr(e);return new _t(r,n)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)};let ap=Je($r);var Rm={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(t,e){let r=(e=Je(e))*e,n=r*r;return{x:.5*((t=Je(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}},unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,s=0,l=r*r;do{l=r*r;let m=l*l;s=(r*(1.007226+l*(.015085+m*(.028874*l-.044475-.005916*m)))-e)/(1.007226+l*(.045255+m*(.259866*l-.311325-.005916*11*m))),r=mt(r-s,-ap,ap)}while(Math.abs(s)>1e-6&&--n>0);l=r*r;let u=mt(xi(t/(.8707+l*(l*(l*l*l*(.003971-.001529*l)-.013791)-.131979))),-180,180),p=xi(r);return new _t(u,p)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)};let lp=Je($r),cp={albers:km,equalEarth:Pm,equirectangular:Dm,lambertConformalConic:Lm,mercator:Bm,naturalEarth:Rm,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(t,e){e=Je(e),t=Je(t);let r=Math.cos(e),n=2/Math.PI,s=Math.acos(r*Math.cos(t/2)),l=Math.sin(s)/s,u=.5*(t*n+2*r*Math.sin(t/2)/l)||0,p=.5*(e+Math.sin(e)/l)||0;return{x:.5*(u/Math.PI+.5),y:1-.5*(p/Math.PI+1),z:0}},unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,s=25,l=1e-6,u=0,p=0;do{let m=Math.cos(n),g=Math.sin(n),x=2*g*m,v=g*g,b=m*m,I=Math.cos(r/2),A=Math.sin(r/2),k=2*I*A,D=A*A,U=1-b*I*I,$=U?1/U:0,H=U?Math.acos(m*I)*Math.sqrt(1/U):0,Y=.5*(2*H*m*A+2*r/Math.PI)-t,J=.5*(H*g+n)-e,Q=.5*$*(b*D+H*m*I*v)+1/Math.PI,he=$*(k*x/4-H*g*A),le=.125*$*(x*A-H*g*b*k),Se=.5*$*(v*I+H*D*m)+.5,be=he*le-Se*Q;u=(J*he-Y*Se)/be,p=(Y*le-J*Q)/be,r=mt(r-u,-Math.PI,Math.PI),n=mt(n-p,-lp,lp)}while((Math.abs(u)>l||Math.abs(p)>l)&&--s>0);return new _t(xi(r),xi(n))},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Er(1,t)*e,farthestPixelDistance(t){return Qo(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new es(t,e)}};a.ARRAY_TYPE=Dt,a.AUTH_ERR_MSG=re,a.Aabb=Sr,a.Actor=class{constructor(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.cancelCallbacks={},In(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ir()?t:me,this.scheduler=new bm}send(t,e,r,n,s=!1,l){let u=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=l,this.callbacks[u]=r);let p=rr(this.globalScope)?void 0:[];return this.target.postMessage({id:u,type:t,hasCallback:!!r,targetMapId:n,mustQueue:s,sourceMapId:this.mapId,data:qo(e,p)},p),{cancel:()=>{r&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){let e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){let n=this.cancelCallbacks[r];delete this.cancelCallbacks[r],n&&n.cancel()}else if(e.mustQueue||ir()){let n=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add(()=>this.processTask(r,e),n&&n.metadata||{type:"message"})}else this.processTask(r,e)}processTask(t,e){if(e.type==="<response>"){let r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Gr(e.error)):r(null,Gr(e.data)))}else{let r=rr(this.globalScope)?void 0:[],n=e.hasCallback?(l,u)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:l?qo(l):null,data:qo(u,r)},r)}:l=>{},s=Gr(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,s,n);else if(this.parent.getWorkerSource){let l=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,l[0],s.source)[l[1]](s,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=Mc,a.Color=lt,a.ColorMode=Xr,a.CullFaceMode=Ir,a.DEMData=Ac,a.DataConstantProperty=Pe,a.DedupedRequest=op,a.DepthMode=aa,a.EXTENT=Qe,a.Elevation=class{getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,r=!0){e==null&&(e=null);let n=this._source();if(!n||t.y<0||t.y>1)return e;let s=n.getSource().maxzoom,l=1<<s,u=Math.floor(t.x),p=t.x-u,m=new Ei(s,u,s,Math.floor(p*l),Math.floor(t.y*l)),g=this.findDEMTileFor(m);if(!g||!g.dem)return e;let x=g.dem,v=1<<g.tileID.canonical.z,b=(p*v-g.tileID.canonical.x)*x.dim,I=(t.y*v-g.tileID.canonical.y)*x.dim,A=Math.floor(b),k=Math.floor(I);return(r?this.exaggeration():1)*pt(pt(x.get(A,k),x.get(A,k+1),I-k),pt(x.get(A+1,k),x.get(A+1,k+1),I-k),b-A)}getAtTileOffset(t,e,r){let n=1<<t.canonical.z;return this.getAtPointOrZero(new sc(t.wrap+(t.canonical.x+e/Qe)/n,(t.canonical.y+r/Qe)/n))}getAtTileOffsetFunc(t,e){return r=>{let n=this.getAtTileOffset(t,r.x,r.y),s=e.upVector(t.canonical,r.x,r.y);return Qi(s,s,n*e.upVectorScale(t.canonical)),s}}getForTilePoints(t,e,r,n){let s=Cc.create(this,t,n);return!!s&&(e.forEach(l=>{l[2]=this.exaggeration()*s.getElevationAt(l[0],l[1],r)}),!0)}getMinMaxForTile(t){let e=this.findDEMTileFor(t);if(!e||!e.dem)return null;let r=e.dem.tree,n=e.tileID,s=1<<t.canonical.z-n.canonical.z,l=t.canonical.x/s-n.canonical.x,u=t.canonical.y/s-n.canonical.y,p=0;for(let m=0;m<t.canonical.z-n.canonical.z&&!r.leaves[p];m++){l*=2,u*=2;let g=2*Math.floor(u)+Math.floor(l);p=r.childOffsets[p]+g,l%=1,u%=1}return{min:this.exaggeration()*r.minimums[p],max:this.exaggeration()*r.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,r){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},a.ErrorEvent=ps,a.EvaluationParameters=Ze,a.Event=Dr,a.Evented=Lr,a.Frustum=_h,a.GLOBE_ZOOM_THRESHOLD_MAX=6,a.GlobeSharedBuffers=Qh,a.GlyphManager=oa,a.ImagePosition=zh,a.LineAtlas=Gh,a.LngLat=_t,a.LngLatBounds=Ho,a.LocalGlyphMode=Lh,a.MAX_MERCATOR_LATITUDE=$r,a.MercatorCoordinate=sc,a.ONE_EM=oi,a.OverscaledTileID=Ei,a.Properties=ri,a.RGBAImage=Ki,a.Ray=class{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,r){let n=er(e,this.dir);if(Math.abs(n)<1e-6)return!1;let s=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/n;return r[0]=this.pos[0]+this.dir[0]*s,r[1]=this.pos[1]+this.dir[1]*s,r[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(t,e,r){if(function(b,I){var A=b[0],k=b[1],D=b[2],U=I[0],$=I[1],H=I[2];return Math.abs(A-U)<=Mi*Math.max(1,Math.abs(A),Math.abs(U))&&Math.abs(k-$)<=Mi*Math.max(1,Math.abs(k),Math.abs($))&&Math.abs(D-H)<=Mi*Math.max(1,Math.abs(D),Math.abs(H))}(this.pos,t)||e===0)return r[0]=r[1]=r[2]=0,!1;let[n,s,l]=this.dir,u=this.pos[0]-t[0],p=this.pos[1]-t[1],m=this.pos[2]-t[2],g=n*n+s*s+l*l,x=2*(u*n+p*s+m*l),v=x*x-4*g*(u*u+p*p+m*m-e*e);if(v<0){let b=Math.max(-x/2,0),I=u+n*b,A=p+s*b,k=m+l*b,D=Math.hypot(I,A,k);return r[0]=I*e/D,r[1]=A*e/D,r[2]=k*e/D,!1}{let b=(-x-Math.sqrt(v))/(2*g);if(b<0){let I=Math.hypot(u,p,m);return r[0]=u*e/I,r[1]=p*e/I,r[2]=m*e/I,!1}return r[0]=u+n*b,r[1]=p+s*b,r[2]=m+l*b,!0}}},a.RequestManager=class{constructor(t,e,r){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){let t=function(){let e="";for(let r=0;r<10;r++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",K,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!ue(t))return t;let r=Le(t);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!ue(t))return t;let r=Le(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!ue(t))return t;let r=Le(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,r,n){let s=Le(t);return ue(t)?(s.path=`/styles/v1${s.path}/sprite${e}${r}`,this._makeAPIURL(s,this._customAccessToken||n)):(s.path+=`${e}${r}`,Oe(s))}normalizeTileURL(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!ue(t))return t;let n=Le(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||r&&n.authority!=="raster"&&r===512?"@2x":""}${C.supported?".webp":"$1"}`),n.authority==="raster"?n.path=`/${S.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${S.TILE_URL_VERSION}${n.path}`);let s=this._customAccessToken||function(l){for(let u of l){let p=u.match(/^access_token=(.*)$/);if(p)return p[1]}return null}(n.params)||S.ACCESS_TOKEN;return S.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(t,e){let r=Le(t);if(!r.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!r.path.match(/\.[\w]+$/))return t;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${S.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${S.TILE_URL_VERSION}/`,"")}`;let s=r.params;return e&&(s=s.filter(l=>!l.match(/^access_token=/))),s.length&&(n+=`?${s.join("&")}`),n}canonicalizeTileset(t,e){let r=!!e&&ue(e),n=[];for(let s of t.tiles||[])pe(s)?n.push(this.canonicalizeTileURL(s,r)):n.push(s);return n}_makeAPIURL(t,e){let r="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",n=Le(S.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,t.protocol==="http"){let s=t.params.indexOf("secure");s>=0&&t.params.splice(s,1)}if(n.path!=="/"&&(t.path=`${n.path}${t.path}`),!S.REQUIRE_ACCESS_TOKEN)return Oe(t);if(e=e||S.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter(s=>s.indexOf("access_token")===-1),t.params.push(`access_token=${e||""}`),Oe(t)}},a.ResourceType=us,a.SegmentVector=Nt,a.SourceCache=Jo,a.StencilMode=qh,a.StructArrayLayout1ui2=ec,a.StructArrayLayout2f1f2i16=th,a.StructArrayLayout2i4=$s,a.StructArrayLayout2ui4=Hn,a.StructArrayLayout3f12=Xs,a.StructArrayLayout3ui6=Hi,a.StructArrayLayout4i8=qs,a.Texture=Ic,a.Tile=Kh,a.Transitionable=wi,a.Uniform1f=nc,a.Uniform1i=class extends hn{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},a.Uniform2f=class extends hn{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]))}},a.Uniform3f=class extends hn{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]))}},a.Uniform4f=Eu,a.UniformColor=Su,a.UniformMatrix2f=class extends hn{constructor(t,e){super(t,e),this.current=Ip}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},a.UniformMatrix3f=class extends hn{constructor(t,e){super(t,e),this.current=Sp}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},a.UniformMatrix4f=class extends hn{constructor(t,e){super(t,e),this.current=Ep}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}}},a.UnwrappedTileID=Zh,a.ValidationError=Ae,a.VectorTileWorkerSource=class extends Lr{constructor(t,e,r,n,s){super(),this.actor=t,this.layerIndex=e,this.availableImages=r,this.loadVectorData=s||sp,this.loading={},this.loaded={},this.deduped=new op(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler}loadTile(t,e){let r=t.uid,n=t&&t.request,s=n&&n.collectResourceTiming,l=this.loading[r]=new Cm(t);l.abort=this.loadVectorData(t,(u,p)=>{let m=!this.loading[r];if(delete this.loading[r],m||u||!p)return l.status="done",m||(this.loaded[r]=l),e(u);let g=p.rawData,x={};p.expires&&(x.expires=p.expires),p.cacheControl&&(x.cacheControl=p.cacheControl),l.vectorTile=p.vectorTile||new Yo.VectorTile(new tl(g));let v=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,(b,I)=>{if(b||!I)return e(b);let A={};if(s){let k=Bd(n);k.length>0&&(A.resourceTiming=JSON.parse(JSON.stringify(k)))}e(null,Lt({rawTileData:g.slice(0)},I,x,A))})};this.isSpriteLoaded?v():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(v,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):v()}),this.loaded=this.loaded||{},this.loaded[r]=l})}reloadTile(t,e){let r=this.loaded,n=t.uid,s=this;if(r&&r[n]){let l=r[n];l.showCollisionBoxes=t.showCollisionBoxes,l.enableTerrain=!!t.enableTerrain,l.projection=t.projection;let u=(p,m)=>{let g=l.reloadCallback;g&&(delete l.reloadCallback,l.parse(l.vectorTile,s.layerIndex,this.availableImages,s.actor,g)),e(p,m)};l.status==="parsing"?l.reloadCallback=u:l.status==="done"&&(l.vectorTile?l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,u):u())}}abortTile(t,e){let r=t.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e()}removeTile(t,e){let r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()}},a.WritingMode=Yi,a.ZoomHistory=c,a.add=co,a.addDynamicAttributes=Oh,a.adjoint=function(t,e){var r=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],g=e[7],x=e[8];return t[0]=u*x-p*g,t[1]=s*g-n*x,t[2]=n*p-s*u,t[3]=p*m-l*x,t[4]=r*x-s*m,t[5]=s*l-r*p,t[6]=l*g-u*m,t[7]=n*m-r*g,t[8]=r*u-n*l,t},a.asyncAll=rn,a.bezier=fo,a.bindAll=In,a.boundsAttributes=Hh,a.bufferConvexPolygon=function(t,e){let r=[];for(let n=0;n<t.length;n++){let s=mr(n-1,-1,t.length-1),l=mr(n+1,-1,t.length-1),u=t[n],p=t[l],m=t[s].sub(u).unit(),g=p.sub(u).unit(),x=g.angleWithSep(m.x,m.y),v=m.add(g).unit().mult(-1*e/Math.sin(x/2));r.push(u.add(v))}return r},a.cacheEntryPossiblyAdded=function(t){hs++,hs>pa&&(t.getActor().send("enforceCacheSizeLimit",dl),hs=0)},a.calculateGlobeMatrix=rp,a.calculateGlobeMercatorMatrix=function(t){let e=t.worldSize,r=mt(t.center.lat,-85.051129,$r),n=new Ce(Hs(t.center.lng)*e,Ks(r)*e),s=Er(1,t.center.lat)*e,l=t.pixelsPerMeter,u=e/(s/t.pixelsPerMeter),p=ui(new Float64Array(16));return pr(p,p,[n.x,n.y,0]),Ai(p,p,[u,u,l]),p},a.clamp=mt,a.clearTileCache=function(t){let e=me.caches.delete(ti);t&&e.catch(t).then(()=>t())},a.clipLine=wd,a.clone=function(t){var e=new Dt(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},a.clone$1=ki,a.collisionCircleLayout=Df,a.config=S,a.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},a.create=function(){var t=new Dt(16);return Dt!=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},a.create$1=so,a.createExpression=Uo,a.createLayout=Pt,a.createStyleLayer=function(t){return t.type==="custom"?new _m(t):new ym[t.type](t)},a.cross=wn,a.degToRad=Je,a.div=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},a.dot=er,a.ease=mo,a.easeCubicInOut=po,a.emitValidationErrors=Hl,a.endsWith=Mn,a.enforceCacheSizeLimit=function(t){xo(),nr&&nr.then(e=>{e.keys().then(r=>{for(let n=0;n<r.length-t;n++)e.delete(r[n])})})},a.evaluateSizeForFeature=_c,a.evaluateSizeForZoom=ta,a.evaluateVariableOffset=Md,a.evented=fi,a.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},a.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},a.exported=vi,a.exported$1=C,a.extend=Lt,a.extend$1=Br,a.filterObject=An,a.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},a.fromQuat=function(t,e){var r=e[0],n=e[1],s=e[2],l=e[3],u=r+r,p=n+n,m=s+s,g=r*u,x=n*u,v=n*p,b=s*u,I=s*p,A=s*m,k=l*u,D=l*p,U=l*m;return t[0]=1-v-A,t[1]=x+U,t[2]=b-D,t[3]=0,t[4]=x-U,t[5]=1-g-A,t[6]=I+k,t[7]=0,t[8]=b+D,t[9]=I-k,t[10]=1-g-v,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},a.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},a.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},a.furthestTileCorner=function(t){let e=Math.round((t+45+360)%360/90)%4;return tn[e]},a.getAABBPointSquareDist=function(t,e,r){let n=0;for(let s=0;s<2;++s){let l=r?r[s]:0;t[s]>l&&(n+=(t[s]-l)*(t[s]-l)),e[s]<l&&(n+=(l-e[s])*(l-e[s]))}return n},a.getAnchorAlignment=Dh,a.getAnchorJustification=Rh,a.getBounds=function(t){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let l of t)e=Math.min(e,l.x),r=Math.min(r,l.y),n=Math.max(n,l.x),s=Math.max(s,l.y);return{min:new Ce(e,r),max:new Ce(n,s)}},a.getColumn=function(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]},a.getImage=fl,a.getJSON=function(t,e){return Zi(Lt(t,{type:"json"}),e)},a.getMapSessionAPI=Pr,a.getPerformanceMeasurement=Bd,a.getProjection=function(t){let e=cp[t.name];if(!e)throw new Error(`Invalid projection name: ${t.name}`);return e.conic?function(r,n){if(n.parallels&&Math.abs(n.parallels[0]+n.parallels[1])<.01){let s=function(l){let u=Math.max(.01,Math.cos(Je(l))),p=1/(2*Math.max(Math.PI*u,1/u));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(m,g){let x=Je(m)*u,v=Math.sin(Je(g))/u;return{x:x*p+.5,y:-v*p+.5,z:0}},unproject(m,g){let x=-(g-.5)/p,v=mt(xi((m-.5)/p)/u,-180,180),b=Math.asin(mt(x*u,-1,1)),I=mt(xi(b),-85.051129,$r);return new _t(v,I)}}}(n.parallels[0]);if(n.name==="lambertConformalConic"){let{project:l,unproject:u}=cp.mercator;s={wrap:!0,supportsWorldCopies:!0,project:l,unproject:u}}return Lt({},r,n,s)}return Lt({},r,n)}(e,t):e},a.getRTLTextPluginStatus=Fi,a.getReferrer=ma,a.getTilePoint=function(t,{x:e,y:r},n=0){return new Ce(((e-n)*t.scale-t.x)*Qe,(r*t.scale-t.y)*Qe)},a.getTileVec3=function(t,e,r=0){return fr(((e.x-r)*t.scale-t.x)*Qe,(e.y*t.scale-t.y)*Qe,zu(e.z,e.y))},a.getVideo=function(t,e){let r=me.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let n=0;n<t.length;n++){let s=me.document.createElement("source");pl(t[n])||(r.crossOrigin="Anonymous"),s.src=t[n],r.appendChild(s)}return{cancel:()=>{}}},a.globeBuffersForTileMesh=function(t,e,r,n){let s=t.context,l=t.transform,u=e.globeGridBuffer,p=e.globePoleBuffer;if(!u){let m=Qh.createGridVertices(r.canonical);u=e.globeGridBuffer=s.createVertexBuffer(m,Qd,!1)}if(!p){let m=Qh.createPoleTriangleVertices(n,l.tileSize*n,r.canonical.y===0);p=e.globePoleBuffer=s.createVertexBuffer(m,Qd,!1)}return[u,p]},a.globeDenormalizeECEF=ip,a.globeMatrixForTile=function(t,e){let r=ip(kc(t)),n=((s=new Float64Array(16))[0]=(l=e)[0],s[1]=l[1],s[2]=l[2],s[3]=l[3],s[4]=l[4],s[5]=l[5],s[6]=l[6],s[7]=l[7],s[8]=l[8],s[9]=l[9],s[10]=l[10],s[11]=l[11],s[12]=l[12],s[13]=l[13],s[14]=l[14],s[15]=l[15],s);var s,l;return Yr(n,n,r),n},a.globePoleMatrixForTile=function(t,e,r){let n=ui(new Float64Array(16)),s=Math.pow(2,t.z),l=(t.x-s/2)/s*Math.PI*2,u=r.point,p=r.worldSize/(r.tileSize*s);return pr(n,n,[u.x,u.y,-r.worldSize/Math.PI/2]),Ai(n,n,[p,p,p]),yn(n,n,Je(-r._center.lat)),Ji(n,n,Je(-r._center.lng)),Ji(n,n,l),e&&Ai(n,n,[1,-1,1]),n},a.globeTileBounds=kc,a.globeToMercatorTransition=function(t){return Cr(5,6,t)},a.identity=ui,a.identity$1=ns,a.invert=function(t,e){var r=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],g=e[7],x=e[8],v=e[9],b=e[10],I=e[11],A=e[12],k=e[13],D=e[14],U=e[15],$=r*p-n*u,H=r*m-s*u,Y=r*g-l*u,J=n*m-s*p,Q=n*g-l*p,he=s*g-l*m,le=x*k-v*A,Se=x*D-b*A,be=x*U-I*A,ce=v*D-b*k,we=v*U-I*k,Ie=b*U-I*D,fe=$*Ie-H*we+Y*ce+J*be-Q*Se+he*le;return fe?(t[0]=(p*Ie-m*we+g*ce)*(fe=1/fe),t[1]=(s*we-n*Ie-l*ce)*fe,t[2]=(k*he-D*Q+U*J)*fe,t[3]=(b*Q-v*he-I*J)*fe,t[4]=(m*be-u*Ie-g*Se)*fe,t[5]=(r*Ie-s*be+l*Se)*fe,t[6]=(D*Y-A*he-U*H)*fe,t[7]=(x*he-b*Y+I*H)*fe,t[8]=(u*we-p*be+g*le)*fe,t[9]=(n*be-r*we-l*le)*fe,t[10]=(A*Q-k*Y+U*$)*fe,t[11]=(v*Y-x*Q-I*$)*fe,t[12]=(p*Se-u*ce-m*le)*fe,t[13]=(r*ce-n*Se+s*le)*fe,t[14]=(k*H-A*J-D*$)*fe,t[15]=(x*J-v*H+b*$)*fe,t):null},a.isMapAuthenticated=function(t){return gr.has(t)},a.isMapboxURL=ue,a.latFromMercatorY=hr,a.len=Tn,a.length=is,a.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},a.loadVectorTile=sp,a.makeRequest=Zi,a.mercatorXfromLng=Hs,a.mercatorYfromLat=Ks,a.mercatorZfromAltitude=Er,a.mul=Yr,a.mul$1=da,a.multiply=function(t,e,r){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],b=r[0],I=r[1],A=r[2],k=r[3],D=r[4],U=r[5],$=r[6],H=r[7],Y=r[8];return t[0]=b*n+I*u+A*g,t[1]=b*s+I*p+A*x,t[2]=b*l+I*m+A*v,t[3]=k*n+D*u+U*g,t[4]=k*s+D*p+U*x,t[5]=k*l+D*m+U*v,t[6]=$*n+H*u+Y*g,t[7]=$*s+H*p+Y*x,t[8]=$*l+H*m+Y*v,t},a.multiply$1=ao,a.multiply$2=vn,a.nextPowerOfTwo=zi,a.normalize=bn,a.normalize$1=function(t,e){var r=e[0],n=e[1],s=e[2],l=e[3],u=r*r+n*n+s*s+l*l;return u>0&&(u=1/Math.sqrt(u)),t[0]=r*u,t[1]=n*u,t[2]=s*u,t[3]=l*u,t},a.number=pt,a.ortho=function(t,e,r,n,s,l,u){var p=1/(e-r),m=1/(n-s),g=1/(l-u);return t[0]=-2*p,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*m,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*g,t[11]=0,t[12]=(e+r)*p,t[13]=(s+n)*m,t[14]=(u+l)*g,t[15]=1,t},a.pbf=tl,a.perspective=function(t,e,r,n,s){var l,u=1/Math.tan(e/2);return t[0]=u/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0?(t[10]=(s+n)*(l=1/(n-s)),t[14]=2*s*n*l):(t[10]=-1,t[14]=-2*n),t},a.pick=function(t,e){let r={};for(let n=0;n<e.length;n++){let s=e[n];s in t&&(r[s]=t[s])}return r},a.plugin=ot,a.pointGeometry=Ce,a.polygonIntersectsBox=Ru,a.polygonIntersectsPolygon=Pu,a.polygonizeBounds=function(t,e,r=0,n=!0){let s=new Ce(r,r),l=t.sub(s),u=e.add(s),p=[l,new Ce(u.x,l.y),u,new Ce(l.x,u.y)];return n&&p.push(l),p},a.posAttributes=Sm,a.postMapLoadEvent=yt,a.postTurnstileEvent=wt,a.potpack=Ch,a.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},a.radToDeg=xi,a.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],a.registerForPluginStateChange=function(t){return t({pluginStatus:je,pluginURL:Ye}),fi.on("pluginStateChange",t),t},a.removeAuthState=function(t){gr.delete(t)},a.renderColorRamp=xh,a.rotateX=yn,a.rotateX$1=os,a.rotateY=Ji,a.rotateZ=function(t,e,r){var n=Math.sin(r),s=Math.cos(r),l=e[0],u=e[1],p=e[2],m=e[3],g=e[4],x=e[5],v=e[6],b=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]=l*s+g*n,t[1]=u*s+x*n,t[2]=p*s+v*n,t[3]=m*s+b*n,t[4]=g*s-l*n,t[5]=x*s-u*n,t[6]=v*s-p*n,t[7]=b*s-m*n,t},a.rotateZ$1=function(t,e,r){r*=.5;var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(r),m=Math.cos(r);return t[0]=n*m+s*p,t[1]=s*m-n*p,t[2]=l*m+u*p,t[3]=u*m-l*p,t},a.scale=Ai,a.scale$1=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},a.scale$2=Qi,a.scaleAndAdd=Ci,a.setCacheLimits=function(t,e){dl=t,pa=e},a.setColumn=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3]},a.setRTLTextPlugin=function(t,e,r=!1){if(je===Re||je===Ge||je===ft)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ye=vi.resolveURL(t),je=Re,xt=e,$t(),r||Wi()},a.smoothstep=Cr,a.spec=se,a.storeAuthState=function(t,e){e?gr.add(t):gr.delete(t)},a.sub=en,a.subtract=xn,a.symbolSize=Lf,a.tileAABB=function(t,e,r,n,s,l,u,p,m){if(m.name==="globe"){let I=kc(new Zh(l,new Mc(r,n,s)).canonical).getCorners(),A=Number.MAX_VALUE,k=[-A,-A,-A],D=[A,A,A],U=rp(t,e);for(let $=0;$<I.length;$++)nt(I[$],I[$],U),x=D,v=I[$],(g=D)[0]=Math.min(x[0],v[0]),g[1]=Math.min(x[1],v[1]),g[2]=Math.min(x[2],v[2]),ua(k,k,I[$]);return new Sr(D,k)}var g,x,v;let b=la({z:r,x:n,y:s},m);return new Sr([(l+b.x/b.scale)*e,e*(b.y/b.scale),u],[(l+b.x2/b.scale)*e,e*(b.y2/b.scale),p])},a.tileTransform=la,a.transformMat3=function(t,e,r){var n=e[0],s=e[1],l=e[2];return t[0]=n*r[0]+s*r[3]+l*r[6],t[1]=n*r[1]+s*r[4]+l*r[7],t[2]=n*r[2]+s*r[5]+l*r[8],t},a.transformMat4=nt,a.transformMat4$1=tr,a.transformQuat=rs,a.translate=pr,a.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},a.triggerPluginCompletionEvent=It,a.uniqueId=go,a.validateCustomStyleLayer=function(t){let e=[],r=t.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),t.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&t.renderingMode!=="2d"&&t.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},a.validateFog=Hc,a.validateLight=$n,a.validateStyle=Zn,a.values=Sn,a.vectorTile=Yo,a.version=ji,a.warnOnce=zt,a.window=me,a.wrap=mr}),Rc(["./shared"],function(a){"use strict";function ji(O){let S=typeof O;if(S==="number"||S==="boolean"||S==="string"||O==null)return JSON.stringify(O);if(Array.isArray(O)){let V="[";for(let W of O)V+=`${ji(W)},`;return`${V}]`}let C=Object.keys(O).sort(),F="{";for(let V=0;V<C.length;V++)F+=`${JSON.stringify(C[V])}:${ji(O[C[V]])},`;return`${F}}`}function Ar(O){let S="";for(let C of a.refProperties)S+=`/${ji(O[C])}`;return S}class yi{constructor(S){this.keyCache={},S&&this.replace(S)}replace(S){this._layerConfigs={},this._layers={},this.update(S,[])}update(S,C){for(let V of S)this._layerConfigs[V.id]=V,(this._layers[V.id]=a.createStyleLayer(V)).compileFilter(),this.keyCache[V.id]&&delete this.keyCache[V.id];for(let V of C)delete this.keyCache[V],delete this._layerConfigs[V],delete this._layers[V];this.familiesBySource={};let F=function(V,W){let ee={};for(let K=0;K<V.length;K++){let re=W&&W[V[K].id]||Ar(V[K]);W&&(W[V[K].id]=re);let ue=ee[re];ue||(ue=ee[re]=[]),ue.push(V[K])}let te=[];for(let K in ee)te.push(ee[K]);return te}(a.values(this._layerConfigs),this.keyCache);for(let V of F){let W=V.map(pe=>this._layers[pe.id]),ee=W[0];if(ee.visibility==="none")continue;let te=ee.source||"",K=this.familiesBySource[te];K||(K=this.familiesBySource[te]={});let re=ee.sourceLayer||"_geojsonTileLayer",ue=K[re];ue||(ue=K[re]=[]),ue.push(W)}}}let{ImageBitmap:Ce}=a.window;class qe{loadTile(S,C){let{uid:F,encoding:V,rawImageData:W,padding:ee,buildQuadTree:te}=S,K=Ce&&W instanceof Ce?this.getImageData(W,ee):W;C(null,new a.DEMData(F,K,V,ee<1,te))}getImageData(S,C){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(S.width,S.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=S.width,this.offscreenCanvas.height=S.height,this.offscreenCanvasContext.drawImage(S,0,0,S.width,S.height);let F=this.offscreenCanvasContext.getImageData(-C,-C,S.width+2*C,S.height+2*C);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:F.width,height:F.height},F.data)}}var me=function O(S,C){var F,V=S&&S.type;if(V==="FeatureCollection")for(F=0;F<S.features.length;F++)O(S.features[F],C);else if(V==="GeometryCollection")for(F=0;F<S.geometries.length;F++)O(S.geometries[F],C);else if(V==="Feature")O(S.geometry,C);else if(V==="Polygon")Mi(S.coordinates,C);else if(V==="MultiPolygon")for(F=0;F<S.coordinates.length;F++)Mi(S.coordinates[F],C);return S};function Mi(O,S){if(O.length!==0){Dt(O[0],S);for(var C=1;C<O.length;C++)Dt(O[C],!S)}}function Dt(O,S){for(var C=0,F=0,V=0,W=O.length,ee=W-1;V<W;ee=V++){var te=(O[V][0]-O[ee][0])*(O[ee][1]+O[V][1]),K=C+te;F+=Math.abs(C)>=Math.abs(te)?C-K+te:te-K+C,C=K}C+F>=0!=!!S&&O.reverse()}let so=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class ui{constructor(S){this._feature=S,this.extent=a.EXTENT,this.type=S.type,this.properties=S.tags,"id"in S&&!isNaN(S.id)&&(this.id=parseInt(S.id,10))}loadGeometry(){if(this._feature.type===1){let S=[];for(let C of this._feature.geometry)S.push([new a.pointGeometry(C[0],C[1])]);return S}{let S=[];for(let C of this._feature.geometry){let F=[];for(let V of C)F.push(new a.pointGeometry(V[0],V[1]));S.push(F)}return S}}toGeoJSON(S,C,F){return so.call(this,S,C,F)}}class ao{constructor(S){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=S.length,this._features=S}feature(S){return new ui(this._features[S])}}var pr=a.vectorTile.VectorTileFeature,Ai=yn;function yn(O,S){this.options=S||{},this.features=O,this.length=O.length}function Ji(O,S){this.id=typeof O.id=="number"?O.id:void 0,this.type=O.type,this.rawGeometry=O.type===1?[O.geometry]:O.geometry,this.properties=O.tags,this.extent=S||4096}yn.prototype.feature=function(O){return new Ji(this.features[O],this.options.extent)},Ji.prototype.loadGeometry=function(){var O=this.rawGeometry;this.geometry=[];for(var S=0;S<O.length;S++){for(var C=O[S],F=[],V=0;V<C.length;V++)F.push(new a.pointGeometry(C[V][0],C[V][1]));this.geometry.push(F)}return this.geometry},Ji.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var O=this.geometry,S=1/0,C=-1/0,F=1/0,V=-1/0,W=0;W<O.length;W++)for(var ee=O[W],te=0;te<ee.length;te++){var K=ee[te];S=Math.min(S,K.x),C=Math.max(C,K.x),F=Math.min(F,K.y),V=Math.max(V,K.y)}return[S,F,C,V]},Ji.prototype.toGeoJSON=pr.prototype.toGeoJSON;var Yr=Jr,lo=Ai;function Jr(O){var S=new a.pbf;return function(C,F){for(var V in C.layers)F.writeMessage(3,is,C.layers[V])}(O,S),S.finish()}function is(O,S){var C;S.writeVarintField(15,O.version||1),S.writeStringField(1,O.name||""),S.writeVarintField(5,O.extent||4096);var F={keys:[],values:[],keycache:{},valuecache:{}};for(C=0;C<O.length;C++)F.feature=O.feature(C),S.writeMessage(2,fr,F);var V=F.keys;for(C=0;C<V.length;C++)S.writeStringField(3,V[C]);var W=F.values;for(C=0;C<W.length;C++)S.writeMessage(4,Qi,W[C])}function fr(O,S){var C=O.feature;C.id!==void 0&&S.writeVarintField(1,C.id),S.writeMessage(2,co,O),S.writeVarintField(3,C.type),S.writeMessage(4,ua,C)}function co(O,S){var C=O.feature,F=O.keys,V=O.values,W=O.keycache,ee=O.valuecache;for(var te in C.properties){var K=C.properties[te],re=W[te];if(K!==null){re===void 0&&(F.push(te),W[te]=re=F.length-1),S.writeVarint(re);var ue=typeof K;ue!=="string"&&ue!=="boolean"&&ue!=="number"&&(K=JSON.stringify(K));var pe=ue+":"+K,ye=ee[pe];ye===void 0&&(V.push(K),ee[pe]=ye=V.length-1),S.writeVarint(ye)}}}function xn(O,S){return(S<<3)+(7&O)}function vn(O){return O<<1^O>>31}function ua(O,S){for(var C=O.loadGeometry(),F=O.type,V=0,W=0,ee=C.length,te=0;te<ee;te++){var K=C[te],re=1;F===1&&(re=K.length),S.writeVarint(xn(1,re));for(var ue=F===3?K.length-1:K.length,pe=0;pe<ue;pe++){pe===1&&F!==1&&S.writeVarint(xn(2,ue-1));var ye=K[pe].x-V,Le=K[pe].y-W;S.writeVarint(vn(ye)),S.writeVarint(vn(Le)),V+=ye,W+=Le}F===3&&S.writeVarint(xn(7,1))}}function Qi(O,S){var C=typeof O;C==="string"?S.writeStringField(1,O):C==="boolean"?S.writeBooleanField(7,O):C==="number"&&(O%1!=0?S.writeDoubleField(3,O):O<0?S.writeSVarintField(6,O):S.writeVarintField(5,O))}function Ci(O,S,C,F,V,W){if(V-F<=C)return;let ee=F+V>>1;bn(O,S,ee,F,V,W%2),Ci(O,S,C,F,ee-1,W+1),Ci(O,S,C,ee+1,V,W+1)}function bn(O,S,C,F,V,W){for(;V>F;){if(V-F>600){let re=V-F+1,ue=C-F+1,pe=Math.log(re),ye=.5*Math.exp(2*pe/3),Le=.5*Math.sqrt(pe*ye*(re-ye)/re)*(ue-re/2<0?-1:1);bn(O,S,C,Math.max(F,Math.floor(C-ue*ye/re+Le)),Math.min(V,Math.floor(C+(re-ue)*ye/re+Le)),W)}let ee=S[2*C+W],te=F,K=V;for(er(O,S,F,C),S[2*V+W]>ee&&er(O,S,F,V);te<K;){for(er(O,S,te,K),te++,K--;S[2*te+W]<ee;)te++;for(;S[2*K+W]>ee;)K--}S[2*F+W]===ee?er(O,S,F,K):(K++,er(O,S,K,V)),K<=C&&(F=K+1),C<=K&&(V=K-1)}}function er(O,S,C,F){wn(O,C,F),wn(S,2*C,2*F),wn(S,2*C+1,2*F+1)}function wn(O,S,C){let F=O[S];O[S]=O[C],O[C]=F}function nt(O,S,C,F){let V=O-C,W=S-F;return V*V+W*W}Yr.fromVectorTileJs=Jr,Yr.fromGeojsonVt=function(O,S){S=S||{};var C={};for(var F in O)C[F]=new Ai(O[F].features,S),C[F].name=F,C[F].version=S.version,C[F].extent=S.extent;return Jr({layers:C})},Yr.GeoJSONWrapper=lo;let rs=O=>O[0],Qr=O=>O[1];class en{constructor(S,C=rs,F=Qr,V=64,W=Float64Array){this.nodeSize=V,this.points=S;let ee=S.length<65536?Uint16Array:Uint32Array,te=this.ids=new ee(S.length),K=this.coords=new W(2*S.length);for(let re=0;re<S.length;re++)te[re]=re,K[2*re]=C(S[re]),K[2*re+1]=F(S[re]);Ci(te,K,V,0,te.length-1,0)}range(S,C,F,V){return function(W,ee,te,K,re,ue,pe){let ye=[0,W.length-1,0],Le=[],Oe,Ue;for(;ye.length;){let Ne=ye.pop(),Ke=ye.pop(),wt=ye.pop();if(Ke-wt<=pe){for(let St=wt;St<=Ke;St++)Oe=ee[2*St],Ue=ee[2*St+1],Oe>=te&&Oe<=re&&Ue>=K&&Ue<=ue&&Le.push(W[St]);continue}let Et=Math.floor((wt+Ke)/2);Oe=ee[2*Et],Ue=ee[2*Et+1],Oe>=te&&Oe<=re&&Ue>=K&&Ue<=ue&&Le.push(W[Et]);let yt=(Ne+1)%2;(Ne===0?te<=Oe:K<=Ue)&&(ye.push(wt),ye.push(Et-1),ye.push(yt)),(Ne===0?re>=Oe:ue>=Ue)&&(ye.push(Et+1),ye.push(Ke),ye.push(yt))}return Le}(this.ids,this.coords,S,C,F,V,this.nodeSize)}within(S,C,F){return function(V,W,ee,te,K,re){let ue=[0,V.length-1,0],pe=[],ye=K*K;for(;ue.length;){let Le=ue.pop(),Oe=ue.pop(),Ue=ue.pop();if(Oe-Ue<=re){for(let yt=Ue;yt<=Oe;yt++)nt(W[2*yt],W[2*yt+1],ee,te)<=ye&&pe.push(V[yt]);continue}let Ne=Math.floor((Ue+Oe)/2),Ke=W[2*Ne],wt=W[2*Ne+1];nt(Ke,wt,ee,te)<=ye&&pe.push(V[Ne]);let Et=(Le+1)%2;(Le===0?ee-K<=Ke:te-K<=wt)&&(ue.push(Ue),ue.push(Ne-1),ue.push(Et)),(Le===0?ee+K>=Ke:te+K>=wt)&&(ue.push(Ne+1),ue.push(Oe),ue.push(Et))}return pe}(this.ids,this.coords,S,C,F,this.nodeSize)}}let da={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:O=>O},Tn=Math.fround||(tr=new Float32Array(1),O=>(tr[0]=+O,tr[0]));var tr;class ho{constructor(S){this.options=tn(Object.create(da),S),this.trees=new Array(this.options.maxZoom+1)}load(S){let{log:C,minZoom:F,maxZoom:V,nodeSize:W}=this.options;C&&console.time("total time");let ee=`prepare ${S.length} points`;C&&console.time(ee),this.points=S;let te=[];for(let K=0;K<S.length;K++)S[K].geometry&&te.push(os(S[K],K));this.trees[V+1]=new en(te,po,fo,W,Float32Array),C&&console.timeEnd(ee);for(let K=V;K>=F;K--){let re=+Date.now();te=this._cluster(te,K),this.trees[K]=new en(te,po,fo,W,Float32Array),C&&console.log("z%d: %d clusters in %dms",K,te.length,+Date.now()-re)}return C&&console.timeEnd("total time"),this}getClusters(S,C){let F=((S[0]+180)%360+360)%360-180,V=Math.max(-90,Math.min(90,S[1])),W=S[2]===180?180:((S[2]+180)%360+360)%360-180,ee=Math.max(-90,Math.min(90,S[3]));if(S[2]-S[0]>=360)F=-180,W=180;else if(F>W){let ue=this.getClusters([F,V,180,ee],C),pe=this.getClusters([-180,V,W,ee],C);return ue.concat(pe)}let te=this.trees[this._limitZoom(C)],K=te.range(En(F),Je(ee),En(W),Je(V)),re=[];for(let ue of K){let pe=te.points[ue];re.push(pe.numPoints?uo(pe):this.points[pe.index])}return re}getChildren(S){let C=this._getOriginId(S),F=this._getOriginZoom(S),V="No cluster with the specified id.",W=this.trees[F];if(!W)throw new Error(V);let ee=W.points[C];if(!ee)throw new Error(V);let te=this.options.radius/(this.options.extent*Math.pow(2,F-1)),K=W.within(ee.x,ee.y,te),re=[];for(let ue of K){let pe=W.points[ue];pe.parentId===S&&re.push(pe.numPoints?uo(pe):this.points[pe.index])}if(re.length===0)throw new Error(V);return re}getLeaves(S,C,F){let V=[];return this._appendLeaves(V,S,C=C||10,F=F||0,0),V}getTile(S,C,F){let V=this.trees[this._limitZoom(S)],W=Math.pow(2,S),{extent:ee,radius:te}=this.options,K=te/ee,re=(F-K)/W,ue=(F+1+K)/W,pe={features:[]};return this._addTileFeatures(V.range((C-K)/W,re,(C+1+K)/W,ue),V.points,C,F,W,pe),C===0&&this._addTileFeatures(V.range(1-K/W,re,1,ue),V.points,W,F,W,pe),C===W-1&&this._addTileFeatures(V.range(0,re,K/W,ue),V.points,-1,F,W,pe),pe.features.length?pe:null}getClusterExpansionZoom(S){let C=this._getOriginZoom(S)-1;for(;C<=this.options.maxZoom;){let F=this.getChildren(S);if(C++,F.length!==1)break;S=F[0].properties.cluster_id}return C}_appendLeaves(S,C,F,V,W){let ee=this.getChildren(C);for(let te of ee){let K=te.properties;if(K&&K.cluster?W+K.point_count<=V?W+=K.point_count:W=this._appendLeaves(S,K.cluster_id,F,V,W):W<V?W++:S.push(te),S.length===F)break}return W}_addTileFeatures(S,C,F,V,W,ee){for(let te of S){let K=C[te],re=K.numPoints,ue,pe,ye;if(re)ue=ss(K),pe=K.x,ye=K.y;else{let Ue=this.points[K.index];ue=Ue.properties,pe=En(Ue.geometry.coordinates[0]),ye=Je(Ue.geometry.coordinates[1])}let Le={type:1,geometry:[[Math.round(this.options.extent*(pe*W-F)),Math.round(this.options.extent*(ye*W-V))]],tags:ue},Oe;re?Oe=K.id:this.options.generateId?Oe=K.index:this.points[K.index].id&&(Oe=this.points[K.index].id),Oe!==void 0&&(Le.id=Oe),ee.features.push(Le)}}_limitZoom(S){return Math.max(this.options.minZoom,Math.min(+S,this.options.maxZoom+1))}_cluster(S,C){let F=[],{radius:V,extent:W,reduce:ee,minPoints:te}=this.options,K=V/(W*Math.pow(2,C));for(let re=0;re<S.length;re++){let ue=S[re];if(ue.zoom<=C)continue;ue.zoom=C;let pe=this.trees[C+1],ye=pe.within(ue.x,ue.y,K),Le=ue.numPoints||1,Oe=Le;for(let Ue of ye){let Ne=pe.points[Ue];Ne.zoom>C&&(Oe+=Ne.numPoints||1)}if(Oe>Le&&Oe>=te){let Ue=ue.x*Le,Ne=ue.y*Le,Ke=ee&&Le>1?this._map(ue,!0):null,wt=(re<<5)+(C+1)+this.points.length;for(let Et of ye){let yt=pe.points[Et];if(yt.zoom<=C)continue;yt.zoom=C;let St=yt.numPoints||1;Ue+=yt.x*St,Ne+=yt.y*St,yt.parentId=wt,ee&&(Ke||(Ke=this._map(ue,!0)),ee(Ke,this._map(yt)))}ue.parentId=wt,F.push(ns(Ue/Oe,Ne/Oe,wt,Oe,Ke))}else if(F.push(ue),Oe>1)for(let Ue of ye){let Ne=pe.points[Ue];Ne.zoom<=C||(Ne.zoom=C,F.push(Ne))}}return F}_getOriginId(S){return S-this.points.length>>5}_getOriginZoom(S){return(S-this.points.length)%32}_map(S,C){if(S.numPoints)return C?tn({},S.properties):S.properties;let F=this.points[S.index].properties,V=this.options.map(F);return C&&V===F?tn({},V):V}}function ns(O,S,C,F,V){return{x:Tn(O),y:Tn(S),zoom:1/0,id:C,parentId:-1,numPoints:F,properties:V}}function os(O,S){let[C,F]=O.geometry.coordinates;return{x:Tn(En(C)),y:Tn(Je(F)),zoom:1/0,index:S,parentId:-1}}function uo(O){return{type:"Feature",id:O.id,properties:ss(O),geometry:{type:"Point",coordinates:[(S=O.x,360*(S-.5)),xi(O.y)]}};var S}function ss(O){let S=O.numPoints,C=S>=1e4?`${Math.round(S/1e3)}k`:S>=1e3?Math.round(S/100)/10+"k":S;return tn(tn({},O.properties),{cluster:!0,cluster_id:O.id,point_count:S,point_count_abbreviated:C})}function En(O){return O/360+.5}function Je(O){let S=Math.sin(O*Math.PI/180),C=.5-.25*Math.log((1+S)/(1-S))/Math.PI;return C<0?0:C>1?1:C}function xi(O){let S=(180-360*O)*Math.PI/180;return 360*Math.atan(Math.exp(S))/Math.PI-90}function tn(O,S){for(let C in S)O[C]=S[C];return O}function po(O){return O.x}function fo(O){return O.y}function mo(O,S,C,F){for(var V,W=F,ee=C-S>>1,te=C-S,K=O[S],re=O[S+1],ue=O[C],pe=O[C+1],ye=S+3;ye<C;ye+=3){var Le=mt(O[ye],O[ye+1],K,re,ue,pe);if(Le>W)V=ye,W=Le;else if(Le===W){var Oe=Math.abs(ye-ee);Oe<te&&(V=ye,te=Oe)}}W>F&&(V-S>3&&mo(O,S,V,F),O[V+2]=W,C-V>3&&mo(O,V,C,F))}function mt(O,S,C,F,V,W){var ee=V-C,te=W-F;if(ee!==0||te!==0){var K=((O-C)*ee+(S-F)*te)/(ee*ee+te*te);K>1?(C=V,F=W):K>0&&(C+=ee*K,F+=te*K)}return(ee=O-C)*ee+(te=S-F)*te}function Cr(O,S,C,F){var V={id:O===void 0?null:O,type:S,geometry:C,tags:F,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(W){var ee=W.geometry,te=W.type;if(te==="Point"||te==="MultiPoint"||te==="LineString")mr(W,ee);else if(te==="Polygon"||te==="MultiLineString")for(var K=0;K<ee.length;K++)mr(W,ee[K]);else if(te==="MultiPolygon")for(K=0;K<ee.length;K++)for(var re=0;re<ee[K].length;re++)mr(W,ee[K][re])}(V),V}function mr(O,S){for(var C=0;C<S.length;C+=3)O.minX=Math.min(O.minX,S[C]),O.minY=Math.min(O.minY,S[C+1]),O.maxX=Math.max(O.maxX,S[C]),O.maxY=Math.max(O.maxY,S[C+1])}function rn(O,S,C,F){if(S.geometry){var V=S.geometry.coordinates,W=S.geometry.type,ee=Math.pow(C.tolerance/((1<<C.maxZoom)*C.extent),2),te=[],K=S.id;if(C.promoteId?K=S.properties[C.promoteId]:C.generateId&&(K=F||0),W==="Point")Sn(V,te);else if(W==="MultiPoint")for(var re=0;re<V.length;re++)Sn(V[re],te);else if(W==="LineString")Lt(V,te,ee,!1);else if(W==="MultiLineString"){if(C.lineMetrics){for(re=0;re<V.length;re++)Lt(V[re],te=[],ee,!1),O.push(Cr(K,"LineString",te,S.properties));return}_o(V,te,ee,!1)}else if(W==="Polygon")_o(V,te,ee,!0);else{if(W!=="MultiPolygon"){if(W==="GeometryCollection"){for(re=0;re<S.geometry.geometries.length;re++)rn(O,{id:K,geometry:S.geometry.geometries[re],properties:S.properties},C,F);return}throw new Error("Input data is not a valid GeoJSON object.")}for(re=0;re<V.length;re++){var ue=[];_o(V[re],ue,ee,!0),te.push(ue)}}O.push(Cr(K,W,te,S.properties))}}function Sn(O,S){S.push(go(O[0])),S.push(yo(O[1])),S.push(0)}function Lt(O,S,C,F){for(var V,W,ee=0,te=0;te<O.length;te++){var K=go(O[te][0]),re=yo(O[te][1]);S.push(K),S.push(re),S.push(0),te>0&&(ee+=F?(V*re-K*W)/2:Math.sqrt(Math.pow(K-V,2)+Math.pow(re-W,2))),V=K,W=re}var ue=S.length-3;S[2]=1,mo(S,0,ue,C),S[ue+2]=1,S.size=Math.abs(ee),S.start=0,S.end=S.size}function _o(O,S,C,F){for(var V=0;V<O.length;V++){var W=[];Lt(O[V],W,C,F),S.push(W)}}function go(O){return O/360+.5}function yo(O){var S=Math.sin(O*Math.PI/180),C=.5-.25*Math.log((1+S)/(1-S))/Math.PI;return C<0?0:C>1?1:C}function zi(O,S,C,F,V,W,ee,te){if(F/=S,W>=(C/=S)&&ee<F)return O;if(ee<C||W>=F)return null;for(var K=[],re=0;re<O.length;re++){var ue=O[re],pe=ue.geometry,ye=ue.type,Le=V===0?ue.minX:ue.minY,Oe=V===0?ue.maxX:ue.maxY;if(Le>=C&&Oe<F)K.push(ue);else if(!(Oe<C||Le>=F)){var Ue=[];if(ye==="Point"||ye==="MultiPoint")as(pe,Ue,C,F,V);else if(ye==="LineString")In(pe,Ue,C,F,V,!1,te.lineMetrics);else if(ye==="MultiLineString")zr(pe,Ue,C,F,V,!1);else if(ye==="Polygon")zr(pe,Ue,C,F,V,!0);else if(ye==="MultiPolygon")for(var Ne=0;Ne<pe.length;Ne++){var Ke=[];zr(pe[Ne],Ke,C,F,V,!0),Ke.length&&Ue.push(Ke)}if(Ue.length){if(te.lineMetrics&&ye==="LineString"){for(Ne=0;Ne<Ue.length;Ne++)K.push(Cr(ue.id,ye,Ue[Ne],ue.tags));continue}ye!=="LineString"&&ye!=="MultiLineString"||(Ue.length===1?(ye="LineString",Ue=Ue[0]):ye="MultiLineString"),ye!=="Point"&&ye!=="MultiPoint"||(ye=Ue.length===3?"Point":"MultiPoint"),K.push(Cr(ue.id,ye,Ue,ue.tags))}}}return K.length?K:null}function as(O,S,C,F,V){for(var W=0;W<O.length;W+=3){var ee=O[W+V];ee>=C&&ee<=F&&(S.push(O[W]),S.push(O[W+1]),S.push(O[W+2]))}}function In(O,S,C,F,V,W,ee){for(var te,K,re=Mn(O),ue=V===0?ki:ls,pe=O.start,ye=0;ye<O.length-3;ye+=3){var Le=O[ye],Oe=O[ye+1],Ue=O[ye+2],Ne=O[ye+3],Ke=O[ye+4],wt=V===0?Le:Oe,Et=V===0?Ne:Ke,yt=!1;ee&&(te=Math.sqrt(Math.pow(Le-Ne,2)+Math.pow(Oe-Ke,2))),wt<C?Et>C&&(K=ue(re,Le,Oe,Ne,Ke,C),ee&&(re.start=pe+te*K)):wt>F?Et<F&&(K=ue(re,Le,Oe,Ne,Ke,F),ee&&(re.start=pe+te*K)):An(re,Le,Oe,Ue),Et<C&&wt>=C&&(K=ue(re,Le,Oe,Ne,Ke,C),yt=!0),Et>F&&wt<=F&&(K=ue(re,Le,Oe,Ne,Ke,F),yt=!0),!W&&yt&&(ee&&(re.end=pe+te*K),S.push(re),re=Mn(O)),ee&&(pe+=te)}var St=O.length-3;Le=O[St],Oe=O[St+1],Ue=O[St+2],(wt=V===0?Le:Oe)>=C&&wt<=F&&An(re,Le,Oe,Ue),St=re.length-3,W&&St>=3&&(re[St]!==re[0]||re[St+1]!==re[1])&&An(re,re[0],re[1],re[2]),re.length&&S.push(re)}function Mn(O){var S=[];return S.size=O.size,S.start=O.start,S.end=O.end,S}function zr(O,S,C,F,V,W){for(var ee=0;ee<O.length;ee++)In(O[ee],S,C,F,V,W,!1)}function An(O,S,C,F){O.push(S),O.push(C),O.push(F)}function ki(O,S,C,F,V,W){var ee=(W-S)/(F-S);return O.push(W),O.push(C+(V-C)*ee),O.push(1),ee}function ls(O,S,C,F,V,W){var ee=(W-C)/(V-C);return O.push(S+(F-S)*ee),O.push(W),O.push(1),ee}function zt(O,S){for(var C=[],F=0;F<O.length;F++){var V,W=O[F],ee=W.type;if(ee==="Point"||ee==="MultiPoint"||ee==="LineString")V=Pi(W.geometry,S);else if(ee==="MultiLineString"||ee==="Polygon"){V=[];for(var te=0;te<W.geometry.length;te++)V.push(Pi(W.geometry[te],S))}else if(ee==="MultiPolygon")for(V=[],te=0;te<W.geometry.length;te++){for(var K=[],re=0;re<W.geometry[te].length;re++)K.push(Pi(W.geometry[te][re],S));V.push(K)}C.push(Cr(W.id,ee,V,W.tags))}return C}function Pi(O,S){var C=[];C.size=O.size,O.start!==void 0&&(C.start=O.start,C.end=O.end);for(var F=0;F<O.length;F+=3)C.push(O[F]+S,O[F+1],O[F+2]);return C}function Cn(O,S){if(O.transformed)return O;var C,F,V,W=1<<O.z,ee=O.x,te=O.y;for(C=0;C<O.features.length;C++){var K=O.features[C],re=K.geometry,ue=K.type;if(K.geometry=[],ue===1)for(F=0;F<re.length;F+=2)K.geometry.push(ir(re[F],re[F+1],S,W,ee,te));else for(F=0;F<re.length;F++){var pe=[];for(V=0;V<re[F].length;V+=2)pe.push(ir(re[F][V],re[F][V+1],S,W,ee,te));K.geometry.push(pe)}}return O.transformed=!0,O}function ir(O,S,C,F,V,W){return[Math.round(C*(O*F-V)),Math.round(C*(S*F-W))]}function zn(O,S,C,F,V){for(var W=S===V.maxZoom?0:V.tolerance/((1<<S)*V.extent),ee={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:C,y:F,z:S,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},te=0;te<O.length;te++){ee.numFeatures++,nn(ee,O[te],W,V);var K=O[te].minX,re=O[te].minY,ue=O[te].maxX,pe=O[te].maxY;K<ee.minX&&(ee.minX=K),re<ee.minY&&(ee.minY=re),ue>ee.maxX&&(ee.maxX=ue),pe>ee.maxY&&(ee.maxY=pe)}return ee}function nn(O,S,C,F){var V=S.geometry,W=S.type,ee=[];if(W==="Point"||W==="MultiPoint")for(var te=0;te<V.length;te+=3)ee.push(V[te]),ee.push(V[te+1]),O.numPoints++,O.numSimplified++;else if(W==="LineString")_r(ee,V,O,C,!1,!1);else if(W==="MultiLineString"||W==="Polygon")for(te=0;te<V.length;te++)_r(ee,V[te],O,C,W==="Polygon",te===0);else if(W==="MultiPolygon")for(var K=0;K<V.length;K++){var re=V[K];for(te=0;te<re.length;te++)_r(ee,re[te],O,C,!0,te===0)}if(ee.length){var ue=S.tags||null;if(W==="LineString"&&F.lineMetrics){for(var pe in ue={},S.tags)ue[pe]=S.tags[pe];ue.mapbox_clip_start=V.start/V.size,ue.mapbox_clip_end=V.end/V.size}var ye={geometry:ee,type:W==="Polygon"||W==="MultiPolygon"?3:W==="LineString"||W==="MultiLineString"?2:1,tags:ue};S.id!==null&&(ye.id=S.id),O.features.push(ye)}}function _r(O,S,C,F,V,W){var ee=F*F;if(F>0&&S.size<(V?ee:F))C.numPoints+=S.length/3;else{for(var te=[],K=0;K<S.length;K+=3)(F===0||S[K+2]>ee)&&(C.numSimplified++,te.push(S[K]),te.push(S[K+1])),C.numPoints++;V&&function(re,ue){for(var pe=0,ye=0,Le=re.length,Oe=Le-2;ye<Le;Oe=ye,ye+=2)pe+=(re[ye]-re[Oe])*(re[ye+1]+re[Oe+1]);if(pe>0===ue)for(ye=0,Le=re.length;ye<Le/2;ye+=2){var Ue=re[ye],Ne=re[ye+1];re[ye]=re[Le-2-ye],re[ye+1]=re[Le-1-ye],re[Le-2-ye]=Ue,re[Le-1-ye]=Ne}}(te,W),O.push(te)}}function Gi(O,S){var C=(S=this.options=function(V,W){for(var ee in W)V[ee]=W[ee];return V}(Object.create(this.options),S)).debug;if(C&&console.time("preprocess data"),S.maxZoom<0||S.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(S.promoteId&&S.generateId)throw new Error("promoteId and generateId cannot be used together.");var F=function(V,W){var ee=[];if(V.type==="FeatureCollection")for(var te=0;te<V.features.length;te++)rn(ee,V.features[te],W,te);else rn(ee,V.type==="Feature"?V:{geometry:V},W);return ee}(O,S);this.tiles={},this.tileCoords=[],C&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",S.indexMaxZoom,S.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(F=function(V,W){var ee=W.buffer/W.extent,te=V,K=zi(V,1,-1-ee,ee,0,-1,2,W),re=zi(V,1,1-ee,2+ee,0,-1,2,W);return(K||re)&&(te=zi(V,1,-ee,1+ee,0,-1,2,W)||[],K&&(te=zt(K,1).concat(te)),re&&(te=te.concat(zt(re,-1)))),te}(F,S)).length&&this.splitTile(F,0,0,0),C&&(F.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function kr(O,S,C){return 32*((1<<O)*C+S)+O}function rr(O,S){let C=O.tileID.canonical;if(!this._geoJSONIndex)return S(null,null);let F=this._geoJSONIndex.getTile(C.z,C.x,C.y);if(!F)return S(null,null);let V=new ao(F.features),W=Yr(V);W.byteOffset===0&&W.byteLength===W.buffer.byteLength||(W=new Uint8Array(W)),S(null,{vectorTile:V,rawData:W.buffer})}Gi.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Gi.prototype.splitTile=function(O,S,C,F,V,W,ee){for(var te=[O,S,C,F],K=this.options,re=K.debug;te.length;){F=te.pop(),C=te.pop(),S=te.pop(),O=te.pop();var ue=1<<S,pe=kr(S,C,F),ye=this.tiles[pe];if(!ye&&(re>1&&console.time("creation"),ye=this.tiles[pe]=zn(O,S,C,F,K),this.tileCoords.push({z:S,x:C,y:F}),re)){re>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",S,C,F,ye.numFeatures,ye.numPoints,ye.numSimplified),console.timeEnd("creation"));var Le="z"+S;this.stats[Le]=(this.stats[Le]||0)+1,this.total++}if(ye.source=O,V){if(S===K.maxZoom||S===V)continue;var Oe=1<<V-S;if(C!==Math.floor(W/Oe)||F!==Math.floor(ee/Oe))continue}else if(S===K.indexMaxZoom||ye.numPoints<=K.indexMaxPoints)continue;if(ye.source=null,O.length!==0){re>1&&console.time("clipping");var Ue,Ne,Ke,wt,Et,yt,St=.5*K.buffer/K.extent,Pr=.5-St,gr=.5+St,ti=1+St;Ue=Ne=Ke=wt=null,Et=zi(O,ue,C-St,C+gr,0,ye.minX,ye.maxX,K),yt=zi(O,ue,C+Pr,C+ti,0,ye.minX,ye.maxX,K),O=null,Et&&(Ue=zi(Et,ue,F-St,F+gr,1,ye.minY,ye.maxY,K),Ne=zi(Et,ue,F+Pr,F+ti,1,ye.minY,ye.maxY,K),Et=null),yt&&(Ke=zi(yt,ue,F-St,F+gr,1,ye.minY,ye.maxY,K),wt=zi(yt,ue,F+Pr,F+ti,1,ye.minY,ye.maxY,K),yt=null),re>1&&console.timeEnd("clipping"),te.push(Ue||[],S+1,2*C,2*F),te.push(Ne||[],S+1,2*C,2*F+1),te.push(Ke||[],S+1,2*C+1,2*F),te.push(wt||[],S+1,2*C+1,2*F+1)}}},Gi.prototype.getTile=function(O,S,C){var F=this.options,V=F.extent,W=F.debug;if(O<0||O>24)return null;var ee=1<<O,te=kr(O,S=(S%ee+ee)%ee,C);if(this.tiles[te])return Cn(this.tiles[te],V);W>1&&console.log("drilling down to z%d-%d-%d",O,S,C);for(var K,re=O,ue=S,pe=C;!K&&re>0;)re--,ue=Math.floor(ue/2),pe=Math.floor(pe/2),K=this.tiles[kr(re,ue,pe)];return K&&K.source?(W>1&&console.log("found parent tile z%d-%d-%d",re,ue,pe),W>1&&console.time("drilling down"),this.splitTile(K.source,re,ue,pe,O,S,C),W>1&&console.timeEnd("drilling down"),this.tiles[te]?Cn(this.tiles[te],V):null):null};class kn extends a.VectorTileWorkerSource{constructor(S,C,F,V,W){super(S,C,F,V,rr),W&&(this.loadGeoJSON=W)}loadData(S,C){let F=S&&S.request,V=F&&F.collectResourceTiming;this.loadGeoJSON(S,(W,ee)=>{if(W||!ee)return C(W);if(typeof ee!="object")return C(new Error(`Input data given to '${S.source}' is not a valid GeoJSON object.`));{me(ee,!0);try{if(S.filter){let K=a.createExpression(S.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(K.result==="error")throw new Error(K.value.map(ue=>`${ue.key}: ${ue.message}`).join(", "));let re=ee.features.filter(ue=>K.value.evaluate({zoom:0},ue));ee={type:"FeatureCollection",features:re}}this._geoJSONIndex=S.cluster?new ho(function({superclusterOptions:K,clusterProperties:re}){if(!re||!K)return K;let ue={},pe={},ye={accumulated:null,zoom:0},Le={properties:null},Oe=Object.keys(re);for(let Ue of Oe){let[Ne,Ke]=re[Ue],wt=a.createExpression(Ke),Et=a.createExpression(typeof Ne=="string"?[Ne,["accumulated"],["get",Ue]]:Ne);ue[Ue]=wt.value,pe[Ue]=Et.value}return K.map=Ue=>{Le.properties=Ue;let Ne={};for(let Ke of Oe)Ne[Ke]=ue[Ke].evaluate(ye,Le);return Ne},K.reduce=(Ue,Ne)=>{Le.properties=Ne;for(let Ke of Oe)ye.accumulated=Ue[Ke],Ue[Ke]=pe[Ke].evaluate(ye,Le)},K}(S)).load(ee.features):function(K,re){return new Gi(K,re)}(ee,S.geojsonVtOptions)}catch(K){return C(K)}this.loaded={};let te={};if(V){let K=a.getPerformanceMeasurement(F);K&&(te.resourceTiming={},te.resourceTiming[S.source]=JSON.parse(JSON.stringify(K)))}C(null,te)}})}reloadTile(S,C){let F=this.loaded;return F&&F[S.uid]?super.reloadTile(S,C):this.loadTile(S,C)}loadGeoJSON(S,C){if(S.request)a.getJSON(S.request,C);else{if(typeof S.data!="string")return C(new Error(`Input data given to '${S.source}' is not a valid GeoJSON object.`));try{return C(null,JSON.parse(S.data))}catch{return C(new Error(`Input data given to '${S.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(S,C){try{C(null,this._geoJSONIndex.getClusterExpansionZoom(S.clusterId))}catch(F){C(F)}}getClusterChildren(S,C){try{C(null,this._geoJSONIndex.getChildren(S.clusterId))}catch(F){C(F)}}getClusterLeaves(S,C){try{C(null,this._geoJSONIndex.getLeaves(S.clusterId,S.limit,S.offset))}catch(F){C(F)}}}class vi{constructor(S){this.self=S,this.actor=new a.Actor(S,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:kn},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(C,F)=>{if(this.workerSourceTypes[C])throw new Error(`Worker source with name "${C}" already registered.`);this.workerSourceTypes[C]=F},this.self.registerRTLTextPlugin=C=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=C.applyArabicShaping,a.plugin.processBidirectionalText=C.processBidirectionalText,a.plugin.processStyledBidirectionalText=C.processStyledBidirectionalText}}clearCaches(S,C,F){delete this.layerIndexes[S],delete this.availableImages[S],delete this.workerSources[S],delete this.demWorkerSources[S],F()}checkIfReady(S,C,F){F()}setReferrer(S,C){this.referrer=C}spriteLoaded(S,C){this.isSpriteLoaded[S]=C;for(let F in this.workerSources[S]){let V=this.workerSources[S][F];for(let W in V)V[W]instanceof a.VectorTileWorkerSource&&(V[W].isSpriteLoaded=C,V[W].fire(new a.Event("isSpriteLoaded")))}}setImages(S,C,F){this.availableImages[S]=C;for(let V in this.workerSources[S]){let W=this.workerSources[S][V];for(let ee in W)W[ee].availableImages=C}F()}enableTerrain(S,C,F){this.terrain=C,F()}setProjection(S,C){this.projections[S]=a.getProjection(C)}setLayers(S,C,F){this.getLayerIndex(S).replace(C),F()}updateLayers(S,C,F){this.getLayerIndex(S).update(C.layers,C.removedIds),F()}loadTile(S,C,F){let V=this.enableTerrain?a.extend({enableTerrain:this.terrain},C):C;V.projection=this.projections[S]||this.defaultProjection,this.getWorkerSource(S,C.type,C.source).loadTile(V,F)}loadDEMTile(S,C,F){let V=this.enableTerrain?a.extend({buildQuadTree:this.terrain},C):C;this.getDEMWorkerSource(S,C.source).loadTile(V,F)}reloadTile(S,C,F){let V=this.enableTerrain?a.extend({enableTerrain:this.terrain},C):C;V.projection=this.projections[S]||this.defaultProjection,this.getWorkerSource(S,C.type,C.source).reloadTile(V,F)}abortTile(S,C,F){this.getWorkerSource(S,C.type,C.source).abortTile(C,F)}removeTile(S,C,F){this.getWorkerSource(S,C.type,C.source).removeTile(C,F)}removeSource(S,C,F){if(!this.workerSources[S]||!this.workerSources[S][C.type]||!this.workerSources[S][C.type][C.source])return;let V=this.workerSources[S][C.type][C.source];delete this.workerSources[S][C.type][C.source],V.removeSource!==void 0?V.removeSource(C,F):F()}loadWorkerSource(S,C,F){try{this.self.importScripts(C.url),F()}catch(V){F(V.toString())}}syncRTLPluginState(S,C,F){try{a.plugin.setState(C);let V=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&V!=null){this.self.importScripts(V);let W=a.plugin.isParsed();F(W?void 0:new Error(`RTL Text Plugin failed to import scripts from ${V}`),W)}}catch(V){F(V.toString())}}getAvailableImages(S){let C=this.availableImages[S];return C||(C=[]),C}getLayerIndex(S){let C=this.layerIndexes[S];return C||(C=this.layerIndexes[S]=new yi),C}getWorkerSource(S,C,F){return this.workerSources[S]||(this.workerSources[S]={}),this.workerSources[S][C]||(this.workerSources[S][C]={}),this.workerSources[S][C][F]||(this.workerSources[S][C][F]=new this.workerSourceTypes[C]({send:(V,W,ee,te,K,re)=>{this.actor.send(V,W,ee,S,K,re)},scheduler:this.actor.scheduler},this.getLayerIndex(S),this.getAvailableImages(S),this.isSpriteLoaded[S])),this.workerSources[S][C][F]}getDEMWorkerSource(S,C){return this.demWorkerSources[S]||(this.demWorkerSources[S]={}),this.demWorkerSources[S][C]||(this.demWorkerSources[S][C]=new qe),this.demWorkerSources[S][C]}enforceCacheSizeLimit(S,C){a.enforceCacheSizeLimit(C)}getWorkerPerformanceMetrics(S,C,F){F(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new vi(self)),vi}),Rc(["./shared"],function(a){"use strict";var ji=Ar;function Ar(c){return!function(i){return typeof window>"u"||typeof document>"u"?"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 h,d,f=new Blob([""],{type:"text/javascript"}),_=URL.createObjectURL(f);try{d=new Worker(_),h=!0}catch{h=!1}return d&&d.terminate(),URL.revokeObjectURL(_),h}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var h=document.createElement("canvas");h.width=h.height=1;var d=h.getContext("2d");if(!d)return!1;var f=d.getImageData(0,0,1,1);return f&&f.width===h.width}()?(yi[o=i&&i.failIfMajorPerformanceCaveat]===void 0&&(yi[o]=function(h){var d,f=function(_){var y=document.createElement("canvas"),w=Object.create(Ar.webGLContextAttributes);return w.failIfMajorPerformanceCaveat=_,y.getContext("webgl",w)||y.getContext("experimental-webgl",w)}(h);if(!f)return!1;try{d=f.createShader(f.VERTEX_SHADER)}catch{return!1}return!(!d||f.isContextLost())&&(f.shaderSource(d,"void main() {}"),f.compileShader(d),f.getShaderParameter(d,f.COMPILE_STATUS)===!0)}(o)),yi[o]?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 o}(c)}var yi={};function Ce(c,i){var o=i[0],h=i[1],d=i[2],f=i[3],_=o*f-d*h;return _?(c[0]=f*(_=1/_),c[1]=-h*_,c[2]=-d*_,c[3]=o*_,c):null}function qe(c,i){if(Array.isArray(c)){if(!Array.isArray(i)||c.length!==i.length)return!1;for(let o=0;o<c.length;o++)if(!qe(c[o],i[o]))return!1;return!0}if(typeof c=="object"&&c!==null&&i!==null){if(typeof i!="object"||Object.keys(c).length!==Object.keys(i).length)return!1;for(let o in c)if(!qe(c[o],i[o]))return!1;return!0}return c===i}Ar.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};let me={create:function(c,i,o){let h=a.window.document.createElement(c);return i!==void 0&&(h.className=i),o&&o.appendChild(h),h},createSVG:function(c,i,o){let h=a.window.document.createElementNS("http://www.w3.org/2000/svg",c);for(let d of Object.keys(i))h.setAttributeNS(null,d,i[d]);return o&&o.appendChild(h),h}},Mi=a.window.document&&a.window.document.documentElement.style,Dt=Mi&&Mi.userSelect!==void 0?"userSelect":"WebkitUserSelect",so;me.disableDrag=function(){Mi&&Dt&&(so=Mi[Dt],Mi[Dt]="none")},me.enableDrag=function(){Mi&&Dt&&(Mi[Dt]=so)};let ui=function(c){c.preventDefault(),c.stopPropagation(),a.window.removeEventListener("click",ui,!0)};function ao(c,i,o){let h=c.offsetWidth===i.width?1:c.offsetWidth/i.width;return new a.pointGeometry((o.clientX-i.left)*h,(o.clientY-i.top)*h)}function pr(c){let{userImage:i}=c;return!!(i&&i.render&&i.render())&&(c.data.replace(new Uint8Array(i.data.buffer)),!0)}me.suppressClick=function(){a.window.addEventListener("click",ui,!0),a.window.setTimeout(()=>{a.window.removeEventListener("click",ui,!0)},0)},me.mousePos=function(c,i){let o=c.getBoundingClientRect();return ao(c,o,i)},me.touchPos=function(c,i){let o=c.getBoundingClientRect(),h=[];for(let d=0;d<i.length;d++)h.push(ao(c,o,i[d]));return h},me.mouseButton=function(c){return a.window.InstallTrigger!==void 0&&c.button===2&&c.ctrlKey&&a.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:c.button};class Ai extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(let{ids:o,callback:h}of this.requestors)this._notify(o,h);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,o){this._validate(i,o)&&(this.images[i]=o)}_validate(i,o){let h=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${i}" has invalid "stretchX" value`))),h=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${i}" has invalid "stretchY" value`))),h=!1),this._validateContent(o.content,o)||(this.fire(new a.ErrorEvent(new Error(`Image "${i}" has invalid "content" value`))),h=!1),h}_validateStretch(i,o){if(!i)return!0;let h=0;for(let d of i){if(d[0]<h||d[1]<d[0]||o<d[1])return!1;h=d[1]}return!0}_validateContent(i,o){return!(i&&(i.length!==4||i[0]<0||o.data.width<i[0]||i[1]<0||o.data.height<i[1]||i[2]<0||o.data.width<i[2]||i[3]<0||o.data.height<i[3]||i[2]<i[0]||i[3]<i[1]))}updateImage(i,o){o.version=this.images[i].version+1,this.images[i]=o,this.updatedImages[i]=!0}removeImage(i){let o=this.images[i];delete this.images[i],delete this.patterns[i],o.userImage&&o.userImage.onRemove&&o.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(i,o){let h=!0;if(!this.isLoaded())for(let d of i)this.images[d]||(h=!1);this.isLoaded()||h?this._notify(i,o):this.requestors.push({ids:i,callback:o})}_notify(i,o){let h={};for(let d of i){this.images[d]||this.fire(new a.Event("styleimagemissing",{id:d}));let f=this.images[d];f?h[d]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:Boolean(f.userImage&&f.userImage.render)}:a.warnOnce(`Image "${d}" 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.`)}o(null,h)}getPixelSize(){let{width:i,height:o}=this.atlasImage;return{width:i,height:o}}getPattern(i){let o=this.patterns[i],h=this.getImage(i);if(!h)return null;if(o&&o.position.version===h.version)return o.position;if(o)o.position.version=h.version;else{let d={w:h.data.width+2,h:h.data.height+2,x:0,y:0},f=new a.ImagePosition(d,h);this.patterns[i]={bin:d,position:f}}return this._updatePatternAtlas(),this.patterns[i].position}bind(i){let o=i.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.Texture(i,this.atlasImage,o.RGBA),this.atlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}_updatePatternAtlas(){let i=[];for(let f in this.patterns)i.push(this.patterns[f].bin);let{w:o,h}=a.potpack(i),d=this.atlasImage;d.resize({width:o||1,height:h||1});for(let f in this.patterns){let{bin:_}=this.patterns[f],y=_.x+1,w=_.y+1,T=this.images[f].data,E=T.width,M=T.height;a.RGBAImage.copy(T,d,{x:0,y:0},{x:y,y:w},{width:E,height:M}),a.RGBAImage.copy(T,d,{x:0,y:M-1},{x:y,y:w-1},{width:E,height:1}),a.RGBAImage.copy(T,d,{x:0,y:0},{x:y,y:w+M},{width:E,height:1}),a.RGBAImage.copy(T,d,{x:E-1,y:0},{x:y-1,y:w},{width:1,height:M}),a.RGBAImage.copy(T,d,{x:0,y:0},{x:y+E,y:w},{width:1,height:M})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(i){for(let o of i){if(this.callbackDispatchedThisFrame[o])continue;this.callbackDispatchedThisFrame[o]=!0;let h=this.images[o];pr(h)&&this.updateImage(o,h)}}}let yn=new a.Properties({anchor:new a.DataConstantProperty(a.spec.light.anchor),position:new class{constructor(){this.specification=a.spec.light.position}possiblyEvaluate(c,i){return function([o,h,d]){let f=a.degToRad(h+90),_=a.degToRad(d);return{x:o*Math.cos(f)*Math.sin(_),y:o*Math.sin(f)*Math.sin(_),z:o*Math.cos(_),azimuthal:h,polar:d}}(c.expression.evaluate(i))}interpolate(c,i,o){return{x:a.number(c.x,i.x,o),y:a.number(c.y,i.y,o),z:a.number(c.z,i.z,o),azimuthal:a.number(c.azimuthal,i.azimuthal,o),polar:a.number(c.polar,i.polar,o)}}},color:new a.DataConstantProperty(a.spec.light.color),intensity:new a.DataConstantProperty(a.spec.light.intensity)}),Ji="-transition";class Yr extends a.Evented{constructor(i){super(),this._transitionable=new a.Transitionable(yn),this.setLight(i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(i,o={}){if(!this._validate(a.validateLight,i,o))for(let h in i){let d=i[h];a.endsWith(h,Ji)?this._transitionable.setTransition(h.slice(0,-Ji.length),d):this._transitionable.setValue(h,d)}}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}_validate(i,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,i.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}let lo=new a.Properties({source:new a.DataConstantProperty(a.spec.terrain.source),exaggeration:new a.DataConstantProperty(a.spec.terrain.exaggeration)}),Jr="-transition";class is extends a.Evented{constructor(i,o){super(),this._transitionable=new a.Transitionable(lo),this.set(i),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=o}get(){return this._transitionable.serialize()}set(i){for(let o in i){let h=i[o];a.endsWith(o,Jr)?this._transitionable.setTransition(o.slice(0,-Jr.length),h):this._transitionable.setValue(o,h)}}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}}function fr(c,i,o,h){let d=a.smoothstep(45,65,o),[f,_]=co(c,h),y=a.length(i),w=1-Math.min(1,Math.exp((y-f)/(_-f)*-6));return w*=w*w,w=Math.min(1,1.00747*w),w*d*c.alpha}function co(c,i){let o=.5/Math.tan(.5*i);return[c.range[0]+o,c.range[1]+o]}let xn=new a.Properties({range:new a.DataConstantProperty(a.spec.fog.range),color:new a.DataConstantProperty(a.spec.fog.color),"horizon-blend":new a.DataConstantProperty(a.spec.fog["horizon-blend"])}),vn="-transition";class ua extends a.Evented{constructor(i,o){super(),this._transitionable=new a.Transitionable(xn),this.set(i),this._transitioning=this._transitionable.untransitioned(),this._transform=o}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(i,o={}){if(!this._validate(a.validateFog,i,o))for(let h in i){let d=i[h];a.endsWith(h,vn)?this._transitionable.setTransition(h.slice(0,-vn.length),d):this._transitionable.setValue(h,d)}}getOpacity(i){if(!this._transform.projection.supportsFog)return 0;let o=this.properties&&this.properties.get("color")||1;return a.smoothstep(45,65,i)*o.a}getOpacityAtLatLng(i,o){return this._transform.projection.supportsFog?function(h,d,f){let _=a.MercatorCoordinate.fromLngLat(d),y=f.elevation?f.elevation.getAtPointOrZero(_):0,w=[_.x,_.y,y];return a.transformMat4(w,w,f.mercatorFogMatrix),fr(h,w,f.pitch,f._fov)}(this.state,i,o):0}getFovAdjustedRange(i){return this._transform.projection.supportsFog?co(this.state,i):[0,1]}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}_validate(i,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,i.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}class Qi{constructor(i,o){this.workerPool=i,this.actors=[],this.currentActor=0,this.id=a.uniqueId();let h=this.workerPool.acquire(this.id);for(let d=0;d<h.length;d++){let f=new Qi.Actor(h[d],o,this.id);f.name=`Worker ${d}`,this.actors.push(f)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(i,o,h){a.asyncAll(this.actors,(d,f)=>{d.send(i,o,f)},h=h||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Ci(c,i,o){return i*(a.EXTENT/(c.tileSize*Math.pow(2,o-c.tileID.overscaledZ)))}Qi.Actor=a.Actor;class bn{constructor(i,o,h){this.context=i;let d=i.gl;this.buffer=d.createBuffer(),this.dynamicDraw=Boolean(h),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete o.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){let o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let er={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wn{constructor(i,o,h,d){this.length=o.length,this.attributes=h,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.context=i;let f=i.gl;this.buffer=f.createBuffer(),i.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete o.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){let o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,o){for(let h=0;h<this.attributes.length;h++){let d=o.attributes[this.attributes[h].name];d!==void 0&&i.enableVertexAttribArray(d)}}setVertexAttribPointers(i,o,h){for(let d=0;d<this.attributes.length;d++){let f=this.attributes[d],_=o.attributes[f.name];_!==void 0&&i.vertexAttribPointer(_,f.components,i[er[f.type]],!1,this.itemSize,f.offset+this.itemSize*(h||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class nt{constructor(i){this.gl=i.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(i){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class rs extends nt{getDefault(){return a.Color.transparent}set(i){let o=this.current;(i.r!==o.r||i.g!==o.g||i.b!==o.b||i.a!==o.a||this.dirty)&&(this.gl.clearColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class Qr extends nt{getDefault(){return 1}set(i){(i!==this.current||this.dirty)&&(this.gl.clearDepth(i),this.current=i,this.dirty=!1)}}class en extends nt{getDefault(){return 0}set(i){(i!==this.current||this.dirty)&&(this.gl.clearStencil(i),this.current=i,this.dirty=!1)}}class da extends nt{getDefault(){return[!0,!0,!0,!0]}set(i){let o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||i[3]!==o[3]||this.dirty)&&(this.gl.colorMask(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class Tn extends nt{getDefault(){return!0}set(i){(i!==this.current||this.dirty)&&(this.gl.depthMask(i),this.current=i,this.dirty=!1)}}class tr extends nt{getDefault(){return 255}set(i){(i!==this.current||this.dirty)&&(this.gl.stencilMask(i),this.current=i,this.dirty=!1)}}class ho extends nt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(i){let o=this.current;(i.func!==o.func||i.ref!==o.ref||i.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(i.func,i.ref,i.mask),this.current=i,this.dirty=!1)}}class ns extends nt{getDefault(){let i=this.gl;return[i.KEEP,i.KEEP,i.KEEP]}set(i){let o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(i[0],i[1],i[2]),this.current=i,this.dirty=!1)}}class os extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;i?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=i,this.dirty=!1}}class uo extends nt{getDefault(){return[0,1]}set(i){let o=this.current;(i[0]!==o[0]||i[1]!==o[1]||this.dirty)&&(this.gl.depthRange(i[0],i[1]),this.current=i,this.dirty=!1)}}class ss extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;i?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=i,this.dirty=!1}}class En extends nt{getDefault(){return this.gl.LESS}set(i){(i!==this.current||this.dirty)&&(this.gl.depthFunc(i),this.current=i,this.dirty=!1)}}class Je extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;i?o.enable(o.BLEND):o.disable(o.BLEND),this.current=i,this.dirty=!1}}class xi extends nt{getDefault(){let i=this.gl;return[i.ONE,i.ZERO]}set(i){let o=this.current;(i[0]!==o[0]||i[1]!==o[1]||this.dirty)&&(this.gl.blendFunc(i[0],i[1]),this.current=i,this.dirty=!1)}}class tn extends nt{getDefault(){return a.Color.transparent}set(i){let o=this.current;(i.r!==o.r||i.g!==o.g||i.b!==o.b||i.a!==o.a||this.dirty)&&(this.gl.blendColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class po extends nt{getDefault(){return this.gl.FUNC_ADD}set(i){(i!==this.current||this.dirty)&&(this.gl.blendEquation(i),this.current=i,this.dirty=!1)}}class fo extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;i?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=i,this.dirty=!1}}class mo extends nt{getDefault(){return this.gl.BACK}set(i){(i!==this.current||this.dirty)&&(this.gl.cullFace(i),this.current=i,this.dirty=!1)}}class mt extends nt{getDefault(){return this.gl.CCW}set(i){(i!==this.current||this.dirty)&&(this.gl.frontFace(i),this.current=i,this.dirty=!1)}}class Cr extends nt{getDefault(){return null}set(i){(i!==this.current||this.dirty)&&(this.gl.useProgram(i),this.current=i,this.dirty=!1)}}class mr extends nt{getDefault(){return this.gl.TEXTURE0}set(i){(i!==this.current||this.dirty)&&(this.gl.activeTexture(i),this.current=i,this.dirty=!1)}}class rn extends nt{getDefault(){let i=this.gl;return[0,0,i.drawingBufferWidth,i.drawingBufferHeight]}set(i){let o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||i[3]!==o[3]||this.dirty)&&(this.gl.viewport(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class Sn extends nt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,i),this.current=i,this.dirty=!1}}class Lt extends nt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class _o extends nt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.bindTexture(o.TEXTURE_2D,i),this.current=i,this.dirty=!1}}class go extends nt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class yo extends nt{getDefault(){return null}set(i){let o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class zi extends nt{constructor(i){super(i),this.vao=i.extVertexArrayObject}getDefault(){return null}set(i){this.vao&&(i!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(i),this.current=i,this.dirty=!1)}}class as extends nt{getDefault(){return 4}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,i),this.current=i,this.dirty=!1}}class In extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i),this.current=i,this.dirty=!1}}class Mn extends nt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,i),this.current=i,this.dirty=!1}}class zr extends nt{constructor(i,o){super(i),this.context=i,this.parent=o}getDefault(){return null}}class An extends zr{setDirty(){this.dirty=!0}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i,0),this.current=i,this.dirty=!1}}class ki extends zr{attachment(){return this.gl.DEPTH_ATTACHMENT}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class ls extends ki{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class zt{constructor(i,o,h,d){this.context=i,this.width=o,this.height=h;let f=this.framebuffer=i.gl.createFramebuffer();this.colorAttachment=new An(i,f),d&&(this.depthAttachment=new ki(i,f))}destroy(){let i=this.context.gl,o=this.colorAttachment.get();if(o&&i.deleteTexture(o),this.depthAttachment){let h=this.depthAttachment.get();h&&i.deleteRenderbuffer(h)}i.deleteFramebuffer(this.framebuffer)}}class Pi{constructor(i){this.gl=i,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new rs(this),this.clearDepth=new Qr(this),this.clearStencil=new en(this),this.colorMask=new da(this),this.depthMask=new Tn(this),this.stencilMask=new tr(this),this.stencilFunc=new ho(this),this.stencilOp=new ns(this),this.stencilTest=new os(this),this.depthRange=new uo(this),this.depthTest=new ss(this),this.depthFunc=new En(this),this.blend=new Je(this),this.blendFunc=new xi(this),this.blendColor=new tn(this),this.blendEquation=new po(this),this.cullFace=new fo(this),this.cullFaceSide=new mo(this),this.frontFace=new mt(this),this.program=new Cr(this),this.activeTexture=new mr(this),this.viewport=new rn(this),this.bindFramebuffer=new Sn(this),this.bindRenderbuffer=new Lt(this),this.bindTexture=new _o(this),this.bindVertexBuffer=new go(this),this.bindElementBuffer=new yo(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new zi(this),this.pixelStoreUnpack=new as(this),this.pixelStoreUnpackPremultiplyAlpha=new In(this),this.pixelStoreUnpackFlipY=new Mn(this),this.extTextureFilterAnisotropic=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=i.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=i.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(i.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=i.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=i.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=i.getParameter(i.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(i,o){return new bn(this,i,o)}createVertexBuffer(i,o,h){return new wn(this,i,o,h)}createRenderbuffer(i,o,h){let d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,i,o,h),this.bindRenderbuffer.set(null),f}createFramebuffer(i,o,h){return new zt(this,i,o,h)}clear({color:i,depth:o,stencil:h}){let d=this.gl,f=0;i&&(f|=d.COLOR_BUFFER_BIT,this.clearColor.set(i),this.colorMask.set([!0,!0,!0,!0])),o!==void 0&&(f|=d.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),h!==void 0&&(f|=d.STENCIL_BUFFER_BIT,this.clearStencil.set(h),this.stencilMask.set(255)),d.clear(f)}setCullFace(i){i.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(i.mode),this.frontFace.set(i.frontFace))}setDepthMode(i){i.func!==this.gl.ALWAYS||i.mask?(this.depthTest.set(!0),this.depthFunc.set(i.func),this.depthMask.set(i.mask),this.depthRange.set(i.range)):this.depthTest.set(!1)}setStencilMode(i){i.test.func!==this.gl.ALWAYS||i.mask?(this.stencilTest.set(!0),this.stencilMask.set(i.mask),this.stencilOp.set([i.fail,i.depthFail,i.pass]),this.stencilFunc.set({func:i.test.func,ref:i.ref,mask:i.test.mask})):this.stencilTest.set(!1)}setColorMode(i){qe(i.blendFunction,a.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor)),this.colorMask.set(i.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Cn{constructor(i,o,h,d){this.screenBounds=i,this.cameraPoint=o,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=h,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(f=>d.pointCoordinate3D(f)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(i,o){let h,d;if(i instanceof a.pointGeometry||typeof i[0]=="number"){let f=a.pointGeometry.convert(i);h=[a.pointGeometry.convert(i)],d=o.isPointAboveHorizon(f)}else{let f=a.pointGeometry.convert(i[0]),_=a.pointGeometry.convert(i[1]);h=[f,_],d=a.polygonizeBounds(f,_).every(y=>o.isPointAboveHorizon(y))}return new Cn(h,o.getCameraPoint(),d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(i){return a.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],i)}bufferedCameraGeometry(i){let o=this.screenBounds[0],h=this.screenBounds.length===1?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],d=a.polygonizeBounds(o,h,0,!1);return this.cameraPoint.y>h.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<h.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=h.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),a.bufferConvexPolygon(d,i)}containsTile(i,o,h){let d=i.queryPadding+1,f=i.tileID.wrap,_=h?this._bufferedCameraMercator(d,o).map(P=>a.getTilePoint(i.tileTransform,P,f)):this._bufferedScreenMercator(d,o).map(P=>a.getTilePoint(i.tileTransform,P,f)),y=this.screenGeometryMercator.map(P=>a.getTileVec3(i.tileTransform,P,f)),w=y.map(P=>new a.pointGeometry(P[0],P[1])),T=o.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),E=a.getTileVec3(i.tileTransform,T,f),M=y.map(P=>{let R=a.sub(P,P,E);return a.normalize(R,R),new a.Ray(E,R)}),z=Ci(i,1,o.zoom);if(a.polygonIntersectsBox(_,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:w,tilespaceRays:M,bufferedTilespaceGeometry:_,bufferedTilespaceBounds:(B=a.getBounds(_),B.min.x=a.clamp(B.min.x,0,a.EXTENT),B.min.y=a.clamp(B.min.y,0,a.EXTENT),B.max.x=a.clamp(B.max.x,0,a.EXTENT),B.max.y=a.clamp(B.max.y,0,a.EXTENT),B),tile:i,tileID:i.tileID,pixelToTileUnitsFactor:z};var B}_bufferedScreenMercator(i,o){let h=ir(i);if(this._screenRaycastCache[h])return this._screenRaycastCache[h];{let d=this.bufferedScreenGeometry(i).map(f=>o.pointCoordinate3D(f));return this._screenRaycastCache[h]=d,d}}_bufferedCameraMercator(i,o){let h=ir(i);if(this._cameraRaycastCache[h])return this._cameraRaycastCache[h];{let d=this.bufferedCameraGeometry(i).map(f=>o.pointCoordinate3D(f));return this._cameraRaycastCache[h]=d,d}}}function ir(c){return 100*c|0}function zn(c,i,o){let h=function(d,f){if(d)return o(d);if(f){let _=a.pick(a.extend(f,c),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);f.vector_layers&&(_.vectorLayers=f.vector_layers,_.vectorLayerIds=_.vectorLayers.map(y=>y.id)),_.tiles=i.canonicalizeTileset(_,c.url),o(null,_)}};return c.url?a.getJSON(i.transformRequest(i.normalizeSourceURL(c.url),a.ResourceType.Source),h):a.exported.frame(()=>h(null,c))}class nn{constructor(i,o,h){this.bounds=a.LngLatBounds.convert(this.validateBounds(i)),this.minzoom=o||0,this.maxzoom=h||24}validateBounds(i){return Array.isArray(i)&&i.length===4?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(i){let o=Math.pow(2,i.z),h=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*o),d=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*o),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*o),_=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*o);return i.x>=h&&i.x<f&&i.y>=d&&i.y<_}}class _r extends a.Evented{constructor(i,o,h,d){super(),this.id=i,this.dispatcher=h,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.extend({type:"raster"},o),a.extend(this,a.pick(o,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=zn(this._options,this.map._requestManager,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new a.ErrorEvent(i)):o&&(a.extend(this,o),o.bounds&&(this.tileBounds=new nn(o.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(o.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(i,o){let h=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),h,this.tileSize);i.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(f,_,y,w)=>{if(delete i.request,i.aborted)i.state="unloaded",o(null);else if(f)i.state="errored",o(f);else if(_){this.map._refreshExpiredTiles&&i.setExpiryData({cacheControl:y,expires:w});let T=this.map.painter.context,E=T.gl;i.texture=this.map.painter.getTileTexture(_.width),i.texture?i.texture.update(_,{useMipmap:!0}):(i.texture=new a.Texture(T,_,E.RGBA,{useMipmap:!0}),i.texture.bind(E.LINEAR,E.CLAMP_TO_EDGE),T.extTextureFilterAnisotropic&&E.texParameterf(E.TEXTURE_2D,T.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,T.extTextureFilterAnisotropicMax)),i.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),o(null)}})}abortTile(i,o){i.request&&(i.request.cancel(),delete i.request),o()}unloadTile(i,o){i.texture&&this.map.painter.saveTileTexture(i.texture),o()}hasTransition(){return!1}}let Gi;function kr(c,i,o,h,d,f,_,y){let w=[c,o,d,i,h,f,1,1,1],T=[_,y,1],E=a.adjoint([],w),[M,z,B]=a.transformMat3(T,T,a.transpose(E,E));return a.multiply(w,[M,0,0,0,z,0,0,0,B],w)}class rr extends a.Evented{constructor(i,o,h,d){super(),this.id=i,this.dispatcher=h,this.coordinates=o.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=o}load(i,o){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(h,d)=>{this._loaded=!0,h?this.fire(new a.ErrorEvent(h)):d&&(this.image=a.exported.getImageData(d),this.width=this.image.width,this.height=this.image.height,i&&(this.coordinates=i),o&&o(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url?(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(i){this.coordinates=i,delete this._boundsArray;let o=i.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(h){let d=1/0,f=1/0,_=-1/0,y=-1/0;for(let M of h)d=Math.min(d,M.x),f=Math.min(f,M.y),_=Math.max(_,M.x),y=Math.max(y,M.y);let w=Math.max(_-d,y-f),T=Math.max(0,Math.floor(-Math.log(w)/Math.LN2)),E=Math.pow(2,T);return new a.CanonicalTileID(T,Math.floor((d+_)/2*E),Math.floor((f+y)/2*E))}(o),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){let i=a.tileTransform(this.tileID,this.map.transform.projection),[o,h,d,f]=this.coordinates.map(_=>{let y=i.projection.project(_[0],_[1]);return a.getTilePoint(i,y)._round()});return this.perspectiveTransform=function(_,y,w,T,E,M,z,B,P,R){let q=kr(0,0,_,0,0,y,_,y),L=kr(w,T,E,M,z,B,P,R);return a.multiply(L,a.adjoint(q,q),L),[L[6]/L[8]*_/a.EXTENT,L[7]/L[8]*y/a.EXTENT]}(this.width,this.height,o.x,o.y,h.x,h.y,f.x,f.y,d.x,d.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(o.x,o.y,0,0),this._boundsArray.emplaceBack(h.x,h.y,a.EXTENT,0),this._boundsArray.emplaceBack(f.x,f.y,0,a.EXTENT),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let i=this.map.painter.context,o=i.gl;this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(i,this.image,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE));for(let h in this.tiles){let d=this.tiles[h];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture)}}loadTile(i,o){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},o(null)):(i.state="errored",o(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}let kn={vector:class extends a.Evented{constructor(c,i,o,h){if(super(),this.id=c,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(i,["url","scheme","tileSize","promoteId"])),this._options=a.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(h),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=zn(this._options,this.map._requestManager,(c,i)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):i&&(a.extend(this,i),i.bounds&&(this.tileBounds=new nn(i.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(i.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(c){return!this.tileBounds||this.tileBounds.contains(c.canonical)}onAdd(c){this.map=c,this.load()}setSourceProperty(c){this._tileJSONRequest&&this._tileJSONRequest.cancel(),c();let i=this.map.style._getSourceCaches(this.id);for(let o of i)o.clearTiles();this.load()}setTiles(c){return this.setSourceProperty(()=>{this._options.tiles=c}),this}setUrl(c){return this.setSourceProperty(()=>{this.url=c,this._options.url=c}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(c,i){let o=this.map._requestManager.normalizeTileURL(c.tileID.canonical.url(this.tiles,this.scheme)),h={request:this.map._requestManager.transformRequest(o,a.ResourceType.Tile),data:void 0,uid:c.uid,tileID:c.tileID,tileZoom:c.tileZoom,zoom:c.tileID.overscaledZ,tileSize:this.tileSize*c.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:c.isSymbolTile};if(h.request.collectResourceTiming=this._collectResourceTiming,c.actor&&c.state!=="expired")c.state==="loading"?c.reloadCallback=i:c.request=c.actor.send("reloadTile",h,d.bind(this));else if(c.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)c.request=c.actor.send("loadTile",h,d.bind(this),void 0,!0);else{let f=a.loadVectorTile.call({deduped:this._deduped},h,(_,y)=>{_||!y?d.call(this,_):(h.data={cacheControl:y.cacheControl,expires:y.expires,rawData:y.rawData.slice(0)},c.actor&&c.actor.send("loadTile",h,d.bind(this),void 0,!0))},!0);c.request={cancel:f}}function d(f,_){return delete c.request,c.aborted?i(null):f&&f.status!==404?i(f):(_&&_.resourceTiming&&(c.resourceTiming=_.resourceTiming),this.map._refreshExpiredTiles&&_&&c.setExpiryData(_),c.loadVectorData(_,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(c.reloadCallback&&(this.loadTile(c,c.reloadCallback),c.reloadCallback=null)))}}abortTile(c){c.request&&(c.request.cancel(),delete c.request),c.actor&&c.actor.send("abortTile",{uid:c.uid,type:this.type,source:this.id})}unloadTile(c){c.unloadVectorData(),c.actor&&c.actor.send("removeTile",{uid:c.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:_r,"raster-dem":class extends _r{constructor(c,i,o,h){super(c,i,o,h),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(c,i){let o=this.map._requestManager.normalizeTileURL(c.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function h(d,f){d&&(c.state="errored",i(d)),f&&(c.dem=f,c.dem.onDeserialize(),c.needsHillshadePrepare=!0,c.needsDEMTextureUpload=!0,c.state="loaded",i(null))}c.request=a.getImage(this.map._requestManager.transformRequest(o,a.ResourceType.Tile),function(d,f,_,y){if(delete c.request,c.aborted)c.state="unloaded",i(null);else if(d)c.state="errored",i(d);else if(f){this.map._refreshExpiredTiles&&c.setExpiryData({cacheControl:_,expires:y});let w=a.window.ImageBitmap&&f instanceof a.window.ImageBitmap&&(Gi==null&&(Gi=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&typeof a.window.createImageBitmap=="function"),Gi),T=1-(f.width-a.prevPowerOfTwo(f.width))/2;T<1||c.neighboringTiles||(c.neighboringTiles=this._getNeighboringTiles(c.tileID));let E=w?f:a.exported.getImageData(f,T),M={uid:c.uid,coord:c.tileID,source:this.id,rawImageData:E,encoding:this.encoding,padding:T};c.actor&&c.state!=="expired"||(c.actor=this.dispatcher.getActor(),c.actor.send("loadDEMTile",M,h.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(c){let i=c.canonical,o=Math.pow(2,i.z),h=(i.x-1+o)%o,d=i.x===0?c.wrap-1:c.wrap,f=(i.x+1+o)%o,_=i.x+1===o?c.wrap+1:c.wrap,y={};return y[new a.OverscaledTileID(c.overscaledZ,d,i.z,h,i.y).key]={backfilled:!1},y[new a.OverscaledTileID(c.overscaledZ,_,i.z,f,i.y).key]={backfilled:!1},i.y>0&&(y[new a.OverscaledTileID(c.overscaledZ,d,i.z,h,i.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(c.overscaledZ,c.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(c.overscaledZ,_,i.z,f,i.y-1).key]={backfilled:!1}),i.y+1<o&&(y[new a.OverscaledTileID(c.overscaledZ,d,i.z,h,i.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(c.overscaledZ,c.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(c.overscaledZ,_,i.z,f,i.y+1).key]={backfilled:!1}),y}unloadTile(c){c.demTexture&&this.map.painter.saveTileTexture(c.demTexture),c.fbo&&(c.fbo.destroy(),delete c.fbo),c.dem&&delete c.dem,delete c.neighboringTiles,c.state="unloaded"}},geojson:class extends a.Evented{constructor(c,i,o,h){super(),this.id=c,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(h),this._data=i.data,this._options=a.extend({},i),this._collectResourceTiming=i.collectResourceTiming,i.maxzoom!==void 0&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;let d=a.EXTENT/this.tileSize;this.workerOptions=a.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(i.buffer!==void 0?i.buffer:128)*d,tolerance:(i.tolerance!==void 0?i.tolerance:.375)*d,extent:a.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:i.clusterMaxZoom!==void 0?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:a.EXTENT,radius:(i.clusterRadius!==void 0?i.clusterRadius:50)*d,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}onAdd(c){this.map=c,this.setData(this._data)}setData(c){return this._data=c,this._updateWorkerData(),this}getClusterExpansionZoom(c,i){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:c,source:this.id},i),this}getClusterChildren(c,i){return this.actor.send("geojson.getClusterChildren",{clusterId:c,source:this.id},i),this}getClusterLeaves(c,i,o,h){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:c,limit:i,offset:o},h),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.Event("dataloading",{dataType:"source"})),this._loaded=!1;let c=a.extend({},this.workerOptions),i=this._data;typeof i=="string"?(c.request=this.map._requestManager.transformRequest(a.exported.resolveURL(i),a.ResourceType.Source),c.request.collectResourceTiming=this._collectResourceTiming):c.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,c,(o,h)=>{if(this._loaded=!0,this._pendingLoad=null,o)this.fire(new a.ErrorEvent(o));else{let d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&h&&h.resourceTiming&&h.resourceTiming[this.id]&&(d.resourceTiming=h.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(c,i){let o=c.actor?"reloadTile":"loadTile";c.actor=this.actor,c.request=this.actor.send(o,{type:this.type,uid:c.uid,tileID:c.tileID,tileZoom:c.tileZoom,zoom:c.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(h,d)=>(delete c.request,c.unloadVectorData(),c.aborted?i(null):h?i(h):(c.loadVectorData(d,this.map.painter,o==="reloadTile"),i(null))),void 0,o==="loadTile")}abortTile(c){c.request&&(c.request.cancel(),delete c.request),c.aborted=!0}unloadTile(c){c.unloadVectorData(),this.actor.send("removeTile",{uid:c.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends rr{constructor(c,i,o,h){super(c,i,o,h),this.roundZoom=!0,this.type="video",this.options=i}load(){this._loaded=!1;let c=this.options;this.urls=[];for(let i of c.urls)this.urls.push(this.map._requestManager.transformRequest(i,a.ResourceType.Source).url);a.getVideo(this.urls,(i,o)=>{this._loaded=!0,i?this.fire(new a.ErrorEvent(i)):o&&(this.video=o,this.video.loop=!0,this.video.setAttribute("playsinline",""),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(c){if(this.video){let i=this.video.seekable;c<i.start(0)||c>i.end(0)?this.fire(new a.ErrorEvent(new a.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=c}}getVideo(){return this.video}onAdd(c){this.map||(this.map=c,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let c=this.map.painter.context,i=c.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 a.Texture(c,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2));for(let o in this.tiles){let h=this.tiles[o];h.state!=="loaded"&&(h.state="loaded",h.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:rr,canvas:class extends rr{constructor(c,i,o,h){super(c,i,o,h),i.coordinates?Array.isArray(i.coordinates)&&i.coordinates.length===4&&!i.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(f=>typeof f!="number"))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "coordinates"'))),i.animate&&typeof i.animate!="boolean"&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'optional "animate" property must be a boolean value'))),i.canvas?typeof i.canvas=="string"||i.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,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 a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "canvas"'))),this.options=i,this.animate=i.animate===void 0||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.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(c){this.map=c,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let c=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,c=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,c=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let i=this.map.painter.context,o=i.gl;this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(c||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(i,this.canvas,o.RGBA,{premultiply:!0});for(let h in this.tiles){let d=this.tiles[h];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let c of[this.canvas.width,this.canvas.height])if(isNaN(c)||c<=0)return!0;return!1}}},vi=function(c,i,o,h){let d=new kn[i.type](c,i,o,h);if(d.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${d.id}`);return a.bindAll(["load","abort","unload","serialize","prepare"],d),d};function O(c,i){let o=a.identity([]);return a.scale(o,o,[.5*c.width,.5*-c.height,1]),a.translate(o,o,[1,-1,0]),a.multiply$1(o,o,c.calculateProjMatrix(i.toUnwrapped()))}function S(c,i,o,h,d,f,_,y=!1){let w=c.tilesIn(h,_,y);w.sort(F);let T=[];for(let M of w)T.push({wrappedTileID:M.tile.tileID.wrapped().key,queryResults:M.tile.queryRenderedFeatures(i,o,c._state,M,d,f,O(c.transform,M.tile.tileID),y)});let E=function(M){let z={},B={};for(let P of M){let R=P.queryResults,q=P.wrappedTileID,L=B[q]=B[q]||{};for(let G in R){let Z=R[G],N=L[G]=L[G]||{},j=z[G]=z[G]||[];for(let X of Z)N[X.featureIndex]||(N[X.featureIndex]=!0,j.push(X))}}return z}(T);for(let M in E)E[M].forEach(z=>{let B=z.feature,P=c.getFeatureState(B.layer["source-layer"],B.id);B.source=B.layer.source,B.layer["source-layer"]&&(B.sourceLayer=B.layer["source-layer"]),B.state=P});return E}function C(c,i){let o=c.getRenderableIds().map(f=>c.getTileByID(f)),h=[],d={};for(let f=0;f<o.length;f++){let _=o[f],y=_.tileID.canonical.key;d[y]||(d[y]=!0,_.querySourceFeatures(h,i))}return h}function F(c,i){let o=c.tileID,h=i.tileID;return o.overscaledZ-h.overscaledZ||o.canonical.y-h.canonical.y||o.wrap-h.wrap||o.canonical.x-h.canonical.x}function V(){return Gr.workerClass!=null?new Gr.workerClass:new a.window.Worker(Gr.workerUrl)}let W="mapboxgl_preloaded_worker_pool";class ee{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length<ee.workerCount;)this.workers.push(new V);return this.active[i]=!0,this.workers.slice()}release(i){delete this.active[i],this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[W]}numActive(){return Object.keys(this.active).length}}let te;function K(){return te||(te=new ee),te}function re(c,i){let o={};for(let h in c)h!=="ref"&&(o[h]=c[h]);return a.refProperties.forEach(h=>{h in i&&(o[h]=i[h])}),o}function ue(c){c=c.slice();let i=Object.create(null);for(let o=0;o<c.length;o++)i[c[o].id]=c[o];for(let o=0;o<c.length;o++)"ref"in c[o]&&(c[o]=re(c[o],i[c[o].ref]));return c}ee.workerCount=2;let pe={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",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function ye(c,i,o){o.push({command:pe.addSource,args:[c,i[c]]})}function Le(c,i,o){i.push({command:pe.removeSource,args:[c]}),o[c]=!0}function Oe(c,i,o,h){Le(c,o,h),ye(c,i,o)}function Ue(c,i,o){let h;for(h in c[o])if(c[o].hasOwnProperty(h)&&h!=="data"&&!qe(c[o][h],i[o][h]))return!1;for(h in i[o])if(i[o].hasOwnProperty(h)&&h!=="data"&&!qe(c[o][h],i[o][h]))return!1;return!0}function Ne(c,i,o,h,d,f){let _;for(_ in i=i||{},c=c||{})c.hasOwnProperty(_)&&(qe(c[_],i[_])||o.push({command:f,args:[h,_,i[_],d]}));for(_ in i)i.hasOwnProperty(_)&&!c.hasOwnProperty(_)&&(qe(c[_],i[_])||o.push({command:f,args:[h,_,i[_],d]}))}function Ke(c){return c.id}function wt(c,i){return c[i.id]=i,c}class Et{constructor(i,o){this.reset(i,o)}reset(i,o){this.points=i||[],this._distances=[0];for(let h=1;h<this.points.length;h++)this._distances[h]=this._distances[h-1]+this.points[h].dist(this.points[h-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(i){if(this.points.length===1)return this.points[0];i=a.clamp(i,0,1);let o=1,h=this._distances[o],d=i*this.paddedLength+this.padding;for(;h<d&&o<this._distances.length;)h=this._distances[++o];let f=o-1,_=this._distances[f],y=h-_,w=y>0?(d-_)/y:0;return this.points[f].mult(1-w).add(this.points[o].mult(w))}}class yt{constructor(i,o,h){let d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(i/h),this.yCellCount=Math.ceil(o/h);for(let _=0;_<this.xCellCount*this.yCellCount;_++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=i,this.height=o,this.xScale=this.xCellCount/i,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(i,o,h,d,f){this._forEachCell(o,h,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(i),this.bboxes.push(o),this.bboxes.push(h),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(i,o,h,d){this._forEachCell(o-d,h-d,o+d,h+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(i),this.circles.push(o),this.circles.push(h),this.circles.push(d)}_insertBoxCell(i,o,h,d,f,_){this.boxCells[f].push(_)}_insertCircleCell(i,o,h,d,f,_){this.circleCells[f].push(_)}_query(i,o,h,d,f,_){if(h<0||i>this.width||d<0||o>this.height)return!f&&[];let y=[];if(i<=0&&o<=0&&this.width<=h&&this.height<=d){if(f)return!0;for(let w=0;w<this.boxKeys.length;w++)y.push({key:this.boxKeys[w],x1:this.bboxes[4*w],y1:this.bboxes[4*w+1],x2:this.bboxes[4*w+2],y2:this.bboxes[4*w+3]});for(let w=0;w<this.circleKeys.length;w++){let T=this.circles[3*w],E=this.circles[3*w+1],M=this.circles[3*w+2];y.push({key:this.circleKeys[w],x1:T-M,y1:E-M,x2:T+M,y2:E+M})}return _?y.filter(_):y}return this._forEachCell(i,o,h,d,this._queryCell,y,{hitTest:f,seenUids:{box:{},circle:{}}},_),f?y.length>0:y}_queryCircle(i,o,h,d,f){let _=i-h,y=i+h,w=o-h,T=o+h;if(y<0||_>this.width||T<0||w>this.height)return!d&&[];let E=[];return this._forEachCell(_,w,y,T,this._queryCellCircle,E,{hitTest:d,circle:{x:i,y:o,radius:h},seenUids:{box:{},circle:{}}},f),d?E.length>0:E}query(i,o,h,d,f){return this._query(i,o,h,d,!1,f)}hitTest(i,o,h,d,f){return this._query(i,o,h,d,!0,f)}hitTestCircle(i,o,h,d){return this._queryCircle(i,o,h,!0,d)}_queryCell(i,o,h,d,f,_,y,w){let T=y.seenUids,E=this.boxCells[f];if(E!==null){let z=this.bboxes;for(let B of E)if(!T.box[B]){T.box[B]=!0;let P=4*B;if(i<=z[P+2]&&o<=z[P+3]&&h>=z[P+0]&&d>=z[P+1]&&(!w||w(this.boxKeys[B]))){if(y.hitTest)return _.push(!0),!0;_.push({key:this.boxKeys[B],x1:z[P],y1:z[P+1],x2:z[P+2],y2:z[P+3]})}}}let M=this.circleCells[f];if(M!==null){let z=this.circles;for(let B of M)if(!T.circle[B]){T.circle[B]=!0;let P=3*B;if(this._circleAndRectCollide(z[P],z[P+1],z[P+2],i,o,h,d)&&(!w||w(this.circleKeys[B]))){if(y.hitTest)return _.push(!0),!0;{let R=z[P],q=z[P+1],L=z[P+2];_.push({key:this.circleKeys[B],x1:R-L,y1:q-L,x2:R+L,y2:q+L})}}}}}_queryCellCircle(i,o,h,d,f,_,y,w){let T=y.circle,E=y.seenUids,M=this.boxCells[f];if(M!==null){let B=this.bboxes;for(let P of M)if(!E.box[P]){E.box[P]=!0;let R=4*P;if(this._circleAndRectCollide(T.x,T.y,T.radius,B[R+0],B[R+1],B[R+2],B[R+3])&&(!w||w(this.boxKeys[P])))return _.push(!0),!0}}let z=this.circleCells[f];if(z!==null){let B=this.circles;for(let P of z)if(!E.circle[P]){E.circle[P]=!0;let R=3*P;if(this._circlesCollide(B[R],B[R+1],B[R+2],T.x,T.y,T.radius)&&(!w||w(this.circleKeys[P])))return _.push(!0),!0}}}_forEachCell(i,o,h,d,f,_,y,w){let T=this._convertToXCellCoord(i),E=this._convertToYCellCoord(o),M=this._convertToXCellCoord(h),z=this._convertToYCellCoord(d);for(let B=T;B<=M;B++)for(let P=E;P<=z;P++)if(f.call(this,i,o,h,d,this.xCellCount*P+B,_,y,w))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,o,h,d,f,_){let y=d-i,w=f-o,T=h+_;return T*T>y*y+w*w}_circleAndRectCollide(i,o,h,d,f,_,y){let w=(_-d)/2,T=Math.abs(i-(d+w));if(T>w+h)return!1;let E=(y-f)/2,M=Math.abs(o-(f+E));if(M>E+h)return!1;if(T<=w||M<=E)return!0;let z=T-w,B=M-E;return z*z+B*B<=h*h}}let St=Math.tan(85*Math.PI/180);function Pr(c,i,o,h,d,f){let _=a.create();if(o){if(d.projection.name==="globe")_=a.calculateGlobeMatrix(d,d.worldSize/d._projectionScaler,[0,0]),a.multiply$1(_,_,a.globeDenormalizeECEF(a.globeTileBounds(i)));else{let y=Ce([],f);_[0]=y[0],_[1]=y[1],_[4]=y[2],_[5]=y[3]}h||a.rotateZ(_,_,d.angle)}else a.multiply$1(_,d.labelPlaneMatrix,c);return _}function gr(c,i,o,h,d,f){if(o){if(d.projection.name==="globe"){let _=Pr(c,i,o,h,d,f);return a.invert(_,_),a.multiply$1(_,c,_),_}{let _=a.clone(c),y=a.identity([]);return y[0]=f[0],y[1]=f[1],y[4]=f[2],y[5]=f[3],a.multiply$1(_,_,y),h||a.rotateZ(_,_,-d.angle),_}}return d.glCoordMatrix}function ti(c,i,o=0){let h=[c.x,c.y,o,1];o?a.transformMat4$1(h,h,i):bo(h,h,i);let d=h[3];return{point:new a.pointGeometry(h[0]/d,h[1]/d),signedDistanceFromCamera:d}}function nr(c,i){return Math.min(.5+c/i*.5,1.5)}function cs(c,i){let o=c[0]/c[3],h=c[1]/c[3];return o>=-i[0]&&o<=i[0]&&h>=-i[1]&&h<=i[1]}function dl(c,i,o,h,d,f,_,y,w,T){let E=o.transform,M=h?c.textSizeData:c.iconSizeData,z=a.evaluateSizeForZoom(M,o.transform.zoom),B=[256/o.width*2+1,256/o.height*2+1],P=h?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;P.clear();let R=c.lineVertexArray,q=h?c.text.placedSymbolArray:c.icon.placedSymbolArray,L=o.transform.width/o.transform.height,G=!1;for(let Z=0;Z<q.length;Z++){let N=q.get(Z);if(N.writingMode!==a.WritingMode.vertical||G||Z!==0&&q.get(Z-1).writingMode===a.WritingMode.horizontal||(G=!0),N.hidden||N.writingMode===a.WritingMode.vertical&&!G){Zi(N.numGlyphs,P);continue}G=!1;let j=new a.pointGeometry(N.tileAnchorX,N.tileAnchorY),X=w?w(j):[0,0,0],ie=E.projection.projectTilePoint(j.x,j.y,T.canonical),oe=[ie.x+X[0],ie.y+X[1],ie.z+X[2]],Ee=[...oe,1];if(a.transformMat4$1(Ee,Ee,i),!cs(Ee,B)){Zi(N.numGlyphs,P);continue}let xe=nr(o.transform.cameraToCenterDistance,Ee[3]),ge=a.evaluateSizeForFeature(M,z,N),ae=_?ge/xe:ge*xe,ne=ti(new a.pointGeometry(oe[0],oe[1]),d,oe[2]);if(ne.signedDistanceFromCamera<=0){Zi(N.numGlyphs,P);continue}let _e={},de=_?null:w,Be=fa(N,ae,!1,y,i,d,f,c.glyphOffsetArray,R,P,ne.point,j,_e,L,de,E.projection,T);G=Be.useVertical,de&&Be.needsFlipping&&(_e={}),(Be.notEnoughRoom||G||Be.needsFlipping&&fa(N,ae,!0,y,i,d,f,c.glyphOffsetArray,R,P,ne.point,j,_e,L,de,E.projection,T).notEnoughRoom)&&Zi(N.numGlyphs,P)}h?c.text.dynamicLayoutVertexBuffer.updateData(P):c.icon.dynamicLayoutVertexBuffer.updateData(P)}function pa(c,i,o,h,d,f,_,y,w,T,E,M,z,B,P){let R=y.glyphStartIndex+y.numGlyphs,q=y.lineStartIndex,L=y.lineStartIndex+y.lineLength,G=i.getoffsetX(y.glyphStartIndex),Z=i.getoffsetX(R-1),N=vo(c*G,o,h,d,f,_,y.segment,q,L,w,T,E,M,z,!0,B,P);if(!N)return null;let j=vo(c*Z,o,h,d,f,_,y.segment,q,L,w,T,E,M,z,!0,B,P);return j?{first:N,last:j}:null}function xo(c,i,o,h){return c.writingMode===a.WritingMode.horizontal&&Math.abs(o.y-i.y)>Math.abs(o.x-i.x)*h?{useVertical:!0}:c.writingMode===a.WritingMode.vertical?i.y<o.y?{needsFlipping:!0}:null:c.flipState!==0&&function(d,f,_){let y=(f.x-d.x)*_;return y===0||Math.abs((f.y-d.y)/y)>St}(i,o,h)?c.flipState===1?{needsFlipping:!0}:null:i.x>o.x?{needsFlipping:!0}:null}function fa(c,i,o,h,d,f,_,y,w,T,E,M,z,B,P,R,q){let L=i/24,G=c.lineOffsetX*L,Z=c.lineOffsetY*L,N;if(c.numGlyphs>1){let j=c.glyphStartIndex+c.numGlyphs,X=c.lineStartIndex,ie=c.lineStartIndex+c.lineLength,oe=pa(L,y,G,Z,o,E,M,c,w,f,z,P,!1,R,q);if(!oe)return{notEnoughRoom:!0};let Ee=ti(oe.first.point,_).point,xe=ti(oe.last.point,_).point;if(h&&!o){let ge=xo(c,Ee,xe,B);if(c.flipState=ge&&ge.needsFlipping?1:2,ge)return ge}N=[oe.first];for(let ge=c.glyphStartIndex+1;ge<j-1;ge++)N.push(vo(L*y.getoffsetX(ge),G,Z,o,E,M,c.segment,X,ie,w,f,z,P,!1,!1,R,q));N.push(oe.last)}else{if(h&&!o){let X=ti(M,d).point,ie=c.lineStartIndex+c.segment+1,oe=new a.pointGeometry(w.getx(ie),w.gety(ie)),Ee=ti(oe,d),xe=xo(c,X,Ee.signedDistanceFromCamera>0?Ee.point:us(M,oe,X,1,d,void 0,R,q.canonical),B);if(c.flipState=xe&&xe.needsFlipping?1:2,xe)return xe}let j=vo(L*y.getoffsetX(c.glyphStartIndex),G,Z,o,E,M,c.segment,c.lineStartIndex,c.lineStartIndex+c.lineLength,w,f,z,P,!1,!1,R,q);if(!j)return{notEnoughRoom:!0};N=[j]}for(let j of N)a.addDynamicAttributes(T,j.point,j.angle);return{}}function hs(c,i,o,h,d){let f=h.projectTilePoint(c.x,c.y,i);if(!d)return ti(f,o,f.z);let _=d(c);return ti(new a.pointGeometry(f.x+_[0],f.y+_[1]),o,f.z+_[2])}function us(c,i,o,h,d,f,_,y){let w=hs(c.add(c.sub(i)._unit()),y,d,_,f).point,T=o.sub(w);return o.add(T._mult(h/T.mag()))}function vo(c,i,o,h,d,f,_,y,w,T,E,M,z,B,P,R,q){let L=h?c-i:c+i,G=L>0?1:-1,Z=0;h&&(G*=-1,Z=Math.PI),G<0&&(Z+=Math.PI);let N=G>0?y+_:y+_+1,j=d,X=d,ie=0,oe=0,Ee=Math.abs(L),xe=[],ge=[],ae=f,ne=()=>{let Te=N-G;return ie===0?f:new a.pointGeometry(T.getx(Te),T.gety(Te))},_e=()=>us(ne(),ae,X,Ee-ie+1,E,z,R,q.canonical);for(;ie+oe<=Ee;){if(N+=G,N<y||N>=w)return null;if(X=j,xe.push(j),B&&ge.push(ae||ne()),j=M[N],j===void 0){ae=new a.pointGeometry(T.getx(N),T.gety(N));let Te=hs(ae,q.canonical,E,R,z);j=Te.signedDistanceFromCamera>0?M[N]=Te.point:_e()}else ae=null;ie+=oe,oe=X.dist(j)}P&&z&&(ae=ae||new a.pointGeometry(T.getx(N),T.gety(N)),M[N]=j=M[N]===void 0?j:_e(),oe=X.dist(j));let de=(Ee-ie)/oe,Be=j.sub(X),Ve=Be.mult(de)._add(X);o&&Ve._add(Be._unit()._perp()._mult(o*G));let Xe=Z+Math.atan2(j.y-X.y,j.x-X.x);return xe.push(Ve),B&&(ae=ae||new a.pointGeometry(T.getx(N),T.gety(N)),ge.push(function(Te,Re,Ge){let ft=1-Ge;return new a.pointGeometry(Te.x*ft+Re.x*Ge,Te.y*ft+Re.y*Ge)}(ge.length>0?ge[ge.length-1]:ae,ae,de))),{point:Ve,angle:Xe,path:xe,tilePath:ge}}let ma=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Zi(c,i){for(let o=0;o<c;o++){let h=i.length;i.resize(h+4),i.float32.set(ma,3*h)}}function bo(c,i,o){let h=i[0],d=i[1];return c[0]=o[0]*h+o[4]*d+o[12],c[1]=o[1]*h+o[5]*d+o[13],c[3]=o[3]*h+o[7]*d+o[15],c}let or=100;class Fc{constructor(i,o,h=new yt(i.width+200,i.height+200,25),d=new yt(i.width+200,i.height+200,25)){this.transform=i,this.grid=h,this.ignoredGrid=d,this.pitchfactor=Math.cos(i._pitch)*i.cameraToCenterDistance,this.screenRightBoundary=i.width+or,this.screenBottomBoundary=i.height+or,this.gridRightBoundary=i.width+200,this.gridBottomBoundary=i.height+200,this.fogState=o}placeCollisionBox(i,o,h,d,f,_,y){let w=o.projectedAnchorX,T=o.projectedAnchorY,E=o.projectedAnchorZ,M=o.elevation,z=o.tileID;if(M&&z){let N=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),j=N.upVector(z.canonical,o.tileAnchorX,o.tileAnchorY),X=N.upVectorScale(z.canonical);w+=j[0]*M*X,T+=j[1]*M*X,E+=j[2]*M*X}let B=this.projectAndGetPerspectiveRatio(_,w,T,E,o.tileID),P=f*B.perspectiveRatio,R=(o.x1*i+h.x-o.padding)*P+B.point.x,q=(o.y1*i+h.y-o.padding)*P+B.point.y,L=(o.x2*i+h.x+o.padding)*P+B.point.x,G=(o.y2*i+h.y+o.padding)*P+B.point.y,Z=B.perspectiveRatio<=.55||B.aboveHorizon;return!this.isInsideGrid(R,q,L,G)||!d&&this.grid.hitTest(R,q,L,G,y)||Z?{box:[],offscreen:!1}:{box:[R,q,L,G],offscreen:this.isOffscreen(R,q,L,G)}}placeCollisionCircles(i,o,h,d,f,_,y,w,T,E,M,z,B,P){let R=[],q=this.transform.elevation,L=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),G=q?q.getAtTileOffsetFunc(P,L):de=>[0,0,0],Z=new a.pointGeometry(o.tileAnchorX,o.tileAnchorY),N=this.transform.projection.projectTilePoint(o.tileAnchorX,o.tileAnchorY,P.canonical),j=G(Z),X=[N.x+j[0],N.y+j[1],N.z+j[2]],ie=this.projectAndGetPerspectiveRatio(_,X[0],X[1],X[2],P),{perspectiveRatio:oe}=ie,Ee=(E?f/oe:f*oe)/a.ONE_EM,xe=ti(new a.pointGeometry(X[0],X[1]),y,X[2]).point,ge=ie.signedDistanceFromCamera>0?pa(Ee,d,o.lineOffsetX*Ee,o.lineOffsetY*Ee,!1,xe,Z,o,h,y,{},q&&!E?G:null,E&&!!q,this.transform.projection,P):null,ae=!1,ne=!1,_e=!0;if(ge&&!ie.aboveHorizon){let de=.5*z*oe+B,Be=new a.pointGeometry(-100,-100),Ve=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),Xe=new Et,Te=ge.first,Re=ge.last,Ge=[];for(let je=Te.path.length-1;je>=1;je--)Ge.push(Te.path[je]);for(let je=1;je<Re.path.length;je++)Ge.push(Re.path[je]);let ft=2.5*de;if(w){let je=Ge.map(q?(Ye,It)=>{let $t=G(It<Te.path.length-1?Te.tilePath[Te.path.length-1-It]:Re.tilePath[It-Te.path.length+2]);return ti(Ye,w,$t[2])}:Ye=>ti(Ye,w));Ge=je.some(Ye=>Ye.signedDistanceFromCamera<=0)?[]:je.map(Ye=>Ye.point)}let xt=[];if(Ge.length>0){let je=Ge[0].clone(),Ye=Ge[0].clone();for(let It=1;It<Ge.length;It++)je.x=Math.min(je.x,Ge[It].x),je.y=Math.min(je.y,Ge[It].y),Ye.x=Math.max(Ye.x,Ge[It].x),Ye.y=Math.max(Ye.y,Ge[It].y);xt=je.x>=Be.x&&Ye.x<=Ve.x&&je.y>=Be.y&&Ye.y<=Ve.y?[Ge]:Ye.x<Be.x||je.x>Ve.x||Ye.y<Be.y||je.y>Ve.y?[]:a.clipLine([Ge],Be.x,Be.y,Ve.x,Ve.y)}for(let je of xt){Xe.reset(je,.25*de);let Ye=0;Ye=Xe.length<=.5*de?1:Math.ceil(Xe.paddedLength/ft)+1;for(let It=0;It<Ye;It++){let $t=It/Math.max(Ye-1,1),fi=Xe.lerp($t),Fi=fi.x+or,Wi=fi.y+or;R.push(Fi,Wi,de,0);let ot=Fi-de,Ze=Wi-de,tt=Fi+de,Bt=Wi+de;if(_e=_e&&this.isOffscreen(ot,Ze,tt,Bt),ne=ne||this.isInsideGrid(ot,Ze,tt,Bt),!i&&this.grid.hitTestCircle(Fi,Wi,de,M)&&(ae=!0,!T))return{circles:[],offscreen:!1,collisionDetected:ae}}}}return{circles:!T&&ae||!ne?[]:R,offscreen:_e,collisionDetected:ae}}queryRenderedSymbols(i){if(i.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let o=[],h=1/0,d=1/0,f=-1/0,_=-1/0;for(let E of i){let M=new a.pointGeometry(E.x+or,E.y+or);h=Math.min(h,M.x),d=Math.min(d,M.y),f=Math.max(f,M.x),_=Math.max(_,M.y),o.push(M)}let y=this.grid.query(h,d,f,_).concat(this.ignoredGrid.query(h,d,f,_)),w={},T={};for(let E of y){let M=E.key;if(w[M.bucketInstanceId]===void 0&&(w[M.bucketInstanceId]={}),w[M.bucketInstanceId][M.featureIndex])continue;let z=[new a.pointGeometry(E.x1,E.y1),new a.pointGeometry(E.x2,E.y1),new a.pointGeometry(E.x2,E.y2),new a.pointGeometry(E.x1,E.y2)];a.polygonIntersectsPolygon(o,z)&&(w[M.bucketInstanceId][M.featureIndex]=!0,T[M.bucketInstanceId]===void 0&&(T[M.bucketInstanceId]=[]),T[M.bucketInstanceId].push(M.featureIndex))}return T}insertCollisionBox(i,o,h,d,f){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:h,featureIndex:d,collisionGroupID:f},i[0],i[1],i[2],i[3])}insertCollisionCircles(i,o,h,d,f){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:h,featureIndex:d,collisionGroupID:f};for(let w=0;w<i.length;w+=4)_.insertCircle(y,i[w],i[w+1],i[w+2])}projectAndGetPerspectiveRatio(i,o,h,d,f){let _=[o,h,d||0,1],y=!1;if(d||this.transform.pitch>0){a.transformMat4$1(_,_,i);let w=!1;this.fogState&&f&&(w=function(T,E,M,z,B,P){let R=P.calculateFogTileMatrix(B),q=[E,M,z];return a.transformMat4(q,q,R),fr(T,q,P.pitch,P._fov)}(this.fogState,o,h,d||0,f.toUnwrapped(),this.transform)>.9),y=_[2]>_[3]||w}else bo(_,_,i);return{point:new a.pointGeometry((_[0]/_[3]+1)/2*this.transform.width+or,(-_[1]/_[3]+1)/2*this.transform.height+or),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/_[3]*.5,1.5),signedDistanceFromCamera:_[3],aboveHorizon:y}}isOffscreen(i,o,h,d){return h<or||i>=this.screenRightBoundary||d<or||o>this.screenBottomBoundary}isInsideGrid(i,o,h,d){return h>=0&&i<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){let i=a.identity([]);return a.translate(i,i,[-100,-100,0]),i}}class pl{constructor(i,o,h,d){this.opacity=i?Math.max(0,Math.min(1,i.opacity+(i.placed?o:-o))):d&&h?1:0,this.placed=h}isHidden(){return this.opacity===0&&!this.placed}}class Pn{constructor(i,o,h,d,f,_=!1){this.text=new pl(i?i.text:null,o,h,f),this.icon=new pl(i?i.icon:null,o,d,f),this.clipped=_}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Dn{constructor(i,o,h,d=!1){this.text=i,this.icon=o,this.skipFade=h,this.clipped=d}}class wo{constructor(){this.invProjMatrix=a.create(),this.viewportMatrix=a.create(),this.circles=[]}}class fl{constructor(i,o,h,d,f){this.bucketInstanceId=i,this.featureIndex=o,this.sourceLayerIndex=h,this.bucketIndex=d,this.tileID=f}}class ml{constructor(i){this.crossSourceCollisions=i,this.maxGroupID=0,this.collisionGroups={}}get(i){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[i]){let o=++this.maxGroupID;this.collisionGroups[i]={ID:o,predicate:h=>h.collisionGroupID===o}}return this.collisionGroups[i]}}function ds(c,i,o,h,d){let{horizontalAlign:f,verticalAlign:_}=a.getAnchorAlignment(c),y=-(f-.5)*i,w=-(_-.5)*o,T=a.evaluateVariableOffset(c,h);return new a.pointGeometry(y+T[0]*d,w+T[1]*d)}function Dr(c,i,o,h,d){let f=new a.pointGeometry(c,i);return o&&f._rotate(h?d:-d),f}class ps{constructor(i,o,h,d,f){this.transform=i.clone(),this.collisionIndex=new Fc(this.transform,f),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new ml(h),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(i,o,h,d){let f=h.getBucket(o),_=h.latestFeatureIndex;if(!f||!_||o.id!==f.layerIds[0])return;let y=f.layers[0].layout,w=h.collisionBoxArray,T=Math.pow(2,this.transform.zoom-h.tileID.overscaledZ),E=h.tileSize/a.EXTENT,M=h.tileID.toUnwrapped(),z=this.transform.calculateProjMatrix(M),B=y.get("text-pitch-alignment")==="map",P=y.get("text-rotation-alignment")==="map";o.compileFilter();let R=o.dynamicFilter(),q=o.dynamicFilterNeedsFeature(),L=this.transform.calculatePixelsToTileUnitsMatrix(h),G=Pr(z,h.tileID.canonical,B,P,this.transform,L),Z=null;if(B){let X=gr(z,h.tileID.canonical,B,P,this.transform,L);Z=a.multiply$1([],this.transform.labelPlaneMatrix,X)}let N=null;R&&h.latestFeatureIndex&&(N={unwrappedTileID:M,dynamicFilter:R,dynamicFilterNeedsFeature:q,featureIndex:h.latestFeatureIndex}),this.retainedQueryData[f.bucketInstanceId]=new fl(f.bucketInstanceId,_,f.sourceLayerIndex,f.index,h.tileID);let j={bucket:f,layout:y,posMatrix:z,textLabelPlaneMatrix:G,labelToScreenMatrix:Z,clippingData:N,scale:T,textPixelRatio:E,holdingForFade:h.holdingForFade(),collisionBoxArray:w,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(d)for(let X of f.sortKeyRanges){let{sortKey:ie,symbolInstanceStart:oe,symbolInstanceEnd:Ee}=X;i.push({sortKey:ie,symbolInstanceStart:oe,symbolInstanceEnd:Ee,parameters:j})}else i.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:j})}attemptAnchorPlacement(i,o,h,d,f,_,y,w,T,E,M,z,B,P,R,q,L,G){let Z=[z.textOffset0,z.textOffset1],N=ds(i,h,d,Z,f),j=this.collisionIndex.placeCollisionBox(f,o,Dr(N.x,N.y,_,y,this.transform.angle),M,w,T,E.predicate);if((!q||this.collisionIndex.placeCollisionBox(P.getSymbolInstanceIconSize(G,this.transform.zoom,B),q,Dr(N.x,N.y,_,y,this.transform.angle),M,w,T,E.predicate).box.length!==0)&&j.box.length>0){let X;return this.prevPlacement&&this.prevPlacement.variableOffsets[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID].text&&(X=this.prevPlacement.variableOffsets[z.crossTileID].anchor),this.variableOffsets[z.crossTileID]={textOffset:Z,width:h,height:d,anchor:i,textScale:f,prevAnchor:X},this.markUsedJustification(P,i,z,R),P.allowVerticalPlacement&&(this.markUsedOrientation(P,R,z),this.placedOrientations[z.crossTileID]=R),{shift:N,placedGlyphBoxes:j}}}placeLayerBucketPart(i,o,h,d){let{bucket:f,layout:_,posMatrix:y,textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:E,textPixelRatio:M,holdingForFade:z,collisionBoxArray:B,partiallyEvaluatedTextSize:P,partiallyEvaluatedIconSize:R,collisionGroup:q}=i.parameters,L=_.get("text-optional"),G=_.get("icon-optional"),Z=_.get("text-allow-overlap"),N=_.get("icon-allow-overlap"),j=_.get("text-rotation-alignment")==="map",X=_.get("text-pitch-alignment")==="map",ie=_.get("icon-text-fit")!=="none",oe=_.get("symbol-z-order")==="viewport-y",Ee=Z&&(N||!f.hasIconData()||G),xe=N&&(Z||!f.hasTextData()||L);!f.collisionArrays&&B&&f.deserializeCollisionBoxes(B),h&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,B);let ge=(ae,ne,_e)=>{if(E){let ot={zoom:this.transform.zoom,pitch:this.transform.pitch},Ze=null;if(E.dynamicFilterNeedsFeature){let tt=this.retainedQueryData[f.bucketInstanceId];Ze=E.featureIndex.loadFeature({featureIndex:ae.featureIndex,bucketIndex:tt.bucketIndex,sourceLayerIndex:tt.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,E.dynamicFilter)(ot,Ze,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new a.pointGeometry(ae.tileAnchorX,ae.tileAnchorY),this.transform.calculateDistanceTileData(E.unwrappedTileID)))return this.placements[ae.crossTileID]=new Dn(!1,!1,!1,!0),void(o[ae.crossTileID]=!0)}if(o[ae.crossTileID])return;if(z)return void(this.placements[ae.crossTileID]=new Dn(!1,!1,!1));let de=!1,Be=!1,Ve=!0,Xe=null,Te={box:null,offscreen:null},Re={box:null,offscreen:null},Ge=null,ft=null,xt=null,je=0,Ye=0,It=0;_e.textFeatureIndex?je=_e.textFeatureIndex:ae.useRuntimeCollisionCircles&&(je=ae.featureIndex),_e.verticalTextFeatureIndex&&(Ye=_e.verticalTextFeatureIndex);let $t=ot=>{ot.tileID=this.retainedQueryData[f.bucketInstanceId].tileID,(this.transform.elevation||ot.elevation)&&(ot.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[f.bucketInstanceId].tileID,ot.tileAnchorX,ot.tileAnchorY):0)},fi=_e.textBox;if(fi){$t(fi);let ot=tt=>{let Bt=a.WritingMode.horizontal;if(f.allowVerticalPlacement&&!tt&&this.prevPlacement){let wi=this.prevPlacement.placedOrientations[ae.crossTileID];wi&&(this.placedOrientations[ae.crossTileID]=wi,Bt=wi,this.markUsedOrientation(f,Bt,ae))}return Bt},Ze=(tt,Bt)=>{if(f.allowVerticalPlacement&&ae.numVerticalGlyphVertices>0&&_e.verticalTextBox){for(let wi of f.writingModes)if(wi===a.WritingMode.vertical?(Te=Bt(),Re=Te):Te=tt(),Te&&Te.box&&Te.box.length)break}else Te=tt()};if(_.get("text-variable-anchor")){let tt=_.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[ae.crossTileID]){let Tt=this.prevPlacement.variableOffsets[ae.crossTileID];tt.indexOf(Tt.anchor)>0&&(tt=tt.filter(Ti=>Ti!==Tt.anchor),tt.unshift(Tt.anchor))}let Bt=(Tt,Ti,Xo)=>{let mi=f.getSymbolInstanceTextSize(P,ae,this.transform.zoom,ne),ln=(Tt.x2-Tt.x1)*mi+2*Tt.padding,Pe=(Tt.y2-Tt.y1)*mi+2*Tt.padding,Fe=ie&&!N?Ti:null;Fe&&$t(Fe);let Kt={box:[],offscreen:!1},cn=Z?2*tt.length:tt.length;for(let Zr=0;Zr<cn;++Zr){let ri=this.attemptAnchorPlacement(tt[Zr%tt.length],Tt,ln,Pe,mi,j,X,M,y,q,Zr>=tt.length,ae,ne,f,Xo,Fe,P,R);if(ri&&(Kt=ri.placedGlyphBoxes,Kt&&Kt.box&&Kt.box.length)){de=!0,Xe=ri.shift;break}}return Kt};Ze(()=>Bt(fi,_e.iconBox,a.WritingMode.horizontal),()=>{let Tt=_e.verticalTextBox;return Tt&&$t(Tt),f.allowVerticalPlacement&&!(Te&&Te.box&&Te.box.length)&&ae.numVerticalGlyphVertices>0&&Tt?Bt(Tt,_e.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),Te&&(de=Te.box,Ve=Te.offscreen);let wi=ot(Te&&Te.box);if(!de&&this.prevPlacement){let Tt=this.prevPlacement.variableOffsets[ae.crossTileID];Tt&&(this.variableOffsets[ae.crossTileID]=Tt,this.markUsedJustification(f,Tt.anchor,ae,wi))}}else{let tt=(Bt,wi)=>{let Tt=f.getSymbolInstanceTextSize(P,ae,this.transform.zoom,ne),Ti=this.collisionIndex.placeCollisionBox(Tt,Bt,new a.pointGeometry(0,0),Z,M,y,q.predicate);return Ti&&Ti.box&&Ti.box.length&&(this.markUsedOrientation(f,wi,ae),this.placedOrientations[ae.crossTileID]=wi),Ti};Ze(()=>tt(fi,a.WritingMode.horizontal),()=>{let Bt=_e.verticalTextBox;return f.allowVerticalPlacement&&ae.numVerticalGlyphVertices>0&&Bt?($t(Bt),tt(Bt,a.WritingMode.vertical)):{box:null,offscreen:null}}),ot(Te&&Te.box&&Te.box.length)}}if(Ge=Te,de=Ge&&Ge.box&&Ge.box.length>0,Ve=Ge&&Ge.offscreen,ae.useRuntimeCollisionCircles){let ot=f.text.placedSymbolArray.get(ae.centerJustifiedTextSymbolIndex>=0?ae.centerJustifiedTextSymbolIndex:ae.verticalPlacedTextSymbolIndex),Ze=a.evaluateSizeForFeature(f.textSizeData,P,ot),tt=_.get("text-padding");ft=this.collisionIndex.placeCollisionCircles(Z,ot,f.lineVertexArray,f.glyphOffsetArray,Ze,y,w,T,h,X,q.predicate,ae.collisionCircleDiameter*Ze/a.ONE_EM,tt,this.retainedQueryData[f.bucketInstanceId].tileID),de=Z||ft.circles.length>0&&!ft.collisionDetected,Ve=Ve&&ft.offscreen}if(_e.iconFeatureIndex&&(It=_e.iconFeatureIndex),_e.iconBox){let ot=Ze=>{$t(Ze);let tt=ie&&Xe?Dr(Xe.x,Xe.y,j,X,this.transform.angle):new a.pointGeometry(0,0),Bt=f.getSymbolInstanceIconSize(R,this.transform.zoom,ne);return this.collisionIndex.placeCollisionBox(Bt,Ze,tt,N,M,y,q.predicate)};Re&&Re.box&&Re.box.length&&_e.verticalIconBox?(xt=ot(_e.verticalIconBox),Be=xt.box.length>0):(xt=ot(_e.iconBox),Be=xt.box.length>0),Ve=Ve&&xt.offscreen}let Fi=L||ae.numHorizontalGlyphVertices===0&&ae.numVerticalGlyphVertices===0,Wi=G||ae.numIconVertices===0;if(Fi||Wi?Wi?Fi||(Be=Be&&de):de=Be&&de:Be=de=Be&&de,de&&Ge&&Ge.box&&this.collisionIndex.insertCollisionBox(Ge.box,_.get("text-ignore-placement"),f.bucketInstanceId,Re&&Re.box&&Ye?Ye:je,q.ID),Be&&xt&&this.collisionIndex.insertCollisionBox(xt.box,_.get("icon-ignore-placement"),f.bucketInstanceId,It,q.ID),ft&&(de&&this.collisionIndex.insertCollisionCircles(ft.circles,_.get("text-ignore-placement"),f.bucketInstanceId,je,q.ID),h)){let ot=f.bucketInstanceId,Ze=this.collisionCircleArrays[ot];Ze===void 0&&(Ze=this.collisionCircleArrays[ot]=new wo);for(let tt=0;tt<ft.circles.length;tt+=4)Ze.circles.push(ft.circles[tt+0]),Ze.circles.push(ft.circles[tt+1]),Ze.circles.push(ft.circles[tt+2]),Ze.circles.push(ft.collisionDetected?1:0)}this.placements[ae.crossTileID]=new Dn(de||Ee,Be||xe,Ve||f.justReloaded),o[ae.crossTileID]=!0};if(oe){let ae=f.getSortedSymbolIndexes(this.transform.angle);for(let ne=ae.length-1;ne>=0;--ne){let _e=ae[ne];ge(f.symbolInstances.get(_e),_e,f.collisionArrays[_e])}}else for(let ae=i.symbolInstanceStart;ae<i.symbolInstanceEnd;ae++)ge(f.symbolInstances.get(ae),ae,f.collisionArrays[ae]);if(h&&f.bucketInstanceId in this.collisionCircleArrays){let ae=this.collisionCircleArrays[f.bucketInstanceId];a.invert(ae.invProjMatrix,y),ae.viewportMatrix=this.collisionIndex.getViewportMatrix()}f.justReloaded=!1}markUsedJustification(i,o,h,d){let f;f=d===a.WritingMode.vertical?h.verticalPlacedTextSymbolIndex:{left:h.leftJustifiedTextSymbolIndex,center:h.centerJustifiedTextSymbolIndex,right:h.rightJustifiedTextSymbolIndex}[a.getAnchorJustification(o)];let _=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex,h.verticalPlacedTextSymbolIndex];for(let y of _)y>=0&&(i.text.placedSymbolArray.get(y).crossTileID=f>=0&&y!==f?0:h.crossTileID)}markUsedOrientation(i,o,h){let d=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly?o:0,f=o===a.WritingMode.vertical?o:0,_=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex];for(let y of _)i.text.placedSymbolArray.get(y).placedOrientation=d;h.verticalPlacedTextSymbolIndex&&(i.text.placedSymbolArray.get(h.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;let o=this.prevPlacement,h=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;let d=o?o.symbolFadeChange(i):1,f=o?o.opacities:{},_=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(let w in this.placements){let T=this.placements[w],E=f[w];E?(this.opacities[w]=new Pn(E,d,T.text,T.icon,null,T.clipped),h=h||T.text!==E.text.placed||T.icon!==E.icon.placed):(this.opacities[w]=new Pn(null,d,T.text,T.icon,T.skipFade,T.clipped),h=h||T.text||T.icon)}for(let w in f){let T=f[w];if(!this.opacities[w]){let E=new Pn(T,d,!1,!1);E.isHidden()||(this.opacities[w]=E,h=h||T.text.placed||T.icon.placed)}}for(let w in _)this.variableOffsets[w]||!this.opacities[w]||this.opacities[w].isHidden()||(this.variableOffsets[w]=_[w]);for(let w in y)this.placedOrientations[w]||!this.opacities[w]||this.opacities[w].isHidden()||(this.placedOrientations[w]=y[w]);h?this.lastPlacementChangeTime=i:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:i)}updateLayerOpacities(i,o){let h={};for(let d of o){let f=d.getBucket(i);f&&d.latestFeatureIndex&&i.id===f.layerIds[0]&&this.updateBucketOpacities(f,h,d.collisionBoxArray)}}updateBucketOpacities(i,o,h){i.hasTextData()&&i.text.opacityVertexArray.clear(),i.hasIconData()&&i.icon.opacityVertexArray.clear(),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexArray.clear(),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexArray.clear();let d=i.layers[0].layout,f=!!i.layers[0].dynamicFilter(),_=new Pn(null,0,!1,!1,!0),y=d.get("text-allow-overlap"),w=d.get("icon-allow-overlap"),T=d.get("text-variable-anchor"),E=d.get("text-rotation-alignment")==="map",M=d.get("text-pitch-alignment")==="map",z=d.get("icon-text-fit")!=="none",B=new Pn(null,0,y&&(w||!i.hasIconData()||d.get("icon-optional")),w&&(y||!i.hasTextData()||d.get("text-optional")),!0);!i.collisionArrays&&h&&(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData())&&i.deserializeCollisionBoxes(h);let P=(q,L,G)=>{for(let Z=0;Z<L/4;Z++)q.opacityVertexArray.emplaceBack(G)},R=0;for(let q=0;q<i.symbolInstances.length;q++){let L=i.symbolInstances.get(q),{numHorizontalGlyphVertices:G,numVerticalGlyphVertices:Z,crossTileID:N}=L,j=this.opacities[N];o[N]?j=_:j||(j=B,this.opacities[N]=j),o[N]=!0;let X=G>0||Z>0,ie=L.numIconVertices>0,oe=this.placedOrientations[L.crossTileID],Ee=oe===a.WritingMode.vertical,xe=oe===a.WritingMode.horizontal||oe===a.WritingMode.horizontalOnly;if(!X&&!ie||j.isHidden()||R++,X){let ge=fs(j.text);P(i.text,G,Ee?Rr:ge),P(i.text,Z,xe?Rr:ge);let ae=j.text.isHidden();[L.rightJustifiedTextSymbolIndex,L.centerJustifiedTextSymbolIndex,L.leftJustifiedTextSymbolIndex].forEach(de=>{de>=0&&(i.text.placedSymbolArray.get(de).hidden=ae||Ee?1:0)}),L.verticalPlacedTextSymbolIndex>=0&&(i.text.placedSymbolArray.get(L.verticalPlacedTextSymbolIndex).hidden=ae||xe?1:0);let ne=this.variableOffsets[L.crossTileID];ne&&this.markUsedJustification(i,ne.anchor,L,oe);let _e=this.placedOrientations[L.crossTileID];_e&&(this.markUsedJustification(i,"left",L,_e),this.markUsedOrientation(i,_e,L))}if(ie){let ge=fs(j.icon);L.placedIconSymbolIndex>=0&&(P(i.icon,L.numIconVertices,Ee?Rr:ge),i.icon.placedSymbolArray.get(L.placedIconSymbolIndex).hidden=j.icon.isHidden()),L.verticalPlacedIconSymbolIndex>=0&&(P(i.icon,L.numVerticalIconVertices,xe?Rr:ge),i.icon.placedSymbolArray.get(L.verticalPlacedIconSymbolIndex).hidden=j.icon.isHidden())}if(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData()){let ge=i.collisionArrays[q];if(ge){let ae=new a.pointGeometry(0,0),ne=!0;if(ge.textBox||ge.verticalTextBox){if(T){let de=this.variableOffsets[N];de?(ae=ds(de.anchor,de.width,de.height,de.textOffset,de.textScale),E&&ae._rotate(M?this.transform.angle:-this.transform.angle)):ne=!1}f&&(ne=!j.clipped),ge.textBox&&Lr(i.textCollisionBox.collisionVertexArray,j.text.placed,!ne||Ee,ae.x,ae.y),ge.verticalTextBox&&Lr(i.textCollisionBox.collisionVertexArray,j.text.placed,!ne||xe,ae.x,ae.y)}let _e=ne&&Boolean(!xe&&ge.verticalIconBox);ge.iconBox&&Lr(i.iconCollisionBox.collisionVertexArray,j.icon.placed,_e,z?ae.x:0,z?ae.y:0),ge.verticalIconBox&&Lr(i.iconCollisionBox.collisionVertexArray,j.icon.placed,!_e,z?ae.x:0,z?ae.y:0)}}}if(i.fullyClipped=R===0,i.sortFeatures(this.transform.angle),this.retainedQueryData[i.bucketInstanceId]&&(this.retainedQueryData[i.bucketInstanceId].featureSortOrder=i.featureSortOrder),i.hasTextData()&&i.text.opacityVertexBuffer&&i.text.opacityVertexBuffer.updateData(i.text.opacityVertexArray),i.hasIconData()&&i.icon.opacityVertexBuffer&&i.icon.opacityVertexBuffer.updateData(i.icon.opacityVertexArray),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexBuffer&&i.iconCollisionBox.collisionVertexBuffer.updateData(i.iconCollisionBox.collisionVertexArray),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexBuffer&&i.textCollisionBox.collisionVertexBuffer.updateData(i.textCollisionBox.collisionVertexArray),i.bucketInstanceId in this.collisionCircleArrays){let q=this.collisionCircleArrays[i.bucketInstanceId];i.placementInvProjMatrix=q.invProjMatrix,i.placementViewportMatrix=q.viewportMatrix,i.collisionCircleArray=q.circles,delete this.collisionCircleArrays[i.bucketInstanceId]}}symbolFadeChange(i){return this.fadeDuration===0?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(i,o){let h=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*h>i}setStale(){this.stale=!0}}function Lr(c,i,o,h,d){c.emplaceBack(i?1:0,o?1:0,h||0,d||0),c.emplaceBack(i?1:0,o?1:0,h||0,d||0),c.emplaceBack(i?1:0,o?1:0,h||0,d||0),c.emplaceBack(i?1:0,o?1:0,h||0,d||0)}let se=Math.pow(2,25),Ae=Math.pow(2,24),_l=Math.pow(2,17),Br=Math.pow(2,16),Ft=Math.pow(2,9),yr=Math.pow(2,8),sr=Math.pow(2,1);function fs(c){if(c.opacity===0&&!c.placed)return 0;if(c.opacity===1&&c.placed)return 4294967295;let i=c.placed?1:0,o=Math.floor(127*c.opacity);return o*se+i*Ae+o*_l+i*Br+o*Ft+i*yr+o*sr+i}let Rr=0;class Me{constructor(i){this._sortAcrossTiles=i.layout.get("symbol-z-order")!=="viewport-y"&&i.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,o,h,d,f){let _=this._bucketParts;for(;this._currentTileIndex<i.length;)if(o.getBucketParts(_,d,i[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,_.sort((y,w)=>y.sortKey-w.sortKey));this._currentPartIndex<_.length;){let y=_[this._currentPartIndex];if(o.placeLayerBucketPart(y,this._seenCrossTileIDs,h,y.symbolInstanceStart===0),this._currentPartIndex++,f())return!0}return!1}}class et{constructor(i,o,h,d,f,_,y,w){this.placement=new ps(i,f,_,y,w),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=h,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(i,o,h){let d=a.exported.now(),f=()=>{let _=a.exported.now()-d;return!this._forceFullPlacement&&_>2};for(;this._currentPlacementIndex>=0;){let _=o[i[this._currentPlacementIndex]],y=this.placement.collisionIndex.transform.zoom;if(_.type==="symbol"&&(!_.minzoom||_.minzoom<=y)&&(!_.maxzoom||_.maxzoom>y)){if(this._inProgressLayer||(this._inProgressLayer=new Me(_)),this._inProgressLayer.continuePlacement(h[_.source],this.placement,this._showCollisionBoxes,_,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}let We=512/a.EXTENT/2;class ar{constructor(i,o,h){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=h;for(let d=0;d<o.length;d++){let f=o.get(d),_=f.key;this.indexedSymbolInstances[_]||(this.indexedSymbolInstances[_]=[]),this.indexedSymbolInstances[_].push({crossTileID:f.crossTileID,coord:this.getScaledCoordinates(f,i)})}}getScaledCoordinates(i,o){let h=We/Math.pow(2,o.canonical.z-this.tileID.canonical.z);return{x:Math.floor((o.canonical.x*a.EXTENT+i.tileAnchorX)*h),y:Math.floor((o.canonical.y*a.EXTENT+i.tileAnchorY)*h)}}findMatches(i,o,h){let d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z);for(let f=0;f<i.length;f++){let _=i.get(f);if(_.crossTileID)continue;let y=this.indexedSymbolInstances[_.key];if(!y)continue;let w=this.getScaledCoordinates(_,o);for(let T of y)if(Math.abs(T.coord.x-w.x)<=d&&Math.abs(T.coord.y-w.y)<=d&&!h[T.crossTileID]){h[T.crossTileID]=!0,_.crossTileID=T.crossTileID;break}}}}class Ln{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class He{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(i){let o=Math.round((i-this.lng)/360);if(o!==0)for(let h in this.indexes){let d=this.indexes[h],f={};for(let _ in d){let y=d[_];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),f[y.tileID.key]=y}this.indexes[h]=f}this.lng=i}addBucket(i,o,h){if(this.indexes[i.overscaledZ]&&this.indexes[i.overscaledZ][i.key]){if(this.indexes[i.overscaledZ][i.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(i.overscaledZ,this.indexes[i.overscaledZ][i.key])}for(let f=0;f<o.symbolInstances.length;f++)o.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[i.overscaledZ]||(this.usedCrossTileIDs[i.overscaledZ]={});let d=this.usedCrossTileIDs[i.overscaledZ];for(let f in this.indexes){let _=this.indexes[f];if(Number(f)>i.overscaledZ)for(let y in _){let w=_[y];w.tileID.isChildOf(i)&&w.findMatches(o.symbolInstances,i,d)}else{let y=_[i.scaledTo(Number(f)).key];y&&y.findMatches(o.symbolInstances,i,d)}}for(let f=0;f<o.symbolInstances.length;f++){let _=o.symbolInstances.get(f);_.crossTileID||(_.crossTileID=h.generate(),d[_.crossTileID]=!0)}return this.indexes[i.overscaledZ]===void 0&&(this.indexes[i.overscaledZ]={}),this.indexes[i.overscaledZ][i.key]=new ar(i,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(i,o){for(let h in o.indexedSymbolInstances)for(let d of o.indexedSymbolInstances[h])delete this.usedCrossTileIDs[i][d.crossTileID]}removeStaleBuckets(i){let o=!1;for(let h in this.indexes){let d=this.indexes[h];for(let f in d)i[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(h,d[f]),delete d[f],o=!0)}return o}}class To{constructor(){this.layerIndexes={},this.crossTileIDs=new Ln,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(i,o,h,d){let f=this.layerIndexes[i.id];f===void 0&&(f=this.layerIndexes[i.id]=new He);let _=!1,y={};d.name!=="globe"&&f.handleWrapJump(h);for(let w of o){let T=w.getBucket(i);T&&i.id===T.layerIds[0]&&(T.bucketInstanceId||(T.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(w.tileID,T,this.crossTileIDs)&&(_=!0),y[T.bucketInstanceId]=!0)}return f.removeStaleBuckets(y)&&(_=!0),_}pruneUnusedLayers(i){let o={};i.forEach(h=>{o[h]=!0});for(let h in this.layerIndexes)o[h]||delete this.layerIndexes[h]}}let Fr=(c,i)=>a.emitValidationErrors(c,i&&i.filter(o=>o.identifier!=="source.canvas")),Eo=a.pick(pe,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Di=a.pick(pe,["setCenter","setZoom","setBearing","setPitch"]),kt=function(){let c={},i=a.spec.$version;for(let o in a.spec.$root){let h=a.spec.$root[o];if(h.required){let d=null;d=o==="version"?i:h.type==="array"?[]:{},d!=null&&(c[o]=d)}}return c}(),Oc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class di extends a.Evented{constructor(i,o={}){super(),this.map=i,this.dispatcher=new Qi(K(),this),this.imageManager=new Ai,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(i._requestManager,o.localFontFamily?a.LocalGlyphMode.all:o.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,o.localFontFamily||o.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new To,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());let h=this;this._rtlTextPluginCallback=di.registerForPluginStateChange(d=>{h.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,_)=>{if(a.triggerPluginCompletionEvent(f),_&&_.every(y=>y))for(let y in h._sourceCaches){let w=h._sourceCaches[y],T=w.getSource().type;T!=="vector"&&T!=="geojson"||w.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;let f=this.getSource(d.sourceId);if(f&&f.vectorLayerIds)for(let _ in this._layers){let y=this._layers[_];y.source===f.id&&this._validateLayer(y)}})}loadURL(i,o={}){this.fire(new a.Event("dataloading",{dataType:"style"}));let h=typeof o.validate=="boolean"?o.validate:!a.isMapboxURL(i);i=this.map._requestManager.normalizeStyleURL(i,o.accessToken);let d=this.map._requestManager.transformRequest(i,a.ResourceType.Style);this._request=a.getJSON(d,(f,_)=>{this._request=null,f?this.fire(new a.ErrorEvent(f)):_&&this._load(_,h)})}loadJSON(i,o={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(i,o.validate!==!1)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(kt,!1)}_updateLayerCount(i,o){let h=o?1:-1;i.is3D()&&(this._num3DLayers+=h),i.type==="circle"&&(this._numCircleLayers+=h),i.type==="symbol"&&(this._numSymbolLayers+=h)}_load(i,o){if(o&&Fr(this,a.validateStyle(i)))return;this._loaded=!0,this.stylesheet=i,this.updateProjection();for(let d in i.sources)this.addSource(d,i.sources[d],{validate:!1});this._changed=!1,i.sprite?this._loadSprite(i.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(i.glyphs);let h=ue(this.stylesheet.layers);this._order=h.map(d=>d.id),this._layers={},this._serializedLayers={};for(let d of h)d=a.createStyleLayer(d),d.setEventedParent(this,{layer:{id:d.id}}),this._layers[d.id]=d,this._serializedLayers[d.id]=d.serialize(),this._updateLayerCount(d,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Yr(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&this.terrain.drapeRenderMode===0}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){let i=this.map.transform.projection,o=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),h=this.map.transform.projection;if(this._loaded&&(h.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),o){if(h.isReprojectedInTileSpace||i.isReprojectedInTileSpace){this.map.painter.clearBackgroundTiles();for(let d in this._sourceCaches)this._sourceCaches[d].clearTiles()}else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(i){this._spriteRequest=function(o,h,d){let f,_,y,w=a.exported.devicePixelRatio>1?"@2x":"",T=a.getJSON(h.transformRequest(h.normalizeSpriteURL(o,w,".json"),a.ResourceType.SpriteJSON),(z,B)=>{T=null,y||(y=z,f=B,M())}),E=a.getImage(h.transformRequest(h.normalizeSpriteURL(o,w,".png"),a.ResourceType.SpriteImage),(z,B)=>{E=null,y||(y=z,_=B,M())});function M(){if(y)d(y);else if(f&&_){let z=a.exported.getImageData(_),B={};for(let P in f){let{width:R,height:q,x:L,y:G,sdf:Z,pixelRatio:N,stretchX:j,stretchY:X,content:ie}=f[P],oe=new a.RGBAImage({width:R,height:q});a.RGBAImage.copy(z,oe,{x:L,y:G},{x:0,y:0},{width:R,height:q}),B[P]={data:oe,pixelRatio:N,sdf:Z,stretchX:j,stretchY:X,content:ie}}d(null,B)}}return{cancel(){T&&(T.cancel(),T=null),E&&(E.cancel(),E=null)}}}(i,this.map._requestManager,(o,h)=>{if(this._spriteRequest=null,o)this.fire(new a.ErrorEvent(o));else if(h)for(let d in h)this.imageManager.addImage(d,h[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(i){let o=this.getSource(i.source);if(!o)return;let h=i.sourceLayer;h&&(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(h)===-1)&&this.fire(new a.ErrorEvent(new Error(`Source layer "${h}" does not exist on source "${o.id}" as specified by style layer "${i.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){let o=[];for(let h of i){let d=this._layers[h];d.type!=="custom"&&o.push(d.serialize())}return o}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(let i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(let i in this._layers)if(this._layers[i].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&Oc[i.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(i){if(!this._loaded)return;let o=this._changed;if(this._changed){let d=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);(d.length||f.length)&&this._updateWorkerLayers(d,f);for(let _ in this._updatedSources){let y=this._updatedSources[_];y==="reload"?this._reloadSource(_):y==="clear"&&this._clearSource(_)}this._updateTilesForChangedImages();for(let _ in this._updatedPaintProps)this._layers[_].updateTransitions(i);this.light.updateTransitions(i),this.fog&&this.fog.updateTransitions(i),this._resetUpdates()}let h={};for(let d in this._sourceCaches){let f=this._sourceCaches[d];h[d]=f.used,f.used=!1}for(let d of this._order){let f=this._layers[d];if(f.recalculate(i,this._availableImages),!f.isHidden(i.zoom)){let y=this._getLayerSourceCache(f);y&&(y.used=!0)}let _=this.map.painter;if(_){let y=f.getProgramIds();if(!y)continue;let w=f.getProgramConfiguration(i.zoom);for(let T of y)_.useProgram(T,w)}}for(let d in h){let f=this._sourceCaches[d];h[d]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(i),this.terrain&&this.terrain.recalculate(i),this.fog&&this.fog.recalculate(i),this.z=i.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){let i=Object.keys(this._changedImages);if(i.length){for(let o in this._sourceCaches)this._sourceCaches[o].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,o){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:o})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),Fr(this,a.validateStyle(i)))return!1;(i=a.clone$1(i)).layers=ue(i.layers);let o=function(d,f){if(!d)return[{command:pe.setStyle,args:[f]}];let _=[];try{if(!qe(d.version,f.version))return[{command:pe.setStyle,args:[f]}];qe(d.center,f.center)||_.push({command:pe.setCenter,args:[f.center]}),qe(d.zoom,f.zoom)||_.push({command:pe.setZoom,args:[f.zoom]}),qe(d.bearing,f.bearing)||_.push({command:pe.setBearing,args:[f.bearing]}),qe(d.pitch,f.pitch)||_.push({command:pe.setPitch,args:[f.pitch]}),qe(d.sprite,f.sprite)||_.push({command:pe.setSprite,args:[f.sprite]}),qe(d.glyphs,f.glyphs)||_.push({command:pe.setGlyphs,args:[f.glyphs]}),qe(d.transition,f.transition)||_.push({command:pe.setTransition,args:[f.transition]}),qe(d.light,f.light)||_.push({command:pe.setLight,args:[f.light]}),qe(d.fog,f.fog)||_.push({command:pe.setFog,args:[f.fog]}),qe(d.projection,f.projection)||_.push({command:pe.setProjection,args:[f.projection]});let y={},w=[];(function(M,z,B,P){let R;for(R in z=z||{},M=M||{})M.hasOwnProperty(R)&&(z.hasOwnProperty(R)||Le(R,B,P));for(R in z)z.hasOwnProperty(R)&&(M.hasOwnProperty(R)?qe(M[R],z[R])||(M[R].type==="geojson"&&z[R].type==="geojson"&&Ue(M,z,R)?B.push({command:pe.setGeoJSONSourceData,args:[R,z[R].data]}):Oe(R,z,B,P)):ye(R,z,B))})(d.sources,f.sources,w,y);let T=[];d.layers&&d.layers.forEach(M=>{y[M.source]?_.push({command:pe.removeLayer,args:[M.id]}):T.push(M)});let E=d.terrain;E&&y[E.source]&&(_.push({command:pe.setTerrain,args:[void 0]}),E=void 0),_=_.concat(w),qe(E,f.terrain)||_.push({command:pe.setTerrain,args:[f.terrain]}),function(M,z,B){z=z||[];let P=(M=M||[]).map(Ke),R=z.map(Ke),q=M.reduce(wt,{}),L=z.reduce(wt,{}),G=P.slice(),Z=Object.create(null),N,j,X,ie,oe,Ee,xe;for(N=0,j=0;N<P.length;N++)X=P[N],L.hasOwnProperty(X)?j++:(B.push({command:pe.removeLayer,args:[X]}),G.splice(G.indexOf(X,j),1));for(N=0,j=0;N<R.length;N++)X=R[R.length-1-N],G[G.length-1-N]!==X&&(q.hasOwnProperty(X)?(B.push({command:pe.removeLayer,args:[X]}),G.splice(G.lastIndexOf(X,G.length-j),1)):j++,Ee=G[G.length-N],B.push({command:pe.addLayer,args:[L[X],Ee]}),G.splice(G.length-N,0,X),Z[X]=!0);for(N=0;N<R.length;N++)if(X=R[N],ie=q[X],oe=L[X],!Z[X]&&!qe(ie,oe))if(qe(ie.source,oe.source)&&qe(ie["source-layer"],oe["source-layer"])&&qe(ie.type,oe.type)){for(xe in Ne(ie.layout,oe.layout,B,X,null,pe.setLayoutProperty),Ne(ie.paint,oe.paint,B,X,null,pe.setPaintProperty),qe(ie.filter,oe.filter)||B.push({command:pe.setFilter,args:[X,oe.filter]}),qe(ie.minzoom,oe.minzoom)&&qe(ie.maxzoom,oe.maxzoom)||B.push({command:pe.setLayerZoomRange,args:[X,oe.minzoom,oe.maxzoom]}),ie)ie.hasOwnProperty(xe)&&xe!=="layout"&&xe!=="paint"&&xe!=="filter"&&xe!=="metadata"&&xe!=="minzoom"&&xe!=="maxzoom"&&(xe.indexOf("paint.")===0?Ne(ie[xe],oe[xe],B,X,xe.slice(6),pe.setPaintProperty):qe(ie[xe],oe[xe])||B.push({command:pe.setLayerProperty,args:[X,xe,oe[xe]]}));for(xe in oe)oe.hasOwnProperty(xe)&&!ie.hasOwnProperty(xe)&&xe!=="layout"&&xe!=="paint"&&xe!=="filter"&&xe!=="metadata"&&xe!=="minzoom"&&xe!=="maxzoom"&&(xe.indexOf("paint.")===0?Ne(ie[xe],oe[xe],B,X,xe.slice(6),pe.setPaintProperty):qe(ie[xe],oe[xe])||B.push({command:pe.setLayerProperty,args:[X,xe,oe[xe]]}))}else B.push({command:pe.removeLayer,args:[X]}),Ee=G[G.lastIndexOf(X)+1],B.push({command:pe.addLayer,args:[oe,Ee]})}(T,f.layers,_)}catch(y){console.warn("Unable to compute style diff:",y),_=[{command:pe.setStyle,args:[f]}]}return _}(this.serialize(),i).filter(d=>!(d.command in Di));if(o.length===0)return!1;let h=o.filter(d=>!(d.command in Eo));if(h.length>0)throw new Error(`Unimplemented: ${h.map(d=>d.command).join(", ")}.`);return o.forEach(d=>{d.command!=="setTransition"&&this[d.command].apply(this,d.args)}),this.stylesheet=i,this.updateProjection(),!0}addImage(i,o){if(this.getImage(i))return this.fire(new a.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(i,o),this._afterImageUpdated(i)}updateImage(i,o){this.imageManager.updateImage(i,o)}getImage(i){return this.imageManager.getImage(i)}removeImage(i){if(!this.getImage(i))return this.fire(new a.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(i),this._afterImageUpdated(i)}_afterImageUpdated(i){this._availableImages=this.imageManager.listImages(),this._changedImages[i]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(i,o,h={}){if(this._checkLoaded(),this.getSource(i)!==void 0)throw new Error("There is already a source with this ID");if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(o.type)>=0&&this._validate(a.validateStyle.source,`sources.${i}`,o,null,h))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);let d=vi(i,o,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:d.serialize(),sourceId:i}));let f=_=>{let y=(_?"symbol:":"other:")+i,w=this._sourceCaches[y]=new a.SourceCache(y,d,_);(_?this._symbolSourceCaches:this._otherSourceCaches)[i]=w,w.style=this,w.onAdd(this.map)};f(!1),o.type!=="vector"&&o.type!=="geojson"||f(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(i){this._checkLoaded();let o=this.getSource(i);if(o===void 0)throw new Error("There is no source with this ID");for(let d in this._layers)if(this._layers[d].source===i)return this.fire(new a.ErrorEvent(new Error(`Source "${i}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.get().source===i)return this.fire(new a.ErrorEvent(new Error(`Source "${i}" cannot be removed while terrain is using it.`)));let h=this._getSourceCaches(i);for(let d of h)delete this._sourceCaches[d.id],delete this._updatedSources[d.id],d.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles();delete this._otherSourceCaches[i],delete this._symbolSourceCaches[i],o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,o){this._checkLoaded(),this.getSource(i).setData(o),this._changed=!0}getSource(i){let o=this._getSourceCache(i);return o&&o.getSource()}addLayer(i,o,h={}){this._checkLoaded();let d=i.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let f;if(i.type==="custom"){if(Fr(this,a.validateCustomStyleLayer(i)))return;f=a.createStyleLayer(i)}else{if(typeof i.source=="object"&&(this.addSource(d,i.source),i=a.clone$1(i),i=a.extend(i,{source:d})),this._validate(a.validateStyle.layer,`layers.${d}`,i,{arrayIndex:-1},h))return;f=a.createStyleLayer(i),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}let _=o?this._order.indexOf(o):this._order.length;if(o&&_===-1)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`)));this._order.splice(_,0,d),this._layerOrderChanged=!0,this._layers[d]=f;let y=this._getLayerSourceCache(f);if(this._removedLayers[d]&&f.source&&y&&f.type!=="custom"){let w=this._removedLayers[d];delete this._removedLayers[d],w.type!==f.type?this._updatedSources[f.source]="clear":(this._updatedSources[f.source]="reload",y.pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(i,o){if(this._checkLoaded(),this._changed=!0,!this._layers[i])return void this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be moved.`)));if(i===o)return;let h=this._order.indexOf(i);this._order.splice(h,1);let d=o?this._order.indexOf(o):this._order.length;o&&d===-1?this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`))):(this._order.splice(d,0,i),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(i){this._checkLoaded();let o=this._layers[i];if(!o)return void this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be removed.`)));o.setEventedParent(null),this._updateLayerCount(o,!1);let h=this._order.indexOf(i);this._order.splice(h,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[i]=o,delete this._layers[i],delete this._serializedLayers[i],delete this._updatedLayers[i],delete this._updatedPaintProps[i],o.onRemove&&o.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(let o in this._layers)if(this._layers[o].type===i)return!0;return!1}setLayerZoomRange(i,o,h){this._checkLoaded();let d=this.getLayer(i);d?d.minzoom===o&&d.maxzoom===h||(o!=null&&(d.minzoom=o),h!=null&&(d.maxzoom=h),this._updateLayer(d)):this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,o,h={}){this._checkLoaded();let d=this.getLayer(i);if(d){if(!qe(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(a.validateStyle.filter,`layers.${d.id}.filter`,o,{layerType:d.type},h)||(d.filter=a.clone$1(o),this._updateLayer(d)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(i){return a.clone$1(this.getLayer(i).filter)}setLayoutProperty(i,o,h,d={}){this._checkLoaded();let f=this.getLayer(i);f?qe(f.getLayoutProperty(o),h)||(f.setLayoutProperty(o,h,d),this._updateLayer(f)):this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(i,o){let h=this.getLayer(i);if(h)return h.getLayoutProperty(o);this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style.`)))}setPaintProperty(i,o,h,d={}){this._checkLoaded();let f=this.getLayer(i);f?qe(f.getPaintProperty(o),h)||(f.setPaintProperty(o,h,d)&&this._updateLayer(f),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,o){return this.getLayer(i).getPaintProperty(o)}setFeatureState(i,o){this._checkLoaded();let h=i.source,d=i.sourceLayer,f=this.getSource(h);if(f===void 0)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));let _=f.type;if(_==="geojson"&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(_==="vector"&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));i.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));let y=this._getSourceCaches(h);for(let w of y)w.setFeatureState(d,i.id,o)}removeFeatureState(i,o){this._checkLoaded();let h=i.source,d=this.getSource(h);if(d===void 0)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));let f=d.type,_=f==="vector"?i.sourceLayer:void 0;if(f==="vector"&&!_)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof i.id!="string"&&typeof i.id!="number")return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));let y=this._getSourceCaches(h);for(let w of y)w.removeFeatureState(_,i.id,o)}getFeatureState(i){this._checkLoaded();let o=i.source,h=i.sourceLayer,d=this.getSource(o);if(d!==void 0){if(d.type!=="vector"||h)return i.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(o)[0].getFeatureState(h,i.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${o}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){let i={};for(let o in this._sourceCaches){let h=this._sourceCaches[o].getSource();i[h.id]||(i[h.id]=h.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,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,projection:this.stylesheet.projection,sources:i,layers:this._serializeLayers(this._order)},o=>o!==void 0)}_updateLayer(i){this._updatedLayers[i.id]=!0;let o=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&o&&o.getSource().type!=="raster"&&(this._updatedSources[i.source]="reload",o.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){let o=_=>this._layers[_].type==="fill-extrusion",h={},d=[];for(let _=this._order.length-1;_>=0;_--){let y=this._order[_];if(o(y)){h[y]=_;for(let w of i){let T=w[y];if(T)for(let E of T)d.push(E)}}}d.sort((_,y)=>y.intersectionZ-_.intersectionZ);let f=[];for(let _=this._order.length-1;_>=0;_--){let y=this._order[_];if(o(y))for(let w=d.length-1;w>=0;w--){let T=d[w].feature;if(h[T.layer.id]<_)break;f.push(T),d.pop()}else for(let w of i){let T=w[y];if(T)for(let E of T)f.push(E.feature)}}return f}queryRenderedFeatures(i,o,h){o&&o.filter&&this._validate(a.validateStyle.filter,"queryRenderedFeatures.filter",o.filter,null,o);let d={};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new a.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(let w of o.layers){let T=this._layers[w];if(!T)return this.fire(new a.ErrorEvent(new Error(`The layer '${w}' does not exist in the map's style and cannot be queried for features.`))),[];d[T.source]=!0}}let f=[];o.availableImages=this._availableImages;let _=o&&o.layers?o.layers.some(w=>{let T=this.getLayer(w);return T&&T.is3D()}):this.has3DLayers(),y=Cn.createFromScreenPoints(i,h);for(let w in this._sourceCaches){let T=this._sourceCaches[w].getSource().id;o.layers&&!d[T]||f.push(S(this._sourceCaches[w],this._layers,this._serializedLayers,y,o,h,_,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(w,T,E,M,z,B,P){let R={},q=B.queryRenderedSymbols(M),L=[];for(let G of Object.keys(q).map(Number))L.push(P[G]);L.sort(F);for(let G of L){let Z=G.featureIndex.lookupSymbolFeatures(q[G.bucketInstanceId],T,G.bucketIndex,G.sourceLayerIndex,z.filter,z.layers,z.availableImages,w);for(let N in Z){let j=R[N]=R[N]||[],X=Z[N];X.sort((ie,oe)=>{let Ee=G.featureSortOrder;if(Ee){let xe=Ee.indexOf(ie.featureIndex);return Ee.indexOf(oe.featureIndex)-xe}return oe.featureIndex-ie.featureIndex});for(let ie of X)j.push(ie)}}for(let G in R)R[G].forEach(Z=>{let N=Z.feature,j=E(w[G]).getFeatureState(N.layer["source-layer"],N.id);N.source=N.layer.source,N.layer["source-layer"]&&(N.sourceLayer=N.layer["source-layer"]),N.state=j});return R}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),y.screenGeometry,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(i,o){o&&o.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",o.filter,null,o);let h=this._getSourceCaches(i),d=[];for(let f of h)d=d.concat(C(f,o));return d}addSourceType(i,o,h){return di.getSourceType(i)?h(new Error(`A source type called "${i}" already exists.`)):(di.setSourceType(i,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:i,url:o.workerSourceURL},h):h(null,null))}getLight(){return this.light.getLight()}setLight(i,o={}){this._checkLoaded();let h=this.light.getLight(),d=!1;for(let _ in i)if(!qe(i[_],h[_])){d=!0;break}if(!d)return;let f={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(i,o),this.light.updateTransitions(f)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,o=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(o===1){if(typeof i.source=="object"){let h="terrain-dem-src";this.addSource(h,i.source),i=a.clone$1(i),i=a.extend(i,{source:h})}if(this._validate(a.validateStyle.terrain,"terrain",i))return}if(!this.terrain||this.terrain&&o!==this.terrain.drapeRenderMode)this._createTerrain(i,o);else{let h=this.terrain,d=h.get();for(let f in i)if(!qe(i[f],d[f])){h.set(i),this.stylesheet.terrain=i;let _={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};h.updateTransitions(_);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(i){let o=this.fog=new ua(i,this.map.transform);this.stylesheet.fog=i;let h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(h)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(let i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(i){if(this._checkLoaded(),!i)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){let o=this.fog,h=o.get();for(let d in i)if(!qe(i[d],h[d])){o.set(i),this.stylesheet.fog=i;let f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(f);break}}else this._createFog(i);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;let i=this._order.filter(h=>this.isLayerDraped(this._layers[h])),o=this._order.filter(h=>!this.isLayerDraped(this._layers[h]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...o)}_createTerrain(i,o){let h=this.terrain=new is(i,o);this.stylesheet.terrain=i,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();let d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};h.updateTransitions(d)}_force3DLayerUpdate(){for(let i in this._layers){let o=this._layers[i];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(let i in this._layers){let o=this._layers[i];o.type==="symbol"&&this._updateLayer(o)}}_validate(i,o,h,d,f={}){return(!f||f.validate!==!1)&&Fr(this,i.call(a.validateStyle,a.extend({key:o,style:this.serialize(),value:h,styleSpec:a.spec},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(let i in this._layers)this._layers[i].setEventedParent(null);for(let i in this._sourceCaches)this._sourceCaches[i].clearTiles(),this._sourceCaches[i].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){let o=this._getSourceCaches(i);for(let h of o)h.clearTiles()}_reloadSource(i){let o=this._getSourceCaches(i);for(let h of o)h.resume(),h.reload()}_updateSources(i){for(let o in this._sourceCaches)this._sourceCaches[o].update(i)}_generateCollisionBoxes(){for(let i in this._sourceCaches){let o=this._sourceCaches[i];o.resume(),o.reload()}}_updatePlacement(i,o,h,d,f=!1){let _=!1,y=!1,w={};for(let T of this._order){let E=this._layers[T];if(E.type!=="symbol")continue;if(!w[E.source]){let z=this._getLayerSourceCache(E);if(!z)continue;w[E.source]=z.getRenderableIds(!0).map(B=>z.getTileByID(B)).sort((B,P)=>P.tileID.overscaledZ-B.tileID.overscaledZ||(B.tileID.isLessThan(P.tileID)?-1:1))}let M=this.crossTileSymbolIndex.addLayer(E,w[E.source],i.center.lng,i.projection);_=_||M}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),f=f||this._layerOrderChanged||h===0,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(f||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),i.zoom))&&(this.pauseablePlacement=new et(i,this._order,f,o,h,d,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,w),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),y=!0),_&&this.pauseablePlacement.placement.setStale()),y||_)for(let T of this._order){let E=this._layers[T];E.type==="symbol"&&this.placement.updateLayerOpacities(E,w[E.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(let i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,o,h){this.imageManager.getImages(o.icons,h),this._updateTilesForChangedImages();let d=f=>{f&&f.setDependencies(o.tileID.key,o.type,o.icons)};d(this._otherSourceCaches[o.source]),d(this._symbolSourceCaches[o.source])}getGlyphs(i,o,h){this.glyphManager.getGlyphs(o.stacks,h)}getResource(i,o,h){return a.makeRequest(o,h)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return i.type==="symbol"?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){let o=[];return this._otherSourceCaches[i]&&o.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&o.push(this._symbolSourceCaches[i]),o}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}di.getSourceType=function(c){return kn[c]},di.setSourceType=function(c,i){kn[c]=i},di.registerForPluginStateChange=a.registerForPluginStateChange;var ms=`
|
|
9
|
-
#define EPSILON 0.0000001
|
|
10
|
-
#define PI 3.141592653589793
|
|
11
|
-
#define EXTENT 8192.0
|
|
12
|
-
#ifdef FOG
|
|
13
|
-
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}
|
|
14
|
-
#endif`,Bn="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let Rn={},Fn={};Rn=$e("",`
|
|
15
|
-
#define ELEVATION_SCALE 7.0
|
|
16
|
-
#define ELEVATION_OFFSET 450.0
|
|
17
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
18
|
-
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
|
|
19
|
-
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
|
|
20
|
-
#else
|
|
21
|
-
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
|
|
22
|
-
#endif
|
|
23
|
-
#ifdef TERRAIN
|
|
24
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
25
|
-
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
|
|
26
|
-
#else
|
|
27
|
-
uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
|
|
28
|
-
#endif
|
|
29
|
-
uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
|
|
30
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
31
|
-
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
|
|
32
|
-
#else
|
|
33
|
-
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
|
|
34
|
-
#ifdef TERRAIN_DEM_NEAREST_FILTER
|
|
35
|
-
return u_exaggeration*tl;
|
|
36
|
-
#endif
|
|
37
|
-
float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
|
|
38
|
-
#endif
|
|
39
|
-
}float prevElevation(vec2 apos) {
|
|
40
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
41
|
-
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
|
|
42
|
-
#else
|
|
43
|
-
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
|
|
44
|
-
#endif
|
|
45
|
-
}
|
|
46
|
-
#ifdef TERRAIN_VERTEX_MORPHING
|
|
47
|
-
float elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
|
|
48
|
-
#else
|
|
49
|
-
float elevation(vec2 apos) {return currentElevation(apos);}
|
|
50
|
-
#endif
|
|
51
|
-
float unpack_depth(vec4 rgba_depth)
|
|
52
|
-
{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
|
|
53
|
-
unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
|
|
54
|
-
);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
|
|
55
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
56
|
-
float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
|
|
57
|
-
#else
|
|
58
|
-
vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
|
|
59
|
-
#endif
|
|
60
|
-
return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
|
|
61
|
-
#else
|
|
62
|
-
float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
|
|
63
|
-
#endif`,!0),Fn=$e(`#ifdef FOG
|
|
64
|
-
uniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
|
|
65
|
-
#endif`,`#ifdef FOG
|
|
66
|
-
uniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
|
|
67
|
-
#endif`,!0);let lt=$e(`
|
|
68
|
-
highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}
|
|
69
|
-
#ifdef TERRAIN
|
|
70
|
-
highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
|
|
71
|
-
#endif`,`
|
|
72
|
-
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
|
|
73
|
-
#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)
|
|
74
|
-
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
|
|
75
|
-
#else
|
|
76
|
-
return vec3(0.0);
|
|
77
|
-
#endif
|
|
78
|
-
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {
|
|
79
|
-
#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)
|
|
80
|
-
return mix(globe,mercator,t);
|
|
81
|
-
#else
|
|
82
|
-
return globe;
|
|
83
|
-
#endif
|
|
84
|
-
}
|
|
85
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
86
|
-
mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
|
|
87
|
-
#endif
|
|
88
|
-
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
|
|
89
|
-
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
|
90
|
-
);}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;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),_s=ms;var _a={background:$e(`uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;
|
|
91
|
-
#ifdef FOG
|
|
92
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
93
|
-
#endif
|
|
94
|
-
gl_FragColor=out_color*u_opacity;
|
|
95
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
96
|
-
gl_FragColor=vec4(1.0);
|
|
97
|
-
#endif
|
|
98
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
|
|
99
|
-
#ifdef FOG
|
|
100
|
-
v_fog_pos=fog_position(a_pos);
|
|
101
|
-
#endif
|
|
102
|
-
}`),backgroundPattern:$e(`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);vec4 out_color=mix(color1,color2,u_mix);
|
|
103
|
-
#ifdef FOG
|
|
104
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
105
|
-
#endif
|
|
106
|
-
gl_FragColor=out_color*u_opacity;
|
|
107
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
108
|
-
gl_FragColor=vec4(1.0);
|
|
109
|
-
#endif
|
|
110
|
-
}`,`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);
|
|
111
|
-
#ifdef FOG
|
|
112
|
-
v_fog_pos=fog_position(a_pos);
|
|
113
|
-
#endif
|
|
114
|
-
}`),circle:$e(`varying vec3 v_data;varying float v_visibility;
|
|
115
|
-
#pragma mapbox: define highp vec4 color
|
|
116
|
-
#pragma mapbox: define mediump float radius
|
|
117
|
-
#pragma mapbox: define lowp float blur
|
|
118
|
-
#pragma mapbox: define lowp float opacity
|
|
119
|
-
#pragma mapbox: define highp vec4 stroke_color
|
|
120
|
-
#pragma mapbox: define mediump float stroke_width
|
|
121
|
-
#pragma mapbox: define lowp float stroke_opacity
|
|
122
|
-
void main() {
|
|
123
|
-
#pragma mapbox: initialize highp vec4 color
|
|
124
|
-
#pragma mapbox: initialize mediump float radius
|
|
125
|
-
#pragma mapbox: initialize lowp float blur
|
|
126
|
-
#pragma mapbox: initialize lowp float opacity
|
|
127
|
-
#pragma mapbox: initialize highp vec4 stroke_color
|
|
128
|
-
#pragma mapbox: initialize mediump float stroke_width
|
|
129
|
-
#pragma mapbox: initialize lowp float stroke_opacity
|
|
130
|
-
vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
|
|
131
|
-
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
|
|
132
|
-
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
|
|
133
|
-
#ifdef FOG
|
|
134
|
-
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
|
|
135
|
-
#endif
|
|
136
|
-
gl_FragColor=out_color*(v_visibility*opacity_t);
|
|
137
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
138
|
-
gl_FragColor=vec4(1.0);
|
|
139
|
-
#endif
|
|
140
|
-
}`,`#define NUM_VISIBILITY_RINGS 2
|
|
141
|
-
#define INV_SQRT2 0.70710678
|
|
142
|
-
#define ELEVATION_BIAS 0.0001
|
|
143
|
-
#define NUM_SAMPLES_PER_RING 16
|
|
144
|
-
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
|
|
145
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
146
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
|
|
147
|
-
#endif
|
|
148
|
-
varying vec3 v_data;varying float v_visibility;
|
|
149
|
-
#pragma mapbox: define highp vec4 color
|
|
150
|
-
#pragma mapbox: define mediump float radius
|
|
151
|
-
#pragma mapbox: define lowp float blur
|
|
152
|
-
#pragma mapbox: define lowp float opacity
|
|
153
|
-
#pragma mapbox: define highp vec4 stroke_color
|
|
154
|
-
#pragma mapbox: define mediump float stroke_width
|
|
155
|
-
#pragma mapbox: define lowp float stroke_opacity
|
|
156
|
-
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
|
|
157
|
-
#if defined(TERRAIN)
|
|
158
|
-
return elevation(pos)+ELEVATION_BIAS;
|
|
159
|
-
#else
|
|
160
|
-
return 0.0;
|
|
161
|
-
#endif
|
|
162
|
-
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
|
|
163
|
-
#ifdef PITCH_WITH_MAP
|
|
164
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
165
|
-
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
|
|
166
|
-
#else
|
|
167
|
-
return u_matrix*( world_center+vec4(sample_offset,0,0) );
|
|
168
|
-
#endif
|
|
169
|
-
#else
|
|
170
|
-
return projected_center+vec4(sample_offset,0,0);
|
|
171
|
-
#endif
|
|
172
|
-
}float get_sample_step() {
|
|
173
|
-
#ifdef PITCH_WITH_MAP
|
|
174
|
-
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
|
|
175
|
-
#else
|
|
176
|
-
return PI/float(NUM_SAMPLES_PER_RING);
|
|
177
|
-
#endif
|
|
178
|
-
}void main(void) {
|
|
179
|
-
#pragma mapbox: initialize highp vec4 color
|
|
180
|
-
#pragma mapbox: initialize mediump float radius
|
|
181
|
-
#pragma mapbox: initialize lowp float blur
|
|
182
|
-
#pragma mapbox: initialize lowp float opacity
|
|
183
|
-
#pragma mapbox: initialize highp vec4 stroke_color
|
|
184
|
-
#pragma mapbox: initialize mediump float stroke_width
|
|
185
|
-
#pragma mapbox: initialize lowp float stroke_opacity
|
|
186
|
-
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);
|
|
187
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
188
|
-
vec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);
|
|
189
|
-
#else
|
|
190
|
-
mat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);
|
|
191
|
-
#endif
|
|
192
|
-
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
|
|
193
|
-
#ifdef PITCH_WITH_MAP
|
|
194
|
-
#ifdef SCALE_WITH_MAP
|
|
195
|
-
view_scale=1.0;
|
|
196
|
-
#else
|
|
197
|
-
view_scale=projected_center.w/u_camera_to_center_distance;
|
|
198
|
-
#endif
|
|
199
|
-
#else
|
|
200
|
-
#ifdef SCALE_WITH_MAP
|
|
201
|
-
view_scale=u_camera_to_center_distance;
|
|
202
|
-
#else
|
|
203
|
-
view_scale=projected_center.w;
|
|
204
|
-
#endif
|
|
205
|
-
#endif
|
|
206
|
-
#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)
|
|
207
|
-
view_scale*=a_scale;
|
|
208
|
-
#endif
|
|
209
|
-
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
|
|
210
|
-
#ifdef TERRAIN
|
|
211
|
-
float step=get_sample_step();
|
|
212
|
-
#ifdef PITCH_WITH_MAP
|
|
213
|
-
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;
|
|
214
|
-
#else
|
|
215
|
-
vec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;
|
|
216
|
-
#endif
|
|
217
|
-
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
|
|
218
|
-
#else
|
|
219
|
-
visibility=1.0;
|
|
220
|
-
#endif
|
|
221
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
222
|
-
visibility=1.0;
|
|
223
|
-
#endif
|
|
224
|
-
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
|
|
225
|
-
#ifdef FOG
|
|
226
|
-
v_fog_pos=fog_position(world_center.xyz);
|
|
227
|
-
#endif
|
|
228
|
-
}`),clippingMask:$e("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:$e(`uniform highp float u_intensity;varying vec2 v_extrude;
|
|
229
|
-
#pragma mapbox: define highp float weight
|
|
230
|
-
#define GAUSS_COEF 0.3989422804014327
|
|
231
|
-
void main() {
|
|
232
|
-
#pragma mapbox: initialize highp float weight
|
|
233
|
-
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
|
|
234
|
-
#ifdef FOG
|
|
235
|
-
gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);
|
|
236
|
-
#endif
|
|
237
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
238
|
-
gl_FragColor=vec4(1.0);
|
|
239
|
-
#endif
|
|
240
|
-
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
|
|
241
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
242
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
|
|
243
|
-
#endif
|
|
244
|
-
varying vec2 v_extrude;
|
|
245
|
-
#pragma mapbox: define highp float weight
|
|
246
|
-
#pragma mapbox: define mediump float radius
|
|
247
|
-
const highp float ZERO=1.0/255.0/16.0;
|
|
248
|
-
#define GAUSS_COEF 0.3989422804014327
|
|
249
|
-
void main(void) {
|
|
250
|
-
#pragma mapbox: initialize highp float weight
|
|
251
|
-
#pragma mapbox: initialize mediump float radius
|
|
252
|
-
vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);
|
|
253
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
254
|
-
extrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
|
255
|
-
#else
|
|
256
|
-
vec3 pos=vec3(tilePos+extrude,elevation(tilePos));
|
|
257
|
-
#endif
|
|
258
|
-
gl_Position=u_matrix*vec4(pos,1);
|
|
259
|
-
#ifdef FOG
|
|
260
|
-
v_fog_pos=fog_position(pos);
|
|
261
|
-
#endif
|
|
262
|
-
}`),heatmapTexture:$e(`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;
|
|
263
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
264
|
-
gl_FragColor=vec4(0.0);
|
|
265
|
-
#endif
|
|
266
|
-
}`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:$e("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;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_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
|
|
267
|
-
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:$e("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_2f;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_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
|
|
268
|
-
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(
|
|
269
|
-
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:$e("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;
|
|
270
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
271
|
-
attribute vec3 a_pos_3;
|
|
272
|
-
#endif
|
|
273
|
-
varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
|
|
274
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
275
|
-
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
|
|
276
|
-
#else
|
|
277
|
-
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
|
|
278
|
-
#endif
|
|
279
|
-
}`),fill:$e(`#pragma mapbox: define highp vec4 color
|
|
280
|
-
#pragma mapbox: define lowp float opacity
|
|
281
|
-
void main() {
|
|
282
|
-
#pragma mapbox: initialize highp vec4 color
|
|
283
|
-
#pragma mapbox: initialize lowp float opacity
|
|
284
|
-
vec4 out_color=color;
|
|
285
|
-
#ifdef FOG
|
|
286
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
287
|
-
#endif
|
|
288
|
-
gl_FragColor=out_color*opacity;
|
|
289
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
290
|
-
gl_FragColor=vec4(1.0);
|
|
291
|
-
#endif
|
|
292
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
|
|
293
|
-
#pragma mapbox: define highp vec4 color
|
|
294
|
-
#pragma mapbox: define lowp float opacity
|
|
295
|
-
void main() {
|
|
296
|
-
#pragma mapbox: initialize highp vec4 color
|
|
297
|
-
#pragma mapbox: initialize lowp float opacity
|
|
298
|
-
gl_Position=u_matrix*vec4(a_pos,0,1);
|
|
299
|
-
#ifdef FOG
|
|
300
|
-
v_fog_pos=fog_position(a_pos);
|
|
301
|
-
#endif
|
|
302
|
-
}`),fillOutline:$e(`varying vec2 v_pos;
|
|
303
|
-
#pragma mapbox: define highp vec4 outline_color
|
|
304
|
-
#pragma mapbox: define lowp float opacity
|
|
305
|
-
void main() {
|
|
306
|
-
#pragma mapbox: initialize highp vec4 outline_color
|
|
307
|
-
#pragma mapbox: initialize lowp float opacity
|
|
308
|
-
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
|
|
309
|
-
#ifdef FOG
|
|
310
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
311
|
-
#endif
|
|
312
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
313
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
314
|
-
gl_FragColor=vec4(1.0);
|
|
315
|
-
#endif
|
|
316
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
|
|
317
|
-
#pragma mapbox: define highp vec4 outline_color
|
|
318
|
-
#pragma mapbox: define lowp float opacity
|
|
319
|
-
void main() {
|
|
320
|
-
#pragma mapbox: initialize highp vec4 outline_color
|
|
321
|
-
#pragma mapbox: initialize lowp float opacity
|
|
322
|
-
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
323
|
-
#ifdef FOG
|
|
324
|
-
v_fog_pos=fog_position(a_pos);
|
|
325
|
-
#endif
|
|
326
|
-
}`),fillOutlinePattern:$e(`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;
|
|
327
|
-
#pragma mapbox: define lowp float opacity
|
|
328
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
329
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
330
|
-
void main() {
|
|
331
|
-
#pragma mapbox: initialize lowp float opacity
|
|
332
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
333
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
334
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);
|
|
335
|
-
#ifdef FOG
|
|
336
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
337
|
-
#endif
|
|
338
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
339
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
340
|
-
gl_FragColor=vec4(1.0);
|
|
341
|
-
#endif
|
|
342
|
-
}`,`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;
|
|
343
|
-
#pragma mapbox: define lowp float opacity
|
|
344
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
345
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
346
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
347
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
348
|
-
void main() {
|
|
349
|
-
#pragma mapbox: initialize lowp float opacity
|
|
350
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
351
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
352
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
353
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
354
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
355
|
-
#ifdef FOG
|
|
356
|
-
v_fog_pos=fog_position(a_pos);
|
|
357
|
-
#endif
|
|
358
|
-
}`),fillPattern:$e(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
|
|
359
|
-
#pragma mapbox: define lowp float opacity
|
|
360
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
361
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
362
|
-
void main() {
|
|
363
|
-
#pragma mapbox: initialize lowp float opacity
|
|
364
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
365
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
366
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);
|
|
367
|
-
#ifdef FOG
|
|
368
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
369
|
-
#endif
|
|
370
|
-
gl_FragColor=out_color*opacity;
|
|
371
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
372
|
-
gl_FragColor=vec4(1.0);
|
|
373
|
-
#endif
|
|
374
|
-
}`,`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;
|
|
375
|
-
#pragma mapbox: define lowp float opacity
|
|
376
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
377
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
378
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
379
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
380
|
-
void main() {
|
|
381
|
-
#pragma mapbox: initialize lowp float opacity
|
|
382
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
383
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
384
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
385
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
386
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);
|
|
387
|
-
#ifdef FOG
|
|
388
|
-
v_fog_pos=fog_position(a_pos);
|
|
389
|
-
#endif
|
|
390
|
-
}`),fillExtrusion:$e(`varying vec4 v_color;void main() {vec4 color=v_color;
|
|
391
|
-
#ifdef FOG
|
|
392
|
-
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
|
393
|
-
#endif
|
|
394
|
-
gl_FragColor=color;
|
|
395
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
396
|
-
gl_FragColor=vec4(1.0);
|
|
397
|
-
#endif
|
|
398
|
-
}`,`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 vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
|
399
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
400
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
|
|
401
|
-
#endif
|
|
402
|
-
varying vec4 v_color;
|
|
403
|
-
#pragma mapbox: define highp float base
|
|
404
|
-
#pragma mapbox: define highp float height
|
|
405
|
-
#pragma mapbox: define highp vec4 color
|
|
406
|
-
void main() {
|
|
407
|
-
#pragma mapbox: initialize highp float base
|
|
408
|
-
#pragma mapbox: initialize highp float height
|
|
409
|
-
#pragma mapbox: initialize highp vec4 color
|
|
410
|
-
vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
|
|
411
|
-
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
|
412
|
-
centroid_pos=a_centroid_pos;
|
|
413
|
-
#endif
|
|
414
|
-
#ifdef TERRAIN
|
|
415
|
-
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);
|
|
416
|
-
#else
|
|
417
|
-
vec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
|
|
418
|
-
#endif
|
|
419
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
420
|
-
float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
|
421
|
-
#endif
|
|
422
|
-
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);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,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*=(
|
|
423
|
-
(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.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
|
|
424
|
-
#ifdef FOG
|
|
425
|
-
v_fog_pos=fog_position(pos);
|
|
426
|
-
#endif
|
|
427
|
-
}`),fillExtrusionPattern:$e(`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;
|
|
428
|
-
#pragma mapbox: define lowp float base
|
|
429
|
-
#pragma mapbox: define lowp float height
|
|
430
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
431
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
432
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
433
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
434
|
-
void main() {
|
|
435
|
-
#pragma mapbox: initialize lowp float base
|
|
436
|
-
#pragma mapbox: initialize lowp float height
|
|
437
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
438
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
439
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
440
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
441
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;
|
|
442
|
-
#ifdef FOG
|
|
443
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
444
|
-
#endif
|
|
445
|
-
gl_FragColor=out_color;
|
|
446
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
447
|
-
gl_FragColor=vec4(1.0);
|
|
448
|
-
#endif
|
|
449
|
-
}`,`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 vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
|
450
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
451
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
|
|
452
|
-
#endif
|
|
453
|
-
varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
|
|
454
|
-
#pragma mapbox: define lowp float base
|
|
455
|
-
#pragma mapbox: define lowp float height
|
|
456
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
457
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
458
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
459
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
460
|
-
void main() {
|
|
461
|
-
#pragma mapbox: initialize lowp float base
|
|
462
|
-
#pragma mapbox: initialize lowp float height
|
|
463
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
464
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
465
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
466
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
467
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_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;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
|
|
468
|
-
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
|
469
|
-
centroid_pos=a_centroid_pos;
|
|
470
|
-
#endif
|
|
471
|
-
#ifdef TERRAIN
|
|
472
|
-
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);
|
|
473
|
-
#else
|
|
474
|
-
vec3 p=vec3(pos_nx.xy,z);
|
|
475
|
-
#endif
|
|
476
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
477
|
-
float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
|
478
|
-
#endif
|
|
479
|
-
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
|
|
480
|
-
? pos_nx.xy
|
|
481
|
-
: 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,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*=(
|
|
482
|
-
(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;
|
|
483
|
-
#ifdef FOG
|
|
484
|
-
v_fog_pos=fog_position(p);
|
|
485
|
-
#endif
|
|
486
|
-
}`),hillshadePrepare:$e(`#ifdef GL_ES
|
|
487
|
-
precision highp float;
|
|
488
|
-
#endif
|
|
489
|
-
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
|
|
490
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
491
|
-
return texture2D(u_image,coord).a/4.0;
|
|
492
|
-
#else
|
|
493
|
-
vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
|
|
494
|
-
#endif
|
|
495
|
-
}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(
|
|
496
|
-
(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)
|
|
497
|
-
)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
|
|
498
|
-
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
|
|
499
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
500
|
-
gl_FragColor=vec4(1.0);
|
|
501
|
-
#endif
|
|
502
|
-
}`,"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:$e(`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;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
|
|
503
|
-
#ifdef FOG
|
|
504
|
-
gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
|
|
505
|
-
#endif
|
|
506
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
507
|
-
gl_FragColor=vec4(1.0);
|
|
508
|
-
#endif
|
|
509
|
-
}`,`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;
|
|
510
|
-
#ifdef FOG
|
|
511
|
-
v_fog_pos=fog_position(a_pos);
|
|
512
|
-
#endif
|
|
513
|
-
}`),line:$e(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
|
|
514
|
-
#ifdef RENDER_LINE_DASH
|
|
515
|
-
uniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
|
|
516
|
-
#endif
|
|
517
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
518
|
-
uniform sampler2D u_gradient_image;varying highp vec2 v_uv;
|
|
519
|
-
#endif
|
|
520
|
-
#pragma mapbox: define highp vec4 color
|
|
521
|
-
#pragma mapbox: define lowp float floorwidth
|
|
522
|
-
#pragma mapbox: define lowp vec4 dash_from
|
|
523
|
-
#pragma mapbox: define lowp vec4 dash_to
|
|
524
|
-
#pragma mapbox: define lowp float blur
|
|
525
|
-
#pragma mapbox: define lowp float opacity
|
|
526
|
-
void main() {
|
|
527
|
-
#pragma mapbox: initialize highp vec4 color
|
|
528
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
529
|
-
#pragma mapbox: initialize lowp vec4 dash_from
|
|
530
|
-
#pragma mapbox: initialize lowp vec4 dash_to
|
|
531
|
-
#pragma mapbox: initialize lowp float blur
|
|
532
|
-
#pragma mapbox: initialize lowp float opacity
|
|
533
|
-
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);
|
|
534
|
-
#ifdef RENDER_LINE_DASH
|
|
535
|
-
float sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
|
|
536
|
-
#endif
|
|
537
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
538
|
-
vec4 out_color=texture2D(u_gradient_image,v_uv);
|
|
539
|
-
#else
|
|
540
|
-
vec4 out_color=color;
|
|
541
|
-
#endif
|
|
542
|
-
#ifdef FOG
|
|
543
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
544
|
-
#endif
|
|
545
|
-
#ifdef RENDER_LINE_ALPHA_DISCARD
|
|
546
|
-
if (alpha < u_alpha_discard_threshold) {discard;}
|
|
547
|
-
#endif
|
|
548
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
549
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
550
|
-
gl_FragColor=vec4(1.0);
|
|
551
|
-
#endif
|
|
552
|
-
}`,`
|
|
553
|
-
#define EXTRUDE_SCALE 0.015873016
|
|
554
|
-
attribute vec2 a_pos_normal;attribute vec4 a_data;
|
|
555
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
556
|
-
attribute vec3 a_packed;
|
|
557
|
-
#else
|
|
558
|
-
attribute float a_linesofar;
|
|
559
|
-
#endif
|
|
560
|
-
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;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;
|
|
561
|
-
#ifdef RENDER_LINE_DASH
|
|
562
|
-
uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
|
|
563
|
-
#endif
|
|
564
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
565
|
-
uniform float u_image_height;varying highp vec2 v_uv;
|
|
566
|
-
#endif
|
|
567
|
-
#pragma mapbox: define highp vec4 color
|
|
568
|
-
#pragma mapbox: define lowp float floorwidth
|
|
569
|
-
#pragma mapbox: define lowp vec4 dash_from
|
|
570
|
-
#pragma mapbox: define lowp vec4 dash_to
|
|
571
|
-
#pragma mapbox: define lowp float blur
|
|
572
|
-
#pragma mapbox: define lowp float opacity
|
|
573
|
-
#pragma mapbox: define mediump float gapwidth
|
|
574
|
-
#pragma mapbox: define lowp float offset
|
|
575
|
-
#pragma mapbox: define mediump float width
|
|
576
|
-
void main() {
|
|
577
|
-
#pragma mapbox: initialize highp vec4 color
|
|
578
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
579
|
-
#pragma mapbox: initialize lowp vec4 dash_from
|
|
580
|
-
#pragma mapbox: initialize lowp vec4 dash_to
|
|
581
|
-
#pragma mapbox: initialize lowp float blur
|
|
582
|
-
#pragma mapbox: initialize lowp float opacity
|
|
583
|
-
#pragma mapbox: initialize mediump float gapwidth
|
|
584
|
-
#pragma mapbox: initialize lowp float offset
|
|
585
|
-
#pragma mapbox: initialize mediump float width
|
|
586
|
-
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
|
|
587
|
-
#ifndef RENDER_TO_TEXTURE
|
|
588
|
-
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
589
|
-
#else
|
|
590
|
-
v_gamma_scale=1.0;
|
|
591
|
-
#endif
|
|
592
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
593
|
-
float a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];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);
|
|
594
|
-
#endif
|
|
595
|
-
#ifdef RENDER_LINE_DASH
|
|
596
|
-
float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);
|
|
597
|
-
#endif
|
|
598
|
-
v_width2=vec2(outset,inset);
|
|
599
|
-
#ifdef FOG
|
|
600
|
-
v_fog_pos=fog_position(pos);
|
|
601
|
-
#endif
|
|
602
|
-
}`),linePattern:$e(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
|
|
603
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
604
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
605
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
606
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
607
|
-
#pragma mapbox: define lowp float blur
|
|
608
|
-
#pragma mapbox: define lowp float opacity
|
|
609
|
-
void main() {
|
|
610
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
611
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
612
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
613
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
614
|
-
#pragma mapbox: initialize lowp float blur
|
|
615
|
-
#pragma mapbox: initialize lowp float opacity
|
|
616
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);
|
|
617
|
-
#ifdef FOG
|
|
618
|
-
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
|
619
|
-
#endif
|
|
620
|
-
gl_FragColor=color*(alpha*opacity);
|
|
621
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
622
|
-
gl_FragColor=vec4(1.0);
|
|
623
|
-
#endif
|
|
624
|
-
}`,`
|
|
625
|
-
#define scale 0.015873016
|
|
626
|
-
attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;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;
|
|
627
|
-
#pragma mapbox: define lowp float blur
|
|
628
|
-
#pragma mapbox: define lowp float opacity
|
|
629
|
-
#pragma mapbox: define lowp float offset
|
|
630
|
-
#pragma mapbox: define mediump float gapwidth
|
|
631
|
-
#pragma mapbox: define mediump float width
|
|
632
|
-
#pragma mapbox: define lowp float floorwidth
|
|
633
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
634
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
635
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
636
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
637
|
-
void main() {
|
|
638
|
-
#pragma mapbox: initialize lowp float blur
|
|
639
|
-
#pragma mapbox: initialize lowp float opacity
|
|
640
|
-
#pragma mapbox: initialize lowp float offset
|
|
641
|
-
#pragma mapbox: initialize mediump float gapwidth
|
|
642
|
-
#pragma mapbox: initialize mediump float width
|
|
643
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
644
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
645
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
646
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
647
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
648
|
-
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
|
|
649
|
-
#ifndef RENDER_TO_TEXTURE
|
|
650
|
-
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
651
|
-
#else
|
|
652
|
-
v_gamma_scale=1.0;
|
|
653
|
-
#endif
|
|
654
|
-
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
|
|
655
|
-
#ifdef FOG
|
|
656
|
-
v_fog_pos=fog_position(pos);
|
|
657
|
-
#endif
|
|
658
|
-
}`),raster:$e(`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(
|
|
659
|
-
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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
|
|
660
|
-
#ifdef FOG
|
|
661
|
-
out_color=fog_dither(fog_apply(out_color,v_fog_pos));
|
|
662
|
-
#endif
|
|
663
|
-
gl_FragColor=vec4(out_color*color.a,color.a);
|
|
664
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
665
|
-
gl_FragColor=vec4(1.0);
|
|
666
|
-
#endif
|
|
667
|
-
}`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
|
|
668
|
-
#ifdef FOG
|
|
669
|
-
v_fog_pos=fog_position(a_pos);
|
|
670
|
-
#endif
|
|
671
|
-
}`),symbolIcon:$e(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
|
|
672
|
-
#pragma mapbox: define lowp float opacity
|
|
673
|
-
void main() {
|
|
674
|
-
#pragma mapbox: initialize lowp float opacity
|
|
675
|
-
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
|
|
676
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
677
|
-
gl_FragColor=vec4(1.0);
|
|
678
|
-
#endif
|
|
679
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;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_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;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;
|
|
680
|
-
#pragma mapbox: define lowp float opacity
|
|
681
|
-
void main() {
|
|
682
|
-
#pragma mapbox: initialize lowp float opacity
|
|
683
|
-
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.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;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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
684
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
685
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
686
|
-
0.5+0.5*distance_ratio,0.0,1.5);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),anchorZ,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);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);
|
|
687
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
688
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
689
|
-
#else
|
|
690
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
691
|
-
#endif
|
|
692
|
-
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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);
|
|
693
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
694
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
695
|
-
#endif
|
|
696
|
-
float occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;
|
|
697
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
698
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
699
|
-
#endif
|
|
700
|
-
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;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:$e(`#define SDF_PX 8.0
|
|
701
|
-
uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
|
|
702
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
703
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
704
|
-
#pragma mapbox: define lowp float opacity
|
|
705
|
-
#pragma mapbox: define lowp float halo_width
|
|
706
|
-
#pragma mapbox: define lowp float halo_blur
|
|
707
|
-
void main() {
|
|
708
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
709
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
710
|
-
#pragma mapbox: initialize lowp float opacity
|
|
711
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
712
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
713
|
-
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float 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);
|
|
714
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
715
|
-
gl_FragColor=vec4(1.0);
|
|
716
|
-
#endif
|
|
717
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;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_inv_rot_matrix;uniform vec2 u_merc_center;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 vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;
|
|
718
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
719
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
720
|
-
#pragma mapbox: define lowp float opacity
|
|
721
|
-
#pragma mapbox: define lowp float halo_width
|
|
722
|
-
#pragma mapbox: define lowp float halo_blur
|
|
723
|
-
void main() {
|
|
724
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
725
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
726
|
-
#pragma mapbox: initialize lowp float opacity
|
|
727
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
728
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
729
|
-
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
730
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
731
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
732
|
-
0.5+0.5*distance_ratio,0.0,1.5);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),anchorZ,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);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);
|
|
733
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
734
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
735
|
-
#else
|
|
736
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
737
|
-
#endif
|
|
738
|
-
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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
|
|
739
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
740
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
741
|
-
#endif
|
|
742
|
-
float occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
|
|
743
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
744
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
745
|
-
#endif
|
|
746
|
-
vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:$e(`#define SDF_PX 8.0
|
|
747
|
-
#define SDF 1.0
|
|
748
|
-
#define ICON 0.0
|
|
749
|
-
uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
|
|
750
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
751
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
752
|
-
#pragma mapbox: define lowp float opacity
|
|
753
|
-
#pragma mapbox: define lowp float halo_width
|
|
754
|
-
#pragma mapbox: define lowp float halo_blur
|
|
755
|
-
void main() {
|
|
756
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
757
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
758
|
-
#pragma mapbox: initialize lowp float opacity
|
|
759
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
760
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
761
|
-
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
|
|
762
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
763
|
-
gl_FragColor=vec4(1.0);
|
|
764
|
-
#endif
|
|
765
|
-
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
|
|
766
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
767
|
-
gl_FragColor=vec4(1.0);
|
|
768
|
-
#endif
|
|
769
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;
|
|
770
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
771
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
772
|
-
#pragma mapbox: define lowp float opacity
|
|
773
|
-
#pragma mapbox: define lowp float halo_width
|
|
774
|
-
#pragma mapbox: define lowp float halo_blur
|
|
775
|
-
void main() {
|
|
776
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
777
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
778
|
-
#pragma mapbox: initialize lowp float opacity
|
|
779
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
780
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
781
|
-
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
782
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
783
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
784
|
-
0.5+0.5*distance_ratio,0.0,1.5);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),anchorZ,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);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);
|
|
785
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
786
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
787
|
-
#else
|
|
788
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
789
|
-
#endif
|
|
790
|
-
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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);
|
|
791
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
792
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
793
|
-
#endif
|
|
794
|
-
float occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
|
|
795
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
796
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
797
|
-
#endif
|
|
798
|
-
v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:$e(`uniform sampler2D u_image0;varying vec2 v_pos0;
|
|
799
|
-
#ifdef FOG
|
|
800
|
-
varying float v_fog_opacity;
|
|
801
|
-
#endif
|
|
802
|
-
void main() {vec4 color=texture2D(u_image0,v_pos0);
|
|
803
|
-
#ifdef FOG
|
|
804
|
-
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
|
|
805
|
-
#endif
|
|
806
|
-
gl_FragColor=color;
|
|
807
|
-
#ifdef TERRAIN_WIREFRAME
|
|
808
|
-
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
|
809
|
-
#endif
|
|
810
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
811
|
-
gl_FragColor=vec4(1.0);
|
|
812
|
-
#endif
|
|
813
|
-
}`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;
|
|
814
|
-
#ifdef FOG
|
|
815
|
-
varying float v_fog_opacity;
|
|
816
|
-
#endif
|
|
817
|
-
const float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;
|
|
818
|
-
#ifdef TERRAIN_WIREFRAME
|
|
819
|
-
elevation+=u_skirt_height*u_skirt_height*wireframeOffset;
|
|
820
|
-
#endif
|
|
821
|
-
vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
|
|
822
|
-
#ifdef FOG
|
|
823
|
-
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
|
|
824
|
-
#endif
|
|
825
|
-
}`),terrainDepth:$e(`#ifdef GL_ES
|
|
826
|
-
precision highp float;
|
|
827
|
-
#endif
|
|
828
|
-
varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:$e(`
|
|
829
|
-
varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
|
|
830
|
-
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
|
|
831
|
-
#ifdef FOG
|
|
832
|
-
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
|
|
833
|
-
#endif
|
|
834
|
-
sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
|
|
835
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
836
|
-
gl_FragColor=vec4(1.0);
|
|
837
|
-
#endif
|
|
838
|
-
}`,Bn),skyboxGradient:$e(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
|
|
839
|
-
#ifdef FOG
|
|
840
|
-
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
|
|
841
|
-
#endif
|
|
842
|
-
color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
|
|
843
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
844
|
-
gl_FragColor=vec4(1.0);
|
|
845
|
-
#endif
|
|
846
|
-
}`,Bn),skyboxCapture:$e(`
|
|
847
|
-
varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
|
|
848
|
-
#ifdef GL_ES
|
|
849
|
-
precision highp float;
|
|
850
|
-
#endif
|
|
851
|
-
#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
|
|
852
|
-
#define BETA_M vec3(21e-6,21e-6,21e-6)
|
|
853
|
-
#define MIE_G 0.76
|
|
854
|
-
#define DENSITY_HEIGHT_SCALE_R 8000.0
|
|
855
|
-
#define DENSITY_HEIGHT_SCALE_M 1200.0
|
|
856
|
-
#define PLANET_RADIUS 6360e3
|
|
857
|
-
#define ATMOSPHERE_RADIUS 6420e3
|
|
858
|
-
#define SAMPLE_STEPS 10
|
|
859
|
-
#define DENSITY_STEPS 4
|
|
860
|
-
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:$e(`uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);
|
|
861
|
-
#ifdef TERRAIN_WIREFRAME
|
|
862
|
-
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
|
863
|
-
#endif
|
|
864
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
865
|
-
gl_FragColor=vec4(1.0);
|
|
866
|
-
#endif
|
|
867
|
-
}`,`uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);
|
|
868
|
-
#ifdef TERRAIN_WIREFRAME
|
|
869
|
-
height+=wireframeOffset;
|
|
870
|
-
#endif
|
|
871
|
-
vec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}`),globeAtmosphere:$e(`uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)
|
|
872
|
-
discard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}`,"attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function $e(c,i,o){let h=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,f=i.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),_=c.match(d),y=i.match(d),w=ms.match(d),T=y?y.concat(_):_;o||(Rn.staticUniforms&&(T=Rn.staticUniforms.concat(T)),Fn.staticUniforms&&(T=Fn.staticUniforms.concat(T))),T&&(T=T.concat(w));let E={};return{fragmentSource:c=c.replace(h,(M,z,B,P,R)=>(E[R]=!0,z==="define"?`
|
|
873
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
874
|
-
varying ${B} ${P} ${R};
|
|
875
|
-
#else
|
|
876
|
-
uniform ${B} ${P} u_${R};
|
|
877
|
-
#endif
|
|
878
|
-
`:`
|
|
879
|
-
#ifdef HAS_UNIFORM_u_${R}
|
|
880
|
-
${B} ${P} ${R} = u_${R};
|
|
881
|
-
#endif
|
|
882
|
-
`)),vertexSource:i=i.replace(h,(M,z,B,P,R)=>{let q=P==="float"?"vec2":"vec4",L=R.match(/color/)?"color":q;return E[R]?z==="define"?`
|
|
883
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
884
|
-
uniform lowp float u_${R}_t;
|
|
885
|
-
attribute ${B} ${q} a_${R};
|
|
886
|
-
varying ${B} ${P} ${R};
|
|
887
|
-
#else
|
|
888
|
-
uniform ${B} ${P} u_${R};
|
|
889
|
-
#endif
|
|
890
|
-
`:L==="vec4"?`
|
|
891
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
892
|
-
${R} = a_${R};
|
|
893
|
-
#else
|
|
894
|
-
${B} ${P} ${R} = u_${R};
|
|
895
|
-
#endif
|
|
896
|
-
`:`
|
|
897
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
898
|
-
${R} = unpack_mix_${L}(a_${R}, u_${R}_t);
|
|
899
|
-
#else
|
|
900
|
-
${B} ${P} ${R} = u_${R};
|
|
901
|
-
#endif
|
|
902
|
-
`:z==="define"?`
|
|
903
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
904
|
-
uniform lowp float u_${R}_t;
|
|
905
|
-
attribute ${B} ${q} a_${R};
|
|
906
|
-
#else
|
|
907
|
-
uniform ${B} ${P} u_${R};
|
|
908
|
-
#endif
|
|
909
|
-
`:L==="vec4"?`
|
|
910
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
911
|
-
${B} ${P} ${R} = a_${R};
|
|
912
|
-
#else
|
|
913
|
-
${B} ${P} ${R} = u_${R};
|
|
914
|
-
#endif
|
|
915
|
-
`:`
|
|
916
|
-
#ifndef HAS_UNIFORM_u_${R}
|
|
917
|
-
${B} ${P} ${R} = unpack_mix_${L}(a_${R}, u_${R}_t);
|
|
918
|
-
#else
|
|
919
|
-
${B} ${P} ${R} = u_${R};
|
|
920
|
-
#endif
|
|
921
|
-
`}),staticAttributes:f,staticUniforms:T}}class Li{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(i,o,h,d,f,_,y,w){this.context=i;let T=this.boundPaintVertexBuffers.length!==d.length;for(let E=0;!T&&E<d.length;E++)this.boundPaintVertexBuffers[E]!==d[E]&&(T=!0);i.extVertexArrayObject&&this.vao&&this.boundProgram===o&&this.boundLayoutVertexBuffer===h&&!T&&this.boundIndexBuffer===f&&this.boundVertexOffset===_&&this.boundDynamicVertexBuffer===y&&this.boundDynamicVertexBuffer2===w?(i.bindVertexArrayOES.set(this.vao),y&&y.bind(),f&&f.dynamicDraw&&f.bind(),w&&w.bind()):this.freshBind(o,h,d,f,_,y,w)}freshBind(i,o,h,d,f,_,y){let w,T=i.numAttributes,E=this.context,M=E.gl;if(E.extVertexArrayObject)this.vao&&this.destroy(),this.vao=E.extVertexArrayObject.createVertexArrayOES(),E.bindVertexArrayOES.set(this.vao),w=0,this.boundProgram=i,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffer=_,this.boundDynamicVertexBuffer2=y;else{w=E.currentNumAttributes||0;for(let z=T;z<w;z++)M.disableVertexAttribArray(z)}o.enableAttributes(M,i);for(let z of h)z.enableAttributes(M,i);_&&_.enableAttributes(M,i),y&&y.enableAttributes(M,i),o.bind(),o.setVertexAttribPointers(M,i,f);for(let z of h)z.bind(),z.setVertexAttribPointers(M,i,f);_&&(_.bind(),_.setVertexAttribPointers(M,i,f)),d&&d.bind(),y&&(y.bind(),y.setVertexAttribPointers(M,i,f)),E.currentNumAttributes=T}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function gl(c,i){let o=Math.pow(2,i.canonical.z),h=i.canonical.y;return[new a.MercatorCoordinate(0,h/o).toLngLat().lat,new a.MercatorCoordinate(0,(h+1)/o).toLngLat().lat]}function gs(c,i,o,h,d,f,_){let y=c.context,w=y.gl,T=o.fbo;if(!T)return;c.prepareDrawTile(i);let E=c.useProgram("hillshade");y.activeTexture.set(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,T.colorAttachment.get());let M=((R,q,L,G)=>{let Z=L.paint.get("hillshade-shadow-color"),N=L.paint.get("hillshade-highlight-color"),j=L.paint.get("hillshade-accent-color"),X=L.paint.get("hillshade-illumination-direction")*(Math.PI/180);L.paint.get("hillshade-illumination-anchor")==="viewport"&&(X-=R.transform.angle);let ie=!R.options.moving;return{u_matrix:G||R.transform.calculateProjMatrix(q.tileID.toUnwrapped(),ie),u_image:0,u_latrange:gl(0,q.tileID),u_light:[L.paint.get("hillshade-exaggeration"),X],u_shadow:Z,u_highlight:N,u_accent:j}})(c,o,h,c.terrain?i.projMatrix:null);c.prepareDrawProgram(y,E,i.toUnwrapped());let{tileBoundsBuffer:z,tileBoundsIndexBuffer:B,tileBoundsSegments:P}=c.getTileBoundsBuffers(o);E.draw(y,w.TRIANGLES,d,f,_,a.CullFaceMode.disabled,M,h.id,z,B,P)}function Ut(c,i,o){if(!i.needsDEMTextureUpload)return;let h=c.context,d=h.gl;h.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||c.getTileTexture(o.stride);let f=o.getPixels();i.demTexture?i.demTexture.update(f,{premultiply:!1}):i.demTexture=new a.Texture(h,f,d.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function So(c,i,o,h,d,f){let _=c.context,y=_.gl;if(!i.dem)return;let w=i.dem;if(_.activeTexture.set(y.TEXTURE1),Ut(c,i,w),!i.demTexture)return;i.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);let T=w.dim;_.activeTexture.set(y.TEXTURE0);let E=i.fbo;if(!E){let P=new a.Texture(_,{width:T,height:T,data:null},y.RGBA);P.bind(y.LINEAR,y.CLAMP_TO_EDGE),E=i.fbo=_.createFramebuffer(T,T,!0),E.colorAttachment.set(P.texture)}_.bindFramebuffer.set(E.framebuffer),_.viewport.set([0,0,T,T]);let{tileBoundsBuffer:M,tileBoundsIndexBuffer:z,tileBoundsSegments:B}=c.getMercatorTileBoundsBuffers();c.useProgram("hillshadePrepare").draw(_,y.TRIANGLES,h,d,f,a.CullFaceMode.disabled,((P,R)=>{let q=R.stride,L=a.create();return a.ortho(L,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(L,L,[0,-a.EXTENT,0]),{u_matrix:L,u_image:1,u_dimension:[q,q],u_zoom:P.overscaledZ,u_unpack:R.unpackVector}})(i.tileID,w),o.id,M,z,B),i.needsHillshadePrepare=!1}let Or=(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_image0:new a.Uniform1i(c,i.u_image0),u_skirt_height:new a.Uniform1f(c,i.u_skirt_height)}),Wt=(c,i)=>({u_matrix:c,u_image0:0,u_skirt_height:i}),ys=(c,i,o,h,d)=>({u_proj_matrix:Float32Array.from(c),u_globe_matrix:i,u_merc_matrix:o,u_zoom_transition:h,u_merc_center:d,u_image0:0});function Bi(c,i){return c!=null&&i!=null&&!(!c.hasData()||!i.hasData())&&c.demTexture!=null&&i.demTexture!=null&&c.tileID.key!==i.tileID.key}let lr=new class{constructor(){this.operations={}}newMorphing(c,i,o,h,d){if(c in this.operations){let f=this.operations[c];f.to.tileID.key!==o.tileID.key&&(f.queued=o)}else this.operations[c]={startTime:h,phase:0,duration:d,from:i,to:o,queued:null}}getMorphValuesForProxy(c){if(!(c in this.operations))return null;let i=this.operations[c];return{from:i.from,to:i.to,phase:i.phase}}update(c){for(let i in this.operations){let o=this.operations[i];for(o.phase=(c-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,c)){delete this.operations[i];break}}}_nextOp(c,i){return!!c.queued&&(c.from=c.to,c.to=c.queued,c.queued=null,c.phase=0,c.startTime=i,!0)}_validOp(c){return c.from.hasData()&&c.to.hasData()}},on={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Uc(c,i){let o=1<<c.z;return!i&&(c.x===0||c.x===o-1)||c.y===0||c.y===o-1}let cr=c=>({u_matrix:c});function yl(c,i,o,h,d){if(d>0){let f=a.exported.now(),_=(f-c.timeAdded)/d,y=i?(f-i.timeAdded)/d:-1,w=o.getSource(),T=h.coveringZoomLevel({tileSize:w.tileSize,roundZoom:w.roundZoom}),E=!i||Math.abs(i.tileID.overscaledZ-T)>Math.abs(c.tileID.overscaledZ-T),M=E&&c.refreshedUponExpiration?1:a.clamp(E?_:1-y,0,1);return c.refreshedUponExpiration&&_>=1&&(c.refreshedUponExpiration=!1),i?{opacity:1,mix:1-M}:{opacity:M,mix:0}}return{opacity:1,mix:0}}class xl extends a.SourceCache{constructor(i){let o={type:"raster-dem",maxzoom:i.transform.maxZoom},h=new Qi(K(),null),d=vi("mock-dem",o,h,i.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(i,o){i.state="loaded",o(null)}}class bi extends a.SourceCache{constructor(i){let o=vi("proxy",{type:"geojson",maxzoom:i.transform.maxZoom},new Qi(K(),null),i.style);super("proxy",o,!1),o.setEventedParent(this),this.map=this.getSource().map=i,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(i,o,h){if(i.freezeTileCoverage)return;this.transform=i;let d=i.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((f,_)=>{if(f[_.key]="",!this._tiles[_.key]){let y=new a.Tile(_,this._source.tileSize*_.overscaleFactor(),i.tileZoom);y.state="loaded",this._tiles[_.key]=y}return f},{});for(let f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(i){let o=this.proxyCachedFBO[i];if(o!==void 0){let h=Object.values(o);this.renderCachePool.push(...h),delete this.proxyCachedFBO[i]}}deallocRenderCache(){this.renderCache.forEach(i=>i.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Io extends a.OverscaledTileID{constructor(i,o,h){super(i.overscaledZ,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y),this.proxyTileKey=o,this.projMatrix=h}}class Ur extends a.Elevation{constructor(i,o){super(),this.painter=i,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[h,d,f]=function(w){let T=new a.StructArrayLayout4i8,E=new a.StructArrayLayout3ui6,M=131;T.reserve(17161),E.reserve(33800);let z=a.EXTENT/128,B=a.EXTENT+z/2,P=B+z;for(let q=-z;q<P;q+=z)for(let L=-z;L<P;L+=z){let G=L<0||L>B||q<0||q>B?24575:0,Z=a.clamp(Math.round(L),0,a.EXTENT),N=a.clamp(Math.round(q),0,a.EXTENT);T.emplaceBack(Z+G,N,Z,N)}let R=(q,L)=>{let G=L*M+q;E.emplaceBack(G+1,G,G+M),E.emplaceBack(G+M,G+M+1,G+1)};for(let q=1;q<129;q++)for(let L=1;L<129;L++)R(L,q);return[0,129].forEach(q=>{for(let L=0;L<130;L++)R(L,q),R(q,L)}),[T,E,32768]}(),_=i.context;this.gridBuffer=_.createVertexBuffer(h,a.boundsAttributes.members),this.gridIndexBuffer=_.createIndexBuffer(d),this.gridSegments=a.SegmentVector.simpleSegment(0,0,h.length,d.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,h.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new bi(o.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);let y=_.gl;this._overlapStencilMode=new a.StencilMode({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=i.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new xl(o.map)}set style(i){i.on("data",this._onStyleDataEvent.bind(this)),i.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=i,this._checkRenderCacheEfficiency()}update(i,o,h){if(i&&i.terrain){this._style!==i&&(this.style=i),this.enabled=!0;let d=i.terrain.properties;this.sourceCache=i.terrain.drapeRenderMode===0?this._mockSourceCache:i._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");let f=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
|
|
922
|
-
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let _=this.getScaledDemTileSize();this.sourceCache.update(o,_,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,f(),this._initializing=!0),f(),o.updateElevation(!h),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(i){this._findCoveringTileCache[i]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){let i=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||i.efficiency!==100&&a.warnOnce(`Terrain render cache efficiency is not optimal (${i.efficiency}%) and performance
|
|
923
|
-
may be affected negatively, consider placing all background, fill and line layers before layer
|
|
924
|
-
with id '${i.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(i){i.coord&&i.dataType==="source"?this._clearRenderCacheForTile(i.sourceCacheId,i.coord):i.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(let i in this._style._sourceCaches)this._style._sourceCaches[i].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(i=>i.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){let i=2*this.proxySourceCache.getSource().tileSize;return[i,i]}set useVertexMorphing(i){this._useVertexMorphing=i}updateTileBinding(i){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let o=this.proxySourceCache,h=this.painter.transform;this._initializing&&(this._initializing=h._centerAltitude===0&&this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(h.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);let d=this.proxyCoords=o.getIds().map(w=>{let T=o.getTileByID(w).tileID;return T.projMatrix=h.calculateProjMatrix(T.toUnwrapped()),T});(function(w,T){let E=T.transform.pointCoordinate(T.transform.getCameraPoint()),M=new a.pointGeometry(E.x,E.y);w.sort((z,B)=>{if(B.overscaledZ-z.overscaledZ)return B.overscaledZ-z.overscaledZ;let P=new a.pointGeometry(z.canonical.x+(1<<z.canonical.z)*z.wrap,z.canonical.y),R=new a.pointGeometry(B.canonical.x+(1<<B.canonical.z)*B.wrap,B.canonical.y),q=M.mult(1<<z.canonical.z);return q.x-=.5,q.y-=.5,q.distSqr(P)-q.distSqr(R)})})(d,this.painter),this._previousZoom=h.zoom;let f=this.proxyToSource||{};this.proxyToSource={},d.forEach(w=>{this.proxyToSource[w.key]={}}),this.terrainTileForTile={};let _=this._style._sourceCaches;for(let w in _){let T=_[w];if(!T.used||(T!==this.sourceCache&&this.resetTileLookupCache(T.id),this._setupProxiedCoordsForOrtho(T,i[w],f),T.usedForTerrain))continue;let E=i[w];T.getSource().reparseOverscaled&&this._assignTerrainTiles(E)}this.proxiedCoords[o.id]=d.map(w=>new Io(w,w.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();let y={};this._visibleDemTiles=[];for(let w of this.proxyCoords){let T=this.terrainTileForTile[w.key];if(!T)continue;let E=T.tileID.key;E in y||(this._visibleDemTiles.push(T),y[E]=E)}}_assignTerrainTiles(i){this._initializing||i.forEach(o=>{if(this.terrainTileForTile[o.key])return;let h=this._findTileCoveringTileID(o,this.sourceCache);h&&(this.terrainTileForTile[o.key]=h)})}_prepareDEMTextures(){let i=this.painter.context,o=i.gl;for(let h in this.terrainTileForTile){let d=this.terrainTileForTile[h],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(i.activeTexture.set(o.TEXTURE1),Ut(this.painter,d,f))}}_prepareDemTileUniforms(i,o,h,d){if(!o||o.demTexture==null)return!1;let f=i.tileID.canonical,_=Math.pow(2,o.tileID.canonical.z-f.z),y=d||"";return h[`u_dem_tl${y}`]=[f.x*_%1,f.y*_%1],h[`u_dem_scale${y}`]=_,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){let i=this.painter.context,o=i.gl;if(!this._emptyDepthBufferTexture){let h={width:1,height:1,data:new Uint8Array([255,255,255,255])};this._emptyDepthBufferTexture=new a.Texture(i,h,o.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let i=0,o=this._visibleDemTiles.reduce((h,d)=>{if(!d.dem)return h;let f=d.dem.tree.minimums[0];return f>0&&i++,h+f},0);return i?o/i:0}_updateEmptyDEMTexture(){let i=this.painter.context,o=i.gl;i.activeTexture.set(o.TEXTURE2);let h=this._getLoadedAreaMinimum(),d={width:1,height:1,data:new Uint8Array(a.DEMData.pack(h,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let f=this._emptyDEMTexture;return f?f.update(d,{premultiply:!1}):f=this._emptyDEMTexture=new a.Texture(i,d,o.RGBA,{premultiply:!1}),f}setupElevationDraw(i,o,h){let d=this.painter.context,f=d.gl,_=(y=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(y),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var y;_.u_dem_size=this.sourceCache.getSource().tileSize,_.u_exaggeration=this.exaggeration();let w=this.painter.transform,T=w.projection.createTileTransform(w,w.worldSize),E=i.tileID.canonical;_.u_tile_tl_up=T.upVector(E,0,0),_.u_tile_tr_up=T.upVector(E,a.EXTENT,0),_.u_tile_br_up=T.upVector(E,a.EXTENT,a.EXTENT),_.u_tile_bl_up=T.upVector(E,0,a.EXTENT),_.u_tile_up_scale=T.upVectorScale(E);let M=null,z=null,B=1;if(h&&h.morphing&&this._useVertexMorphing){let P=h.morphing.srcDemTile,R=h.morphing.dstDemTile;B=h.morphing.phase,P&&R&&(this._prepareDemTileUniforms(i,P,_,"_prev")&&(z=P),this._prepareDemTileUniforms(i,R,_)&&(M=R))}if(z&&M?(d.activeTexture.set(f.TEXTURE2),M.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),d.activeTexture.set(f.TEXTURE4),z.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),_.u_dem_lerp=B):(M=this.terrainTileForTile[i.tileID.key],d.activeTexture.set(f.TEXTURE2),(this._prepareDemTileUniforms(i,M,_)?M.demTexture:this.emptyDEMTexture).bind(f.NEAREST,f.CLAMP_TO_EDGE)),d.activeTexture.set(f.TEXTURE3),h&&h.useDepthForOcclusion?(this._depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),_.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height]):(this.emptyDepthBufferTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),_.u_depth_size_inv=[1,1]),h&&h.useMeterToDem&&M){let P=(1<<M.tileID.canonical.z)*a.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;_.u_meter_to_dem=P}h&&h.labelPlaneMatrixInv&&(_.u_label_plane_matrix_inv=h.labelPlaneMatrixInv),o.setTerrainUniformValues(d,_)}renderToBackBuffer(i){let o=this.painter,h=this.painter.context;i.length!==0&&(h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),this.renderingToTexture=!1,function(d,f,_,y,w){if(d.transform.projection.name==="globe")(function(T,E,M,z,B){let P=T.context,R=P.gl,q,L,G=T.options.showTerrainWireframe?2:0,Z=(ge,ae)=>{if(L===ge)return;let ne=[];ae&&ne.push(on[G]),ne.push(on[ge]),ne.push("PROJECTION_GLOBE_VIEW"),q=T.useProgram("globeRaster",null,ne),L=ge},N=T.colorModeForRenderPass(),j=new a.DepthMode(R.LEQUAL,a.DepthMode.ReadWrite,T.depthRangeFor3D);lr.update(B);let X=T.transform,ie=a.calculateGlobeMatrix(X,X.worldSize),oe=a.calculateGlobeMercatorMatrix(X),Ee=[a.mercatorXfromLng(X.center.lng),a.mercatorYfromLat(X.center.lat)],xe=T.globeSharedBuffers;(G?[!1,!0]:[!1]).forEach(ge=>{L=-1;let ae=ge?R.LINES:R.TRIANGLES;for(let ne of z){let _e=M.getTile(ne),de=Math.pow(2,ne.canonical.z),[Be,Ve]=a.globeBuffersForTileMesh(T,_e,ne,de),Xe=a.StencilMode.disabled,Te=E.prevTerrainTileForTile[ne.key],Re=E.terrainTileForTile[ne.key];Bi(Te,Re)&&lr.newMorphing(ne.key,Te,Re,B,250),P.activeTexture.set(R.TEXTURE0),_e.texture.bind(R.LINEAR,R.CLAMP_TO_EDGE);let Ge=lr.getMorphValuesForProxy(ne.key),ft=Ge?1:0,xt={};Ge&&a.extend$1(xt,{morphing:{srcDemTile:Ge.from,dstDemTile:Ge.to,phase:a.easeCubicInOut(Ge.phase)}});let je=a.globeMatrixForTile(ne.canonical,ie),Ye=ys(X.projMatrix,je,oe,a.globeToMercatorTransition(X.zoom),Ee);if(Z(ft,ge),E.setupElevationDraw(_e,q,xt),T.prepareDrawProgram(P,q,ne.toUnwrapped()),xe){let[It,$t]=ge?xe.getWirefameBuffer(T.context):[xe.gridIndexBuffer,xe.gridSegments];q.draw(P,ae,j,Xe,N,a.CullFaceMode.backCCW,Ye,"globe_raster",Be,It,$t)}if(!ge){let It=[ne.canonical.y===0?a.globePoleMatrixForTile(ne.canonical,!1,X):null,ne.canonical.y===de-1?a.globePoleMatrixForTile(ne.canonical,!0,X):null];for(let $t of It){if(!$t)continue;let fi=ys(X.projMatrix,$t,$t,0,Ee);xe&&q.draw(P,ae,j,Xe,N,a.CullFaceMode.disabled,fi,"globe_pole_raster",Ve,xe.poleIndexBuffer,xe.poleSegments)}}}})})(d,f,_,y,w);else{let T=d.context,E=T.gl,M,z,B=d.options.showTerrainWireframe?2:0,P=(Z,N)=>{if(z===Z)return;let j=[on[Z]];N&&j.push(on[B]),M=d.useProgram("terrainRaster",null,j),z=Z},R=d.colorModeForRenderPass(),q=new a.DepthMode(E.LEQUAL,a.DepthMode.ReadWrite,d.depthRangeFor3D);lr.update(w);let L=d.transform,G=6*Math.pow(1.5,22-L.zoom)*f.exaggeration();(B?[!1,!0]:[!1]).forEach(Z=>{z=-1;let N=Z?E.LINES:E.TRIANGLES,[j,X]=Z?f.getWirefameBuffer():[f.gridIndexBuffer,f.gridSegments];for(let ie of y){let oe=_.getTile(ie),Ee=a.StencilMode.disabled,xe=f.prevTerrainTileForTile[ie.key],ge=f.terrainTileForTile[ie.key];Bi(xe,ge)&&lr.newMorphing(ie.key,xe,ge,w,250),T.activeTexture.set(E.TEXTURE0),oe.texture.bind(E.LINEAR,E.CLAMP_TO_EDGE,E.LINEAR_MIPMAP_NEAREST);let ae=lr.getMorphValuesForProxy(ie.key),ne=ae?1:0,_e;ae&&(_e={morphing:{srcDemTile:ae.from,dstDemTile:ae.to,phase:a.easeCubicInOut(ae.phase)}});let de=Wt(ie.projMatrix,Uc(ie.canonical,L.renderWorldCopies)?G/10:G);P(ne,Z),f.setupElevationDraw(oe,M,_e),d.prepareDrawProgram(T,M,ie.toUnwrapped()),M.draw(T,N,q,Ee,R,a.CullFaceMode.backCCW,de,"terrain_raster",f.gridBuffer,j,X)}})}}(o,this,this.proxySourceCache,i,this._updateTimestamp),this.renderingToTexture=!0,i.splice(0,i.length))}renderBatch(i){if(this._drapedRenderBatches.length===0)return i+1;this.renderingToTexture=!0;let o=this.painter,h=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],_=this._drapedRenderBatches.shift(),y=[],w=o.style.order,T=0;for(let E of f){let M=d.getTileByID(E.proxyTileKey),z=d.proxyCachedFBO[E.key]?d.proxyCachedFBO[E.key][i]:void 0,B=z!==void 0?d.renderCache[z]:this.pool[T++],P=z!==void 0;if(M.texture=B.tex,P&&!B.dirty){y.push(M.tileID);continue}let R;h.bindFramebuffer.set(B.fb.framebuffer),this.renderedToTile=!1,B.dirty&&(h.clear({color:a.Color.transparent,stencil:0}),B.dirty=!1);for(let q=_.start;q<=_.end;++q){let L=o.style._layers[w[q]];if(L.isHidden(o.transform.zoom))continue;let G=o.style._getLayerSourceCache(L),Z=G?this.proxyToSource[E.key][G.id]:[E];if(!Z)continue;let N=Z;h.viewport.set([0,0,B.fb.width,B.fb.height]),R!==(G?G.id:null)&&(this._setupStencil(B,Z,L,G),R=G?G.id:null),o.renderLayer(o,G,L,N)}this.renderedToTile?(B.dirty=!0,y.push(M.tileID)):P||--T,T===5&&(T=0,this.renderToBackBuffer(y))}return this.renderToBackBuffer(y),this.renderingToTexture=!1,h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),_.end+1}postRender(){}renderCacheEfficiency(i){let o=i.order.length;if(o===0)return{efficiency:100};let h,d=0,f=0,_=!1;for(let y=0;y<o;++y){let w=i._layers[i.order[y]];this._style.isLayerDraped(w)?(_&&++d,++f):_||(_=!0,h=w.id)}return f===0?{efficiency:100}:{efficiency:100*(1-d/f),firstUndrapedLayer:h}}getMinElevationBelowMSL(){let i=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{i=Math.min(i,o.dem.tree.minimums[0])}),i===0?i:(i-30)*this._exaggeration}raycast(i,o,h){if(!this._visibleDemTiles)return null;let d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{let _=f.tileID,y=Math.pow(2,_.overscaledZ),{x:w,y:T}=_.canonical,E=w/y,M=(w+1)/y,z=T/y,B=(T+1)/y;return{minx:E,miny:z,maxx:M,maxy:B,t:f.dem.tree.raycastRoot(E,z,M,B,i,o,h),tile:f}});d.sort((f,_)=>(f.t!==null?f.t:Number.MAX_VALUE)-(_.t!==null?_.t:Number.MAX_VALUE));for(let f of d){if(f.t==null)return null;let _=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,i,o,h);if(_!=null)return _}return null}_createFBO(){let i=this.painter.context,o=i.gl,h=this.drapeBufferSize;i.activeTexture.set(o.TEXTURE0);let d=new a.Texture(i,{width:h[0],height:h[1],data:null},o.RGBA);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);let f=i.createFramebuffer(h[0],h[1],!1);return f.colorAttachment.set(d.texture),f.depthAttachment=new ls(i,f.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=i.createRenderbuffer(i.gl.DEPTH_STENCIL,h[0],h[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),i.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),i.extTextureFilterAnisotropic&&!i.extTextureFilterAnisotropicForceOff&&o.texParameterf(o.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax),{fb:f,tex:d,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(let i in this._style._sourceCaches)if(this._style._sourceCaches[i].hasTransition())return!0;return this._style.order.some(i=>{let o=this._style._layers[i],h=o.isHidden(this.painter.transform.zoom),d=o.getCrossfadeParameters(),f=!!d&&d.t!==1,_=o.hasTransition();return o.type!=="custom"&&!h&&(f||_)})}_clearRasterFadeFromRenderCache(){let i=!1;for(let o in this._style._sourceCaches)if(this._style._sourceCaches[o]._source instanceof _r){i=!0;break}if(i)for(let o=0;o<this._style.order.length;++o){let h=this._style._layers[this._style.order[o]],d=h.isHidden(this.painter.transform.zoom),f=this._style._getLayerSourceCache(h);if(h.type!=="raster"||d||!f)continue;let _=h.paint.get("raster-fade-duration");for(let y of this.proxyCoords){let w=this.proxyToSource[y.key][f.id];if(w)for(let T of w){let E=yl(f.getTile(T),f.findLoadedParent(T,0),f,this.painter.transform,_);(E.opacity!==1||E.mix!==0)&&this._clearRenderCacheForTile(f.id,T)}}}}_setupDrapedRenderBatches(){let i=this._style.order,o=i.length;if(o===0)return;let h=[],d,f=0,_=this._style._layers[i[f]];for(;!this._style.isLayerDraped(_)&&_.isHidden(this.painter.transform.zoom)&&++f<o;)_=this._style._layers[i[f]];for(;f<o;++f){let y=this._style._layers[i[f]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=f):d!==void 0&&(h.push({start:d,end:f-1}),d=void 0))}d!==void 0&&h.push({start:d,end:f-1}),this._drapedRenderBatches=h}_setupRenderCache(i){let o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){let _=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<_.length;++y){let w=Object.values(_[y]);o.renderCachePool.push(...w)}}return}this._clearRasterFadeFromRenderCache();let h=this.proxyCoords,d=this._tilesDirty;for(let _=h.length-1;_>=0;_--){let y=h[_];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){let w=i[y.key],T=this.proxyToSource[y.key],E=0;for(let M in T){let z=T[M],B=w[M];if(!B||B.length!==z.length||z.some((P,R)=>P!==B[R]||d[M]&&d[M].hasOwnProperty(P.key))){E=-1;break}++E}for(let M in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][M]].dirty=E<0||E!==Object.values(w).length}}let f=[...this._drapedRenderBatches];f.sort((_,y)=>y.end-y.start-(_.end-_.start));for(let _ of f)for(let y of h){if(o.proxyCachedFBO[y.key])continue;let w=o.renderCachePool.pop();w===void 0&&o.renderCache.length<50&&(w=o.renderCache.length,o.renderCache.push(this._createFBO())),w!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][_.start]=w,o.renderCache[w].dirty=!0)}this._tilesDirty={}}_setupStencil(i,o,h,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let f=this.painter.context,_=f.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(h.isTileClipped())y=o.length,this._overlapStencilMode.test={func:_.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o[o.length-1].overscaledZ))return void(this._overlapStencilType=!1);y=1,this._overlapStencilMode.test={func:_.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+y>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=y,this._overlapStencilMode.ref=this._stencilRef,h.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(i){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[i.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(i,o){let h=this.painter,d=this.painter.context,f=d.gl;h._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);let _=h.useProgram("clippingMask");for(let y of i){let w=h._tileClippingMaskIDs[y.key]=--o;_.draw(d,f.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:f.ALWAYS,mask:0},w,255,f.KEEP,f.KEEP,f.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,cr(y.projMatrix),"$clipping",h.tileExtentBuffer,h.quadTriangleIndexBuffer,h.tileExtentSegments)}}pointCoordinate(i){let o=this.painter.transform;if(i.x<0||i.x>o.width||i.y<0||i.y>o.height)return null;let h=[i.x,i.y,1,1];a.transformMat4$1(h,h,o.pixelMatrixInverse),a.scale$1(h,h,1/h[3]),h[0]/=o.worldSize,h[1]/=o.worldSize;let d=o._camera.position,f=a.mercatorZfromAltitude(1,o.center.lat),_=[d[0],d[1],d[2]/f,0],y=a.subtract([],h.slice(0,3),_);a.normalize(y,y);let w=this.raycast(_,y,this._exaggeration);return w!==null&&w?(a.scaleAndAdd(_,_,y,w),_[3]=_[2],_[2]*=f,_):null}drawDepth(){let i=this.painter,o=i.context,h=this.proxySourceCache,d=Math.ceil(i.width),f=Math.ceil(i.height);if(!this._depthFBO||this._depthFBO.width===d&&this._depthFBO.height===f||(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){let _=o.gl,y=o.createFramebuffer(d,f,!0);o.activeTexture.set(_.TEXTURE0);let w=new a.Texture(o,{width:d,height:f,data:null},_.RGBA);w.bind(_.NEAREST,_.CLAMP_TO_EDGE),y.colorAttachment.set(w.texture);let T=o.createRenderbuffer(o.gl.DEPTH_COMPONENT16,d,f);y.depthAttachment.set(T),this._depthFBO=y,this._depthTexture=w}o.bindFramebuffer.set(this._depthFBO.framebuffer),o.viewport.set([0,0,d,f]),function(_,y,w,T){if(_.transform.projection.name==="globe")return;let E=_.context,M=E.gl;E.clear({depth:1});let z=_.useProgram("terrainDepth"),B=new a.DepthMode(M.LESS,a.DepthMode.ReadWrite,_.depthRangeFor3D);for(let P of T){let R=w.getTile(P),q=Wt(P.projMatrix,0);y.setupElevationDraw(R,z),z.draw(E,M.TRIANGLES,B,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,q,"terrain_depth",y.gridBuffer,y.gridIndexBuffer,y.gridNoSkirtSegments)}}(i,this,h,this.proxyCoords)}_setupProxiedCoordsForOrtho(i,o,h){if(i.getSource()instanceof rr)return this._setupProxiedCoordsForImageSource(i,o,h);this._findCoveringTileCache[i.id]=this._findCoveringTileCache[i.id]||{};let d=this.proxiedCoords[i.id]=[],f=this.proxyCoords;for(let y=0;y<f.length;y++){let w=f[y],T=this._findTileCoveringTileID(w,i);if(T){let E=this._createProxiedId(w,T,h[w.key]&&h[w.key][i.id]);d.push(E),this.proxyToSource[w.key][i.id]=[E]}}let _=!1;for(let y=0;y<o.length;y++){let w=i.getTile(o[y]);if(!w||!w.hasData())continue;let T=this._findTileCoveringTileID(w.tileID,this.proxySourceCache);if(T&&T.tileID.canonical.z!==w.tileID.canonical.z){let E=this.proxyToSource[T.tileID.key][i.id],M=this._createProxiedId(T.tileID,w,h[T.tileID.key]&&h[T.tileID.key][i.id]);E?E.splice(E.length-1,0,M):this.proxyToSource[T.tileID.key][i.id]=[M],d.push(M),_=!0}}this._sourceTilesOverlap[i.id]=_}_setupProxiedCoordsForImageSource(i,o,h){if(!i.getSource().loaded())return;let d=this.proxiedCoords[i.id]=[],f=this.proxyCoords,_=i.getSource(),y=new a.pointGeometry(_.tileID.x,_.tileID.y)._div(1<<_.tileID.z),w=_.coordinates.map(a.MercatorCoordinate.fromLngLat).reduce((E,M)=>(E.min.x=Math.min(E.min.x,M.x-y.x),E.min.y=Math.min(E.min.y,M.y-y.y),E.max.x=Math.max(E.max.x,M.x-y.x),E.max.y=Math.max(E.max.y,M.y-y.y),E),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),T=(E,M)=>{let z=E.wrap+E.canonical.x/(1<<E.canonical.z),B=E.canonical.y/(1<<E.canonical.z),P=a.EXTENT/(1<<E.canonical.z),R=M.wrap+M.canonical.x/(1<<M.canonical.z),q=M.canonical.y/(1<<M.canonical.z);return z+P<R+w.min.x||z>R+w.max.x||B+P<q+w.min.y||B>q+w.max.y};for(let E=0;E<f.length;E++){let M=f[E];for(let z=0;z<o.length;z++){let B=i.getTile(o[z]);if(!B||!B.hasData()||T(M,B.tileID))continue;let P=this._createProxiedId(M,B,h[M.key]&&h[M.key][i.id]),R=this.proxyToSource[M.key][i.id];R?R.push(P):this.proxyToSource[M.key][i.id]=[P],d.push(P)}}}_createProxiedId(i,o,h){let d=this.orthoMatrix;if(h){let f=h.find(_=>_.key===o.tileID.key);if(f)return f}if(o.tileID.key!==i.key){let f=i.canonical.z-o.tileID.canonical.z,_,y,w;d=a.create();let T=o.tileID.wrap-i.wrap<<i.overscaledZ;f>0?(_=a.EXTENT>>f,y=_*((o.tileID.canonical.x<<f)-i.canonical.x+T),w=_*((o.tileID.canonical.y<<f)-i.canonical.y)):(_=a.EXTENT<<-f,y=a.EXTENT*(o.tileID.canonical.x-(i.canonical.x+T<<-f)),w=a.EXTENT*(o.tileID.canonical.y-(i.canonical.y<<-f))),a.ortho(d,0,_,0,_,0,1),a.translate(d,d,[y,w,0])}return new Io(o.tileID,i.key,d)}_findTileCoveringTileID(i,o){let h=o.getTile(i);if(h&&h.hasData())return h;let d=this._findCoveringTileCache[o.id],f=d[i.key];if(h=f?o.getTileByID(f):null,h&&h.hasData()||f===null)return h;let _=h?h.tileID:i,y=_.overscaledZ,w=o.getSource().minzoom,T=[];if(!f){let M=o.getSource().maxzoom;if(i.canonical.z>=M){let z=i.canonical.z-M;o.getSource().reparseOverscaled?(y=Math.max(i.canonical.z+2,o.transform.tileZoom),_=new a.OverscaledTileID(y,i.wrap,M,i.canonical.x>>z,i.canonical.y>>z)):z!==0&&(y=M,_=new a.OverscaledTileID(y,i.wrap,M,i.canonical.x>>z,i.canonical.y>>z))}_.key!==i.key&&(T.push(_.key),h=o.getTile(_))}let E=M=>{T.forEach(z=>{d[z]=M}),T.length=0};for(y-=1;y>=w&&(!h||!h.hasData());y--){h&&E(h.tileID.key);let M=_.calculateScaledKey(y);if(h=o.getTileByID(M),h&&h.hasData())break;let z=d[M];if(z===null)break;z===void 0?T.push(M):h=o.getTileByID(z)}return E(h?h.tileID.key:null),h&&h.hasData()?h:null}findDEMTileFor(i){return this.enabled?this._findTileCoveringTileID(i,this.sourceCache):null}prepareDrawTile(i){this.renderedToTile=!0}_clearRenderCacheForTile(i,o){let h=this._tilesDirty[i];h||(h=this._tilesDirty[i]={}),h[o.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){let i=function(o){let h,d,f,_=new a.StructArrayLayout2ui4,y=131;for(d=1;d<129;d++){for(h=1;h<129;h++)f=d*y+h,_.emplaceBack(f,f+1),_.emplaceBack(f,f+y),_.emplaceBack(f+1,f+y),d===128&&_.emplaceBack(f+y,f+y+1);_.emplaceBack(f+1,f+1+y)}return _}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(i),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,i.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function xs(c){let i=[];for(let o=0;o<c.length;o++){if(c[o]===null)continue;let h=c[o].split(" ");i.push(h.pop())}return i}class Mo{static cacheKey(i,o,h){let d=`${i}${h?h.cacheKey:""}`;for(let f of o)d+=`/${f}`;return d}constructor(i,o,h,d,f,_){let y=i.gl;this.program=y.createProgram();let w=xs(h.staticAttributes),T=d?d.getBinderAttributes():[],E=w.concat(T),M=h.staticUniforms?xs(h.staticUniforms):[],z=d?d.getBinderUniforms():[],B=M.concat(z),P=[];for(let j of B)P.indexOf(j)<0&&P.push(j);let R=d?d.defines():[];R=R.concat(_.map(j=>`#define ${j}`));let q=R.concat(`
|
|
925
|
-
#ifdef GL_ES
|
|
926
|
-
precision mediump float;
|
|
927
|
-
#else
|
|
928
|
-
|
|
929
|
-
#if !defined(lowp)
|
|
930
|
-
#define lowp
|
|
931
|
-
#endif
|
|
932
|
-
|
|
933
|
-
#if !defined(mediump)
|
|
934
|
-
#define mediump
|
|
935
|
-
#endif
|
|
936
|
-
|
|
937
|
-
#if !defined(highp)
|
|
938
|
-
#define highp
|
|
939
|
-
#endif
|
|
940
|
-
|
|
941
|
-
#endif`,_s,lt.fragmentSource,Fn.fragmentSource,h.fragmentSource).join(`
|
|
942
|
-
`),L=R.concat(`
|
|
943
|
-
#ifdef GL_ES
|
|
944
|
-
precision highp float;
|
|
945
|
-
#else
|
|
946
|
-
|
|
947
|
-
#if !defined(lowp)
|
|
948
|
-
#define lowp
|
|
949
|
-
#endif
|
|
950
|
-
|
|
951
|
-
#if !defined(mediump)
|
|
952
|
-
#define mediump
|
|
953
|
-
#endif
|
|
954
|
-
|
|
955
|
-
#if !defined(highp)
|
|
956
|
-
#define highp
|
|
957
|
-
#endif
|
|
958
|
-
|
|
959
|
-
#endif`,_s,lt.vertexSource,Fn.vertexSource,Rn.vertexSource,h.vertexSource).join(`
|
|
960
|
-
`),G=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(G,q),y.compileShader(G),y.attachShader(this.program,G);let Z=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(Z,L),y.compileShader(Z),y.attachShader(this.program,Z),this.attributes={};let N={};this.numAttributes=E.length;for(let j=0;j<this.numAttributes;j++)E[j]&&(y.bindAttribLocation(this.program,j,E[j]),this.attributes[E[j]]=j);y.linkProgram(this.program),y.deleteShader(Z),y.deleteShader(G);for(let j=0;j<P.length;j++){let X=P[j];if(X&&!N[X]){let ie=y.getUniformLocation(this.program,X);ie&&(N[X]=ie)}}this.fixedUniforms=f(i,N),this.binderUniforms=d?d.getUniforms(i,N):[],_.indexOf("TERRAIN")!==-1&&(this.terrainUniforms=((j,X)=>({u_dem:new a.Uniform1i(j,X.u_dem),u_dem_prev:new a.Uniform1i(j,X.u_dem_prev),u_dem_unpack:new a.Uniform4f(j,X.u_dem_unpack),u_dem_tl:new a.Uniform2f(j,X.u_dem_tl),u_dem_scale:new a.Uniform1f(j,X.u_dem_scale),u_dem_tl_prev:new a.Uniform2f(j,X.u_dem_tl_prev),u_dem_scale_prev:new a.Uniform1f(j,X.u_dem_scale_prev),u_dem_size:new a.Uniform1f(j,X.u_dem_size),u_dem_lerp:new a.Uniform1f(j,X.u_dem_lerp),u_exaggeration:new a.Uniform1f(j,X.u_exaggeration),u_depth:new a.Uniform1i(j,X.u_depth),u_depth_size_inv:new a.Uniform2f(j,X.u_depth_size_inv),u_meter_to_dem:new a.Uniform1f(j,X.u_meter_to_dem),u_label_plane_matrix_inv:new a.UniformMatrix4f(j,X.u_label_plane_matrix_inv),u_tile_tl_up:new a.Uniform3f(j,X.u_tile_tl_up),u_tile_tr_up:new a.Uniform3f(j,X.u_tile_tr_up),u_tile_br_up:new a.Uniform3f(j,X.u_tile_br_up),u_tile_bl_up:new a.Uniform3f(j,X.u_tile_bl_up),u_tile_up_scale:new a.Uniform1f(j,X.u_tile_up_scale)}))(i,N)),_.indexOf("FOG")!==-1&&(this.fogUniforms=((j,X)=>({u_fog_matrix:new a.UniformMatrix4f(j,X.u_fog_matrix),u_fog_range:new a.Uniform2f(j,X.u_fog_range),u_fog_color:new a.Uniform4f(j,X.u_fog_color),u_fog_horizon_blend:new a.Uniform1f(j,X.u_fog_horizon_blend),u_fog_temporal_offset:new a.Uniform1f(j,X.u_fog_temporal_offset)}))(i,N))}setTerrainUniformValues(i,o){if(!this.terrainUniforms)return;let h=this.terrainUniforms;if(!this.failedToCreate){i.program.set(this.program);for(let d in o)h[d].set(o[d])}}setFogUniformValues(i,o){if(!this.fogUniforms)return;let h=this.fogUniforms;if(!this.failedToCreate){i.program.set(this.program);for(let d in o)h[d].location&&h[d].set(o[d])}}draw(i,o,h,d,f,_,y,w,T,E,M,z,B,P,R,q){let L=i.gl;if(this.failedToCreate)return;i.program.set(this.program),i.setDepthMode(h),i.setStencilMode(d),i.setColorMode(f),i.setCullFace(_);for(let Z of Object.keys(this.fixedUniforms))this.fixedUniforms[Z].set(y[Z]);P&&P.setUniforms(i,this.binderUniforms,z,{zoom:B});let G={[L.LINES]:2,[L.TRIANGLES]:3,[L.LINE_STRIP]:1}[o];for(let Z of M.get()){let N=Z.vaos||(Z.vaos={});(N[w]||(N[w]=new Li)).bind(i,this,T,P?P.getPaintVertexBuffers():[],E,Z.vertexOffset,R,q),L.drawElements(o,Z.primitiveLength*G,L.UNSIGNED_SHORT,Z.primitiveOffset*G*2)}}}function vl(c,i,o){let h=1/Ci(o,1,i.transform.tileZoom),d=Math.pow(2,o.tileID.overscaledZ),f=o.tileSize*Math.pow(2,i.transform.tileZoom)/d,_=f*(o.tileID.canonical.x+o.tileID.wrap*d),y=f*o.tileID.canonical.y;return{u_image:0,u_texsize:o.imageAtlasTexture.size,u_scale:[h,c.fromScale,c.toScale],u_fade:c.t,u_pixel_coord_upper:[_>>16,y>>16],u_pixel_coord_lower:[65535&_,65535&y]}}let bl=(c,i,o,h)=>{let d=i.style.light,f=d.properties.get("position"),_=[f.x,f.y,f.z],y=a.create$1();d.properties.get("anchor")==="viewport"&&(a.fromRotation(y,-i.transform.angle),a.transformMat3(_,_,y));let w=d.properties.get("color");return{u_matrix:c,u_lightpos:_,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+o,u_opacity:h}},ga=(c,i,o,h,d,f,_)=>a.extend(bl(c,i,o,h),vl(f,i,_),{u_height_factor:-Math.pow(2,d.overscaledZ)/_.tileSize/8}),wl=c=>({u_matrix:c}),ya=(c,i,o,h)=>a.extend(wl(c),vl(o,i,h)),Vc=(c,i)=>({u_matrix:c,u_world:i}),Tl=(c,i,o,h,d)=>a.extend(ya(c,i,o,h),{u_world:d}),Nc=(c,i,o,h)=>{let d=c.transform,f;return f=h.paint.get("circle-pitch-alignment")==="map"?d.calculatePixelsToTileUnitsMatrix(o):new Float32Array([d.pixelsToGLUnits[0],0,0,d.pixelsToGLUnits[1]]),{u_camera_to_center_distance:d.cameraToCenterDistance,u_matrix:c.translatePosMatrix(i.projMatrix,o,h.paint.get("circle-translate"),h.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:f}},xa=c=>{let i=[];return c.paint.get("circle-pitch-alignment")==="map"&&i.push("PITCH_WITH_MAP"),c.paint.get("circle-pitch-scale")==="map"&&i.push("SCALE_WITH_MAP"),i},El=(c,i,o)=>{let h=a.EXTENT/o.tileSize;return{u_matrix:c,u_camera_to_center_distance:i.cameraToCenterDistance,u_extrude_scale:[i.pixelsToGLUnits[0]/h,i.pixelsToGLUnits[1]/h]}},va=(c,i,o=1)=>({u_matrix:c,u_color:i,u_overlay:0,u_overlay_scale:o}),Sl=(c,i,o,h)=>({u_matrix:c,u_extrude_scale:Ci(i,1,o),u_intensity:h}),Il=(c,i,o,h,d,f)=>{let _=c.transform,y=_.calculatePixelsToTileUnitsMatrix(i),w={u_matrix:Ao(c,i,o,d),u_pixels_to_tile_units:y,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:f,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Co(o)){let T=On(i,c.transform);w.u_texsize=i.lineAtlasTexture.size,w.u_scale=[T,h.fromScale,h.toScale],w.u_mix=h.t}return w},sn=(c,i,o,h,d)=>{let f=c.transform,_=On(i,f);return{u_matrix:Ao(c,i,o,d),u_texsize:i.imageAtlasTexture.size,u_pixels_to_tile_units:f.calculatePixelsToTileUnitsMatrix(i),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[_,h.fromScale,h.toScale],u_fade:h.t,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function On(c,i){return 1/Ci(c,1,i.tileZoom)}function Ao(c,i,o,h){return c.translatePosMatrix(h||i.tileID.projMatrix,i,o.paint.get("line-translate"),o.paint.get("line-translate-anchor"))}function Co(c){let i=c.paint.get("line-dasharray").value;return i.value||i.kind!=="constant"}let vs=(c,i,o,h,d,f)=>{return{u_matrix:c,u_tl_parent:i,u_scale_parent:o,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(y=d.paint.get("raster-saturation"),y>0?1-1/(1.001-y):-y),u_contrast_factor:(_=d.paint.get("raster-contrast"),_>0?1/(1-_):1+_),u_spin_weights:bs(d.paint.get("raster-hue-rotate")),u_perspective_transform:f};var _,y};function bs(c){c*=Math.PI/180;let i=Math.sin(c),o=Math.cos(c);return[(2*o+1)/3,(-Math.sqrt(3)*i-o+1)/3,(Math.sqrt(3)*i-o+1)/3]}let ws=(c,i,o,h,d,f,_,y,w,T,E,M,z,B)=>{let P=d.transform;return{u_is_size_zoom_constant:+(c==="constant"||c==="source"),u_is_size_feature_constant:+(c==="constant"||c==="camera"),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:P.cameraToCenterDistance,u_pitch:P.pitch/360*2*Math.PI,u_rotate_symbol:+o,u_aspect_ratio:P.width/P.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+w,u_pitch_with_map:+h,u_texsize:T,u_tile_id:E,u_zoom_transition:M,u_inv_rot_matrix:z,u_merc_center:B,u_texture:0}},zo=(c,i,o,h,d,f,_,y,w,T,E,M,z,B,P)=>{let{cameraToCenterDistance:R,_pitch:q}=d.transform;return a.extend(ws(c,i,o,h,d,f,_,y,w,T,M,z,B,P),{u_gamma_scale:h?R*Math.cos(d.terrain?0:q):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+E})},ko=(c,i,o,h,d,f,_,y,w,T,E,M,z,B)=>a.extend(zo(c,i,o,h,d,f,_,y,!0,w,!0,E,M,z,B),{u_texsize_icon:T,u_texture_icon:1}),pt=(c,i,o)=>({u_matrix:c,u_opacity:i,u_color:o}),Ts=(c,i,o,h,d,f)=>a.extend(function(_,y,w,T){let E=w.imageManager.getPattern(_.from.toString()),M=w.imageManager.getPattern(_.to.toString()),{width:z,height:B}=w.imageManager.getPixelSize(),P=Math.pow(2,T.tileID.overscaledZ),R=T.tileSize*Math.pow(2,w.transform.tileZoom)/P,q=R*(T.tileID.canonical.x+T.tileID.wrap*P),L=R*T.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:E.tl,u_pattern_br_a:E.br,u_pattern_tl_b:M.tl,u_pattern_br_b:M.br,u_texsize:[z,B],u_mix:y.t,u_pattern_size_a:E.displaySize,u_pattern_size_b:M.displaySize,u_scale_a:y.fromScale,u_scale_b:y.toScale,u_tile_units_to_pixels:1/Ci(T,1,w.transform.tileZoom),u_pixel_coord_upper:[q>>16,L>>16],u_pixel_coord_lower:[65535&q,65535&L]}}(h,f,o,d),{u_matrix:c,u_opacity:i}),Ml={fillExtrusion:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_lightpos:new a.Uniform3f(c,i.u_lightpos),u_lightintensity:new a.Uniform1f(c,i.u_lightintensity),u_lightcolor:new a.Uniform3f(c,i.u_lightcolor),u_vertical_gradient:new a.Uniform1f(c,i.u_vertical_gradient),u_opacity:new a.Uniform1f(c,i.u_opacity)}),fillExtrusionPattern:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_lightpos:new a.Uniform3f(c,i.u_lightpos),u_lightintensity:new a.Uniform1f(c,i.u_lightintensity),u_lightcolor:new a.Uniform3f(c,i.u_lightcolor),u_vertical_gradient:new a.Uniform1f(c,i.u_vertical_gradient),u_height_factor:new a.Uniform1f(c,i.u_height_factor),u_image:new a.Uniform1i(c,i.u_image),u_texsize:new a.Uniform2f(c,i.u_texsize),u_pixel_coord_upper:new a.Uniform2f(c,i.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(c,i.u_pixel_coord_lower),u_scale:new a.Uniform3f(c,i.u_scale),u_fade:new a.Uniform1f(c,i.u_fade),u_opacity:new a.Uniform1f(c,i.u_opacity)}),fill:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix)}),fillPattern:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_image:new a.Uniform1i(c,i.u_image),u_texsize:new a.Uniform2f(c,i.u_texsize),u_pixel_coord_upper:new a.Uniform2f(c,i.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(c,i.u_pixel_coord_lower),u_scale:new a.Uniform3f(c,i.u_scale),u_fade:new a.Uniform1f(c,i.u_fade)}),fillOutline:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_world:new a.Uniform2f(c,i.u_world)}),fillOutlinePattern:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_world:new a.Uniform2f(c,i.u_world),u_image:new a.Uniform1i(c,i.u_image),u_texsize:new a.Uniform2f(c,i.u_texsize),u_pixel_coord_upper:new a.Uniform2f(c,i.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(c,i.u_pixel_coord_lower),u_scale:new a.Uniform3f(c,i.u_scale),u_fade:new a.Uniform1f(c,i.u_fade)}),circle:(c,i)=>({u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(c,i.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(c,i.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(c,i.u_matrix)}),collisionBox:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(c,i.u_extrude_scale)}),collisionCircle:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_inv_matrix:new a.UniformMatrix4f(c,i.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(c,i.u_viewport_size)}),debug:(c,i)=>({u_color:new a.UniformColor(c,i.u_color),u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_overlay:new a.Uniform1i(c,i.u_overlay),u_overlay_scale:new a.Uniform1f(c,i.u_overlay_scale)}),clippingMask:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix)}),heatmap:(c,i)=>({u_extrude_scale:new a.Uniform1f(c,i.u_extrude_scale),u_intensity:new a.Uniform1f(c,i.u_intensity),u_matrix:new a.UniformMatrix4f(c,i.u_matrix)}),heatmapTexture:(c,i)=>({u_image:new a.Uniform1i(c,i.u_image),u_color_ramp:new a.Uniform1i(c,i.u_color_ramp),u_opacity:new a.Uniform1f(c,i.u_opacity)}),hillshade:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_image:new a.Uniform1i(c,i.u_image),u_latrange:new a.Uniform2f(c,i.u_latrange),u_light:new a.Uniform2f(c,i.u_light),u_shadow:new a.UniformColor(c,i.u_shadow),u_highlight:new a.UniformColor(c,i.u_highlight),u_accent:new a.UniformColor(c,i.u_accent)}),hillshadePrepare:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_image:new a.Uniform1i(c,i.u_image),u_dimension:new a.Uniform2f(c,i.u_dimension),u_zoom:new a.Uniform1f(c,i.u_zoom),u_unpack:new a.Uniform4f(c,i.u_unpack)}),line:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(c,i.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(c,i.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(c,i.u_units_to_pixels),u_dash_image:new a.Uniform1i(c,i.u_dash_image),u_gradient_image:new a.Uniform1i(c,i.u_gradient_image),u_image_height:new a.Uniform1f(c,i.u_image_height),u_texsize:new a.Uniform2f(c,i.u_texsize),u_scale:new a.Uniform3f(c,i.u_scale),u_mix:new a.Uniform1f(c,i.u_mix),u_alpha_discard_threshold:new a.Uniform1f(c,i.u_alpha_discard_threshold)}),linePattern:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_texsize:new a.Uniform2f(c,i.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(c,i.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(c,i.u_device_pixel_ratio),u_image:new a.Uniform1i(c,i.u_image),u_units_to_pixels:new a.Uniform2f(c,i.u_units_to_pixels),u_scale:new a.Uniform3f(c,i.u_scale),u_fade:new a.Uniform1f(c,i.u_fade),u_alpha_discard_threshold:new a.Uniform1f(c,i.u_alpha_discard_threshold)}),raster:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_tl_parent:new a.Uniform2f(c,i.u_tl_parent),u_scale_parent:new a.Uniform1f(c,i.u_scale_parent),u_fade_t:new a.Uniform1f(c,i.u_fade_t),u_opacity:new a.Uniform1f(c,i.u_opacity),u_image0:new a.Uniform1i(c,i.u_image0),u_image1:new a.Uniform1i(c,i.u_image1),u_brightness_low:new a.Uniform1f(c,i.u_brightness_low),u_brightness_high:new a.Uniform1f(c,i.u_brightness_high),u_saturation_factor:new a.Uniform1f(c,i.u_saturation_factor),u_contrast_factor:new a.Uniform1f(c,i.u_contrast_factor),u_spin_weights:new a.Uniform3f(c,i.u_spin_weights),u_perspective_transform:new a.Uniform2f(c,i.u_perspective_transform)}),symbolIcon:(c,i)=>({u_is_size_zoom_constant:new a.Uniform1i(c,i.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(c,i.u_is_size_feature_constant),u_size_t:new a.Uniform1f(c,i.u_size_t),u_size:new a.Uniform1f(c,i.u_size),u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_pitch:new a.Uniform1f(c,i.u_pitch),u_rotate_symbol:new a.Uniform1i(c,i.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(c,i.u_aspect_ratio),u_fade_change:new a.Uniform1f(c,i.u_fade_change),u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(c,i.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(c,i.u_coord_matrix),u_is_text:new a.Uniform1i(c,i.u_is_text),u_pitch_with_map:new a.Uniform1i(c,i.u_pitch_with_map),u_texsize:new a.Uniform2f(c,i.u_texsize),u_tile_id:new a.Uniform3f(c,i.u_tile_id),u_zoom_transition:new a.Uniform1f(c,i.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(c,i.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(c,i.u_merc_center),u_texture:new a.Uniform1i(c,i.u_texture)}),symbolSDF:(c,i)=>({u_is_size_zoom_constant:new a.Uniform1i(c,i.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(c,i.u_is_size_feature_constant),u_size_t:new a.Uniform1f(c,i.u_size_t),u_size:new a.Uniform1f(c,i.u_size),u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_pitch:new a.Uniform1f(c,i.u_pitch),u_rotate_symbol:new a.Uniform1i(c,i.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(c,i.u_aspect_ratio),u_fade_change:new a.Uniform1f(c,i.u_fade_change),u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(c,i.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(c,i.u_coord_matrix),u_is_text:new a.Uniform1i(c,i.u_is_text),u_pitch_with_map:new a.Uniform1i(c,i.u_pitch_with_map),u_texsize:new a.Uniform2f(c,i.u_texsize),u_texture:new a.Uniform1i(c,i.u_texture),u_gamma_scale:new a.Uniform1f(c,i.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(c,i.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(c,i.u_tile_id),u_zoom_transition:new a.Uniform1f(c,i.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(c,i.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(c,i.u_merc_center),u_is_halo:new a.Uniform1i(c,i.u_is_halo)}),symbolTextAndIcon:(c,i)=>({u_is_size_zoom_constant:new a.Uniform1i(c,i.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(c,i.u_is_size_feature_constant),u_size_t:new a.Uniform1f(c,i.u_size_t),u_size:new a.Uniform1f(c,i.u_size),u_camera_to_center_distance:new a.Uniform1f(c,i.u_camera_to_center_distance),u_pitch:new a.Uniform1f(c,i.u_pitch),u_rotate_symbol:new a.Uniform1i(c,i.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(c,i.u_aspect_ratio),u_fade_change:new a.Uniform1f(c,i.u_fade_change),u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(c,i.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(c,i.u_coord_matrix),u_is_text:new a.Uniform1i(c,i.u_is_text),u_pitch_with_map:new a.Uniform1i(c,i.u_pitch_with_map),u_texsize:new a.Uniform2f(c,i.u_texsize),u_texsize_icon:new a.Uniform2f(c,i.u_texsize_icon),u_texture:new a.Uniform1i(c,i.u_texture),u_texture_icon:new a.Uniform1i(c,i.u_texture_icon),u_gamma_scale:new a.Uniform1f(c,i.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(c,i.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(c,i.u_is_halo)}),background:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_opacity:new a.Uniform1f(c,i.u_opacity),u_color:new a.UniformColor(c,i.u_color)}),backgroundPattern:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_opacity:new a.Uniform1f(c,i.u_opacity),u_image:new a.Uniform1i(c,i.u_image),u_pattern_tl_a:new a.Uniform2f(c,i.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(c,i.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(c,i.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(c,i.u_pattern_br_b),u_texsize:new a.Uniform2f(c,i.u_texsize),u_mix:new a.Uniform1f(c,i.u_mix),u_pattern_size_a:new a.Uniform2f(c,i.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(c,i.u_pattern_size_b),u_scale_a:new a.Uniform1f(c,i.u_scale_a),u_scale_b:new a.Uniform1f(c,i.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(c,i.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(c,i.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(c,i.u_tile_units_to_pixels)}),terrainRaster:Or,terrainDepth:Or,skybox:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_sun_direction:new a.Uniform3f(c,i.u_sun_direction),u_cubemap:new a.Uniform1i(c,i.u_cubemap),u_opacity:new a.Uniform1f(c,i.u_opacity),u_temporal_offset:new a.Uniform1f(c,i.u_temporal_offset)}),skyboxGradient:(c,i)=>({u_matrix:new a.UniformMatrix4f(c,i.u_matrix),u_color_ramp:new a.Uniform1i(c,i.u_color_ramp),u_center_direction:new a.Uniform3f(c,i.u_center_direction),u_radius:new a.Uniform1f(c,i.u_radius),u_opacity:new a.Uniform1f(c,i.u_opacity),u_temporal_offset:new a.Uniform1f(c,i.u_temporal_offset)}),skyboxCapture:(c,i)=>({u_matrix_3f:new a.UniformMatrix3f(c,i.u_matrix_3f),u_sun_direction:new a.Uniform3f(c,i.u_sun_direction),u_sun_intensity:new a.Uniform1f(c,i.u_sun_intensity),u_color_tint_r:new a.Uniform4f(c,i.u_color_tint_r),u_color_tint_m:new a.Uniform4f(c,i.u_color_tint_m),u_luminance:new a.Uniform1f(c,i.u_luminance)}),globeRaster:(c,i)=>({u_proj_matrix:new a.UniformMatrix4f(c,i.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(c,i.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(c,i.u_merc_matrix),u_zoom_transition:new a.Uniform1f(c,i.u_zoom_transition),u_merc_center:new a.Uniform2f(c,i.u_merc_center),u_image0:new a.Uniform1i(c,i.u_image0)}),globeAtmosphere:(c,i)=>({u_center:new a.Uniform2f(c,i.u_center),u_radius:new a.Uniform1f(c,i.u_radius),u_screen_size:new a.Uniform2f(c,i.u_screen_size),u_pixel_ratio:new a.Uniform1f(c,i.u_pixel_ratio),u_opacity:new a.Uniform1f(c,i.u_opacity),u_fadeout_range:new a.Uniform1f(c,i.u_fadeout_range),u_start_color:new a.Uniform3f(c,i.u_start_color),u_end_color:new a.Uniform3f(c,i.u_end_color)})},Po;function ba(c,i,o,h,d,f,_){let y=c.context,w=y.gl,T=c.useProgram("collisionBox"),E=[],M=0,z=0;for(let Z=0;Z<h.length;Z++){let N=h[Z],j=i.getTile(N),X=j.getBucket(o);if(!X)continue;let ie=N.projMatrix;d[0]===0&&d[1]===0||(ie=c.translatePosMatrix(N.projMatrix,j,d,f));let oe=_?X.textCollisionBox:X.iconCollisionBox,Ee=X.collisionCircleArray;if(Ee.length>0){let xe=a.create(),ge=ie;a.mul(xe,X.placementInvProjMatrix,c.transform.glCoordMatrix),a.mul(xe,xe,X.placementViewportMatrix),E.push({circleArray:Ee,circleOffset:z,transform:ge,invTransform:xe}),M+=Ee.length/4,z=M}oe&&(c.terrain&&c.terrain.setupElevationDraw(j,T),T.draw(y,w.LINES,a.DepthMode.disabled,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.disabled,El(ie,c.transform,j),o.id,oe.layoutVertexBuffer,oe.indexBuffer,oe.segments,null,c.transform.zoom,null,oe.collisionVertexBuffer,oe.collisionVertexBufferExt))}if(!_||!E.length)return;let B=c.useProgram("collisionCircle"),P=new a.StructArrayLayout2f1f2i16;P.resize(4*M),P._trim();let R=0;for(let Z of E)for(let N=0;N<Z.circleArray.length/4;N++){let j=4*N,X=Z.circleArray[j+0],ie=Z.circleArray[j+1],oe=Z.circleArray[j+2],Ee=Z.circleArray[j+3];P.emplace(R++,X,ie,oe,Ee,0),P.emplace(R++,X,ie,oe,Ee,1),P.emplace(R++,X,ie,oe,Ee,2),P.emplace(R++,X,ie,oe,Ee,3)}(!Po||Po.length<2*M)&&(Po=function(Z){let N=2*Z,j=new a.StructArrayLayout3ui6;j.resize(N),j._trim();for(let X=0;X<N;X++){let ie=6*X;j.uint16[ie+0]=4*X+0,j.uint16[ie+1]=4*X+1,j.uint16[ie+2]=4*X+2,j.uint16[ie+3]=4*X+2,j.uint16[ie+4]=4*X+3,j.uint16[ie+5]=4*X+0}return j}(M));let q=y.createIndexBuffer(Po,!0),L=y.createVertexBuffer(P,a.collisionCircleLayout.members,!0);for(let Z of E){let N={u_matrix:Z.transform,u_inv_matrix:Z.invTransform,u_camera_to_center_distance:(G=c.transform).cameraToCenterDistance,u_viewport_size:[G.width,G.height]};B.draw(y,w.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.disabled,N,o.id,L,q,a.SegmentVector.simpleSegment(0,2*Z.circleOffset,Z.circleArray.length,Z.circleArray.length/2),null,c.transform.zoom,null,null,null)}var G;L.destroy(),q.destroy()}let Es=a.identity(new Float32Array(16));function Al(c,i,o,h,d,f){let{horizontalAlign:_,verticalAlign:y}=a.getAnchorAlignment(c),w=-(_-.5)*i,T=-(y-.5)*o,E=a.evaluateVariableOffset(c,h);return new a.pointGeometry((w/d+E[0])*f,(T/d+E[1])*f)}function jc(c,i,o,h,d,f,_,y,w,T,E,M){let z=c.text.placedSymbolArray,B=c.text.dynamicLayoutVertexArray,P=c.icon.dynamicLayoutVertexArray,R={},q=y.projMatrix,L=f.elevation,G=L?L.getAtTileOffsetFunc(y,M):Z=>[0,0,0];B.clear();for(let Z=0;Z<z.length;Z++){let N=z.get(Z),j=c.allowVerticalPlacement&&!N.placedOrientation,X=N.hidden||!N.crossTileID||j?null:h[N.crossTileID];if(X){let ie=new a.pointGeometry(N.tileAnchorX,N.tileAnchorY),oe=G(ie),Ee=ti(ie,o?q:_,oe[2]),xe=nr(f.cameraToCenterDistance,Ee.signedDistanceFromCamera),ge=d.evaluateSizeForFeature(c.textSizeData,T,N)*xe/a.ONE_EM;o&&(ge*=c.tilePixelRatio/w);let{width:ae,height:ne,anchor:_e,textOffset:de,textScale:Be}=X,Ve=Al(_e,ae,ne,de,Be,ge),Xe=o?ti(ie.add(Ve),_,oe[2]).point:Ee.point.add(i?Ve.rotate(-f.angle):Ve),Te=c.allowVerticalPlacement&&N.placedOrientation===a.WritingMode.vertical?Math.PI/2:0;for(let Re=0;Re<N.numGlyphs;Re++)a.addDynamicAttributes(B,Xe,Te);E&&N.associatedIconIndex>=0&&(R[N.associatedIconIndex]={shiftedAnchor:Xe,angle:Te})}else Zi(N.numGlyphs,B)}if(E){P.clear();let Z=c.icon.placedSymbolArray;for(let N=0;N<Z.length;N++){let j=Z.get(N);if(j.hidden)Zi(j.numGlyphs,P);else{let X=R[N];if(X)for(let ie=0;ie<j.numGlyphs;ie++)a.addDynamicAttributes(P,X.shiftedAnchor,X.angle);else Zi(j.numGlyphs,P)}}c.icon.dynamicLayoutVertexBuffer.updateData(P)}c.text.dynamicLayoutVertexBuffer.updateData(B)}function Gc(c,i,o){return o.iconsInText&&i?"symbolTextAndIcon":c?"symbolSDF":"symbolIcon"}function Ss(c,i,o,h,d,f,_,y,w,T,E,M){let z=c.context,B=z.gl,P=c.transform,R=P.projection.createTileTransform(P,P.worldSize),q=y==="map",L=w==="map",G=q&&o.layout.get("symbol-placement")!=="point",Z=q&&!L&&!G,N=o.layout.get("symbol-sort-key").constantOr(1)!==void 0,j=!1,X=c.depthModeForSublayer(0,a.DepthMode.ReadOnly),ie=[a.mercatorXfromLng(P.center.lng),a.mercatorYfromLat(P.center.lat)],oe=o.layout.get("text-variable-anchor"),Ee=P.projection.name==="globe",xe=Ee?a.globeToMercatorTransition(P.zoom):0,ge=[],ae=[];c.terrain&&L&&ae.push("PITCH_WITH_MAP_TERRAIN"),Ee&&ae.push("PROJECTION_GLOBE_VIEW"),G&&ae.push("PROJECTED_POS_ON_VIEWPORT");for(let ne of h){let _e=i.getTile(ne),de=_e.getBucket(o);if(!de||de.projection!==P.projection.name)continue;let Be=d?de.text:de.icon;if(!Be||de.fullyClipped||!Be.segments.get().length)continue;let Ve=Be.programConfigurations.get(o.id),Xe=d||de.sdfIcons,Te=d?de.textSizeData:de.iconSizeData,Re=L||P.pitch!==0,Ge=c.useProgram(Gc(Xe,d,de),Ve,ae),ft=a.evaluateSizeForZoom(Te,P.zoom),xt=[ne.canonical.x,ne.canonical.y,1<<ne.canonical.z],je,Ye,It,$t,fi=[0,0],Fi=null;if(d){if(Ye=_e.glyphAtlasTexture,It=B.LINEAR,je=_e.glyphAtlasTexture.size,de.iconsInText){fi=_e.imageAtlasTexture.size,Fi=_e.imageAtlasTexture;let Kt=Te.kind==="composite"||Te.kind==="camera";$t=Re||c.options.rotating||c.options.zooming||Kt?B.LINEAR:B.NEAREST}}else{let Kt=o.layout.get("icon-size").constantOr(0)!==1||de.iconsNeedLinear;Ye=_e.imageAtlasTexture,It=Xe||c.options.rotating||c.options.zooming||Kt||Re?B.LINEAR:B.NEAREST,je=_e.imageAtlasTexture.size}let Wi=c.transform.calculatePixelsToTileUnitsMatrix(_e),ot=Pr(ne.projMatrix,_e.tileID.canonical,L,q,c.transform,Wi),Ze=c.terrain&&L&&G?a.invert(new Float32Array(16),ot):Es,tt=gr(ne.projMatrix,_e.tileID.canonical,L,q,c.transform,Wi),Bt=oe&&de.hasTextData(),wi=o.layout.get("icon-text-fit")!=="none"&&Bt&&de.hasIconData();if(G){let Kt=P.elevation,cn=Kt?Kt.getAtTileOffsetFunc(ne,R):Zr=>[0,0,0];dl(de,ne.projMatrix,c,d,ot,tt,L,T,cn,ne)}let Tt=c.translatePosMatrix(ne.projMatrix,_e,f,_),Ti=G||d&&oe||wi?Es:ot,Xo=c.translatePosMatrix(tt,_e,f,_,!0),mi=Xe&&o.paint.get(d?"text-halo-width":"icon-halo-width").constantOr(1)!==0,ln,Pe=R.createInversionMatrix(ne.toUnwrapped());ln=Xe?de.iconsInText?ko(Te.kind,ft,Z,L,c,Tt,Ti,Xo,je,fi,xt,xe,Pe,ie):zo(Te.kind,ft,Z,L,c,Tt,Ti,Xo,d,je,!0,xt,xe,Pe,ie):ws(Te.kind,ft,Z,L,c,Tt,Ti,Xo,d,je,xt,xe,Pe,ie);let Fe={program:Ge,buffers:Be,uniformValues:ln,atlasTexture:Ye,atlasTextureIcon:Fi,atlasInterpolation:It,atlasInterpolationIcon:$t,isSDF:Xe,hasHalo:mi,tile:_e,labelPlaneMatrixInv:Ze};if(N&&de.canOverlap){j=!0;let Kt=Be.segments.get();for(let cn of Kt)ge.push({segments:new a.SegmentVector([cn]),sortKey:cn.sortKey,state:Fe})}else ge.push({segments:Be.segments,sortKey:0,state:Fe})}j&&ge.sort((ne,_e)=>ne.sortKey-_e.sortKey);for(let ne of ge){let _e=ne.state;if(c.terrain&&c.terrain.setupElevationDraw(_e.tile,_e.program,{useDepthForOcclusion:!Ee,labelPlaneMatrixInv:_e.labelPlaneMatrixInv}),z.activeTexture.set(B.TEXTURE0),_e.atlasTexture.bind(_e.atlasInterpolation,B.CLAMP_TO_EDGE),_e.atlasTextureIcon&&(z.activeTexture.set(B.TEXTURE1),_e.atlasTextureIcon&&_e.atlasTextureIcon.bind(_e.atlasInterpolationIcon,B.CLAMP_TO_EDGE)),_e.isSDF){let de=_e.uniformValues;_e.hasHalo&&(de.u_is_halo=1,Is(_e.buffers,ne.segments,o,c,_e.program,X,E,M,de)),de.u_is_halo=0}Is(_e.buffers,ne.segments,o,c,_e.program,X,E,M,_e.uniformValues)}}function Is(c,i,o,h,d,f,_,y,w){let T=h.context;d.draw(T,T.gl.TRIANGLES,f,_,y,a.CullFaceMode.disabled,w,o.id,c.layoutVertexBuffer,c.indexBuffer,i,o.paint,h.transform.zoom,c.programConfigurations.get(o.id),c.dynamicLayoutVertexBuffer,c.opacityVertexBuffer)}function Ms(c,i,o,h,d,f,_){let y=c.context.gl,w=o.paint.get("fill-pattern"),T=w&&w.constantOr(1),E=o.getCrossfadeParameters(),M,z,B,P,R;_?(z=T&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=y.LINES):(z=T?"fillPattern":"fill",M=y.TRIANGLES);for(let q of h){let L=i.getTile(q);if(T&&!L.patternsLoaded())continue;let G=L.getBucket(o);if(!G)continue;c.prepareDrawTile(q);let Z=G.programConfigurations.get(o.id),N=c.useProgram(z,Z);T&&(c.context.activeTexture.set(y.TEXTURE0),L.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),Z.updatePaintBuffers(E));let j=w.constantOr(null);if(j&&L.imageAtlas){let ie=L.imageAtlas,oe=ie.patternPositions[j.to.toString()],Ee=ie.patternPositions[j.from.toString()];oe&&Ee&&Z.setConstantPatternPositions(oe,Ee)}let X=c.translatePosMatrix(q.projMatrix,L,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(_){P=G.indexBuffer2,R=G.segments2;let ie=c.terrain&&c.terrain.renderingToTexture?c.terrain.drapeBufferSize:[y.drawingBufferWidth,y.drawingBufferHeight];B=z==="fillOutlinePattern"&&T?Tl(X,c,E,L,ie):Vc(X,ie)}else P=G.indexBuffer,R=G.segments,B=T?ya(X,c,E,L):wl(X);c.prepareDrawProgram(c.context,N,q.toUnwrapped()),N.draw(c.context,M,d,c.stencilModeForClipping(q),f,a.CullFaceMode.disabled,B,o.id,G.layoutVertexBuffer,P,R,o.paint,c.transform.zoom,Z)}}function Do(c,i,o,h,d,f,_){let y=c.context,w=y.gl,T=o.paint.get("fill-extrusion-pattern"),E=T.constantOr(1),M=o.getCrossfadeParameters(),z=o.paint.get("fill-extrusion-opacity");for(let B of h){let P=i.getTile(B),R=P.getBucket(o);if(!R)continue;let q=R.programConfigurations.get(o.id),L=c.useProgram(E?"fillExtrusionPattern":"fillExtrusion",q);if(c.terrain){let X=c.terrain;if(!R.enableTerrain)continue;if(X.setupElevationDraw(P,L,{useMeterToDem:!0}),Cl(y,i,B,R,o,X),!R.centroidVertexBuffer){let ie=L.attributes.a_centroid_pos;ie!==void 0&&w.vertexAttrib2f(ie,0,0)}}E&&(c.context.activeTexture.set(w.TEXTURE0),P.imageAtlasTexture.bind(w.LINEAR,w.CLAMP_TO_EDGE),q.updatePaintBuffers(M));let G=T.constantOr(null);if(G&&P.imageAtlas){let X=P.imageAtlas,ie=X.patternPositions[G.to.toString()],oe=X.patternPositions[G.from.toString()];ie&&oe&&q.setConstantPatternPositions(ie,oe)}let Z=c.translatePosMatrix(B.projMatrix,P,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),N=o.paint.get("fill-extrusion-vertical-gradient"),j=E?ga(Z,c,N,z,B,M,P):bl(Z,c,N,z);c.prepareDrawProgram(y,L,B.toUnwrapped()),L.draw(y,y.gl.TRIANGLES,d,f,_,a.CullFaceMode.backCCW,j,o.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,o.paint,c.transform.zoom,q,c.terrain?R.centroidVertexBuffer:null)}}function Cl(c,i,o,h,d,f){let _=[L=>{let G=L.canonical.x-1,Z=L.wrap;return G<0&&(G=(1<<L.canonical.z)-1,Z--),new a.OverscaledTileID(L.overscaledZ,Z,L.canonical.z,G,L.canonical.y)},L=>{let G=L.canonical.x+1,Z=L.wrap;return G===1<<L.canonical.z&&(G=0,Z++),new a.OverscaledTileID(L.overscaledZ,Z,L.canonical.z,G,L.canonical.y)},L=>new a.OverscaledTileID(L.overscaledZ,L.wrap,L.canonical.z,L.canonical.x,(L.canonical.y===0?1<<L.canonical.z:L.canonical.y)-1),L=>new a.OverscaledTileID(L.overscaledZ,L.wrap,L.canonical.z,L.canonical.x,L.canonical.y===(1<<L.canonical.z)-1?0:L.canonical.y+1)],y=L=>{let G=i.getSource().maxzoom,Z=ie=>{let oe=i.getTileByID(ie);if(oe&&oe.hasData())return oe.getBucket(d)},N,j,X;return(L.overscaledZ===L.canonical.z||L.overscaledZ>=G)&&(N=Z(L.key)),L.overscaledZ>=G&&(j=Z(L.calculateScaledKey(L.overscaledZ+1))),L.overscaledZ>G&&(X=Z(L.calculateScaledKey(L.overscaledZ-1))),N||j||X},w=[0,0,0],T=(L,G)=>(w[0]=Math.min(L.min.y,G.min.y),w[1]=Math.max(L.max.y,G.max.y),w[2]=a.EXTENT-G.min.x>L.max.x?G.min.x-a.EXTENT:L.max.x,w),E=(L,G)=>(w[0]=Math.min(L.min.x,G.min.x),w[1]=Math.max(L.max.x,G.max.x),w[2]=a.EXTENT-G.min.y>L.max.y?G.min.y-a.EXTENT:L.max.y,w),M=[(L,G)=>T(L,G),(L,G)=>T(G,L),(L,G)=>E(L,G),(L,G)=>E(G,L)],z=new a.pointGeometry(0,0),B,P,R,q=(L,G,Z,N,j)=>{let X=[[N?Z:L,N?L:Z,0],[N?Z:G,N?G:Z,0]],ie=j<0?a.EXTENT+j:j,oe=[N?ie:(L+G)/2,N?(L+G)/2:ie,0];return Z===0&&j<0||Z!==0&&j>0?f.getForTilePoints(R,[oe],!0,P):X.push(oe),f.getForTilePoints(o,X,!0,B),Math.max(X[0][2],X[1][2],oe[2])/f.exaggeration()};for(let L=0;L<4;L++){let G=h.borders[L];if(G.length===0&&(h.borderDone[L]=!0),h.borderDone[L])continue;let Z=R=_[L](o),N=y(Z);if(!N||!N.enableTerrain||(P=f.findDEMTileFor(Z),!P||!P.dem))continue;if(!B){let oe=f.findDEMTileFor(o);if(!oe||!oe.dem)return;B=oe}let j=(L<2?1:5)-L,X=N.borders[j],ie=0;for(let oe=0;oe<G.length;oe++){let Ee=h.featuresOnBorder[G[oe]],xe=Ee.borders[L],ge;for(;ie<X.length&&(ge=N.featuresOnBorder[X[ie]],!(ge.borders[j][1]>xe[0]+3));)N.borderDone[j]||N.encodeCentroid(void 0,ge,!1),ie++;if(ge&&ie<X.length){let ae=ie,ne=0;for(;!(ge.borders[j][0]>xe[1]-3)&&(ne++,++ie!==X.length);)ge=N.featuresOnBorder[X[ie]];if(ge=N.featuresOnBorder[X[ae]],Ee.intersectsCount()>1||ge.intersectsCount()>1||ne!==1){ne!==1&&(ie=ae),h.encodeCentroid(void 0,Ee,!1),N.borderDone[j]||N.encodeCentroid(void 0,ge,!1);continue}let _e=M[L](Ee,ge),de=L%2?a.EXTENT-1:0;z.x=q(_e[0],Math.min(a.EXTENT-1,_e[1]),de,L<2,_e[2]),z.y=0,h.encodeCentroid(z,Ee,!1),N.borderDone[j]||N.encodeCentroid(z,ge,!1)}else h.encodeCentroid(void 0,Ee,!1)}h.borderDone[L]=h.needsCentroidUpdate=!0,N.borderDone[j]||(N.borderDone[j]=N.needsCentroidUpdate=!0)}(h.needsCentroidUpdate||!h.centroidVertexBuffer&&h.centroidVertexArray.length!==0)&&h.uploadCentroid(c)}let zl=new a.Color(1,0,0,1),Zc=new a.Color(0,1,0,1),Lo=new a.Color(0,0,1,1),Bo=new a.Color(1,0,1,1),kl=new a.Color(0,1,1,1);function pi(c,i,o,h){an(c,0,i+o/2,c.transform.width,o,h)}function As(c,i,o,h){an(c,i-o/2,0,o,c.transform.height,h)}function an(c,i,o,h,d,f){let _=c.context,y=_.gl;y.enable(y.SCISSOR_TEST),y.scissor(i*a.exported.devicePixelRatio,o*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio,d*a.exported.devicePixelRatio),_.clear({color:f}),y.disable(y.SCISSOR_TEST)}function Cs(c,i,o){let h=c.context,d=h.gl,f=o.projMatrix,_=c.useProgram("debug"),y=i.getTileByID(o.key);c.terrain&&c.terrain.setupElevationDraw(y,_);let w=a.DepthMode.disabled,T=a.StencilMode.disabled,E=c.colorModeForRenderPass(),M="$debug";h.activeTexture.set(d.TEXTURE0),c.emptyTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),y._makeDebugTileBoundsBuffers(c.context,c.transform.projection);let z=y._tileDebugBuffer||c.debugBuffer,B=y._tileDebugIndexBuffer||c.debugIndexBuffer,P=y._tileDebugSegments||c.debugSegments;_.draw(h,d.LINE_STRIP,w,T,E,a.CullFaceMode.disabled,va(f,a.Color.red),M,z,B,P);let R=y.latestRawTileData,q=Math.floor((R&&R.byteLength||0)/1024),L=i.getTile(o).tileSize,G=512/Math.min(L,512)*(o.overscaledZ/c.transform.zoom)*.5,Z=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(Z+=` => ${o.overscaledZ}`),function(N,j){N.initDebugOverlayCanvas();let X=N.debugOverlayCanvas,ie=N.context.gl,oe=N.debugOverlayCanvas.getContext("2d");oe.clearRect(0,0,X.width,X.height),oe.shadowColor="white",oe.shadowBlur=2,oe.lineWidth=1.5,oe.strokeStyle="white",oe.textBaseline="top",oe.font="bold 36px Open Sans, sans-serif",oe.fillText(j,5,5),oe.strokeText(j,5,5),N.debugOverlayTexture.update(X),N.debugOverlayTexture.bind(ie.LINEAR,ie.CLAMP_TO_EDGE)}(c,`${Z} ${q}kb`),_.draw(h,d.TRIANGLES,w,T,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,va(f,a.Color.transparent,G),M,c.debugBuffer,c.quadTriangleIndexBuffer,c.debugSegments)}let wa=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ta}=wa;function $i(c,i,o,h){c.emplaceBack(i,o,h)}class zs{constructor(i){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,$i(this.vertexArray,-1,-1,1),$i(this.vertexArray,1,-1,1),$i(this.vertexArray,-1,1,1),$i(this.vertexArray,1,1,1),$i(this.vertexArray,-1,-1,-1),$i(this.vertexArray,1,-1,-1),$i(this.vertexArray,-1,1,-1),$i(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=i.createVertexBuffer(this.vertexArray,Ta),this.indexBuffer=i.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function Vr(c,i,o,h,d,f){let _=c.gl,y=i.paint.get("sky-atmosphere-color"),w=i.paint.get("sky-atmosphere-halo-color"),T=i.paint.get("sky-atmosphere-sun-intensity"),E=((M,z,B,P,R)=>({u_matrix_3f:M,u_sun_direction:z,u_sun_intensity:B,u_color_tint_r:[P.r,P.g,P.b,P.a],u_color_tint_m:[R.r,R.g,R.b,R.a],u_luminance:5e-5}))(a.fromMat4([],h),d,T,y,w);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+f,i.skyboxTexture,0),o.draw(c,_.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,E,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}let Ro={symbol:function(c,i,o,h,d){if(c.renderPass!=="translucent")return;let f=a.StencilMode.disabled,_=c.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(y,w,T,E,M,z,B){let P=w.transform,R=M==="map",q=z==="map",L=P.projection.createTileTransform(P,P.worldSize);for(let G of y){let Z=E.getTile(G),N=Z.getBucket(T);if(!N||N.projection!==P.projection.name||!N.text||!N.text.segments.get().length)continue;let j=a.evaluateSizeForZoom(N.textSizeData,P.zoom),X=w.transform.calculatePixelsToTileUnitsMatrix(Z),ie=Pr(G.projMatrix,Z.tileID.canonical,q,R,w.transform,X),oe=T.layout.get("icon-text-fit")!=="none"&&N.hasIconData();if(j){let Ee=Math.pow(2,P.zoom-Z.tileID.overscaledZ);jc(N,R,q,B,a.symbolSize,P,ie,G,Ee,j,oe,L)}}}(h,c,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d),o.paint.get("icon-opacity").constantOr(1)!==0&&Ss(c,i,o,h,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),f,_),o.paint.get("text-opacity").constantOr(1)!==0&&Ss(c,i,o,h,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),f,_),i.map.showCollisionBoxes&&(ba(c,i,o,h,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),ba(c,i,o,h,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(c,i,o,h){if(c.renderPass!=="translucent")return;let d=o.paint.get("circle-opacity"),f=o.paint.get("circle-stroke-width"),_=o.paint.get("circle-stroke-opacity"),y=o.layout.get("circle-sort-key").constantOr(1)!==void 0;if(d.constantOr(1)===0&&(f.constantOr(1)===0||_.constantOr(1)===0))return;let w=c.context,T=w.gl,E=c.depthModeForSublayer(0,a.DepthMode.ReadOnly),M=a.StencilMode.disabled,z=c.colorModeForRenderPass(),B=[];for(let R=0;R<h.length;R++){let q=h[R],L=i.getTile(q),G=L.getBucket(o);if(!G)continue;let Z=G.programConfigurations.get(o.id),N=xa(o),j={programConfiguration:Z,program:c.useProgram("circle",Z,N),layoutVertexBuffer:G.layoutVertexBuffer,indexBuffer:G.indexBuffer,uniformValues:Nc(c,q,L,o),tile:L};if(y){let X=G.segments.get();for(let ie of X)B.push({segments:new a.SegmentVector([ie]),sortKey:ie.sortKey,state:j})}else B.push({segments:G.segments,sortKey:0,state:j})}y&&B.sort((R,q)=>R.sortKey-q.sortKey);let P={useDepthForOcclusion:c.transform.projection.name!=="globe"};for(let R of B){let{programConfiguration:q,program:L,layoutVertexBuffer:G,indexBuffer:Z,uniformValues:N,tile:j}=R.state,X=R.segments;c.terrain&&c.terrain.setupElevationDraw(j,L,P),c.prepareDrawProgram(w,L,j.tileID.toUnwrapped()),L.draw(w,T.TRIANGLES,E,M,z,a.CullFaceMode.disabled,N,o.id,G,Z,X,o.paint,c.transform.zoom,q)}},heatmap:function(c,i,o,h){if(o.paint.get("heatmap-opacity")!==0)if(c.renderPass==="offscreen"){let d=c.context,f=d.gl,_=a.StencilMode.disabled,y=new a.ColorMode([f.ONE,f.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(w,T,E){let M=w.gl;w.activeTexture.set(M.TEXTURE1),w.viewport.set([0,0,T.width/4,T.height/4]);let z=E.heatmapFbo;if(z)M.bindTexture(M.TEXTURE_2D,z.colorAttachment.get()),w.bindFramebuffer.set(z.framebuffer);else{let B=M.createTexture();M.bindTexture(M.TEXTURE_2D,B),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_S,M.CLAMP_TO_EDGE),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_T,M.CLAMP_TO_EDGE),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MIN_FILTER,M.LINEAR),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MAG_FILTER,M.LINEAR),z=E.heatmapFbo=w.createFramebuffer(T.width/4,T.height/4,!1),function(P,R,q,L){let G=P.gl;G.texImage2D(G.TEXTURE_2D,0,G.RGBA,R.width/4,R.height/4,0,G.RGBA,P.extRenderToTextureHalfFloat?P.extTextureHalfFloat.HALF_FLOAT_OES:G.UNSIGNED_BYTE,null),L.colorAttachment.set(q)}(w,T,B,z)}})(d,c,o),d.clear({color:a.Color.transparent});for(let w=0;w<h.length;w++){let T=h[w];if(i.hasRenderableParent(T))continue;let E=i.getTile(T),M=E.getBucket(o);if(!M)continue;let z=M.programConfigurations.get(o.id),B=c.useProgram("heatmap",z),{zoom:P}=c.transform;c.terrain&&c.terrain.setupElevationDraw(E,B),c.prepareDrawProgram(d,B,T.toUnwrapped()),B.draw(d,f.TRIANGLES,a.DepthMode.disabled,_,y,a.CullFaceMode.disabled,Sl(T.projMatrix,E,P,o.paint.get("heatmap-intensity")),o.id,M.layoutVertexBuffer,M.indexBuffer,M.segments,o.paint,c.transform.zoom,z)}d.viewport.set([0,0,c.width,c.height])}else c.renderPass==="translucent"&&(c.context.setColorMode(c.colorModeForRenderPass()),function(d,f){let _=d.context,y=_.gl,w=f.heatmapFbo;if(!w)return;_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,w.colorAttachment.get()),_.activeTexture.set(y.TEXTURE1);let T=f.colorRampTexture;T||(T=f.colorRampTexture=new a.Texture(_,f.colorRamp,y.RGBA)),T.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.useProgram("heatmapTexture").draw(_,y.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,d.colorModeForRenderPass(),a.CullFaceMode.disabled,((E,M,z,B)=>({u_image:0,u_color_ramp:1,u_opacity:M.paint.get("heatmap-opacity")}))(0,f),f.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,f.paint,d.transform.zoom)}(c,o))},line:function(c,i,o,h){if(c.renderPass!=="translucent")return;let d=o.paint.get("line-opacity"),f=o.paint.get("line-width");if(d.constantOr(1)===0||f.constantOr(1)===0)return;let _=c.depthModeForSublayer(0,a.DepthMode.ReadOnly),y=c.colorModeForRenderPass(),w=o.paint.get("line-dasharray"),T=w.constantOr(1),E=o.layout.get("line-cap"),M=o.paint.get("line-pattern"),z=M.constantOr(1),B=o.paint.get("line-gradient"),P=o.getCrossfadeParameters(),R=z?"linePattern":"line",q=c.context,L=q.gl,G=(N=>{let j=[];Co(N)&&j.push("RENDER_LINE_DASH"),N.paint.get("line-gradient")&&j.push("RENDER_LINE_GRADIENT");let X=N.paint.get("line-pattern").constantOr(1),ie=N.paint.get("line-opacity").constantOr(1)!==1;return!X&&ie&&j.push("RENDER_LINE_ALPHA_DISCARD"),j})(o),Z=G.includes("RENDER_LINE_ALPHA_DISCARD");c.terrain&&c.terrain.clipOrMaskOverlapStencilType()&&(Z=!1);for(let N of h){let j=i.getTile(N);if(z&&!j.patternsLoaded())continue;let X=j.getBucket(o);if(!X)continue;c.prepareDrawTile(N);let ie=X.programConfigurations.get(o.id),oe=c.useProgram(R,ie,G),Ee=M.constantOr(null);if(Ee&&j.imageAtlas){let de=j.imageAtlas,Be=de.patternPositions[Ee.to.toString()],Ve=de.patternPositions[Ee.from.toString()];Be&&Ve&&ie.setConstantPatternPositions(Be,Ve)}let xe=w.constantOr(null),ge=E.constantOr(null);if(!z&&xe&&ge&&j.lineAtlas){let de=j.lineAtlas,Be=de.getDash(xe.to,ge),Ve=de.getDash(xe.from,ge);Be&&Ve&&ie.setConstantPatternPositions(Be,Ve)}let ae=c.terrain?N.projMatrix:null,ne=z?sn(c,j,o,P,ae):Il(c,j,o,P,ae,X.lineClipsArray.length);if(B){let de=X.gradients[o.id],Be=de.texture;if(o.gradientVersion!==de.version){let Ve=256;if(o.stepInterpolant){let Xe=i.getSource().maxzoom,Te=N.canonical.z===Xe?Math.ceil(1<<c.transform.maxZoom-N.canonical.z):1;Ve=a.clamp(a.nextPowerOfTwo(X.maxLineLength/a.EXTENT*1024*Te),256,q.maxTextureSize)}de.gradient=a.renderColorRamp({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Ve,image:de.gradient||void 0,clips:X.lineClipsArray}),de.texture?de.texture.update(de.gradient):de.texture=new a.Texture(q,de.gradient,L.RGBA),de.version=o.gradientVersion,Be=de.texture}q.activeTexture.set(L.TEXTURE1),Be.bind(o.stepInterpolant?L.NEAREST:L.LINEAR,L.CLAMP_TO_EDGE)}T&&(q.activeTexture.set(L.TEXTURE0),j.lineAtlasTexture.bind(L.LINEAR,L.REPEAT),ie.updatePaintBuffers(P)),z&&(q.activeTexture.set(L.TEXTURE0),j.imageAtlasTexture.bind(L.LINEAR,L.CLAMP_TO_EDGE),ie.updatePaintBuffers(P)),c.prepareDrawProgram(q,oe,N.toUnwrapped());let _e=de=>{oe.draw(q,L.TRIANGLES,_,de,y,a.CullFaceMode.disabled,ne,o.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,o.paint,c.transform.zoom,ie,X.layoutVertexBuffer2)};if(Z){let de=c.stencilModeForClipping(N).ref;de===0&&c.terrain&&q.clear({stencil:0});let Be={func:L.EQUAL,mask:255};ne.u_alpha_discard_threshold=.8,_e(new a.StencilMode(Be,de,255,L.KEEP,L.KEEP,L.INVERT)),ne.u_alpha_discard_threshold=0,_e(new a.StencilMode(Be,de,255,L.KEEP,L.KEEP,L.KEEP))}else _e(c.stencilModeForClipping(N))}Z&&(c.resetStencilClippingMasks(),c.terrain&&q.clear({stencil:0}))},fill:function(c,i,o,h){let d=o.paint.get("fill-color"),f=o.paint.get("fill-opacity");if(f.constantOr(1)===0)return;let _=c.colorModeForRenderPass(),y=o.paint.get("fill-pattern"),w=c.opaquePassEnabledForLayer()&&!y.constantOr(1)&&d.constantOr(a.Color.transparent).a===1&&f.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===w){let T=c.depthModeForSublayer(1,c.renderPass==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);Ms(c,i,o,h,T,_,!1)}if(c.renderPass==="translucent"&&o.paint.get("fill-antialias")){let T=c.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);Ms(c,i,o,h,T,_,!0)}},"fill-extrusion":function(c,i,o,h){let d=o.paint.get("fill-extrusion-opacity");if(d!==0&&c.renderPass==="translucent"){let f=new a.DepthMode(c.context.gl.LEQUAL,a.DepthMode.ReadWrite,c.depthRangeFor3D);if(d!==1||o.paint.get("fill-extrusion-pattern").constantOr(1))Do(c,i,o,h,f,a.StencilMode.disabled,a.ColorMode.disabled),Do(c,i,o,h,f,c.stencilModeFor3D(),c.colorModeForRenderPass()),c.resetStencilClippingMasks();else{let _=c.colorModeForRenderPass();Do(c,i,o,h,f,a.StencilMode.disabled,_)}}},hillshade:function(c,i,o,h){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;let d=c.context,f=c.depthModeForSublayer(0,a.DepthMode.ReadOnly),_=c.colorModeForRenderPass(),y=c.terrain&&c.terrain.renderingToTexture,[w,T]=c.renderPass!=="translucent"||y?[{},h]:c.stencilConfigForOverlap(h);for(let E of T){let M=i.getTile(E);if(M.needsHillshadePrepare&&c.renderPass==="offscreen")So(c,M,o,f,a.StencilMode.disabled,_);else if(c.renderPass==="translucent"){let z=y&&c.terrain?c.terrain.stencilModeForRTTOverlap(E):w[E.overscaledZ];gs(c,E,M,o,f,z,_)}}d.viewport.set([0,0,c.width,c.height]),c.resetStencilClippingMasks()},raster:function(c,i,o,h,d,f){if(c.renderPass!=="translucent"||o.paint.get("raster-opacity")===0||!h.length)return;let _=c.context,y=_.gl,w=i.getSource(),T=c.useProgram("raster"),E=c.colorModeForRenderPass(),M=c.terrain&&c.terrain.renderingToTexture,[z,B]=w instanceof rr||M?[{},h]:c.stencilConfigForOverlap(h),P=B[B.length-1].overscaledZ,R=!c.options.moving;for(let q of B){let L=M?a.DepthMode.disabled:c.depthModeForSublayer(q.overscaledZ-P,o.paint.get("raster-opacity")===1?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,y.LESS),G=q.toUnwrapped(),Z=i.getTile(q);if(M&&(!Z||!Z.hasData()))continue;let N=M?q.projMatrix:c.transform.calculateProjMatrix(G,R),j=c.terrain&&M?c.terrain.stencilModeForRTTOverlap(q):z[q.overscaledZ],X=f?0:o.paint.get("raster-fade-duration");Z.registerFadeDuration(X);let ie=i.findLoadedParent(q,0),oe=yl(Z,ie,i,c.transform,X),Ee,xe;c.terrain&&c.terrain.prepareDrawTile(q);let ge=o.paint.get("raster-resampling")==="nearest"?y.NEAREST:y.LINEAR;_.activeTexture.set(y.TEXTURE0),Z.texture.bind(ge,y.CLAMP_TO_EDGE),_.activeTexture.set(y.TEXTURE1),ie?(ie.texture.bind(ge,y.CLAMP_TO_EDGE),Ee=Math.pow(2,ie.tileID.overscaledZ-Z.tileID.overscaledZ),xe=[Z.tileID.canonical.x*Ee%1,Z.tileID.canonical.y*Ee%1]):Z.texture.bind(ge,y.CLAMP_TO_EDGE);let ae=vs(N,xe||[0,0],Ee||1,oe,o,w instanceof rr?w.perspectiveTransform:[0,0]);if(c.prepareDrawProgram(_,T,G),w instanceof rr)T.draw(_,y.TRIANGLES,L,a.StencilMode.disabled,E,a.CullFaceMode.disabled,ae,o.id,w.boundsBuffer,c.quadTriangleIndexBuffer,w.boundsSegments);else{let{tileBoundsBuffer:ne,tileBoundsIndexBuffer:_e,tileBoundsSegments:de}=c.getTileBoundsBuffers(Z);T.draw(_,y.TRIANGLES,L,j,E,a.CullFaceMode.disabled,ae,o.id,ne,_e,de)}}c.resetStencilClippingMasks()},background:function(c,i,o,h){let d=o.paint.get("background-color"),f=o.paint.get("background-opacity");if(f===0)return;let _=c.context,y=_.gl,w=c.transform,T=w.tileSize,E=o.paint.get("background-pattern");if(c.isPatternMissing(E))return;let M=!E&&d.a===1&&f===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==M)return;let z=a.StencilMode.disabled,B=c.depthModeForSublayer(0,M==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),P=c.colorModeForRenderPass(),R=c.useProgram(E?"backgroundPattern":"background"),q,L=h;L||(q=c.getBackgroundTiles(),L=Object.values(q).map(Z=>Z.tileID)),E&&(_.activeTexture.set(y.TEXTURE0),c.imageManager.bind(c.context));let G=o.getCrossfadeParameters();for(let Z of L){let N=Z.toUnwrapped(),j=h?Z.projMatrix:c.transform.calculateProjMatrix(N);c.prepareDrawTile(Z);let X=i?i.getTile(Z):q?q[Z.key]:new a.Tile(Z,T,w.zoom,c),ie=E?Ts(j,f,c,E,{tileID:Z,tileSize:T},G):pt(j,f,d);c.prepareDrawProgram(_,R,N);let{tileBoundsBuffer:oe,tileBoundsIndexBuffer:Ee,tileBoundsSegments:xe}=c.getTileBoundsBuffers(X);R.draw(_,y.TRIANGLES,B,z,P,a.CullFaceMode.disabled,ie,o.id,oe,Ee,xe)}},sky:function(c,i,o){let h=c.transform,d=h.projection.name==="mercator"||h.projection.name==="globe"?1:a.smoothstep(7,8,h.zoom),f=o.paint.get("sky-opacity")*d;if(f===0)return;let _=c.context,y=o.paint.get("sky-type"),w=new a.DepthMode(_.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),T=c.frameCounter/1e3%1;y==="atmosphere"?c.renderPass==="offscreen"?o.needsSkyboxCapture(c)&&(function(E,M,z,B){let P=E.context,R=P.gl,q=M.skyboxFbo;if(!q){q=M.skyboxFbo=P.createFramebuffer(32,32,!1),M.skyboxGeometry=new zs(P),M.skyboxTexture=P.gl.createTexture(),R.bindTexture(R.TEXTURE_CUBE_MAP,M.skyboxTexture),R.texParameteri(R.TEXTURE_CUBE_MAP,R.TEXTURE_WRAP_S,R.CLAMP_TO_EDGE),R.texParameteri(R.TEXTURE_CUBE_MAP,R.TEXTURE_WRAP_T,R.CLAMP_TO_EDGE),R.texParameteri(R.TEXTURE_CUBE_MAP,R.TEXTURE_MIN_FILTER,R.LINEAR),R.texParameteri(R.TEXTURE_CUBE_MAP,R.TEXTURE_MAG_FILTER,R.LINEAR);for(let N=0;N<6;++N)R.texImage2D(R.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,R.RGBA,32,32,0,R.RGBA,R.UNSIGNED_BYTE,null)}P.bindFramebuffer.set(q.framebuffer),P.viewport.set([0,0,32,32]);let L=M.getCenter(E,!0),G=E.useProgram("skyboxCapture"),Z=new Float64Array(16);a.identity(Z),a.rotateY(Z,Z,.5*-Math.PI),Vr(P,M,G,Z,L,0),a.identity(Z),a.rotateY(Z,Z,.5*Math.PI),Vr(P,M,G,Z,L,1),a.identity(Z),a.rotateX(Z,Z,.5*-Math.PI),Vr(P,M,G,Z,L,2),a.identity(Z),a.rotateX(Z,Z,.5*Math.PI),Vr(P,M,G,Z,L,3),a.identity(Z),Vr(P,M,G,Z,L,4),a.identity(Z),a.rotateY(Z,Z,Math.PI),Vr(P,M,G,Z,L,5),P.viewport.set([0,0,E.width,E.height])}(c,o),o.markSkyboxValid(c)):c.renderPass==="sky"&&function(E,M,z,B,P){let R=E.context,q=R.gl,L=E.transform,G=E.useProgram("skybox");R.activeTexture.set(q.TEXTURE0),q.bindTexture(q.TEXTURE_CUBE_MAP,M.skyboxTexture);let Z=((N,j,X,ie,oe)=>({u_matrix:N,u_sun_direction:j,u_cubemap:0,u_opacity:ie,u_temporal_offset:oe}))(L.skyboxMatrix,M.getCenter(E,!1),0,B,P);E.prepareDrawProgram(R,G),G.draw(R,q.TRIANGLES,z,a.StencilMode.disabled,E.colorModeForRenderPass(),a.CullFaceMode.backCW,Z,"skybox",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(c,o,w,f,T):y==="gradient"&&c.renderPass==="sky"&&function(E,M,z,B,P){let R=E.context,q=R.gl,L=E.transform,G=E.useProgram("skyboxGradient");M.skyboxGeometry||(M.skyboxGeometry=new zs(R)),R.activeTexture.set(q.TEXTURE0);let Z=M.colorRampTexture;Z||(Z=M.colorRampTexture=new a.Texture(R,M.colorRamp,q.RGBA)),Z.bind(q.LINEAR,q.CLAMP_TO_EDGE);let N=((j,X,ie,oe,Ee)=>({u_matrix:j,u_color_ramp:0,u_center_direction:X,u_radius:a.degToRad(ie),u_opacity:oe,u_temporal_offset:Ee}))(L.skyboxMatrix,M.getCenter(E,!1),M.paint.get("sky-gradient-radius"),B,P);E.prepareDrawProgram(R,G),G.draw(R,q.TRIANGLES,z,a.StencilMode.disabled,E.colorModeForRenderPass(),a.CullFaceMode.backCW,N,"skyboxGradient",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(c,o,w,f,T)},debug:function(c,i,o){for(let h=0;h<o.length;h++)Cs(c,i,o[h])},custom:function(c,i,o){let h=c.context,d=o.implementation;if(c.transform.projection.unsupportedLayers&&c.transform.projection.unsupportedLayers.includes("custom"))a.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if(c.renderPass==="offscreen"){let f=d.prerender;f&&(c.setCustomLayerDefaults(),h.setColorMode(c.colorModeForRenderPass()),f.call(d,h.gl,c.transform.customLayerMatrix()),h.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),h.setColorMode(c.colorModeForRenderPass()),h.setStencilMode(a.StencilMode.disabled);let f=d.renderingMode==="3d"?new a.DepthMode(c.context.gl.LEQUAL,a.DepthMode.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,a.DepthMode.ReadOnly);h.setDepthMode(f),d.render(h.gl,c.transform.customLayerMatrix()),h.setDirty(),c.setBaseState(),h.bindFramebuffer.set(null)}}};class Pl{constructor(i,o){this.context=new Pi(i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=a.SourceCache.maxUnderzooming+a.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new To,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(i,o){let h=!!i&&!!i.terrain&&this.transform.projection.supportsTerrain;if(!(h||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ur(this,i));let d=this._terrain;this.transform.elevation=h?d:null,d.update(i,this.transform,o)}_updateFog(i){let o=i.fog;if(!o||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);let[h,d]=o.getFovAdjustedRange(this.transform._fov);if(h>d)return void(this.transform.fogCullDistSq=null);let f=h+.78*(d-h);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(i,o){if(this.width=i*a.exported.devicePixelRatio,this.height=o*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let h of this.style.order)this.style._layers[h].resize()}setup(){let i=this.context,o=new a.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(a.EXTENT,0),o.emplaceBack(0,a.EXTENT),o.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=i.createVertexBuffer(o,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);let h=new a.StructArrayLayout2i4;h.emplaceBack(0,0),h.emplaceBack(a.EXTENT,0),h.emplaceBack(0,a.EXTENT),h.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=i.createVertexBuffer(h,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);let d=new a.StructArrayLayout2i4;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=i.createVertexBuffer(d,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);let f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=i.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);let _=new a.StructArrayLayout3ui6;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=i.createIndexBuffer(_);let y=new a.StructArrayLayout1ui2;for(let T of[0,1,3,2,0])y.emplaceBack(T);this.debugIndexBuffer=i.createIndexBuffer(y),this.emptyTexture=new a.Texture(i,{width:1,height:1,data:new Uint8Array([0,0,0,0])},i.gl.RGBA),this.identityMat=a.create();let w=this.context.gl;this.stencilClearMode=new a.StencilMode({func:w.ALWAYS,mask:0},0,255,w.ZERO,w.ZERO,w.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(i){return i._makeTileBoundsBuffers(this.context,this.transform.projection),i._tileBoundsBuffer?{tileBoundsBuffer:i._tileBoundsBuffer,tileBoundsIndexBuffer:i._tileBoundsIndexBuffer,tileBoundsSegments:i._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){let i=this.context,o=i.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(i,o.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,cr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(i,o,h){if(!o||this.currentStencilSource===o.id||!i.isTileClipped()||!h||h.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let y=!1;for(let w of h)if(this._tileClippingMaskIDs[w.key]===void 0){y=!0;break}if(!y)return}this.currentStencilSource=o.id;let d=this.context,f=d.gl;this.nextStencilID+h.length>256&&this.clearStencil(),d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);let _=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let y of h){let w=o.getTile(y),T=this._tileClippingMaskIDs[y.key]=this.nextStencilID++,{tileBoundsBuffer:E,tileBoundsIndexBuffer:M,tileBoundsSegments:z}=this.getTileBoundsBuffers(w);_.draw(d,f.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:f.ALWAYS,mask:0},T,255,f.KEEP,f.KEEP,f.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,cr(y.projMatrix),"$clipping",E,M,z)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let i=this.nextStencilID++,o=this.context.gl;return new a.StencilMode({func:o.NOTEQUAL,mask:255},i,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(i){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(i);let o=this.context.gl;return new a.StencilMode({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[i.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(i){let o=this.context.gl,h=i.sort((_,y)=>y.overscaledZ-_.overscaledZ),d=h[h.length-1].overscaledZ,f=h[0].overscaledZ-d+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();let _={};for(let y=0;y<f;y++)_[y+d]=new a.StencilMode({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=f,[_,h]}return[{[d]:a.StencilMode.disabled},h]}colorModeForRenderPass(){let i=this.context.gl;return this._showOverdrawInspector?new a.ColorMode([i.CONSTANT_COLOR,i.ONE],new a.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?a.ColorMode.unblended:a.ColorMode.alphaBlended}depthModeForSublayer(i,o,h){if(!this.opaquePassEnabledForLayer())return a.DepthMode.disabled;let d=1-((1+this.currentLayer)*this.numSublayers+i)*this.depthEpsilon;return new a.DepthMode(h||this.context.gl.LEQUAL,o,[d,d])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(i,o){this.style=i,this.options=o,this.lineAtlas=i.lineAtlas,this.imageManager=i.imageManager,this.glyphManager=i.glyphManager,this.symbolFadeChange=i.placement.symbolFadeChange(a.exported.now()),this.imageManager.beginFrame();let h=this.style.order,d=this.style._sourceCaches;for(let T in d){let E=d[T];E.used&&E.prepare(this.context)}let f={},_={},y={};for(let T in d){let E=d[T];f[T]=E.getVisibleCoordinates(),_[T]=f[T].slice().reverse(),y[T]=E.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let T=0;T<h.length;T++)if(this.style._layers[h[T]].is3D()){this.opaquePassCutoff=T;break}if(this.terrain&&(this.terrain.updateTileBinding(y),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new a.GlobeSharedBuffers(this.context)),!a.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(let T of h){let E=this.style._layers[T],M=i._getLayerSourceCache(E);if(!E.hasOffscreenPass()||E.isHidden(this.transform.zoom))continue;let z=M?_[M.id]:void 0;(E.type==="custom"||E.isSky()||z&&z.length)&&this.renderLayer(this,M,E,z)}this.depthRangeFor3D=[0,1-(i.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let w=a.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(w=this.style.fog.properties.get("color")),this.context.clear({color:o.showOverdrawInspector?a.Color.black:w,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=h.length-1;this.currentLayer>=0;this.currentLayer--){let T=this.style._layers[h[this.currentLayer]],E=i._getLayerSourceCache(T);if(T.isSky())continue;let M=E?_[E.id]:void 0;this._renderTileClippingMasks(T,E,M),this.renderLayer(this,E,T,M)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<h.length;this.currentLayer++){let T=this.style._layers[h[this.currentLayer]],E=i._getLayerSourceCache(T);T.isSky()&&this.renderLayer(this,E,T,E?_[E.id]:void 0)}for(this.transform.projection.name==="globe"&&function(T){let E=T.context,M=E.gl,z=T.transform,B=new a.DepthMode(M.LEQUAL,a.DepthMode.ReadOnly,[0,1]),P=T.useProgram("globeAtmosphere"),R=z._camera.getWorldToCamera(z.worldSize,1),q=z._camera.getCameraToClipPerspective(z._fov,z.width/z.height,z._nearZ,z._farZ),L=a.mul([],R,a.calculateGlobeMatrix(z,z.worldSize)),G=a.mul([],z.labelPlaneMatrix,q),Z=a.transformMat4([],[0,0,0],L),N=a.add([],Z,[z.worldSize/Math.PI/2,0,0]),j=a.transformMat4([],Z,G),X=a.transformMat4([],N,G),ie=a.length(a.sub([],X,j)),oe=1-a.globeToMercatorTransition(z.zoom),Ee={u_center:j,u_radius:ie,u_screen_size:[z.width,z.height],u_pixel_ratio:a.exported.devicePixelRatio,u_opacity:oe,u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};T.prepareDrawProgram(E,P);let xe=T.globeSharedBuffers;xe&&P.draw(E,M.TRIANGLES,B,a.StencilMode.disabled,a.ColorMode.alphaBlended,a.CullFaceMode.backCW,Ee,"skybox",xe.atmosphereVertexBuffer,xe.atmosphereIndexBuffer,xe.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<h.length;){let T=this.style._layers[h[this.currentLayer]],E=i._getLayerSourceCache(T);if(T.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(T)){if(T.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}let M=E?(T.type==="symbol"?y:_)[E.id]:void 0;this._renderTileClippingMasks(T,E,E?f[E.id]:void 0),this.renderLayer(this,E,T,M),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let T=null;a.values(this.style._layers).forEach(E=>{let M=i._getLayerSourceCache(E);M&&!E.isHidden(this.transform.zoom)&&(!T||T.getSource().maxzoom<M.getSource().maxzoom)&&(T=M)}),T&&this.options.showTileBoundaries&&Ro.debug(this,T,T.getVisibleCoordinates())}this.options.showPadding&&function(T){let E=T.transform.padding;pi(T,T.transform.height-(E.top||0),3,zl),pi(T,E.bottom||0,3,Zc),As(T,E.left||0,3,Lo),As(T,T.transform.width-(E.right||0),3,Bo);let M=T.transform.centerPoint;(function(z,B,P,R){an(z,B-1,P-10,2,20,R),an(z,B-10,P-1,20,2,R)})(T,M.x,T.transform.height-M.y,kl)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(a.window.performance.now()),this.saveCanvasCopy())}renderLayer(i,o,h,d){h.isHidden(this.transform.zoom)||(h.type==="background"||h.type==="sky"||h.type==="custom"||d&&d.length)&&(this.id=h.id,this.gpuTimingStart(h),i.transform.projection.unsupportedLayers&&i.transform.projection.unsupportedLayers.includes(h.type)||Ro[h.type](i,o,h,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(i){if(!this.options.gpuTiming)return;let o=this.context.extTimerQuery,h=this.gpuTimers[i.id];h||(h=this.gpuTimers[i.id]={calls:0,cpuTime:0,query:o.createQueryEXT()}),h.calls++,o.beginQueryEXT(o.TIME_ELAPSED_EXT,h.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;let i=this.context.extTimerQuery;i.endQueryEXT(i.TIME_ELAPSED_EXT)}collectGpuTimers(){let i=this.gpuTimers;return this.gpuTimers={},i}queryGpuTimers(i){let o={};for(let h in i){let d=i[h],f=this.context.extTimerQuery,_=f.getQueryObjectEXT(d.query,f.QUERY_RESULT_EXT)/1e6;f.deleteQueryEXT(d.query),o[h]=_}return o}translatePosMatrix(i,o,h,d,f){if(!h[0]&&!h[1])return i;let _=f?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(_){let T=Math.sin(_),E=Math.cos(_);h=[h[0]*E-h[1]*T,h[0]*T+h[1]*E]}let y=[f?h[0]:Ci(o,h[0],this.transform.zoom),f?h[1]:Ci(o,h[1],this.transform.zoom),0],w=new Float32Array(16);return a.translate(w,i,y),w}saveTileTexture(i){let o=this._tileTextures[i.size[0]];o?o.push(i):this._tileTextures[i.size[0]]=[i]}getTileTexture(i){let o=this._tileTextures[i];return o&&o.length>0?o.pop():null}isPatternMissing(i){if(!i)return!1;if(!i.from||!i.to)return!0;let o=this.imageManager.getPattern(i.from.toString()),h=this.imageManager.getPattern(i.to.toString());return!o||!h}currentGlobalDefines(){let i=this.terrain&&this.terrain.renderingToTexture,o=this.style&&this.style.fog,h=[];return this.terrain&&!this.terrain.renderingToTexture&&h.push("TERRAIN"),o&&!i&&o.getOpacity(this.transform.pitch)!==0&&h.push("FOG"),i&&h.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&h.push("OVERDRAW_INSPECTOR"),h}useProgram(i,o,h){this.cache=this.cache||{};let d=h||[],f=this.currentGlobalDefines().concat(d),_=Mo.cacheKey(i,f,o);return this.cache[_]||(this.cache[_]=new Mo(this.context,i,_a[i],o,Ml[i],f)),this.cache[_]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(i){this.terrain&&this.terrain.prepareDrawTile(i)}prepareDrawProgram(i,o,h){if(this.terrain&&this.terrain.renderingToTexture)return;let d=this.style.fog;if(d){let f=d.getOpacity(this.transform.pitch);f!==0&&o.setFogUniformValues(i,((_,y,w,T)=>{let E=y.properties.get("color"),M=_.frameCounter/1e3%1,z=[E.r/E.a,E.g/E.a,E.b/E.a,T];return{u_fog_matrix:w?_.transform.calculateFogTileMatrix(w):_.identityMat,u_fog_range:y.getFovAdjustedRange(_.transform._fov),u_fog_color:z,u_fog_horizon_blend:y.properties.get("horizon-blend"),u_fog_temporal_offset:M}})(this,d,h,f))}}setTileLoadedFlag(i){this.tileLoaded=i}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){let i=this.context.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.copyTexImage2D(i.TEXTURE_2D,0,i.RGBA,0,0,i.drawingBufferWidth,i.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let i=this.style&&this.style.fog;return!!i&&i.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){let i=this._backgroundTiles,o=this._backgroundTiles={},h=this.transform.coveringTiles({tileSize:512});for(let d of h)o[d.key]=i[d.key]||new a.Tile(d,512,this.transform.tileZoom,this);return o}clearBackgroundTiles(){this._backgroundTiles={}}}class ks{constructor(i=0,o=0,h=0,d=0){if(isNaN(i)||i<0||isNaN(o)||o<0||isNaN(h)||h<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=o,this.left=h,this.right=d}interpolate(i,o,h){return o.top!=null&&i.top!=null&&(this.top=a.number(i.top,o.top,h)),o.bottom!=null&&i.bottom!=null&&(this.bottom=a.number(i.bottom,o.bottom,h)),o.left!=null&&i.left!=null&&(this.left=a.number(i.left,o.left,h)),o.right!=null&&i.right!=null&&(this.right=a.number(i.right,o.right,h)),this}getCenter(i,o){let h=a.clamp((this.left+i-this.right)/2,0,i),d=a.clamp((this.top+o-this.bottom)/2,0,o);return new a.pointGeometry(h,d)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new ks(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Nr(c,i){let o=a.getColumn(c,3);a.fromQuat(c,i),a.setColumn(c,3,o)}function Dl(c,i){a.setColumn(c,3,[i[0],i[1],i[2],1])}function Ea(c,i){let o=a.identity$1([]);return a.rotateZ$1(o,o,-i),a.rotateX$1(o,o,-c),o}function Sa(c,i){let o=[c[0],c[1],0],h=[i[0],i[1],0];if(a.length(o)>=1e-15){let _=a.normalize([],o);a.scale$2(h,_,a.dot(h,_)),i[0]=h[0],i[1]=h[1]}let d=a.cross([],i,c);if(a.len(d)<1e-15)return null;let f=Math.atan2(-d[1],d[0]);return Ea(Math.atan2(Math.sqrt(c[0]*c[0]+c[1]*c[1]),-c[2]),f)}class Ll{constructor(i,o){this.position=i,this.orientation=o}get position(){return this._position}set position(i){this._position=this._renderWorldCopies?function(o){if(!o)return;let h=Array.isArray(o)?new a.MercatorCoordinate(o[0],o[1],o[2]):o;return h.x=a.wrap(h.x,0,1),h}(i):i}lookAtPoint(i,o){if(this.orientation=null,!this.position)return;let h=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(i)):0,d=this.position,f=a.MercatorCoordinate.fromLngLat(i,h),_=[f.x-d.x,f.y-d.y,f.z-d.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=Sa(_,o)}setPitchBearing(i,o){this.orientation=Ea(a.degToRad(i),a.degToRad(-o))}}class Ia{constructor(i,o){this._transform=a.identity([]),this._orientation=a.identity$1([]),o&&(this._orientation=o,Nr(this._transform,this._orientation)),i&&Dl(this._transform,i)}get mercatorPosition(){let i=this.position;return new a.MercatorCoordinate(i[0],i[1],i[2])}get position(){let i=a.getColumn(this._transform,3);return[i[0],i[1],i[2]]}set position(i){Dl(this._transform,i)}get orientation(){return this._orientation}set orientation(i){this._orientation=i,Nr(this._transform,this._orientation)}getPitchBearing(){let i=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2])}}setPitchBearing(i,o){this._orientation=Ea(i,o),Nr(this._transform,this._orientation)}forward(){let i=a.getColumn(this._transform,2);return[-i[0],-i[1],-i[2]]}up(){let i=a.getColumn(this._transform,1);return[-i[0],-i[1],-i[2]]}right(){let i=a.getColumn(this._transform,0);return[i[0],i[1],i[2]]}getCameraToWorld(i,o){let h=new Float64Array(16);return a.invert(h,this.getWorldToCamera(i,o)),h}getWorldToCameraPosition(i,o,h){let d=this.position;a.scale$2(d,d,-i);let f=new Float64Array(16);return a.fromScaling(f,[h,h,h]),a.translate(f,f,d),f[10]*=o,f}getWorldToCamera(i,o){let h=new Float64Array(16),d=new Float64Array(4),f=this.position;return a.conjugate(d,this._orientation),a.scale$2(f,f,-i),a.fromQuat(h,d),a.translate(h,h,f),h[1]*=-1,h[5]*=-1,h[9]*=-1,h[13]*=-1,h[8]*=o,h[9]*=o,h[10]*=o,h[11]*=o,h}getCameraToClipPerspective(i,o,h,d){let f=new Float64Array(16);return a.perspective(f,i,o,h,d),f}getDistanceToElevation(i){let o=i===0?0:a.mercatorZfromAltitude(i,this.position[1]),h=this.forward();return(o-this.position[2])/h[2]}clone(){return new Ia([...this.position],[...this.orientation])}}function Bl(c,i){let o=Ds(c),h=function(f,_,y,w,T){let E=new a.LngLat(y.lng-180*qi,y.lat),M=new a.LngLat(y.lng+180*qi,y.lat),z=f.project(E.lng,E.lat),B=f.project(M.lng,M.lat),P=-Math.atan2(B.y-z.y,B.x-z.x),R=a.MercatorCoordinate.fromLngLat(y);R.y=a.clamp(R.y,-.999975,.999975);let q=R.toLngLat(),L=f.project(q.lng,q.lat),G=a.MercatorCoordinate.fromLngLat(q);G.x+=qi;let Z=G.toLngLat(),N=f.project(Z.lng,Z.lat),j=Aa(N.x-L.x,N.y-L.y,P),X=a.MercatorCoordinate.fromLngLat(q);X.y+=qi;let ie=X.toLngLat(),oe=f.project(ie.lng,ie.lat),Ee=Aa(oe.x-L.x,oe.y-L.y,P),xe=Math.abs(j.x)/Math.abs(Ee.y),ge=a.identity([]);a.rotateZ(ge,ge,-P*(1-(T?0:w)));let ae=a.identity([]);return a.scale(ae,ae,[1,1-(1-xe)*w,1]),ae[4]=-Ee.x/Ee.y*w,a.rotateZ(ae,ae,P),a.multiply$1(ae,ge,ae),ae}(c.projection,0,c.center,o,i),d=Ps(c);return a.scale(h,h,[d,d,1]),h}function Ps(c){let i=c.projection,o=Ds(c),h=Ma(i,c.center),d=Ma(i,a.LngLat.convert(i.center));return Math.pow(2,h*o+(1-o)*d)}function Ds(c){let i=c.projection.range;if(!i)return 0;let o=Math.max(c.width,c.height),h=Math.log(o/1024)/Math.LN2;return a.smoothstep(i[0]+h,i[1]+h,c.zoom)}let qi=1/4e4;function Ma(c,i){let o=a.clamp(i.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=new a.LngLat(i.lng-180*qi,o),d=new a.LngLat(i.lng+180*qi,o),f=c.project(h.lng,o),_=c.project(d.lng,o),y=a.MercatorCoordinate.fromLngLat(h),w=a.MercatorCoordinate.fromLngLat(d),T=_.x-f.x,E=_.y-f.y,M=w.x-y.x,z=w.y-y.y,B=Math.sqrt((M*M+z*z)/(T*T+E*E));return Math.log(B)/Math.LN2}function Aa(c,i,o){let h=Math.cos(o),d=Math.sin(o);return{x:c*h-i*d,y:c*d+i*h}}class Fo{constructor(i,o,h,d,f){this.tileSize=512,this._renderWorldCopies=f===void 0||f,this._minZoom=i||0,this._maxZoom=o||22,this._minPitch=h==null?0:h,this._maxPitch=d==null?60:d,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ks,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ia,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){let i=new Fo(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return i.setProjection(this.getProjection()),i._elevation=this._elevation,i._centerAltitude=this._centerAltitude,i.tileSize=this.tileSize,i.setMaxBounds(this.getMaxBounds()),i.width=this.width,i.height=this.height,i.cameraElevationReference=this.cameraElevationReference,i._center=this._center,i._setZoom(this.zoom),i._cameraZoom=this._cameraZoom,i.angle=this.angle,i._fov=this._fov,i._pitch=this._pitch,i._nearZ=this._nearZ,i._farZ=this._farZ,i._averageElevation=this._averageElevation,i._unmodified=this._unmodified,i._edgeInsets=this._edgeInsets.clone(),i._camera=this._camera.clone(),i._calcMatrices(),i.freezeTileCoverage=this.freezeTileCoverage,i}get elevation(){return this._elevation}set elevation(i){this._elevation!==i&&(this._elevation=i,i?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(i){this._terrainEnabled()&&this._cameraZoom==null&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),i&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels"])}setProjection(i){i==null&&(i={name:"mercator"}),this.projectionOptions=i;let o=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(i),!qe(o,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(i){i===void 0?i=!0:i===null&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){let i=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(i))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(i){this.rotation=i}get rotation(){return-this.angle/Math.PI*180}set rotation(i){let o=-i*Math.PI/180;var h;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=(h=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h),function(d,f,_){var y=f[0],w=f[1],T=f[2],E=f[3],M=Math.sin(_),z=Math.cos(_);d[0]=y*z+T*M,d[1]=w*z+E*M,d[2]=y*-M+T*z,d[3]=w*-M+E*z}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(i){let o=a.clamp(i,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=i/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(i){this._averageElevation=i,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(i){let o=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(i){this._zoom=i,this.scale=this.zoomScale(i),this.tileZoom=Math.floor(i),this.zoomFraction=i-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;let i=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return i===-1?(this._cameraZoom=null,!1):(this._centerAltitude=i,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;let i=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],h=this.horizonLineFromTop(),d=0,f=0;for(let _=0;_<o.length;_++){let y=new a.pointGeometry(o[_][0]*this.width,h+o[_][1]*(this.height-h)),w=i.pointCoordinate(y);if(!w)continue;let T=1/Math.hypot(w[0]-this._camera.position[0],w[1]-this._camera.position[1]);d+=w[3]*T,f+=T}return f===0?NaN:d/f}get center(){return this._center}set center(i){i.lat===this._center.lat&&i.lng===this._center.lng||(this._unmodified=!1,this._center=i,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCenterElevation()?this._updateCameraOnTerrain():this._cameraZoom=null:this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._cameraZoom==null||!this._elevation)return;let i=this._cameraZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),h=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(i),f=this._mercatorZfromZoom(this._maxZoom),_=Math.max(d-h,f);this._setZoom(this._zoomFromMercatorZ(_))}get padding(){return this._edgeInsets.toJSON()}set padding(i){this._edgeInsets.equals(i)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,i,1),this._calcMatrices())}computeZoomRelativeTo(i){let o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,i.toAltitude())),h;h=i.z<this._camera.position[2]?[o.x,o.y,o.z]:[i.x,i.y,i.z];let d=a.length(a.sub([],this._camera.position,h));return a.clamp(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(i){if(!this.height||!i.position&&!i.orientation)return;this._updateCameraState();let o=!1;if(i.orientation&&!a.exactEquals(i.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(i.orientation)),i.position){let h=[i.position.x,i.position.y,i.position.z];a.exactEquals$1(h,this._camera.position)||(this._setCameraPosition(h),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let i=this._camera.position,o=new Ll;return o.position=new a.MercatorCoordinate(i[0],i[1],i[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(i){if(!a.length$1(i))return!1;a.normalize$1(i,i);let o=a.transformQuat([],[0,0,-1],i),h=a.transformQuat([],[0,-1,0],i);if(h[2]<0)return!1;let d=Sa(o,h);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(i){let o=this.zoomScale(this.minZoom)*this.tileSize,h=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;i[2]=a.clamp(i[2],d/h,d/o),this._camera.position=i}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(i){return this._edgeInsets.equals(i)}interpolatePadding(i,o,h){this._unmodified=!1,this._edgeInsets.interpolate(i,o,h),this._constrain(),this._calcMatrices()}coveringZoomLevel(i){let o=(i.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/i.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(i){let o=[new a.UnwrappedTileID(0,i)];if(this.renderWorldCopies){let h=this.pointCoordinate(new a.pointGeometry(0,0)),d=this.pointCoordinate(new a.pointGeometry(this.width,0)),f=this.pointCoordinate(new a.pointGeometry(this.width,this.height)),_=this.pointCoordinate(new a.pointGeometry(0,this.height)),y=Math.floor(Math.min(h.x,d.x,f.x,_.x)),w=Math.floor(Math.max(h.x,d.x,f.x,_.x)),T=1;for(let E=y-T;E<=w+T;E++)E!==0&&o.push(new a.UnwrappedTileID(E,i))}return o}coveringTiles(i){let o=this.coveringZoomLevel(i),h=o,d=this.elevation&&!i.isTerrainDEM,f=this.projection.name==="mercator";if(i.minzoom!==void 0&&o<i.minzoom)return[];i.maxzoom!==void 0&&o>i.maxzoom&&(o=i.maxzoom);let _=this.locationCoordinate(this.center),y=1<<o,w=[y*_.x,y*_.y,0],T=a.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,this.projection.name!=="globe"),E=this.pointCoordinate(this.getCameraPoint()),M=y*a.mercatorZfromAltitude(1,this.center.lat),z=this._camera.position[2]/a.mercatorZfromAltitude(1,this.center.lat),B=[y*E.x,y*E.y,z],P=this.cameraToCenterDistance/i.tileSize*(i.roundZoom?1:.502),R=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?o:0,q=i.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,L=i.isTerrainDEM?-q:this._elevation?this._elevation.getMinElevationBelowMSL():0,G=this.projection.isReprojectedInTileSpace?Ps(this):1,Z=ne=>{let de=new a.MercatorCoordinate(ne.x+25e-6,ne.y,ne.z),Be=new a.MercatorCoordinate(ne.x,ne.y+25e-6,ne.z),Ve=ne.toLngLat(),Xe=de.toLngLat(),Te=Be.toLngLat(),Re=this.locationCoordinate(Ve),Ge=this.locationCoordinate(Xe),ft=this.locationCoordinate(Te),xt=Math.hypot(Ge.x-Re.x,Ge.y-Re.y),je=Math.hypot(ft.x-Re.x,ft.y-Re.y);return Math.sqrt(xt*je)*G/25e-6},N=ne=>{let _e=q,de=L;return{aabb:a.tileAABB(this,y,0,0,0,ne,de,_e,this.projection),zoom:0,x:0,y:0,minZ:de,maxZ:_e,wrap:ne,fullyVisible:!1}},j=[],X=[],ie=o,oe=i.reparseOverscaled?h:o,Ee=ne=>ne*ne,xe=Ee((z-this._centerAltitude)*M),ge=ne=>{if(!this._elevation||!ne.tileID||!f)return;let _e=this._elevation.getMinMaxForTile(ne.tileID),de=ne.aabb;_e?(de.min[2]=_e.min,de.max[2]=_e.max,de.center[2]=(de.min[2]+de.max[2])/2):(ne.shouldSplit=ae(ne),ne.shouldSplit||(de.min[2]=de.max[2]=de.center[2]=this._centerAltitude))},ae=ne=>{if(ne.zoom<R)return!0;if(ne.zoom===ie)return!1;if(ne.shouldSplit!=null)return ne.shouldSplit;let _e=ne.aabb.distanceX(B),de=ne.aabb.distanceY(B),Be=xe;d&&(Be=Ee(ne.aabb.distanceZ(B)*M));let Ve=1;if(this.projection.isReprojectedInTileSpace&&h<=5){let Te=Math.pow(2,ne.zoom),Re=Z(new a.MercatorCoordinate((ne.x+.5)/Te,(ne.y+.5)/Te));Ve=Re>.85?1:Re}let Xe=_e*_e+de*de+Be;return Xe<Ee((1<<ie-ne.zoom)*P*Ve*((Te,Re)=>{if(Re*Ee(.707)<Te)return 1;let Ge=Math.sqrt(Re/Te);return Ge/(1.4144271570014144+(Math.pow(1.1,Ge-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Be,xe),Xe))};if(this.renderWorldCopies)for(let ne=1;ne<=3;ne++)j.push(N(-ne)),j.push(N(ne));for(j.push(N(0));j.length>0;){let ne=j.pop(),_e=ne.x,de=ne.y,Be=ne.fullyVisible;if(!Be){let Ve=ne.aabb.intersects(T);if(Ve===0)continue;Be=Ve===2}if(ne.zoom!==ie&&ae(ne))for(let Ve=0;Ve<4;Ve++){let Xe=(_e<<1)+Ve%2,Te=(de<<1)+(Ve>>1),Re={aabb:f?ne.aabb.quadrant(Ve):a.tileAABB(this,y,ne.zoom+1,Xe,Te,ne.wrap,ne.minZ,ne.maxZ,this.projection),zoom:ne.zoom+1,x:Xe,y:Te,wrap:ne.wrap,fullyVisible:Be,tileID:void 0,shouldSplit:void 0,minZ:ne.minZ,maxZ:ne.maxZ};d&&(Re.tileID=new a.OverscaledTileID(ne.zoom+1===ie?oe:ne.zoom+1,ne.wrap,ne.zoom+1,Xe,Te),ge(Re)),j.push(Re)}else{let Ve=ne.zoom===ie?oe:ne.zoom;if(i.minzoom&&i.minzoom>Ve)continue;let Xe=w[0]-(.5+_e+(ne.wrap<<ne.zoom))*(1<<o-ne.zoom),Te=w[1]-.5-de,Re=ne.tileID?ne.tileID:new a.OverscaledTileID(Ve,ne.wrap,ne.zoom,_e,de);X.push({tileID:Re,distanceSq:Xe*Xe+Te*Te})}}if(this.fogCullDistSq){let ne=this.fogCullDistSq,_e=this.horizonLineFromTop();X=X.filter(de=>{let Be=[0,0,0,1],Ve=[a.EXTENT,a.EXTENT,0,1],Xe=this.calculateFogTileMatrix(de.tileID.toUnwrapped());a.transformMat4$1(Be,Be,Xe),a.transformMat4$1(Ve,Ve,Xe);let Te=a.getAABBPointSquareDist(Be,Ve);if(Te===0)return!0;let Re=!1,Ge=this._elevation;if(Ge&&Te>ne&&_e!==0){let ft=this.calculateProjMatrix(de.tileID.toUnwrapped()),xt;i.isTerrainDEM||(xt=Ge.getMinMaxForTile(de.tileID)),xt||(xt={min:L,max:q});let je=a.furthestTileCorner(this.rotation),Ye=[je[0]*a.EXTENT,je[1]*a.EXTENT,xt.max];a.transformMat4(Ye,Ye,ft),Re=(1-Ye[1])*this.height*.5<_e}return Te<ne||Re})}return X.sort((ne,_e)=>ne.distanceSq-_e.distanceSq).map(ne=>ne.tileID)}resize(i,o){this.width=i,this.height=o,this.pixelsToGLUnits=[2/i,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log(i)/Math.LN2}project(i){let o=a.clamp(i.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=this.projection.project(i.lng,o);return new a.pointGeometry(h.x*this.worldSize,h.y*this.worldSize)}unproject(i){return this.projection.unproject(i.x/this.worldSize,i.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(i,o){let h=this.pointCoordinate(o),d=this.pointCoordinate(this.centerPoint),f=this.locationCoordinate(i);this.setLocation(new a.MercatorCoordinate(f.x-(h.x-d.x),f.y-(h.y-d.y)))}setLocation(i){this.center=this.coordinateLocation(i),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(i){return this.projection.locationPoint(this,i)}locationPoint3D(i){return this._coordinatePoint(this.locationCoordinate(i),!0)}pointLocation(i){return this.coordinateLocation(this.pointCoordinate(i))}pointLocation3D(i){return this.coordinateLocation(this.pointCoordinate3D(i))}locationCoordinate(i,o){let h=o?a.mercatorZfromAltitude(o,i.lat):void 0,d=this.projection.project(i.lng,i.lat);return new a.MercatorCoordinate(d.x,d.y,h)}coordinateLocation(i){return this.projection.unproject(i.x,i.y)}pointRayIntersection(i,o){let h=o!=null?o:this._centerAltitude,d=[i.x,i.y,0,1],f=[i.x,i.y,1,1];a.transformMat4$1(d,d,this.pixelMatrixInverse),a.transformMat4$1(f,f,this.pixelMatrixInverse);let _=f[3];a.scale$1(d,d,1/d[3]),a.scale$1(f,f,1/_);let y=d[2],w=f[2];return{p0:d,p1:f,t:y===w?0:(h-y)/(w-y)}}screenPointToMercatorRay(i){let o=[i.x,i.y,0,1],h=[i.x,i.y,1,1];return a.transformMat4$1(o,o,this.pixelMatrixInverse),a.transformMat4$1(h,h,this.pixelMatrixInverse),a.scale$1(o,o,1/o[3]),a.scale$1(h,h,1/h[3]),o[2]=a.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,h[2]=a.mercatorZfromAltitude(h[2],this._center.lat)*this.worldSize,a.scale$1(o,o,1/this.worldSize),a.scale$1(h,h,1/this.worldSize),new a.Ray([o[0],o[1],o[2]],a.normalize([],a.sub([],h,o)))}rayIntersectionCoordinate(i){let{p0:o,p1:h,t:d}=i,f=a.mercatorZfromAltitude(o[2],this._center.lat),_=a.mercatorZfromAltitude(h[2],this._center.lat);return new a.MercatorCoordinate(a.number(o[0],h[0],d)/this.worldSize,a.number(o[1],h[1],d)/this.worldSize,a.number(f,_,d))}pointCoordinate(i,o=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(i.x,i.y,o)}pointCoordinate3D(i){if(!this.elevation)return this.pointCoordinate(i);let o=this.elevation,h=this.elevation.pointCoordinate(i);if(h)return new a.MercatorCoordinate(h[0],h[1],h[2]);let d=0,f=this.horizonLineFromTop();if(i.y>f)return this.pointCoordinate(i);let _=.02*f,y=i.clone();for(let w=0;w<10&&f-d>_;w++){y.y=a.number(d,f,.66);let T=o.pointCoordinate(y);T?(f=y.y,h=T):d=y.y}return h?new a.MercatorCoordinate(h[0],h[1],h[2]):this.pointCoordinate(i)}isPointAboveHorizon(i){if(this.elevation)return!this.elevation.pointCoordinate(i);{let o=this.horizonLineFromTop();return i.y<o}}_coordinatePoint(i,o){let h=o&&this.elevation?this.elevation.getAtPointOrZero(i,this._centerAltitude):this._centerAltitude,d=[i.x*this.worldSize,i.y*this.worldSize,h+i.toAltitude(),1];return a.transformMat4$1(d,d,this.pixelMatrix),d[3]>0?new a.pointGeometry(d[0]/d[3],d[1]/d[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(i,o){let h=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),d=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),f=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),_=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom),y=this.pointCoordinate(h,i),w=this.pointCoordinate(d,i),T=this.pointCoordinate(f,o),E=this.pointCoordinate(_,o),M=(z,B)=>(B.y-z.y)/(B.x-z.x);return y.y>1&&w.y>=0?y=new a.MercatorCoordinate((1-E.y)/M(E,y)+E.x,1):y.y<0&&w.y<=1&&(y=new a.MercatorCoordinate(-E.y/M(E,y)+E.x,0)),w.y>1&&y.y>=0?w=new a.MercatorCoordinate((1-T.y)/M(T,w)+T.x,1):w.y<0&&y.y<=1&&(w=new a.MercatorCoordinate(-T.y/M(T,w)+T.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(y)).extend(this.coordinateLocation(w)).extend(this.coordinateLocation(E)).extend(this.coordinateLocation(T))}_getBounds3D(){let i=this.elevation;if(!i.visibleDemTiles.length)return this._getBounds(0,0);let o=i.visibleDemTiles.reduce((h,d)=>{if(d.dem){let f=d.dem.tree;h.min=Math.min(h.min,f.minimums[0]),h.max=Math.max(h.max,f.maximums[0])}return h},{min:Number.MAX_VALUE,max:0});return this._getBounds(o.min*i.exaggeration(),o.max*i.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(i=!0){let o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,h=this.height/2-o*(1-this._horizonShift);return i?Math.max(0,h):h}getMaxBounds(){return this.maxBounds}setMaxBounds(i){this.maxBounds=i,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,i&&(this.minLat=i.getSouth(),this.maxLat=i.getNorth(),this.minLng=i.getWest(),this.maxLng=i.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=a.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=a.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=a.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(i,o){return this.projection.createTileTransform(this,o).createTileMatrix(i)}calculateDistanceTileData(i){let o=i.key,h=this._distanceTileDataCache;if(h[o])return h[o];let d=i.canonical,f=1/this.height,_=this.cameraWorldSize/this.zoomScale(d.z),y=(d.x+Math.pow(2,d.z)*i.wrap)*_,w=d.y*_,T=this.point,E=this.angle,M=Math.sin(-E),z=-Math.cos(-E);return h[o]={bearing:[M,z],center:[(T.x-y)*f,(T.y-w)*f],scale:_/a.EXTENT*f},h[o]}calculateFogTileMatrix(i){let o=i.key,h=this._fogTileMatrixCache;if(h[o])return h[o];let d=this.calculatePosMatrix(i,this.cameraWorldSize);return a.multiply$1(d,this.worldToFogMatrix,d),h[o]=new Float32Array(d),h[o]}calculateProjMatrix(i,o=!1){let h=i.key,d=o?this._alignedProjMatrixCache:this._projMatrixCache;if(d[h])return d[h];let f=this.calculatePosMatrix(i,this.worldSize);return a.multiply$1(f,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.alignedProjMatrix:this.projMatrix,f),d[h]=new Float32Array(f),d[h]}calculatePixelsToTileUnitsMatrix(i){let o=i.tileID.key,h=this._pixelsToTileUnitsCache;if(h[o])return h[o];let d=function(f,_){let{scale:y}=f.tileTransform,w=y*a.EXTENT/(f.tileSize*Math.pow(2,_.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return T=new Float32Array(4),z=(E=_.inverseAdjustmentMatrix)[1],B=E[2],P=E[3],q=(M=[w,w])[1],T[0]=E[0]*(R=M[0]),T[1]=z*R,T[2]=B*q,T[3]=P*q,T;var T,E,M,z,B,P,R,q}(i,this);return h[o]=d,h[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;let i=this._elevation;this._updateCameraState();let o=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=this._camera.forward(),f=a.mercatorZfromAltitude(1,this._center.lat);h[2]/=f,d[2]/=f,a.normalize(d,d);let _=i.raycast(h,d,i.exaggeration());if(_){let y=a.scaleAndAdd([],h,d,_),w=new a.MercatorCoordinate(y[0],y[1],a.mercatorZfromAltitude(y[2],a.latFromMercatorY(y[1]))),T=(w.z+a.length([w.x-h[0],w.y-h[1],w.z-h[2]*f]))*this._projectionScaler;this._cameraZoom=this._zoomFromMercatorZ(T),this._centerAltitude=w.toAltitude(),this._center=this.coordinateLocation(w),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;let i=this._elevation;this._updateCameraState();let o=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=i.getAtPointOrZero(new a.MercatorCoordinate(...h)),f=this._minimumHeightOverTerrain()*Math.cos(a.degToRad(this._maxPitch)),_=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*d;if(_<f){let y=this.locationCoordinate(this._center,this._centerAltitude),w=[y.x-h[0],y.y-h[1],y.z-h[2]],T=a.length(w);w[2]-=(f-_)/this._projectionScaler;let E=a.length(w);if(E===0)return;a.scale$2(w,w,T/E*this._projectionScaler),this._camera.position=[y.x-w[0],y.y-w[1],y.z*this._projectionScaler-w[2]],this._camera.orientation=Sa(w,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){let M=this.center;return M.lat=a.clamp(M.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(M.lng=a.clamp(M.lng,this.minLng,this.maxLng)),this.center=M,void(this._constraining=!1)}let i=this._unmodified,{x:o,y:h}=this.point,d=0,f=o,_=h,y=this.width/2,w=this.height/2,T=this.worldMinY*this.scale,E=this.worldMaxY*this.scale;if(h-w<T&&(_=T+w),h+w>E&&(_=E-w),E-T<this.height&&(d=Math.max(d,this.height/(E-T)),_=(E+T)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let M=this.worldMinX*this.scale,z=this.worldMaxX*this.scale,B=this.worldSize/2-(M+z)/2;f=(o+B+this.worldSize)%this.worldSize-B,f-y<M&&(f=M+y),f+y>z&&(f=z-y),z-M<this.width&&(d=Math.max(d,this.width/(z-M)),f=(z+M)/2)}f===o&&_===h||(this.center=this.unproject(new a.pointGeometry(f,_))),d&&(this.zoom+=this.scaleZoom(d)),this._constrainCameraAltitude(),this._unmodified=i,this._constraining=!1}_minZoomForBounds(){let i=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(i=Math.max(i,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),i}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;let i=this._fov/2,o=this.centerOffset,h=this.pixelsPerMeter;this._projectionScaler=h/(a.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(i)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;let d=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?h:1),f=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);f[8]=2*-o.x/this.width,f[9]=2*o.y/this.height;let _=a.mul([],f,d);if(this.projection.isReprojectedInTileSpace){let N=this.locationCoordinate(this.center),j=a.identity([]);a.translate(j,j,[N.x*this.worldSize,N.y*this.worldSize,0]),a.multiply$1(j,j,Bl(this)),a.translate(j,j,[-N.x*this.worldSize,-N.y*this.worldSize,0]),a.multiply$1(_,_,j),this.inverseAdjustmentMatrix=function(X){let ie=Bl(X,!0);return Ce([],[ie[0],ie[1],ie[4],ie[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=a.scale([],_,[this.worldSize,this.worldSize,this.worldSize/h,1]),this.projMatrix=_,this.invProjMatrix=a.invert(new Float64Array(16),this.projMatrix);let y=new Float32Array(16);a.identity(y),a.scale(y,y,[1,-1,1]),a.rotateX(y,y,this._pitch),a.rotateZ(y,y,this.angle);let w=a.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),T=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;w[8]=2*-o.x/this.width,w[9]=2*(o.y+T)/this.height,this.skyboxMatrix=a.multiply$1(y,w,y);let E=this.point,M=E.x,z=E.y,B=this.width%2/2,P=this.height%2/2,R=Math.cos(this.angle),q=Math.sin(this.angle),L=M-Math.round(M)+R*B+q*P,G=z-Math.round(z)+R*P+q*B,Z=new Float64Array(_);if(a.translate(Z,Z,[L>.5?L-1:L,G>.5?G-1:G,0]),this.alignedProjMatrix=Z,_=a.create(),a.scale(_,_,[this.width/2,-this.height/2,1]),a.translate(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=a.create(),a.scale(_,_,[1,-1,1]),a.translate(_,_,[-1,-1,0]),a.scale(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},_=a.invert(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let i=this.cameraWorldSize,o=this.cameraPixelsPerMeter,h=this._camera.position,d=1/this.height,f=[i,i,o];a.scale$2(f,f,d),a.scale$2(h,h,-1),a.multiply$2(h,h,f);let _=a.create();a.translate(_,_,h),a.scale(_,_,f),this.mercatorFogMatrix=_,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(i,o,d)}_computeCameraPosition(i){let o=(i=i||this.pixelsPerMeter)/this.pixelsPerMeter,h=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*o-i/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-h[0]*f,d.y/this.worldSize-h[1]*f,i/this.worldSize*this._centerAltitude-h[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(i){let o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),h=i[2],d=1;h>0&&(d=Math.min((o-this._camera.position[2])/h,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,i,d),this._updateStateFromCamera()}_updateStateFromCamera(){let i=this._camera.position,o=this._camera.forward(),{pitch:h,bearing:d}=this._camera.getPitchBearing(),f=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,_=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),y=Math.max((i[2]-f)/Math.cos(h),_),w=this._zoomFromMercatorZ(y);a.scaleAndAdd(i,i,o,y),this._pitch=a.clamp(h,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(d,-Math.PI,Math.PI),this._setZoom(a.clamp(w,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(i[0],i[1],i[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(i){return Math.pow(2,i)*this.tileSize}_mercatorZfromZoom(i){return this.cameraToCenterDistance/this._worldSizeFromZoom(i)}_minimumHeightOverTerrain(){let i=Math.min((this._cameraZoom!=null?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(i)}_zoomFromMercatorZ(i){return this.scaleZoom(this.cameraToCenterDistance/(i*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(i,o){let h=Math.min(i.x,o.x),d=Math.max(i.x,o.x),f=Math.min(i.y,o.y),_=Math.max(i.y,o.y);if(f<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;let y=[new a.pointGeometry(h,f),new a.pointGeometry(d,_),new a.pointGeometry(h,_),new a.pointGeometry(d,f)],w=this.renderWorldCopies?-3:0,T=this.renderWorldCopies?4:1;for(let E of y){let M=this.pointRayIntersection(E);if(M.t<0)return!0;let z=this.rayIntersectionCoordinate(M);if(z.x<w||z.y<0||z.x>T||z.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(i,o){let h=a.length(a.sub([],this._camera.position,i)),d=this._zoomFromMercatorZ(h)+o;return h-this._mercatorZfromZoom(d)}getCameraPoint(){let i=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,i))}}function jr(c,i){let o=!1,h=null,d=()=>{h=null,o&&(c(),h=setTimeout(d,i),o=!1)};return()=>(o=!0,h||d(),h)}class Rl{constructor(i){this._hashName=i&&encodeURIComponent(i),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=jr(this._updateHashUnthrottled.bind(this),300)}addTo(i){return this._map=i,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(i){let o=this._map.getCenter(),h=Math.round(100*this._map.getZoom())/100,d=Math.ceil((h*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,d),_=Math.round(o.lng*f)/f,y=Math.round(o.lat*f)/f,w=this._map.getBearing(),T=this._map.getPitch(),E="";if(E+=i?`/${_}/${y}/${h}`:`${h}/${y}/${_}`,(w||T)&&(E+="/"+Math.round(10*w)/10),T&&(E+=`/${Math.round(T)}`),this._hashName){let M=this._hashName,z=!1,B=a.window.location.hash.slice(1).split("&").map(P=>{let R=P.split("=")[0];return R===M?(z=!0,`${R}=${E}`):P}).filter(P=>P);return z||B.push(`${M}=${E}`),`#${B.join("&")}`}return`#${E}`}_getCurrentHash(){let i=a.window.location.hash.replace("#","");if(this._hashName){let o;return i.split("&").map(h=>h.split("=")).forEach(h=>{h[0]===this._hashName&&(o=h)}),(o&&o[1]||"").split("/")}return i.split("/")}_onHashChange(){let i=this._getCurrentHash();if(i.length>=3&&!i.some(o=>isNaN(o))){let o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(i[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:o,pitch:+(i[4]||0)}),!0}return!1}_updateHashUnthrottled(){let i=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,i)}}let xr={linearity:.3,easing:a.bezier(0,0,.3,1)},Un=a.extend({deceleration:2500,maxSpeed:1400},xr),Fl=a.extend({deceleration:20,maxSpeed:1400},xr),Ca=a.extend({deceleration:1e3,maxSpeed:360},xr),ht=a.extend({deceleration:1e3,maxSpeed:90},xr);class Ls{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(i){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:i})}_drainInertiaBuffer(){let i=this._inertiaBuffer,o=a.exported.now();for(;i.length>0&&o-i[0].time>160;)i.shift()}_onMoveEnd(i){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let o={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(let{settings:f}of this._inertiaBuffer)o.zoom+=f.zoomDelta||0,o.bearing+=f.bearingDelta||0,o.pitch+=f.pitchDelta||0,f.panDelta&&o.pan._add(f.panDelta),f.around&&(o.around=f.around),f.pinchAround&&(o.pinchAround=f.pinchAround);let h=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){let f=Oo(o.pan.mag(),h,a.extend({},Un,i||{}));d.offset=o.pan.mult(f.amount/o.pan.mag()),d.center=this._map.transform.center,Bs(d,f)}if(o.zoom){let f=Oo(o.zoom,h,Fl);d.zoom=this._map.transform.zoom+f.amount,Bs(d,f)}if(o.bearing){let f=Oo(o.bearing,h,Ca);d.bearing=this._map.transform.bearing+a.clamp(f.amount,-179,179),Bs(d,f)}if(o.pitch){let f=Oo(o.pitch,h,ht);d.pitch=this._map.transform.pitch+f.amount,Bs(d,f)}if(d.zoom||d.bearing){let f=o.pinchAround===void 0?o.around:o.pinchAround;d.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),a.extend(d,{noMoveStart:!0})}}function Bs(c,i){(!c.duration||c.duration<i.duration)&&(c.duration=i.duration,c.easing=i.easing)}function Oo(c,i,o){let{maxSpeed:h,linearity:d,deceleration:f}=o,_=a.clamp(c*d/(i/1e3),-h,h),y=Math.abs(_)/(f*d);return{easing:o.easing,duration:1e3*y,amount:_*(y/2)}}class ii extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o,h,d={}){let f=me.mousePos(o.getCanvasContainer(),h),_=o.unproject(f);super(i,a.extend({point:f,lngLat:_,originalEvent:h},d)),this._defaultPrevented=!1,this.target=o}}class Rs extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o,h){let d=i==="touchend"?h.changedTouches:h.touches,f=me.touchPos(o.getCanvasContainer(),d),_=f.map(w=>o.unproject(w)),y=f.reduce((w,T,E,M)=>w.add(T.div(M.length)),new a.pointGeometry(0,0));super(i,{points:f,point:y,lngLats:_,lngLat:o.unproject(y),originalEvent:h}),this._defaultPrevented=!1}}class $c extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o,h){super(i,{originalEvent:h}),this._defaultPrevented=!1}}class Ol{constructor(i,o){this._map=i,this._clickTolerance=o.clickTolerance}reset(){delete this._mousedownPos}wheel(i){return this._firePreventable(new $c(i.type,this._map,i))}mousedown(i,o){return this._mousedownPos=o,this._firePreventable(new ii(i.type,this._map,i))}mouseup(i){this._map.fire(new ii(i.type,this._map,i))}preclick(i){let o=a.extend({},i);o.type="preclick",this._map.fire(new ii(o.type,this._map,o))}click(i,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(i),this._map.fire(new ii(i.type,this._map,i)))}dblclick(i){return this._firePreventable(new ii(i.type,this._map,i))}mouseover(i){this._map.fire(new ii(i.type,this._map,i))}mouseout(i){this._map.fire(new ii(i.type,this._map,i))}touchstart(i){return this._firePreventable(new Rs(i.type,this._map,i))}touchmove(i){this._map.fire(new Rs(i.type,this._map,i))}touchend(i){this._map.fire(new Rs(i.type,this._map,i))}touchcancel(i){this._map.fire(new Rs(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class qc{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(i){this._map.fire(new ii(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ii("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._map.fire(new ii(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class za{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,o){this.isEnabled()&&i.shiftKey&&i.button===0&&(me.disableDrag(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(i,o){if(!this._active)return;let h=o;if(this._lastPos.equals(h)||!this._box&&h.dist(this._startPos)<this._clickTolerance)return;let d=this._startPos;this._lastPos=h,this._box||(this._box=me.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",i));let f=Math.min(d.x,h.x),_=Math.max(d.x,h.x),y=Math.min(d.y,h.y),w=Math.max(d.y,h.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${f}px,${y}px)`,this._box.style.width=_-f+"px",this._box.style.height=w-y+"px")})}mouseupWindow(i,o){if(!this._active||i.button!==0)return;let h=this._startPos,d=o;if(this.reset(),me.suppressClick(),h.x!==d.x||h.y!==d.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:i})),{cameraAnimation:f=>f.fitScreenCoordinates(h,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",i)}keydown(i){this._active&&i.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",i))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),me.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(i,o){return this._map.fire(new a.Event(i,{originalEvent:o}))}}function Vn(c,i){let o={};for(let h=0;h<c.length;h++)o[c[h].identifier]=i[h];return o}class Uo{constructor(i){this.reset(),this.numTouches=i.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(i,o,h){(this.centroid||h.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=i.timeStamp),h.length===this.numTouches&&(this.centroid=function(d){let f=new a.pointGeometry(0,0);for(let _ of d)f._add(_);return f.div(d.length)}(o),this.touches=Vn(h,o)))}touchmove(i,o,h){if(this.aborted||!this.centroid)return;let d=Vn(h,o);for(let f in this.touches){let _=this.touches[f],y=d[f];(!y||y.dist(_)>30)&&(this.aborted=!0)}}touchend(i,o,h){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),h.length===0){let d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class Vo{constructor(i){this.singleTap=new Uo(i),this.numTaps=i.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(i,o,h){this.singleTap.touchstart(i,o,h)}touchmove(i,o,h){this.singleTap.touchmove(i,o,h)}touchend(i,o,h){let d=this.singleTap.touchend(i,o,h);if(d){let f=i.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(d)<30;if(f&&_||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class ka{constructor(){this._zoomIn=new Vo({numTouches:1,numTaps:2}),this._zoomOut=new Vo({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,o,h){this._zoomIn.touchstart(i,o,h),this._zoomOut.touchstart(i,o,h)}touchmove(i,o,h){this._zoomIn.touchmove(i,o,h),this._zoomOut.touchmove(i,o,h)}touchend(i,o,h){let d=this._zoomIn.touchend(i,o,h),f=this._zoomOut.touchend(i,o,h);return d?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()+1,around:_.unproject(d)},{originalEvent:i})}):f?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()-1,around:_.unproject(f)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}let Ul={0:1,2:2};class Nn{constructor(i){this.reset(),this._clickTolerance=i.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(i,o){return!1}_move(i,o){return{}}mousedown(i,o){if(this._lastPoint)return;let h=me.mouseButton(i);this._correctButton(i,h)&&(this._lastPoint=o,this._eventButton=h)}mousemoveWindow(i,o){let h=this._lastPoint;if(h){if(i.preventDefault(),function(d,f){let _=Ul[f];return d.buttons===void 0||(d.buttons&_)!==_}(i,this._eventButton))this.reset();else if(this._moved||!(o.dist(h)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(h,o)}}mouseupWindow(i){this._lastPoint&&me.mouseButton(i)===this._eventButton&&(this._moved&&me.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fs extends Nn{mousedown(i,o){super.mousedown(i,o),this._lastPoint&&(this._active=!0)}_correctButton(i,o){return o===0&&!i.ctrlKey}_move(i,o){return{around:o,panDelta:o.sub(i)}}}class Ri extends Nn{_correctButton(i,o){return o===0&&i.ctrlKey||o===2}_move(i,o){let h=.8*(o.x-i.x);if(h)return this._active=!0,{bearingDelta:h}}contextmenu(i){i.preventDefault()}}class Pa extends Nn{_correctButton(i,o){return o===0&&i.ctrlKey||o===2}_move(i,o){let h=-.5*(o.y-i.y);if(h)return this._active=!0,{pitchDelta:h}}contextmenu(i){i.preventDefault()}}class Vl{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),a.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new a.pointGeometry(0,0)}touchstart(i,o,h){return this._calculateTransform(i,o,h)}touchmove(i,o,h){if(this._active&&!(h.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(h.length===1)return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return i.preventDefault(),this._calculateTransform(i,o,h)}}touchend(i,o,h){this._calculateTransform(i,o,h),this._active&&h.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(i,o,h){h.length>0&&(this._active=!0);let d=Vn(h,o),f=new a.pointGeometry(0,0),_=new a.pointGeometry(0,0),y=0;for(let T in d){let E=d[T],M=this._touches[T];M&&(f._add(E),_._add(E.sub(M)),y++,d[T]=E)}if(this._touches=d,y<this._minTouches||!_.mag())return;let w=_.div(y);return this._sum._add(w),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(y),panDelta:w}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=me.create("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class Os{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(i){}_move(i,o,h){return{}}touchstart(i,o,h){this._firstTwoTouches||h.length<2||(this._firstTwoTouches=[h[0].identifier,h[1].identifier],this._start([o[0],o[1]]))}touchmove(i,o,h){if(!this._firstTwoTouches)return;i.preventDefault();let[d,f]=this._firstTwoTouches,_=vr(h,o,d),y=vr(h,o,f);if(!_||!y)return;let w=this._aroundCenter?null:_.add(y).div(2);return this._move([_,y],w,i)}touchend(i,o,h){if(!this._firstTwoTouches)return;let[d,f]=this._firstTwoTouches,_=vr(h,o,d),y=vr(h,o,f);_&&y||(this._active&&me.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&i.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function vr(c,i,o){for(let h=0;h<c.length;h++)if(c[h].identifier===o)return i[h]}function Da(c,i){return Math.log(c/i)/Math.LN2}class Us extends Os{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(i){this._startDistance=this._distance=i[0].dist(i[1])}_move(i,o){let h=this._distance;if(this._distance=i[0].dist(i[1]),this._active||!(Math.abs(Da(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Da(this._distance,h),pinchAround:o}}}function Vs(c,i){return 180*c.angleWith(i)/Math.PI}class Ns extends Os{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,o){let h=this._vector;if(this._vector=i[0].sub(i[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Vs(this._vector,h),pinchAround:o}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());let o=25/(Math.PI*this._minDiameter)*360,h=Vs(i,this._startVector);return Math.abs(h)<o}}function js(c){return Math.abs(c.y)>Math.abs(c.x)}class Nl extends Os{constructor(i){super(),this._map=i}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(i){this._lastPoints=i,js(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,o,h){let d=i[0].sub(this._lastPoints[0]),f=i[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&h.touches.length<3)&&(this._valid=this.gestureBeginsVertically(d,f,h.timeStamp),this._valid))return this._lastPoints=i,this._active=!0,{pitchDelta:(d.y+f.y)/2*-.5}}gestureBeginsVertically(i,o,h){if(this._valid!==void 0)return this._valid;let d=i.mag()>=2,f=o.mag()>=2;if(!d&&!f)return;if(!d||!f)return this._firstMove===void 0&&(this._firstMove=h),h-this._firstMove<100&&void 0;let _=i.y>0==o.y>0;return js(i)&&js(o)&&_}}let jn={panStep:100,bearingStep:15,pitchStep:10};class Xc{constructor(){let i=jn;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let o=0,h=0,d=0,f=0,_=0;switch(i.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:i.shiftKey?h=-1:(i.preventDefault(),f=-1);break;case 39:i.shiftKey?h=1:(i.preventDefault(),f=1);break;case 38:i.shiftKey?d=1:(i.preventDefault(),_=-1);break;case 40:i.shiftKey?d=-1:(i.preventDefault(),_=1);break;default:return}return this._rotationDisabled&&(h=0,d=0),{cameraAnimation:y=>{let w=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:Wc,zoom:o?Math.round(w)+o*(i.shiftKey?2:1):w,bearing:y.getBearing()+h*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-_*this._panStep],center:y.getCenter()},{originalEvent:i})}}}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 Wc(c){return c*(2-c)}let La=4.000244140625;class Gs{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._handler=o,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&i.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(i){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(i.ctrlKey||i.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=i.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*i.deltaY:i.deltaY,h=a.exported.now(),d=h-(this._lastWheelEventTime||0);this._lastWheelEventTime=h,o!==0&&o%La==0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=setTimeout(this._onTimeout,40,i)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),i.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=i,this._delta-=o,this._active||this._start(i)),i.preventDefault()}_onTimeout(i){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)}_start(i){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);let o=me.mousePos(this._el,i);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let i=this._map.transform,o=()=>i._terrainEnabled()&&this._aroundCoord?i.computeZoomRelativeTo(this._aroundCoord):i.zoom;if(this._delta!==0){let w=this._type==="wheel"&&Math.abs(this._delta)>La?this._wheelZoomRate:this._defaultZoomRate,T=2/(1+Math.exp(-Math.abs(this._delta*w)));this._delta<0&&T!==0&&(T=1/T);let E=o(),M=Math.pow(2,E),z=typeof this._targetZoom=="number"?i.zoomScale(this._targetZoom):M;this._targetZoom=Math.min(i.maxZoom,Math.max(i.minZoom,i.scaleZoom(z*T))),this._type==="wheel"&&(this._startZoom=o(),this._easing=this._smoothOutEasing(200)),this._delta=0}let h=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,f=this._easing,_,y=!1;if(this._type==="wheel"&&d&&f){let w=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),T=f(w);_=a.number(d,h,T),w<1?this._frameId||(this._frameId=!0):y=!0}else _=h,y=!0;return this._active=!0,y&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!y,zoomDelta:_-o(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(i){let o=a.ease;if(this._prevEase){let h=this._prevEase,d=(a.exported.now()-h.start)/h.duration,f=h.easing(d+.01)-h.easing(d),_=.27/Math.sqrt(f*f+1e-4)*.01,y=Math.sqrt(.0729-_*_);o=a.bezier(_,y,.25,1)}return this._prevEase={start:a.exported.now(),duration:i,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=me.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!a.window.document.fullscreenElement}_showBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class Ba{constructor(i,o){this._clickZoom=i,this._tapZoom=o}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 jl{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(i,o){return i.preventDefault(),{cameraAnimation:h=>{h.easeTo({duration:300,zoom:h.getZoom()+(i.shiftKey?-1:1),around:h.unproject(o)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gl{constructor(){this._tap=new Vo({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(i,o,h){this._swipePoint||(this._tapTime&&i.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?h.length>0&&(this._swipePoint=o[0],this._swipeTouch=h[0].identifier):this._tap.touchstart(i,o,h))}touchmove(i,o,h){if(this._tapTime){if(this._swipePoint){if(h[0].identifier!==this._swipeTouch)return;let d=o[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,i.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(i,o,h)}touchend(i,o,h){this._tapTime?this._swipePoint&&h.length===0&&this.reset():this._tap.touchend(i,o,h)&&(this._tapTime=i.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zs{constructor(i,o,h){this._el=i,this._mousePan=o,this._touchPan=h}enable(i){this._inertiaOptions=i||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ra{constructor(i,o,h){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=o,this._mousePitch=h}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 Zl{constructor(i,o,h,d){this._el=i,this._touchZoom=o,this._touchRotate=h,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("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()}}let No=c=>c.zoom||c.drag||c.pitch||c.rotate;class $l extends a.Event{}class ql{constructor(){this.constants=[1,1,.01],this.radius=0}setup(i,o){let h=a.sub([],o,i);this.radius=a.length(h[2]<0?a.div([],h,this.constants):[h[0],h[1],0])}projectRay(i){a.div(i,i,this.constants),a.normalize(i,i),a.mul$1(i,i,this.constants);let o=a.scale$2([],i,this.radius);if(o[2]>0){let h=a.scale$2([],[0,0,1],a.dot(o,[0,0,1])),d=a.scale$2([],a.normalize([],[o[0],o[1],0]),this.radius),f=a.add([],o,a.scale$2([],a.sub([],a.add([],d,h),o),2));o[0]=f[0],o[1]=f[1]}return o}}function jo(c){return c.panDelta&&c.panDelta.mag()||c.zoomDelta||c.bearingDelta||c.pitchDelta}class Gn{constructor(i,o){this._map=i,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ls(i),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new ql,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),a.bindAll(["handleEvent","handleWindowEvent"],this);let h=this._el;this._listeners=[[h,"touchstart",{passive:!0}],[h,"touchmove",{passive:!1}],[h,"touchend",void 0],[h,"touchcancel",void 0],[h,"mousedown",void 0],[h,"mousemove",void 0],[h,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0}],[a.window.document,"mouseup",void 0],[h,"mouseover",void 0],[h,"mouseout",void 0],[h,"dblclick",void 0],[h,"click",void 0],[h,"keydown",{capture:!1}],[h,"keyup",void 0],[h,"wheel",{passive:!1}],[h,"contextmenu",void 0],[a.window,"blur",void 0]];for(let[d,f,_]of this._listeners)d.addEventListener(f,d===a.window.document?this.handleWindowEvent:this.handleEvent,_)}destroy(){for(let[i,o,h]of this._listeners)i.removeEventListener(o,i===a.window.document?this.handleWindowEvent:this.handleEvent,h)}_addDefaultHandlers(i){let o=this._map,h=o.getCanvasContainer();this._add("mapEvent",new Ol(o,i));let d=o.boxZoom=new za(o,i);this._add("boxZoom",d);let f=new ka,_=new jl;o.doubleClickZoom=new Ba(_,f),this._add("tapZoom",f),this._add("clickZoom",_);let y=new Gl;this._add("tapDragZoom",y);let w=o.touchPitch=new Nl(o);this._add("touchPitch",w);let T=new Ri(i),E=new Pa(i);o.dragRotate=new Ra(i,T,E),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",E,["mouseRotate"]);let M=new Fs(i),z=new Vl(o,i);o.dragPan=new Zs(h,M,z),this._add("mousePan",M),this._add("touchPan",z,["touchZoom","touchRotate"]);let B=new Ns,P=new Us;o.touchZoomRotate=new Zl(h,P,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",P,["touchPan","touchRotate"]),this._add("blockableMapEvent",new qc(o));let R=o.scrollZoom=new Gs(o,this);this._add("scrollZoom",R,["mousePan"]);let q=o.keyboard=new Xc;this._add("keyboard",q);for(let L of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])i.interactive&&i[L]&&o[L].enable(i[L])}_add(i,o,h){this._handlers.push({handlerName:i,handler:o,allowed:h}),this._handlersById[i]=o}stop(i){if(!this._updatingCamera){for(let{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[]}}isActive(){for(let{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(No(this._eventsInProgress))||this.isZooming()}_blockedByActive(i,o,h){for(let d in i)if(d!==h&&(!o||o.indexOf(d)<0))return!0;return!1}handleWindowEvent(i){this.handleEvent(i,`${i.type}Window`)}_getMapTouches(i){let o=[];for(let h of i)this._el.contains(h.target)&&o.push(h);return o}handleEvent(i,o){this._updatingCamera=!0;let h=i.type==="renderFrame",d=h?void 0:i,f={needsRenderFrame:!1},_={},y={},w=i.touches?this._getMapTouches(i.touches):void 0,T=w?me.touchPos(this._el,w):h?void 0:me.mousePos(this._el,i);for(let{handlerName:z,handler:B,allowed:P}of this._handlers){if(!B.isEnabled())continue;let R;this._blockedByActive(y,P,z)?B.reset():B[o||i.type]&&(R=B[o||i.type](i,T,w),this.mergeHandlerResult(f,_,R,z,d),R&&R.needsRenderFrame&&this._triggerRenderFrame()),(R||B.isActive())&&(y[z]=B)}let E={};for(let z in this._previousActiveHandlers)y[z]||(E[z]=d);this._previousActiveHandlers=y,(Object.keys(E).length||jo(f))&&(this._changes.push([f,_,E]),this._triggerRenderFrame()),(Object.keys(y).length||jo(f))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:M}=f;M&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],M(this._map))}mergeHandlerResult(i,o,h,d,f){if(!h)return;a.extend(i,h);let _={handlerName:d,originalEvent:h.originalEvent||f};h.zoomDelta!==void 0&&(o.zoom=_),h.panDelta!==void 0&&(o.drag=_),h.pitchDelta!==void 0&&(o.pitch=_),h.bearingDelta!==void 0&&(o.rotate=_)}_applyChanges(){let i={},o={},h={};for(let[d,f,_]of this._changes)d.panDelta&&(i.panDelta=(i.panDelta||new a.pointGeometry(0,0))._add(d.panDelta)),d.zoomDelta&&(i.zoomDelta=(i.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(i.bearingDelta=(i.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(i.pitchDelta=(i.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(i.around=d.around),d.aroundCoord!==void 0&&(i.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(i.pinchAround=d.pinchAround),d.noInertia&&(i.noInertia=d.noInertia),a.extend(o,f),a.extend(h,_);this._updateMapTransform(i,o,h),this._changes=[]}_updateMapTransform(i,o,h){let d=this._map,f=d.transform,_=G=>[G.x,G.y,G.z];if((G=>{let Z=this._eventsInProgress.drag;return Z&&!this._handlersById[Z.handlerName].isActive()})()&&!jo(i)){let G=f.zoom;f.cameraElevationReference="sea",f.recenterOnTerrain(),f.cameraElevationReference="ground",G!==f.zoom&&this._map._update(!0)}if(!jo(i))return this._fireEvents(o,h,!0);let{panDelta:y,zoomDelta:w,bearingDelta:T,pitchDelta:E,around:M,aroundCoord:z,pinchAround:B}=i;B!==void 0&&(M=B),(G=>o.drag&&!this._eventsInProgress.drag)()&&M&&(this._dragOrigin=_(f.pointCoordinate3D(M)),this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),M=M||d.transform.centerPoint,T&&(f.bearing+=T),E&&(f.pitch+=E),f._updateCameraState();let P=[0,0,0];if(y){let G=f.pointCoordinate(M),Z=f.pointCoordinate(M.sub(y));G&&Z&&(P[0]=Z.x-G.x,P[1]=Z.y-G.y)}let R=f.zoom,q=[0,0,0];if(w){let G=_(z||f.pointCoordinate3D(M)),Z={dir:a.normalize([],a.sub([],G,f._camera.position))};if(Z.dir[2]<0){let N=f.zoomDeltaToMovement(G,w);a.scale$2(q,Z.dir,N)}}let L=a.add(P,P,q);f._translateCameraConstrained(L),w&&Math.abs(f.zoom-R)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),i.noInertia||this._inertia.record(i),this._fireEvents(o,h,!0)}_fireEvents(i,o,h){let d=No(this._eventsInProgress),f=No(i),_={};for(let E in i){let{originalEvent:M}=i[E];this._eventsInProgress[E]||(_[`${E}start`]=M),this._eventsInProgress[E]=i[E]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(let E in _)this._fireEvent(E,_[E]);f&&this._fireEvent("move",f.originalEvent);for(let E in i){let{originalEvent:M}=i[E];this._fireEvent(E,M)}let y={},w;for(let E in this._eventsInProgress){let{handlerName:M,originalEvent:z}=this._eventsInProgress[E];this._handlersById[M].isActive()||(delete this._eventsInProgress[E],w=o[M]||z,y[`${E}end`]=w)}for(let E in y)this._fireEvent(E,y[E]);let T=No(this._eventsInProgress);if(h&&(d||f)&&!T){this._updatingCamera=!0;let E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),M=z=>z!==0&&-this._bearingSnap<z&&z<this._bearingSnap;E?(M(E.bearing||this._map.getBearing())&&(E.bearing=0),this._map.easeTo(E,{originalEvent:w})):(this._map.fire(new a.Event("moveend",{originalEvent:w})),M(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(i,o){this._map.fire(new a.Event(i,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(i=>{delete this._frameId,this.handleEvent(new $l("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}let Fa="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Xl extends a.Evented{constructor(i,o){super(),this._moving=!1,this._zooming=!1,this.transform=i,this._bearingSnap=o.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(i,o){return this.jumpTo({center:i},o)}panBy(i,o,h){return i=a.pointGeometry.convert(i).mult(-1),this.panTo(this.transform.center,a.extend({offset:i},o),h)}panTo(i,o,h){return this.easeTo(a.extend({center:i},o),h)}getZoom(){return this.transform.zoom}setZoom(i,o){return this.jumpTo({zoom:i},o),this}zoomTo(i,o,h){return this.easeTo(a.extend({zoom:i},o),h)}zoomIn(i,o){return this.zoomTo(this.getZoom()+1,i,o),this}zoomOut(i,o){return this.zoomTo(this.getZoom()-1,i,o),this}getBearing(){return this.transform.bearing}setBearing(i,o){return this.jumpTo({bearing:i},o),this}getPadding(){return this.transform.padding}setPadding(i,o){return this.jumpTo({padding:i},o),this}rotateTo(i,o,h){return this.easeTo(a.extend({bearing:i},o),h)}resetNorth(i,o){return this.rotateTo(0,a.extend({duration:1e3},i),o),this}resetNorthPitch(i,o){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},i),o),this}snapToNorth(i,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(i,o):this}getPitch(){return this.transform.pitch}setPitch(i,o){return this.jumpTo({pitch:i},o),this}cameraForBounds(i,o){i=a.LngLatBounds.convert(i);let h=o&&o.bearing||0;return this._cameraForBoxAndBearing(i.getNorthWest(),i.getSouthEast(),h,o)}_extendCameraOptions(i){let o={top:0,bottom:0,right:0,left:0};if(typeof(i=a.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding=="number"){let h=i.padding;i.padding={top:h,bottom:h,right:h,left:h}}return i.padding=a.extend(o,i.padding),i}_cameraForBoxAndBearing(i,o,h,d){let f=this._extendCameraOptions(d),_=this.transform,y=_.padding,w=_.project(a.LngLat.convert(i)),T=_.project(a.LngLat.convert(o)),E=w.rotate(-a.degToRad(h)),M=T.rotate(-a.degToRad(h)),z=new a.pointGeometry(Math.max(E.x,M.x),Math.max(E.y,M.y)),B=new a.pointGeometry(Math.min(E.x,M.x),Math.min(E.y,M.y)),P=z.sub(B),R=(_.width-(y.left+y.right+f.padding.left+f.padding.right))/P.x,q=(_.height-(y.top+y.bottom+f.padding.top+f.padding.bottom))/P.y;if(q<0||R<0)return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let L=Math.min(_.scaleZoom(_.scale*Math.min(R,q)),f.maxZoom),G=typeof f.offset.x=="number"?new a.pointGeometry(f.offset.x,f.offset.y):a.pointGeometry.convert(f.offset),Z=new a.pointGeometry((f.padding.left-f.padding.right)/2,(f.padding.top-f.padding.bottom)/2).rotate(h*Math.PI/180),N=G.add(Z).mult(_.scale/_.zoomScale(L));return{center:_.unproject(w.add(T).div(2).sub(N)),zoom:L,bearing:h}}_cameraForBox(i,o,h,d,f){let _=this._extendCameraOptions(f);h=h||0,d=d||0,i=a.LngLat.convert(i),o=a.LngLat.convert(o);let y=this.transform.clone();y.padding=_.padding;let w=this.getFreeCameraOptions(),T=new a.LngLat(.5*(i.lng+o.lng),.5*(i.lat+o.lat)),E=.5*(h+d);if(y._camera.position[2]<a.mercatorZfromAltitude(E,T.lat))return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");w.lookAtPoint(T),y.setFreeCameraOptions(w);let M=a.MercatorCoordinate.fromLngLat(i),z=a.MercatorCoordinate.fromLngLat(o),B=y.pointRayIntersection(y.centerPoint,E),P=[(R=y.rayIntersectionCoordinate(B)).x,R.y,R.z];var R;let q=y.screenPointToMercatorRay(y.centerPoint),L=y.projection.name!=="globe",G,Z=0;do{let N=Math.floor(y.zoom),j=1<<N,X=Math.min(j*M.x,j*z.x),ie=Math.min(j*M.y,j*z.y),oe=Math.max(j*M.x,j*z.x),Ee=Math.max(j*M.y,j*z.y),xe=new a.Aabb([X,ie,h],[oe,Ee,d]),ge=a.Frustum.fromInvProjectionMatrix(y.invProjMatrix,y.worldSize,N,L);if(xe.intersects(ge)!==2){G&&(y._camera.position=a.scaleAndAdd([],y._camera.position,q.dir,-G),y._updateStateFromCamera());break}let ae=a.sub([],y._camera.position,P);G=.5*a.length(ae),y._camera.position=a.scaleAndAdd([],y._camera.position,q.dir,G);try{y._updateStateFromCamera()}catch{return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++Z<10);return{center:y.center,zoom:y.zoom,bearing:y.bearing,pitch:y.pitch}}fitBounds(i,o,h){return this._fitInternal(this.cameraForBounds(i,o),o,h)}_raycastElevationBox(i,o){let h=this.transform.elevation;if(!h)return;let d=new a.pointGeometry(i.x,o.y),f=new a.pointGeometry(o.x,i.y),_=h.pointCoordinate(i);if(!_)return;let y=h.pointCoordinate(o);if(!y)return;let w=h.pointCoordinate(d);if(!w)return;let T=h.pointCoordinate(f);if(!T)return;let E=new a.MercatorCoordinate(_[0],_[1]).toLngLat(),M=new a.MercatorCoordinate(y[0],y[1]).toLngLat(),z=new a.MercatorCoordinate(w[0],w[1]).toLngLat(),B=new a.MercatorCoordinate(T[0],T[1]).toLngLat(),P=Math.min(E.lng,Math.min(M.lng,Math.min(z.lng,B.lng))),R=Math.min(E.lat,Math.min(M.lat,Math.min(z.lat,B.lat))),q=Math.max(E.lng,Math.max(M.lng,Math.max(z.lng,B.lng))),L=Math.max(E.lat,Math.max(M.lat,Math.max(z.lat,B.lat))),G=Math.min(_[3],Math.min(y[3],Math.min(w[3],T[3]))),Z=Math.max(_[3],Math.max(y[3],Math.max(w[3],T[3])));return{minLngLat:new a.LngLat(P,R),maxLngLat:new a.LngLat(q,L),minAltitude:G,maxAltitude:Z}}fitScreenCoordinates(i,o,h,d,f){let _,y,w,T,E=a.pointGeometry.convert(i),M=a.pointGeometry.convert(o),z=this._raycastElevationBox(E,M);if(z)_=z.minLngLat,y=z.maxLngLat,w=z.minAltitude,T=z.maxAltitude;else{if(this.transform.anyCornerOffEdge(E,M))return this;_=this.transform.pointLocation(E),y=this.transform.pointLocation(M)}return this._fitInternal(this.transform.pitch===0?this._cameraForBoxAndBearing(this.transform.pointLocation(a.pointGeometry.convert(i)),this.transform.pointLocation(a.pointGeometry.convert(o)),h,d):this._cameraForBox(_,y,w,T,d),d,f)}_fitInternal(i,o,h){return i?(delete(o=a.extend(i,o)).padding,o.linear?this.easeTo(o,h):this.flyTo(o,h)):this}jumpTo(i,o){this.stop();let h=i.preloadOnly?this.transform.clone():this.transform,d=!1,f=!1,_=!1;return"zoom"in i&&h.zoom!==+i.zoom&&(d=!0,h.zoom=+i.zoom),i.center!==void 0&&(h.center=a.LngLat.convert(i.center)),"bearing"in i&&h.bearing!==+i.bearing&&(f=!0,h.bearing=+i.bearing),"pitch"in i&&h.pitch!==+i.pitch&&(_=!0,h.pitch=+i.pitch),i.padding==null||h.isPaddingEqual(i.padding)||(h.padding=i.padding),i.preloadOnly?(this._preloadTiles(h),this):(this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),d&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),f&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),_&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.warnOnce(Fa),this.transform.getFreeCameraOptions()}setFreeCameraOptions(i,o){let h=this.transform;if(!h.projection.supportsFreeCamera)return void a.warnOnce(Fa);this.stop();let d=h.zoom,f=h.pitch,_=h.bearing;h.setFreeCameraOptions(i);let y=d!==h.zoom,w=f!==h.pitch,T=_!==h.bearing;return this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),y&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),T&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),w&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)),this}easeTo(i,o){this._stop(!1,i.easeId),((i=a.extend({offset:[0,0],duration:500,easing:a.ease},i)).animate===!1||!i.essential&&a.exported.prefersReducedMotion)&&(i.duration=0);let h=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),y=this.getPadding(),w="zoom"in i?+i.zoom:d,T="bearing"in i?this._normalizeBearing(i.bearing,f):f,E="pitch"in i?+i.pitch:_,M="padding"in i?i.padding:h.padding,z=a.pointGeometry.convert(i.offset),B=h.centerPoint.add(z),P=h.projection.name==="globe"?h.pointCoordinate(B).toLngLat():h.pointLocation(B),R=a.LngLat.convert(i.center||P);this._normalizeCenter(R);let q=h.project(P),L=h.project(R).sub(q),G=h.zoomScale(w-d),Z,N;i.around&&(Z=a.LngLat.convert(i.around),N=h.locationPoint(Z));let j=this._zooming||w!==d,X=this._rotating||f!==T,ie=this._pitching||E!==_,oe=!h.isPaddingEqual(M),Ee=ge=>ae=>{if(j&&(ge.zoom=a.number(d,w,ae)),X&&(ge.bearing=a.number(f,T,ae)),ie&&(ge.pitch=a.number(_,E,ae)),oe&&(ge.interpolatePadding(y,M,ae),B=ge.centerPoint.add(z)),Z)ge.setLocationAtPoint(Z,N);else{let ne=ge.zoomScale(ge.zoom-d),_e=w>d?Math.min(2,G):Math.max(.5,G),de=Math.pow(_e,1-ae),Be=ge.unproject(q.add(L.mult(ae*de)).mult(ne));ge.setLocationAtPoint(ge.renderWorldCopies?Be.wrap():Be,B)}return i.preloadOnly||this._fireMoveEvents(o),ge};if(i.preloadOnly){let ge=this._emulate(Ee,i.duration,h);return this._preloadTiles(ge),this}let xe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=j,this._rotating=X,this._pitching=ie,this._padding=oe,this._easeId=i.easeId,this._prepareEase(o,i.noMoveStart,xe),this._ease(Ee(h),ge=>{h.recenterOnTerrain(),this._afterEase(o,ge)},i),this}_prepareEase(i,o,h={}){this._moving=!0,this.transform.cameraElevationReference="sea",o||h.moving||this.fire(new a.Event("movestart",i)),this._zooming&&!h.zooming&&this.fire(new a.Event("zoomstart",i)),this._rotating&&!h.rotating&&this.fire(new a.Event("rotatestart",i)),this._pitching&&!h.pitching&&this.fire(new a.Event("pitchstart",i))}_fireMoveEvents(i){this.fire(new a.Event("move",i)),this._zooming&&this.fire(new a.Event("zoom",i)),this._rotating&&this.fire(new a.Event("rotate",i)),this._pitching&&this.fire(new a.Event("pitch",i))}_afterEase(i,o){if(this._easeId&&o&&this._easeId===o)return;delete this._easeId,this.transform.cameraElevationReference="ground";let h=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,h&&this.fire(new a.Event("zoomend",i)),d&&this.fire(new a.Event("rotateend",i)),f&&this.fire(new a.Event("pitchend",i)),this.fire(new a.Event("moveend",i))}flyTo(i,o){if(!i.essential&&a.exported.prefersReducedMotion){let Te=a.pick(i,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Te,o)}this.stop(),i=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},i);let h=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),y=this.getPadding(),w="zoom"in i?a.clamp(+i.zoom,h.minZoom,h.maxZoom):d,T="bearing"in i?this._normalizeBearing(i.bearing,f):f,E="pitch"in i?+i.pitch:_,M="padding"in i?i.padding:h.padding,z=h.zoomScale(w-d),B=a.pointGeometry.convert(i.offset),P=h.centerPoint.add(B),R=h.pointLocation(P),q=a.LngLat.convert(i.center||R);this._normalizeCenter(q);let L=h.project(R),G=h.project(q).sub(L),Z=i.curve,N=Math.max(h.width,h.height),j=N/z,X=G.mag();if("minZoom"in i){let Te=a.clamp(Math.min(i.minZoom,d,w),h.minZoom,h.maxZoom),Re=N/h.zoomScale(Te-d);Z=Math.sqrt(Re/X*2)}let ie=Z*Z;function oe(Te){let Re=(j*j-N*N+(Te?-1:1)*ie*ie*X*X)/(2*(Te?j:N)*ie*X);return Math.log(Math.sqrt(Re*Re+1)-Re)}function Ee(Te){return(Math.exp(Te)-Math.exp(-Te))/2}function xe(Te){return(Math.exp(Te)+Math.exp(-Te))/2}let ge=oe(0),ae=function(Te){return xe(ge)/xe(ge+Z*Te)},ne=function(Te){return N*((xe(ge)*(Ee(Re=ge+Z*Te)/xe(Re))-Ee(ge))/ie)/X;var Re},_e=(oe(1)-ge)/Z;if(Math.abs(X)<1e-6||!isFinite(_e)){if(Math.abs(N-j)<1e-6)return this.easeTo(i,o);let Te=j<N?-1:1;_e=Math.abs(Math.log(j/N))/Z,ne=function(){return 0},ae=function(Re){return Math.exp(Te*Z*Re)}}i.duration="duration"in i?+i.duration:1e3*_e/("screenSpeed"in i?+i.screenSpeed/Z:+i.speed),i.maxDuration&&i.duration>i.maxDuration&&(i.duration=0);let de=f!==T,Be=E!==_,Ve=!h.isPaddingEqual(M),Xe=Te=>Re=>{let Ge=Re*_e,ft=1/ae(Ge);Te.zoom=Re===1?w:d+Te.scaleZoom(ft),de&&(Te.bearing=a.number(f,T,Re)),Be&&(Te.pitch=a.number(_,E,Re)),Ve&&(Te.interpolatePadding(y,M,Re),P=Te.centerPoint.add(B));let xt=Re===1?q:Te.unproject(L.add(G.mult(ne(Ge))).mult(ft));return Te.setLocationAtPoint(Te.renderWorldCopies?xt.wrap():xt,P),Te._updateCenterElevation(),i.preloadOnly||this._fireMoveEvents(o),Te};if(i.preloadOnly){let Te=this._emulate(Xe,i.duration,h);return this._preloadTiles(Te),this}return this._zooming=!0,this._rotating=de,this._pitching=Be,this._padding=Ve,this._prepareEase(o,!1),this._ease(Xe(h),()=>this._afterEase(o),i),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(i,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let h=this._onEaseEnd;delete this._onEaseEnd,h.call(this,o)}if(!i){let h=this.handlers;h&&h.stop(!1)}return this}_ease(i,o,h){h.animate===!1||h.duration===0?(i(1),o()):(this._easeStart=a.exported.now(),this._easeOptions=h,this._onEaseFrame=i,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let i=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(i)),i<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(i,o){i=a.wrap(i,-180,180);let h=Math.abs(i-o);return Math.abs(i-360-o)<h&&(i-=360),Math.abs(i+360-o)<h&&(i+=360),i}_normalizeCenter(i){let o=this.transform;if(!o.renderWorldCopies||o.maxBounds)return;let h=i.lng-o.center.lng;i.lng+=h>180?-360:h<-180?360:0}_emulate(i,o,h){let d=Math.ceil(15*o/1e3),f=[],_=i(h.clone());for(let y=0;y<=d;y++){let w=_(y/d);f.push(w.clone())}return f}}class Oa{constructor(i={}){this.options=i,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(i){let o=this.options&&this.options.compact;return this._map=i,this._container=me.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=me.create("button","mapboxgl-ctrl-attrib-button",this._container),me.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=me.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),o&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(i,o){let h=this._map._getUIString(`AttributionControl.${o}`);i.setAttribute("aria-label",h),i.removeAttribute("title"),i.firstElementChild&&i.firstElementChild.setAttribute("title",h)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let i=this._editLink;i||(i=this._editLink=this._container.querySelector(".mapbox-improve-map"));let o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN}];if(i){let h=o.reduce((d,f,_)=>(f.value&&(d+=`${f.key}=${f.value}${_<o.length-1?"&":""}`),d),"?");i.href=`${a.config.FEEDBACK_URL}/${h}${this._map._hash?this._map._hash.getHashString(!0):""}`,i.rel="noopener nofollow",this._setElementTitle(i,"MapFeedback")}}_updateData(i){!i||i.sourceDataType!=="metadata"&&i.sourceDataType!=="visibility"&&i.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let i=[];if(this._map.style.stylesheet){let d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}let o=this._map.style._sourceCaches;for(let d in o){let f=o[d];if(f.used){let _=f.getSource();_.attribution&&i.indexOf(_.attribution)<0&&i.push(_.attribution)}}i.sort((d,f)=>d.length-f.length),i=i.filter((d,f)=>{for(let _=f+1;_<i.length;_++)if(i[_].indexOf(d)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=[...this.options.customAttribution,...i]:i.unshift(this.options.customAttribution));let h=i.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,i.length?(this._innerContainer.innerHTML=h,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Ua{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(i){this._map=i,this._container=me.create("div","mapboxgl-ctrl");let o=me.create("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(i){i&&i.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;let i=this._map.style._sourceCaches;if(Object.entries(i).length===0)return!0;for(let o in i){let h=i[o].getSource();if(h.hasOwnProperty("mapbox_logo")&&!h.mapbox_logo)return!1}return!0}_updateCompact(){let i=this._container.children;if(i.length){let o=i[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class Va{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){let o=++this._id;return this._queue.push({callback:i,id:o,cancelled:!1}),o}remove(i){let o=this._currentlyRunning,h=o?this._queue.concat(o):this._queue;for(let d of h)if(d.id===i)return void(d.cancelled=!0)}run(i=0){let o=this._currentlyRunning=this._queue;this._queue=[];for(let h of o)if(!h.cancelled&&(h.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Na(c,i,o){if(c=new a.LngLat(c.lng,c.lat),i){let h=new a.LngLat(c.lng-360,c.lat),d=new a.LngLat(c.lng+360,c.lat),f=360*Math.ceil(Math.abs(c.lng-o.center.lng)/360),_=o.locationPoint(c).distSqr(i),y=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint(h).distSqr(i)<_&&(y||Math.abs(h.lng-o.center.lng)<f)?c=h:o.locationPoint(d).distSqr(i)<_&&(y||Math.abs(d.lng-o.center.lng)<f)&&(c=d)}for(;Math.abs(c.lng-o.center.lng)>180;){let h=o.locationPoint(c);if(h.x>=0&&h.y>=0&&h.x<=o.width&&h.y<=o.height)break;c.lng>o.center.lng?c.lng-=360:c.lng+=360}return c}let Ht={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%)"};class ja extends a.Evented{constructor(i,o){if(super(),(i instanceof a.window.HTMLElement||o)&&(i=a.extend({element:i},o)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=i&&i.anchor||"center",this._color=i&&i.color||"#3FB1CE",this._scale=i&&i.scale||1,this._draggable=i&&i.draggable||!1,this._clickTolerance=i&&i.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=i&&i.rotation||0,this._rotationAlignment=i&&i.rotationAlignment||"auto",this._pitchAlignment=i&&i.pitchAlignment&&i.pitchAlignment!=="auto"?i.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),i&&i.element)this._element=i.element,this._offset=a.pointGeometry.convert(i&&i.offset||[0,0]);else{this._defaultMarker=!0,this._element=me.create("div");let d=41,f=27,_=me.createSVG("svg",{display:"block",height:d*this._scale+"px",width:f*this._scale+"px",viewBox:`0 0 ${f} ${d}`},this._element),y=me.createSVG("radialGradient",{id:"shadowGradient"},me.createSVG("defs",{},_));me.createSVG("stop",{offset:"10%","stop-opacity":.4},y),me.createSVG("stop",{offset:"100%","stop-opacity":.05},y),me.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},_),me.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},_),me.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},_),me.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},_),this._offset=a.pointGeometry.convert(i&&i.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",d=>{d.preventDefault()}),this._element.addEventListener("mousedown",d=>{d.preventDefault()});let h=this._element.classList;for(let d in Ht)h.remove(`mapboxgl-marker-anchor-${d}`);h.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(i){return i===this._map||(this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._updateMoving),i.on("moveend",this._update),i.on("remove",this._clearFadeTimer),i._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),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),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(i){return this._lngLat=a.LngLat.convert(i),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(i){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),i){if(!("offset"in i.options)){let d=Math.sqrt(Math.pow(13.5,2)/2);i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=i,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(i){let o=i.code,h=i.charCode||i.keyCode;o!=="Space"&&o!=="Enter"&&h!==32&&h!==13||this.togglePopup()}_onMapClick(i){let o=i.originalEvent.target,h=this._element;this._popup&&(o===h||h.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let i=this._popup;return i?(i.isOpen()?(i.remove(),this._element.setAttribute("aria-expanded","false")):(i.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){let i=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(i))return void this._clearFadeTimer();let o=this._map.unproject(i),h=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){let f=this._map.getFreeCameraOptions();if(f.position){let _=f.position.toLngLat();h=_.distanceTo(o)<.9*_.distanceTo(this._lngLat)}}let d=(1-this._map._queryFogOpacity(o))*(h?.2:1);this._element.style.opacity=`${d}`,this._popup&&this._popup._setOpacity(`${d}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(i){let o=this._map.transform;return!!i&&i.x>=0&&i.x<o.width&&i.y>=0&&i.y<o.height}_updateDOM(){let i=this._pos||new a.pointGeometry(0,0),o=this._calculatePitch(),h=this._calculateRotation();this._element.style.transform=`${Ht[this._anchor]} translate(${i.x}px, ${i.y}px) rotateX(${o}deg) rotateZ(${h}deg)`}_calculatePitch(){return this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?0:this._pitchAlignment==="map"?this._map.getPitch():0}_calculateRotation(){return this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?this._rotation:this._rotationAlignment==="map"?this._rotation-this._map.getBearing():0}_update(i){a.window.cancelAnimationFrame(this._updateFrameId),this._map&&(this._map.transform.renderWorldCopies&&(this._lngLat=Na(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._transformedOffset()),i===!0?this._updateFrameId=a.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!this._map.getTerrain()&&!this._map.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;let i=this._map.transform,o=this._offset.mult(this._scale);return this._rotationAlignment==="map"&&o._rotate(i.angle),this._pitchAlignment==="map"&&(o.y*=Math.cos(i._pitch)),o}getOffset(){return this._offset}setOffset(i){return this._offset=a.pointGeometry.convert(i),this._update(),this}_onMove(i){if(!this._isDragging){let o=this._clickTolerance||this._map._clickTolerance;this._isDragging=i.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=i.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.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),this._state==="active"&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(i){this._element.contains(i.originalEvent.target)&&(i.preventDefault(),this._positionDelta=i.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=i.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(i){return this._draggable=!!i,this._map&&(i?(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(i){return this._rotation=i||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i&&i!=="auto"?i:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class br{constructor(i){this.jumpTo(i)}getValue(i){if(i<=this._startTime)return this._start;if(i>=this._endTime)return this._end;let o=a.easeCubicInOut((i-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(i){return i>=this._startTime&&i<=this._endTime}jumpTo(i){this._startTime=-1/0,this._endTime=-1/0,this._start=i,this._end=i}easeTo(i,o,h){this._start=this.getValue(o),this._end=i,this._startTime=o,this._endTime=o+h}}let Wl={"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","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},{HTMLImageElement:Xi,HTMLElement:Zn,ImageBitmap:$n}=a.window,Hc={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function Ga(c){c.parentNode&&c.parentNode.removeChild(c)}let Kc={showCompass:!0,showZoom:!0,visualizePitch:!1};class Hl{constructor(i,o,h=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new Ri({clickTolerance:i.dragRotate._mouseRotate._clickTolerance}),this.map=i,h&&(this.mousePitch=new Pa({clickTolerance:i.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(i,o){this.mouseRotate.mousedown(i,o),this.mousePitch&&this.mousePitch.mousedown(i,o),me.disableDrag()}move(i,o){let h=this.map,d=this.mouseRotate.mousemoveWindow(i,o);if(d&&d.bearingDelta&&h.setBearing(h.getBearing()+d.bearingDelta),this.mousePitch){let f=this.mousePitch.mousemoveWindow(i,o);f&&f.pitchDelta&&h.setPitch(h.getPitch()+f.pitchDelta)}}off(){let i=this.element;i.removeEventListener("mousedown",this.mousedown),i.removeEventListener("touchstart",this.touchstart,{passive:!1}),i.removeEventListener("touchmove",this.touchmove),i.removeEventListener("touchend",this.touchend),i.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){me.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(i){this.down(a.extend({},i,{ctrlKey:!0,preventDefault:()=>i.preventDefault()}),me.mousePos(this.element,i)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(i){this.move(i,me.mousePos(this.element,i))}mouseup(i){this.mouseRotate.mouseupWindow(i),this.mousePitch&&this.mousePitch.mouseupWindow(i),this.offTemp()}touchstart(i){i.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=me.touchPos(this.element,i.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>i.preventDefault()},this._startPos))}touchmove(i){i.targetTouches.length!==1?this.reset():(this._lastPos=me.touchPos(this.element,i.targetTouches)[0],this.move({preventDefault:()=>i.preventDefault()},this._lastPos))}touchend(i){i.targetTouches.length===0&&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()}}let Go={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},ai,Zo=0,qn=!1,$o={maxWidth:100,unit:"metric"};function ke(c,i,o){let h=o&&o.maxWidth||100,d=c._containerHeight/2,f=c.unproject([0,d]),_=c.unproject([h,d]),y=f.distanceTo(_);if(o&&o.unit==="imperial"){let w=3.2808*y;w>5280?Xn(i,h,w/5280,c._getUIString("ScaleControl.Miles"),c):Xn(i,h,w,c._getUIString("ScaleControl.Feet"),c)}else o&&o.unit==="nautical"?Xn(i,h,y/1852,c._getUIString("ScaleControl.NauticalMiles"),c):y>=1e3?Xn(i,h,y/1e3,c._getUIString("ScaleControl.Kilometers"),c):Xn(i,h,y,c._getUIString("ScaleControl.Meters"),c)}function Xn(c,i,o,h,d){let f=function(y){let w=Math.pow(10,`${Math.floor(y)}`.length-1),T=y/w;return T=T>=10?10:T>=5?5:T>=3?3:T>=2?2:T>=1?1:function(E){let M=Math.pow(10,Math.ceil(-Math.log(E)/Math.LN10));return Math.round(E*M)/M}(T),w*T}(o),_=f/o;d._requestDomTask(()=>{c.style.width=i*_+"px",c.innerHTML=`${f} ${h}`})}let Kl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},qo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),Gr={version:a.version,supported:ji,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends Xl{constructor(c){if((c=a.extend({},Hc,c)).minZoom!=null&&c.maxZoom!=null&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(c.minPitch!=null&&c.maxPitch!=null&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(c.minPitch!=null&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(c.maxPitch!=null&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Fo(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new Va,this._domRenderTaskQueue=new Va,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},Wl,c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new br(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,typeof c.container=="string"){if(this._container=a.window.document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof Zn))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)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)),a.window!==void 0&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Gn(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new Rl(typeof c.hash=="string"&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new Oa({customAttribution:c.customAttribution})),this._logoControl=new Ua,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",i=>{this._update(i.dataType==="style"),this.fire(new a.Event(`${i.dataType}data`,i))}),this.on("dataloading",i=>{this.fire(new a.Event(`${i.dataType}dataloading`,i))})}_getMapId(){return this._mapId}addControl(c,i){if(i===void 0&&(i=c.getDefaultPosition?c.getDefaultPosition():"top-right"),!c||!c.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let o=c.onAdd(this);this._controls.push(c);let h=this._controlPositions[i];return i.indexOf("bottom")!==-1?h.insertBefore(o,h.firstChild):h.appendChild(o),this}removeControl(c){if(!c||!c.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(c);return i>-1&&this._controls.splice(i,1),c.onRemove(this),this}hasControl(c){return this._controls.indexOf(c)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(c){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));let i=!this._moving;return i&&this.fire(new a.Event("movestart",c)).fire(new a.Event("move",c)),this.fire(new a.Event("resize",c)),i&&this.fire(new a.Event("moveend",c)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(c){return this.transform.setMaxBounds(a.LngLatBounds.convert(c)),this._update()}setMinZoom(c){if((c=c==null?-2:c)>=-2&&c<=this.transform.maxZoom)return this.transform.minZoom=c,this._update(),this.getZoom()<c?this.setZoom(c):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(c){if((c=c==null?22:c)>=this.transform.minZoom)return this.transform.maxZoom=c,this._update(),this.getZoom()>c?this.setZoom(c):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(c){if((c=c==null?0:c)<0)throw new Error("minPitch must be greater than or equal to 0");if(c>=0&&c<=this.transform.maxPitch)return this.transform.minPitch=c,this._update(),this.getPitch()<c?this.setPitch(c):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(c){if((c=c==null?85:c)>85)throw new Error("maxPitch must be less than or equal to 85");if(c>=this.transform.minPitch)return this.transform.maxPitch=c,this._update(),this.getPitch()>c?this.setPitch(c):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(c){return this.transform.renderWorldCopies=c,this._update()}getProjection(){return this.transform.getProjection()}setProjection(c){return this._lazyInitEmptyStyle(),typeof c=="string"&&(c={name:c}),this._runtimeProjection=c,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(c){return this.transform.locationPoint3D(a.LngLat.convert(c))}unproject(c){return this.transform.pointLocation3D(a.pointGeometry.convert(c))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(c,i,o){if(c==="mouseenter"||c==="mouseover"){let h=!1,d=_=>{let y=i.filter(T=>this.getLayer(T)),w=y.length?this.queryRenderedFeatures(_.point,{layers:y}):[];w.length?h||(h=!0,o.call(this,new ii(c,this,_.originalEvent,{features:w}))):h=!1},f=()=>{h=!1};return{layers:new Set(i),listener:o,delegates:{mousemove:d,mouseout:f}}}if(c==="mouseleave"||c==="mouseout"){let h=!1,d=_=>{let y=i.filter(w=>this.getLayer(w));(y.length?this.queryRenderedFeatures(_.point,{layers:y}):[]).length?h=!0:h&&(h=!1,o.call(this,new ii(c,this,_.originalEvent)))},f=_=>{h&&(h=!1,o.call(this,new ii(c,this,_.originalEvent)))};return{layers:new Set(i),listener:o,delegates:{mousemove:d,mouseout:f}}}{let h=d=>{let f=i.filter(y=>this.getLayer(y)),_=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];_.length&&(d.features=_,o.call(this,d),delete d.features)};return{layers:new Set(i),listener:o,delegates:{[c]:h}}}}on(c,i,o){if(o===void 0)return super.on(c,i);Array.isArray(i)||(i=[i]);let h=this._createDelegatedListener(c,i,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[c]=this._delegatedListeners[c]||[],this._delegatedListeners[c].push(h);for(let d in h.delegates)this.on(d,h.delegates[d]);return this}once(c,i,o){if(o===void 0)return super.once(c,i);Array.isArray(i)||(i=[i]);let h=this._createDelegatedListener(c,i,o);for(let d in h.delegates)this.once(d,h.delegates[d]);return this}off(c,i,o){if(o===void 0)return super.off(c,i);i=new Set(Array.isArray(i)?i:[i]);let h=(f,_)=>{if(f.size!==_.size)return!1;for(let y of f)if(!_.has(y))return!1;return!0},d=this._delegatedListeners?this._delegatedListeners[c]:void 0;return d&&(f=>{for(let _=0;_<f.length;_++){let y=f[_];if(y.listener===o&&h(y.layers,i)){for(let w in y.delegates)this.off(w,y.delegates[w]);return f.splice(_,1),this}}})(d),this}queryRenderedFeatures(c,i){return this.style?(i!==void 0||c===void 0||c instanceof a.pointGeometry||Array.isArray(c)||(i=c,c=void 0),this.style.queryRenderedFeatures(c=c||[[0,0],[this.transform.width,this.transform.height]],i=i||{},this.transform)):[]}querySourceFeatures(c,i){return this.style.querySourceFeatures(c,i)}queryTerrainElevation(c,i){let o=this.transform.elevation;return o?(i=a.extend({},{exaggerated:!0},i),o.getAtPoint(a.MercatorCoordinate.fromLngLat(c),null,i.exaggerated)):null}setStyle(c,i){return(i=a.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i)).diff!==!1&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.localFontFamily===this._localFontFamily&&this.style&&c?(this._diffStyle(c,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(c,i))}_getUIString(c){let i=this._locale[c];if(i==null)throw new Error(`Missing UI string '${c}'`);return i}_updateStyle(c,i){return this.style&&(this.style.setEventedParent(null),this.style._remove(),delete this.style),c&&(this.style=new di(this,i||{}),this.style.setEventedParent(this,{style:this.style}),typeof c=="string"?this.style.loadURL(c):this.style.loadJSON(c)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new di(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(c,i){if(typeof c=="string"){let o=this._requestManager.normalizeStyleURL(c),h=this._requestManager.transformRequest(o,a.ResourceType.Style);a.getJSON(h,(d,f)=>{d?this.fire(new a.ErrorEvent(d)):f&&this._updateDiff(f,i)})}else typeof c=="object"&&this._updateDiff(c,i)}_updateDiff(c,i){try{this.style.setState(c)&&this._update(!0)}catch(o){a.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(c,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(c,i){return this._lazyInitEmptyStyle(),this.style.addSource(c,i),this._update(!0)}isSourceLoaded(c){let i=this.style&&this.style._getSourceCaches(c);if(i.length!==0)return i.every(o=>o.loaded());this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${c}'`)))}areTilesLoaded(){let c=this.style&&this.style._sourceCaches;for(let i in c){let o=c[i]._tiles;for(let h in o){let d=o[h];if(d.state!=="loaded"&&d.state!=="errored")return!1}}return!0}addSourceType(c,i,o){return this._lazyInitEmptyStyle(),this.style.addSourceType(c,i,o)}removeSource(c){return this.style.removeSource(c),this._updateTerrain(),this._update(!0)}getSource(c){return this.style.getSource(c)}addImage(c,i,{pixelRatio:o=1,sdf:h=!1,stretchX:d,stretchY:f,content:_}={}){if(this._lazyInitEmptyStyle(),i instanceof Xi||$n&&i instanceof $n){let{width:y,height:w,data:T}=a.exported.getImageData(i);this.style.addImage(c,{data:new a.RGBAImage({width:y,height:w},T),pixelRatio:o,stretchX:d,stretchY:f,content:_,sdf:h,version:0})}else{if(i.width===void 0||i.height===void 0)return this.fire(new a.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`")));{let{width:y,height:w,data:T}=i,E=i;this.style.addImage(c,{data:new a.RGBAImage({width:y,height:w},new Uint8Array(T)),pixelRatio:o,stretchX:d,stretchY:f,content:_,sdf:h,version:0,userImage:E}),E.onAdd&&E.onAdd(this,c)}}}updateImage(c,i){let o=this.style.getImage(c);if(!o)return this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let h=i instanceof Xi||$n&&i instanceof $n?a.exported.getImageData(i):i,{width:d,height:f,data:_}=h;return d===void 0||f===void 0?this.fire(new a.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`"))):d!==o.data.width||f!==o.data.height?this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(o.data.replace(_,!(i instanceof Xi||$n&&i instanceof $n)),void this.style.updateImage(c,o))}hasImage(c){return c?!!this.style.getImage(c):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(c){this.style.removeImage(c)}loadImage(c,i){a.getImage(this._requestManager.transformRequest(c,a.ResourceType.Image),(o,h)=>{i(o,h instanceof Xi?a.exported.getImageData(h):h)})}listImages(){return this.style.listImages()}addLayer(c,i){return this._lazyInitEmptyStyle(),this.style.addLayer(c,i),this._update(!0)}moveLayer(c,i){return this.style.moveLayer(c,i),this._update(!0)}removeLayer(c){return this.style.removeLayer(c),this._update(!0)}getLayer(c){return this.style.getLayer(c)}setLayerZoomRange(c,i,o){return this.style.setLayerZoomRange(c,i,o),this._update(!0)}setFilter(c,i,o={}){return this.style.setFilter(c,i,o),this._update(!0)}getFilter(c){return this.style.getFilter(c)}setPaintProperty(c,i,o,h={}){return this.style.setPaintProperty(c,i,o,h),this._update(!0)}getPaintProperty(c,i){return this.style.getPaintProperty(c,i)}setLayoutProperty(c,i,o,h={}){return this.style.setLayoutProperty(c,i,o,h),this._update(!0)}getLayoutProperty(c,i){return this.style.getLayoutProperty(c,i)}setLight(c,i={}){return this._lazyInitEmptyStyle(),this.style.setLight(c,i),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(c){return this._lazyInitEmptyStyle(),!c&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(c),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){this.transform.projection.name==="globe"&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(c){return this._lazyInitEmptyStyle(),this.style.setFog(c),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(c){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(c),this.transform):0}setFeatureState(c,i){return this.style.setFeatureState(c,i),this._update()}removeFeatureState(c,i){return this.style.removeFeatureState(c,i),this._update()}getFeatureState(c){return this.style.getFeatureState(c)}_updateContainerDimensions(){if(!this._container)return;let c=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300,o,h=this._container;for(;h&&!o;){let d=a.window.getComputedStyle(h).transform;d&&d!=="none"&&(o=d.match(/matrix.*\((.+)\)/)[1].split(", ")),h=h.parentElement}o?(this._containerWidth=o[0]&&o[0]!=="0"?Math.abs(c/o[0]):c,this._containerHeight=o[3]&&o[3]!=="0"?Math.abs(i/o[3]):i):(this._containerWidth=c,this._containerHeight=i)}_detectMissingCSS(){a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&a.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){let c=this._container;c.classList.add("mapboxgl-map"),(this._missingCSSCanary=me.create("div","mapboxgl-canary",c)).style.visibility="hidden",this._detectMissingCSS();let i=this._canvasContainer=me.create("div","mapboxgl-canvas-container",c);this._interactive&&i.classList.add("mapboxgl-interactive"),this._canvas=me.create("canvas","mapboxgl-canvas",i),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"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);let o=this._controlContainer=me.create("div","mapboxgl-control-container",c),h=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{h[d]=me.create("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(c,i){let o=a.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(c),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${c}px`,this._canvas.style.height=`${i}px`}_addMarker(c){this._markers.push(c)}_removeMarker(c){let i=this._markers.indexOf(c);i!==-1&&this._markers.splice(i,1)}_setupPainter(){let c=a.extend({},ji.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);i?(a.storeAuthState(i,!0),this.painter=new Pl(i,this.transform),this.on("data",o=>{o.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(i)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(c){c.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:c}))}_contextRestored(c){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:c}))}_onMapScroll(c){if(c.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(c){return this.style?(this._styleDirty=this._styleDirty||c,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(c){return this._update(),this._renderTaskQueue.add(c)}_cancelRenderFrame(c){this._renderTaskQueue.remove(c)}_requestDomTask(c){!this.loaded()||this.loaded()&&!this.isMoving()?c():this._domRenderTaskQueue.add(c)}_render(c){let i,o=this.painter.context.extTimerQuery,h=a.exported.now();this.listens("gpu-timing-frame")&&(i=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,i));let d=this._updateAverageElevation(h);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(c),this._domRenderTaskQueue.run(c),this._removed)return;this._updateProjection();let f=!1,_=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let w=this.transform.zoom,T=this.transform.pitch,E=a.exported.now();this.style.zoomHistory.update(w,E);let M=new a.EvaluationParameters(w,{now:E,fadeDuration:_,pitch:T,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),z=M.crossFadingFactor();z===1&&z===this._crossFadingFactor||(f=!0,this._crossFadingFactor=z),this.style.update(M)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,_,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:_,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||f)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){let w=a.exported.now()-h;o.endQueryEXT(o.TIME_ELAPSED_EXT,i),setTimeout(()=>{let T=o.getQueryObjectEXT(i,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(i),this.fire(new a.Event("gpu-timing-frame",{cpuTime:w,gpuTime:T}))},50)}if(this.listens("gpu-timing-layer")){let w=this.painter.collectGpuTimers();setTimeout(()=>{let T=this.painter.queryGpuTimers(w);this.fire(new a.Event("gpu-timing-layer",{layerTimes:T}))},50)}let y=this._sourcesDirty||this._styleDirty||this._placementDirty||d;if(y||this._repaint)this.triggerRepaint();else{let w=!this.isMoving()&&this.loaded();if(w&&(d=this._updateAverageElevation(h,!0)),d)this.triggerRepaint();else if(this._triggerFrame(!1),w&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let T=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:T})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(let c of this._markers)c._update()}_updateAverageElevation(c,i=!1){let o=h=>(this.transform.averageElevation=h,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);if((i||c-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(c)){let h=this.transform.averageElevation,d=this.transform.sampleAverageElevation();isNaN(d)?d=0:this._averageElevationLastSampledAt=c;let f=Math.abs(h-d);if(f>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(d),o(d);this._averageElevation.easeTo(d,c,300)}else if(f>1e-4)return this._averageElevation.jumpTo(d),o(d)}return!!this._averageElevation.isEasing(c)&&o(this._averageElevation.getValue(c))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.AUTH_ERR_MSG||c.status===401)){let i=this.painter.context.gl;a.storeAuthState(i,!1),this._logoControl instanceof Ua&&this._logoControl._updateLogo(),i&&i.clear(i.DEPTH_BUFFER_BIT|i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){let c=this.painter.canvasCopy(),i=this.painter.getCanvasCopiesAndTimestamps();i.timeStamps.push(performance.now());let o=this.painter.context.gl,h=o.createFramebuffer();function d(f){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0);let _=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,_),_}return o.bindFramebuffer(o.FRAMEBUFFER,h),this._canvasPixelComparison(d(c),i.canvasCopies.map(d),i.timeStamps)}_canvasPixelComparison(c,i,o){let h=o[1]-o[0],d=c.length/4;for(let f=0;f<i.length;f++){let _=i[f],y=0;for(let w=0;w<_.length;w+=4)_[w]===c[w]&&_[w+1]===c[w+1]&&_[w+2]===c[w+2]&&_[w+3]===c[w+3]&&(y+=1);h+=(o[f+2]-o[f+1])*(1-y/d)}return h}remove(){this._hash&&this._hash.remove();for(let i of this._controls)i.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),a.window!==void 0&&(a.window.removeEventListener("resize",this._onWindowResize,!1),a.window.removeEventListener("orientationchange",this._onWindowResize,!1),a.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),a.window.removeEventListener("online",this._onWindowOnline,!1));let c=this.painter.context.gl.getExtension("WEBGL_lose_context");c&&c.loseContext(),Ga(this._canvasContainer),Ga(this._controlContainer),Ga(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),a.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new a.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(c){this._renderNextFrame=this._renderNextFrame||c,this.style&&!this._frame&&(this._frame=a.exported.frame(i=>{let o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(i)}))}_preloadTiles(c){let i=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(i,(o,h)=>o._preloadTiles(c,h),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(c){this._trackResize&&this.resize({originalEvent:c})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(c){this._showTileBoundaries!==c&&(this._showTileBoundaries=c,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(c){this._showTerrainWireframe!==c&&(this._showTerrainWireframe=c,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(c){this._speedIndexTiming!==c&&(this._speedIndexTiming=c,this._update())}get showPadding(){return!!this._showPadding}set showPadding(c){this._showPadding!==c&&(this._showPadding=c,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(c){this._showCollisionBoxes!==c&&(this._showCollisionBoxes=c,c?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(c){this._showOverdrawInspector!==c&&(this._showOverdrawInspector=c,this._update())}get repaint(){return!!this._repaint}set repaint(c){this._repaint!==c&&(this._repaint=c,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(c){this._vertices=c,this._update()}_setCacheLimits(c,i){a.setCacheLimits(c,i)}get version(){return a.version}},NavigationControl:class{constructor(c){this.options=a.extend({},Kc,c),this._container=me.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",i=>this._map.zoomIn({},{originalEvent:i})),me.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",i=>this._map.zoomOut({},{originalEvent:i})),me.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",i=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:i}):this._map.resetNorth({},{originalEvent:i})}),this._compassIcon=me.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){let c=this._map.getZoom(),i=c===this._map.getMaxZoom(),o=c===this._map.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString())}_rotateCompassArrow(){let c=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._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=c)})}onAdd(c){return this._map=c,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 Hl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),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(c,i){let o=me.create("button",c,this._container);return o.type="button",o.addEventListener("click",i),o}_setButtonTitle(c,i){let o=this._map._getUIString(`NavigationControl.${i}`);c.setAttribute("aria-label",o),c.firstElementChild&&c.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends a.Evented{constructor(c){super(),this.options=a.extend({},Go,c),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation"],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=jr(this._updateMarkerRotation,20)}onAdd(c){var i;return this._map=c,this._container=me.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),i=this._setupUI,ai!==void 0?i(ai):a.window.navigator.permissions!==void 0?a.window.navigator.permissions.query({name:"geolocation"}).then(o=>{ai=o.state!=="denied",i(ai)}):(ai=!!a.window.navigator.geolocation,i(ai)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(a.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(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Zo=0,qn=!1}_isOutOfMapMaxBounds(c){let i=this._map.getMaxBounds(),o=c.coords;return i&&(o.longitude<i.getWest()||o.longitude>i.getEast()||o.latitude<i.getSouth()||o.latitude>i.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(c){if(this._map){if(this._isOutOfMapMaxBounds(c))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",c)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=c,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(c),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(c),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",c)),this._finish()}}_updateCamera(c){let i=new a.LngLat(c.coords.longitude,c.coords.latitude),o=c.coords.accuracy,h=this._map.getBearing(),d=a.extend({bearing:h},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),d,{geolocateSource:!0})}_updateMarker(c){if(c){let i=new a.LngLat(c.coords.longitude,c.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=c.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let c=this._map._containerHeight/2,i=this._map.unproject([0,c]),o=this._map.unproject([100,c]),h=i.distanceTo(o)/100,d=Math.ceil(2*this._accuracy/h);this._circleElement.style.width=`${d}px`,this._circleElement.style.height=`${d}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(c){if(this._map){if(this.options.trackUserLocation)if(c.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(c.code===3&&qn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",c)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(c){if(this._container.addEventListener("contextmenu",i=>i.preventDefault()),this._geolocateButton=me.create("button","mapboxgl-ctrl-geolocate",this._container),me.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",c===!1){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");let i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}else{let i=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=me.create("div","mapboxgl-user-location"),this._dotElement.appendChild(me.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(me.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new ja({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=me.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ja({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",i=>{i.geolocateSource||this._watchState!=="ACTIVE_LOCK"||i.originalEvent&&i.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(c){this._userLocationDotMarker&&(c.webkitCompassHeading?this._heading=c.webkitCompassHeading:c.absolute===!0&&(this._heading=-1*c.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Zo--,qn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new a.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let c;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Zo++,Zo>1?(c={maximumAge:6e5,timeout:0},qn=!0):(c=this.options.positionOptions,qn=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,c),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){let c=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};a.window.DeviceMotionEvent!==void 0&&typeof a.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(i=>{i==="granted"&&c()}).catch(console.error):c()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Oa,ScaleControl:class{constructor(c){this.options=a.extend({},$o,c),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){ke(this._map,this._container,this.options)}onAdd(c){return this._map=c,this._container=me.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",c.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(c){this.options.unit=c,ke(this._map,this._container,this.options)}},FullscreenControl:class{constructor(c){this._fullscreen=!1,c&&c.container&&(c.container instanceof a.window.HTMLElement?this._container=c.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=me.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){let c=this._fullscreenButton=me.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);me.create("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden",!0),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){let c=this._getTitle();this._fullscreenButton.setAttribute("aria-label",c),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",c)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(c){super(),this.options=a.extend(Object.create(Kl),c),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this),this._classList=new Set(c&&c.className?c.className.trim().split(/\s+/):[])}addTo(c){return this._map&&this.remove(),this._map=c,this.options.closeOnClick&&this._map.on("preclick",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._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),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 a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(c){return this._lngLat=a.LngLat.convert(c),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("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._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(c){return this.setDOMContent(a.window.document.createTextNode(c))}setHTML(c){let i=a.window.document.createDocumentFragment(),o=a.window.document.createElement("body"),h;for(o.innerHTML=c;h=o.firstChild,h;)i.appendChild(h);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(c){return this.options.maxWidth=c,this._update(),this}setDOMContent(c){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=me.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(c),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(c){return this._classList.add(c),this._container&&this._updateClassList(),this}removeClassName(c){return this._classList.delete(c),this._container&&this._updateClassList(),this}setOffset(c){return this.options.offset=c,this._update(),this}toggleClassName(c){let i;return this._classList.delete(c)?i=!1:(this._classList.add(c),i=!0),this._container&&this._updateClassList(),i}_createCloseButton(){this.options.closeButton&&(this._closeButton=me.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(c){this._update(c.point)}_onMouseMove(c){this._update(c.point)}_onDrag(c){this._update(c.point)}_getAnchor(c){if(this.options.anchor)return this.options.anchor;let i=this._pos,o=this._container.offsetWidth,h=this._container.offsetHeight,d;return d=i.y+c.bottom.y<h?["top"]:i.y>this._map.transform.height-h?["bottom"]:[],i.x<o/2?d.push("left"):i.x>this._map.transform.width-o/2&&d.push("right"),d.length===0?"bottom":d.join("-")}_updateClassList(){let c=[...this._classList];c.push("mapboxgl-popup"),this._anchor&&c.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&c.push("mapboxgl-popup-track-pointer"),this._container.className=c.join(" ")}_update(c){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=me.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=me.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),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=Na(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||c){let i=this._pos=this._trackPointer&&c?c:this._map.project(this._lngLat),o=function(f){if(f||(f=new a.pointGeometry(0,0)),typeof f=="number"){let _=Math.round(Math.sqrt(.5*Math.pow(f,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,f),"top-left":new a.pointGeometry(_,_),"top-right":new a.pointGeometry(-_,_),bottom:new a.pointGeometry(0,-f),"bottom-left":new a.pointGeometry(_,-_),"bottom-right":new a.pointGeometry(-_,-_),left:new a.pointGeometry(f,0),right:new a.pointGeometry(-f,0)}}if(f instanceof a.pointGeometry||Array.isArray(f)){let _=a.pointGeometry.convert(f);return{center:_,top:_,"top-left":_,"top-right":_,bottom:_,"bottom-left":_,"bottom-right":_,left:_,right:_}}return{center:a.pointGeometry.convert(f.center||[0,0]),top:a.pointGeometry.convert(f.top||[0,0]),"top-left":a.pointGeometry.convert(f["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(f["top-right"]||[0,0]),bottom:a.pointGeometry.convert(f.bottom||[0,0]),"bottom-left":a.pointGeometry.convert(f["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(f["bottom-right"]||[0,0]),left:a.pointGeometry.convert(f.left||[0,0]),right:a.pointGeometry.convert(f.right||[0,0])}}(this.options.offset),h=this._anchor=this._getAnchor(o),d=i.add(o[h]).round();this._map._requestDomTask(()=>{this._container&&h&&(this._container.style.transform=`${Ht[h]} translate(${d.x}px,${d.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let c=this._container.querySelector(qo);c&&c.focus()}_onClose(){this.remove()}_setOpacity(c){this._content&&(this._content.style.opacity=c),this._tip&&(this._tip.style.opacity=c)}},Marker:ja,Style:di,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:Ll,Evented:a.Evented,config:a.config,prewarm:function(){K().acquire(W)},clearPrewarmedResources:function(){let c=te;c&&(c.isPreloaded()&&c.numActive()===1?(c.release(W),te=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 accessToken(){return a.config.ACCESS_TOKEN},set accessToken(c){a.config.ACCESS_TOKEN=c},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(c){a.config.API_URL=c},get workerCount(){return ee.workerCount},set workerCount(c){ee.workerCount=c},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(c){a.config.MAX_PARALLEL_IMAGE_REQUESTS=c},clearStorage(c){a.clearTileCache(c)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return Gr});var yp=Bc;return yp})});export default Um();
|