@qaecy/cue-ui 0.0.21 → 0.0.23

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/247.js ADDED
@@ -0,0 +1,3 @@
1
+ (self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[247],{1247(Zy){Zy.exports=function(){"use strict";var $l,Wl,jd;function Gd(a,Pt){if($l)if(Wl){var Qr="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 = {}; ("+$l+")(sharedChunk); ("+Wl+")(sharedChunk); self.onerror = null;",zt={};$l(zt),jd=Pt(zt),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(jd.workerUrl=window.URL.createObjectURL(new Blob([Qr],{type:"text/javascript"})))}else Wl=Pt;else $l=Pt}return Gd(0,function(a){var Pt="3.3.0";let Qr;const zt={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==Qr){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Qr=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch{Qr=t}}return Qr},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!zt.API_URL)return null;try{const t=new URL(zt.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"};function qn(t){return zt.API_URL_REGEX.test(t)}function Wt(t){return 0===t.indexOf("mapbox:")}function Rr(t){return zt.API_CDN_URL_REGEX.test(t)}function _n(t){return zt.API_SPRITE_REGEX.test(t)}function gn(t){return zt.API_STYLE_REGEX.test(t)&&!_n(t)}const bo={create:"create",load:"load",fullLoad:"fullLoad"};function Ua(t){const e=t.name.split("?")[0];return Rr(e)&&e.includes("mapbox-gl.js")?"javascript":Rr(e)&&e.includes("mapbox-gl.css")?"css":zt.API_FONTS_REGEX.test(e)?"fontRange":_n(e)?"sprite":gn(e)?"style":zt.API_TILEJSON_REGEX.test(e)?"tilejson":"other"}function kr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ko=wo;function wo(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}wo.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var l=this.sampleCurveDerivativeX(i);if(Math.abs(l)<1e-6)break;i-=s/l}var u=0,p=1;for(i=t,n=0;n<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));n++)t>s?u=i:p=i,i=.5*(p-u)+u;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var $n=kr(Ko),Wn=Mn;function Mn(t,e){this.x=t,this.y=e}Mn.prototype={clone:function(){return new Mn(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),s=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(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}},Mn.convert=function(t){return t instanceof Mn?t:Array.isArray(t)?new Mn(t[0],t[1]):t};var Ue=kr(Wn);const To=Math.PI/180,Us=180/Math.PI;function qt(t){return t*To}function dr(t){return t*Us}const ja=[[0,0],[1,0],[1,1],[0,1]];function $e(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function en(t,e,i,n){const s=new $n(t,e,i,n);return function(l){return s.solve(l)}}const xr=en(.25,.1,.25,1);function Dt(t,e,i){return Math.min(i,Math.max(e,t))}function Jo(t,e,i){return(i=Dt((i-t)/(e-t),0,1))*i*(3-2*i)}function Hn(t,e,i){const n=i-e,s=((t-e)%n+n)%n+e;return s===e?i:s}function tn(t,e,i){if(!t.length)return i(null,[]);let n=t.length;const s=new Array(t.length);let l=null;t.forEach((u,p)=>{e(u,(m,_)=>{m&&(l=m),s[p]=_,0==--n&&i(l,s)})})}function pr(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}let Mo=1;function Qo(){return Mo++}function js(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function Gs(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Zs(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 Eo(t,e){t.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function En(t,e){return-1!==t.indexOf(e,t.length-e.length)}function fr(t,e,i){const n={};for(const s in t)n[s]=e.call(i||this,t[s],s,t);return n}function jr(t,e,i){const n={};for(const s in t)e.call(i||this,t[s],s,t)&&(n[s]=t[s]);return n}function Or(t){return Array.isArray(t)?t.map(Or):"object"==typeof t&&t?fr(t,Or):t}const Ga={};function ki(t){Ga[t]||(typeof console<"u"&&console.warn(t),Ga[t]=!0)}function Gr(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function So(t){let e=0;for(let i,n,s=0,l=t.length,u=l-1;s<l;u=s++)i=t[s],n=t[u],e+=(n.x-i.x)*(i.y+n.y);return e}function Sn([t,e,i]){const n=qt(e+90),s=qt(i);return{x:t*Math.cos(n)*Math.sin(s),y:t*Math.sin(n)*Math.sin(s),z:t*Math.cos(s),azimuthal:e,polar:i}}function yn(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function Ao(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,n,s,l)=>{const u=s||l;return e[n]=!u||u.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let Vi,es,ts,Zr,An,Xn,Te=null;function U(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function H(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function te(t,e,i,n){for(;e<i;){const s=e+i>>1;t[s]<n?e=s+1:i=s}return e}function ye(t,e,i,n){for(;e<i;){const s=e+i>>1;t[s]<=n?e=s+1:i=s}return e}function Ee(){return null==Vi&&(Vi=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Vi}const ze={now:()=>void 0!==Zr?Zr:performance.now(),setNow(t){Zr=t},restoreNow(){Zr=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;An||(An=document.createElement("canvas"));const s=An.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return(i>An.width||n>An.height)&&(An.width=i,An.height=n),s.clearRect(-e,-e,i+2*e,n+2*e),s.drawImage(t,0,0,i,n),s.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(es||(es=document.createElement("a")),es.href=t,es.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==ts&&(ts=window.matchMedia("(prefers-reduced-motion: reduce)")),ts.matches)},hasCanvasFingerprintNoise(){if(void 0!==Xn)return Xn;if(!Ee())return Xn=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let i=0;for(let s=0;s<t.width;++s)e.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,e.fillRect(s,0,1,1);const n=e.getImageData(0,0,t.width,t.height);i=0;for(let s=0;s<n.data.length;++s)if(s%4!=3&&i++!==n.data[s])return Xn=!0,!0;return Xn=!1,!1}},tt="mapbox-tiles";let Ye,ot,xe=500,rt=50;function Lt(){try{return caches}catch{}}function ui(){const t=Lt();t&&!Ye&&(Ye=t.open(tt))}function bi(t){const e=t.indexOf("?");if(e<0)return t;const i=["language","worldview"],n=new URLSearchParams,s=new URLSearchParams(t.slice(e));for(const l of i){const u=s.get(l);u&&n.set(l,u)}return`${t.slice(0,e)}?${n.toString()}`}function di(t,e){const i=t.indexOf("?");if(i<0)return`${t}?${new URLSearchParams(e).toString()}`;const n=new URLSearchParams(t.slice(i));for(const s in e)n.set(s,e[s]);return`${t.slice(0,i)}?${n.toString()}`}let ai=1/0;const ri={supported:!1,testSupport:function(t){!Ki&&gi&&(vi?_r(t):ci=t)}};let ci,gi,Ki=!1,vi=!1;const vr=typeof self<"u"?self:{};function _r(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,gi),t.isContextLost())return;ri.supported=!0}catch{}t.deleteTexture(e),Ki=!0}vr.document&&(gi=vr.document.createElement("img"),gi.onload=function(){ci&&_r(ci),ci=null,vi=!0},gi.onerror=function(){Ki=!0,ci=null},gi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Er={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Er);class Zi extends Error{constructor(e,i,n){401===i&&qn(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ui=yn()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,ge=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Ui())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(n,s){const l=new AbortController,u=new Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:Ui(),referrerPolicy:n.referrerPolicy,signal:l.signal});let p=!1,m=!1;const _=(y=u.url).indexOf("sku=")>0&&qn(y);var y;"json"===n.type&&u.headers.set("Accept","application/json");const v=(E,A,I)=>{if(m)return;if(E&&"SecurityError"!==E.message&&ki(E.toString()),A&&I)return w(A);const z=Date.now();fetch(u).then(L=>{if(L.ok){const N=_?L.clone():null;return w(L,N,z)}return s(new Zi(L.statusText,L.status,n.url))}).catch(L=>{"AbortError"!==L.name&&s(new Error(`${L.message} ${n.url}`))})},w=(E,A,I)=>{("arrayBuffer"===n.type?E.arrayBuffer():"json"===n.type?E.json():E.text()).then(z=>{m||(A&&I&&function(L,N,G){if(ui(),!Ye)return;const j=Ao(N.headers.get("Cache-Control")||"");if(j["no-store"])return;const X={status:N.status,statusText:N.statusText,headers:new Headers};N.headers.forEach((ie,oe)=>X.headers.set(oe,ie)),j["max-age"]&&X.headers.set("Expires",new Date(G+1e3*j["max-age"]).toUTCString());const W=X.headers.get("Expires");if(!W||new Date(W).getTime()-G<42e4)return;let J=bi(L.url);if(206===N.status){const ie=L.headers.get("Range");if(!ie)return;X.status=200,J=di(J,{range:ie})}!function(ie,oe){if(void 0===ot)try{new Response(new ReadableStream),ot=!0}catch{ot=!1}ot?oe(ie.body):ie.blob().then(oe)}(N,ie=>{const oe=new Response(ie,X);ui(),Ye&&Ye.then(he=>he.put(J,oe)).catch(he=>ki(he.message))})}(u,A,I),p=!0,s(null,z,E.headers.get("Cache-Control"),E.headers.get("Expires")))}).catch(z=>{m||s(new Error(z.message))})};return _?function(E,A){if(ui(),!Ye)return A(null);Ye.then(I=>{let z=bi(E.url);const L=E.headers.get("Range");L&&(z=di(z,{range:L})),I.match(z).then(N=>{const G=function(j){if(!j)return!1;const X=new Date(j.headers.get("Expires")||0),W=Ao(j.headers.get("Cache-Control")||"");return X>Date.now()&&!W["no-cache"]}(N);I.delete(z),G&&I.put(z,N.clone()),A(null,N,G)}).catch(A)}).catch(A)}(u,v):v(null,null),{cancel:()=>{m=!0,p||l.abort()}}}(t,e);if(yn()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(n,s){const l=new XMLHttpRequest;l.open(n.method||"GET",n.url,!0),"arrayBuffer"===n.type&&(l.responseType="arraybuffer");for(const u in n.headers)l.setRequestHeader(u,n.headers[u]);return"json"===n.type&&(l.responseType="text",l.setRequestHeader("Accept","application/json")),l.withCredentials="include"===n.credentials,l.onerror=()=>{s(new Error(l.statusText))},l.onload=()=>{if((l.status>=200&&l.status<300||0===l.status)&&null!==l.response){let u=l.response;if("json"===n.type)try{u=JSON.parse(l.response)}catch(p){return s(p)}s(null,u,l.getResponseHeader("Cache-Control"),l.getResponseHeader("Expires"))}else s(new Zi(l.statusText,l.status,n.url))},l.send(n.body),{cancel:()=>l.abort()}}(t,e)},ve=function(t,e){return ge(pr(t,{type:"arrayBuffer"}),e)};function De(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const Ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ke,Ge;ke=[],Ge=0;const Ze=function(t,e){if(ri.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Ge>=zt.MAX_PARALLEL_IMAGE_REQUESTS){const l={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return ke.push(l),l}Ge++;let i=!1;const n=()=>{if(!i)for(i=!0,Ge--;ke.length&&Ge<zt.MAX_PARALLEL_IMAGE_REQUESTS;){const l=ke.shift(),{requestParameters:u,callback:p,cancelled:m}=l;m||(l.cancel=Ze(u,p).cancel)}},s=ve(t,(l,u,p,m)=>{n(),l?e(l):u&&(self.createImageBitmap?function(_,y){const v=new Blob([new Uint8Array(_)],{type:"image/png"});createImageBitmap(v).then(w=>{y(null,w)}).catch(w=>{y(new Error(`Could not load image because of ${w.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(_,y)=>e(_,y,p,m)):function(_,y){const v=new Image;v.onload=()=>{y(null,v),URL.revokeObjectURL(v.src),v.onload=null,requestAnimationFrame(()=>{v.src=Ne})},v.onerror=()=>y(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const w=new Blob([new Uint8Array(_)],{type:"image/png"});v.src=_.byteLength?URL.createObjectURL(w):Ne}(u,(_,y)=>e(_,y,p,m)))});return{cancel:()=>{s.cancel(),n()}}},Be="01",We="NO_ACCESS_TOKEN",Ve=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function _t(t){const e=t.match(Ve);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 Vt(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const lt="mapbox.eventData";function pi(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Mi{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=pi(zt.ACCESS_TOKEN);let n="";return n=i&&i.u?btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,(s,l)=>String.fromCharCode(+("0x"+l)))):zt.ACCESS_TOKEN||"",e?`${lt}.${e}:${n}`:`${lt}:${n}`}fetchEventData(){const e=U("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const s=localStorage.getItem(i);s&&(this.eventData=JSON.parse(s));const l=localStorage.getItem(n);l&&(this.anonId=l)}catch{ki("Unable to read from LocalStorage")}}saveEventData(){const e=U("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),s=this.anonId;if(e&&s)try{localStorage.setItem(n,s),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData))}catch{ki("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,i,n,s){if(!zt.EVENTS_URL)return;const l=_t(zt.EVENTS_URL);l.params.push(`access_token=${s||zt.ACCESS_TOKEN||""}`);const u={event:this.type,created:new Date(e).toISOString()},p=i?pr(u,i):u,m={url:Vt(l),headers:{"Content-Type":"text/plain"},body:JSON.stringify([p])};var y;this.pendingRequest=(y=_=>{this.pendingRequest=null,n(_),this.saveEventData(),this.processRequests(s)},ge(pr(m,{method:"POST"}),y))}queueRequest(e,i){this.queue.push(e),this.processRequests(i)}}const Di=new class extends Mi{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){zt.EVENTS_URL&&zt.ACCESS_TOKEN&&Array.isArray(t)&&t.some(i=>Wt(i)||qn(i))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=pi(zt.ACCESS_TOKEN),i=e?e.u:zt.ACCESS_TOKEN;let n=i!==this.eventData.tokenU;Zs(this.anonId)||(this.anonId=js(),n=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const 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;n?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Pt,skuId:Be,"enabled.telemetry":!1,userId:this.anonId},l=>{l||(this.eventData.lastSuccess=s,this.eventData.tokenU=i)},t):this.processRequests()}},qi=Di.postTurnstileEvent.bind(Di),sr=new class extends Mi{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,n){this.skuToken=e,this.errorCb=n,zt.EVENTS_URL&&(i||zt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(We)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Zs(this.anonId)||(this.anonId=js()),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Pt,skuId:Be,skuToken:this.skuToken,userId:this.anonId},n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t))}remove(){this.errorCb=null}},ti=sr.postMapLoadEvent.bind(sr),Br=new class extends Mi{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){zt.EVENTS_URL&&(t||zt.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,performanceData:i}=this.queue.shift(),n=function(s){const l=performance.getEntriesByType("resource"),u=performance.getEntriesByType("mark"),p=function(E){const A={};if(E)for(const I in E)if("other"!==I)for(const z of E[I]){const L=`${I}ResolveRangeMin`,N=`${I}ResolveRangeMax`,G=`${I}RequestCount`,j=`${I}RequestCachedCount`;A[L]=Math.min(A[L]||1/0,z.startTime),A[N]=Math.max(A[N]||-1/0,z.responseEnd);const X=W=>{void 0===A[W]&&(A[W]=0),++A[W]};void 0!==z.transferSize&&0===z.transferSize&&X(j),X(G)}return A}(function(E,A){const I={};if(E)for(const z of E){const L=A(z);void 0===I[L]&&(I[L]=[]),I[L].push(z)}return I}(l,Ua)),m=window.devicePixelRatio,_=navigator.connection||navigator.mozConnection||navigator.webkitConnection,y=_?_.effectiveType:void 0,v={counters:[],metadata:[],attributes:[]},w=(E,A,I)=>{null!=I&&E.push({name:A,value:I.toString()})};for(const E in p)w(v.counters,E,p[E]);if(s.interactionRange[0]!==1/0&&s.interactionRange[1]!==-1/0&&(w(v.counters,"interactionRangeMin",s.interactionRange[0]),w(v.counters,"interactionRangeMax",s.interactionRange[1])),u)for(const E of Object.keys(bo)){const A=bo[E],I=u.find(z=>z.name===A);I&&w(v.counters,A,I.startTime)}return w(v.counters,"visibilityHidden",s.visibilityHidden),w(v.attributes,"style",function(E){if(E)for(const A of E){const I=A.name.split("?")[0];if(gn(I)){const z=I.split("/").slice(-2);if(2===z.length)return`mapbox://styles/${z[0]}/${z[1]}`}}}(l)),w(v.attributes,"terrainEnabled",s.terrainEnabled?"true":"false"),w(v.attributes,"fogEnabled",s.fogEnabled?"true":"false"),w(v.attributes,"projection",s.projection),w(v.attributes,"zoom",s.zoom),w(v.metadata,"devicePixelRatio",m),w(v.metadata,"connectionEffectiveType",y),w(v.metadata,"navigatorUserAgent",navigator.userAgent),w(v.metadata,"screenWidth",window.screen.width),w(v.metadata,"screenHeight",window.screen.height),w(v.metadata,"windowWidth",window.innerWidth),w(v.metadata,"windowHeight",window.innerHeight),w(v.metadata,"mapWidth",s.width/m),w(v.metadata,"mapHeight",s.height/m),w(v.metadata,"webglRenderer",s.renderer),w(v.metadata,"webglVendor",s.vendor),w(v.metadata,"sdkVersion",Pt),w(v.metadata,"sdkIdentifier","mapbox-gl-js"),v}(i);for(const s of n.metadata);for(const s of n.counters);for(const s of n.attributes);this.postEvent(e,n,()=>{},t)}},rn=Br.postPerformanceEvent.bind(Br),ar=new class extends Mi{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,n){if(!zt.API_URL||!zt.SESSION_PATH)return;const s=_t(zt.API_URL+zt.SESSION_PATH);s.params.push(`sku=${e||""}`),s.params.push(`access_token=${n||zt.ACCESS_TOKEN||""}`);const l={url:Vt(s),headers:{"Content-Type":"text/plain"}};var p;this.pendingRequest=(p=u=>{this.pendingRequest=null,i(u),this.saveEventData(),this.processRequests(n)},ge(pr(l,{method:"GET"}),p))}getSessionAPI(t,e,i,n){this.skuToken=e,this.errorCb=n,zt.SESSION_PATH&&zt.API_URL&&(i||zt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(We)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t)}remove(){this.errorCb=null}},qs=ar.getSessionAPI.bind(ar),Yn=new Set;function is(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Hl(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class Io{constructor(e,i={}){pr(this,i),this.type=e}}class Xl extends Io{constructor(e,i={}){super("error",pr({error:e},i))}}class rs{on(e,i){return this._listeners=this._listeners||{},is(e,i,this._listeners),this}off(e,i){return Hl(e,i,this._listeners),Hl(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},is(e,i,this._oneTimeListeners),this):new Promise(n=>this.once(e,n))}fire(e,i){"string"==typeof e&&(e=new Io(e,i||{}));const n=e.type;if(this.listens(n)){e.target=this;const s=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const p of s)p.call(this,e);const l=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const p of l)Hl(n,p,this._oneTimeListeners),p.call(this,e);const u=this._eventedParent;u&&(pr(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),u.fire(e))}else e instanceof Xl&&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,i){return this._eventedParent=e,this._eventedParentData=i,this}}a.y=void 0;var Yh={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 Za(t){return(t=Math.round(t))<0?0:t>255?255:t}function Yl(t){return Za("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function qa(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Kl(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{a.y={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Yh)return Yh[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),s=i.indexOf(")");if(-1!==n&&s+1===i.length){var l=i.substr(0,n),u=i.substr(n+1,s-(n+1)).split(","),p=1;switch(l){case"rgba":if(4!==u.length)return null;p=qa(u.pop());case"rgb":return 3!==u.length?null:[Yl(u[0]),Yl(u[1]),Yl(u[2]),p];case"hsla":if(4!==u.length)return null;p=qa(u.pop());case"hsl":if(3!==u.length)return null;var m=(parseFloat(u[0])%360+360)%360/360,_=qa(u[1]),y=qa(u[2]),v=y<=.5?y*(_+1):y+_-y*_,w=2*y-v;return[Za(255*Kl(w,v,m+1/3)),Za(255*Kl(w,v,m)),Za(255*Kl(w,v,m-1/3)),p];default:return null}}return null}}catch{}class Sr{constructor(e,i,n,s=1){this.r=e,this.g=i,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof Sr)return e;if("string"!=typeof e)return;const i=a.y(e);return i?new Sr(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,i,n,s]=this.toArray();return`rgba(${Math.round(e)},${Math.round(i)},${Math.round(n)},${s})`}toArray(){const{r:e,g:i,b:n,a:s}=this;return 0===s?[0,0,0,0]:[255*e/s,255*i/s,255*n/s,s]}toArray01(){const{r:e,g:i,b:n,a:s}=this;return 0===s?[0,0,0,0]:[e/s,i/s,n/s,s]}toArray01Scaled(e){const{r:i,g:n,b:s,a:l}=this;return 0===l?[0,0,0]:[i/l*e,n/l*e,s/l*e]}toArray01PremultipliedAlpha(){const{r:e,g:i,b:n,a:s}=this;return[e,i,n,s]}toArray01Linear(){const{r:e,g:i,b:n,a:s}=this;return 0===s?[0,0,0,0]:[Math.pow(e/s,2.2),Math.pow(i/s,2.2),Math.pow(n/s,2.2),s]}}Sr.black=new Sr(0,0,0,1),Sr.white=new Sr(1,1,1,1),Sr.transparent=new Sr(0,0,0,0),Sr.red=new Sr(1,0,0,1),Sr.blue=new Sr(0,0,1,1);var ji=Sr;function Ut(t,e,i){return t*(1-i)+e*i}function Kh(t,e,i){return t.map((n,s)=>Ut(n,e[s],i))}var $a=Object.freeze({__proto__:null,array:Kh,color:function(t,e,i){return new ji(Ut(t.r,e.r,i),Ut(t.g,e.g,i),Ut(t.b,e.b,i),Ut(t.a,e.a,i))},number:Ut});function Jl(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}class Zd extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}var xn=Zd;class Ql{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[n,s]of i)this.bindings[n]=s}concat(e){return new Ql(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)}}var qd=Ql;const ns={kind:"null"},Xe={kind:"number"},ni={kind:"string"},oi={kind:"boolean"},qr={kind:"color"},os={kind:"object"},Ht={kind:"value"},Wa={kind:"collator"},ss={kind:"formatted"},$s={kind:"resolvedImage"};function Ar(t,e){return{kind:"array",itemType:t,N:e}}function Ni(t){if("array"===t.kind){const e=Ni(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const dt=[ns,Xe,ni,oi,qr,ss,os,Ar(Ht),$s];function Co(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Co(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const i of dt)if(!Co(i,e))return null}return`Expected ${Ni(t)} but found ${Ni(e)} instead.`}function yt(t,e){return e.some(i=>i.kind===t.kind)}function Kn(t,e){return e.some(i=>"null"===i?null===t:"array"===i?Array.isArray(t):"object"===i?t&&!Array.isArray(t)&&"object"==typeof t:i===typeof t)}class Rt{constructor(e,i,n){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class as{constructor(e,i,n,s,l){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=n,this.fontStack=s,this.textColor=l}}class lr{constructor(e){this.sections=e}static fromString(e){return new lr([new as(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length)}static factory(e){return e instanceof lr?e:lr.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){e.push(["image",i.image.namePrimary]);continue}e.push(i.text);const n={};i.fontStack&&(n["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(n["font-scale"]=i.scale),i.textColor&&(n["text-color"]=["rgba"].concat(i.textColor.toArray())),e.push(n)}return e}}class pt{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,i){return e?new pt({namePrimary:e,nameSecondary:i,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function Jh(t,e,i,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Po(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof ji||t instanceof Rt||t instanceof lr||t instanceof pt)return!0;if(Array.isArray(t)){for(const e of t)if(!Po(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Po(t[e]))return!1;return!0}return!1}function $i(t){if(null===t)return ns;if("string"==typeof t)return ni;if("boolean"==typeof t)return oi;if("number"==typeof t)return Xe;if(t instanceof ji)return qr;if(t instanceof Rt)return Wa;if(t instanceof lr)return ss;if(t instanceof pt)return $s;if(Array.isArray(t)){const e=t.length;let i;for(const n of t){const s=$i(n);if(i){if(i===s)continue;i=Ht;break}i=s}return Ar(i||Ht,e)}return os}function $r(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ji||t instanceof lr||t instanceof pt?t.toString():JSON.stringify(t)}class Jn{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(2!==e.length)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Po(e[1]))return i.error("invalid value");const n=e[1];let s=$i(n);const l=i.expectedType;return"array"!==s.kind||0!==s.N||!l||"array"!==l.kind||"number"==typeof l.N&&0!==l.N||(s=l),new Jn(s,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ji?["rgba"].concat(this.value.toArray()):this.value instanceof lr?this.value.serialize():this.value}}var In=Jn,Wi=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const ec={string:ni,number:Xe,boolean:oi,object:os};class tc{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let n,s=1;const l=e[0];if("array"===l){let p,m;if(e.length>2){const _=e[1];if("string"!=typeof _||!(_ in ec)||"object"===_)return i.error('The item type argument of "array" must be one of string, number, boolean',1);p=ec[_],s++}else p=Ht;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);m=e[2],s++}n=Ar(p,m)}else n=ec[l];const u=[];for(;s<e.length;s++){const p=i.parse(e[s],s,Ht);if(!p)return null;u.push(p)}return new tc(n,u)}evaluate(e){for(let i=0;i<this.args.length;i++){const n=this.args[i].evaluate(e);if(!Co(this.type,$i(n)))return n;if(i===this.args.length-1)throw new Wi(`Expected value to be of type ${Ni(this.type)}, but found ${Ni($i(n))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,i=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){i.push(n.kind);const s=e.N;("number"==typeof s||this.args.length>1)&&i.push(s)}}return i.concat(this.args.map(n=>n.serialize()))}}var Cn=tc;class ls{constructor(e){this.type=ss,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return i.error("First argument must be an image or text section.");const s=[];let l=!1;for(let u=1;u<=e.length-1;++u){const p=e[u];if(l&&"object"==typeof p&&!Array.isArray(p)){l=!1;let m=null;if(p["font-scale"]&&(m=i.parse(p["font-scale"],1,Xe),!m))return null;let _=null;if(p["text-font"]&&(_=i.parse(p["text-font"],1,Ar(ni)),!_))return null;let y=null;if(p["text-color"]&&(y=i.parse(p["text-color"],1,qr),!y))return null;const v=s[s.length-1];v.scale=m,v.font=_,v.textColor=y}else{const m=i.parse(e[u],1,Ht);if(!m)return null;const _=m.type.kind;if("string"!==_&&"value"!==_&&"null"!==_&&"resolvedImage"!==_)return i.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 ls(s)}evaluate(e){return new lr(this.sections.map(i=>{const n=i.content.evaluate(e);return $i(n)===$s?new as("",n,null,null,null):new as($r(n),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const i of this.sections){e.push(i.content.serialize());const n={};i.scale&&(n["font-scale"]=i.scale.serialize()),i.font&&(n["text-font"]=i.font.serialize()),i.textColor&&(n["text-color"]=i.textColor.serialize()),e.push(n)}return e}}class zo{constructor(e,i){this.type=$s,this.inputPrimary=e,this.inputSecondary=i}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");const n=i.parse(e[1],1,ni);if(!n)return i.error("No image name provided.");if(2===e.length)return new zo(n);const s=i.parse(e[2],1,ni);return s?new zo(n,s):i.error("Secondary image variant is not a string.")}evaluate(e){const i=pt.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(i.namePrimary)>-1,i.nameSecondary&&i.available&&e.availableImages&&(i.available=e.availableImages.indexOf(i.nameSecondary)>-1)),i}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function cs(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const nn={"to-boolean":oi,"to-color":qr,"to-number":Xe,"to-string":ni};class Ha{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[0],s=[];let l=ns;if("to-array"===n){if(!Array.isArray(e[1]))return null;const u=e[1].length;if(i.expectedType){if("array"!==i.expectedType.kind)return i.error(`Expected ${i.expectedType.kind} but found array.`);l=Ar(i.expectedType.itemType,u)}else{if(!(u>0&&Po(e[1][0])))return null;l=Ar($i(e[1][0]),u)}for(let p=0;p<u;p++){const m=e[1][p];let _;if("array"===cs(m))_=i.parse(m,void 0,l.itemType);else{const y=cs(m);if(y!==l.itemType.kind)return i.error(`Expected ${l.itemType.kind} but found ${y}.`);_=i.registry.literal.parse(["literal",void 0===m?null:m],i)}if(!_)return null;s.push(_)}}else{if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return i.error("Expected one argument.");l=nn[n];for(let u=1;u<e.length;u++){const p=i.parse(e[u],u,Ht);if(!p)return null;s.push(p)}}return new Ha(l,s)}evaluate(e){if("boolean"===this.type.kind)return!!this.args[0].evaluate(e);if("color"===this.type.kind){let i,n;for(const s of this.args){if(i=s.evaluate(e),n=null,i instanceof ji)return i;if("string"==typeof i){const l=e.parseColor(i);if(l)return l}else if(Array.isArray(i)&&(n=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Jh(i[0],i[1],i[2],i[3]),!n))return new ji(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new Wi(n||`Could not parse color from value '${"string"==typeof i?i:String(JSON.stringify(i))}'`)}if("number"===this.type.kind){let i=null;for(const n of this.args){if(i=n.evaluate(e),null===i)return 0;const s=Number(i);if(!isNaN(s))return s}throw new Wi(`Could not convert ${JSON.stringify(i)} to number.`)}return"formatted"===this.type.kind?lr.fromString($r(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?pt.fromString($r(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(i=>i.evaluate(e)):$r(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new ls([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new zo(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}var Pn=Ha;const Ws=["Unknown","Point","LineString","Polygon"];var Qh=class{constructor(t,e){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,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ws[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||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ji.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}};class Do{constructor(e,i,n,s,l){this.name=e,this.type=i,this._evaluate=n,this.args=s,this._overloadIndex=l}evaluate(e){if(!this._evaluate){const i=Do.definitions[this.name];this._evaluate=Array.isArray(i)?i[2]:i.overloads[this._overloadIndex][1]}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,i){const n=e[0],s=Do.definitions[n];if(!s)return i.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const l=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=[];let m=null,_=-1;for(const[y,v]of u){if(Array.isArray(y)&&y.length!==e.length-1)continue;p.push(y),_++,m=new su(i.registry,i.path,null,i.scope,void 0,i._scope,i.options);const w=[];let E=!1;for(let A=1;A<e.length;A++){const I=e[A],z=Array.isArray(y)?y[A-1]:y.type,L=m.parse(I,1+w.length,z);if(!L){E=!0;break}w.push(L)}if(!E)if(Array.isArray(y)&&y.length!==w.length)m.error(`Expected ${y.length} arguments, but found ${w.length} instead.`);else{for(let A=0;A<w.length;A++){const I=Array.isArray(y)?y[A]:y.type,z=w[A];m.concat(A+1).checkSubtype(I,z.type)}if(0===m.errors.length)return new Do(n,l,v,w,_)}}if(1===p.length)i.errors.push(...m.errors);else{const y=(p.length?p:u.map(([w])=>w)).map(eu).join(" | "),v=[];for(let w=1;w<e.length;w++){const E=i.parse(e[w],1+v.length);if(!E)return null;v.push(Ni(E.type))}i.error(`Expected arguments of type ${y}, but found (${v.join(", ")}) instead.`)}return null}static register(e,i){Do.definitions=i;for(const n in i)e[n]=Do}}function eu(t){return Array.isArray(t)?`(${t.map(Ni).join(", ")})`:`(${Ni(t.type)}...)`}var Gt=Do;class Hs{constructor(e,i,n){this.type=Wa,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(2!==e.length)return i.error("Expected one argument.");const n=e[1];if("object"!=typeof n||Array.isArray(n))return i.error("Collator options argument must be an object.");const s=i.parse(void 0!==n["case-sensitive"]&&n["case-sensitive"],1,oi);if(!s)return null;const l=i.parse(void 0!==n["diacritic-sensitive"]&&n["diacritic-sensitive"],1,oi);if(!l)return null;let u=null;return n.locale&&(u=i.parse(n.locale,1,ni),!u)?null:new Hs(s,l,u)}evaluate(e){return new Rt(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(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}var ic={exports:{}};ic.exports=function(){function t(n,s,l,u,p){for(;u>l;){if(u-l>600){var m=u-l+1,_=s-l+1,y=Math.log(m),v=.5*Math.exp(2*y/3),w=.5*Math.sqrt(y*v*(m-v)/m)*(_-m/2<0?-1:1);t(n,s,Math.max(l,Math.floor(s-_*v/m+w)),Math.min(u,Math.floor(s+(m-_)*v/m+w)),p)}var E=n[s],A=l,I=u;for(e(n,l,s),p(n[u],E)>0&&e(n,l,u);A<I;){for(e(n,A,I),A++,I--;p(n[A],E)<0;)A++;for(;p(n[I],E)>0;)I--}0===p(n[l],E)?e(n,l,I):e(n,++I,u),I<=s&&(l=I+1),s<=I&&(u=I-1)}}function e(n,s,l){var u=n[s];n[s]=n[l],n[l]=u}function i(n,s){return n<s?-1:n>s?1:0}return function(n,s,l,u,p){t(n,s,l||0,u||n.length-1,p||i)}}();var $d=kr(ic.exports);function Wd(t){let e=0;for(let i,n,s=0,l=t.length,u=l-1;s<l;u=s++)i=t[s],n=t[u],e+=(n.x-i.x)*(i.y+n.y);return e}function Qn(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 eo(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Xa(t,e,i){const n=t[0]-e[0],s=t[1]-e[1],l=t[0]-i[0],u=t[1]-i[1];return n*u-l*s==0&&n*l<=0&&s*u<=0}function hs(t,e,i=!1){let n=!1;for(let p=0,m=e.length;p<m;p++){const _=e[p];for(let y=0,v=_.length,w=v-1;y<v;w=y++){const E=_[w],A=_[y];if(Xa(t,E,A))return i;(l=E)[1]>(s=t)[1]!=(u=A)[1]>s[1]&&s[0]<(u[0]-l[0])*(s[1]-l[1])/(u[1]-l[1])+l[0]&&(n=!n)}}var s,l,u;return n}function rc(t,e,i,n){const s=n[0]-i[0],l=n[1]-i[1],u=(t[0]-i[0])*l-s*(t[1]-i[1]),p=(e[0]-i[0])*l-s*(e[1]-i[1]);return u>0&&p<0||u<0&&p>0}function zn(t,e,i,n){return(s=[n[0]-i[0],n[1]-i[1]])[0]*(l=[e[0]-t[0],e[1]-t[1]])[1]-s[1]*l[0]!=0&&!(!rc(t,e,i,n)||!rc(i,n,t,e));var s,l}const to=8192;function Xs(t,e){const i=(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(i*s*to),Math.round(n*s*to)]}function nc(t,e){for(let i=0;i<e.length;i++)if(hs(t,e[i]))return!0;return!1}function oc(t,e,i){for(const n of i)for(let s=0,l=n.length,u=l-1;s<l;u=s++)if(zn(t,e,n[u],n[s]))return!0;return!1}function Wr(t,e){for(let i=0;i<t.length;++i)if(!hs(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(oc(t[i],t[i+1],e))return!1;return!0}function tu(t,e){for(let i=0;i<e.length;i++)if(Wr(t,e[i]))return!0;return!1}function sc(t,e,i){const n=[];for(let s=0;s<t.length;s++){const l=[];for(let u=0;u<t[s].length;u++){const p=Xs(t[s][u],i);Qn(e,p),l.push(p)}n.push(l)}return n}function ac(t,e,i){const n=[];for(let s=0;s<t.length;s++){const l=sc(t[s],e,i);n.push(l)}return n}function lc(t,e,i,n){if(t[0]<i[0]||t[0]>i[2]){const s=.5*n;let l=t[0]-i[0]>s?-n:i[0]-t[0]>s?n:0;0===l&&(l=t[0]-i[2]>s?-n:i[2]-t[0]>s?n:0),t[0]+=l}Qn(e,t)}function cc(t,e,i,n){const s=Math.pow(2,n.z)*to,l=[n.x*to,n.y*to],u=[];if(!t)return u;for(const p of t)for(const m of p){const _=[m.x+l[0],m.y+l[1]];lc(_,e,i,s),u.push(_)}return u}function hc(t,e,i,n){const s=Math.pow(2,n.z)*to,l=[n.x*to,n.y*to],u=[];if(!t)return u;for(const m of t){const _=[];for(const y of m){const v=[y.x+l[0],y.y+l[1]];Qn(e,v),_.push(v)}u.push(_)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(const m of u)for(const _ of m)lc(_,e,i,s)}var p;return u}class us{constructor(e,i){this.type=oi,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Po(e[1])){const n=e[1];if("FeatureCollection"===n.type)for(let s=0;s<n.features.length;++s){const l=n.features[s].geometry.type;if("Polygon"===l||"MultiPolygon"===l)return new us(n,n.features[s].geometry)}else if("Feature"===n.type){const s=n.geometry.type;if("Polygon"===s||"MultiPolygon"===s)return new us(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new us(n,n)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(i,n){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if("Polygon"===n.type){const p=sc(n.coordinates,l,u),m=cc(i.geometry(),s,l,u);if(!eo(s,l))return!1;for(const _ of m)if(!hs(_,p))return!1}if("MultiPolygon"===n.type){const p=ac(n.coordinates,l,u),m=cc(i.geometry(),s,l,u);if(!eo(s,l))return!1;for(const _ of m)if(!nc(_,p))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(i,n){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if("Polygon"===n.type){const p=sc(n.coordinates,l,u),m=hc(i.geometry(),s,l,u);if(!eo(s,l))return!1;for(const _ of m)if(!Wr(_,p))return!1}if("MultiPolygon"===n.type){const p=ac(n.coordinates,l,u),m=hc(i.geometry(),s,l,u);if(!eo(s,l))return!1;for(const _ of m)if(!tu(_,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var Ya=us,Ys={exports:{}};Ys.exports=function(){var t={kilometers:1,miles:.621371192237334,nauticalmiles:.5399568034557235,meters:1e3,metres:1e3,yards:1093.6132983377079,feet:3280.839895013123,inches:39370.078740157485},e=1/298.257223563,i=e*(2-e),n=Math.PI/180,s=function(_,y){if(void 0===_)throw new Error("No latitude given.");if(y&&!t[y])throw new Error("Unknown unit "+y+". Use one of: "+Object.keys(t).join(", "));var v=6378.137*n*(y?t[y]:1),w=Math.cos(_*n),E=1/(1-i*(1-w*w)),A=Math.sqrt(E);this.kx=v*A*w,this.ky=v*A*E*(1-i)},l={units:{configurable:!0}};function u(_,y){return _[0]===y[0]&&_[1]===y[1]}function p(_,y,v){var w=m(y[0]-_[0]);return[_[0]+w*v,_[1]+(y[1]-_[1])*v]}function m(_){for(;_<-180;)_+=360;for(;_>180;)_-=360;return _}return s.fromTile=function(_,y,v){var w=Math.PI*(1-2*(_+.5)/Math.pow(2,y)),E=Math.atan(.5*(Math.exp(w)-Math.exp(-w)))/n;return new s(E,v)},l.units.get=function(){return t},s.prototype.distance=function(_,y){var v=m(_[0]-y[0])*this.kx,w=(_[1]-y[1])*this.ky;return Math.sqrt(v*v+w*w)},s.prototype.bearing=function(_,y){var v=m(y[0]-_[0])*this.kx;return Math.atan2(v,(y[1]-_[1])*this.ky)/n},s.prototype.destination=function(_,y,v){var w=v*n;return this.offset(_,Math.sin(w)*y,Math.cos(w)*y)},s.prototype.offset=function(_,y,v){return[_[0]+y/this.kx,_[1]+v/this.ky]},s.prototype.lineDistance=function(_){for(var y=0,v=0;v<_.length-1;v++)y+=this.distance(_[v],_[v+1]);return y},s.prototype.area=function(_){for(var y=0,v=0;v<_.length;v++)for(var w=_[v],E=0,A=w.length,I=A-1;E<A;I=E++)y+=m(w[E][0]-w[I][0])*(w[E][1]+w[I][1])*(v?-1:1);return Math.abs(y)/2*this.kx*this.ky},s.prototype.along=function(_,y){var v=0;if(y<=0)return _[0];for(var w=0;w<_.length-1;w++){var E=_[w],A=_[w+1],I=this.distance(E,A);if((v+=I)>y)return p(E,A,(y-(v-I))/I)}return _[_.length-1]},s.prototype.pointToSegmentDistance=function(_,y,v){var w=y[0],E=y[1],A=m(v[0]-w)*this.kx,I=(v[1]-E)*this.ky,z=0;return 0===A&&0===I||((z=(m(_[0]-w)*this.kx*A+(_[1]-E)*this.ky*I)/(A*A+I*I))>1?(w=v[0],E=v[1]):z>0&&(w+=A/this.kx*z,E+=I/this.ky*z)),A=m(_[0]-w)*this.kx,I=(_[1]-E)*this.ky,Math.sqrt(A*A+I*I)},s.prototype.pointOnLine=function(_,y){for(var v,w,E,A,I=1/0,z=0;z<_.length-1;z++){var L=_[z][0],N=_[z][1],G=m(_[z+1][0]-L)*this.kx,j=(_[z+1][1]-N)*this.ky,X=0;0===G&&0===j||((X=(m(y[0]-L)*this.kx*G+(y[1]-N)*this.ky*j)/(G*G+j*j))>1?(L=_[z+1][0],N=_[z+1][1]):X>0&&(L+=G/this.kx*X,N+=j/this.ky*X));var W=(G=m(y[0]-L)*this.kx)*G+(j=(y[1]-N)*this.ky)*j;W<I&&(I=W,v=L,w=N,E=z,A=X)}return{point:[v,w],index:E,t:Math.max(0,Math.min(1,A))}},s.prototype.lineSlice=function(_,y,v){var w=this.pointOnLine(v,_),E=this.pointOnLine(v,y);if(w.index>E.index||w.index===E.index&&w.t>E.t){var A=w;w=E,E=A}var I=[w.point],z=w.index+1,L=E.index;!u(v[z],I[0])&&z<=L&&I.push(v[z]);for(var N=z+1;N<=L;N++)I.push(v[N]);return u(v[L],E.point)||I.push(E.point),I},s.prototype.lineSliceAlong=function(_,y,v){for(var w=0,E=[],A=0;A<v.length-1;A++){var I=v[A],z=v[A+1],L=this.distance(I,z);if((w+=L)>_&&0===E.length&&E.push(p(I,z,(_-(w-L))/L)),w>=y)return E.push(p(I,z,(y-(w-L))/L)),E;w>_&&E.push(z)}return E},s.prototype.bufferPoint=function(_,y){var v=y/this.ky,w=y/this.kx;return[_[0]-w,_[1]-v,_[0]+w,_[1]+v]},s.prototype.bufferBBox=function(_,y){var v=y/this.ky,w=y/this.kx;return[_[0]-w,_[1]-v,_[2]+w,_[3]+v]},s.prototype.insideBBox=function(_,y){return m(_[0]-y[0])>=0&&m(_[0]-y[2])<=0&&_[1]>=y[1]&&_[1]<=y[3]},Object.defineProperties(s,l),s}();var io=kr(Ys.exports),uc={exports:{}};uc.exports=function(){var t=function(i,n){if(void 0===i&&(i=[]),void 0===n&&(n=e),this.data=i,this.length=this.data.length,this.compare=n,this.length>0)for(var s=(this.length>>1)-1;s>=0;s--)this._down(s)};function e(i,n){return i<n?-1:i>n?1:0}return t.prototype.push=function(i){this.data.push(i),this.length++,this._up(this.length-1)},t.prototype.pop=function(){if(0!==this.length){var i=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),i}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(i){for(var n=this.data,s=this.compare,l=n[i];i>0;){var u=i-1>>1,p=n[u];if(s(l,p)>=0)break;n[i]=p,i=u}n[i]=l},t.prototype._down=function(i){for(var n=this.data,s=this.compare,l=this.length>>1,u=n[i];i<l;){var p=1+(i<<1),m=n[p],_=p+1;if(_<this.length&&s(n[_],m)<0&&(p=_,m=n[_]),s(m,u)>=0)break;n[i]=m,i=p}n[i]=u},t}();var Hr=kr(uc.exports),qe=8192;function Ka(t,e){return e.dist-t.dist}function pc(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function ro(t){return t[1]-t[0]+1}function on(t,e){const i=t[1]>=t[0]&&t[1]<e;return i||console.warn("Distance Expression: Index is out of range"),i}function fc(t,e){if(t[0]>t[1])return[null,null];const i=ro(t);if(e){if(2===i)return[t,null];const n=Math.floor(i/2);return[[t[0],t[0]+n],[t[0]+n,t[1]]]}{if(1===i)return[t,null];const n=Math.floor(i/2)-1;return[[t[0],t[0]+n],[t[0]+n+1,t[1]]]}}function Lo(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!on(e,t.length))return i;for(let n=e[0];n<=e[1];++n)Qn(i,t[n]);return i}function Ja(t){const e=[1/0,1/0,-1/0,-1/0];for(let i=0;i<t.length;++i)for(let n=0;n<t[i].length;++n)Qn(e,t[i][n]);return e}function Ro(t,e,i){if(pc(t)||pc(e))return NaN;let n=0,s=0;return t[2]<e[0]&&(n=e[0]-t[2]),t[0]>e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(s=t[1]-e[3]),t[3]<e[1]&&(s=e[1]-t[3]),i.distance([0,0],[n,s])}function mc(t){return 360*t-180}function Hd(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function ds(t,e){const i=Math.pow(2,e.z),n=(t.y/qe+e.y)/i;return[mc((t.x/qe+e.x)/i),Hd(n)]}function Xd(t,e){const i=[];for(let n=0;n<t.length;++n)i.push(ds(t[n],e));return i}function iu(t,e,i){const n=i.pointOnLine(e,t).point;return i.distance(t,n)}function ru(t,e,i,n,s){const l=i.slice(n[0],n[1]+1);let u=1/0;for(let p=e[0];p<=e[1];++p)if(0===(u=Math.min(u,iu(t[p],l,s))))return 0;return u}function _c(t,e,i,n,s){const l=Math.min(s.pointToSegmentDistance(t,i,n),s.pointToSegmentDistance(e,i,n)),u=Math.min(s.pointToSegmentDistance(i,t,e),s.pointToSegmentDistance(n,t,e));return Math.min(l,u)}function Yd(t,e,i,n,s){if(!on(e,t.length)||!on(n,i.length))return NaN;let l=1/0;for(let u=e[0];u<e[1];++u)for(let p=n[0];p<n[1];++p){if(zn(t[u],t[u+1],i[p],i[p+1]))return 0;l=Math.min(l,_c(t[u],t[u+1],i[p],i[p+1],s))}return l}function Kd(t,e,i,n,s){if(!on(e,t.length)||!on(n,i.length))return NaN;let l=1/0;for(let u=e[0];u<=e[1];++u)for(let p=n[0];p<=n[1];++p)if(0===(l=Math.min(l,s.distance(t[u],i[p]))))return l;return l}function Jd(t,e,i){if(hs(t,e,!0))return 0;let n=1/0;for(const s of e){const l=s.length;if(l<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(s[0]!==s[l-1]&&0===(n=Math.min(n,i.pointToSegmentDistance(t,s[l-1],s[0])))||0===(n=Math.min(n,iu(t,s,i))))return n}return n}function nu(t,e,i,n){if(!on(e,t.length))return NaN;for(let l=e[0];l<=e[1];++l)if(hs(t[l],i,!0))return 0;let s=1/0;for(let l=e[0];l<e[1];++l)for(const u of i)for(let p=0,m=u.length,_=m-1;p<m;_=p++){if(zn(t[l],t[l+1],u[_],u[p]))return 0;s=Math.min(s,_c(t[l],t[l+1],u[_],u[p],n))}return s}function Js(t,e){for(const i of t)for(let n=0;n<=i.length-1;++n)if(hs(i[n],e,!0))return!0;return!1}function Qd(t,e,i,n=1/0){const s=Ja(t),l=Ja(e);if(n!==1/0&&Ro(s,l,i)>=n)return n;if(eo(s,l)){if(Js(t,e))return 0}else if(Js(e,t))return 0;let u=n;for(const p of t)for(let m=0,_=p.length,y=_-1;m<_;y=m++)for(const v of e)for(let w=0,E=v.length,A=E-1;w<E;A=w++){if(zn(p[y],p[m],v[A],v[w]))return 0;u=Math.min(u,_c(p[y],p[m],v[A],v[w],i))}return u}function Qa(t,e,i,n,s,l,u){if(null===l||null===u)return;const p=Ro(Lo(n,l),Lo(s,u),i);p<e&&t.push({dist:p,range1:l,range2:u})}function gc(t,e,i,n,s=1/0){let l=Math.min(n.distance(t[0],i[0][0]),s);if(0===l)return l;const u=new Hr([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Ka),p=e?50:100,m=Ja(i);for(;u.length;){const _=u.pop();if(_.dist>=l)continue;const y=_.range1;if(ro(y)<=p){if(!on(y,t.length))return NaN;if(e){const v=nu(t,y,i,n);if(0===(l=Math.min(l,v)))return l}else for(let v=y[0];v<=y[1];++v){const w=Jd(t[v],i,n);if(0===(l=Math.min(l,w)))return l}}else{const v=fc(y,e);if(null!==v[0]){const w=Ro(Lo(t,v[0]),m,n);w<l&&u.push({dist:w,range1:v[0],range2:[0,0]})}if(null!==v[1]){const w=Ro(Lo(t,v[1]),m,n);w<l&&u.push({dist:w,range1:v[1],range2:[0,0]})}}}return l}function ou(t,e,i,n,s,l=1/0){let u=Math.min(l,s.distance(t[0],i[0]));if(0===u)return u;const p=new Hr([{dist:0,range1:[0,t.length-1],range2:[0,i.length-1]}],Ka),m=e?50:100,_=n?50:100;for(;p.length;){const y=p.pop();if(y.dist>=u)continue;const v=y.range1,w=y.range2;if(ro(v)<=m&&ro(w)<=_){if(!on(v,t.length)||!on(w,i.length))return NaN;if(e&&n?u=Math.min(u,Yd(t,v,i,w,s)):e||n?e&&!n?u=Math.min(u,ru(i,w,t,v,s)):!e&&n&&(u=Math.min(u,ru(t,v,i,w,s))):u=Math.min(u,Kd(t,v,i,w,s)),0===u)return u}else{const E=fc(v,e),A=fc(w,n);Qa(p,u,s,t,i,E[0],A[0]),Qa(p,u,s,t,i,E[0],A[1]),Qa(p,u,s,t,i,E[1],A[0]),Qa(p,u,s,t,i,E[1],A[1])}}return u}function yc(t,e,i,n,s=1/0){let l=s;const u=Lo(t,[0,t.length-1]);for(const p of i)if(!(l!==1/0&&Ro(u,Lo(p,[0,p.length-1]),n)>=l)&&(l=Math.min(l,ou(t,e,p,!0,n,l)),0===l))return l;return l}function el(t,e,i,n,s=1/0){let l=s;const u=Lo(t,[0,t.length-1]);for(const p of i){if(l!==1/0&&Ro(u,Ja(p),n)>=l)continue;const m=gc(t,e,p,n,l);if(isNaN(m))return m;if(0===(l=Math.min(l,m)))return l}return l}function xc(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class ko{constructor(e,i){this.type=Xe,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Po(e[1])){const n=e[1];if("FeatureCollection"===n.type){for(let s=0;s<n.features.length;++s)if(xc(n.features[s].geometry.type))return new ko(n,n.features[s].geometry)}else if("Feature"===n.type){if(xc(n.geometry.type))return new ko(n,n.geometry)}else if(xc(n.type))return new ko(n,n)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const i=e.geometry(),n=e.canonicalID();if(null!=i&&null!=n){if("Point"===e.geometryType())return function(s,l,u){const p=[];for(const _ of s)for(const y of _)p.push(ds(y,l));const m=new io(p[0][1],"meters");return"Point"===u.type||"MultiPoint"===u.type||"LineString"===u.type?ou(p,!1,"Point"===u.type?[u.coordinates]:u.coordinates,"LineString"===u.type,m):"MultiLineString"===u.type?yc(p,!1,u.coordinates,m):"Polygon"===u.type||"MultiPolygon"===u.type?el(p,!1,"Polygon"===u.type?[u.coordinates]:u.coordinates,m):null}(i,n,this.geometries);if("LineString"===e.geometryType())return function(s,l,u){const p=[];for(const _ of s){const y=[];for(const v of _)y.push(ds(v,l));p.push(y)}const m=new io(p[0][0][1],"meters");if("Point"===u.type||"MultiPoint"===u.type||"LineString"===u.type)return yc("Point"===u.type?[u.coordinates]:u.coordinates,"LineString"===u.type,p,m);if("MultiLineString"===u.type){let _=1/0;for(let y=0;y<u.coordinates.length;y++){const v=yc(u.coordinates[y],!0,p,m,_);if(isNaN(v))return v;if(0===(_=Math.min(_,v)))return _}return _}if("Polygon"===u.type||"MultiPolygon"===u.type){let _=1/0;for(let y=0;y<p.length;y++){const v=el(p[y],!0,"Polygon"===u.type?[u.coordinates]:u.coordinates,m,_);if(isNaN(v))return v;if(0===(_=Math.min(_,v)))return _}return _}return null}(i,n,this.geometries);if("Polygon"===e.geometryType())return function(s,l,u){const p=[];for(const _ of function(y){const w=y.length;if(w<=1)return[y];const E=[];let A,I;for(let z=0;z<w;z++){const L=Wd(y[z]);0!==L&&(y[z].area=Math.abs(L),void 0===I&&(I=L<0),I===L<0?(A&&E.push(A),A=[y[z]]):A.push(y[z]))}return A&&E.push(A),E}(s)){const y=[];for(let v=0;v<_.length;++v)y.push(Xd(_[v],l));p.push(y)}const m=new io(p[0][0][0][1],"meters");if("Point"===u.type||"MultiPoint"===u.type||"LineString"===u.type)return el("Point"===u.type?[u.coordinates]:u.coordinates,"LineString"===u.type,p,m);if("MultiLineString"===u.type){let _=1/0;for(let y=0;y<u.coordinates.length;y++){const v=el(u.coordinates[y],!0,p,m,_);if(isNaN(v))return v;if(0===(_=Math.min(_,v)))return _}return _}return"Polygon"===u.type||"MultiPolygon"===u.type?function(_,y,v){let w=1/0;for(const E of _)for(const A of y){const I=Qd(E,A,v,w);if(isNaN(I))return I;if(0===(w=Math.min(w,I)))return w}return w}("Polygon"===u.type?[u.coordinates]:u.coordinates,p,m):null}(i,n,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}var tl=ko;function Qs(t,e){switch(t){case"string":return $r(e);case"number":return+e;case"boolean":return!!e;case"color":return ji.parse(e);case"formatted":return lr.fromString($r(e));case"resolvedImage":return pt.fromString($r(e))}return e}function vc(t,e,i,n){return void 0!==n&&(t=n*Math.round(t/n)),void 0!==e&&t<e&&(t=e),void 0!==i&&t>i&&(t=i),t}class ea{constructor(e,i,n){this.type=e,this.key=i,this.scope=n}static parse(e,i){let n=i.expectedType;if(null==n&&(n=Ht),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");const s=i.parse(e[1],1);if(!(s instanceof In))return i.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const l=i.parse(e[2],2);return l instanceof In?new ea(n,$r(s.value),$r(l.value)):i.error("Scope of 'config' expression must be a string literal.")}return new ea(n,$r(s.value))}evaluate(e){const i=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),n=e.getConfig(i);if(!n)return null;const{type:s,value:l,values:u,minValue:p,maxValue:m,stepValue:_}=n,y=n.default.evaluate(e);let v=y;if(l){const w=e.scope;e.scope=(w||"").split("\x1f").slice(1).join("\x1f"),v=l.evaluate(e),e.scope=w}return s&&(v=Qs(s,v)),void 0===v||void 0===p&&void 0===m&&void 0===_||("number"==typeof v?v=vc(v,p,m,_):Array.isArray(v)&&(v=v.map(w=>"number"==typeof w?vc(w,p,m,_):w))),void 0!==l&&void 0!==v&&u&&!u.includes(v)&&(v=y,s&&(v=Qs(s,v))),(s&&s!==this.type||void 0!==v&&$i(v)!==this.type)&&(v=Qs(this.type.kind,v)),v}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}var ps=ea;function fs(t){if(t instanceof Gt&&("get"===t.name&&1===t.args.length||"feature-state"===t.name||"has"===t.name&&1===t.args.length||"properties"===t.name||"geometry-type"===t.name||"id"===t.name||/^filter-/.test(t.name))||t instanceof Ya||t instanceof tl)return!1;let e=!0;return t.eachChild(i=>{e&&!fs(i)&&(e=!1)}),e}function ta(t){if(t instanceof Gt&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild(i=>{e&&!ta(i)&&(e=!1)}),e}function ia(t){if(t instanceof ps)return!1;let e=!0;return t.eachChild(i=>{e&&!ia(i)&&(e=!1)}),e}function cr(t,e){if(t instanceof Gt&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild(n=>{i&&!cr(n,e)&&(i=!1)}),i}class no{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(2!==e.length||"string"!=typeof e[1])return i.error("'var' expression requires exactly one string literal argument.");const n=e[1];return i.scope.has(n)?new no(n,i.scope.get(n)):i.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]}}var br=no;class bc{constructor(e,i=[],n,s=new qd,l=[],u,p){this.registry=e,this.path=i,this.key=i.map(m=>`[${m}]`).join(""),this.scope=s,this.errors=l,this.expectedType=n,this._scope=u,this.options=p}parse(e,i,n,s,l={}){return i||n?this.concat(i,n,s)._parse(e,l):this._parse(e,l)}_parse(e,i){function n(s,l,u){return"assert"===u?new Cn(l,[s]):"coerce"===u?new Pn(l,[s]):s}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const s="string"==typeof e[0]?this.registry[e[0]]:void 0;if(s){let l=s.parse(e,this);if(!l)return null;if(this.expectedType){const u=this.expectedType,p=l.type;if("string"!==u.kind&&"number"!==u.kind&&"boolean"!==u.kind&&"object"!==u.kind&&"array"!==u.kind||"value"!==p.kind)if("color"!==u.kind&&"formatted"!==u.kind&&"resolvedImage"!==u.kind||"value"!==p.kind&&"string"!==p.kind){if(this.checkSubtype(u,p))return null}else l=n(l,u,i.typeAnnotation||"coerce");else l=n(l,u,i.typeAnnotation||"assert")}if(!(l instanceof In)&&"resolvedImage"!==l.type.kind&&wc(l)){const u=new Qh(this._scope,this.options);try{l=new In(l.type,l.evaluate(u))}catch(p){return this.error(p.message),null}}return l}return Pn.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,n){const s="number"==typeof e?this.path.concat(e):this.path,l=n?this.scope.concat(n):this.scope;return new bc(this.registry,s,i||null,l,this.errors,this._scope,this.options)}error(e,...i){const n=`${this.key}${i.map(s=>`[${s}]`).join("")}`;this.errors.push(new xn(n,e))}checkSubtype(e,i){const n=Co(e,i);return n&&this.error(n),n}}var su=bc;function wc(t){if(t instanceof br)return wc(t.boundExpression);if(t instanceof Gt&&"error"===t.name||t instanceof Hs||t instanceof Ya||t instanceof tl||t instanceof ps)return!1;const e=t instanceof Pn||t instanceof Cn;let i=!0;return t.eachChild(n=>{i=e?i&&wc(n):i&&n instanceof In}),!!i&&fs(t)&&cr(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Oo(t,e){const i=t.length-1;let n,s,l=0,u=i,p=0;for(;l<=u;)if(p=Math.floor((l+u)/2),n=t[p],s=t[p+1],n<=e){if(p===i||e<s)return p;l=p+1}else{if(!(n>e))throw new Wi("Input is not a number.");u=p-1}return 0}class il{constructor(e,i,n){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[s,l]of n)this.labels.push(s),this.outputs.push(l)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const n=i.parse(e[1],1,Xe);if(!n)return null;const s=[];let l=null;i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType);for(let u=1;u<e.length;u+=2){const p=1===u?-1/0:e[u],m=e[u+1],_=u,y=u+1;if("number"!=typeof p)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',_);if(s.length&&s[s.length-1][0]>=p)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',_);const v=i.parse(m,y,l);if(!v)return null;l=l||v.type,s.push([p,v])}return new il(l,n,s)}evaluate(e){const i=this.labels,n=this.outputs;if(1===i.length)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=i[0])return n[0].evaluate(e);const l=i.length;return s>=i[l-1]?n[l-1].evaluate(e):n[Oo(i,s)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}var ra=il;const lu=4/29,ms=6/29,Tc=3*ms*ms,cu=ms*ms*ms,ep=Math.PI/180,sn=180/Math.PI;function rl(t){return t>cu?Math.pow(t,1/3):t/Tc+lu}function nl(t){return t>ms?t*t*t:Tc*(t-lu)}function ol(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function sl(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Mc(t){const e=sl(t.r),i=sl(t.g),n=sl(t.b),s=rl((.4124564*e+.3575761*i+.1804375*n)/.95047),l=rl((.2126729*e+.7151522*i+.072175*n)/1);return{l:116*l-16,a:500*(s-l),b:200*(l-rl((.0193339*e+.119192*i+.9503041*n)/1.08883)),alpha:t.a}}function Ec(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*nl(e),i=.95047*nl(i),n=1.08883*nl(n),new ji(ol(3.2404542*i-1.5371385*e-.4985314*n),ol(-.969266*i+1.8760108*e+.041556*n),ol(.0556434*i-.2040259*e+1.0572252*n),t.alpha)}function hu(t,e,i){const n=e-t;return t+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const _s={forward:Mc,reverse:Ec,interpolate:function(t,e,i){return{l:Ut(t.l,e.l,i),a:Ut(t.a,e.a,i),b:Ut(t.b,e.b,i),alpha:Ut(t.alpha,e.alpha,i)}}},gs={forward:function(t){const{l:e,a:i,b:n}=Mc(t),s=Math.atan2(n,i)*sn;return{h:s<0?s+360:s,c:Math.sqrt(i*i+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*ep,i=t.c;return Ec({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:hu(t.h,e.h,i),c:Ut(t.c,e.c,i),l:Ut(t.l,e.l,i),alpha:Ut(t.alpha,e.alpha,i)}}};var Sc=Object.freeze({__proto__:null,hcl:gs,lab:_s});class na{constructor(e,i,n,s,l){this.type=e,this.operator=i,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(const[u,p]of l)this.labels.push(u),this.outputs.push(p)}static interpolationFactor(e,i,n,s){let l=0;if("exponential"===e.name)l=ys(i,e.base,n,s);else if("linear"===e.name)l=ys(i,1,n,s);else if("cubic-bezier"===e.name){const u=e.controlPoints;l=new $n(u[0],u[1],u[2],u[3]).solve(ys(i,1,n,s))}return l}static parse(e,i){let[n,s,l,...u]=e;if(!Array.isArray(s)||0===s.length)return i.error("Expected an interpolation type expression.",1);if("linear"===s[0])s={name:"linear"};else if("exponential"===s[0]){const _=s[1];if("number"!=typeof _)return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:_}}else{if("cubic-bezier"!==s[0])return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{const _=s.slice(1);if(4!==_.length||_.some(y=>"number"!=typeof y||y<0||y>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:_}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(l=i.parse(l,2,Xe),!l)return null;const p=[];let m=null;"interpolate-hcl"===n||"interpolate-lab"===n?m=qr:i.expectedType&&"value"!==i.expectedType.kind&&(m=i.expectedType);for(let _=0;_<u.length;_+=2){const y=u[_],v=u[_+1],w=_+3,E=_+4;if("number"!=typeof y)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(p.length&&p[p.length-1][0]>=y)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',w);const A=i.parse(v,E,m);if(!A)return null;m=m||A.type,p.push([y,A])}return"number"===m.kind||"color"===m.kind||"array"===m.kind&&"number"===m.itemType.kind&&"number"==typeof m.N?new na(m,n,s,l,p):i.error(`Type ${Ni(m)} is not interpolatable.`)}evaluate(e){const i=this.labels,n=this.outputs;if(1===i.length)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=i[0])return n[0].evaluate(e);const l=i.length;if(s>=i[l-1])return n[l-1].evaluate(e);const u=Oo(i,s),p=na.interpolationFactor(this.interpolation,s,i[u],i[u+1]),m=n[u].evaluate(e),_=n[u+1].evaluate(e);return"interpolate"===this.operator?$a[this.type.kind.toLowerCase()](m,_,p):"interpolate-hcl"===this.operator?gs.reverse(gs.interpolate(gs.forward(m),gs.forward(_),p)):_s.reverse(_s.interpolate(_s.forward(m),_s.forward(_),p))}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const i=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)i.push(this.labels[n],this.outputs[n].serialize());return i}}function ys(t,e,i,n){const s=n-i,l=t-i;return 0===s?0:1===e?l/s:(Math.pow(e,l)-1)/(Math.pow(e,s)-1)}var Fr=na;class xs{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument.");let n=null;const s=i.expectedType;s&&"value"!==s.kind&&(n=s);const l=[];for(const p of e.slice(1)){const m=i.parse(p,1+l.length,n,void 0,{typeAnnotation:"omit"});if(!m)return null;n=n||m.type,l.push(m)}const u=s&&l.some(p=>Co(s,p.type));return new xs(u?Ht:n,l)}evaluate(e){let i,n=null,s=0;for(const l of this.args){if(s++,n=l.evaluate(e),n&&n instanceof pt&&!n.available&&(i||(i=n),n=null,s===this.args.length))return i;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var Ac=xs;class al{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let l=1;l<e.length-1;l+=2){const u=e[l];if("string"!=typeof u)return i.error(`Expected string, but found ${typeof u} instead.`,l);if(/[^a-zA-Z0-9_]/.test(u))return i.error("Variable names must contain only alphanumeric characters or '_'.",l);const p=i.parse(e[l+1],l+1);if(!p)return null;n.push([u,p])}const s=i.parse(e[e.length-1],e.length-1,i.expectedType,n);return s?new al(n,s):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[i,n]of this.bindings)e.push(i,n.serialize());return e.push(this.result.serialize()),e}}var Ic=al;class so{constructor(e,i,n){this.type=e,this.index=i,this.input=n}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Xe),s=i.parse(e[2],2,Ar(i.expectedType||Ht));return n&&s?new so(s.type.itemType,n,s):null}evaluate(e){const i=this.index.evaluate(e),n=this.input.evaluate(e);if(i<0)throw new Wi(`Array index out of bounds: ${i} < 0.`);if(i>=n.length)throw new Wi(`Array index out of bounds: ${i} > ${n.length-1}.`);if(i!==Math.floor(i))throw new Wi(`Array index must be an integer, but found ${i} instead.`);return n[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Xt=so;class Cc{constructor(e,i){this.type=oi,this.needle=e,this.haystack=i}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Ht),s=i.parse(e[2],2,Ht);return n&&s?yt(n.type,[oi,ni,Xe,ns,Ht])?new Cc(n,s):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ni(n.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!Kn(i,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Ni($i(i))} instead.`);if(!Kn(n,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Ni($i(n))} instead.`);return n.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var tp=Cc;class ll{constructor(e,i,n){this.type=Xe,this.needle=e,this.haystack=i,this.fromIndex=n}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Ht),s=i.parse(e[2],2,Ht);if(!n||!s)return null;if(!yt(n.type,[oi,ni,Xe,ns,Ht]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ni(n.type)} instead`);if(4===e.length){const l=i.parse(e[3],3,Xe);return l?new ll(n,s,l):null}return new ll(n,s)}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Kn(i,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Ni($i(i))} instead.`);if(!Kn(n,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Ni($i(n))} instead.`);if(this.fromIndex){const s=this.fromIndex.evaluate(e);return n.indexOf(i,s)}return n.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var uu=ll;class Pc{constructor(e,i,n,s,l,u){this.inputType=e,this.type=i,this.input=n,this.cases=s,this.outputs=l,this.otherwise=u}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let n,s;i.expectedType&&"value"!==i.expectedType.kind&&(s=i.expectedType);const l={},u=[];for(let _=2;_<e.length-1;_+=2){let y=e[_];const v=e[_+1];Array.isArray(y)||(y=[y]);const w=i.concat(_);if(0===y.length)return w.error("Expected at least one branch label.");for(const A of y){if("number"!=typeof A&&"string"!=typeof A)return w.error("Branch labels must be numbers or strings.");if("number"==typeof A&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return w.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof A&&Math.floor(A)!==A)return w.error("Numeric branch labels must be integer values.");if(n){if(w.checkSubtype(n,$i(A)))return null}else n=$i(A);if(void 0!==l[String(A)])return w.error("Branch labels must be unique.");l[String(A)]=u.length}const E=i.parse(v,_,s);if(!E)return null;s=s||E.type,u.push(E)}const p=i.parse(e[1],1,Ht);if(!p)return null;const m=i.parse(e[e.length-1],e.length-1,s);return m?"value"!==p.type.kind&&i.concat(1).checkSubtype(n,p.type)?null:new Pc(n,s,p,l,u,m):null}evaluate(e){const i=this.input.evaluate(e);return($i(i)===this.inputType&&this.outputs[this.cases[i]]||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(){const e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),n=[],s={};for(const u of i){const p=s[this.cases[u]];void 0===p?(s[this.cases[u]]=n.length,n.push([this.cases[u],[u]])):n[p][1].push(u)}const l=u=>"number"===this.inputType.kind?Number(u):u;for(const[u,p]of n)e.push(1===p.length?l(p[0]):p.map(l)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}var du=Pc;class cl{constructor(e,i,n){this.type=e,this.branches=i,this.otherwise=n}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let n;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);const s=[];for(let u=1;u<e.length-1;u+=2){const p=i.parse(e[u],u,oi);if(!p)return null;const m=i.parse(e[u+1],u+1,n);if(!m)return null;s.push([p,m]),n=n||m.type}const l=i.parse(e[e.length-1],e.length-1,n);return l?new cl(n,s,l):null}evaluate(e){for(const[i,n]of this.branches)if(i.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,n]of this.branches)e(i),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var pu=cl;class oa{constructor(e,i,n,s){this.type=e,this.input=i,this.beginIndex=n,this.endIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Ht),s=i.parse(e[2],2,Xe);if(!n||!s)return null;if(!yt(n.type,[Ar(Ht),ni,Ht]))return i.error(`Expected first argument to be of type array or string, but found ${Ni(n.type)} instead`);if(4===e.length){const l=i.parse(e[3],3,Xe);return l?new oa(n.type,n,s,l):null}return new oa(n.type,n,s)}evaluate(e){const i=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Kn(i,["string","array"]))throw new Wi(`Expected first argument to be of type array or string, but found ${Ni($i(i))} instead.`);if(this.endIndex){const s=this.endIndex.evaluate(e);return i.slice(n,s)}return i.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var vs=oa;function zc(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Dc(t,e,i,n){return 0===n.compare(e,i)}function bs(t,e,i){const n="=="!==t&&"!="!==t;return class Gy{constructor(l,u,p){this.type=oi,this.lhs=l,this.rhs=u,this.collator=p,this.hasUntypedArgument="value"===l.type.kind||"value"===u.type.kind}static parse(l,u){if(3!==l.length&&4!==l.length)return u.error("Expected two or three arguments.");const p=l[0];let m=u.parse(l[1],1,Ht);if(!m)return null;if(!zc(p,m.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${Ni(m.type)}'.`);let _=u.parse(l[2],2,Ht);if(!_)return null;if(!zc(p,_.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${Ni(_.type)}'.`);if(m.type.kind!==_.type.kind&&"value"!==m.type.kind&&"value"!==_.type.kind)return u.error(`Cannot compare types '${Ni(m.type)}' and '${Ni(_.type)}'.`);n&&("value"===m.type.kind&&"value"!==_.type.kind?m=new Cn(_.type,[m]):"value"!==m.type.kind&&"value"===_.type.kind&&(_=new Cn(m.type,[_])));let y=null;if(4===l.length){if("string"!==m.type.kind&&"string"!==_.type.kind&&"value"!==m.type.kind&&"value"!==_.type.kind)return u.error("Cannot use collator to compare non-string types.");if(y=u.parse(l[3],3,Wa),!y)return null}return new Gy(m,_,y)}evaluate(l){const u=this.lhs.evaluate(l),p=this.rhs.evaluate(l);if(n&&this.hasUntypedArgument){const m=$i(u),_=$i(p);if(m.kind!==_.kind||"string"!==m.kind&&"number"!==m.kind)throw new Wi(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${m.kind}, ${_.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const m=$i(u),_=$i(p);if("string"!==m.kind||"string"!==_.kind)return e(l,u,p)}return this.collator?i(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(){const l=[t];return this.eachChild(u=>{l.push(u.serialize())}),l}}}const Lc=bs("==",function(t,e,i){return e===i},Dc),Rc=bs("!=",function(t,e,i){return e!==i},function(t,e,i,n){return!Dc(0,e,i,n)}),ip=bs("<",function(t,e,i){return e<i},function(t,e,i,n){return n.compare(e,i)<0}),rp=bs(">",function(t,e,i){return e>i},function(t,e,i,n){return n.compare(e,i)>0}),fu=bs("<=",function(t,e,i){return e<=i},function(t,e,i,n){return n.compare(e,i)<=0}),np=bs(">=",function(t,e,i){return e>=i},function(t,e,i,n){return n.compare(e,i)>=0});class kc{constructor(e,i,n,s,l,u){this.type=ni,this.number=e,this.locale=i,this.currency=n,this.unit=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(e,i){if(3!==e.length)return i.error("Expected two arguments.");const n=i.parse(e[1],1,Xe);if(!n)return null;const s=e[2];if("object"!=typeof s||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=i.parse(s.locale,1,ni),!l))return null;let u=null;if(s.currency&&(u=i.parse(s.currency,1,ni),!u))return null;let p=null;if(s.unit&&(p=i.parse(s.unit,1,ni),!p))return null;let m=null;if(s["min-fraction-digits"]&&(m=i.parse(s["min-fraction-digits"],1,Xe),!m))return null;let _=null;return s["max-fraction-digits"]&&(_=i.parse(s["max-fraction-digits"],1,Xe),!_)?null:new kc(n,l,u,p,m,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.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.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.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 Oc{constructor(e){this.type=Xe,this.input=e}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=i.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?i.error(`Expected argument of type string or array, but found ${Ni(n.type)} instead.`):new Oc(n):null}evaluate(e){const i=this.input.evaluate(e);if("string"==typeof i||Array.isArray(i))return i.length;throw new Wi(`Expected value to be of type string or array, but found ${Ni($i(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function mu(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Bc={"==":Lc,"!=":Rc,">":rp,"<":ip,">=":np,"<=":fu,array:Cn,at:Xt,boolean:Cn,case:pu,coalesce:Ac,collator:Hs,format:ls,image:zo,in:tp,"index-of":uu,interpolate:Fr,"interpolate-hcl":Fr,"interpolate-lab":Fr,length:Oc,let:Ic,literal:In,match:du,number:Cn,"number-format":kc,object:Cn,slice:vs,step:ra,string:Cn,"to-boolean":Pn,"to-color":Pn,"to-number":Pn,"to-string":Pn,var:br,within:Ya,distance:tl,config:ps};function Fc(t,[e,i,n,s]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const l=s?s.evaluate(t):1,u=Jh(e,i,n,l);if(u)throw new Wi(u);return new ji(e/255*l,i/255*l,n/255*l,l)}function _u(t,[e,i,n,s]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const l=s?s.evaluate(t):1,u=(y=i,v=n,w=l,"number"==typeof(_=e)&&_>=0&&_<=360?"number"==typeof y&&y>=0&&y<=100&&"number"==typeof v&&v>=0&&v<=100?void 0===w||"number"==typeof w&&w>=0&&w<=1?null:`Invalid hsla value [${[_,y,v,w].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof w?[_,y,v,w]:[_,y,v]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof w?[_,y,v,w]:[_,y,v]).join(", ")}]: 'h' must be between 0 and 360.`);var _,y,v,w;if(u)throw new Wi(u);const p=`hsla(${e}, ${i}%, ${n}%, ${l})`,m=ji.parse(p);if(!m)throw new Wi(`Failed to parse HSLA color: ${p}`);return m}function Nc(t,e){return t in e}function Vc(t,e){const i=e[t];return void 0===i?null:i}function Bo(t){return{type:t}}Gt.register(Bc,{error:[{kind:"error"},[ni],(t,[e])=>{throw new Wi(e.evaluate(t))}],typeof:[ni,[Ht],(t,[e])=>Ni($i(e.evaluate(t)))],"to-rgba":[Ar(Xe,4),[qr],(t,[e])=>e.evaluate(t).toArray()],rgb:[qr,[Xe,Xe,Xe],Fc],rgba:[qr,[Xe,Xe,Xe,Xe],Fc],hsl:[qr,[Xe,Xe,Xe],_u],hsla:[qr,[Xe,Xe,Xe,Xe],_u],has:{type:oi,overloads:[[[ni],(t,[e])=>Nc(e.evaluate(t),t.properties())],[[ni,os],(t,[e,i])=>Nc(e.evaluate(t),i.evaluate(t))]]},get:{type:Ht,overloads:[[[ni],(t,[e])=>Vc(e.evaluate(t),t.properties())],[[ni,os],(t,[e,i])=>Vc(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Ht,[ni],(t,[e])=>Vc(e.evaluate(t),t.featureState||{})],properties:[os,[],t=>t.properties()],"geometry-type":[ni,[],t=>t.geometryType()],id:[Ht,[],t=>t.id()],zoom:[Xe,[],t=>t.globals.zoom],pitch:[Xe,[],t=>t.globals.pitch||0],"distance-from-center":[Xe,[],t=>t.distanceFromCenter()],"measure-light":[Xe,[ni],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Xe,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xe,[],t=>t.globals.lineProgress||0],"raster-value":[Xe,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Xe,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xe,[],t=>t.globals.skyRadialProgress||0],accumulated:[Ht,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xe,Bo(Xe),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Xe,Bo(Xe),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Xe,overloads:[[[Xe,Xe],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xe],(t,[e])=>-e.evaluate(t)]]},"/":[Xe,[Xe,Xe],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xe,[Xe,Xe],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xe,[],()=>Math.LN2],pi:[Xe,[],()=>Math.PI],e:[Xe,[],()=>Math.E],"^":[Xe,[Xe,Xe],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xe,[Xe],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xe,[Xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xe,[Xe],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xe,[Xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xe,[Xe],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xe,[Xe],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xe,[Xe],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xe,[Xe],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xe,[Xe],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xe,[Xe],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xe,Bo(Xe),(t,e)=>Math.min(...e.map(i=>i.evaluate(t)))],max:[Xe,Bo(Xe),(t,e)=>Math.max(...e.map(i=>i.evaluate(t)))],abs:[Xe,[Xe],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xe,[Xe],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Xe,[Xe],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Xe,[Xe],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[oi,[ni,Ht],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[oi,[Ht],(t,[e])=>t.id()===e.value],"filter-type-==":[oi,[ni],(t,[e])=>t.geometryType()===e.value],"filter-<":[oi,[ni,Ht],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<s}],"filter-id-<":[oi,[Ht],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<n}],"filter->":[oi,[ni,Ht],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>s}],"filter-id->":[oi,[Ht],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[oi,[ni,Ht],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[oi,[Ht],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[oi,[ni,Ht],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[oi,[Ht],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[oi,[Ht],(t,[e])=>e.value in t.properties()],"filter-has-id":[oi,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[oi,[Ar(ni)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[oi,[Ar(Ht)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[oi,[ni,Ar(Ht)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[oi,[ni,Ar(Ht)],(t,[e,i])=>function(n,s,l,u){for(;l<=u;){const 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],i.value,0,i.value.length-1)],all:{type:oi,overloads:[[[oi,oi],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Bo(oi),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:oi,overloads:[[[oi,oi],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Bo(oi),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[oi,[oi],(t,[e])=>!e.evaluate(t)],"is-supported-script":[oi,[ni],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ni,[ni],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ni,[ni],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ni,Bo(Ht),(t,e)=>e.map(i=>$r(i.evaluate(t))).join("")],"resolved-locale":[ni,[Wa],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Xe,[Xe,Xe,Ht],(t,e)=>{const[i,n,s]=e.map(u=>u.evaluate(t));if(i>n||i===n)return i;let l;if("string"==typeof s)l=function(u){let p=0;if(0===u.length)return p;for(let m=0;m<u.length;m++)p=(p<<5)-p+u.charCodeAt(m),p|=0;return p}(s);else{if("number"!=typeof s)throw new Wi(`Invalid seed input: ${s}`);l=s}return i+mu(l)()*(n-i)}]});var ws=Bc;function Uc(t){return{result:"success",value:t}}function Fo(t){return{result:"error",value:t}}function gu(t,e){return!!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function hl(t){return"data-driven"===t["property-type"]}function jc(t){return gu(t.expression,"measure-light")}function yu(t){return gu(t.expression,"zoom")}function Gc(t){return!!t.expression&&t.expression.interpolated}function ul(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function xu(t){return t}function Zc(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],s=n||!(n||void 0!==t.property),l=t.type||(Gc(e)?"exponential":"interval");if(i&&((t=Jl({},t)).stops&&(t.stops=t.stops.map(_=>[_[0],ji.parse(_[1])])),t.default=ji.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Sc[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let u,p,m;if("exponential"===l)u=vu;else if("interval"===l)u=sp;else if("categorical"===l){u=op,p=Object.create(null);for(const _ of t.stops)p[_[0]]=_[1];m=typeof t.stops[0][0]}else{if("identity"!==l)throw new Error(`Unknown function type "${l}"`);u=bu}if(n){const _={},y=[];for(let E=0;E<t.stops.length;E++){const A=t.stops[E],I=A[0].zoom;void 0===_[I]&&(_[I]={zoom:I,type:t.type,property:t.property,default:t.default,stops:[]},y.push(I)),_[I].stops.push([A[0].value,A[1]])}const v=[];for(const E of y)v.push([_[E].zoom,Zc(_[E],e)]);const w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:Fr.interpolationFactor.bind(void 0,w),zoomStops:v.map(E=>E[0]),evaluate:({zoom:E},A)=>vu({stops:v,base:t.base},e,E).evaluate(E,A)}}if(s){const _="exponential"===l?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:Fr.interpolationFactor.bind(void 0,_),zoomStops:t.stops.map(y=>y[0]),evaluate:({zoom:y})=>u(t,e,y,p,m)}}return{kind:"source",evaluate(_,y){const v=y&&y.properties?y.properties[t.property]:void 0;return void 0===v?sa(t.default,e.default):u(t,e,v,p,m)}}}function sa(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function op(t,e,i,n,s){return sa(typeof i===s?n[i]:void 0,t.default,e.default)}function sp(t,e,i){if("number"!==cs(i))return sa(t.default,e.default);const n=t.stops.length;if(1===n||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=Oo(t.stops.map(l=>l[0]),i);return t.stops[s][1]}function vu(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==cs(i))return sa(t.default,e.default);const s=t.stops.length;if(1===s||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const l=Oo(t.stops.map(y=>y[0]),i),u=function(y,v,w,E){const A=E-w,I=y-w;return 0===A?0:1===v?I/A:(Math.pow(v,I)-1)/(Math.pow(v,A)-1)}(i,n,t.stops[l][0],t.stops[l+1][0]),p=t.stops[l][1],m=t.stops[l+1][1];let _=$a[e.type]||xu;if(t.colorSpace&&"rgb"!==t.colorSpace){const y=Sc[t.colorSpace];_=(v,w)=>y.reverse(y.interpolate(y.forward(v),y.forward(w),u))}return"function"==typeof p.evaluate?{evaluate(...y){const v=p.evaluate.apply(void 0,y),w=m.evaluate.apply(void 0,y);if(void 0!==v&&void 0!==w)return _(v,w,u)}}:_(p,m,u)}function bu(t,e,i){return"color"===e.type?i=ji.parse(i):"formatted"===e.type?i=lr.fromString(i.toString()):"resolvedImage"===e.type?i=pt.fromString(i.toString()):cs(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),sa(i,t.default,e.default)}class dl{constructor(e,i,n,s){var l;this.expression=e,this._warningHistory={},this._evaluator=new Qh(n,s),this._defaultValue=i?"color"===(l=i).type&&(ul(l.default)||Array.isArray(l.default))?new ji(0,0,0,0):"color"===l.type?ji.parse(l.default)||null:void 0===l.default?null:l.default:null,this._enumValues=i&&"enum"===i.type?i.values:null}evaluateWithoutErrorHandling(e,i,n,s,l,u,p,m){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=n,this._evaluator.canonical=s||null,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,i,n,s,l,u,p,m){this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=n||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null;try{const _=this.expression.evaluate(this._evaluator);if(null==_||"number"==typeof _&&_!=_)return this._defaultValue;if(this._enumValues&&!(_ in this._enumValues))throw new Wi(`Expected value to be one of ${Object.keys(this._enumValues).map(y=>JSON.stringify(y)).join(", ")}, but found ${JSON.stringify(_)} instead.`);return _}catch(_){return this._warningHistory[_.message]||(this._warningHistory[_.message]=!0,typeof console<"u"&&console.warn(_.message)),this._defaultValue}}}function aa(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in ws}function pl(t,e,i,n){const s=new su(ws,[],e?function(u){const p={color:qr,string:ni,number:Xe,enum:ni,boolean:oi,formatted:ss,resolvedImage:$s};return"array"===u.type?Ar(p[u.value]||Ht,u.length):p[u.type]}(e):void 0,void 0,void 0,i,n),l=s.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return l?Uc(new dl(l,e,i,n)):Fo(s.errors)}class qc{constructor(e,i,n){this.kind=e,this._styleExpression=i,this.isLightConstant=n,this.isStateDependent="constant"!==e&&!ta(i.expression),this.isConfigDependent=!ia(i.expression)}evaluateWithoutErrorHandling(e,i,n,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,s,l,u)}evaluate(e,i,n,s,l,u){return this._styleExpression.evaluate(e,i,n,s,l,u)}}class la{constructor(e,i,n,s,l){this.kind=e,this.zoomStops=n,this._styleExpression=i,this.isStateDependent="camera"!==e&&!ta(i.expression),this.isLightConstant=l,this.isConfigDependent=!ia(i.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,i,n,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,s,l,u)}evaluate(e,i,n,s,l,u){return this._styleExpression.evaluate(e,i,n,s,l,u)}interpolationFactor(e,i,n){return this.interpolationType?Fr.interpolationFactor(this.interpolationType,e,i,n):0}}function fl(t,e,i,n){if("error"===(t=pl(t,e,i,n)).result)return t;const s=t.value.expression,l=fs(s);if(!l&&!hl(e))return Fo([new xn("","data expressions not supported")]);const u=cr(s,["zoom","pitch","distance-from-center"]);if(!u&&!yu(e))return Fo([new xn("","zoom expressions not supported")]);const p=cr(s,["measure-light"]);if(!p&&!jc(e))return Fo([new xn("","measure-light expression not supported")]);const m=e.expression&&e.expression.relaxZoomRestriction,_=ha(s);return _||u||m?_ instanceof xn?Fo([_]):_ instanceof Fr&&!Gc(e)?Fo([new xn("",'"interpolate" expressions cannot be used with this property')]):Uc(_?new la(l?"camera":"composite",t.value,_.labels,_ instanceof Fr?_.interpolation:void 0,p):new qc(l?"constant":"source",t.value,p)):Fo([new xn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ca{constructor(e,i){this._parameters=e,this._specification=i,Jl(this,Zc(this._parameters,this._specification))}static deserialize(e){return new ca(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ha(t){let e=null;if(t instanceof Ic)e=ha(t.result);else if(t instanceof Ac){for(const i of t.args)if(e=ha(i),e)break}else(t instanceof ra||t instanceof Fr)&&t.input instanceof Gt&&"zoom"===t.input.name&&(e=t);return e instanceof xn||t.eachChild(i=>{const n=ha(i);n instanceof xn?e=n:e&&n&&e!==n&&(e=new xn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}var ap=ln,an=3;function ln(t,e,i){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*(i=s[2]);for(var l=0;l<this.d*this.d;l++){var u=s[an+l],p=s[an+l+1];n.push(u===p?null:s.subarray(u,p))}var m=s[an+n.length+1];this.keys=s.subarray(s[an+n.length],m),this.bboxes=s.subarray(m),this.insert=this._insertReadonly}else{this.d=e+2*i;for(var _=0;_<this.d*this.d;_++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var y=i/e*t;this.min=-y,this.max=t+y}ln.prototype.insert=function(t,e,i,n,s){this._forEachCell(e,i,n,s,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(s)},ln.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},ln.prototype._insertCell=function(t,e,i,n,s,l){this.cells[s].push(l)},ln.prototype.query=function(t,e,i,n,s){var l=this.min,u=this.max;if(t<=l&&e<=l&&u<=i&&u<=n&&!s)return Array.prototype.slice.call(this.keys);var p=[];return this._forEachCell(t,e,i,n,this._queryCell,p,{},s),p},ln.prototype._queryCell=function(t,e,i,n,s,l,u,p){var m=this.cells[s];if(null!==m)for(var _=this.keys,y=this.bboxes,v=0;v<m.length;v++){var w=m[v];if(void 0===u[w]){var E=4*w;(p?p(y[E+0],y[E+1],y[E+2],y[E+3]):t<=y[E+2]&&e<=y[E+3]&&i>=y[E+0]&&n>=y[E+1])?(u[w]=!0,l.push(_[w])):u[w]=!1}}},ln.prototype._forEachCell=function(t,e,i,n,s,l,u,p){for(var m=this._convertToCellCoord(t),_=this._convertToCellCoord(e),y=this._convertToCellCoord(i),v=this._convertToCellCoord(n),w=m;w<=y;w++)for(var E=_;E<=v;E++){var A=this.d*E+w;if((!p||p(this._convertFromCellCoord(w),this._convertFromCellCoord(E),this._convertFromCellCoord(w+1),this._convertFromCellCoord(E+1)))&&s.call(this,t,e,i,n,A,l,u,p))return}},ln.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},ln.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},ln.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=an+this.cells.length+1+1,i=0,n=0;n<this.cells.length;n++)i+=this.cells[n].length;var s=new Int32Array(e+i+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[an+u]=l,s.set(p,l),l+=p.length}return s[an+t.length]=l,s.set(this.keys,l),s[an+t.length+1]=l+=this.keys.length,s.set(this.bboxes,l),l+=this.bboxes.length,s.buffer};var Dn=kr(ap);const ua={};function Ke(t,e,i={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ua[e]={klass:t,omit:i.omit||[]}}Ke(Object,"Object"),Dn.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.add(i),{buffer:i}},Dn.deserialize=function(t){return new Dn(t.buffer)},Object.defineProperty(Dn,"name",{value:"Grid"}),Ke(Dn,"Grid"),Ke(ji,"Color"),Ke(Error,"Error"),Ke(lr,"Formatted"),Ke(as,"FormattedSection"),Ke(Zi,"AJAXError"),Ke(pt,"ResolvedImage"),Ke(ca,"StylePropertyFunction"),Ke(dl,"StyleExpression",{omit:["_evaluator"]}),Ke(la,"ZoomDependentExpression"),Ke(qc,"ZoomConstantExpression"),Ke(Gt,"CompoundExpression",{omit:["_evaluate"]});for(const t in ws)ua[ws[t]._classRegistryKey]||Ke(ws[t],`Expression${t}`);function wu(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function ml(t){return self.ImageBitmap&&t instanceof ImageBitmap}function ao(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(wu(t)||ml(t))return e&&e.add(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.add(i.buffer),i}if(t instanceof ImageData)return e&&e.add(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const n of t)i.push(ao(n,e));return i}if(t instanceof Map){const i={$name:"Map"};for(const[n,s]of t.entries())i[n]=ao(s);return i}if("object"==typeof t){const i=t.constructor,n=i._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);const s=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const l in t)t.hasOwnProperty(l)&&(ua[n].omit.indexOf(l)>=0||(s[l]=ao(t[l],e)));t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(s.$name=n),s}throw new Error("can't serialize object of type "+typeof t)}function No(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||wu(t)||ml(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(No);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const s=new Map;for(const l of Object.keys(t))"$name"!==l&&s.set(l,No(t[l]));return s}const{klass:i}=ua[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const s of Object.keys(t))"$name"!==s&&(n[s]=No(t[s]));return n}throw new Error("can't deserialize object of type "+typeof t)}const it_Latin_1_Supplement=t=>t>=128&&t<=255,it_Arabic=t=>t>=1536&&t<=1791,it_Arabic_Supplement=t=>t>=1872&&t<=1919,it_Arabic_Extended_A=t=>t>=2208&&t<=2303,it_Hangul_Jamo=t=>t>=4352&&t<=4607,it_Unified_Canadian_Aboriginal_Syllabics=t=>t>=5120&&t<=5759,it_Khmer=t=>t>=6016&&t<=6143,it_Unified_Canadian_Aboriginal_Syllabics_Extended=t=>t>=6320&&t<=6399,it_General_Punctuation=t=>t>=8192&&t<=8303,it_Letterlike_Symbols=t=>t>=8448&&t<=8527,it_Number_Forms=t=>t>=8528&&t<=8591,it_Miscellaneous_Technical=t=>t>=8960&&t<=9215,it_Control_Pictures=t=>t>=9216&&t<=9279,it_Optical_Character_Recognition=t=>t>=9280&&t<=9311,it_Enclosed_Alphanumerics=t=>t>=9312&&t<=9471,it_Geometric_Shapes=t=>t>=9632&&t<=9727,it_Miscellaneous_Symbols=t=>t>=9728&&t<=9983,it_Miscellaneous_Symbols_and_Arrows=t=>t>=11008&&t<=11263,it_CJK_Radicals_Supplement=t=>t>=11904&&t<=12031,it_Kangxi_Radicals=t=>t>=12032&&t<=12255,it_Ideographic_Description_Characters=t=>t>=12272&&t<=12287,it_CJK_Symbols_and_Punctuation=t=>t>=12288&&t<=12351,it_Hiragana=t=>t>=12352&&t<=12447,it_Katakana=t=>t>=12448&&t<=12543,it_Bopomofo=t=>t>=12544&&t<=12591,it_Hangul_Compatibility_Jamo=t=>t>=12592&&t<=12687,it_Kanbun=t=>t>=12688&&t<=12703,it_Bopomofo_Extended=t=>t>=12704&&t<=12735,it_CJK_Strokes=t=>t>=12736&&t<=12783,it_Katakana_Phonetic_Extensions=t=>t>=12784&&t<=12799,it_Enclosed_CJK_Letters_and_Months=t=>t>=12800&&t<=13055,it_CJK_Compatibility=t=>t>=13056&&t<=13311,it_CJK_Unified_Ideographs_Extension_A=t=>t>=13312&&t<=19903,it_Yijing_Hexagram_Symbols=t=>t>=19904&&t<=19967,it_CJK_Unified_Ideographs=t=>t>=19968&&t<=40959,it_Yi_Syllables=t=>t>=40960&&t<=42127,it_Yi_Radicals=t=>t>=42128&&t<=42191,it_Hangul_Jamo_Extended_A=t=>t>=43360&&t<=43391,it_Hangul_Syllables=t=>t>=44032&&t<=55215,it_Hangul_Jamo_Extended_B=t=>t>=55216&&t<=55295,it_Private_Use_Area=t=>t>=57344&&t<=63743,it_CJK_Compatibility_Ideographs=t=>t>=63744&&t<=64255,it_Arabic_Presentation_Forms_A=t=>t>=64336&&t<=65023,it_Vertical_Forms=t=>t>=65040&&t<=65055,it_CJK_Compatibility_Forms=t=>t>=65072&&t<=65103,it_Small_Form_Variants=t=>t>=65104&&t<=65135,it_Arabic_Presentation_Forms_B=t=>t>=65136&&t<=65279,it_Halfwidth_and_Fullwidth_Forms=t=>t>=65280&&t<=65519,it_CJK_Unified_Ideographs_Extension_B=t=>t>=131072&&t<=173791;function lo(t){for(const e of t)if($c(e.charCodeAt(0)))return!0;return!1}function lp(t){for(const e of t)if(!cp(e.charCodeAt(0)))return!1;return!0}function cp(t){return!(it_Arabic(t)||it_Arabic_Supplement(t)||it_Arabic_Extended_A(t)||it_Arabic_Presentation_Forms_A(t)||it_Arabic_Presentation_Forms_B(t))}function $c(t){return!(746!==t&&747!==t&&(t<4352||!(it_Bopomofo_Extended(t)||it_Bopomofo(t)||it_CJK_Compatibility_Forms(t)&&!(t>=65097&&t<=65103)||it_CJK_Compatibility_Ideographs(t)||it_CJK_Compatibility(t)||it_CJK_Radicals_Supplement(t)||it_CJK_Strokes(t)||!(!it_CJK_Symbols_and_Punctuation(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||it_CJK_Unified_Ideographs_Extension_A(t)||it_CJK_Unified_Ideographs(t)||it_Enclosed_CJK_Letters_and_Months(t)||it_Hangul_Compatibility_Jamo(t)||it_Hangul_Jamo_Extended_A(t)||it_Hangul_Jamo_Extended_B(t)||it_Hangul_Jamo(t)||it_Hangul_Syllables(t)||it_Hiragana(t)||it_Ideographic_Description_Characters(t)||it_Kanbun(t)||it_Kangxi_Radicals(t)||it_Katakana_Phonetic_Extensions(t)||it_Katakana(t)&&12540!==t||!(!it_Halfwidth_and_Fullwidth_Forms(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!it_Small_Form_Variants(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||it_Unified_Canadian_Aboriginal_Syllabics(t)||it_Unified_Canadian_Aboriginal_Syllabics_Extended(t)||it_Vertical_Forms(t)||it_Yijing_Hexagram_Symbols(t)||it_Yi_Syllables(t)||it_Yi_Radicals(t))))}function Tu(t){return!($c(t)||(e=t,it_Latin_1_Supplement(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||it_General_Punctuation(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||it_Letterlike_Symbols(e)||it_Number_Forms(e)||it_Miscellaneous_Technical(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||it_Control_Pictures(e)&&9251!==e||it_Optical_Character_Recognition(e)||it_Enclosed_Alphanumerics(e)||it_Geometric_Shapes(e)||it_Miscellaneous_Symbols(e)&&!(e>=9754&&e<=9759)||it_Miscellaneous_Symbols_and_Arrows(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||it_CJK_Symbols_and_Punctuation(e)||it_Katakana(e)||it_Private_Use_Area(e)||it_CJK_Compatibility_Forms(e)||it_Small_Form_Variants(e)||it_Halfwidth_and_Fullwidth_Forms(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e));var e}function Mu(t){return t>=1424&&t<=2303||it_Arabic_Presentation_Forms_A(t)||it_Arabic_Presentation_Forms_B(t)}function Eu(t,e){return!(!e&&Mu(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||it_Khmer(t))}function Wc(t){for(const e of t)if(Mu(e.charCodeAt(0)))return!0;return!1}const Hc="deferred",Xc="loading",Yc="loaded";let Kc=null,Ir="unavailable",co=null;const Su=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(Ir="error"),Kc&&Kc(t)};function Jc(){Qc.fire(new Io("pluginStateChange",{pluginStatus:Ir,pluginURL:co}))}const Qc=new rs,ho=function(){return Ir},eh=function(){if(Ir!==Hc||!co)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ir=Xc,Jc(),co&&ve({url:co},t=>{t?Su(t):(Ir=Yc,Jc())})},Nr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ir===Yc||null!=Nr.applyArabicShaping,isLoading:()=>Ir===Xc,setState(t){Ir=t.pluginStatus,co=t.pluginURL},isParsed:()=>null!=Nr.applyArabicShaping&&null!=Nr.processBidirectionalText&&null!=Nr.processStyledBidirectionalText,getPluginURL:()=>co};class Ai{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch,this.brightness=i.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(i,n){for(const s of i)if(!Eu(s.charCodeAt(0),n))return!1;return!0}(e,Nr.isLoaded())}}class _l{constructor(e,i,n,s){this.property=e,this.value=i,this.expression=function(l,u,p,m){if(ul(l))return new ca(l,u);if(aa(l)||Array.isArray(l)&&l.length>0){const _=fl(l,u,p,m);if("error"===_.result)throw new Error(_.value.map(y=>`${y.key}: ${y.message}`).join(", "));return _.value}{let _=l;return"string"==typeof l&&"color"===u.type&&(_=ji.parse(l)),{kind:"constant",isConfigDependent:!1,evaluate:()=>_}}}(void 0===i?e.specification.default:i,e.specification,n,s)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,i,n){return this.property.possiblyEvaluate(this,e,i,n)}}class th{constructor(e,i,n){this.property=e,this.value=new _l(e,void 0,i,n)}transitioned(e,i){return new ih(this.property,this.value,i,pr({},e.transition,this.transition),e.now)}untransitioned(){return new ih(this.property,this.value,null,{},0)}}class Ln{constructor(e,i,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=n,this.isConfigDependent=!1}getValue(e){return Or(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new th(this._values[e].property,this._scope,this._options)),this._values[e].value=new _l(this._values[e].property,null===i?void 0:Or(i),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,i){i&&(this._options=i);const n=this._properties.properties;if(e)for(const s in e){const l=e[s];if(En(s,"-transition")){const u=s.slice(0,-11);n[u]&&this.setTransition(u,l)}else n[s]&&this.setValue(s,l)}}getTransition(e){return Or(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new th(this._values[e].property)),this._values[e].transition=Or(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);void 0!==n&&(e[i]=n);const s=this.getTransition(i);void 0!==s&&(e[`${i}-transition`]=s)}return e}transitioned(e,i){const n=new Vo(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,i._values[s]);return n}untransitioned(){const e=new Vo(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class ih{constructor(e,i,n,s,l){const u=s.delay||0,p=s.duration||0;l=l||0,this.property=e,this.value=i,this.begin=l+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,i,n){const s=e.now||0,l=this.value.possiblyEvaluate(e,i,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,i,n);{const p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,i,n),l,$e(p))}}return l}}class Vo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,n){const s=new da(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,i,n);return s}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class hp{constructor(e,i,n){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=i,this._options=n,this.isConfigDependent=!1}getValue(e){return Or(this._values[e].value)}setValue(e,i){this._values[e]=new _l(this._values[e].property,null===i?void 0:Or(i),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].expression.isConfigDependent}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);void 0!==n&&(e[i]=n)}return e}possiblyEvaluate(e,i,n){const s=new da(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,i,n);return s}}class Ts{constructor(e,i,n){this.property=e,this.value=i,this.parameters=n}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,i,n,s){return this.property.evaluate(this.value,this.parameters,e,i,n,s)}}class da{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Oe{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,n){const s=$a[this.specification.type];return s?s(e,i,n):e}}class ht{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,n,s){return new Ts(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(i,null,{},n,s)}:e.expression,i)}interpolate(e,i,n){if("constant"!==e.value.kind||"constant"!==i.value.kind)return e;if(void 0===e.value.value||void 0===i.value.value)return new Ts(this,{kind:"constant",value:void 0},e.parameters);const s=$a[this.specification.type];return s?new Ts(this,{kind:"constant",value:s(e.value.value,i.value.value,n)},e.parameters):e}evaluate(e,i,n,s,l,u){return"constant"===e.kind?e.value:e.evaluate(i,n,s,l,u)}}class Uo{constructor(e){this.specification=e}possiblyEvaluate(e,i,n,s){return!!e.expression.evaluate(i,null,{},n,s)}interpolate(){return!1}}class Ii{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const i=new Ai(0,{});for(const n in e){const s=e[n];s.specification.overridable&&this.overridableProperties.push(n);const l=this.defaultPropertyValues[n]=new _l(s,void 0),u=this.defaultTransitionablePropertyValues[n]=new th(s);this.defaultTransitioningPropertyValues[n]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=l.possiblyEvaluate(i)}}}function pa(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function fa(t){if(Array.isArray(t))return t.map(fa);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=fa(t[i]);return e}return pa(t)}Ke(ht,"DataDrivenProperty"),Ke(Oe,"DataConstantProperty"),Ke(Uo,"ColorRampProperty");var le=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"camera":{"type":"camera"},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"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},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false,"expression":{},"property-type":"data-constant"},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"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}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"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}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"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":1,"tms":1},"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":1}},"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},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"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},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"required":true,"type":"enum","values":{"raster-array":1}},"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},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"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":1}},"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":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"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","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"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":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"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_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"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","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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"],"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{},"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-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"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":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"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","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","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"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function rh(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!rh(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Vr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};rh(t)||(t=ma(t));const i=t;let n=!0;try{n=function(_){if(!Ms(_))return _;let y=fa(_);return nh(y),y=Au(y),y}(i)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const s=le[`filter_${e}`],l=pl(n,s);let u=null;if("error"===l.result)throw new Error(l.value.map(_=>`${_.key}: ${_.message}`).join(", "));u=(_,y,v)=>l.value.evaluate(_,y,{},v);let p=null,m=null;if(n!==i){const _=pl(i,s);if("error"===_.result)throw new Error(_.value.map(y=>`${y.key}: ${y.message}`).join(", "));p=(y,v,w,E,A)=>_.value.evaluate(y,v,{},w,void 0,void 0,E,A),m=!fs(_.value.expression)}return{filter:u,dynamicFilter:p||void 0,needGeometry:Iu(n),needFeature:!!m}}function Au(t){if(!Array.isArray(t))return t;const e=function(i){if(up.has(i[0]))for(let n=1;n<i.length;n++)if(Ms(i[n]))return!0;return i}(t);return!0===e?e:e.map(i=>Au(i))}function nh(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n<t.length-1;n+=2)e=e||Ms(t[n]),i.push(t[n+1]);i.push(t[t.length-1])}else if("match"===t[0]){e=e||Ms(t[1]);for(let n=2;n<t.length-1;n+=2)i.push(t[n+1]);i.push(t[t.length-1])}else if("step"===t[0]){e=e||Ms(t[1]);for(let n=1;n<t.length-1;n+=2)i.push(t[n+1])}e&&(t.length=0,t.push("any",...i));for(let n=1;n<t.length;n++)nh(t[n])}function Ms(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let i=1;i<t.length;i++)if(Ms(t[i]))return!0;return!1}const up=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function dp(t,e){return t<e?-1:t>e?1:0}function Iu(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(Iu(t[e]))return!0;return!1}function ma(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?_a(t[1],t[2],"=="):"!="===e?ga(_a(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?_a(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(ma))):"all"===e?["all"].concat(t.slice(1).map(ma)):"none"===e?["all"].concat(t.slice(1).map(ma).map(ga)):"in"===e?oh(t[1],t.slice(2)):"!in"===e?ga(oh(t[1],t.slice(2))):"has"===e?Cu(t[1]):"!has"!==e||ga(Cu(t[1]));var i}function _a(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function oh(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(i=>typeof i!=typeof e[0])?["filter-in-large",t,["literal",e.sort(dp)]]:["filter-in-small",t,["literal",e]]}}function Cu(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ga(t){return["!",t]}function sh(t,e){return e?`${t}\x1f${e}`:t}const ya="-transition";class Cr extends rs{constructor(e,i,n,s){if(super(),this.id=e.id,this.fqid=sh(this.id,n),this.type=e.type,this.scope=n,this.options=s,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),i.layout&&(this._unevaluatedLayout=new hp(i.layout,this.scope,s),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),i.paint)){this._transitionablePaint=new Ln(i.paint,this.scope,s);for(const l in e.paint)this.setPaintProperty(l,e.paint[l]);for(const l in e.layout)this.setLayoutProperty(l,e.layout[l]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new da(i.paint)}}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i){if("custom"===this.type&&"visibility"===e)return void(this.visibility=i);const n=this._unevaluatedLayout;n._properties.properties[e]&&(n.setValue(e,i),this.isConfigDependent=this.isConfigDependent||n.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return En(e,ya)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i){const n=this._transitionablePaint,s=n._properties.properties;if(En(e,ya)){const v=e.slice(0,-11);return s[v]&&n.setTransition(v,i||void 0),!1}if(!s[e])return!1;const l=n._values[e],u=l.value.isDataDriven(),p=l.value;n.setValue(e,i),this.isConfigDependent=this.isConfigDependent||n.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const m=n._values[e].value,_=m.isDataDriven(),y=En(e,"pattern")||"line-dasharray"===e;return _||u||y||this._handleOverridablePaintPropertyUpdate(e,p,m)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i){return null}_handleOverridablePaintPropertyUpdate(e,i,n){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){return jr({id:this.id,type:this.type,slot:this.slot,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()},(e,i)=>!(void 0===e||"layout"===i&&!Object.keys(e).length||"paint"===i&&!Object.keys(e).length))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof Ts&&hl(i.property.specification)&&("source"===i.value.kind||"composite"===i.value.kind)&&i.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Vr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}}const pp={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class yl{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class wi{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,i.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function li(t,e=1){let i=0,n=0;return{members:t.map(s=>{const l=pp[s.type].BYTES_PER_ELEMENT,u=i=xa(i,Math.max(e,l)),p=s.components||1;return n=Math.max(n,l),i+=l*p,{name:s.name,type:s.type,components:p,offset:u}}),size:xa(i,Math.max(n,e)),alignment:e}}function xa(t,e){return Math.ceil(t/e)*e}class cn extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.int16[s+0]=i,this.int16[s+1]=n,e}}cn.prototype.bytesPerElement=4,Ke(cn,"StructArrayLayout2i4");class wr extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const l=3*e;return this.int16[l+0]=i,this.int16[l+1]=n,this.int16[l+2]=s,e}}wr.prototype.bytesPerElement=6,Ke(wr,"StructArrayLayout3i6");class Rn extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,i,n,s)}emplace(e,i,n,s,l){const u=4*e;return this.int16[u+0]=i,this.int16[u+1]=n,this.int16[u+2]=s,this.int16[u+3]=l,e}}Rn.prototype.bytesPerElement=8,Ke(Rn,"StructArrayLayout4i8");class ah extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,l)}emplace(e,i,n,s,l,u){const p=5*e;return this.int16[p+0]=i,this.int16[p+1]=n,this.int16[p+2]=s,this.int16[p+3]=l,this.int16[p+4]=u,e}}ah.prototype.bytesPerElement=10,Ke(ah,"StructArrayLayout5i10");class lh extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,l,u,p)}emplace(e,i,n,s,l,u,p,m){const _=6*e,y=12*e,v=3*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.uint8[y+4]=s,this.uint8[y+5]=l,this.uint8[y+6]=u,this.uint8[y+7]=p,this.float32[v+2]=m,e}}lh.prototype.bytesPerElement=12,Ke(lh,"StructArrayLayout2i4ub1f12");class uo extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,i,n,s)}emplace(e,i,n,s,l){const u=4*e;return this.float32[u+0]=i,this.float32[u+1]=n,this.float32[u+2]=s,this.float32[u+3]=l,e}}uo.prototype.bytesPerElement=16,Ke(uo,"StructArrayLayout4f16");class po extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,l)}emplace(e,i,n,s,l,u){const p=6*e,m=3*e;return this.uint16[p+0]=i,this.uint16[p+1]=n,this.uint16[p+2]=s,this.uint16[p+3]=l,this.float32[m+2]=u,e}}po.prototype.bytesPerElement=12,Ke(po,"StructArrayLayout4ui1f12");class Es extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,i,n,s)}emplace(e,i,n,s,l){const u=4*e;return this.uint16[u+0]=i,this.uint16[u+1]=n,this.uint16[u+2]=s,this.uint16[u+3]=l,e}}Es.prototype.bytesPerElement=8,Ke(Es,"StructArrayLayout4ui8");class xl extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,s,l,u)}emplace(e,i,n,s,l,u,p){const m=6*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=s,this.int16[m+3]=l,this.int16[m+4]=u,this.int16[m+5]=p,e}}xl.prototype.bytesPerElement=12,Ke(xl,"StructArrayLayout6i12");class va extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p,m,_,y,v,w){const E=this.length;return this.resize(E+1),this.emplace(E,e,i,n,s,l,u,p,m,_,y,v,w)}emplace(e,i,n,s,l,u,p,m,_,y,v,w,E){const A=12*e;return this.int16[A+0]=i,this.int16[A+1]=n,this.int16[A+2]=s,this.int16[A+3]=l,this.uint16[A+4]=u,this.uint16[A+5]=p,this.uint16[A+6]=m,this.uint16[A+7]=_,this.int16[A+8]=y,this.int16[A+9]=v,this.int16[A+10]=w,this.int16[A+11]=E,e}}va.prototype.bytesPerElement=24,Ke(va,"StructArrayLayout4i4ui4i24");class ch extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,s,l,u)}emplace(e,i,n,s,l,u,p){const m=10*e,_=5*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=s,this.float32[_+2]=l,this.float32[_+3]=u,this.float32[_+4]=p,e}}ch.prototype.bytesPerElement=20,Ke(ch,"StructArrayLayout3i3f20");class hh extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}hh.prototype.bytesPerElement=4,Ke(hh,"StructArrayLayout1ul4");class vn extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.uint16[s+0]=i,this.uint16[s+1]=n,e}}vn.prototype.bytesPerElement=4,Ke(vn,"StructArrayLayout2ui4");class uh extends wi{_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,i,n,s,l,u,p,m,_,y,v,w,E){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,n,s,l,u,p,m,_,y,v,w,E)}emplace(e,i,n,s,l,u,p,m,_,y,v,w,E,A){const I=20*e,z=10*e;return this.int16[I+0]=i,this.int16[I+1]=n,this.int16[I+2]=s,this.int16[I+3]=l,this.int16[I+4]=u,this.float32[z+3]=p,this.float32[z+4]=m,this.float32[z+5]=_,this.float32[z+6]=y,this.int16[I+14]=v,this.uint32[z+8]=w,this.uint16[I+18]=E,this.uint16[I+19]=A,e}}uh.prototype.bytesPerElement=40,Ke(uh,"StructArrayLayout5i4f1i1ul2ui40");class ba extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,l,u,p)}emplace(e,i,n,s,l,u,p,m){const _=8*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.int16[_+2]=s,this.int16[_+4]=l,this.int16[_+5]=u,this.int16[_+6]=p,this.int16[_+7]=m,e}}ba.prototype.bytesPerElement=16,Ke(ba,"StructArrayLayout3i2i2i16");class vl extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,l)}emplace(e,i,n,s,l,u){const p=4*e,m=8*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=s,this.int16[m+6]=l,this.int16[m+7]=u,e}}vl.prototype.bytesPerElement=16,Ke(vl,"StructArrayLayout2f1f2i16");class dh extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,i,n,s)}emplace(e,i,n,s,l){const u=12*e,p=3*e;return this.uint8[u+0]=i,this.uint8[u+1]=n,this.float32[p+1]=s,this.float32[p+2]=l,e}}dh.prototype.bytesPerElement=12,Ke(dh,"StructArrayLayout2ub2f12");class Ji extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const l=3*e;return this.uint16[l+0]=i,this.uint16[l+1]=n,this.uint16[l+2]=s,e}}Ji.prototype.bytesPerElement=6,Ke(Ji,"StructArrayLayout3ui6");class Ss extends wi{_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,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X){const W=this.length;return this.resize(W+1),this.emplace(W,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X)}emplace(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X,W){const J=30*e,ie=15*e,oe=60*e;return this.int16[J+0]=i,this.int16[J+1]=n,this.int16[J+2]=s,this.float32[ie+2]=l,this.float32[ie+3]=u,this.uint16[J+8]=p,this.uint16[J+9]=m,this.uint32[ie+5]=_,this.uint32[ie+6]=y,this.uint32[ie+7]=v,this.uint16[J+16]=w,this.uint16[J+17]=E,this.uint16[J+18]=A,this.float32[ie+10]=I,this.float32[ie+11]=z,this.uint8[oe+48]=L,this.uint8[oe+49]=N,this.uint8[oe+50]=G,this.uint32[ie+13]=j,this.int16[J+28]=X,this.uint8[oe+58]=W,e}}Ss.prototype.bytesPerElement=60,Ke(Ss,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class bl extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X,W,J,ie,oe,he,se,_e,Me,fe,we,de){const be=this.length;return this.resize(be+1),this.emplace(be,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X,W,J,ie,oe,he,se,_e,Me,fe,we,de)}emplace(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X,W,J,ie,oe,he,se,_e,Me,fe,we,de,be){const Fe=20*e,Se=40*e,Qe=80*e;return this.float32[Fe+0]=i,this.float32[Fe+1]=n,this.int16[Se+4]=s,this.int16[Se+5]=l,this.int16[Se+6]=u,this.int16[Se+7]=p,this.int16[Se+8]=m,this.int16[Se+9]=_,this.int16[Se+10]=y,this.int16[Se+11]=v,this.int16[Se+12]=w,this.uint16[Se+13]=E,this.uint16[Se+14]=A,this.uint16[Se+15]=I,this.uint16[Se+16]=z,this.uint16[Se+17]=L,this.uint16[Se+18]=N,this.uint16[Se+19]=G,this.uint16[Se+20]=j,this.uint16[Se+21]=X,this.uint16[Se+22]=W,this.uint16[Se+23]=J,this.uint16[Se+24]=ie,this.uint16[Se+25]=oe,this.uint16[Se+26]=he,this.uint16[Se+27]=se,this.uint32[Fe+14]=_e,this.float32[Fe+15]=Me,this.float32[Fe+16]=fe,this.float32[Fe+17]=we,this.float32[Fe+18]=de,this.uint8[Qe+76]=be,e}}bl.prototype.bytesPerElement=80,Ke(bl,"StructArrayLayout2f9i15ui1ul4f1ub80");class wa extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}wa.prototype.bytesPerElement=4,Ke(wa,"StructArrayLayout1f4");class fo extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,l)}emplace(e,i,n,s,l,u){const p=5*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=s,this.float32[p+3]=l,this.float32[p+4]=u,e}}fo.prototype.bytesPerElement=20,Ke(fo,"StructArrayLayout5f20");class ph extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,l,u,p)}emplace(e,i,n,s,l,u,p,m){const _=7*e;return this.float32[_+0]=i,this.float32[_+1]=n,this.float32[_+2]=s,this.float32[_+3]=l,this.float32[_+4]=u,this.float32[_+5]=p,this.float32[_+6]=m,e}}ph.prototype.bytesPerElement=28,Ke(ph,"StructArrayLayout7f28");class Ta extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,i,n,s)}emplace(e,i,n,s,l){const u=6*e;return this.uint32[3*e+0]=i,this.uint16[u+2]=n,this.uint16[u+3]=s,this.uint16[u+4]=l,e}}Ta.prototype.bytesPerElement=12,Ke(Ta,"StructArrayLayout1ul3ui12");class fh extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}fh.prototype.bytesPerElement=2,Ke(fh,"StructArrayLayout1ui2");class jo extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const l=3*e;return this.float32[l+0]=i,this.float32[l+1]=n,this.float32[l+2]=s,e}}jo.prototype.bytesPerElement=12,Ke(jo,"StructArrayLayout3f12");class Ma extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.float32[s+0]=i,this.float32[s+1]=n,e}}Ma.prototype.bytesPerElement=8,Ke(Ma,"StructArrayLayout2f8");class mh extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z){const L=this.length;return this.resize(L+1),this.emplace(L,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z)}emplace(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L){const N=16*e;return this.float32[N+0]=i,this.float32[N+1]=n,this.float32[N+2]=s,this.float32[N+3]=l,this.float32[N+4]=u,this.float32[N+5]=p,this.float32[N+6]=m,this.float32[N+7]=_,this.float32[N+8]=y,this.float32[N+9]=v,this.float32[N+10]=w,this.float32[N+11]=E,this.float32[N+12]=A,this.float32[N+13]=I,this.float32[N+14]=z,this.float32[N+15]=L,e}}mh.prototype.bytesPerElement=64,Ke(mh,"StructArrayLayout16f64");class Ea extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,l,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,l,u,p)}emplace(e,i,n,s,l,u,p,m){const _=10*e,y=5*e;return this.uint16[_+0]=i,this.uint16[_+1]=n,this.uint16[_+2]=s,this.uint16[_+3]=l,this.float32[y+2]=u,this.float32[y+3]=p,this.float32[y+4]=m,e}}Ea.prototype.bytesPerElement=20,Ke(Ea,"StructArrayLayout4ui3f20");class _h extends wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint8[1*e+0]=i,e}}_h.prototype.bytesPerElement=1,Ke(_h,"StructArrayLayout1ub1");class Pu extends yl{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]}}Pu.prototype.size=40;class zu extends uh{get(e){return new Pu(this,e)}}Ke(zu,"CollisionBoxArray");class Du extends yl{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 Lu extends Ss{get(e){return new Du(this,e)}}Ke(Lu,"PlacedSymbolArray");class Ru extends yl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ru.prototype.size=80;class ku extends bl{get(e){return new Ru(this,e)}}Ke(ku,"SymbolInstanceArray");class Ou extends wa{getoffsetX(e){return this.float32[1*e+0]}}Ke(Ou,"GlyphOffsetArray");class Sa extends cn{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ke(Sa,"SymbolLineVertexArray");class Bu extends yl{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]}}Bu.prototype.size=12;class Fu extends Ta{get(e){return new Bu(this,e)}}Ke(Fu,"FeatureIndexArray");class Aa extends vn{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ke(Aa,"FillExtrusionCentroidArray");const fp=li([{name:"a_pos",components:2,type:"Int16"}],4),Nu=li([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Oi{constructor(e=[]){this.segments=e}_prepareSegment(e,i,n,s){let l=this.segments[this.segments.length-1];return e>Oi.MAX_VERTEX_ARRAY_LENGTH&&ki(`Max vertices per segment is ${Oi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!l||l.vertexLength+e>Oi.MAX_VERTEX_ARRAY_LENGTH||l.sortKey!==s)&&(l={vertexOffset:i,primitiveOffset:n,vertexLength:0,primitiveLength:0},void 0!==s&&(l.sortKey=s),this.segments.push(l)),l}prepareSegment(e,i,n,s){return this._prepareSegment(e,i.length,n.length,s)}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,n,s){return new Oi([{vertexOffset:e,primitiveOffset:i,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}function gh(t,e){return 256*(t=Dt(Math.floor(t),0,255))+Dt(Math.floor(e),0,255)}Oi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ke(Oi,"SegmentVector");const Vu=li([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Uu=li([{name:"a_dash",components:4,type:"Uint16"}]);var Ia={exports:{}},yh={exports:function(e,i){var n,s,l,u,p,m,_,y;for(s=e.length-(n=3&e.length),l=i,p=3432918353,m=461845907,y=0;y<s;)_=255&e.charCodeAt(y)|(255&e.charCodeAt(++y))<<8|(255&e.charCodeAt(++y))<<16|(255&e.charCodeAt(++y))<<24,++y,l=27492+(65535&(u=5*(65535&(l=(l^=_=(65535&(_=(_=(65535&_)*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,n){case 3:_^=(255&e.charCodeAt(y+2))<<16;case 2:_^=(255&e.charCodeAt(y+1))<<8;case 1:l^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(y)))*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>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}}.exports,ju={exports:{}};ju.exports=function(e,i){for(var n,s=e.length,l=i^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};var Gu=yh,Zu=ju.exports;Ia.exports=Gu,Ia.exports.murmur3=Gu,Ia.exports.murmur2=Zu;var xh=kr(Ia.exports);class Ca{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,i,n,s){this.ids.push(qu(e)),this.positions.push(i,n,s)}eachPosition(e,i){const n=qu(e);let s=0,l=this.ids.length-1;for(;s<l;){const u=s+l>>1;this.ids[u]>=n?l=u:s=u+1}for(;this.ids[s]===n;)i(this.positions[3*s],this.positions[3*s+1],this.positions[3*s+2]),s++}static serialize(e,i){const n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return vh(n,s,0,n.length-1),i&&(i.add(n.buffer),i.add(s.buffer)),{ids:n,positions:s}}static deserialize(e){const i=new Ca;let n;i.ids=e.ids,i.positions=e.positions;for(const s of i.ids)s!==n&&i.uniqueIds.push(s),n=s;return i.indexed=!0,i}}function qu(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:xh(String(t))}function vh(t,e,i,n){for(;i<n;){const s=t[i+n>>1];let l=i-1,u=n+1;for(;;){do{l++}while(t[l]<s);do{u--}while(t[u]>s);if(l>=u)break;Tl(t,l,u),Tl(e,3*l,3*u),Tl(e,3*l+1,3*u+1),Tl(e,3*l+2,3*u+2)}u-i<n-u?(vh(t,e,i,u),i=u+1):(vh(t,e,u+1,n),n=u)}}function Tl(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}Ke(Ca,"FeaturePositionMap");class kn{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}}class Ml extends kn{constructor(e){super(e),this.current=0}set(e,i,n){this.fetchUniformLocation(e,i)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}}class gr extends kn{constructor(e){super(e),this.current=0}set(e,i,n){this.fetchUniformLocation(e,i)&&this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class mo extends kn{constructor(e){super(e),this.current=[0,0]}set(e,i,n){this.fetchUniformLocation(e,i)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}}class $u extends kn{constructor(e){super(e),this.current=[0,0,0]}set(e,i,n){this.fetchUniformLocation(e,i)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}}class c extends kn{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,n){this.fetchUniformLocation(e,i)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3])))}}class r extends kn{constructor(e){super(e),this.current=ji.transparent}set(e,i,n){this.fetchUniformLocation(e,i)&&(n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a)))}}const o=new Float32Array(16);class h extends kn{constructor(e){super(e),this.current=o}set(e,i,n){if(this.fetchUniformLocation(e,i)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let s=1;s<16;s++)if(n[s]!==this.current[s]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}}const d=new Float32Array(9),f=new Float32Array(4);class g extends kn{constructor(e){super(e),this.current=f}set(e,i,n){if(this.fetchUniformLocation(e,i))for(let s=0;s<4;s++)if(n[s]!==this.current[s]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}}function x(t){return[gh(255*t.r,255*t.g),gh(255*t.b,255*t.a)]}class b{constructor(e,i,n){this.value=e,this.uniformNames=i.map(s=>`u_${s}`),this.type=n}setUniform(e,i,n,s,l){i.set(e,l,s.constantOr(this.value))}getBinding(e,i){return"color"===this.type?new r(e):new gr(e)}}class T{constructor(e,i){this.uniformNames=i.map(n=>`u_${n}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,i,n,s,l){const u="u_pattern"===l||"u_dash"===l?this.pattern:"u_pixel_ratio"===l?this.pixelRatio:null;u&&i.set(e,l,u)}getBinding(e,i){return"u_pattern"===i||"u_dash"===i?new c(e):new gr(e)}}class M{constructor(e,i,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=i.map(l=>({name:`a_${l}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,i,n,s,l,u,p){const m=this.paintVertexArray.length,_=this.expression.evaluate(new Ai(0,{brightness:u}),i,{},l,s,p);this.paintVertexArray.resize(e),this._setPaintValue(m,e,_)}updatePaintArray(e,i,n,s,l,u,p){const m=this.expression.evaluate({zoom:0,brightness:p},n,s,void 0,l);this._setPaintValue(e,i,m)}_setPaintValue(e,i,n){if("color"===this.type){const s=x(n);for(let l=e;l<i;l++)this.paintVertexArray.emplace(l,s[0],s[1])}else{for(let s=e;s<i;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||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class S{constructor(e,i,n,s,l,u){this.expression=e,this.uniformNames=i.map(p=>`u_${p}_t`),this.type=n,this.useIntegerZoom=s,this.zoom=l,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,n,s,l,u,p){const m=this.expression.evaluate(new Ai(this.zoom,{brightness:u}),i,{},l,s,p),_=this.expression.evaluate(new Ai(this.zoom+1,{brightness:u}),i,{},l,s,p),y=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(y,e,m,_)}updatePaintArray(e,i,n,s,l,u,p){const m=this.expression.evaluate({zoom:this.zoom,brightness:p},n,s,void 0,l),_=this.expression.evaluate({zoom:this.zoom+1,brightness:p},n,s,void 0,l);this._setPaintValue(e,i,m,_)}_setPaintValue(e,i,n,s){if("color"===this.type){const l=x(n),u=x(s);for(let p=e;p<i;p++)this.paintVertexArray.emplace(p,l[0],l[1],u[0],u[1])}else{for(let l=e;l<i;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||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,n,s,l){const u=this.useIntegerZoom?Math.floor(n.zoom):n.zoom,p=Dt(this.expression.interpolationFactor(u,this.zoom,this.zoom+1),0,1);i.set(e,l,p)}getBinding(e,i){return new gr(e)}}class C{constructor(e,i,n,s,l){this.expression=e,this.layerId=l,this.paintVertexAttributes=("array"===n?Uu:Vu).members;for(let u=0;u<i.length;++u);this.paintVertexArray=new s}populatePaintArray(e,i,n){const s=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(s,e,i.patterns&&i.patterns[this.layerId],n)}updatePaintArray(e,i,n,s,l,u,p){this._setPaintValues(e,i,n.patterns&&n.patterns[this.layerId],u)}_setPaintValues(e,i,n,s){if(!s||!n)return;const l=s[n];if(!l)return;const{tl:u,br:p,pixelRatio:m}=l;for(let _=e;_<i;_++)this.paintVertexArray.emplace(_,u[0],u[1],p[0],p[1],m)}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class P{constructor(e,i,n=()=>!0){this.binders={},this._buffers=[];const s=[];for(const l in e.paint._values){const u=e.paint.get(l);if(!n(l)||!(u instanceof Ts&&hl(u.property.specification)))continue;const p=O(l,e.type),m=u.value,_=u.property.specification.type,y=!!u.property.useIntegerZoom,v="line-dasharray"===l||l.endsWith("pattern"),w="line-dasharray"===l&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==m.kind||w)if("source"===m.kind||w||v){const E=Z(l,_,"source");this.binders[l]=v?new C(m,p,_,E,e.id):new M(m,p,_,E),s.push(`/a_${l}`)}else{const E=Z(l,_,"composite");this.binders[l]=new S(m,p,_,y,i,E),s.push(`/z_${l}`)}else this.binders[l]=v?new T(m.value,p):new b(m.value,p,_),s.push(`/u_${l}`)}this.cacheKey=s.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof M||i instanceof S?i.maxValue:0}populatePaintArrays(e,i,n,s,l,u,p){for(const m in this.binders){const _=this.binders[m];(_ instanceof M||_ instanceof S||_ instanceof C)&&_.populatePaintArray(e,i,n,s,l,u,p)}}setConstantPatternPositions(e){for(const i in this.binders){const n=this.binders[i];n instanceof T&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,i,n,s,l,u,p,m){let _=!1;const y=Object.keys(e),v=0!==y.length,w=v?y:i.uniqueIds;for(const E in this.binders){const A=this.binders[E];if((A instanceof M||A instanceof S||A instanceof C)&&(!0===A.expression.isStateDependent||!1===A.expression.isLightConstant)){const I=l.paint.get(E);A.expression=I.value;for(const z of w){const L=e[z.toString()];i.eachPosition(z,(N,G,j)=>{const X=s.feature(N);A.updatePaintArray(G,j,X,L,u,p,m)})}if(!v)for(const z of n.uniqueIds){const L=e[z.toString()];n.eachPosition(z,(N,G,j)=>{const X=s.feature(N);A.updatePaintArray(G,j,X,L,u,p,m)})}_=!0}}return _}defines(){const e=[];for(const i in this.binders){const n=this.binders[i];(n instanceof b||n instanceof T)&&e.push(...n.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof M||n instanceof S||n instanceof C)for(let s=0;s<n.paintVertexAttributes.length;s++)e.push(n.paintVertexAttributes[s].name)}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof b||n instanceof T||n instanceof S)for(const s of n.uniformNames)e.push(s)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const i=[];for(const n in this.binders){const s=this.binders[n];if(s instanceof b||s instanceof T||s instanceof S)for(const l of s.uniformNames)i.push({name:l,property:n,binding:s.getBinding(e,l)})}return i}setUniforms(e,i,n,s,l){for(const{name:u,property:p,binding:m}of n)this.binders[p].setUniform(e,m,l,s.get(p),u)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const i=this.binders[e];(i instanceof M||i instanceof S||i instanceof C)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const i in this.binders){const n=this.binders[i];(n instanceof M||n instanceof S||n instanceof C)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof M||i instanceof S||i instanceof C)&&i.destroy()}}}class k{constructor(e,i,n=()=>!0){this.programConfigurations={};for(const s of e)this.programConfigurations[s.id]=new P(s,i,n);this.needsUpload=!1,this._featureMap=new Ca,this._featureMapWithoutIds=new Ca,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,n,s,l,u,p,m){for(const _ in this.programConfigurations)this.programConfigurations[_].populatePaintArrays(e,i,s,l,u,p,m);void 0!==i.id?this._featureMap.add(i.id,n,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,n,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,n,s,l,u){for(const p of n)this.needsUpload=this.programConfigurations[p.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,p,s,l,u||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const R={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function O(t,e){return R[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const D={"line-pattern":{source:po,composite:po},"fill-pattern":{source:po,composite:po},"fill-extrusion-pattern":{source:po,composite:po},"line-dasharray":{source:Es,composite:Es}},F={color:{source:Ma,composite:uo},number:{source:wa,composite:Ma}};function Z(t,e,i){const n=D[t];return n&&n[i]||F[e][i]}Ke(b,"ConstantBinder"),Ke(T,"PatternConstantBinder"),Ke(M,"SourceExpressionBinder"),Ke(C,"PatternCompositeBinder"),Ke(S,"CompositeExpressionBinder"),Ke(P,"ProgramConfiguration",{omit:["_buffers"]}),Ke(k,"ProgramConfigurationSet");const V=qe/Math.PI/2,Y=64,K=[Y,32,16],ee=-V,ce=V;function re(t,e,i,n=V){return i=qt(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function me(t,e,i){return re(Math.cos(qt(t)),Math.sin(qt(t)),e,i)}const pe=6371008.8,Ae=2*Math.PI*pe;class ne{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ne(Hn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,n=this.lat*i,s=e.lat*i,l=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*i);return pe*Math.acos(Math.min(l,1))}toBounds(e=0){const i=360*e/40075017,n=i/Math.cos(Math.PI/180*this.lat);return new ue({lng:this.lng-n,lat:this.lat-i},{lng:this.lng+n,lat:this.lat+i})}toEcef(e){return me(this.lat,this.lng,V+e*V/pe)}static convert(e){if(e instanceof ne)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ne(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ne(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>]")}}class ue{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):4===e.length?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 ne?new ne(e.lng,e.lat):ne.convert(e),this}setSouthWest(e){return this._sw=e instanceof ne?new ne(e.lng,e.lat):ne.convert(e),this}extend(e){const i=this._sw,n=this._ne;let s,l;if(e instanceof ne)s=e,l=e;else{if(!(e instanceof ue))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(ue.convert(e)):this.extend(ne.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(ne.convert(e)):this;if(s=e._sw,l=e._ne,!s||!l)return this}return i||n?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),n.lng=Math.max(l.lng,n.lng),n.lat=Math.max(l.lat,n.lat)):(this._sw=new ne(s.lng,s.lat),this._ne=new ne(l.lng,l.lat)),this}getCenter(){return new ne((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 ne(this.getWest(),this.getNorth())}getSouthEast(){return new ne(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){const{lng:i,lat:n}=ne.convert(e);let s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}static convert(e){return!e||e instanceof ue?e:new ue(e)}}var Q={};!function(i){function n(l,u,p){var m=s(256*l,256*(u=Math.pow(2,p)-u-1),p),_=s(256*(l+1),256*(u+1),p);return m[0]+","+m[1]+","+_[0]+","+_[1]}function s(l,u,p){var m=2*Math.PI*6378137/256/Math.pow(2,p);return[l*m-2*Math.PI*6378137/2,u*m-2*Math.PI*6378137/2]}i.getURL=function(l,u,p,m,_,y){return y=y||{},l+"?"+["bbox="+n(p,m,_),"format="+(y.format||"image/png"),"service="+(y.service||"WMS"),"version="+(y.version||"1.1.1"),"request="+(y.request||"GetMap"),"srs="+(y.srs||"EPSG:3857"),"width="+(y.width||256),"height="+(y.height||256),"layers="+u].join("&")},i.getTileBBox=n,i.getMercCoords=s,Object.defineProperty(i,"__esModule",{value:!0})}(Q);var ae=Q;class Ie{constructor(e,i,n){this.z=e,this.x=i,this.y=n,this.key=je(0,e,e,i,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i){const n=ae.getTileBBox(this.x,this.y,this.z),s=function(l,u,p){let m,_="";for(let y=l;y>0;y--)m=1<<y-1,_+=(u&m?1:0)+(p&m?2:0);return _}(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}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Re{constructor(e,i){this.wrap=e,this.canonical=i,this.key=je(e,i.z,i.z,i.x,i.y)}}class Le{constructor(e,i,n,s,l){this.overscaledZ=e,this.wrap=i,this.canonical=new Ie(n,+s,+l),this.key=0===i&&e===n?this.canonical.key:je(i,e,n,s,l)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const i=this.canonical.z-e;return e>this.canonical.z?new Le(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Le(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return je(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return je(this.wrap*+i,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const i=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new Le(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new Le(i,this.wrap,i,n,s),new Le(i,this.wrap,i,n+1,s),new Le(i,this.wrap,i,n,s+1),new Le(i,this.wrap,i,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 Le(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Le(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 Re(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function je(t,e,i,n,s){const l=1<<Math.min(i,22);let u=l*(s%l)+n%l;return t&&i<22&&(u+=l*l*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*u+i)+(e-i)}const et=[t=>{let e=t.canonical.x-1,i=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,i--),new Le(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,i=t.wrap;return e===1<<t.canonical.z&&(e=0,i++),new Le(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>new Le(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new Le(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)];Ke(Ie,"CanonicalTileID"),Ke(Le,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});function at(t){return Ae*Math.cos(t*Math.PI/180)}function Et(t){return(180+t)/360}function gt(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function bt(t,e){return t/at(e)}function vt(t){return 360*t-180}function Zt(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function _i(t,e){return t*at(Zt(e))}const Ot=85.051129;function Ci(t){return Math.cos(qt(Dt(t,-Ot,Ot)))}function Bt(t,e){const i=Dt(e,0,25.5),n=Math.pow(2,i);return Ci(t)*Ae/(512*n)}function Kt(t){return 1/Math.cos(t*Math.PI/180)}function Ft(t,e=0){const i=Math.exp(Math.PI*(1-(t.y+e/qe)/(1<<t.z)*2));return 80150034*i/(i*i+1)/qe/(1<<t.z)}class Yt{constructor(e,i,n=0){this.x=+e,this.y=+i,this.z=+n}static fromLngLat(e,i=0){const n=ne.convert(e);return new Yt(Et(n.lng),gt(n.lat),bt(i,n.lat))}toLngLat(){return new ne(vt(this.x),Zt(this.y))}toAltitude(){return _i(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ae*Kt(Zt(this.y))}}function yi(t,e,i,n,s,l,u,p,m){const _=(e+n)/2,y=(i+s)/2,v=new Ue(_,y);p(v),function(w,E,A,I,z,L){const N=A-z,G=I-L;return Math.abs((I-E)*N-(A-w)*G)/Math.hypot(N,G)}(v.x,v.y,l.x,l.y,u.x,u.y)>=m?(yi(t,e,i,_,y,l,v,p,m),yi(t,_,y,n,s,v,u,p,m)):t.push(u)}function ii(t,e,i){let n=t[0],s=n.x,l=n.y;e(n);const u=[n];for(let p=1;p<t.length;p++){const m=t[p],{x:_,y}=m;e(m),yi(u,s,l,_,y,n,m,e,i),s=_,l=y,n=m}return u}function Qi(t,e,i,n){if(n(e,i)){const s=e.add(i)._mult(.5);Qi(t,e,s,n),Qi(t,s,i,n)}else t.push(i)}function hr(t,e){let i=t[0];const n=[i];for(let s=1;s<t.length;s++){const l=t[s];Qi(n,i,l,e),i=l}return n}const Pr=Math.pow(2,14)-1,bn=-Pr-1;function zr(t,e){const i=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=Dt(i,bn,Pr),t.y=Dt(n,bn,Pr),(i<t.x||i>t.x+1||n<t.y||n>t.y+1)&&ki("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function er(t,e,i){const n=t.loadGeometry(),s=t.extent,l=qe/s;if(e&&i&&i.projection.isReprojectedInTileSpace){const u=1<<e.z,{scale:p,x:m,y:_,projection:y}=i,v=w=>{const E=vt((e.x+w.x/s)/u),A=Zt((e.y+w.y/s)/u),I=y.project(E,A);w.x=(I.x*p-m)*s,w.y=(I.y*p-_)*s};for(let w=0;w<n.length;w++)if(1!==t.type)n[w]=ii(n[w],v,1);else{const E=[];for(const A of n[w])A.x<0||A.x>=s||A.y<0||A.y>=s||(v(A),E.push(A));n[w]=E}}for(const u of n)for(const p of u)zr(p,l);return n}function Hi(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?er(t):[]}}function yr(t,e,i,n,s){t.emplaceBack(2*e+(n+1)/2,2*i+(s+1)/2)}function Tr(t,e,i){t.emplaceBack(e.x,e.y,e.z,16384*i[0],16384*i[1],16384*i[2])}class Dr{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new cn,this.indexArray=new Ji,this.segments=new Oi,this.programConfigurations=new k(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,s){const l=this.layers[0],u=[];let p=null;"circle"===l.type&&(p=l.layout.get("circle-sort-key"));for(const{feature:_,id:y,index:v,sourceLayerIndex:w}of e){const E=this.layers[0]._featureFilter.needGeometry,A=Hi(_,E);if(!this.layers[0]._featureFilter.filter(new Ai(this.zoom),A,n))continue;const I=p?p.evaluate(A,{},n):void 0,z={id:y,properties:_.properties,type:_.type,sourceLayerIndex:w,index:v,geometry:E?A.geometry:er(_,n,s),patterns:{},sortKey:I};u.push(z)}p&&u.sort((_,y)=>_.sortKey-y.sortKey);let m=null;"globe"===s.projection.name&&(this.globeExtVertexArray=new xl,m=s.projection);for(const _ of u){const{geometry:y,index:v,sourceLayerIndex:w}=_,E=e[v].feature;this.addFeature(_,y,v,i.availableImages,n,m,i.brightness),i.featureIndex.insert(E,y,v,w,this.index)}}update(e,i,n,s,l){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,n,s,l)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,fp.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Nu.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,i,n,s,l,u,p){for(const m of i)for(const _ of m){const y=_.x,v=_.y;if(y<0||y>=qe||v<0||v>=qe)continue;if(u){const A=u.projectTilePoint(y,v,l),I=u.upVector(l,y,v),z=this.globeExtVertexArray;Tr(z,A,I),Tr(z,A,I),Tr(z,A,I),Tr(z,A,I)}const w=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),E=w.vertexLength;yr(this.layoutVertexArray,y,v,-1,-1),yr(this.layoutVertexArray,y,v,1,-1),yr(this.layoutVertexArray,y,v,1,1),yr(this.layoutVertexArray,y,v,-1,1),this.indexArray.emplaceBack(E,E+1,E+2),this.indexArray.emplaceBack(E,E+2,E+3),w.vertexLength+=4,w.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,l,p)}}function wn(t,e){for(let i=0;i<t.length;i++)if(On(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(On(t,e[i]))return!0;return!!za(t,e)}function _o(t,e,i){return!!On(t,e)||!!Da(e,t,i)}function Go(t,e){if(1===t.length)return El(e,t[0]);for(let i=0;i<e.length;i++){const n=e[i];for(let s=0;s<n.length;s++)if(On(t,n[s]))return!0}for(let i=0;i<t.length;i++)if(El(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(za(t,e[i]))return!0;return!1}function Pa(t,e,i){if(t.length>1){if(za(t,e))return!0;for(let n=0;n<e.length;n++)if(Da(e[n],t,i))return!0}for(let n=0;n<t.length;n++)if(Da(t[n],e,i))return!0;return!1}function za(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];for(let l=0;l<e.length-1;l++)if(bh(n,s,e[l],e[l+1]))return!0}return!1}function bh(t,e,i,n){return Gr(t,i,n)!==Gr(e,i,n)&&Gr(t,e,i)!==Gr(t,e,n)}function Da(t,e,i){const n=i*i;if(1===e.length)return t.distSqr(e[0])<n;for(let s=1;s<e.length;s++)if(As(t,e[s-1],e[s])<n)return!0;return!1}function As(t,e,i){const n=e.distSqr(i);if(0===n)return t.distSqr(e);const s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function El(t,e){let i,n,s,l=!1;for(let u=0;u<t.length;u++){i=t[u];for(let p=0,m=i.length-1;p<i.length;m=p++)n=i[p],s=i[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 On(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const 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&&(i=!i)}return i}function Bf(t,e,i,n,s){for(const u of t)if(e<=u.x&&i<=u.y&&n>=u.x&&s>=u.y)return!0;const l=[new Ue(e,i),new Ue(e,s),new Ue(n,s),new Ue(n,i)];if(t.length>2)for(const u of l)if(On(t,u))return!0;for(let u=0;u<t.length-1;u++)if($y(t[u],t[u+1],l))return!0;return!1}function $y(t,e,i){const n=i[0],s=i[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;const l=Gr(t,e,i[0]);return l!==Gr(t,e,i[1])||l!==Gr(t,e,i[2])||l!==Gr(t,e,i[3])}function Sl(t,e,i,n,s,l){let u=e.y-t.y,p=t.x-e.x;if(l=l||0){const m=u*u+p*p;if(0===m)return!0;const _=Math.sqrt(m);u/=_,p/=_}return!((i.x-t.x)*u+(i.y-t.y)*p-l<0||(n.x-t.x)*u+(n.y-t.y)*p-l<0||(s.x-t.x)*u+(s.y-t.y)*p-l<0)}function mp(t,e,i,n,s,l,u){return!(Sl(t,e,n,s,l,u)||Sl(e,i,n,s,l,u)||Sl(i,t,n,s,l,u)||Sl(n,s,t,e,i,u)||Sl(s,l,t,e,i,u)||Sl(l,n,t,e,i,u))}function Al(t,e,i){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Wu(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ff(t,e,i,n,s){if(!e[0]&&!e[1])return t;const l=Ue.convert(e)._mult(s);"viewport"===i&&l._rotate(-n);const u=[];for(let p=0;p<t.length;p++)u.push(t[p].sub(l));return u}function Nf(t,e,i,n){const s=Ue.convert(t)._mult(n);return"viewport"===e&&s._rotate(-i),s}Ke(Dr,"CircleBucket",{omit:["layers"]});const Wy=new Ii({"circle-sort-key":new ht(le.layout_circle["circle-sort-key"]),visibility:new Oe(le.layout_circle.visibility)});var Hy={paint:new Ii({"circle-radius":new ht(le.paint_circle["circle-radius"]),"circle-color":new ht(le.paint_circle["circle-color"]),"circle-blur":new ht(le.paint_circle["circle-blur"]),"circle-opacity":new ht(le.paint_circle["circle-opacity"]),"circle-translate":new Oe(le.paint_circle["circle-translate"]),"circle-translate-anchor":new Oe(le.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Oe(le.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Oe(le.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ht(le.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ht(le.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ht(le.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new Oe(le.paint_circle["circle-emissive-strength"])}),layout:Wy},tr={},ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.setMatrixArrayType=function(t){ir.ARRAY_TYPE=Uf=t},ir.toRadian=function(t){return t*Yy},ir.equals=function(t,e){return Math.abs(t-e)<=Vf*Math.max(1,Math.abs(t),Math.abs(e))},ir.RANDOM=ir.ARRAY_TYPE=ir.EPSILON=void 0;var Vf=1e-6;ir.EPSILON=Vf;var Uf=typeof Float32Array<"u"?Float32Array:Array;ir.ARRAY_TYPE=Uf;var Xy=Math.random;ir.RANDOM=Xy;var Yy=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Pi={};function _p(t){return(_p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.create=function(){var t=new Is.ARRAY_TYPE(4);return Is.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},Pi.clone=function(t){var e=new Is.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Pi.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Pi.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},Pi.fromValues=function(t,e,i,n){var s=new Is.ARRAY_TYPE(4);return s[0]=t,s[1]=e,s[2]=i,s[3]=n,s},Pi.set=function(t,e,i,n,s){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t},Pi.transpose=function(t,e){if(t===e){var i=e[1];t[1]=e[2],t[2]=i}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},Pi.invert=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=i*l-s*n;return u?(t[0]=l*(u=1/u),t[1]=-n*u,t[2]=-s*u,t[3]=i*u,t):null},Pi.adjoint=function(t,e){var i=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=i,t},Pi.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},Pi.multiply=Gf,Pi.rotate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m+l*p,t[1]=s*m+u*p,t[2]=n*-p+l*m,t[3]=s*-p+u*m,t},Pi.scale=function(t,e,i){var n=e[1],s=e[2],l=e[3],u=i[0],p=i[1];return t[0]=e[0]*u,t[1]=n*u,t[2]=s*p,t[3]=l*p,t},Pi.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=-i,t[3]=n,t},Pi.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},Pi.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Pi.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},Pi.LDU=function(t,e,i,n){return t[2]=n[2]/n[0],i[0]=n[0],i[1]=n[1],i[3]=n[3]-t[2]*i[1],[t,e,i]},Pi.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t},Pi.subtract=Zf,Pi.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},Pi.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=e[0],p=e[1],m=e[2],_=e[3];return Math.abs(i-u)<=Is.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(n-p)<=Is.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(s-m)<=Is.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-_)<=Is.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))},Pi.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},Pi.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t},Pi.sub=Pi.mul=void 0;var Is=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==_p(t)&&"function"!=typeof t)return{default:t};var i=jf(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function jf(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(jf=function(n){return n?i:e})(t)}function Gf(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=i[0],m=i[1],_=i[2],y=i[3];return t[0]=n*p+l*m,t[1]=s*p+u*m,t[2]=n*_+l*y,t[3]=s*_+u*y,t}function Zf(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t}Pi.mul=Gf,Pi.sub=Zf;var Li={};function gp(t){return(gp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(Li,"__esModule",{value:!0}),Li.create=function(){var t=new go.ARRAY_TYPE(6);return go.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},Li.clone=function(t){var e=new go.ARRAY_TYPE(6);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},Li.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},Li.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},Li.fromValues=function(t,e,i,n,s,l){var u=new go.ARRAY_TYPE(6);return u[0]=t,u[1]=e,u[2]=i,u[3]=n,u[4]=s,u[5]=l,u},Li.set=function(t,e,i,n,s,l,u){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t[4]=l,t[5]=u,t},Li.invert=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=i*l-n*s;return m?(t[0]=l*(m=1/m),t[1]=-n*m,t[2]=-s*m,t[3]=i*m,t[4]=(s*p-l*u)*m,t[5]=(n*u-i*p)*m,t):null},Li.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},Li.multiply=$f,Li.rotate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=Math.sin(i),y=Math.cos(i);return t[0]=n*y+l*_,t[1]=s*y+u*_,t[2]=n*-_+l*y,t[3]=s*-_+u*y,t[4]=p,t[5]=m,t},Li.scale=function(t,e,i){var n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=i[0],_=i[1];return t[0]=e[0]*m,t[1]=n*m,t[2]=s*_,t[3]=l*_,t[4]=u,t[5]=p,t},Li.translate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=i[0],y=i[1];return t[0]=n,t[1]=s,t[2]=l,t[3]=u,t[4]=n*_+l*y+p,t[5]=s*_+u*y+m,t},Li.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=-i,t[3]=n,t[4]=0,t[5]=0,t},Li.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},Li.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},Li.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},Li.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},Li.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t},Li.subtract=Wf,Li.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t},Li.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t[4]=e[4]+i[4]*n,t[5]=e[5]+i[5]*n,t},Li.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},Li.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=t[4],p=t[5],m=e[0],_=e[1],y=e[2],v=e[3],w=e[4],E=e[5];return Math.abs(i-m)<=go.EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(n-_)<=go.EPSILON*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(s-y)<=go.EPSILON*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(l-v)<=go.EPSILON*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(u-w)<=go.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(p-E)<=go.EPSILON*Math.max(1,Math.abs(p),Math.abs(E))},Li.sub=Li.mul=void 0;var go=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==gp(t)&&"function"!=typeof t)return{default:t};var i=qf(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function qf(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(qf=function(n){return n?i:e})(t)}function $f(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=i[0],y=i[1],v=i[2],w=i[3],E=i[4],A=i[5];return t[0]=n*_+l*y,t[1]=s*_+u*y,t[2]=n*v+l*w,t[3]=s*v+u*w,t[4]=n*E+l*A+p,t[5]=s*E+u*A+m,t}function Wf(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t[4]=e[4]-i[4],t[5]=e[5]-i[5],t}Li.mul=$f,Li.sub=Wf;var fi={};function yp(t){return(yp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(fi,"__esModule",{value:!0}),fi.create=function(){var t=new hn.ARRAY_TYPE(9);return hn.ARRAY_TYPE!=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},fi.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},fi.clone=function(t){var e=new hn.ARRAY_TYPE(9);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},fi.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},fi.fromValues=function(t,e,i,n,s,l,u,p,m){var _=new hn.ARRAY_TYPE(9);return _[0]=t,_[1]=e,_[2]=i,_[3]=n,_[4]=s,_[5]=l,_[6]=u,_[7]=p,_[8]=m,_},fi.set=function(t,e,i,n,s,l,u,p,m,_){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t[4]=l,t[5]=u,t[6]=p,t[7]=m,t[8]=_,t},fi.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fi.transpose=function(t,e){if(t===e){var i=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,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},fi.invert=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],_=e[7],y=e[8],v=y*u-p*_,w=-y*l+p*m,E=_*l-u*m,A=i*v+n*w+s*E;return A?(t[0]=v*(A=1/A),t[1]=(-y*n+s*_)*A,t[2]=(p*n-s*u)*A,t[3]=w*A,t[4]=(y*i-s*m)*A,t[5]=(-p*i+s*l)*A,t[6]=E*A,t[7]=(-_*i+n*m)*A,t[8]=(u*i-n*l)*A,t):null},fi.adjoint=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],_=e[7],y=e[8];return t[0]=u*y-p*_,t[1]=s*_-n*y,t[2]=n*p-s*u,t[3]=p*m-l*y,t[4]=i*y-s*m,t[5]=s*l-i*p,t[6]=l*_-u*m,t[7]=n*m-i*_,t[8]=i*u-n*l,t},fi.determinant=function(t){var e=t[3],i=t[4],n=t[5],s=t[6],l=t[7],u=t[8];return t[0]*(u*i-n*l)+t[1]*(-u*e+n*s)+t[2]*(l*e-i*s)},fi.multiply=Xf,fi.translate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=e[8],w=i[0],E=i[1];return t[0]=n,t[1]=s,t[2]=l,t[3]=u,t[4]=p,t[5]=m,t[6]=w*n+E*u+_,t[7]=w*s+E*p+y,t[8]=w*l+E*m+v,t},fi.rotate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=e[8],w=Math.sin(i),E=Math.cos(i);return t[0]=E*n+w*u,t[1]=E*s+w*p,t[2]=E*l+w*m,t[3]=E*u-w*n,t[4]=E*p-w*s,t[5]=E*m-w*l,t[6]=_,t[7]=y,t[8]=v,t},fi.scale=function(t,e,i){var n=i[0],s=i[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},fi.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},fi.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=0,t[3]=-i,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fi.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fi.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},fi.fromQuat=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=i+i,p=n+n,m=s+s,_=i*u,y=n*u,v=n*p,w=s*u,E=s*p,A=s*m,I=l*u,z=l*p,L=l*m;return t[0]=1-v-A,t[3]=y-L,t[6]=w+z,t[1]=y+L,t[4]=1-_-A,t[7]=E-I,t[2]=w-z,t[5]=E+I,t[8]=1-_-v,t},fi.normalFromMat4=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],_=e[7],y=e[8],v=e[9],w=e[10],E=e[11],A=e[12],I=e[13],z=e[14],L=e[15],N=i*p-n*u,G=i*m-s*u,j=i*_-l*u,X=n*m-s*p,W=n*_-l*p,J=s*_-l*m,ie=y*I-v*A,oe=y*z-w*A,he=y*L-E*A,se=v*z-w*I,_e=v*L-E*I,Me=w*L-E*z,fe=N*Me-G*_e+j*se+X*he-W*oe+J*ie;return fe?(t[0]=(p*Me-m*_e+_*se)*(fe=1/fe),t[1]=(m*he-u*Me-_*oe)*fe,t[2]=(u*_e-p*he+_*ie)*fe,t[3]=(s*_e-n*Me-l*se)*fe,t[4]=(i*Me-s*he+l*oe)*fe,t[5]=(n*he-i*_e-l*ie)*fe,t[6]=(I*J-z*W+L*X)*fe,t[7]=(z*j-A*J-L*G)*fe,t[8]=(A*W-I*j+L*N)*fe,t):null},fi.projection=function(t,e,i){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/i,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},fi.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},fi.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},fi.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t[6]=e[6]+i[6],t[7]=e[7]+i[7],t[8]=e[8]+i[8],t},fi.subtract=Yf,fi.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t},fi.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t[4]=e[4]+i[4]*n,t[5]=e[5]+i[5]*n,t[6]=e[6]+i[6]*n,t[7]=e[7]+i[7]*n,t[8]=e[8]+i[8]*n,t},fi.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]},fi.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=t[4],p=t[5],m=t[6],_=t[7],y=t[8],v=e[0],w=e[1],E=e[2],A=e[3],I=e[4],z=e[5],L=e[6],N=e[7],G=e[8];return Math.abs(i-v)<=hn.EPSILON*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(n-w)<=hn.EPSILON*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(s-E)<=hn.EPSILON*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(l-A)<=hn.EPSILON*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-I)<=hn.EPSILON*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(p-z)<=hn.EPSILON*Math.max(1,Math.abs(p),Math.abs(z))&&Math.abs(m-L)<=hn.EPSILON*Math.max(1,Math.abs(m),Math.abs(L))&&Math.abs(_-N)<=hn.EPSILON*Math.max(1,Math.abs(_),Math.abs(N))&&Math.abs(y-G)<=hn.EPSILON*Math.max(1,Math.abs(y),Math.abs(G))},fi.sub=fi.mul=void 0;var hn=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==yp(t)&&"function"!=typeof t)return{default:t};var i=Hf(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function Hf(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Hf=function(n){return n?i:e})(t)}function Xf(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=e[8],w=i[0],E=i[1],A=i[2],I=i[3],z=i[4],L=i[5],N=i[6],G=i[7],j=i[8];return t[0]=w*n+E*u+A*_,t[1]=w*s+E*p+A*y,t[2]=w*l+E*m+A*v,t[3]=I*n+z*u+L*_,t[4]=I*s+z*p+L*y,t[5]=I*l+z*m+L*v,t[6]=N*n+G*u+j*_,t[7]=N*s+G*p+j*y,t[8]=N*l+G*m+j*v,t}function Yf(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t[4]=e[4]-i[4],t[5]=e[5]-i[5],t[6]=e[6]-i[6],t[7]=e[7]-i[7],t[8]=e[8]-i[8],t}fi.mul=Xf,fi.sub=Yf;var At={};function xp(t){return(xp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(At,"__esModule",{value:!0}),At.create=function(){var t=new Fi.ARRAY_TYPE(16);return Fi.ARRAY_TYPE!=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},At.clone=function(t){var e=new Fi.ARRAY_TYPE(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},At.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},At.fromValues=function(t,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I){var z=new Fi.ARRAY_TYPE(16);return z[0]=t,z[1]=e,z[2]=i,z[3]=n,z[4]=s,z[5]=l,z[6]=u,z[7]=p,z[8]=m,z[9]=_,z[10]=y,z[11]=v,z[12]=w,z[13]=E,z[14]=A,z[15]=I,z},At.set=function(t,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t[4]=l,t[5]=u,t[6]=p,t[7]=m,t[8]=_,t[9]=y,t[10]=v,t[11]=w,t[12]=E,t[13]=A,t[14]=I,t[15]=z,t},At.identity=Jf,At.transpose=function(t,e){if(t===e){var i=e[1],n=e[2],s=e[3],l=e[6],u=e[7],p=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=l,t[11]=e[14],t[12]=s,t[13]=u,t[14]=p}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},At.invert=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],_=e[7],y=e[8],v=e[9],w=e[10],E=e[11],A=e[12],I=e[13],z=e[14],L=e[15],N=i*p-n*u,G=i*m-s*u,j=i*_-l*u,X=n*m-s*p,W=n*_-l*p,J=s*_-l*m,ie=y*I-v*A,oe=y*z-w*A,he=y*L-E*A,se=v*z-w*I,_e=v*L-E*I,Me=w*L-E*z,fe=N*Me-G*_e+j*se+X*he-W*oe+J*ie;return fe?(t[0]=(p*Me-m*_e+_*se)*(fe=1/fe),t[1]=(s*_e-n*Me-l*se)*fe,t[2]=(I*J-z*W+L*X)*fe,t[3]=(w*W-v*J-E*X)*fe,t[4]=(m*he-u*Me-_*oe)*fe,t[5]=(i*Me-s*he+l*oe)*fe,t[6]=(z*j-A*J-L*G)*fe,t[7]=(y*J-w*j+E*G)*fe,t[8]=(u*_e-p*he+_*ie)*fe,t[9]=(n*he-i*_e-l*ie)*fe,t[10]=(A*W-I*j+L*N)*fe,t[11]=(v*j-y*W-E*N)*fe,t[12]=(p*oe-u*se-m*ie)*fe,t[13]=(i*se-n*oe+s*ie)*fe,t[14]=(I*G-A*X-z*N)*fe,t[15]=(y*X-v*G+w*N)*fe,t):null},At.adjoint=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=e[4],p=e[5],m=e[6],_=e[7],y=e[8],v=e[9],w=e[10],E=e[11],A=e[12],I=e[13],z=e[14],L=e[15];return t[0]=p*(w*L-E*z)-v*(m*L-_*z)+I*(m*E-_*w),t[1]=-(n*(w*L-E*z)-v*(s*L-l*z)+I*(s*E-l*w)),t[2]=n*(m*L-_*z)-p*(s*L-l*z)+I*(s*_-l*m),t[3]=-(n*(m*E-_*w)-p*(s*E-l*w)+v*(s*_-l*m)),t[4]=-(u*(w*L-E*z)-y*(m*L-_*z)+A*(m*E-_*w)),t[5]=i*(w*L-E*z)-y*(s*L-l*z)+A*(s*E-l*w),t[6]=-(i*(m*L-_*z)-u*(s*L-l*z)+A*(s*_-l*m)),t[7]=i*(m*E-_*w)-u*(s*E-l*w)+y*(s*_-l*m),t[8]=u*(v*L-E*I)-y*(p*L-_*I)+A*(p*E-_*v),t[9]=-(i*(v*L-E*I)-y*(n*L-l*I)+A*(n*E-l*v)),t[10]=i*(p*L-_*I)-u*(n*L-l*I)+A*(n*_-l*p),t[11]=-(i*(p*E-_*v)-u*(n*E-l*v)+y*(n*_-l*p)),t[12]=-(u*(v*z-w*I)-y*(p*z-m*I)+A*(p*w-m*v)),t[13]=i*(v*z-w*I)-y*(n*z-s*I)+A*(n*w-s*v),t[14]=-(i*(p*z-m*I)-u*(n*z-s*I)+A*(n*m-s*p)),t[15]=i*(p*w-m*v)-u*(n*w-s*v)+y*(n*m-s*p),t},At.determinant=function(t){var e=t[0],i=t[1],n=t[2],s=t[3],l=t[4],u=t[5],p=t[6],m=t[7],_=t[8],y=t[9],v=t[10],w=t[11],E=t[12],A=t[13],I=t[14],z=t[15];return(e*u-i*l)*(v*z-w*I)-(e*p-n*l)*(y*z-w*A)+(e*m-s*l)*(y*I-v*A)+(i*p-n*u)*(_*z-w*E)-(i*m-s*u)*(_*I-v*E)+(n*m-s*p)*(_*A-y*E)},At.multiply=Qf,At.translate=function(t,e,i){var n,s,l,u,p,m,_,y,v,w,E,A,I=i[0],z=i[1],L=i[2];return e===t?(t[12]=e[0]*I+e[4]*z+e[8]*L+e[12],t[13]=e[1]*I+e[5]*z+e[9]*L+e[13],t[14]=e[2]*I+e[6]*z+e[10]*L+e[14],t[15]=e[3]*I+e[7]*z+e[11]*L+e[15]):(s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=e[8],w=e[9],E=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]=_,t[7]=y,t[8]=v,t[9]=w,t[10]=E,t[11]=A,t[12]=n*I+p*z+v*L+e[12],t[13]=s*I+m*z+w*L+e[13],t[14]=l*I+_*z+E*L+e[14],t[15]=u*I+y*z+A*L+e[15]),t},At.scale=function(t,e,i){var n=i[0],s=i[1],l=i[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},At.rotate=function(t,e,i,n){var s,l,u,p,m,_,y,v,w,E,A,I,z,L,N,G,j,X,W,J,ie,oe,he,se,_e=n[0],Me=n[1],fe=n[2],we=Math.hypot(_e,Me,fe);return we<Fi.EPSILON?null:(_e*=we=1/we,Me*=we,fe*=we,s=Math.sin(i),l=Math.cos(i),m=e[1],_=e[2],y=e[3],w=e[5],E=e[6],A=e[7],z=e[9],L=e[10],N=e[11],G=_e*_e*(u=1-l)+l,W=_e*Me*u-fe*s,J=Me*Me*u+l,ie=fe*Me*u+_e*s,oe=_e*fe*u+Me*s,he=Me*fe*u-_e*s,se=fe*fe*u+l,t[0]=(p=e[0])*G+(v=e[4])*(j=Me*_e*u+fe*s)+(I=e[8])*(X=fe*_e*u-Me*s),t[1]=m*G+w*j+z*X,t[2]=_*G+E*j+L*X,t[3]=y*G+A*j+N*X,t[4]=p*W+v*J+I*ie,t[5]=m*W+w*J+z*ie,t[6]=_*W+E*J+L*ie,t[7]=y*W+A*J+N*ie,t[8]=p*oe+v*he+I*se,t[9]=m*oe+w*he+z*se,t[10]=_*oe+E*he+L*se,t[11]=y*oe+A*he+N*se,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},At.rotateX=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),l=e[4],u=e[5],p=e[6],m=e[7],_=e[8],y=e[9],v=e[10],w=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+_*n,t[5]=u*s+y*n,t[6]=p*s+v*n,t[7]=m*s+w*n,t[8]=_*s-l*n,t[9]=y*s-u*n,t[10]=v*s-p*n,t[11]=w*s-m*n,t},At.rotateY=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],m=e[3],_=e[8],y=e[9],v=e[10],w=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-_*n,t[1]=u*s-y*n,t[2]=p*s-v*n,t[3]=m*s-w*n,t[8]=l*n+_*s,t[9]=u*n+y*s,t[10]=p*n+v*s,t[11]=m*n+w*s,t},At.rotateZ=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],m=e[3],_=e[4],y=e[5],v=e[6],w=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+_*n,t[1]=u*s+y*n,t[2]=p*s+v*n,t[3]=m*s+w*n,t[4]=_*s-l*n,t[5]=y*s-u*n,t[6]=v*s-p*n,t[7]=w*s-m*n,t},At.fromTranslation=function(t,e){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]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t},At.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},At.fromRotation=function(t,e,i){var n,s,l,u=i[0],p=i[1],m=i[2],_=Math.hypot(u,p,m);return _<Fi.EPSILON?null:(u*=_=1/_,p*=_,m*=_,n=Math.sin(e),s=Math.cos(e),t[0]=u*u*(l=1-s)+s,t[1]=p*u*l+m*n,t[2]=m*u*l-p*n,t[3]=0,t[4]=u*p*l-m*n,t[5]=p*p*l+s,t[6]=m*p*l+u*n,t[7]=0,t[8]=u*m*l+p*n,t[9]=p*m*l-u*n,t[10]=m*m*l+s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},At.fromXRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=i,t[7]=0,t[8]=0,t[9]=-i,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},At.fromYRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-i,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=i,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},At.fromZRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=0,t[3]=0,t[4]=-i,t[5]=n,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},At.fromRotationTranslation=em,At.fromQuat2=function(t,e){var i=new Fi.ARRAY_TYPE(3),n=-e[0],s=-e[1],l=-e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=n*n+s*s+l*l+u*u;return v>0?(i[0]=2*(p*u+y*n+m*l-_*s)/v,i[1]=2*(m*u+y*s+_*n-p*l)/v,i[2]=2*(_*u+y*l+p*s-m*n)/v):(i[0]=2*(p*u+y*n+m*l-_*s),i[1]=2*(m*u+y*s+_*n-p*l),i[2]=2*(_*u+y*l+p*s-m*n)),em(t,e,i),t},At.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},At.getScaling=tm,At.getRotation=function(t,e){var i=new Fi.ARRAY_TYPE(3);tm(i,e);var n=1/i[0],s=1/i[1],l=1/i[2],u=e[0]*n,p=e[1]*s,m=e[2]*l,_=e[4]*n,y=e[5]*s,v=e[6]*l,w=e[8]*n,E=e[9]*s,A=e[10]*l,I=u+y+A,z=0;return I>0?(z=2*Math.sqrt(I+1),t[3]=.25*z,t[0]=(v-E)/z,t[1]=(w-m)/z,t[2]=(p-_)/z):u>y&&u>A?(z=2*Math.sqrt(1+u-y-A),t[3]=(v-E)/z,t[0]=.25*z,t[1]=(p+_)/z,t[2]=(w+m)/z):y>A?(z=2*Math.sqrt(1+y-u-A),t[3]=(w-m)/z,t[0]=(p+_)/z,t[1]=.25*z,t[2]=(v+E)/z):(z=2*Math.sqrt(1+A-u-y),t[3]=(p-_)/z,t[0]=(w+m)/z,t[1]=(v+E)/z,t[2]=.25*z),t},At.fromRotationTranslationScale=function(t,e,i,n){var s=e[0],l=e[1],u=e[2],p=e[3],m=s+s,_=l+l,y=u+u,v=s*m,w=s*_,E=s*y,A=l*_,I=l*y,z=u*y,L=p*m,N=p*_,G=p*y,j=n[0],X=n[1],W=n[2];return t[0]=(1-(A+z))*j,t[1]=(w+G)*j,t[2]=(E-N)*j,t[3]=0,t[4]=(w-G)*X,t[5]=(1-(v+z))*X,t[6]=(I+L)*X,t[7]=0,t[8]=(E+N)*W,t[9]=(I-L)*W,t[10]=(1-(v+A))*W,t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t},At.fromRotationTranslationScaleOrigin=function(t,e,i,n,s){var l=e[0],u=e[1],p=e[2],m=e[3],_=l+l,y=u+u,v=p+p,w=l*_,E=l*y,A=l*v,I=u*y,z=u*v,L=p*v,N=m*_,G=m*y,j=m*v,X=n[0],W=n[1],J=n[2],ie=s[0],oe=s[1],he=s[2],se=(1-(I+L))*X,_e=(E+j)*X,Me=(A-G)*X,fe=(E-j)*W,we=(1-(w+L))*W,de=(z+N)*W,be=(A+G)*J,Fe=(z-N)*J,Se=(1-(w+I))*J;return t[0]=se,t[1]=_e,t[2]=Me,t[3]=0,t[4]=fe,t[5]=we,t[6]=de,t[7]=0,t[8]=be,t[9]=Fe,t[10]=Se,t[11]=0,t[12]=i[0]+ie-(se*ie+fe*oe+be*he),t[13]=i[1]+oe-(_e*ie+we*oe+Fe*he),t[14]=i[2]+he-(Me*ie+de*oe+Se*he),t[15]=1,t},At.fromQuat=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=i+i,p=n+n,m=s+s,_=i*u,y=n*u,v=n*p,w=s*u,E=s*p,A=s*m,I=l*u,z=l*p,L=l*m;return t[0]=1-v-A,t[1]=y+L,t[2]=w-z,t[3]=0,t[4]=y-L,t[5]=1-_-A,t[6]=E+I,t[7]=0,t[8]=w+z,t[9]=E-I,t[10]=1-_-v,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},At.frustum=function(t,e,i,n,s,l,u){var p=1/(i-e),m=1/(s-n),_=1/(l-u);return t[0]=2*l*p,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*l*m,t[6]=0,t[7]=0,t[8]=(i+e)*p,t[9]=(s+n)*m,t[10]=(u+l)*_,t[11]=-1,t[12]=0,t[13]=0,t[14]=u*l*2*_,t[15]=0,t},At.perspectiveNO=im,At.perspectiveZO=function(t,e,i,n,s){var l,u=1/Math.tan(e/2);return t[0]=u/i,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,null!=s&&s!==1/0?(t[10]=s*(l=1/(n-s)),t[14]=s*n*l):(t[10]=-1,t[14]=-n),t},At.perspectiveFromFieldOfView=function(t,e,i,n){var s=Math.tan(e.upDegrees*Math.PI/180),l=Math.tan(e.downDegrees*Math.PI/180),u=Math.tan(e.leftDegrees*Math.PI/180),p=Math.tan(e.rightDegrees*Math.PI/180),m=2/(u+p),_=2/(s+l);return t[0]=m,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=_,t[6]=0,t[7]=0,t[8]=-(u-p)*m*.5,t[9]=(s-l)*_*.5,t[10]=n/(i-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*i/(i-n),t[15]=0,t},At.orthoNO=rm,At.orthoZO=function(t,e,i,n,s,l,u){var p=1/(e-i),m=1/(n-s),_=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]=_,t[11]=0,t[12]=(e+i)*p,t[13]=(s+n)*m,t[14]=l*_,t[15]=1,t},At.lookAt=function(t,e,i,n){var s,l,u,p,m,_,y,v,w,E,A=e[0],I=e[1],z=e[2],L=n[0],N=n[1],G=n[2],j=i[0],X=i[1],W=i[2];return Math.abs(A-j)<Fi.EPSILON&&Math.abs(I-X)<Fi.EPSILON&&Math.abs(z-W)<Fi.EPSILON?Jf(t):(y=A-j,v=I-X,w=z-W,s=N*(w*=E=1/Math.hypot(y,v,w))-G*(v*=E),l=G*(y*=E)-L*w,u=L*v-N*y,(E=Math.hypot(s,l,u))?(s*=E=1/E,l*=E,u*=E):(s=0,l=0,u=0),p=v*u-w*l,m=w*s-y*u,_=y*l-v*s,(E=Math.hypot(p,m,_))?(p*=E=1/E,m*=E,_*=E):(p=0,m=0,_=0),t[0]=s,t[1]=p,t[2]=y,t[3]=0,t[4]=l,t[5]=m,t[6]=v,t[7]=0,t[8]=u,t[9]=_,t[10]=w,t[11]=0,t[12]=-(s*A+l*I+u*z),t[13]=-(p*A+m*I+_*z),t[14]=-(y*A+v*I+w*z),t[15]=1,t)},At.targetTo=function(t,e,i,n){var s=e[0],l=e[1],u=e[2],p=n[0],m=n[1],_=n[2],y=s-i[0],v=l-i[1],w=u-i[2],E=y*y+v*v+w*w;E>0&&(y*=E=1/Math.sqrt(E),v*=E,w*=E);var A=m*w-_*v,I=_*y-p*w,z=p*v-m*y;return(E=A*A+I*I+z*z)>0&&(A*=E=1/Math.sqrt(E),I*=E,z*=E),t[0]=A,t[1]=I,t[2]=z,t[3]=0,t[4]=v*z-w*I,t[5]=w*A-y*z,t[6]=y*I-v*A,t[7]=0,t[8]=y,t[9]=v,t[10]=w,t[11]=0,t[12]=s,t[13]=l,t[14]=u,t[15]=1,t},At.str=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},At.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},At.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t[6]=e[6]+i[6],t[7]=e[7]+i[7],t[8]=e[8]+i[8],t[9]=e[9]+i[9],t[10]=e[10]+i[10],t[11]=e[11]+i[11],t[12]=e[12]+i[12],t[13]=e[13]+i[13],t[14]=e[14]+i[14],t[15]=e[15]+i[15],t},At.subtract=nm,At.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12]*i,t[13]=e[13]*i,t[14]=e[14]*i,t[15]=e[15]*i,t},At.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t[4]=e[4]+i[4]*n,t[5]=e[5]+i[5]*n,t[6]=e[6]+i[6]*n,t[7]=e[7]+i[7]*n,t[8]=e[8]+i[8]*n,t[9]=e[9]+i[9]*n,t[10]=e[10]+i[10]*n,t[11]=e[11]+i[11]*n,t[12]=e[12]+i[12]*n,t[13]=e[13]+i[13]*n,t[14]=e[14]+i[14]*n,t[15]=e[15]+i[15]*n,t},At.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},At.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=t[4],p=t[5],m=t[6],_=t[7],y=t[8],v=t[9],w=t[10],E=t[11],A=t[12],I=t[13],z=t[14],L=t[15],N=e[0],G=e[1],j=e[2],X=e[3],W=e[4],J=e[5],ie=e[6],oe=e[7],he=e[8],se=e[9],_e=e[10],Me=e[11],fe=e[12],we=e[13],de=e[14],be=e[15];return Math.abs(i-N)<=Fi.EPSILON*Math.max(1,Math.abs(i),Math.abs(N))&&Math.abs(n-G)<=Fi.EPSILON*Math.max(1,Math.abs(n),Math.abs(G))&&Math.abs(s-j)<=Fi.EPSILON*Math.max(1,Math.abs(s),Math.abs(j))&&Math.abs(l-X)<=Fi.EPSILON*Math.max(1,Math.abs(l),Math.abs(X))&&Math.abs(u-W)<=Fi.EPSILON*Math.max(1,Math.abs(u),Math.abs(W))&&Math.abs(p-J)<=Fi.EPSILON*Math.max(1,Math.abs(p),Math.abs(J))&&Math.abs(m-ie)<=Fi.EPSILON*Math.max(1,Math.abs(m),Math.abs(ie))&&Math.abs(_-oe)<=Fi.EPSILON*Math.max(1,Math.abs(_),Math.abs(oe))&&Math.abs(y-he)<=Fi.EPSILON*Math.max(1,Math.abs(y),Math.abs(he))&&Math.abs(v-se)<=Fi.EPSILON*Math.max(1,Math.abs(v),Math.abs(se))&&Math.abs(w-_e)<=Fi.EPSILON*Math.max(1,Math.abs(w),Math.abs(_e))&&Math.abs(E-Me)<=Fi.EPSILON*Math.max(1,Math.abs(E),Math.abs(Me))&&Math.abs(A-fe)<=Fi.EPSILON*Math.max(1,Math.abs(A),Math.abs(fe))&&Math.abs(I-we)<=Fi.EPSILON*Math.max(1,Math.abs(I),Math.abs(we))&&Math.abs(z-de)<=Fi.EPSILON*Math.max(1,Math.abs(z),Math.abs(de))&&Math.abs(L-be)<=Fi.EPSILON*Math.max(1,Math.abs(L),Math.abs(be))},At.sub=At.mul=At.ortho=At.perspective=void 0;var Fi=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==xp(t)&&"function"!=typeof t)return{default:t};var i=Kf(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function Kf(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Kf=function(n){return n?i:e})(t)}function Jf(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 Qf(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=e[8],w=e[9],E=e[10],A=e[11],I=e[12],z=e[13],L=e[14],N=e[15],G=i[0],j=i[1],X=i[2],W=i[3];return t[0]=G*n+j*p+X*v+W*I,t[1]=G*s+j*m+X*w+W*z,t[2]=G*l+j*_+X*E+W*L,t[3]=G*u+j*y+X*A+W*N,t[4]=(G=i[4])*n+(j=i[5])*p+(X=i[6])*v+(W=i[7])*I,t[5]=G*s+j*m+X*w+W*z,t[6]=G*l+j*_+X*E+W*L,t[7]=G*u+j*y+X*A+W*N,t[8]=(G=i[8])*n+(j=i[9])*p+(X=i[10])*v+(W=i[11])*I,t[9]=G*s+j*m+X*w+W*z,t[10]=G*l+j*_+X*E+W*L,t[11]=G*u+j*y+X*A+W*N,t[12]=(G=i[12])*n+(j=i[13])*p+(X=i[14])*v+(W=i[15])*I,t[13]=G*s+j*m+X*w+W*z,t[14]=G*l+j*_+X*E+W*L,t[15]=G*u+j*y+X*A+W*N,t}function em(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=n+n,m=s+s,_=l+l,y=n*p,v=n*m,w=n*_,E=s*m,A=s*_,I=l*_,z=u*p,L=u*m,N=u*_;return t[0]=1-(E+I),t[1]=v+N,t[2]=w-L,t[3]=0,t[4]=v-N,t[5]=1-(y+I),t[6]=A+z,t[7]=0,t[8]=w+L,t[9]=A-z,t[10]=1-(y+E),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t}function tm(t,e){var i=e[4],n=e[5],s=e[6],l=e[8],u=e[9],p=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(i,n,s),t[2]=Math.hypot(l,u,p),t}function im(t,e,i,n,s){var l,u=1/Math.tan(e/2);return t[0]=u/i,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,null!=s&&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}function rm(t,e,i,n,s,l,u){var p=1/(e-i),m=1/(n-s),_=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*_,t[11]=0,t[12]=(e+i)*p,t[13]=(s+n)*m,t[14]=(u+l)*_,t[15]=1,t}function nm(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t[4]=e[4]-i[4],t[5]=e[5]-i[5],t[6]=e[6]-i[6],t[7]=e[7]-i[7],t[8]=e[8]-i[8],t[9]=e[9]-i[9],t[10]=e[10]-i[10],t[11]=e[11]-i[11],t[12]=e[12]-i[12],t[13]=e[13]-i[13],t[14]=e[14]-i[14],t[15]=e[15]-i[15],t}At.perspective=im,At.ortho=rm,At.mul=Qf,At.sub=nm;var Tt={},St={};function vp(t){return(vp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(St,"__esModule",{value:!0}),St.create=sm,St.clone=function(t){var e=new Zo.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},St.length=am,St.fromValues=function(t,e,i){var n=new Zo.ARRAY_TYPE(3);return n[0]=t,n[1]=e,n[2]=i,n},St.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},St.set=function(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t},St.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t},St.subtract=lm,St.multiply=cm,St.divide=hm,St.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},St.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},St.min=function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t},St.max=function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t},St.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},St.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},St.scaleAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t},St.distance=um,St.squaredDistance=dm,St.squaredLength=pm,St.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},St.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},St.normalize=function(t,e){var i=e[0],n=e[1],s=e[2],l=i*i+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},St.dot=fm,St.cross=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=i[0],p=i[1],m=i[2];return t[0]=s*m-l*p,t[1]=l*u-n*m,t[2]=n*p-s*u,t},St.lerp=function(t,e,i,n){var s=e[0],l=e[1],u=e[2];return t[0]=s+n*(i[0]-s),t[1]=l+n*(i[1]-l),t[2]=u+n*(i[2]-u),t},St.hermite=function(t,e,i,n,s,l){var u=l*l,p=u*(2*l-3)+1,m=u*(l-2)+l,_=u*(l-1),y=u*(3-2*l);return t[0]=e[0]*p+i[0]*m+n[0]*_+s[0]*y,t[1]=e[1]*p+i[1]*m+n[1]*_+s[1]*y,t[2]=e[2]*p+i[2]*m+n[2]*_+s[2]*y,t},St.bezier=function(t,e,i,n,s,l){var u=1-l,p=u*u,m=l*l,_=p*u,y=3*l*p,v=3*m*u,w=m*l;return t[0]=e[0]*_+i[0]*y+n[0]*v+s[0]*w,t[1]=e[1]*_+i[1]*y+n[1]*v+s[1]*w,t[2]=e[2]*_+i[2]*y+n[2]*v+s[2]*w,t},St.random=function(t,e){e=e||1;var i=2*Zo.RANDOM()*Math.PI,n=2*Zo.RANDOM()-1,s=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(i)*s,t[1]=Math.sin(i)*s,t[2]=n*e,t},St.transformMat4=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=i[3]*n+i[7]*s+i[11]*l+i[15];return t[0]=(i[0]*n+i[4]*s+i[8]*l+i[12])/(u=u||1),t[1]=(i[1]*n+i[5]*s+i[9]*l+i[13])/u,t[2]=(i[2]*n+i[6]*s+i[10]*l+i[14])/u,t},St.transformMat3=function(t,e,i){var n=e[0],s=e[1],l=e[2];return t[0]=n*i[0]+s*i[3]+l*i[6],t[1]=n*i[1]+s*i[4]+l*i[7],t[2]=n*i[2]+s*i[5]+l*i[8],t},St.transformQuat=function(t,e,i){var n=i[0],s=i[1],l=i[2],u=e[0],p=e[1],m=e[2],_=s*m-l*p,y=l*u-n*m,v=n*p-s*u,w=s*v-l*y,E=l*_-n*v,A=n*y-s*_,I=2*i[3];return y*=I,v*=I,E*=2,A*=2,t[0]=u+(_*=I)+(w*=2),t[1]=p+y+E,t[2]=m+v+A,t},St.rotateX=function(t,e,i,n){var s=[],l=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],l[0]=s[0],l[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),l[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=l[0]+i[0],t[1]=l[1]+i[1],t[2]=l[2]+i[2],t},St.rotateY=function(t,e,i,n){var s=[],l=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],l[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),l[1]=s[1],l[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=l[0]+i[0],t[1]=l[1]+i[1],t[2]=l[2]+i[2],t},St.rotateZ=function(t,e,i,n){var s=[],l=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],l[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),l[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),l[2]=s[2],t[0]=l[0]+i[0],t[1]=l[1]+i[1],t[2]=l[2]+i[2],t},St.angle=function(t,e){var i=t[0],n=t[1],s=t[2],l=e[0],u=e[1],p=e[2],m=Math.sqrt(i*i+n*n+s*s)*Math.sqrt(l*l+u*u+p*p),_=m&&fm(t,e)/m;return Math.acos(Math.min(Math.max(_,-1),1))},St.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},St.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},St.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},St.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=e[0],u=e[1],p=e[2];return Math.abs(i-l)<=Zo.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-u)<=Zo.EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(s-p)<=Zo.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))},St.forEach=St.sqrLen=St.len=St.sqrDist=St.dist=St.div=St.mul=St.sub=void 0;var Zo=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==vp(t)&&"function"!=typeof t)return{default:t};var i=om(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function om(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(om=function(n){return n?i:e})(t)}function sm(){var t=new Zo.ARRAY_TYPE(3);return Zo.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function am(t){return Math.hypot(t[0],t[1],t[2])}function lm(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function cm(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function hm(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t}function um(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function dm(t,e){var i=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2];return i*i+n*n+s*s}function pm(t){var e=t[0],i=t[1],n=t[2];return e*e+i*i+n*n}function fm(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}St.sub=lm,St.mul=cm,St.div=hm,St.dist=um,St.sqrDist=dm,St.len=am,St.sqrLen=pm;var qo,Ky=(qo=sm(),function(t,e,i,n,s,l){var u,p;for(e||(e=3),i||(i=0),p=n?Math.min(n*e+i,t.length):t.length,u=i;u<p;u+=e)qo[0]=t[u],qo[1]=t[u+1],qo[2]=t[u+2],s(qo,qo,l),t[u]=qo[0],t[u+1]=qo[1],t[u+2]=qo[2];return t});St.forEach=Ky;var Nt={};function bp(t){return(bp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.create=_m,Nt.clone=function(t){var e=new Tn.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Nt.fromValues=function(t,e,i,n){var s=new Tn.ARRAY_TYPE(4);return s[0]=t,s[1]=e,s[2]=i,s[3]=n,s},Nt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Nt.set=function(t,e,i,n,s){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t},Nt.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t},Nt.subtract=gm,Nt.multiply=ym,Nt.divide=xm,Nt.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},Nt.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},Nt.min=function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t[3]=Math.min(e[3],i[3]),t},Nt.max=function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t[3]=Math.max(e[3],i[3]),t},Nt.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},Nt.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},Nt.scaleAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t},Nt.distance=vm,Nt.squaredDistance=bm,Nt.length=wm,Nt.squaredLength=Tm,Nt.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},Nt.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},Nt.normalize=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=i*i+n*n+s*s+l*l;return u>0&&(u=1/Math.sqrt(u)),t[0]=i*u,t[1]=n*u,t[2]=s*u,t[3]=l*u,t},Nt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Nt.cross=function(t,e,i,n){var s=i[0]*n[1]-i[1]*n[0],l=i[0]*n[2]-i[2]*n[0],u=i[0]*n[3]-i[3]*n[0],p=i[1]*n[2]-i[2]*n[1],m=i[1]*n[3]-i[3]*n[1],_=i[2]*n[3]-i[3]*n[2],y=e[0],v=e[1],w=e[2],E=e[3];return t[0]=v*_-w*m+E*p,t[1]=-y*_+w*u-E*l,t[2]=y*m-v*u+E*s,t[3]=-y*p+v*l-w*s,t},Nt.lerp=function(t,e,i,n){var s=e[0],l=e[1],u=e[2],p=e[3];return t[0]=s+n*(i[0]-s),t[1]=l+n*(i[1]-l),t[2]=u+n*(i[2]-u),t[3]=p+n*(i[3]-p),t},Nt.random=function(t,e){var i,n,s,l,u,p;e=e||1;do{u=(i=2*Tn.RANDOM()-1)*i+(n=2*Tn.RANDOM()-1)*n}while(u>=1);do{p=(s=2*Tn.RANDOM()-1)*s+(l=2*Tn.RANDOM()-1)*l}while(p>=1);var m=Math.sqrt((1-u)/p);return t[0]=e*i,t[1]=e*n,t[2]=e*s*m,t[3]=e*l*m,t},Nt.transformMat4=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3];return t[0]=i[0]*n+i[4]*s+i[8]*l+i[12]*u,t[1]=i[1]*n+i[5]*s+i[9]*l+i[13]*u,t[2]=i[2]*n+i[6]*s+i[10]*l+i[14]*u,t[3]=i[3]*n+i[7]*s+i[11]*l+i[15]*u,t},Nt.transformQuat=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=i[0],p=i[1],m=i[2],_=i[3],y=_*n+p*l-m*s,v=_*s+m*n-u*l,w=_*l+u*s-p*n,E=-u*n-p*s-m*l;return t[0]=y*_+E*-u+v*-m-w*-p,t[1]=v*_+E*-p+w*-u-y*-m,t[2]=w*_+E*-m+y*-p-v*-u,t[3]=e[3],t},Nt.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},Nt.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Nt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},Nt.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=e[0],p=e[1],m=e[2],_=e[3];return Math.abs(i-u)<=Tn.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(n-p)<=Tn.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(s-m)<=Tn.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-_)<=Tn.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))},Nt.forEach=Nt.sqrLen=Nt.len=Nt.sqrDist=Nt.dist=Nt.div=Nt.mul=Nt.sub=void 0;var Tn=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==bp(t)&&"function"!=typeof t)return{default:t};var i=mm(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function mm(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(mm=function(n){return n?i:e})(t)}function _m(){var t=new Tn.ARRAY_TYPE(4);return Tn.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function gm(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t}function ym(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}function xm(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t[3]=e[3]/i[3],t}function vm(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function bm(t,e){var i=e[0]-t[0],n=e[1]-t[1],s=e[2]-t[2],l=e[3]-t[3];return i*i+n*n+s*s+l*l}function wm(t){return Math.hypot(t[0],t[1],t[2],t[3])}function Tm(t){var e=t[0],i=t[1],n=t[2],s=t[3];return e*e+i*i+n*n+s*s}Nt.sub=gm,Nt.mul=ym,Nt.div=xm,Nt.dist=vm,Nt.sqrDist=bm,Nt.len=wm,Nt.sqrLen=Tm;var Jy=function(){var t=_m();return function(e,i,n,s,l,u){var p,m;for(i||(i=4),n||(n=0),m=s?Math.min(s*i+n,e.length):e.length,p=n;p<m;p+=i)t[0]=e[p],t[1]=e[p+1],t[2]=e[p+2],t[3]=e[p+3],l(t,t,u),e[p]=t[0],e[p+1]=t[1],e[p+2]=t[2],e[p+3]=t[3];return e}}();function wp(t){return(wp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Nt.forEach=Jy,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.create=Tp,Tt.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},Tt.setAxisAngle=Em,Tt.getAxisAngle=function(t,e){var i=2*Math.acos(e[3]),n=Math.sin(i/2);return n>La.EPSILON?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),i},Tt.getAngle=function(t,e){var i=zm(t,e);return Math.acos(2*i*i-1)},Tt.multiply=Sm,Tt.rotateX=function(t,e,i){i*=.5;var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);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},Tt.rotateY=function(t,e,i){i*=.5;var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m-l*p,t[1]=s*m+u*p,t[2]=l*m+n*p,t[3]=u*m-s*p,t},Tt.rotateZ=function(t,e,i){i*=.5;var n=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);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},Tt.calculateW=function(t,e){var i=e[0],n=e[1],s=e[2];return t[0]=i,t[1]=n,t[2]=s,t[3]=Math.sqrt(Math.abs(1-i*i-n*n-s*s)),t},Tt.exp=Am,Tt.ln=Im,Tt.pow=function(t,e,i){return Im(t,e),Pm(t,t,i),Am(t,t),t},Tt.slerp=Xu,Tt.random=function(t){var e=La.RANDOM(),i=La.RANDOM(),n=La.RANDOM(),s=Math.sqrt(1-e),l=Math.sqrt(e);return t[0]=s*Math.sin(2*Math.PI*i),t[1]=s*Math.cos(2*Math.PI*i),t[2]=l*Math.sin(2*Math.PI*n),t[3]=l*Math.cos(2*Math.PI*n),t},Tt.invert=function(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=i*i+n*n+s*s+l*l,p=u?1/u:0;return t[0]=-i*p,t[1]=-n*p,t[2]=-s*p,t[3]=l*p,t},Tt.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Tt.fromMat3=Cm,Tt.fromEuler=function(t,e,i,n){var s=.5*Math.PI/180;e*=s,i*=s,n*=s;var l=Math.sin(e),u=Math.cos(e),p=Math.sin(i),m=Math.cos(i),_=Math.sin(n),y=Math.cos(n);return t[0]=l*m*y-u*p*_,t[1]=u*p*y+l*m*_,t[2]=u*m*_-l*p*y,t[3]=u*m*y+l*p*_,t},Tt.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Tt.setAxes=Tt.sqlerp=Tt.rotationTo=Tt.equals=Tt.exactEquals=Tt.normalize=Tt.sqrLen=Tt.squaredLength=Tt.len=Tt.length=Tt.lerp=Tt.dot=Tt.scale=Tt.mul=Tt.add=Tt.set=Tt.copy=Tt.fromValues=Tt.clone=void 0;var La=Hu(ir),Qy=Hu(fi),$o=Hu(St),un=Hu(Nt);function Mm(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Mm=function(n){return n?i:e})(t)}function Hu(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==wp(t)&&"function"!=typeof t)return{default:t};var i=Mm(e);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}function Tp(){var t=new La.ARRAY_TYPE(4);return La.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Em(t,e,i){i*=.5;var n=Math.sin(i);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(i),t}function Sm(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=i[0],m=i[1],_=i[2],y=i[3];return t[0]=n*y+u*p+s*_-l*m,t[1]=s*y+u*m+l*p-n*_,t[2]=l*y+u*_+n*m-s*p,t[3]=u*y-n*p-s*m-l*_,t}function Am(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=Math.sqrt(i*i+n*n+s*s),p=Math.exp(l),m=u>0?p*Math.sin(u)/u:0;return t[0]=i*m,t[1]=n*m,t[2]=s*m,t[3]=p*Math.cos(u),t}function Im(t,e){var i=e[0],n=e[1],s=e[2],l=e[3],u=Math.sqrt(i*i+n*n+s*s),p=u>0?Math.atan2(u,l)/u:0;return t[0]=i*p,t[1]=n*p,t[2]=s*p,t[3]=.5*Math.log(i*i+n*n+s*s+l*l),t}function Xu(t,e,i,n){var s,l,u,p,m,_=e[0],y=e[1],v=e[2],w=e[3],E=i[0],A=i[1],I=i[2],z=i[3];return(l=_*E+y*A+v*I+w*z)<0&&(l=-l,E=-E,A=-A,I=-I,z=-z),1-l>La.EPSILON?(s=Math.acos(l),u=Math.sin(s),p=Math.sin((1-n)*s)/u,m=Math.sin(n*s)/u):(p=1-n,m=n),t[0]=p*_+m*E,t[1]=p*y+m*A,t[2]=p*v+m*I,t[3]=p*w+m*z,t}function Cm(t,e){var i,n=e[0]+e[4]+e[8];if(n>0)i=Math.sqrt(n+1),t[3]=.5*i,t[0]=(e[5]-e[7])*(i=.5/i),t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{var s=0;e[4]>e[0]&&(s=1),e[8]>e[3*s+s]&&(s=2);var l=(s+1)%3,u=(s+2)%3;i=Math.sqrt(e[3*s+s]-e[3*l+l]-e[3*u+u]+1),t[s]=.5*i,t[3]=(e[3*l+u]-e[3*u+l])*(i=.5/i),t[l]=(e[3*l+s]+e[3*s+l])*i,t[u]=(e[3*u+s]+e[3*s+u])*i}return t}Tt.clone=un.clone,Tt.fromValues=un.fromValues,Tt.copy=un.copy,Tt.set=un.set,Tt.add=un.add,Tt.mul=Sm;var Pm=un.scale;Tt.scale=Pm;var zm=un.dot;Tt.dot=zm,Tt.lerp=un.lerp;var Dm=un.length;Tt.length=Dm,Tt.len=Dm;var Lm=un.squaredLength;Tt.squaredLength=Lm,Tt.sqrLen=Lm;var Mp=un.normalize;Tt.normalize=Mp,Tt.exactEquals=un.exactEquals,Tt.equals=un.equals;var Bn,Rm,km,e0=(Bn=$o.create(),Rm=$o.fromValues(1,0,0),km=$o.fromValues(0,1,0),function(t,e,i){var n=$o.dot(e,i);return n<-.999999?($o.cross(Bn,Rm,e),$o.len(Bn)<1e-6&&$o.cross(Bn,km,e),$o.normalize(Bn,Bn),Em(t,Bn,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):($o.cross(Bn,e,i),t[0]=Bn[0],t[1]=Bn[1],t[2]=Bn[2],t[3]=1+n,Mp(t,t))});Tt.rotationTo=e0;var Ep,Sp,t0=(Ep=Tp(),Sp=Tp(),function(t,e,i,n,s,l){return Xu(Ep,e,s,l),Xu(Sp,i,n,l),Xu(t,Ep,Sp,2*l*(1-l)),t});Tt.sqlerp=t0;var Fn,i0=(Fn=Qy.create(),function(t,e,i,n){return Fn[0]=i[0],Fn[3]=i[1],Fn[6]=i[2],Fn[1]=n[0],Fn[4]=n[1],Fn[7]=n[2],Fn[2]=-e[0],Fn[5]=-e[1],Fn[8]=-e[2],Mp(t,Cm(t,Fn))});Tt.setAxes=i0;var $t={};function Ap(t){return(Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty($t,"__esModule",{value:!0}),$t.create=function(){var t=new Ur.ARRAY_TYPE(8);return Ur.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},$t.clone=function(t){var e=new Ur.ARRAY_TYPE(8);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},$t.fromValues=function(t,e,i,n,s,l,u,p){var m=new Ur.ARRAY_TYPE(8);return m[0]=t,m[1]=e,m[2]=i,m[3]=n,m[4]=s,m[5]=l,m[6]=u,m[7]=p,m},$t.fromRotationTranslationValues=function(t,e,i,n,s,l,u){var p=new Ur.ARRAY_TYPE(8);p[0]=t,p[1]=e,p[2]=i,p[3]=n;var m=.5*s,_=.5*l,y=.5*u;return p[4]=m*n+_*i-y*e,p[5]=_*n+y*t-m*i,p[6]=y*n+m*e-_*t,p[7]=-m*t-_*e-y*i,p},$t.fromRotationTranslation=Fm,$t.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},$t.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},$t.fromMat4=function(t,e){var i=Wo.create();Om.getRotation(i,e);var n=new Ur.ARRAY_TYPE(3);return Om.getTranslation(n,e),Fm(t,i,n),t},$t.copy=Nm,$t.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},$t.set=function(t,e,i,n,s,l,u,p,m){return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t[4]=l,t[5]=u,t[6]=p,t[7]=m,t},$t.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},$t.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},$t.getTranslation=function(t,e){var i=e[4],n=e[5],s=e[6],l=e[7],u=-e[0],p=-e[1],m=-e[2],_=e[3];return t[0]=2*(i*_+l*u+n*m-s*p),t[1]=2*(n*_+l*p+s*u-i*m),t[2]=2*(s*_+l*m+i*p-n*u),t},$t.translate=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=.5*i[0],m=.5*i[1],_=.5*i[2],y=e[4],v=e[5],w=e[6],E=e[7];return t[0]=n,t[1]=s,t[2]=l,t[3]=u,t[4]=u*p+s*_-l*m+y,t[5]=u*m+l*p-n*_+v,t[6]=u*_+n*m-s*p+w,t[7]=-n*p-s*m-l*_+E,t},$t.rotateX=function(t,e,i){var n=-e[0],s=-e[1],l=-e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=p*u+y*n+m*l-_*s,w=m*u+y*s+_*n-p*l,E=_*u+y*l+p*s-m*n,A=y*u-p*n-m*s-_*l;return Wo.rotateX(t,e,i),t[4]=v*(u=t[3])+A*(n=t[0])+w*(l=t[2])-E*(s=t[1]),t[5]=w*u+A*s+E*n-v*l,t[6]=E*u+A*l+v*s-w*n,t[7]=A*u-v*n-w*s-E*l,t},$t.rotateY=function(t,e,i){var n=-e[0],s=-e[1],l=-e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=p*u+y*n+m*l-_*s,w=m*u+y*s+_*n-p*l,E=_*u+y*l+p*s-m*n,A=y*u-p*n-m*s-_*l;return Wo.rotateY(t,e,i),t[4]=v*(u=t[3])+A*(n=t[0])+w*(l=t[2])-E*(s=t[1]),t[5]=w*u+A*s+E*n-v*l,t[6]=E*u+A*l+v*s-w*n,t[7]=A*u-v*n-w*s-E*l,t},$t.rotateZ=function(t,e,i){var n=-e[0],s=-e[1],l=-e[2],u=e[3],p=e[4],m=e[5],_=e[6],y=e[7],v=p*u+y*n+m*l-_*s,w=m*u+y*s+_*n-p*l,E=_*u+y*l+p*s-m*n,A=y*u-p*n-m*s-_*l;return Wo.rotateZ(t,e,i),t[4]=v*(u=t[3])+A*(n=t[0])+w*(l=t[2])-E*(s=t[1]),t[5]=w*u+A*s+E*n-v*l,t[6]=E*u+A*l+v*s-w*n,t[7]=A*u-v*n-w*s-E*l,t},$t.rotateByQuatAppend=function(t,e,i){var n=i[0],s=i[1],l=i[2],u=i[3],p=e[0],m=e[1],_=e[2],y=e[3];return t[0]=p*u+y*n+m*l-_*s,t[1]=m*u+y*s+_*n-p*l,t[2]=_*u+y*l+p*s-m*n,t[3]=y*u-p*n-m*s-_*l,t[4]=(p=e[4])*u+(y=e[7])*n+(m=e[5])*l-(_=e[6])*s,t[5]=m*u+y*s+_*n-p*l,t[6]=_*u+y*l+p*s-m*n,t[7]=y*u-p*n-m*s-_*l,t},$t.rotateByQuatPrepend=function(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=i[0],m=i[1],_=i[2],y=i[3];return t[0]=n*y+u*p+s*_-l*m,t[1]=s*y+u*m+l*p-n*_,t[2]=l*y+u*_+n*m-s*p,t[3]=u*y-n*p-s*m-l*_,t[4]=n*(y=i[7])+u*(p=i[4])+s*(_=i[6])-l*(m=i[5]),t[5]=s*y+u*m+l*p-n*_,t[6]=l*y+u*_+n*m-s*p,t[7]=u*y-n*p-s*m-l*_,t},$t.rotateAroundAxis=function(t,e,i,n){if(Math.abs(n)<Ur.EPSILON)return Nm(t,e);var s=Math.hypot(i[0],i[1],i[2]);n*=.5;var l=Math.sin(n),u=l*i[0]/s,p=l*i[1]/s,m=l*i[2]/s,_=Math.cos(n),y=e[0],v=e[1],w=e[2],E=e[3];t[0]=y*_+E*u+v*m-w*p,t[1]=v*_+E*p+w*u-y*m,t[2]=w*_+E*m+y*p-v*u,t[3]=E*_-y*u-v*p-w*m;var A=e[4],I=e[5],z=e[6],L=e[7];return t[4]=A*_+L*u+I*m-z*p,t[5]=I*_+L*p+z*u-A*m,t[6]=z*_+L*m+A*p-I*u,t[7]=L*_-A*u-I*p-z*m,t},$t.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t[6]=e[6]+i[6],t[7]=e[7]+i[7],t},$t.multiply=Vm,$t.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t},$t.lerp=function(t,e,i,n){var s=1-n;return Um(e,i)<0&&(n=-n),t[0]=e[0]*s+i[0]*n,t[1]=e[1]*s+i[1]*n,t[2]=e[2]*s+i[2]*n,t[3]=e[3]*s+i[3]*n,t[4]=e[4]*s+i[4]*n,t[5]=e[5]*s+i[5]*n,t[6]=e[6]*s+i[6]*n,t[7]=e[7]*s+i[7]*n,t},$t.invert=function(t,e){var i=Yu(e);return t[0]=-e[0]/i,t[1]=-e[1]/i,t[2]=-e[2]/i,t[3]=e[3]/i,t[4]=-e[4]/i,t[5]=-e[5]/i,t[6]=-e[6]/i,t[7]=e[7]/i,t},$t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=e[7],t},$t.normalize=function(t,e){var i=Yu(e);if(i>0){i=Math.sqrt(i);var n=e[0]/i,s=e[1]/i,l=e[2]/i,u=e[3]/i,p=e[4],m=e[5],_=e[6],y=e[7],v=n*p+s*m+l*_+u*y;t[0]=n,t[1]=s,t[2]=l,t[3]=u,t[4]=(p-n*v)/i,t[5]=(m-s*v)/i,t[6]=(_-l*v)/i,t[7]=(y-u*v)/i}return t},$t.str=function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},$t.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},$t.equals=function(t,e){var i=t[0],n=t[1],s=t[2],l=t[3],u=t[4],p=t[5],m=t[6],_=t[7],y=e[0],v=e[1],w=e[2],E=e[3],A=e[4],I=e[5],z=e[6],L=e[7];return Math.abs(i-y)<=Ur.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=Ur.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(s-w)<=Ur.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(l-E)<=Ur.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(u-A)<=Ur.EPSILON*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(p-I)<=Ur.EPSILON*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(m-z)<=Ur.EPSILON*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(_-L)<=Ur.EPSILON*Math.max(1,Math.abs(_),Math.abs(L))},$t.sqrLen=$t.squaredLength=$t.len=$t.length=$t.dot=$t.mul=$t.setReal=$t.getReal=void 0;var Ur=Ip(ir),Wo=Ip(Tt),Om=Ip(At);function Bm(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Bm=function(n){return n?i:e})(t)}function Ip(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==Ap(t)&&"function"!=typeof t)return{default:t};var i=Bm(e);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}function Fm(t,e,i){var n=.5*i[0],s=.5*i[1],l=.5*i[2],u=e[0],p=e[1],m=e[2],_=e[3];return t[0]=u,t[1]=p,t[2]=m,t[3]=_,t[4]=n*_+s*m-l*p,t[5]=s*_+l*u-n*m,t[6]=l*_+n*p-s*u,t[7]=-n*u-s*p-l*m,t}function Nm(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function Vm(t,e,i){var n=e[0],s=e[1],l=e[2],u=e[3],p=i[4],m=i[5],_=i[6],y=i[7],v=e[4],w=e[5],E=e[6],A=e[7],I=i[0],z=i[1],L=i[2],N=i[3];return t[0]=n*N+u*I+s*L-l*z,t[1]=s*N+u*z+l*I-n*L,t[2]=l*N+u*L+n*z-s*I,t[3]=u*N-n*I-s*z-l*L,t[4]=n*y+u*p+s*_-l*m+v*N+A*I+w*L-E*z,t[5]=s*y+u*m+l*p-n*_+w*N+A*z+E*I-v*L,t[6]=l*y+u*_+n*m-s*p+E*N+A*L+v*z-w*I,t[7]=u*y-n*p-s*m-l*_+A*N-v*I-w*z-E*L,t}$t.getReal=Wo.copy,$t.setReal=Wo.copy,$t.mul=Vm;var Um=Wo.dot;$t.dot=Um;var jm=Wo.length;$t.length=jm,$t.len=jm;var Yu=Wo.squaredLength;$t.squaredLength=Yu,$t.sqrLen=Yu;var kt={};function Cp(t){return(Cp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(kt,"__esModule",{value:!0}),kt.create=Zm,kt.clone=function(t){var e=new Ra.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},kt.fromValues=function(t,e){var i=new Ra.ARRAY_TYPE(2);return i[0]=t,i[1]=e,i},kt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},kt.set=function(t,e,i){return t[0]=e,t[1]=i,t},kt.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},kt.subtract=qm,kt.multiply=$m,kt.divide=Wm,kt.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},kt.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},kt.min=function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},kt.max=function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t},kt.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},kt.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},kt.scaleAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},kt.distance=Hm,kt.squaredDistance=Xm,kt.length=Ym,kt.squaredLength=Km,kt.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},kt.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},kt.normalize=function(t,e){var i=e[0],n=e[1],s=i*i+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t},kt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},kt.cross=function(t,e,i){var n=e[0]*i[1]-e[1]*i[0];return t[0]=t[1]=0,t[2]=n,t},kt.lerp=function(t,e,i,n){var s=e[0],l=e[1];return t[0]=s+n*(i[0]-s),t[1]=l+n*(i[1]-l),t},kt.random=function(t,e){e=e||1;var i=2*Ra.RANDOM()*Math.PI;return t[0]=Math.cos(i)*e,t[1]=Math.sin(i)*e,t},kt.transformMat2=function(t,e,i){var n=e[0],s=e[1];return t[0]=i[0]*n+i[2]*s,t[1]=i[1]*n+i[3]*s,t},kt.transformMat2d=function(t,e,i){var n=e[0],s=e[1];return t[0]=i[0]*n+i[2]*s+i[4],t[1]=i[1]*n+i[3]*s+i[5],t},kt.transformMat3=function(t,e,i){var n=e[0],s=e[1];return t[0]=i[0]*n+i[3]*s+i[6],t[1]=i[1]*n+i[4]*s+i[7],t},kt.transformMat4=function(t,e,i){var n=e[0],s=e[1];return t[0]=i[0]*n+i[4]*s+i[12],t[1]=i[1]*n+i[5]*s+i[13],t},kt.rotate=function(t,e,i,n){var s=e[0]-i[0],l=e[1]-i[1],u=Math.sin(n),p=Math.cos(n);return t[0]=s*p-l*u+i[0],t[1]=s*u+l*p+i[1],t},kt.angle=function(t,e){var i=t[0],n=t[1],s=e[0],l=e[1],u=Math.sqrt(i*i+n*n)*Math.sqrt(s*s+l*l);return Math.acos(Math.min(Math.max(u&&(i*s+n*l)/u,-1),1))},kt.zero=function(t){return t[0]=0,t[1]=0,t},kt.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},kt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},kt.equals=function(t,e){var i=t[0],n=t[1],s=e[0],l=e[1];return Math.abs(i-s)<=Ra.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-l)<=Ra.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))},kt.forEach=kt.sqrLen=kt.sqrDist=kt.dist=kt.div=kt.mul=kt.sub=kt.len=void 0;var Ra=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==Cp(t)&&"function"!=typeof t)return{default:t};var i=Gm(void 0);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}(ir);function Gm(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Gm=function(n){return n?i:e})(t)}function Zm(){var t=new Ra.ARRAY_TYPE(2);return Ra.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function qm(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t}function $m(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t}function Wm(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t}function Hm(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function Xm(t,e){var i=e[0]-t[0],n=e[1]-t[1];return i*i+n*n}function Ym(t){return Math.hypot(t[0],t[1])}function Km(t){var e=t[0],i=t[1];return e*e+i*i}kt.len=Ym,kt.sub=qm,kt.mul=$m,kt.div=Wm,kt.dist=Hm,kt.sqrDist=Xm,kt.sqrLen=Km;var r0=function(){var t=Zm();return function(e,i,n,s,l,u){var p,m;for(i||(i=2),n||(n=0),m=s?Math.min(s*i+n,e.length):e.length,p=n;p<m;p+=i)t[0]=e[p],t[1]=e[p+1],l(t,t,u),e[p]=t[0],e[p+1]=t[1];return e}}();function Pp(t){return(Pp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}kt.forEach=r0,Object.defineProperty(tr,"__esModule",{value:!0}),a.a7=tr.vec4=a.N=tr.vec3=tr.vec2=tr.quat2=a.bi=tr.quat=a.a6=tr.mat4=a.co=tr.mat3=tr.mat2d=a.b4=tr.mat2=tr.glMatrix=void 0;var n0=yo(ir);tr.glMatrix=n0;var o0=yo(Pi);a.b4=tr.mat2=o0;var s0=yo(Li);tr.mat2d=s0;var a0=yo(fi);a.co=tr.mat3=a0;var l0=yo(At);a.a6=tr.mat4=l0;var c0=yo(Tt);a.bi=tr.quat=c0;var h0=yo($t);tr.quat2=h0;var u0=yo(kt);tr.vec2=u0;var d0=yo(St);a.N=tr.vec3=d0;var p0=yo(Nt);function Jm(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(Jm=function(n){return n?i:e})(t)}function yo(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==Pp(t)&&"function"!=typeof t)return{default:t};var i=Jm(e);if(i&&i.has(t))return i.get(t);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in t)if("default"!==l&&Object.prototype.hasOwnProperty.call(t,l)){var u=s?Object.getOwnPropertyDescriptor(t,l):null;u&&(u.get||u.set)?Object.defineProperty(n,l,u):n[l]=t[l]}return n.default=t,i&&i.set(t,n),n}a.a7=tr.vec4=p0;class zp{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,n){const s=a.N.dot(i,this.dir);if(Math.abs(s)<1e-6)return!1;const l=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/s;return n[0]=this.pos[0]+this.dir[0]*l,n[1]=this.pos[1]+this.dir[1]*l,n[2]=this.pos[2]+this.dir[2]*l,!0}closestPointOnSphere(e,i,n){if(a.N.equals(this.pos,e)||0===i)return n[0]=n[1]=n[2]=0,!1;const[s,l,u]=this.dir,p=this.pos[0]-e[0],m=this.pos[1]-e[1],_=this.pos[2]-e[2],y=s*s+l*l+u*u,v=2*(p*s+m*l+_*u),w=v*v-4*y*(p*p+m*m+_*_-i*i);if(w<0){const E=Math.max(-v/2,0),A=p+s*E,I=m+l*E,z=_+u*E,L=Math.hypot(A,I,z);return n[0]=A*i/L,n[1]=I*i/L,n[2]=z*i/L,!1}{const E=(-v-Math.sqrt(w))/(2*y);if(E<0){const A=Math.hypot(p,m,_);return n[0]=p*i/A,n[1]=m*i/A,n[2]=_*i/A,!1}return n[0]=p+s*E,n[1]=m+l*E,n[2]=_+u*E,!0}}}class Dp{constructor(e,i,n,s,l){this.TL=e,this.TR=i,this.BR=n,this.BL=s,this.horizon=l}static fromInvProjectionMatrix(e,i,n){const s=[-1,1,1],l=[1,1,1],u=[1,-1,1],p=[-1,-1,1],m=a.N.transformMat4(s,s,e),_=a.N.transformMat4(l,l,e),y=a.N.transformMat4(u,u,e),v=a.N.transformMat4(p,p,e);return new Dp(m,_,y,v,i/n)}}function wh(t,e,i){let n=1/0,s=-1/0;const l=[];for(const u of t){a.N.sub(l,u,e);const p=a.N.dot(l,i);n=Math.min(n,p),s=Math.max(s,p)}return[n,s]}function Qm(t,e){let i=!0;for(let n=0;n<t.planes.length;n++){const s=t.planes[n];let l=0;for(let u=0;u<e.length;u++)l+=a.N.dot(s,e[u])+s[3]>=0;if(0===l)return 0;l!==e.length&&(i=!1)}return i?2:1}function e_(t,e){for(const i of t.projections){const n=wh(e,t.points[0],i.axis);if(i.projection[1]<n[0]||i.projection[0]>n[1])return 0}return 1}function t_(t,e){let i=0;const n=[0,0,0,0];for(let s=0;s<t.length;s++)n[0]=t[s][0],n[1]=t[s][1],n[2]=t[s][2],n[3]=1,a.a7.dot(n,e)>=0&&i++;return i}class Lp{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=Ri.fromPoints(this.points),this.projections=[],this.frustumEdges=[a.N.sub([],this.points[2],this.points[3]),a.N.sub([],this.points[0],this.points[3]),a.N.sub([],this.points[4],this.points[0]),a.N.sub([],this.points[5],this.points[1]),a.N.sub([],this.points[6],this.points[2]),a.N.sub([],this.points[7],this.points[3])];for(const n of this.frustumEdges){const s=[0,-n[2],n[1]],l=[n[2],0,-n[0]];this.projections.push({axis:s,projection:wh(this.points,this.points[0],s)}),this.projections.push({axis:l,projection:wh(this.points,this.points[0],l)})}}static fromInvProjectionMatrix(e,i,n,s){const 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(_=>{const y=a.a7.transformMat4([],_,e),v=1/y[3]/i*l;return a.a7.mul(y,y,[v,v,s?1/y[3]:v,v])}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=a.N.sub([],u[_[0]],u[_[1]]),v=a.N.sub([],u[_[2]],u[_[1]]),w=a.N.normalize([],a.N.cross([],y,v)),E=-a.N.dot(w,u[_[1]]);return w.concat(E)}),m=[];for(let _=0;_<u.length;_++)m.push([u[_][0],u[_][1],u[_][2]]);return new Lp(m,p)}intersectsPrecise(e,i,n){for(let s=0;s<i.length;s++)if(!t_(e,i[s]))return 0;for(let s=0;s<this.planes.length;s++)if(!t_(e,this.planes[s]))return 0;for(const s of n)for(const l of this.frustumEdges){const u=a.N.cross([],s,l),p=a.N.length(u);if(0===p)continue;a.N.scale(u,u,1/p);const m=wh(this.points,this.points[0],u),_=wh(e,this.points[0],u);if(m[0]>_[1]||_[0]>m[1])return 0}return 1}}class Ri{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const s of e)a.N.min(i,i,s),a.N.max(n,n,s);return new Ri(i,n)}static fromTileIdAndHeight(e,i,n){const s=1<<e.canonical.z,l=e.canonical.x,u=e.canonical.y;return new Ri([l/s,u/s,i],[(l+1)/s,(u+1)/s,n])}static applyTransform(e,i){const n=e.getCorners();for(let s=0;s<n.length;++s)a.N.transformMat4(n[s],n[s],i);return Ri.fromPoints(n)}static projectAabbCorners(e,i){const n=e.getCorners();for(let s=0;s<n.length;++s)a.N.transformMat4(n[s],n[s],i);return n}constructor(e,i){this.min=e,this.max=i,this.center=a.N.scale([],a.N.add([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],n=a.N.clone(this.min),s=a.N.clone(this.max);for(let l=0;l<i.length;l++)n[l]=i[l]?this.min[l]:this.center[l],s[l]=i[l]?this.center[l]:this.max[l];return s[2]=this.max[2],new Ri(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(){const e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Qm(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Qm(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,i){return i||this.intersects(e)?e_(e,this.getCorners()):0}intersectsPreciseFlat(e,i){return i||this.intersectsFlat(e)?e_(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let i=0;i<3;++i)if(this.min[i]>e.max[i]||e.min[i]>this.max[i])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e.min[i]),this.max[i]=Math.max(this.max[i],e.max[i])}encapsulatePoint(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e[i]),this.max[i]=Math.max(this.max[i],e[i])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}Ke(Ri,"Aabb");const f0=li([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ku}=f0,m0=li([{name:"a_pos_3",components:3,type:"Int16"}]);var i_=li([{name:"a_pos",type:"Int16",components:2}]);function Ju(t){return t*V/pe}const _0=[new Ri([ee,ee,ee],[ce,ce,ce]),new Ri([ee,ee,ee],[0,0,ce]),new Ri([0,ee,ee],[ce,0,ce]),new Ri([ee,0,ee],[0,ce,ce]),new Ri([0,0,ee],[ce,ce,ce])];function r_(t,e,i,n=!0){const s=a.N.scale([],t._camera.position,t.worldSize),l=[e,i,1,1];a.a7.transformMat4(l,l,t.pixelMatrixInverse),a.a7.scale(l,l,1/l[3]);const u=a.N.sub([],l,s),p=a.N.normalize([],u),m=t.globeMatrix,_=[m[12],m[13],m[14]],y=a.N.sub([],_,s),v=a.N.length(y),w=a.N.normalize([],y),E=t.worldSize/(2*Math.PI),A=a.N.dot(w,p),I=Math.asin(E/v);if(I<Math.acos(A)){if(!n)return null;const se=[],_e=[];a.N.scale(se,p,v/A),a.N.normalize(_e,a.N.sub(_e,se,y)),a.N.normalize(p,a.N.add(p,y,a.N.scale(p,_e,Math.tan(I)*v)))}const z=[];new zp(s,p).closestPointOnSphere(_,E,z);const L=a.N.normalize([],H(m,0)),N=a.N.normalize([],H(m,1)),G=a.N.normalize([],H(m,2)),j=a.N.dot(L,z),X=a.N.dot(N,z),W=a.N.dot(G,z),J=dr(Math.asin(-X/E));let ie=dr(Math.atan2(j,W));ie=t.center.lng+function(se,_e){const Me=(_e-se+180)%360-180;return Me<-180?Me+360:Me}(t.center.lng,ie);const oe=Et(ie),he=Dt(gt(J),0,1);return new Yt(oe,he)}class g0{constructor(e,i,n){this.a=a.N.sub([],e,n),this.b=a.N.sub([],i,n),this.center=n;const s=a.N.normalize([],this.a),l=a.N.normalize([],this.b);this.angle=Math.acos(a.N.dot(s,l))}}function Rp(t,e){if(0===t.angle)return null;let i;return i=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(n,s,l,u){const p=Math.sin(l);return n*(Math.sin((1-u)*l)/p)+s*(Math.sin(u*l)/p)}(t.a[e],t.b[e],t.angle,Dt(i,0,1))+t.center[e]}function xo(t){if(t.z<=1)return _0[t.z+2*t.y+t.x];const e=kp(Qu(t));return Ri.fromPoints(e)}function Ho(t,e,i){return a.N.scale(t,t,1-i),a.N.scaleAndAdd(t,t,e,i)}function n_(t,e,i){for(const n of t)a.N.transformMat4(n,n,e),a.N.scale(n,n,i)}function o_(t,e,i,n){const s=e/t.worldSize,l=t.globeMatrix;if(i.z<=1){const oe=xo(i).getCorners();return n_(oe,l,s),Ri.fromPoints(oe)}const u=Qu(i,n),p=kp(u,V+Ju(t._tileCoverLift));n_(p,l,s);const m=Number.MAX_VALUE,_=[-m,-m,-m],y=[m,m,m];if(u.contains(t.center)){for(const se of p)a.N.min(y,y,se),a.N.max(_,_,se);_[2]=0;const oe=t.point,he=[oe.x*s,oe.y*s,0];return a.N.min(y,y,he),a.N.max(_,_,he),new Ri(y,_)}if(t._tileCoverLift>0){for(const oe of p)a.N.min(y,y,oe),a.N.max(_,_,oe);return new Ri(y,_)}const v=[l[12]*s,l[13]*s,l[14]*s],w=u.getCenter(),E=Dt(t.center.lat,-Ot,Ot),A=Dt(w.lat,-Ot,Ot),I=Et(t.center.lng),z=gt(E);let L=I-Et(w.lng);const N=z-gt(A);L>.5?L-=1:L<-.5&&(L+=1);let G=0;if(Math.abs(L)>Math.abs(N))G=L>=0?1:3;else{G=N>=0?0:2;const oe=[l[4]*s,l[5]*s,l[6]*s],he=-Math.sin(qt(N>=0?u.getSouth():u.getNorth()))*V;a.N.scaleAndAdd(v,v,oe,he)}const j=p[G],X=p[(G+1)%4],W=new g0(j,X,v),J=[Rp(W,0)||j[0],Rp(W,1)||j[1],Rp(W,2)||j[2]],ie=Cs(t.zoom);if(ie>0){const oe=function({x:se,y:_e,z:Me},fe,we,de,be){const Fe=1/(1<<Me);let Se=se*Fe,Qe=Se+Fe,He=_e*Fe,Ce=He+Fe,ft=0;const st=(Se+Qe)/2-de;return st>.5?ft=-1:st<-.5&&(ft=1),Se=((Se+ft)*fe-(de*=fe))*we+de,Qe=((Qe+ft)*fe-de)*we+de,He=(He*fe-(be*=fe))*we+be,Ce=(Ce*fe-be)*we+be,[[Se,Ce,0],[Qe,Ce,0],[Qe,He,0],[Se,He,0]]}(i,e,t._pixelsPerMercatorPixel,I,z);for(let se=0;se<p.length;se++)Ho(p[se],oe[se],ie);const he=a.N.add([],oe[G],oe[(G+1)%4]);a.N.scale(he,he,.5),Ho(J,he,ie)}for(const oe of p)a.N.min(y,y,oe),a.N.max(_,_,oe);return y[2]=Math.min(j[2],X[2]),a.N.min(y,y,J),a.N.max(_,_,J),new Ri(y,_)}function Qu({x:t,y:e,z:i},n=!1){const s=1/(1<<i),l=new ne(vt(t*s),e===(1<<i)-1&&n?-90:Zt((e+1)*s)),u=new ne(vt((t+1)*s),0===e&&n?90:Zt(e*s));return new ue(l,u)}function kp(t,e=V){const i=qt(t.getNorth()),n=qt(t.getSouth()),s=Math.cos(i),l=Math.cos(n),u=Math.sin(i),p=Math.sin(n),m=t.getWest(),_=t.getEast();return[re(l,p,m,e),re(l,p,_,e),re(s,u,_,e),re(s,u,m,e)]}function Th(t,e,i,n){const s=1<<i.z,l=(t/qe+i.x)/s;return me(Zt((e/qe+i.y)/s),vt(l),n)}function ed({min:t,max:e}){return 16383/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const s_=new Float64Array(16);function td(t){const e=ed(t),i=a.a6.fromScaling(s_,[e,e,e]);return a.a6.translate(i,i,a.N.negate([],t.min))}function Op(t){const e=a.a6.fromTranslation(s_,t.min),i=1/ed(t);return a.a6.scale(e,e,[i,i,i])}function Bp(t){const e=qe/(2*Math.PI);return t/(2*Math.PI)/e}function a_(t,e){return qe/(512*Math.pow(2,t))*ed(xo(e))}function l_(t,e,i,n,s){const l=Bp(i),u=[t,e,-i/(2*Math.PI)],p=a.a6.identity(new Float64Array(16));return a.a6.translate(p,p,u),a.a6.scale(p,p,[l,l,l]),a.a6.rotateX(p,p,qt(-s)),a.a6.rotateY(p,p,qt(-n)),p}function Cs(t){return Jo(5,6,t)}function c_(t,e){const i=me(e.lat,e.lng),n=function(l){const u=me(l._center.lat,l._center.lng),p=a.N.fromValues(0,1,0);let m=a.N.cross([],p,u);const _=a.a6.fromRotation([],-l.angle,u);m=a.N.transformMat4(m,m,_),a.a6.fromRotation(_,-l._pitch,m);const y=a.N.normalize([],u);return a.N.scale(y,y,Ju(l.cameraToCenterDistance/l.pixelsPerMeter)),a.N.transformMat4(y,y,_),a.N.add([],u,y)}(t),s=a.N.subtract([],n,i);return a.N.angle(s,i)}function Fp(t,e){return c_(t,e)>Math.PI/2*1.01}const h_=qt(85),y0=Math.cos(h_),x0=Math.sin(h_),v0=a.a6.create(),u_=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function d_(t,e,i,n,s,l,u,p,m){if(l&&t.queryGeometry.isAboveHorizon)return!1;l&&(m*=t.pixelToTileUnitsFactor);const _=t.tileID.canonical,y=i.projection.upVectorScale(_,i.center.lat,i.worldSize).metersToTile;for(const v of e)for(const w of v){const E=w.add(p),A=s&&i.elevation?i.elevation.exaggeration()*s.getElevationAt(E.x,E.y,!0):0,I=i.projection.projectTilePoint(E.x,E.y,_);if(A>0){const G=i.projection.upVector(_,E.x,E.y);I.x+=G[0]*y*A,I.y+=G[1]*y*A,I.z+=G[2]*y*A}const z=l?E:b0(I.x,I.y,I.z,n),L=l?t.tilespaceRays.map(G=>T0(G,A)):t.queryGeometry.screenGeometry,N=a.a7.transformMat4([],[I.x,I.y,I.z,1],n);if(!u&&l?m*=N[3]/i.cameraToCenterDistance:u&&!l&&(m*=i.cameraToCenterDistance/N[3]),l){const G=Zt((w.y/qe+_.y)/(1<<_.z));m/=i.projection.pixelsPerMeter(G,1)/bt(1,G)}if(_o(L,z,m))return!0}return!1}function b0(t,e,i,n){const s=a.a7.transformMat4([],[t,e,i,1],n);return new Ue(s[0]/s[3],s[1]/s[3])}const p_=a.N.fromValues(0,0,0),w0=a.N.fromValues(0,0,1);function T0(t,e){const i=a.N.create();return p_[2]=e,t.intersectsPlane(p_,w0,i),new Ue(i[0],i[1])}class f_ extends Dr{}function m_(t,{width:e,height:i},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*n)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*i*n);return t.width=e,t.height=i,t.data=s,t}function __(t,e,i){const{width:n,height:s}=e;n===t.width&&s===t.height||(Np(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,s)},i),t.width=n,t.height=s,t.data=e.data)}function Np(t,e,i,n,s,l,u){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.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");const p=t.data,m=e.data,_=4===l&&u;for(let y=0;y<s.height;y++){const v=((i.y+y)*t.width+i.x)*l,w=((n.y+y)*e.width+n.x)*l;if(_)for(let E=0;E<s.width;E++){const A=v+E*l+3,I=w+E*l;m[I+0]=255,m[I+1]=255,m[I+2]=255,m[I+3]=p[A]}else for(let E=0;E<s.width*l;E++)m[w+E]=p[v+E]}return e}Ke(f_,"HeatmapBucket",{omit:["layers"]});class Ps{constructor(e,i){m_(this,e,1,i)}resize(e){__(this,new Ps(e),1)}clone(){return new Ps({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,s,l){Np(e,i,n,s,l,1)}}class dn{constructor(e,i){m_(this,e,4,i)}resize(e){__(this,new dn(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new dn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,s,l,u){Np(e,i,n,s,l,4,u)}}class g_{constructor(e,i){this.width=e.width,this.height=e.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}Ke(Ps,"AlphaImage"),Ke(dn,"RGBAImage");const M0=new Ii({visibility:new Oe(le.layout_heatmap.visibility)});var E0={paint:new Ii({"heatmap-radius":new ht(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ht(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Oe(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Uo(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Oe(le.paint_heatmap["heatmap-opacity"])}),layout:M0};function Mh(t){const e={},i=t.resolution||256,n=t.clips?t.clips.length:1,s=t.image||new dn({width:i,height:n}),l=(u,p,m)=>{e[t.evaluationKey]=m;const _=t.expression.evaluate(e);_&&(s.data[u+p+0]=Math.floor(255*_.r/_.a),s.data[u+p+1]=Math.floor(255*_.g/_.a),s.data[u+p+2]=Math.floor(255*_.b/_.a),s.data[u+p+3]=Math.floor(255*_.a))};if(t.clips)for(let u=0,p=0;u<n;++u,p+=4*i)for(let m=0,_=0;m<i;m++,_+=4){const y=m/(i-1),{start:v,end:w}=t.clips[u];l(p,_,v*(1-y)+w*y)}else for(let u=0,p=0;u<i;u++,p+=4)l(0,p,u/(i-1));return s}const S0=new Ii({visibility:new Oe(le.layout_hillshade.visibility)});var A0={paint:new Ii({"hillshade-illumination-direction":new Oe(le.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Oe(le.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Oe(le.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Oe(le.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Oe(le.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Oe(le.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new Oe(le.paint_hillshade["hillshade-emissive-strength"])}),layout:S0};const I0=li([{name:"a_pos",components:2,type:"Int16"}],4),{members:C0}=I0;var Vp={exports:{}};function id(t,e,i){i=i||2;var n,s,l,u,p,m,_,y=e&&e.length,v=y?e[0]*i:t.length,w=y_(t,0,v,i,!0),E=[];if(!w||w.next===w.prev)return E;if(y&&(w=function(I,z,L,N){var G,j,X,W=[];for(G=0,j=z.length;G<j;G++)(X=y_(I,z[G]*N,G<j-1?z[G+1]*N:I.length,N,!1))===X.next&&(X.steiner=!0),W.push(B0(X));for(W.sort(R0),G=0;G<W.length;G++)L=k0(W[G],L);return L}(t,e,w,i)),t.length>80*i){n=l=t[0],s=u=t[1];for(var A=i;A<v;A+=i)(p=t[A])<n&&(n=p),(m=t[A+1])<s&&(s=m),p>l&&(l=p),m>u&&(u=m);_=0!==(_=Math.max(l-n,u-s))?32767/_:0}return Eh(w,E,i,n,s,_,0),E}function y_(t,e,i,n,s){var l,u;if(s===Gp(t,e,i,n)>0)for(l=e;l<i;l+=n)u=b_(l,t[l],t[l+1],u);else for(l=i-n;l>=e;l-=n)u=b_(l,t[l],t[l+1],u);return u&&rd(u,u.next)&&(Ah(u),u=u.next),u}function ka(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!rd(n,n.next)&&0!==Xi(n.prev,n,n.next))n=n.next;else{if(Ah(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function Eh(t,e,i,n,s,l,u){if(t){!u&&l&&function(y,v,w,E){var A=y;do{0===A.z&&(A.z=Up(A.x,A.y,v,w,E)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next}while(A!==y);A.prevZ.nextZ=null,A.prevZ=null,function(I){var z,L,N,G,j,X,W,J,ie=1;do{for(L=I,I=null,j=null,X=0;L;){for(X++,N=L,W=0,z=0;z<ie&&(W++,N=N.nextZ);z++);for(J=ie;W>0||J>0&&N;)0!==W&&(0===J||!N||L.z<=N.z)?(G=L,L=L.nextZ,W--):(G=N,N=N.nextZ,J--),j?j.nextZ=G:I=G,G.prevZ=j,j=G;L=N}j.nextZ=null,ie*=2}while(X>1)}(A)}(t,n,s,l);for(var p,m,_=t;t.prev!==t.next;)if(p=t.prev,m=t.next,l?z0(t,n,s,l):P0(t))e.push(p.i/i|0),e.push(t.i/i|0),e.push(m.i/i|0),Ah(t),t=m.next,_=m.next;else if((t=m)===_){u?1===u?Eh(t=D0(ka(t),e,i),e,i,n,s,l,2):2===u&&L0(t,e,i,n,s,l):Eh(ka(t),e,i,n,s,l,1);break}}}function P0(t){var e=t.prev,i=t,n=t.next;if(Xi(e,i,n)>=0)return!1;for(var s=e.x,l=i.x,u=n.x,p=e.y,m=i.y,_=n.y,y=s<l?s<u?s:u:l<u?l:u,v=p<m?p<_?p:_:m<_?m:_,w=s>l?s>u?s:u:l>u?l:u,E=p>m?p>_?p:_:m>_?m:_,A=n.next;A!==e;){if(A.x>=y&&A.x<=w&&A.y>=v&&A.y<=E&&Il(s,p,l,m,u,_,A.x,A.y)&&Xi(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function z0(t,e,i,n){var s=t.prev,l=t,u=t.next;if(Xi(s,l,u)>=0)return!1;for(var p=s.x,m=l.x,_=u.x,y=s.y,v=l.y,w=u.y,E=p<m?p<_?p:_:m<_?m:_,A=y<v?y<w?y:w:v<w?v:w,I=p>m?p>_?p:_:m>_?m:_,z=y>v?y>w?y:w:v>w?v:w,L=Up(E,A,e,i,n),N=Up(I,z,e,i,n),G=t.prevZ,j=t.nextZ;G&&G.z>=L&&j&&j.z<=N;){if(G.x>=E&&G.x<=I&&G.y>=A&&G.y<=z&&G!==s&&G!==u&&Il(p,y,m,v,_,w,G.x,G.y)&&Xi(G.prev,G,G.next)>=0||(G=G.prevZ,j.x>=E&&j.x<=I&&j.y>=A&&j.y<=z&&j!==s&&j!==u&&Il(p,y,m,v,_,w,j.x,j.y)&&Xi(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;G&&G.z>=L;){if(G.x>=E&&G.x<=I&&G.y>=A&&G.y<=z&&G!==s&&G!==u&&Il(p,y,m,v,_,w,G.x,G.y)&&Xi(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;j&&j.z<=N;){if(j.x>=E&&j.x<=I&&j.y>=A&&j.y<=z&&j!==s&&j!==u&&Il(p,y,m,v,_,w,j.x,j.y)&&Xi(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function D0(t,e,i){var n=t;do{var s=n.prev,l=n.next.next;!rd(s,l)&&x_(s,n,n.next,l)&&Sh(s,l)&&Sh(l,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(l.i/i|0),Ah(n),Ah(n.next),n=t=l),n=n.next}while(n!==t);return ka(n)}function L0(t,e,i,n,s,l){var u=t;do{for(var p=u.next.next;p!==u.prev;){if(u.i!==p.i&&F0(u,p)){var m=v_(u,p);return u=ka(u,u.next),m=ka(m,m.next),Eh(u,e,i,n,s,l,0),void Eh(m,e,i,n,s,l,0)}p=p.next}u=u.next}while(u!==t)}function R0(t,e){return t.x-e.x}function k0(t,e){var i=function(s,l){var u,p=l,m=s.x,_=s.y,y=-1/0;do{if(_<=p.y&&_>=p.next.y&&p.next.y!==p.y){var v=p.x+(_-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(v<=m&&v>y&&(y=v,u=p.x<p.next.x?p:p.next,v===m))return u}p=p.next}while(p!==l);if(!u)return null;var w,E=u,A=u.x,I=u.y,z=1/0;p=u;do{m>=p.x&&p.x>=A&&m!==p.x&&Il(_<I?m:y,_,A,I,_<I?y:m,_,p.x,p.y)&&(w=Math.abs(_-p.y)/(m-p.x),Sh(p,s)&&(w<z||w===z&&(p.x>u.x||p.x===u.x&&O0(u,p)))&&(u=p,z=w)),p=p.next}while(p!==E);return u}(t,e);if(!i)return e;var n=v_(i,t);return ka(n,n.next),ka(i,i.next)}function O0(t,e){return Xi(t.prev,t,e.prev)<0&&Xi(e.next,t,t.next)<0}function Up(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function B0(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Il(t,e,i,n,s,l,u,p){return(s-u)*(e-p)>=(t-u)*(l-p)&&(t-u)*(n-p)>=(i-u)*(e-p)&&(i-u)*(l-p)>=(s-u)*(n-p)}function F0(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(i,n){var s=i;do{if(s.i!==i.i&&s.next.i!==i.i&&s.i!==n.i&&s.next.i!==n.i&&x_(s,s.next,i,n))return!0;s=s.next}while(s!==i);return!1}(t,e)&&(Sh(t,e)&&Sh(e,t)&&function(i,n){var s=i,l=!1,u=(i.x+n.x)/2,p=(i.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!==i);return l}(t,e)&&(Xi(t.prev,t,e.prev)||Xi(t,e.prev,e))||rd(t,e)&&Xi(t.prev,t,t.next)>0&&Xi(e.prev,e,e.next)>0)}function Xi(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function rd(t,e){return t.x===e.x&&t.y===e.y}function x_(t,e,i,n){var s=od(Xi(t,e,i)),l=od(Xi(t,e,n)),u=od(Xi(i,n,t)),p=od(Xi(i,n,e));return s!==l&&u!==p||!(0!==s||!nd(t,i,e))||!(0!==l||!nd(t,n,e))||!(0!==u||!nd(i,t,n))||!(0!==p||!nd(i,e,n))}function nd(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function od(t){return t>0?1:t<0?-1:0}function Sh(t,e){return Xi(t.prev,t,t.next)<0?Xi(t,e,t.next)>=0&&Xi(t,t.prev,e)>=0:Xi(t,e,t.prev)<0||Xi(t,t.next,e)<0}function v_(t,e){var i=new jp(t.i,t.x,t.y),n=new jp(e.i,e.x,e.y),s=t.next,l=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,l.next=n,n.prev=l,n}function b_(t,e,i,n){var s=new jp(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Ah(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 jp(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Gp(t,e,i,n){for(var s=0,l=e,u=i-n;l<i;l+=n)s+=(t[u]-t[l])*(t[l+1]+t[u+1]),u=l;return s}Vp.exports=id,Vp.exports.default=id,id.deviation=function(t,e,i,n){var s=e&&e.length,l=Math.abs(Gp(t,0,s?e[0]*i:t.length,i));if(s)for(var u=0,p=e.length;u<p;u++)l-=Math.abs(Gp(t,e[u]*i,u<p-1?e[u+1]*i:t.length,i));var m=0;for(u=0;u<n.length;u+=3){var _=n[u]*i,y=n[u+1]*i,v=n[u+2]*i;m+=Math.abs((t[_]-t[v])*(t[y+1]-t[_+1])-(t[_]-t[y])*(t[v+1]-t[_+1]))}return 0===l&&0===m?0:Math.abs((m-l)/l)},id.flatten=function(t){for(var e=t[0][0].length,i={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++)i.vertices.push(t[s][l][u]);s>0&&i.holes.push(n+=t[s-1].length)}return i};var sd=kr(Vp.exports);function Zp(t,e){const i=t.length;if(i<=1)return[t];const n=[];let s,l;for(let u=0;u<i;u++){const p=So(t[u]);0!==p&&(t[u].area=Math.abs(p),void 0===l&&(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||($d(n[u],e,1,n[u].length-1,N0),n[u]=n[u].slice(0,e));return n}function N0(t,e){return e.area-t.area}function qp(t,e,i){const n=i.patternDependencies;let s=!1;for(const l of e){const u=l.paint.get(`${t}-pattern`);u.isConstant()||(s=!0);const p=u.constantOr(null);p&&(s=!0,n[p]=!0)}return s}function $p(t,e,i,n,s){const l=s.patternDependencies;for(const u of e){const p=u.paint.get(`${t}-pattern`).value;if("constant"!==p.kind){let m=p.evaluate({zoom:n},i,{},s.availableImages);m=m&&m.name?m.name:m,l[m]=!0,i.patterns[u.id]=m}}return i}class Wp{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new cn,this.indexArray=new Ji,this.indexArray2=new vn,this.programConfigurations=new k(e.layers,e.zoom),this.segments=new Oi,this.segments2=new Oi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection}populate(e,i,n,s){this.hasPattern=qp("fill",this.layers,i);const l=this.layers[0].layout.get("fill-sort-key"),u=[];for(const{feature:p,id:m,index:_,sourceLayerIndex:y}of e){const v=this.layers[0]._featureFilter.needGeometry,w=Hi(p,v);if(!this.layers[0]._featureFilter.filter(new Ai(this.zoom),w,n))continue;const E=l?l.evaluate(w,{},n,i.availableImages):void 0,A={id:m,properties:p.properties,type:p.type,sourceLayerIndex:y,index:_,geometry:v?w.geometry:er(p,n,s),patterns:{},sortKey:E};u.push(A)}l&&u.sort((p,m)=>p.sortKey-m.sortKey);for(const p of u){const{geometry:m,index:_,sourceLayerIndex:y}=p;if(this.hasPattern){const v=$p("fill",this.layers,p,this.zoom,i);this.patternFeatures.push(v)}else this.addFeature(p,m,_,n,{},i.availableImages,i.brightness);i.featureIndex.insert(e[_].feature,m,_,y,this.index)}}update(e,i,n,s,l){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,n,s,l)}addFeatures(e,i,n,s,l,u){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,n,s,u)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,C0),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,i,n,s,l,u=[],p){for(const m of Zp(i,500)){let _=0;for(const I of m)_+=I.length;const y=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray),v=y.vertexLength,w=[],E=[];for(const I of m){if(0===I.length)continue;I!==m[0]&&E.push(w.length/2);const z=this.segments2.prepareSegment(I.length,this.layoutVertexArray,this.indexArray2),L=z.vertexLength;this.layoutVertexArray.emplaceBack(I[0].x,I[0].y),this.indexArray2.emplaceBack(L+I.length-1,L),w.push(I[0].x),w.push(I[0].y);for(let N=1;N<I.length;N++)this.layoutVertexArray.emplaceBack(I[N].x,I[N].y),this.indexArray2.emplaceBack(L+N-1,L+N),w.push(I[N].x),w.push(I[N].y);z.vertexLength+=I.length,z.primitiveLength+=I.length}const A=sd(w,E);for(let I=0;I<A.length;I+=3)this.indexArray.emplaceBack(v+A[I],v+A[I+1],v+A[I+2]);y.vertexLength+=_,y.primitiveLength+=A.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s,p)}}Ke(Wp,"FillBucket",{omit:["layers","patternFeatures"]});const V0=new Ii({"fill-sort-key":new ht(le.layout_fill["fill-sort-key"]),visibility:new Oe(le.layout_fill.visibility)});var U0={paint:new Ii({"fill-antialias":new Oe(le.paint_fill["fill-antialias"]),"fill-opacity":new ht(le.paint_fill["fill-opacity"]),"fill-color":new ht(le.paint_fill["fill-color"]),"fill-outline-color":new ht(le.paint_fill["fill-outline-color"]),"fill-translate":new Oe(le.paint_fill["fill-translate"]),"fill-translate-anchor":new Oe(le.paint_fill["fill-translate-anchor"]),"fill-pattern":new ht(le.paint_fill["fill-pattern"]),"fill-emissive-strength":new Oe(le.paint_fill["fill-emissive-strength"])}),layout:V0};const j0=li([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),G0=li([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Z0=li([{name:"a_centroid_pos",components:2,type:"Uint16"}]),q0=li([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),$0=li([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:W0}=j0;var ad={},H0=Wn,w_=Cl;function Cl(t,e,i,n,s){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=s,t.readFields(X0,this,e)}function X0(t,e,i){1==t?e.id=i.readVarint():2==t?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}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Y0(t){for(var e,i,n=0,s=0,l=t.length,u=l-1;s<l;u=s++)n+=((i=t[u]).x-(e=t[s]).x)*(e.y+i.y);return n}Cl.types=["Unknown","Point","LineString","Polygon"],Cl.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,n=1,s=0,l=0,u=0,p=[];t.pos<i;){if(s<=0){var m=t.readVarint();n=7&m,s=m>>3}if(s--,1===n||2===n)l+=t.readSVarint(),u+=t.readSVarint(),1===n&&(e&&p.push(e),e=[]),e.push(new H0(l,u));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&p.push(e),p},Cl.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,s=0,l=0,u=1/0,p=-1/0,m=1/0,_=-1/0;t.pos<e;){if(n<=0){var y=t.readVarint();i=7&y,n=y>>3}if(n--,1===i||2===i)(s+=t.readSVarint())<u&&(u=s),s>p&&(p=s),(l+=t.readSVarint())<m&&(m=l),l>_&&(_=l);else if(7!==i)throw new Error("unknown command "+i)}return[u,m,p,_]},Cl.prototype.toGeoJSON=function(t,e,i){var n,s,l=this.extent*Math.pow(2,i),u=this.extent*t,p=this.extent*e,m=this.loadGeometry(),_=Cl.types[this.type];function y(E){for(var A=0;A<E.length;A++){var I=E[A];E[A]=[360*(I.x+u)/l-180,360/Math.PI*Math.atan(Math.exp((180-360*(I.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];y(m=v);break;case 2:for(n=0;n<m.length;n++)y(m[n]);break;case 3:for(m=function(E){var A=E.length;if(A<=1)return[E];for(var I,z,L=[],N=0;N<A;N++){var G=Y0(E[N]);0!==G&&(void 0===z&&(z=G<0),z===G<0?(I&&L.push(I),I=[E[N]]):I.push(E[N]))}return I&&L.push(I),L}(m),n=0;n<m.length;n++)for(s=0;s<m[n].length;s++)y(m[n][s])}1===m.length?m=m[0]:_="Multi"+_;var w={type:"Feature",geometry:{type:_,coordinates:m},properties:this.properties};return"id"in this&&(w.id=this.id),w};var K0=w_,T_=M_;function M_(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(J0,this,e),this.length=this._features.length}function J0(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(n){for(var s=null,l=n.readVarint()+n.pos;n.pos<l;){var u=n.readVarint()>>3;s=1===u?n.readString():2===u?n.readFloat():3===u?n.readDouble():4===u?n.readVarint64():5===u?n.readVarint():6===u?n.readSVarint():7===u?n.readBoolean():null}return s}(i))}M_.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 K0(this._pbf,e,this.extent,this._keys,this._values)};var Q0=T_;function ex(t,e,i){if(3===t){var n=new Q0(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var Hp=ad.VectorTile=function(t,e){this.layers=t.readFields(ex,{},e)},ld=ad.VectorTileFeature=w_;function cd(t,e,i,n){const s=[],l=0===n?(u,p,m,_,y,v)=>{u.push(new Ue(v,m+(v-p)/(_-p)*(y-m)))}:(u,p,m,_,y,v)=>{u.push(new Ue(p+(v-m)/(y-m)*(_-p),v))};for(const u of t){const p=[];for(const m of u){if(m.length<=2)continue;const _=[];for(let w=0;w<m.length-1;w++){const E=m[w].x,A=m[w].y,I=m[w+1].x,z=m[w+1].y,L=0===n?E:A,N=0===n?I:z;L<e?N>e&&l(_,E,A,I,z,e):L>i?N<i&&l(_,E,A,I,z,i):_.push(m[w]),N<e&&L>=e&&l(_,E,A,I,z,e),N>i&&L<=i&&l(_,E,A,I,z,i)}let y=m[m.length-1];const v=0===n?y.x:y.y;v>=e&&v<=i&&_.push(y),_.length&&(y=_[_.length-1],_[0].x===y.x&&_[0].y===y.y||_.push(_[0]),p.push(_))}p.length&&s.push(p)}return s}function hd(t,e){return t.x-e.x||t.y-e.y}function E_(t,e){return 0===hd(t.min,e.min)&&0===hd(t.max,e.max)}function S_(t,e){return!(t.min.x>e.max.x||t.max.x<e.min.x||t.min.y>e.max.y||t.max.y<e.min.y)}function A_(t,e,i){const n=1/qe,s=1/(1<<i.canonical.z),l=(e.x*n+i.canonical.x)*s+i.wrap,u=(e.y*n+i.canonical.y)*s;return{min:new Ue((t.x*n+i.canonical.x)*s+i.wrap,(t.y*n+i.canonical.y)*s),max:new Ue(l,u)}}function tx(t,e,i){const n=1<<i.canonical.z,s=((e.x-i.wrap)*n-i.canonical.x)*qe,l=(e.y*n-i.canonical.y)*qe;return{min:new Ue(((t.x-i.wrap)*n-i.canonical.x)*qe,(t.y*n-i.canonical.y)*qe),max:new Ue(s,l)}}function I_(t,e,i,n,s,l,u){const p=t.indices,m=t.vertices,_=[];for(let y=n;y<n+s;y+=3){const v=e[i[y+0]+l],w=e[i[y+1]+l],E=e[i[y+2]+l],A=Math.min(v.x,w.x,E.x),I=Math.max(v.x,w.x,E.x),z=Math.min(v.y,w.y,E.y),L=Math.max(v.y,w.y,E.y);_.length=0,t.grid.query(new Ue(A,z),new Ue(I,L),_);for(let N=0;N<_.length;N++){const G=_[N];if(mp(m[p[3*G+0]],m[p[3*G+1]],m[p[3*G+2]],v,w,E,u))return!0}}return!1}function C_(t,e,i,n){if(!t||!i)return!1;let s=t.vertices;if(!e.canonical.equals(n.canonical)||e.wrap!==n.wrap){if(i.vertices.length<t.vertices.length)return C_(i,n,t,e);const l=e.canonical,u=n.canonical,p=Math.pow(2,u.z-l.z);s=t.vertices.map(m=>new Ue(m.x*l.x*qe*p-u.x*qe,m.y*l.y*qe*p-u.y*qe))}return I_(i,s,t.indices,0,t.indices.length,0,0)}ad.VectorTileLayer=T_;class P_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){const n=this.toIdx(e,i);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function z_(t,e,i,n){let s=0,l=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(n[u])<1e-15){if(i[u]<t[u]||i[u]>e[u])return null}else{const p=1/n[u];let m=(t[u]-i[u])*p,_=(e[u]-i[u])*p;if(m>_){const y=m;m=_,_=y}if(m>s&&(s=m),_<l&&(l=_),s>l)return null}return s}function D_(t,e,i,n,s,l,u,p,m,_,y){const v=n-t,w=s-e,E=l-i,A=u-t,I=p-e,z=m-i,L=y[1]*z-y[2]*I,N=y[2]*A-y[0]*z,G=y[0]*I-y[1]*A,j=v*L+w*N+E*G;if(Math.abs(j)<1e-15)return null;const X=1/j,W=_[0]-t,J=_[1]-e,ie=_[2]-i,oe=(W*L+J*N+ie*G)*X;if(oe<0||oe>1)return null;const he=J*E-ie*w,se=ie*v-W*E,_e=W*w-J*v,Me=(y[0]*he+y[1]*se+y[2]*_e)*X;return Me<0||oe+Me>1?null:(A*he+I*se+z*_e)*X}function L_(t,e,i){return(t-e)/(i-e)}function R_(t,e,i,n,s,l,u,p,m){const _=1<<i,y=l-n,v=u-s,w=(t+1)/_*y+n,E=(e+0)/_*v+s,A=(e+1)/_*v+s;p[0]=(t+0)/_*y+n,p[1]=E,m[0]=w,m[1]=A}class k_{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;const i=function(l){const u=Math.ceil(Math.log2(l.dim/8)),p=[];let m=Math.ceil(Math.pow(2,u));const _=1/m,y=(E,A,I,z,L)=>{const N=z?1:0,G=(E+1)*I-N,j=A*I,X=(A+1)*I-N;L[0]=E*I,L[1]=j,L[2]=G,L[3]=X};let v=new P_(m);const w=[];for(let E=0;E<m*m;E++){y(E%m,Math.floor(E/m),_,!1,w);const A=zs(w[0],w[1],l),I=zs(w[2],w[1],l),z=zs(w[2],w[3],l),L=zs(w[0],w[3],l);v.minimums.push(Math.min(A,I,z,L)),v.maximums.push(Math.max(A,I,z,L)),v.leaves.push(1)}for(p.push(v),m/=2;m>=1;m/=2){const E=p[p.length-1];v=new P_(m);for(let A=0;A<m*m;A++){y(A%m,Math.floor(A/m),2,!0,w);const I=E.getElevation(w[0],w[1]),z=E.getElevation(w[2],w[1]),L=E.getElevation(w[2],w[3]),N=E.getElevation(w[0],w[3]),G=E.isLeaf(w[0],w[1]),j=E.isLeaf(w[2],w[1]),X=E.isLeaf(w[2],w[3]),W=E.isLeaf(w[0],w[3]),J=Math.min(I.min,z.min,L.min,N.min),ie=Math.max(I.max,z.max,L.max,N.max),oe=G&&j&&X&&W;v.maximums.push(ie),v.minimums.push(J),v.leaves.push(ie-J<=5&&oe?1:0)}p.push(v)}return p}(this.dem),n=i.length-1,s=i[n];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(i,0,0,n,0)}raycastRoot(e,i,n,s,l,u,p=1){return z_([e,i,-100],[n,s,this.maximums[0]*p],l,u)}raycast(e,i,n,s,l,u,p=1){if(!this.nodeCount)return null;const m=this.raycastRoot(e,i,n,s,l,u,p);if(null==m)return null;const _=[],y=[],v=[],w=[],E=[{idx:0,t:m,nodex:0,nodey:0,depth:0}];for(;E.length>0;){const{idx:A,t:I,nodex:z,nodey:L,depth:N}=E.pop();if(this.leaves[A]){R_(z,L,N,e,i,n,s,v,w);const j=1<<N,X=(z+0)/j,W=(z+1)/j,J=(L+0)/j,ie=(L+1)/j,oe=zs(X,J,this.dem)*p,he=zs(W,J,this.dem)*p,se=zs(W,ie,this.dem)*p,_e=zs(X,ie,this.dem)*p,Me=D_(v[0],v[1],oe,w[0],v[1],he,w[0],w[1],se,l,u),fe=D_(w[0],w[1],se,v[0],w[1],_e,v[0],v[1],oe,l,u),we=Math.min(null!==Me?Me:Number.MAX_VALUE,null!==fe?fe:Number.MAX_VALUE);if(we!==Number.MAX_VALUE)return we;{const de=a.N.scaleAndAdd([],l,u,I);if(O_(oe,he,_e,se,L_(de[0],v[0],w[0]),L_(de[1],v[1],w[1]))>=de[2])return I}continue}let G=0;for(let j=0;j<this._siblingOffset.length;j++){R_((z<<1)+this._siblingOffset[j][0],(L<<1)+this._siblingOffset[j][1],N+1,e,i,n,s,v,w),v[2]=-100,w[2]=this.maximums[this.childOffsets[A]+j]*p;const X=z_(v,w,l,u);if(null!=X){const W=X;_[j]=W;let J=!1;for(let ie=0;ie<G&&!J;ie++)W>=_[y[ie]]&&(y.splice(ie,0,j),J=!0);J||(y[G]=j),G++}}for(let j=0;j<G;j++){const X=y[j];E.push({idx:this.childOffsets[A]+X,t:_[X],nodex:(z<<1)+this._siblingOffset[X][0],nodey:(L<<1)+this._siblingOffset[X][1],depth:N+1})}}return null}_addNode(e,i,n){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,n,s,l){if(1===e[s].isLeaf(i,n))return;this.childOffsets[l]||(this.childOffsets[l]=this.nodeCount);const u=s-1,p=e[u];let m=0,_=0;for(let y=0;y<this._siblingOffset.length;y++){const v=2*i+this._siblingOffset[y][0],w=2*n+this._siblingOffset[y][1],E=p.getElevation(v,w),A=p.isLeaf(v,w),I=this._addNode(E.min,E.max,A);A&&(m|=1<<y),_||(_=I)}for(let y=0;y<this._siblingOffset.length;y++)m&1<<y||this._construct(e,2*i+this._siblingOffset[y][0],2*n+this._siblingOffset[y][1],u,_+y)}}function O_(t,e,i,n,s,l){return Ut(Ut(t,i,l),Ut(e,n,l),s)}function zs(t,e,i){const n=i.dim,s=Dt(t*n-.5,0,n-1),l=Dt(e*n-.5,0,n-1),u=Math.floor(s),p=Math.floor(l),m=Math.min(u+1,n-1),_=Math.min(p+1,n-1);return O_(i.get(u,p),i.get(m,p),i.get(u,_),i.get(m,_),s-u,l-p)}const ix={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function rx(t,e,i){return(256*t*256+256*e+i)/10-1e4}function nx(t,e,i){return 256*t+e+i/256-32768}class ud{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,n,s=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(n&&"mapbox"!==n&&"terrarium"!==n)return ki(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;const l=this.dim=i.height-2,u=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=s,this._modifiedForSources={},!s){for(let m=0;m<l;m++)u[this._idx(-1,m)]=u[this._idx(0,m)],u[this._idx(l,m)]=u[this._idx(l-1,m)],u[this._idx(m,-1)]=u[this._idx(m,0)],u[this._idx(m,l)]=u[this._idx(m,l-1)];u[this._idx(-1,-1)]=u[this._idx(0,0)],u[this._idx(l,-1)]=u[this._idx(l-1,0)],u[this._idx(-1,l)]=u[this._idx(0,l-1)],u[this._idx(l,l)]=u[this._idx(l-1,l-1)]}const p="terrarium"===n?nx:rx;for(let m=0;m<u.length;++m){const _=4*m;this.floatView[m]=p(this.pixels[_],this.pixels[_+1],this.pixels[_+2])}this._timestamp=ze.now()}_buildQuadTree(){this._tree=new k_(this)}get(e,i,n=!1){n&&(e=Dt(e,-1,this.dim),i=Dt(i,-1,this.dim));const s=this._idx(e,i);return this.floatView[s]}set(e,i,n){const s=this._idx(e,i),l=this.floatView[s];return this.floatView[s]=n,n-l}static getUnpackVector(e){return ix[e]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(e+1)}static pack(e,i){const n=[0,0,0,0],s=ud.getUnpackVector(i);let 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 g_({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=i*this.dim,l=i*this.dim+this.dim,u=n*this.dim,p=n*this.dim+this.dim;switch(i){case-1:s=l-1;break;case 1:l=s+1}switch(n){case-1:u=p-1;break;case 1:p=u+1}const m=-i*this.dim,_=-n*this.dim;for(let y=u;y<p;y++)for(let v=s;v<l;v++){const w=4*this._idx(v,y),E=4*this._idx(v+m,y+_);this.pixels[w+0]=e.pixels[E+0],this.pixels[w+1]=e.pixels[E+1],this.pixels[w+2]=e.pixels[E+2],this.pixels[w+3]=e.pixels[E+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Ke(ud,"DEMData"),Ke(k_,"DemMinMaxQuadTree",{omit:["dem"]});class Pl{constructor(e,i,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=n}static create(e,i,n){const s=n||e.findDEMTileFor(i);if(!s||!s.dem)return;const l=s.dem,u=s.tileID,p=1<<i.canonical.z-u.canonical.z;return new Pl(s,l.dim/qe/p,[(i.canonical.x/p-u.canonical.x)*l.dim,(i.canonical.y/p-u.canonical.y)*l.dim])}tileCoordToPixel(e,i){const n=i*this._scale+this._offset[1],s=Math.floor(e*this._scale+this._offset[0]),l=Math.floor(n);return new Ue(s,l)}getElevationAt(e,i,n,s){const l=e*this._scale+this._offset[0],u=i*this._scale+this._offset[1],p=Math.floor(l),m=Math.floor(u),_=this._dem;return s=!!s,n?Ut(Ut(_.get(p,m,s),_.get(p,m+1,s),u-m),Ut(_.get(p+1,m,s),_.get(p+1,m+1,s),u-m),l-p):_.get(p,m,s)}getElevationAtPixel(e,i,n){return this._dem.get(e,i,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*bt(1,e)*this._dem.stride}}const ox=ld.types,sx=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],ax=["fill-extrusion-flood-light-ground-radius"],lx=Math.pow(2,13),cx=Math.pow(2,15)-1,B_=new Ue(0,1),Ds=2147483648;function Ih(t,e,i,n,s,l,u,p){t.emplaceBack((e<<1)+u,(i<<1)+l,(Math.floor(n*lx)<<1)+s,Math.round(p))}function dd(t,e,i,n,s,l){t.emplaceBack(e.x,e.y,(i.x<<1)+n,(i.y<<1)+s,l)}function Ch(t,e,i){t.emplaceBack(e.x,e.y,e.z,16384*i[0],16384*i[1],16384*i[2])}class F_{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class N_{constructor(){this.centroidXY=new Ue(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Ue(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Ue(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new Ue(this.max.x-this.min.x,this.max.y-this.min.y)}}class V_{constructor(){this.acc=new Ue(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,i){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=i.x,e.min.y=e.max.y=i.y)}appendEdge(e,i,n){this.accCount++,this.acc._add(i);let s=!!this.borders;i.x<e.min.x?(e.min.x=i.x,s=!0):i.x>e.max.x&&(e.max.x=i.x,s=!0),i.y<e.min.y?(e.min.y=i.y,s=!0):i.y>e.max.y&&(e.max.y=i.y,s=!0),((0===i.x||i.x===qe)&&i.x===n.x)!=((0===i.y||i.y===qe)&&i.y===n.y)&&this.processBorderOverlap(i,n),s&&this.checkBorderIntersection(i,n)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,Ut(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>qe!=e.x>qe&&this.addBorderIntersection(1,Ut(i.y,e.y,(qe-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,Ut(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>qe!=e.y>qe&&this.addBorderIntersection(3,Ut(i.x,e.x,(qe-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){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]]);const n=this.borders[e];i<n[0]&&(n[0]=i),i>n[1]&&(n[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,i.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,i.x),this.addBorderIntersection(n,e.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0):0}}function U_(t,e){const i=t.add(e)._unit(),n=Dt(t.x*i.x+t.y*i.y,-1,1);var s,l,u;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*cx*((l=t).x*(u=e).y-l.y*u.x<0?-1:1)}const hx=[t=>t.x<0,t=>t.x>qe,t=>t.y<0,t=>t.y>qe];function ux(t,e,i,n){const s=[4];if(0===n)return s;i._mult(n);const l=t.sub(i),u=e.sub(i),p=[t,e,l,u];for(let m=0;m<4;m++)for(const _ of p)if(hx[m](_)){s.push(m);break}return s}class j_{constructor(e){this.vertexArray=new ah,this.indexArray=new Ji,this.programConfigurations=new k(e.layers,e.zoom,i=>ax.includes(i)),this._segments=new Oi,this.hiddenByLandmarkVertexArray=new _h,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Oi}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,i,n,s=!1){const l=e.length;if(l>2){let u=Math.max(0,this._segments.get().length-1);const p=this._segments._prepareSegment(4*l,this.vertexArray.length,2*this._segmentToGroundQuads[u].length);let m;u!==this._segments.get().length-1&&(u++,this._segmentToGroundQuads[u]=[],this._segmentToRegionTriCounts[u]=[0,0,0,0,0]);{const _=e[0],y=e[1];m=U_(_.sub(e[l-1])._perp()._unit(),y.sub(_)._perp()._unit())}for(let _=0;_<l;_++){const y=_===l-1?0:_+1,v=e[_],w=e[y],E=e[y===l-1?0:y+1],A=w.sub(v)._perp()._unit(),I=U_(A,E.sub(w)._perp()._unit()),z=m,L=I;if(Xp(v,w,i)||s&&q_(v,i)&&q_(w,i)){m=I;continue}const N=p.vertexLength;dd(this.vertexArray,v,w,1,1,z),dd(this.vertexArray,v,w,1,0,z),dd(this.vertexArray,v,w,0,1,L),dd(this.vertexArray,v,w,0,0,L),p.vertexLength+=4;const G=ux(v,w,A,n);for(const j of G)this._segmentToGroundQuads[u].push({id:N,region:j}),this._segmentToRegionTriCounts[u][j]+=2,p.primitiveLength+=2;m=I}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),i=e.length;for(let n=0;n<i;n++)this._segmentToGroundQuads[n].sort((s,l)=>s.region-l.region);for(let n=0;n<i;n++){const s=this._segmentToGroundQuads[n],l=e[n],u=this._segmentToRegionTriCounts[n];u.reduce((m,_)=>m+_,0);let p=0;for(let m=0;m<=4;m++){const _=u[m];if(0!==_){let y=this.regionSegments[m];y||(y=this.regionSegments[m]=new Oi);const v={vertexOffset:l.vertexOffset,primitiveOffset:l.primitiveOffset+p,vertexLength:l.vertexLength,primitiveLength:_};y.get().push(v)}p+=_}for(let m=0;m<s.length;m++){const _=s[m].id;this.indexArray.emplaceBack(_,_+1,_+3),this.indexArray.emplaceBack(_,_+3,_+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,i,n,s,l,u){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,i,n,s,l,u)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,G0.members),this.indexBuffer=e.createIndexBuffer(this.indexArray))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,i,n,s,l,u){this.hasData()&&this.programConfigurations.updatePaintArrays(e,i,n,s,l,u)}updateHiddenByLandmark(e){if(!this.hasData())return;const i=e.groundVertexCount+e.groundVertexArrayOffset;if(0===e.groundVertexCount)return;const n=e.flags&Ds?1:0;for(let s=e.groundVertexArrayOffset;s<i;++s)this.hiddenByLandmarkVertexArray.emplace(s,n);this._needsHiddenByLandmarkUpdate=!0}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,q0.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const i=this.regionSegments[e];i&&i.destroy()}}}}class pd{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ji,this.footprintVertices=new cn,this.footprintSegments=[],this.layoutVertexArray=new Rn,this.centroidVertexArray=new Aa,this.indexArray=new Ji,this.programConfigurations=new k(e.layers,e.zoom,i=>sx.includes(i)),this.segments=new Oi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.groundEffect=new j_(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,i,n,s){this.features=[],this.hasPattern=qp("fill-extrusion",this.layers,i),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Ft(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:l,id:u,index:p,sourceLayerIndex:m}of e){const _=this.layers[0]._featureFilter.needGeometry,y=Hi(l,_);if(!this.layers[0]._featureFilter.filter(new Ai(this.zoom),y,n))continue;const v={id:u,sourceLayerIndex:m,index:p,geometry:_?y.geometry:er(l,n,s),properties:l.properties,type:l.type,patterns:{}},w=this.layoutVertexArray.length;this.hasPattern?this.features.push($p("fill-extrusion",this.layers,v,this.zoom,i)):this.addFeature(v,v.geometry,p,n,{},i.availableImages,s,i.brightness),i.featureIndex.insert(l,v.geometry,p,m,this.index,w)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,n,s,l,u){for(const p of this.features){const{geometry:m}=p;this.addFeature(p,m,p.index,i,n,s,l,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,i,n,s,l){const u=0!==Object.keys(e).length;if(u&&!this.stateDependentLayers.length)return;const p=u?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,i,p,n,s,l),this.groundEffect.update(e,i,p,n,s,l)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,W0),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,$0.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Z0.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,n,s,l,u,p,m){const _=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,y=[new Ue(0,0),new Ue(qe,qe)],v=p.projection,w="globe"===v.name,E="Polygon"===ox[e.type],A=new V_;A.centroidDataIndex=this.centroidData.length;const I=new N_,z=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},s)<=0,L=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},s);I.height=L,I.vertexArrayOffset=this.layoutVertexArray.length,I.groundVertexArrayOffset=this.groundEffect.vertexArray.length,w&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new xl);const N=Zp(i,500);for(let ie=N.length-1;ie>=0;ie--){const oe=N[ie];(0===oe.length||(G=oe[0]).every(he=>he.x<=0)||G.every(he=>he.x>=qe)||G.every(he=>he.y<=0)||G.every(he=>he.y>=qe))&&N.splice(ie,1)}var G;let j;if(w)j=X_(N,y,s);else{j=[];for(const ie of N)j.push({polygon:ie,bounds:y})}const X=E?this.edgeRadius:0,W=X>0&&this.zoom<17,J=(ie,oe)=>{if(0===ie.length)return!1;const he=ie[ie.length-1];return oe.x===he.x&&oe.y===he.y};for(const{polygon:ie,bounds:oe}of j){let he=0,se=0;for(const we of ie)E&&!we[0].equals(we[we.length-1])&&we.push(we[0]),se+=E?we.length-1:we.length;const _e=this.segments.prepareSegment((E?5:4)*se,this.layoutVertexArray,this.indexArray);I.footprintSegIdx<0&&(I.footprintSegIdx=this.footprintSegments.length),I.polygonSegIdx<0&&(I.polygonSegIdx=this.polygonSegments.length);const Me={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},fe=new F_;if(fe.vertexOffset=this.footprintVertices.length,fe.indexOffset=3*this.footprintIndices.length,fe.ringIndices=[],E){const we=[],de=[];he=_e.vertexLength;for(let Fe=0;Fe<ie.length;Fe++){const Se=ie[Fe];Se.length&&0!==Fe&&de.push(we.length/2);const Qe=[];let He,Ce;He=Se[1].sub(Se[0])._perp()._unit(),fe.ringIndices.push(Se.length-1);for(let ft=1;ft<Se.length;ft++){const st=Se[ft],Je=Se[ft===Se.length-1?1:ft+1],Pe=st.clone();if(X){Ce=Je.sub(st)._perp()._unit();const ut=He.add(Ce)._unit(),It=X*Math.min(4,1/(He.x*ut.x+He.y*ut.y));Pe.x+=It*ut.x,Pe.y+=It*ut.y,Pe.x=Math.round(Pe.x),Pe.y=Math.round(Pe.y),He=Ce}!z||0!==X&&!W||J(Qe,Pe)||Qe.push(Pe),Ih(this.layoutVertexArray,Pe.x,Pe.y,0,0,1,1,0),_e.vertexLength++,this.footprintVertices.emplaceBack(st.x,st.y),we.push(st.x,st.y),w&&Ch(this.layoutVertexExtArray,v.projectTilePoint(Pe.x,Pe.y,s),v.upVector(s,Pe.x,Pe.y))}z&&(0===X||W)&&(0!==Qe.length&&J(Qe,Qe[0])&&Qe.pop(),this.groundEffect.addData(Qe,oe,_))}const be=sd(we,de);for(let Fe=0;Fe<be.length;Fe+=3)this.footprintIndices.emplaceBack(fe.vertexOffset+be[Fe+0],fe.vertexOffset+be[Fe+1],fe.vertexOffset+be[Fe+2]),this.indexArray.emplaceBack(he+be[Fe],he+be[Fe+2],he+be[Fe+1]),_e.primitiveLength++;fe.indexCount+=be.length,fe.vertexCount+=this.footprintVertices.length-fe.vertexOffset}for(let we=0;we<ie.length;we++){const de=ie[we];A.startRing(I,de[0]);let be=de.length>4&&$_(de[de.length-2],de[0],de[1]),Fe=X?dx(de[de.length-2],de[0],de[1],X):0;const Se=[];let Qe,He,Ce;He=de[1].sub(de[0])._perp()._unit();let ft=!0;for(let st=1,Je=0;st<de.length;st++){let Pe=de[st-1],ut=de[st];const It=de[st===de.length-1?1:st+1];if(A.appendEdge(I,ut,Pe),Xp(ut,Pe,oe)){X&&(He=It.sub(ut)._perp()._unit(),ft=!ft);continue}const mt=ut.sub(Pe)._perp(),Ct=mt.x/(Math.abs(mt.x)+Math.abs(mt.y)),xt=mt.y>0?1:0,jt=Pe.dist(ut);if(Je+jt>32768&&(Je=0),X){Ce=It.sub(ut)._perp()._unit();let ei=Z_(Pe,ut,It,G_(He,Ce),X);isNaN(ei)&&(ei=0);const si=ut.sub(Pe)._unit();Pe=Pe.add(si.mult(Fe))._round(),ut=ut.add(si.mult(-ei))._round(),Fe=ei,He=Ce,z&&this.zoom>=17&&(J(Se,Pe)||Se.push(Pe),J(Se,ut)||Se.push(ut))}const wt=_e.vertexLength,mi=de.length>4&&$_(Pe,ut,It);let Jt=W_(Je,be,ft);if(Ih(this.layoutVertexArray,Pe.x,Pe.y,Ct,xt,0,0,Jt),Ih(this.layoutVertexArray,Pe.x,Pe.y,Ct,xt,0,1,Jt),Je+=jt,Jt=W_(Je,mi,!ft),be=mi,Ih(this.layoutVertexArray,ut.x,ut.y,Ct,xt,0,0,Jt),Ih(this.layoutVertexArray,ut.x,ut.y,Ct,xt,0,1,Jt),_e.vertexLength+=4,this.indexArray.emplaceBack(wt+0,wt+1,wt+2),this.indexArray.emplaceBack(wt+1,wt+3,wt+2),_e.primitiveLength+=2,X){const ei=he+(1===st?de.length-2:st-2),si=1===st?he:ei+1;if(this.indexArray.emplaceBack(wt+1,ei,wt+3),this.indexArray.emplaceBack(ei,si,wt+3),_e.primitiveLength+=2,void 0===Qe&&(Qe=wt),!Xp(It,de[st],oe)){const Qt=st===de.length-1?Qe:_e.vertexLength;this.indexArray.emplaceBack(wt+2,wt+3,Qt),this.indexArray.emplaceBack(wt+3,Qt+1,Qt),this.indexArray.emplaceBack(wt+3,si,Qt+1),_e.primitiveLength+=3}ft=!ft}if(w){const ei=this.layoutVertexExtArray,si=v.projectTilePoint(Pe.x,Pe.y,s),Qt=v.projectTilePoint(ut.x,ut.y,s),Si=v.upVector(s,Pe.x,Pe.y),hi=v.upVector(s,ut.x,ut.y);Ch(ei,si,Si),Ch(ei,si,Si),Ch(ei,Qt,hi),Ch(ei,Qt,hi)}}E&&(he+=de.length-1),z&&X&&this.zoom>=17&&(0!==Se.length&&J(Se,Se[0])&&Se.pop(),this.groundEffect.addData(Se,oe,_,X>0))}this.footprintSegments.push(fe),Me.triangleCount=this.indexArray.length-Me.triangleArrayOffset,this.polygonSegments.push(Me),++I.footprintSegLen,++I.polygonSegLen}if(I.vertexCount=this.layoutVertexArray.length-I.vertexArrayOffset,I.groundVertexCount=this.groundEffect.vertexArray.length-I.groundVertexArrayOffset,0!==I.vertexCount){if(I.centroidXY=A.borders?B_:this.encodeCentroid(A,I),this.centroidData.push(I),A.borders){this.featuresOnBorder.push(A);const ie=this.featuresOnBorder.length-1;for(let oe=0;oe<A.borders.length;oe++)A.borders[oe][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[oe].push(ie)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s,m),this.groundEffect.addPaintPropertiesData(e,n,l,u,s,m),this.maxHeight=Math.max(this.maxHeight,L)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((i,n)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}splitToSubtiles(){const e=[];for(let p=0;p<this.centroidData.length;p++){const m=this.centroidData[p],_=+(m.min.y+m.max.y>qe),y=2*_+(+(m.min.x+m.max.x>qe)^_);for(let v=0;v<m.polygonSegLen;v++){const w=m.polygonSegIdx+v;e.push({centroidIdx:p,subtile:y,polygonSegmentIdx:w,triangleSegmentIdx:this.polygonSegments[w].triangleSegIdx})}}const i=new Ji;e.sort((p,m)=>p.triangleSegmentIdx===m.triangleSegmentIdx?p.subtile-m.subtile:p.triangleSegmentIdx-m.triangleSegmentIdx);let n=0,s=0,l=0;for(const p of e){if(p.triangleSegmentIdx!==n)break;l++}const u=e.length;for(;s!==e.length;){n=e[s].triangleSegmentIdx;let p=0,m=s,_=s;for(let y=m;y<l&&e[y].subtile===p;y++)_++;for(;m!==l;){const y=e[m];p=y.subtile;const v=this.centroidData[y.centroidIdx].min.clone(),w=this.centroidData[y.centroidIdx].max.clone(),E={vertexOffset:this.segments.segments[n].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[n].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let A=m;A<_;A++){const I=e[A],z=this.polygonSegments[I.polygonSegmentIdx],L=this.centroidData[I.centroidIdx].min,N=this.centroidData[I.centroidIdx].max,G=this.indexArray.uint16;for(let j=z.triangleArrayOffset;j<z.triangleArrayOffset+z.triangleCount;j++)i.emplaceBack(G[3*j],G[3*j+1],G[3*j+2]);E.primitiveLength+=z.triangleCount,v.x=Math.min(v.x,L.x),v.y=Math.min(v.y,L.y),w.x=Math.max(w.x,N.x),w.y=Math.max(w.y,N.y)}E.primitiveLength>0&&this.triangleSubSegments.push({segment:E,min:v,max:w}),m=_;for(let A=m;A<l&&e[A].subtile===e[m].subtile;A++)_++}s=l;for(let y=s;y<u&&e[y].triangleSegmentIdx===e[s].triangleSegmentIdx;y++)l++}i._trim(),this.indexArray=i}getVisibleSegments(e,i,n){let s=0,l=0;const u=1<<e.canonical.z;if(i){const I=i.getMinMaxForTile(e);I&&(s=I.min,l=I.max)}l+=this.maxHeight;const p=e.toUnwrapped();let m;const _=[p.canonical.x/u+p.wrap,p.canonical.y/u],y=[(p.canonical.x+1)/u+p.wrap,(p.canonical.y+1)/u],v=new Oi,w=(I,z,L)=>[I[0]*(1-L[0])+z[0]*L[0],I[1]*(1-L[1])+z[1]*L[1]],E=[],A=[];for(const I of this.triangleSubSegments){E[0]=I.min.x/qe,E[1]=I.min.y/qe,A[0]=I.max.x/qe,A[1]=I.max.y/qe;const z=w(_,y,E),L=w(_,y,A);if(0===new Ri([z[0],z[1],s],[L[0],L[1],l]).intersectsPrecise(n)){m&&(v.segments.push(m),m=void 0);continue}const N=I.segment;m&&m.vertexOffset!==N.vertexOffset&&(v.segments.push(m),m=void 0),m?(m.vertexLength+=N.vertexLength,m.primitiveLength+=N.primitiveLength):m={vertexOffset:N.vertexOffset,primitiveLength:N.primitiveLength,vertexLength:N.vertexLength,primitiveOffset:N.primitiveOffset,sortKey:void 0,vaos:{}}}return m&&v.segments.push(m),v}encodeCentroid(e,i){const n=e.centroid(),s=i.span(),l=Math.min(7,Math.round(s.x*this.tileToMeter/10)),u=Math.min(7,Math.round(s.y*this.tileToMeter/10));return new Ue(Dt(n.x,1,8191)<<3|l,Dt(n.y,1,8191)<<3|u)}encodeBorderCentroid(e){if(!e.borders)return new Ue(0,0);const i=e.borders,n=Number.MAX_VALUE;if(i[0][0]!==n||i[1][0]!==n){const s=i[0][0]!==n?0:1;return new Ue(6|(i[0][0]!==n?0:65528),(i[s][0]+i[s][1])/2<<3|6)}{const s=i[2][0]!==n?2:3;return new Ue((i[s][0]+i[s][1])/2<<3|6,6|(i[2][0]!==n?0:65528))}}showCentroid(e){const i=this.centroidData[e.centroidDataIndex];i.flags&=Ds,i.centroidXY.x=0,i.centroidXY.y=0,this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const i=e.vertexArrayOffset,n=e.vertexCount+e.vertexArrayOffset,s=e.flags&Ds?B_:e.centroidXY,l=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==s.y||l!==s.x){for(let u=i;u<n;++u)this.centroidVertexArray.emplace(u,s.x,s.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;const n=i.getReplacementRegionsForTile(e.toUnwrapped());if(function(l,u){if(l.length!==u.length)return!1;for(let p=0;p<l.length;p++)if(l[p].sourceId!==u[p].sourceId||!E_(l[p],u[p]))return!1;return!0}(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const l of this.centroidData)l.flags&=2147483647;const s=[];for(const l of this.activeReplacements){const u=Math.pow(2,l.footprintTileId.canonical.z-e.canonical.z);for(const p of this.centroidData)if(!(p.flags&Ds||l.min.x>p.max.x||p.min.x>l.max.x||l.min.y>p.max.y||p.min.y>l.max.y))for(let m=0;m<p.footprintSegLen;m++){const _=this.footprintSegments[p.footprintSegIdx+m];if(s.length=0,px(this.footprintVertices,_.vertexOffset,_.vertexCount,l.footprintTileId.canonical,e.canonical,s),I_(l.footprint,s,this.footprintIndices.uint16,_.indexOffset,_.indexCount,-_.vertexOffset,-u)){p.flags|=Ds;break}}}for(const l of this.centroidData)this.writeCentroidToBuffer(l);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,i,n){let s=!1;for(let l=0;l<n.footprintSegLen;l++){const u=this.footprintSegments[n.footprintSegIdx+l];let p=0;for(const m of u.ringIndices){for(let _=p,y=m+p-1;_<m+p;y=_++){const v=this.footprintVertices.int16[2*(_+u.vertexOffset)+0],w=this.footprintVertices.int16[2*(_+u.vertexOffset)+1],E=this.footprintVertices.int16[2*(y+u.vertexOffset)+1];w>i!=E>i&&e<(this.footprintVertices.int16[2*(y+u.vertexOffset)+0]-v)*(i-w)/(E-w)+v&&(s=!s)}p=m}}return s}getHeightAtTileCoord(e,i){let n=Number.NEGATIVE_INFINITY,s=!0;const l=4*(e+qe)*qe+(i+qe);if(this.partLookup.hasOwnProperty(l)){const u=this.partLookup[l];return u?{height:u.height,hidden:!!(u.flags&Ds)}:void 0}for(const u of this.centroidData)e>u.max.x||u.min.x>e||i>u.max.y||u.min.y>i||this.footprintContainsPoint(e,i,u)&&u&&u.height>n&&(n=u.height,this.partLookup[l]=u,s=!!(u.flags&Ds));if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:s};this.partLookup[l]=void 0}}function G_(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function dx(t,e,i,n){const s=e.sub(t)._perp()._unit(),l=i.sub(e)._perp()._unit();return Z_(t,e,i,G_(s,l),n)}function Z_(t,e,i,n,s){const l=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,s*l/n)}function Xp(t,e,i){return t.x<i[0].x&&e.x<i[0].x||t.x>i[1].x&&e.x>i[1].x||t.y<i[0].y&&e.y<i[0].y||t.y>i[1].y&&e.y>i[1].y}function q_(t,e){return t.x<e[0].x||t.x>e[1].x||t.y<e[0].y||t.y>e[1].y}function $_(t,e,i){if(t.x<0||t.x>=qe||e.x<0||e.x>=qe||i.x<0||i.x>=qe)return!1;const n=i.sub(e),s=n.perp(),l=t.sub(e);return(n.x*l.x+n.y*l.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(l.x*l.x+l.y*l.y))>-.866&&s.x*l.x+s.y*l.y<0}function W_(t,e,i){const n=e?2|t:-3&t;return i?1|n:-2&n}function H_(){const t=Math.PI/32,e=Math.tan(t),i=pe;return i*Math.sqrt(1+2*e*e)-i}function X_(t,e,i){const n=1<<i.z,s=vt(i.x/n),l=vt((i.x+1)/n),u=Zt(i.y/n),p=Zt((i.y+1)/n);return function(m,_,y,v,w=0,E){const A=[];if(!m.length||!y||!v)return A;const I=(W,J)=>{for(const ie of W)A.push({polygon:ie,bounds:J})},z=Math.ceil(Math.log2(y)),L=Math.ceil(Math.log2(v)),N=z-L,G=[];for(let W=0;W<Math.abs(N);W++)G.push(N>0?0:1);for(let W=0;W<Math.min(z,L);W++)G.push(0),G.push(1);let j=m;if(j=cd(j,_[0].y-w,_[1].y+w,1),j=cd(j,_[0].x-w,_[1].x+w,0),!j.length)return A;const X=[];for(G.length?X.push({polygons:j,bounds:_,depth:0}):I(j,_);X.length;){const W=X.pop(),J=W.depth,ie=G[J],oe=W.bounds[0],he=W.bounds[1],se=0===ie?oe.x:oe.y,_e=0===ie?he.x:he.y,Me=E?E(ie,se,_e):.5*(se+_e),fe=cd(W.polygons,se-w,Me+w,ie),we=cd(W.polygons,Me-w,_e+w,ie);if(fe.length){const de=[oe,new Ue(0===ie?Me:he.x,1===ie?Me:he.y)];G.length>J+1?X.push({polygons:fe,bounds:de,depth:J+1}):I(fe,de)}if(we.length){const de=[new Ue(0===ie?Me:oe.x,1===ie?Me:oe.y),he];G.length>J+1?X.push({polygons:we,bounds:de,depth:J+1}):I(we,de)}}return A}(t,e,Math.ceil((l-s)/11.25),Math.ceil((u-p)/11.25),1,(m,_,y)=>{if(0===m)return.5*(_+y);{const v=Zt((i.y+_/qe)/n);return(gt(.5*(Zt((i.y+y/qe)/n)+v))*n-i.y)*qe}})}function px(t,e,i,n,s,l){const u=Math.pow(2,n.z-s.z);for(let p=0;p<i;p++){let m=t.int16[2*(p+e)+0],_=t.int16[2*(p+e)+1];m=(m+s.x*qe)*u-n.x*qe,_=(_+s.y*qe)*u-n.y*qe,l.push(new Ue(m,_))}}Ke(pd,"FillExtrusionBucket",{omit:["layers","features"]}),Ke(N_,"PartData"),Ke(F_,"FootprintSegment"),Ke(V_,"BorderCentroidData"),Ke(j_,"GroundEffect");const fx=new Ii({visibility:new Oe(le["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new Oe(le["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var mx={paint:new Ii({"fill-extrusion-opacity":new Oe(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ht(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Oe(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Oe(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ht(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ht(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ht(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Oe(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Oe(le["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Oe(le["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new Oe(le["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new Oe(le["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new Oe(le["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new Oe(le["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new Oe(le["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ht(le["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ht(le["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new Oe(le["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new Oe(le["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new Oe(le["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new Oe(le["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new Oe(le["paint_fill-extrusion"]["fill-extrusion-emissive-strength"])}),layout:fx};class zl extends Ue{constructor(e,i,n){super(e,i),this.z=n}}function Ph(t,e){return t.x*e.x+t.y*e.y}function Y_(t,e){if(1===t.length){let i=0;const n=e[i++];let s;for(;!s||n.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){const l=e[i],u=t[0],p=s.sub(n),m=l.sub(n),_=u.sub(n),y=Ph(p,p),v=Ph(p,m),w=Ph(m,m),E=Ph(_,p),A=Ph(_,m),I=y*w-v*v,z=(w*E-v*A)/I,L=(y*A-v*E)/I,N=n.z*(1-z-L)+s.z*z+l.z*L;if(isFinite(N))return N}return 1/0}{let i=1/0;for(const n of e)i=Math.min(i,n.z);return i}}function K_(t,e,i,n,s,l,u,p){const m=u*s.getElevationAt(t,e,!0,!0),_=0!==l[0],y=_?0===l[1]?u*(l[0]/7-450):u*function(v,w,E){const A=Math.floor(w[0]/8),I=Math.floor(w[1]/8),z=10*(w[0]-8*A),L=10*(w[1]-8*I),N=v.getElevationAt(A,I,!0,!0),G=v.getMeterToDEM(E),j=Math.floor(.5*(z*G-1)),X=Math.floor(.5*(L*G-1)),W=v.tileCoordToPixel(A,I),J=2*j+1,ie=2*X+1,oe=(Fe=J,Se=ie,[(we=v).getElevationAtPixel(de=W.x-j,be=W.y-X,!0),we.getElevationAtPixel(de+Se,be,!0),we.getElevationAtPixel(de,be+Se,!0),we.getElevationAtPixel(de+Fe,be+Se,!0)]),he=Math.abs(oe[0]-oe[1]),se=Math.abs(oe[2]-oe[3]),_e=Math.abs(oe[0]-oe[2])+Math.abs(oe[1]-oe[3]),Me=Math.min(.25,.5*G*(he+se)/J),fe=Math.min(.25,.5*G*_e/ie);var we,de,be,Fe,Se;return N+Math.max(Me*z,fe*L)}(s,l,p):m;return{base:m+(0===i)?-1:i,top:_?Math.max(y+n,m+i+2):m+n}}const _x=li([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:gx}=_x,yx=li([{name:"a_packed",components:4,type:"Float32"}]),{members:xx}=yx;class J_{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new Ps({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){const n=this.getKey(e,i);return this.positions[n]}trim(){const e=this.width,i=this.height=Gs(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,n){const s=[];let 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:0===e[0]});let m=e[0];for(let _=1;_<e.length;_++){p=!p;const y=e[_];l=m*n,m+=y,u=m*n,s.push({left:l,right:u,isDash:p,zeroLength:0===y})}return s}addRoundDash(e,i,n){const s=i/2;for(let l=-n;l<=n;l++){const u=this.width*(this.nextRow+n+l);let p=0,m=e[p];for(let _=0;_<this.width;_++){_/m.right>1&&(m=e[++p]);const y=Math.abs(_-m.left),v=Math.abs(_-m.right),w=Math.min(y,v);let E;const A=l/n*(s+1);if(m.isDash){const I=s-Math.abs(A);E=Math.sqrt(w*w+I*I)}else E=s-Math.sqrt(w*w+A*A);this.image.data[u+_]=Math.max(0,Math.min(255,E+128))}}}addRegularDash(e,i){for(let m=e.length-1;m>=0;--m){const _=e[m],y=e[m+1];_.zeroLength?e.splice(m,1):y&&y.isDash===_.isDash&&(y.left=_.left,e.splice(m,1))}const n=e[0],s=e[e.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const l=this.width*this.nextRow;let u=0,p=e[u];for(let m=0;m<this.width;m++){m/p.right>1&&(p=e[++u]);const _=Math.abs(m-p.left),y=Math.abs(m-p.right),v=Math.min(_,y);this.image.data[l+m]=Math.max(0,Math.min(255,(p.isDash?v:-v)+i+128))}}addDash(e,i){const n=this.getKey(e,i);if(this.positions[n])return this.positions[n];const s="round"===i,l=s?7:0,u=2*l+1;if(this.nextRow+u>this.height)return ki("LineAtlas out of space"),null;0===e.length&&e.push(1);let p=0;for(let y=0;y<e.length;y++)e[y]<0&&(ki("Negative value is found in line dasharray, replacing values with 0"),e[y]=0),p+=e[y];if(0!==p){const y=this.width/p,v=this.getDashRanges(e,this.width,y);s?this.addRoundDash(v,y,l):this.addRegularDash(v,"square"===i?.5*y:0)}const m=this.nextRow+l;this.nextRow+=u;const _={tl:[m,l],br:[p,0]};return this.positions[n]=_,_}}Ke(J_,"LineAtlas");const vx=ld.types,bx=Math.cos(Math.PI/180*37.5);class Yp{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new lh,this.layoutVertexArray2=new uo,this.indexArray=new Ji,this.programConfigurations=new k(e.layers,e.zoom),this.segments=new Oi,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,s){this.hasPattern=qp("line",this.layers,i);const l=this.layers[0].layout.get("line-sort-key"),u=[];for(const{feature:y,id:v,index:w,sourceLayerIndex:E}of e){const A=this.layers[0]._featureFilter.needGeometry,I=Hi(y,A);if(!this.layers[0]._featureFilter.filter(new Ai(this.zoom),I,n))continue;const z=l?l.evaluate(I,{},n):void 0,L={id:v,properties:y.properties,type:y.type,sourceLayerIndex:E,index:w,geometry:A?I.geometry:er(y,n,s),patterns:{},sortKey:z};u.push(L)}l&&u.sort((y,v)=>y.sortKey-v.sortKey);const{lineAtlas:p,featureIndex:m}=i,_=this.addConstantDashes(p);for(const y of u){const{geometry:v,index:w,sourceLayerIndex:E}=y;if(_&&this.addFeatureDashes(y,p),this.hasPattern){const A=$p("line",this.layers,y,this.zoom,i);this.patternFeatures.push(A)}else this.addFeature(y,v,w,n,p.positions,i.availableImages,i.brightness);m.insert(e[w].feature,v,w,E,this.index)}}addConstantDashes(e){let i=!1;for(const n of this.layers){const s=n.paint.get("line-dasharray").value,l=n.layout.get("line-cap").value;if("constant"!==s.kind||"constant"!==l.kind)i=!0;else{const u=l.value,p=s.value;if(!p)continue;e.addDash(p,u)}}return i}addFeatureDashes(e,i){const n=this.zoom;for(const s of this.layers){const l=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if("constant"===l.kind&&"constant"===u.kind)continue;let p,m;if("constant"===l.kind){if(p=l.value,!p)continue}else p=l.evaluate({zoom:n},e);m="constant"===u.kind?u.value:u.evaluate({zoom:n},e),i.addDash(p,m),e.patterns[s.id]=i.getKey(p,m)}}update(e,i,n,s,l){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,n,s,l)}addFeatures(e,i,n,s,l,u){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,n,s,u)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,xx)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gx),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,i,n,s,l,u,p){const m=this.layers[0].layout,_=m.get("line-join").evaluate(e,{}),y=m.get("line-cap").evaluate(e,{}),v=m.get("line-miter-limit"),w=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const E of i)this.addLine(E,e,_,y,v,w);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,u,s,p)}addLine(e,i,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 L=0;L<e.length-1;L++)this.totalDistance+=e[L].dist(e[L+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const p="Polygon"===vx[i.type];let m=e.length;for(;m>=2&&e[m-1].equals(e[m-2]);)m--;let _=0;for(;_<m-1&&e[_].equals(e[_+1]);)_++;if(m<(p?3:2))return;"bevel"===n&&(l=1.05);const y=this.overscaling<=16?15*qe/(512*this.overscaling):0,v=this.segments.prepareSegment(10*m,this.layoutVertexArray,this.indexArray);let w,E,A,I,z;this.e1=this.e2=-1,p&&(w=e[m-2],z=e[_].sub(w)._unit()._perp());for(let L=_;L<m;L++){if(A=L===m-1?p?e[_+1]:void 0:e[L+1],A&&e[L].equals(A))continue;z&&(I=z),w&&(E=w),w=e[L],z=A?A.sub(w)._unit()._perp():I,I=I||z;let N=I.add(z);0===N.x&&0===N.y||N._unit();const G=I.x*z.x+I.y*z.y,j=N.x*z.x+N.y*z.y,X=0!==j?1/j:1/0,W=2*Math.sqrt(2-2*j),J=j<bx&&E&&A,ie=I.x*z.y-I.y*z.x>0;if(J&&L>_){const se=w.dist(E);if(se>2*y){const _e=w.sub(w.sub(E)._mult(y/se)._round());this.updateDistance(E,_e),this.addCurrentVertex(_e,I,0,0,v),E=_e}}const oe=E&&A;let he=oe?n:p?"butt":s;if(oe&&"round"===he&&(X<u?he="miter":X<=2&&(he="fakeround")),"miter"===he&&X>l&&(he="bevel"),"bevel"===he&&(X>2&&(he="flipbevel"),X<l&&(he="miter")),E&&this.updateDistance(E,w),"miter"===he)N._mult(X),this.addCurrentVertex(w,N,0,0,v);else if("flipbevel"===he){if(X>100)N=z.mult(-1);else{const se=X*I.add(z).mag()/I.sub(z).mag();N._perp()._mult(se*(ie?-1:1))}this.addCurrentVertex(w,N,0,0,v),this.addCurrentVertex(w,N.mult(-1),0,0,v)}else if("bevel"===he||"fakeround"===he){const se=-Math.sqrt(X*X-1),_e=ie?se:0,Me=ie?0:se;if(E&&this.addCurrentVertex(w,I,_e,Me,v),"fakeround"===he){const fe=Math.round(180*W/Math.PI/20);for(let we=1;we<fe;we++){let de=we/fe;if(.5!==de){const Fe=de-.5;de+=de*Fe*(de-1)*((1.0904+G*(G*(3.55645-1.43519*G)-3.2452))*Fe*Fe+(.848013+G*(.215638*G-1.06021)))}const be=z.sub(I)._mult(de)._add(I)._unit()._mult(ie?-1:1);this.addHalfVertex(w,be.x,be.y,!1,ie,0,v)}}A&&this.addCurrentVertex(w,z,-_e,-Me,v)}else if("butt"===he)this.addCurrentVertex(w,N,0,0,v);else if("square"===he){const se=E?1:-1;E||this.addCurrentVertex(w,N,se,se,v),this.addCurrentVertex(w,N,0,0,v),E&&this.addCurrentVertex(w,N,se,se,v)}else"round"===he&&(E&&(this.addCurrentVertex(w,I,0,0,v),this.addCurrentVertex(w,I,1,1,v,!0)),A&&(this.addCurrentVertex(w,z,-1,-1,v,!0),this.addCurrentVertex(w,z,0,0,v)));if(J&&L<m-1){const se=w.dist(A);if(se>2*y){const _e=w.add(A.sub(w)._mult(y/se)._round());this.updateDistance(w,_e),this.addCurrentVertex(_e,z,0,0,v),w=_e}}}}addCurrentVertex(e,i,n,s,l,u=!1){const p=i.y*s-i.x,m=-i.y-i.x*s;this.addHalfVertex(e,i.x+i.y*n,i.y-i.x*n,u,!1,n,l),this.addHalfVertex(e,p,m,u,!0,-s,l)}addHalfVertex({x:e,y:i},n,s,l,u,p,m){this.layoutVertexArray.emplaceBack((e<<1)+(l?1:0),(i<<1)+(u?1:0),Math.round(63*n)+128,Math.round(63*s)+128,1+(0===p?0:p<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const _=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,_),m.primitiveLength++),u?this.e2=_:this.e1=_}updateScaledDistance(){if(this.lineClips){const 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,i){this.distance+=e.dist(i),this.updateScaledDistance()}}Ke(Yp,"LineBucket",{omit:["layers","patternFeatures"]});const wx=new Ii({"line-cap":new ht(le.layout_line["line-cap"]),"line-join":new ht(le.layout_line["line-join"]),"line-miter-limit":new Oe(le.layout_line["line-miter-limit"]),"line-round-limit":new Oe(le.layout_line["line-round-limit"]),"line-sort-key":new ht(le.layout_line["line-sort-key"]),visibility:new Oe(le.layout_line.visibility)});var Q_={paint:new Ii({"line-opacity":new ht(le.paint_line["line-opacity"]),"line-color":new ht(le.paint_line["line-color"]),"line-translate":new Oe(le.paint_line["line-translate"]),"line-translate-anchor":new Oe(le.paint_line["line-translate-anchor"]),"line-width":new ht(le.paint_line["line-width"]),"line-gap-width":new ht(le.paint_line["line-gap-width"]),"line-offset":new ht(le.paint_line["line-offset"]),"line-blur":new ht(le.paint_line["line-blur"]),"line-dasharray":new ht(le.paint_line["line-dasharray"]),"line-pattern":new ht(le.paint_line["line-pattern"]),"line-gradient":new Uo(le.paint_line["line-gradient"]),"line-trim-offset":new Oe(le.paint_line["line-trim-offset"]),"line-emissive-strength":new Oe(le.paint_line["line-emissive-strength"]),"line-border-width":new ht(le.paint_line["line-border-width"]),"line-border-color":new ht(le.paint_line["line-border-color"])}),layout:wx};function eg(t,e,i){return e*(qe/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function tg(t,e){return 1/eg(t,1,e.tileZoom)}function ig(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const rg=t=>{const e=[];ng(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");return 0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER"),e};function ng(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const og=new class extends ht{possiblyEvaluate(t,e){return e=new Ai(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=pr({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}(Q_.paint.properties["line-width"].specification);function sg(t,e){return e>0?e+2*t:t}og.useIntegerZoom=!0;const Tx=li([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Mx=li([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ex=li([{name:"a_projected_pos",components:4,type:"Float32"}],4);li([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Sx=li([{name:"a_z_offset",components:1,type:"Float32"}],4),Ax=li([{name:"a_texb",components:2,type:"Uint16"}]),Ix=li([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Cx=li([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);li([{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"}]);const ag=li([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Px=li([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);li([{name:"triangle",components:3,type:"Uint16"}]),li([{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"}]),li([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),li([{type:"Float32",name:"offsetX"}]),li([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Nn=128;function Kp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ai(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:n,interpolationType:s}=i;let 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);const p=n[l],m=n[u];return"composite"===i.kind?{kind:"composite",minZoom:p,maxZoom:m,interpolationType:s}:{kind:"camera",minZoom:p,maxZoom:m,minSize:i.evaluate(new Ai(p)),maxSize:i.evaluate(new Ai(m)),interpolationType:s}}}function fd(t,{uSize:e,uSizeT:i},{lowerSize:n,upperSize:s}){return"source"===t.kind?n/Nn:"composite"===t.kind?Ut(n/Nn,s/Nn,i):e}function Dl(t,e){let i=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:s,minZoom:l,maxZoom:u}=t,p=s?Dt(Fr.interpolationFactor(s,e,l,u),0,1):0;"camera"===t.kind?n=Ut(t.minSize,t.maxSize,p):i=p}return{uSizeT:i,uSize:n}}var zx=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Nn,evaluateSizeForFeature:fd,evaluateSizeForZoom:Dl,getSizeData:Kp});function Dx(t,e,i){return t.sections.forEach(n=>{n.text=function(s,l,u){const p=l.layout.get("text-transform").evaluate(u,{});return"uppercase"===p?s=s.toLocaleUpperCase():"lowercase"===p&&(s=s.toLocaleLowerCase()),Nr.applyArabicShaping&&(s=Nr.applyArabicShaping(s)),s}(n.text,e,i)}),t}const zh={"!":"\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","\u2190":"\u2191","\u2192":"\u2193"};function Lx(t){return"\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"===t}function Rx(t){return"\ufe35"===t||"\ufe47"===t||"\ufe37"===t||"\ufe43"===t||"\ufe41"===t||"\ufe3d"===t||"\ufe3b"===t||"\ufe39"===t||"\ufe17"===t||"\ufe3f"===t}var kx={
2
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
+ read:function(t,e,i,n,s){var l,u,p=8*s-n-1,m=(1<<p)-1,_=m>>1,y=-7,v=i?s-1:0,w=i?-1:1,E=t[e+v];for(v+=w,l=E&(1<<-y)-1,E>>=-y,y+=p;y>0;l=256*l+t[e+v],v+=w,y-=8);for(u=l&(1<<-y)-1,l>>=-y,y+=n;y>0;u=256*u+t[e+v],v+=w,y-=8);if(0===l)l=1-_;else{if(l===m)return u?NaN:1/0*(E?-1:1);u+=Math.pow(2,n),l-=_}return(E?-1:1)*u*Math.pow(2,l-n)},write:function(t,e,i,n,s,l){var u,p,m,_=8*l-s-1,y=(1<<_)-1,v=y>>1,w=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:l-1,A=n?1:-1,I=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,u=y):(u=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-u))<1&&(u--,m*=2),(e+=u+v>=1?w/m:w*Math.pow(2,1-v))*m>=2&&(u++,m/=2),u+v>=y?(p=0,u=y):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[i+E]=255&p,E+=A,p/=256,s-=8);for(u=u<<s|p,_+=s;_>0;t[i+E]=255&u,E+=A,u/=256,_-=8);t[i+E-A]|=128*I}},lg=Ei,md=kx;function Ei(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ei.Varint=0,Ei.Fixed64=1,Ei.Bytes=2,Ei.Fixed32=5;var Jp=4294967296,cg=1/Jp,hg=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Xo(t){return t.type===Ei.Bytes?t.readVarint()+t.pos:t.pos+1}function ug(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var s=i.pos-1;s>=t;s--)i.buf[s+n]=i.buf[s]}function Ox(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function Bx(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function Fx(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function Nx(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function Vx(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function Ux(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function jx(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Gx(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function Zx(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function _d(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Rl(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function dg(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Ei.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){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=_d(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=dg(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_d(this.buf,this.pos)+_d(this.buf,this.pos+4)*Jp;return this.pos+=8,t},readSFixed64:function(){var t=_d(this.buf,this.pos)+dg(this.buf,this.pos+4)*Jp;return this.pos+=8,t},readFloat:function(){var t=md.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=md.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(s,l,u){var p,m,_=u.buf;if(p=(112&(m=_[u.pos++]))>>4,m<128||(p|=(127&(m=_[u.pos++]))<<3,m<128)||(p|=(127&(m=_[u.pos++]))<<10,m<128)||(p|=(127&(m=_[u.pos++]))<<17,m<128)||(p|=(127&(m=_[u.pos++]))<<24,m<128)||(p|=(1&(m=_[u.pos++]))<<31,m<128))return function Ll(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}(s,p,l);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=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!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&hg?hg.decode(this.buf.subarray(e,t)):function(i,n,s){for(var l="",u=n;u<s;){var p,m,_,y=i[u],v=null,w=y>239?4:y>223?3:y>191?2:1;if(u+w>s)break;1===w?y<128&&(v=y):2===w?128==(192&(p=i[u+1]))&&(v=(31&y)<<6|63&p)<=127&&(v=null):3===w?(m=i[u+2],128==(192&(p=i[u+1]))&&128==(192&m)&&((v=(15&y)<<12|(63&p)<<6|63&m)<=2047||v>=55296&&v<=57343)&&(v=null)):4===w&&(m=i[u+2],_=i[u+3],128==(192&(p=i[u+1]))&&128==(192&m)&&128==(192&_)&&((v=(15&y)<<18|(63&p)<<12|(63&m)<<6|63&_)<=65535||v>=1114112)&&(v=null)),null===v?(v=65533,w=1):v>65535&&(v-=65536,l+=String.fromCharCode(v>>>10&1023|55296),v=56320|1023&v),l+=String.fromCharCode(v),u+=w}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!==Ei.Bytes)return t.push(this.readVarint(e));var i=Xo(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ei.Bytes)return t.push(this.readSVarint());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Ei.Bytes)return t.push(this.readBoolean());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Ei.Bytes)return t.push(this.readFloat());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Ei.Bytes)return t.push(this.readDouble());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Ei.Bytes)return t.push(this.readFixed32());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Ei.Bytes)return t.push(this.readSFixed32());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Ei.Bytes)return t.push(this.readFixed64());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Ei.Bytes)return t.push(this.readSFixed64());var e=Xo(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Ei.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ei.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ei.Fixed32)this.pos+=4;else{if(e!==Ei.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Rl(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Rl(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Rl(this.buf,-1&t,this.pos),Rl(this.buf,Math.floor(t*cg),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Rl(this.buf,-1&t,this.pos),Rl(this.buf,Math.floor(t*cg),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,i){var n,s,l,p;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>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),l=n,(p=i).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),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,i)}(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(!!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 i=this.pos-e;i>=128&&ug(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),md.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),md.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&ug(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,Ei.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Ox,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Bx,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Vx,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Fx,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Nx,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Ux,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,jx,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Gx,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Zx,e)},writeBytesField:function(t,e){this.writeTag(t,Ei.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ei.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ei.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ei.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ei.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ei.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ei.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ei.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ei.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ei.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var kl=kr(lg);function qx(t,e,i){e.glyphs=[],1===t&&i.readMessage($x,e)}function $x(t,e,i){if(3===t){const{id:n,bitmap:s,width:l,height:u,left:p,top:m,advance:_}=i.readMessage(Wx,{});e.glyphs.push({id:n,bitmap:new Ps({width:l+6,height:u+6},s),metrics:{width:l,height:u,left:p,top:m,advance:_}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Wx(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const pn={horizontal:1,vertical:2,horizontalOnly:3};class Dh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,i){const n=new Dh;return n.scale=e||1,n.fontStack=i,n}static forImage(e){const i=new Dh;return i.imageName=e,i}}class Ol{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i){const n=new Ol;for(let s=0;s<e.sections.length;s++){const l=e.sections[s];l.image?n.addImageSection(l):n.addTextSection(l,i)}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]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(i,n){let s="";for(let l=0;l<i.length;l++){const u=i.charCodeAt(l+1)||null,p=i.charCodeAt(l-1)||null;s+=!n&&(u&&Tu(u)&&!zh[i[l+1]]||p&&Tu(p)&&!zh[i[l-1]])||!zh[i[l]]?i[l]:zh[i[l]]}return s}(this.text,e)}trim(){let e=0;for(let n=0;n<this.text.length&&gd[this.text.charCodeAt(n)];n++)e++;let i=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&gd[this.text.charCodeAt(n)];n--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){const n=new Ol;return n.text=this.text.substring(e,i),n.sectionIndex=this.sectionIndex.slice(e,i),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(Dh.forText(e.scale,e.fontStack||i));const n=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(n)}addImageSection(e){const i=e.image?e.image.namePrimary:"";if(0===i.length)return void ki("Can't add FormattedSection with an empty image.");const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCodePoint(n),this.sections.push(Dh.forImage(i)),this.sectionIndex.push(this.sections.length-1)):ki("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ef(t,e,i,n,s,l,u,p,m,_,y,v,w,E,A){const I=Ol.fromFeature(t,s);v===pn.vertical&&I.verticalizePunctuation(w);let z=[];const L=function(W,J,ie,oe,he,se){if(!W)return[];const _e=[],Me=function(be,Fe,Se,Qe,He,Ce){let ft=0;for(let st=0;st<be.length();st++){const Je=be.getSection(st);ft+=fg(be.getCodePoint(st),Je,Qe,He,Fe,Ce)}return ft/Math.max(1,Math.ceil(ft/Se))}(W,J,ie,oe,he,se),fe=W.text.indexOf("\u200b")>=0;let we=0;for(let be=0;be<W.length();be++){const Fe=W.getSection(be),Se=W.getCodePoint(be);if(gd[Se]||(we+=fg(Se,Fe,oe,he,J,se)),be<W.length()-1){const Qe=!((de=Se)<11904||!(it_Bopomofo_Extended(de)||it_Bopomofo(de)||it_CJK_Compatibility_Forms(de)||it_CJK_Compatibility_Ideographs(de)||it_CJK_Compatibility(de)||it_CJK_Radicals_Supplement(de)||it_CJK_Strokes(de)||it_CJK_Symbols_and_Punctuation(de)||it_CJK_Unified_Ideographs_Extension_A(de)||it_CJK_Unified_Ideographs(de)||it_Enclosed_CJK_Letters_and_Months(de)||it_Halfwidth_and_Fullwidth_Forms(de)||it_Hiragana(de)||it_Ideographic_Description_Characters(de)||it_Kangxi_Radicals(de)||it_Katakana_Phonetic_Extensions(de)||it_Katakana(de)||it_Vertical_Forms(de)||it_Yi_Radicals(de)||it_Yi_Syllables(de)));(Hx[Se]||Qe||Fe.imageName)&&_e.push(_g(be+1,we,Me,_e,Xx(Se,W.getCodePoint(be+1),Qe&&fe),!1))}}var de;return gg(_g(W.length(),we,Me,_e,0,!0))}(I,_,l,e,n,E),{processBidirectionalText:N,processStyledBidirectionalText:G}=Nr;if(N&&1===I.sections.length){const W=N(I.toString(),L);for(const J of W){const ie=new Ol;ie.text=J,ie.sections=I.sections;for(let oe=0;oe<J.length;oe++)ie.sectionIndex.push(0);z.push(ie)}}else if(G){const W=G(I.text,I.sectionIndex,L);for(const J of W){const ie=new Ol;ie.text=J[0],ie.sectionIndex=J[1],ie.sections=I.sections,z.push(ie)}}else z=function(W,J){const ie=[],oe=W.text;let he=0;for(const se of J)ie.push(W.substring(he,se)),he=se;return he<oe.length&&ie.push(W.substring(he,oe.length)),ie}(I,L);const j=[],X={positionedLines:j,text:I.toString(),top:y[1],bottom:y[1],left:y[0],right:y[0],writingMode:v,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(W,J,ie,oe,he,se,_e,Me,fe,we,de,be){let Fe=0,Se=0,Qe=0;const He="right"===Me?1:"left"===Me?0:.5;let Ce=!1;for(const It of he){const mt=It.getSections();for(const Ct of mt){if(Ct.imageName)continue;const xt=J[Ct.fontStack];if(xt&&(Ce=void 0!==xt.ascender&&void 0!==xt.descender,!Ce))break}if(!Ce)break}let ft=0;for(const It of he){It.trim();const mt=It.getMaxScale(),Ct=24*(mt-1),xt={positionedGlyphs:[],lineOffset:0};W.positionedLines[ft]=xt;const jt=xt.positionedGlyphs;let wt=0;if(!It.length()){Se+=se,++ft;continue}let mi=0,Jt=0;for(let si=0;si<It.length();si++){const Qt=It.getSection(si),Si=It.getSectionIndex(si),hi=It.getCodePoint(si);let Bi=Qt.scale,Yi=null,ur=null,Ti=null,zi=24,rr=0;const nr=!(fe===pn.horizontal||!de&&!$c(hi)||de&&(gd[hi]||(st=hi,it_Arabic(st)||it_Arabic_Supplement(st)||it_Arabic_Extended_A(st)||it_Arabic_Presentation_Forms_A(st)||it_Arabic_Presentation_Forms_B(st))));if(Qt.imageName){const or=oe[Qt.imageName];if(!or)continue;Ti=Qt.imageName,W.iconsInText=W.iconsInText||!0,ur=or.paddedRect;const xi=or.displaySize;Bi=24*Bi/be,Yi={width:xi[0],height:xi[1],left:0,top:-3,advance:nr?xi[1]:xi[0],localGlyph:!1},rr=Ce?-Yi.height*Bi:24*mt-17-xi[1]*Bi,zi=Yi.advance;const Yr=(nr?xi[0]:xi[1])*Bi-24*mt;Yr>0&&Yr>wt&&(wt=Yr)}else{const or=ie[Qt.fontStack];if(!or)continue;or[hi]&&(ur=or[hi]);const xi=J[Qt.fontStack];if(!xi)continue;const Yr=xi.glyphs[hi];if(!Yr)continue;if(Yi=Yr.metrics,zi=8203!==hi?24:0,Ce){const Ns=void 0!==xi.ascender?Math.abs(xi.ascender):0,Lr=void 0!==xi.descender?Math.abs(xi.descender):0,Mr=(Ns+Lr)*Bi;mi<Mr&&(mi=Mr,Jt=(Ns-Lr)/2*Bi),rr=-Ns*Bi}else rr=24*(mt-Bi)-17}nr?(W.verticalizable=!0,jt.push({glyph:hi,imageName:Ti,x:Fe,y:Se+rr,vertical:nr,scale:Bi,localGlyph:Yi.localGlyph,fontStack:Qt.fontStack,sectionIndex:Si,metrics:Yi,rect:ur}),Fe+=zi*Bi+we):(jt.push({glyph:hi,imageName:Ti,x:Fe,y:Se+rr,vertical:nr,scale:Bi,localGlyph:Yi.localGlyph,fontStack:Qt.fontStack,sectionIndex:Si,metrics:Yi,rect:ur}),Fe+=Yi.advance*Bi+we)}0!==jt.length&&(Qe=Math.max(Fe-we,Qe),Ce?yg(jt,He,wt,Jt,se*mt/2):yg(jt,He,wt,0,se/2)),Fe=0;const ei=se*mt+wt;xt.lineOffset=Math.max(wt,Ct),Se+=ei,++ft}var st;const Je=Se,{horizontalAlign:Pe,verticalAlign:ut}=tf(_e);(function(It,mt,Ct,xt,jt,wt){const mi=(mt-Ct)*jt,Jt=-wt*xt;for(const ei of It)for(const si of ei.positionedGlyphs)si.x+=mi,si.y+=Jt})(W.positionedLines,He,Pe,ut,Qe,Je),W.top+=-ut*Je,W.bottom=W.top+Je,W.left+=-Pe*Qe,W.right=W.left+Qe,W.hasBaseline=Ce}(X,e,i,n,z,u,p,m,v,_,w,A),!function(W){for(const J of W)if(0!==J.positionedGlyphs.length)return!1;return!0}(j)&&X}const gd={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Hx={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 fg(t,e,i,n,s,l){if(e.imageName){const u=n[e.imageName];return u?u.displaySize[0]*e.scale*24/l+s:0}{const u=i[e.fontStack],p=u&&u.glyphs[t];return p?p.metrics.advance*e.scale+s:0}}function mg(t,e,i,n){const s=Math.pow(t-e,2);return n?t<e?s/2:2*s:s+Math.abs(i)*i}function Xx(t,e,i){let n=0;return 10===t&&(n-=1e4),i&&(n+=150),40!==t&&65288!==t||(n+=50),41!==e&&65289!==e||(n+=50),n}function _g(t,e,i,n,s,l){let u=null,p=mg(e,i,s,l);for(const m of n){const _=mg(e-m.x,i,s,l)+m.badness;_<=p&&(u=m,p=_)}return{index:t,x:e,priorBreak:u,badness:p}}function gg(t){return t?gg(t.priorBreak).concat(t.index):[]}function tf(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function yg(t,e,i,n,s){if(!(e||i||n||s))return;const 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+=i+n+s}function Yx(t,e,i,n){const{horizontalAlign:s,verticalAlign:l}=tf(n),u=i[0]-t.displaySize[0]*s,p=i[1]-t.displaySize[1]*l;return{imagePrimary:t,imageSecondary:e,top:p,bottom:p+t.displaySize[1],left:u,right:u+t.displaySize[0]}}function xg(t,e,i,n,s,l){const u=t.imagePrimary;let p;if(u.content){const z=u.content,L=u.pixelRatio||1;p=[z[0]/L,z[1]/L,u.displaySize[0]-z[2]/L,u.displaySize[1]-z[3]/L]}const m=e.left*l,_=e.right*l;let y,v,w,E;"width"===i||"both"===i?(E=s[0]+m-n[3],v=s[0]+_+n[1]):(E=s[0]+(m+_-u.displaySize[0])/2,v=E+u.displaySize[0]);const A=e.top*l,I=e.bottom*l;return"height"===i||"both"===i?(y=s[1]+A-n[0],w=s[1]+I+n[2]):(y=s[1]+(A+I-u.displaySize[1])/2,w=y+u.displaySize[1]),{imagePrimary:u,imageSecondary:void 0,top:y,right:v,bottom:w,left:E,collisionPadding:p}}class Yo extends Ue{constructor(e,i,n,s,l){super(e,i),this.angle=s,this.z=n,void 0!==l&&(this.segment=l)}clone(){return new Yo(this.x,this.y,this.z,this.angle,this.segment)}}function vg(t,e,i,n,s){if(void 0===e.segment)return!0;let l=e,u=e.segment+1,p=0;for(;p>-i/2;){if(u--,u<0)return!1;p-=t[u].dist(l),l=t[u]}p+=t[u].dist(t[u+1]),u++;const m=[];let _=0;for(;p<i/2;){const y=t[u],v=t[u+1];if(!v)return!1;let w=t[u-1].angleTo(y)-y.angleTo(v);for(w=Math.abs((w+3*Math.PI)%(2*Math.PI)-Math.PI),m.push({distance:p,angleDelta:w}),_+=w;p-m[0].distance>n;)_-=m.shift().angleDelta;if(_>s)return!1;u++,p+=y.dist(v)}return!0}function bg(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function wg(t,e,i){return t?.6*e*i:0}function Tg(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Kx(t,e,i,n,s,l){const u=wg(i,s,l),p=Tg(i,n)*l;let m=0;const _=bg(t)/2;for(let y=0;y<t.length-1;y++){const v=t[y],w=t[y+1],E=v.dist(w);if(m+E>_){const A=(_-m)/E,I=Ut(v.x,w.x,A),z=Ut(v.y,w.y,A),L=new Yo(I,z,0,w.angleTo(v),y);return!u||vg(t,L,p,u,e)?L:void 0}m+=E}}function Jx(t,e,i,n,s,l,u,p,m){const _=wg(n,l,u),y=Tg(n,s),v=y*u,w=0===t[0].x||t[0].x===m||0===t[0].y||t[0].y===m;return e-v<e/4&&(e=v+e/4),Mg(t,w?e/2*p%e:(y/2+2*l)*u*p%e,e,_,i,v,w,!1,m)}function Mg(t,e,i,n,s,l,u,p,m){const _=l/2,y=bg(t);let v=0,w=e-i,E=[];for(let A=0;A<t.length-1;A++){const I=t[A],z=t[A+1],L=I.dist(z),N=z.angleTo(I);for(;w+i<v+L;){w+=i;const G=(w-v)/L,j=Ut(I.x,z.x,G),X=Ut(I.y,z.y,G);if(j>=0&&j<m&&X>=0&&X<m&&w-_>=0&&w+_<=y){const W=new Yo(j,X,0,N,A);n&&!vg(t,W,l,n,s)||E.push(W)}}v+=L}return p||E.length||u||(E=Mg(t,v/2,i,n,s,l,u,!0,m)),E}function Eg(t,e,i,n,s){const l=[];for(let u=0;u<t.length;u++){const p=t[u];let m;for(let _=0;_<p.length-1;_++){let y=p[_],v=p[_+1];y.x<e&&v.x<e||(y.x<e?y=new Ue(e,y.y+(e-y.x)/(v.x-y.x)*(v.y-y.y))._round():v.x<e&&(v=new Ue(e,y.y+(e-y.x)/(v.x-y.x)*(v.y-y.y))._round()),y.y<i&&v.y<i||(y.y<i?y=new Ue(y.x+(i-y.y)/(v.y-y.y)*(v.x-y.x),i)._round():v.y<i&&(v=new Ue(y.x+(i-y.y)/(v.y-y.y)*(v.x-y.x),i)._round()),y.x>=n&&v.x>=n||(y.x>=n?y=new Ue(n,y.y+(n-y.x)/(v.x-y.x)*(v.y-y.y))._round():v.x>=n&&(v=new Ue(n,y.y+(n-y.x)/(v.x-y.x)*(v.y-y.y))._round()),y.y>=s&&v.y>=s||(y.y>=s?y=new Ue(y.x+(s-y.y)/(v.y-y.y)*(v.x-y.x),s)._round():v.y>=s&&(v=new Ue(y.x+(s-y.y)/(v.y-y.y)*(v.x-y.x),s)._round()),m&&y.equals(m[m.length-1])||(m=[y],l.push(m)),m.push(v)))))}}return l}function Sg(t){let e=0,i=0;for(const u of t)e+=u.w*u.h,i=Math.max(i,u.w);t.sort((u,p)=>p.h-u.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,l=0;for(const u of t)for(let p=n.length-1;p>=0;p--){const 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){const _=n.pop();p<n.length&&(n[p]=_)}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}}Ke(Yo,"Anchor");class rf{constructor(e,{pixelRatio:i,version:n,stretchX:s,stretchY:l,content:u}){this.paddedRect=e,this.pixelRatio=i,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 Ag{constructor(e,i){const n={},s={};this.haveRenderCallbacks=[];const l=[];this.addImages(e,n,l),this.addImages(i,s,l);const{w:u,h:p}=Sg(l),m=new dn({width:u||1,height:p||1});for(const _ in e){const y=e[_],v=n[_].paddedRect;dn.copy(y.data,m,{x:0,y:0},{x:v.x+1,y:v.y+1},y.data,y.sdf)}for(const _ in i){const y=i[_],v=s[_].paddedRect,w=v.x+1,E=v.y+1,A=y.data.width,I=y.data.height;dn.copy(y.data,m,{x:0,y:0},{x:w,y:E},y.data),dn.copy(y.data,m,{x:0,y:I-1},{x:w,y:E-1},{width:A,height:1}),dn.copy(y.data,m,{x:0,y:0},{x:w,y:E+I},{width:A,height:1}),dn.copy(y.data,m,{x:A-1,y:0},{x:w-1,y:E},{width:1,height:I}),dn.copy(y.data,m,{x:0,y:0},{x:w+A,y:E},{width:1,height:I})}this.image=m,this.iconPositions=n,this.patternPositions=s}addImages(e,i,n){for(const s in e){const l=e[s],u={x:0,y:0,w:l.data.width+2,h:l.data.height+2};n.push(u),i[s]=new rf(u,l),l.hasRenderCallback&&this.haveRenderCallbacks.push(s)}}patchUpdatedImages(e,i,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(s=>e.hasImage(s,n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,n);for(const s in e.getUpdatedImages(n))this.patchUpdatedImage(this.iconPositions[s],e.getImage(s,n),i),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s,n),i)}patchUpdatedImage(e,i,n){if(!e||!i||e.version===i.version)return;e.version=i.version;const[s,l]=e.tl,u=!!Object.keys(this.patternPositions).length;n.update(i.data,{useMipmap:u},{x:s,y:l})}}Ke(rf,"ImagePosition"),Ke(Ag,"ImageAtlas");const Lh=1e20;function Ig(t,e,i,n,s,l,u,p,m){for(let _=e;_<e+n;_++)Cg(t,i*l+_,l,s,u,p,m);for(let _=i;_<i+s;_++)Cg(t,_*l+e,1,n,u,p,m)}function Cg(t,e,i,n,s,l,u){l[0]=0,u[0]=-Lh,u[1]=Lh,s[0]=t[e];for(let p=1,m=0,_=0;p<n;p++){s[p]=t[e+p*i];const y=p*p;do{const v=l[m];_=(s[p]-s[v]+y-v*v)/(p-v)/2}while(_<=u[m]&&--m>-1);m++,l[m]=p,u[m]=_,u[m+1]=Lh}for(let p=0,m=0;p<n;p++){for(;u[m+1]<p;)m++;const _=l[m],y=p-_;t[e+p*i]=s[_]+y*y}}const nf={none:0,ideographs:1,all:2};class Bl{constructor(e,i,n){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=n,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e,i){this.urls[i]=e}getGlyphs(e,i,n){const s=[],l=this.urls[i]||zt.GLYPHS_URL;for(const u in e)for(const p of e[u])s.push({stack:u,id:p});tn(s,({stack:u,id:p},m)=>{let _=this.entries[u];_||(_=this.entries[u]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let y=_.glyphs[p];if(void 0!==y)return void m(null,{stack:u,id:p,glyph:y});if(y=this._tinySDF(_,u,p),y)return _.glyphs[p]=y,void m(null,{stack:u,id:p,glyph:y});const v=Math.floor(p/256);if(256*v>65535)return void m(new Error("glyphs > 65535 not supported"));if(_.ranges[v])return void m(null,{stack:u,id:p,glyph:y});let w=_.requests[v];w||(w=_.requests[v]=[],Bl.loadGlyphRange(u,v,l,this.requestManager,(E,A)=>{if(A){_.ascender=A.ascender,_.descender=A.descender;for(const I in A.glyphs)this._doesCharSupportLocalGlyph(+I)||(_.glyphs[+I]=A.glyphs[+I]);_.ranges[v]=!0}for(const I of w)I(E,A);delete _.requests[v]})),w.push((E,A)=>{E?m(E):A&&m(null,{stack:u,id:p,glyph:A.glyphs[p]||null})})},(u,p)=>{if(u)n(u);else if(p){const m={};for(const{stack:_,id:y,glyph:v}of p)void 0===m[_]&&(m[_]={}),void 0===m[_].glyphs&&(m[_].glyphs={}),m[_].glyphs[y]=v&&{id:v.id,bitmap:v.bitmap.clone(),metrics:v.metrics},m[_].ascender=this.entries[_].ascender,m[_].descender=this.entries[_].descender;n(null,m)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==nf.none&&(this.localGlyphMode===nf.all?!!this.localFontFamily:!!this.localFontFamily&&(it_CJK_Unified_Ideographs(e)||it_Hangul_Syllables(e)||it_Hiragana(e)||it_Katakana(e)||it_CJK_Symbols_and_Punctuation(e)||it_CJK_Unified_Ideographs_Extension_A(e)||it_CJK_Unified_Ideographs_Extension_B(e)))}_tinySDF(e,i,n){const s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let l=e.tinySDF;if(!l){let I="400";/bold/i.test(i)?I="900":/medium/i.test(i)?I="500":/light/i.test(i)&&(I="200"),l=e.tinySDF=new Bl.TinySDF({fontFamily:s,fontWeight:I,fontSize:48,buffer:6,radius:16}),l.fontWeight=I}if(this.localGlyphs[l.fontWeight][n])return this.localGlyphs[l.fontWeight][n];const u=String.fromCodePoint(n),{data:p,width:m,height:_,glyphWidth:y,glyphHeight:v,glyphLeft:w,glyphTop:E,glyphAdvance:A}=l.draw(u);return this.localGlyphs[l.fontWeight][n]={id:n,bitmap:new Ps({width:m,height:_},p),metrics:{width:y/2,height:v/2,left:w/2,top:E/2-27,advance:A/2,localGlyph:!0}}}}Bl.loadGlyphRange=function(t,e,i,n,s){const l=256*e,u=l+255,p=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${l}-${u}`),Er.Glyphs);ve(p,(m,_)=>{if(m)s(m);else if(_){const y={},v=new kl(_).readFields(qx,{});for(const w of v.glyphs)y[w.id]=w;s(null,{glyphs:y,ascender:v.ascender,descender:v.descender})}})},Bl.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:l="normal",fontStyle:u="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const p=this.size=t+4*e,m=this._createCanvas(p),_=this.ctx=m.getContext("2d",{willReadFrequently:!0});_.font=`${u} ${l} ${t}px ${s}`,_.textBaseline="alphabetic",_.textAlign="left",_.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){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:l}=this.ctx.measureText(t),u=Math.ceil(i),p=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l-s))),m=Math.min(this.size-this.buffer,u+Math.ceil(n)),_=p+2*this.buffer,y=m+2*this.buffer,v=Math.max(_*y,0),w=new Uint8ClampedArray(v),E={data:w,width:_,height:y,glyphWidth:p,glyphHeight:m,glyphTop:u,glyphLeft:0,glyphAdvance:e};if(0===p||0===m)return E;const{ctx:A,buffer:I,gridInner:z,gridOuter:L}=this;A.clearRect(I,I,p,m),A.fillText(t,I,I+u);const N=A.getImageData(I,I,p,m);L.fill(Lh,0,v),z.fill(0,0,v);for(let G=0;G<m;G++)for(let j=0;j<p;j++){const X=N.data[4*(G*p+j)+3]/255;if(0===X)continue;const W=(G+I)*_+j+I;if(1===X)L[W]=0,z[W]=Lh;else{const J=.5-X;L[W]=J>0?J*J:0,z[W]=J<0?J*J:0}}Ig(L,0,0,_,y,_,this.f,this.v,this.z),Ig(z,I,I,p,m,_,this.f,this.v,this.z);for(let G=0;G<v;G++){const j=Math.sqrt(L[G])-Math.sqrt(z[G]);w[G]=Math.round(255-255*(j/this.radius+this.cutoff))}return E}};function Pg(t,e,i,n){const s=[],l=t.imagePrimary,u=l.pixelRatio,p=l.paddedRect.w-2,m=l.paddedRect.h-2,_=t.right-t.left,y=t.bottom-t.top,v=l.stretchX||[[0,p]],w=l.stretchY||[[0,m]],E=(se,_e)=>se+_e[1]-_e[0],A=v.reduce(E,0),I=w.reduce(E,0),z=p-A,L=m-I;let N=0,G=A,j=0,X=I,W=0,J=z,ie=0,oe=L;if(l.content&&n){const se=l.content;N=yd(v,0,se[0]),j=yd(w,0,se[1]),G=yd(v,se[0],se[2]),X=yd(w,se[1],se[3]),W=se[0]-N,ie=se[1]-j,J=se[2]-se[0]-G,oe=se[3]-se[1]-X}const he=(se,_e,Me,fe)=>{const we=xd(se.stretch-N,G,_,t.left),de=vd(se.fixed-W,J,se.stretch,A),be=xd(_e.stretch-j,X,y,t.top),Fe=vd(_e.fixed-ie,oe,_e.stretch,I),Se=xd(Me.stretch-N,G,_,t.left),Qe=vd(Me.fixed-W,J,Me.stretch,A),He=xd(fe.stretch-j,X,y,t.top),Ce=vd(fe.fixed-ie,oe,fe.stretch,I),ft=new Ue(we,be),st=new Ue(Se,be),Je=new Ue(Se,He),Pe=new Ue(we,He),ut=new Ue(de/u,Fe/u),It=new Ue(Qe/u,Ce/u),mt=e*Math.PI/180;if(mt){const Jt=Math.sin(mt),ei=Math.cos(mt),si=[ei,-Jt,Jt,ei];ft._matMult(si),st._matMult(si),Pe._matMult(si),Je._matMult(si)}const Ct=se.stretch+se.fixed,xt=Me.stretch+Me.fixed,jt=_e.stretch+_e.fixed,wt=fe.stretch+fe.fixed,mi=t.imageSecondary;return{tl:ft,tr:st,bl:Pe,br:Je,texPrimary:{x:l.paddedRect.x+1+Ct,y:l.paddedRect.y+1+jt,w:xt-Ct,h:wt-jt},texSecondary:mi?{x:mi.paddedRect.x+1+Ct,y:mi.paddedRect.y+1+jt,w:xt-Ct,h:wt-jt}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ut,pixelOffsetBR:It,minFontScaleX:J/u/_,minFontScaleY:oe/u/y,isSDF:i}};if(n&&(l.stretchX||l.stretchY)){const se=zg(v,z,A),_e=zg(w,L,I);for(let Me=0;Me<se.length-1;Me++){const fe=se[Me],we=se[Me+1];for(let de=0;de<_e.length-1;de++)s.push(he(fe,_e[de],we,_e[de+1]))}}else s.push(he({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:m+1}));return s}function yd(t,e,i){let n=0;for(const s of t)n+=Math.max(e,Math.min(i,s[1]))-Math.max(e,Math.min(i,s[0]));return n}function zg(t,e,i){const n=[{fixed:-1,stretch:0}];for(const[s,l]of t){const 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:i}),n}function xd(t,e,i,n){return t/e*i+n}function vd(t,e,i,n){return t-e*i/n}function Qx(t,e,i,n){const s=e+t.positionedLines[n].lineOffset;return 0===n?i+s/2:i+(s+(e+t.positionedLines[n-1].lineOffset))/2}function e1(t,e=1,i=!1){let n=1/0,s=1/0,l=-1/0,u=-1/0;const p=t[0];for(let E=0;E<p.length;E++){const A=p[E];(!E||A.x<n)&&(n=A.x),(!E||A.y<s)&&(s=A.y),(!E||A.x>l)&&(l=A.x),(!E||A.y>u)&&(u=A.y)}const m=Math.min(l-n,u-s);let _=m/2;const y=new Hr([],t1);if(0===m)return new Ue(n,s);for(let E=n;E<l;E+=m)for(let A=s;A<u;A+=m)y.push(new Fl(E+_,A+_,_,t));let v=function(E){let A=0,I=0,z=0;const L=E[0];for(let N=0,G=L.length,j=G-1;N<G;j=N++){const X=L[N],W=L[j],J=X.x*W.y-W.x*X.y;I+=(X.x+W.x)*J,z+=(X.y+W.y)*J,A+=3*J}return new Fl(I/A,z/A,0,E)}(t),w=y.length;for(;y.length;){const E=y.pop();(E.d>v.d||!v.d)&&(v=E,i&&console.log("found best %d after %d probes",Math.round(1e4*E.d)/1e4,w)),E.max-v.d<=e||(_=E.h/2,y.push(new Fl(E.p.x-_,E.p.y-_,_,t)),y.push(new Fl(E.p.x+_,E.p.y-_,_,t)),y.push(new Fl(E.p.x-_,E.p.y+_,_,t)),y.push(new Fl(E.p.x+_,E.p.y+_,_,t)),w+=4)}return i&&(console.log(`num probes: ${w}`),console.log(`best distance: ${v.d}`)),v.p}function t1(t,e){return e.max-t.max}class Fl{constructor(e,i,n,s){this.p=new Ue(e,i),this.h=n,this.d=function(l,u){let p=!1,m=1/0;for(let _=0;_<u.length;_++){const y=u[_];for(let v=0,w=y.length,E=w-1;v<w;E=v++){const A=y[v],I=y[E];A.y>l.y!=I.y>l.y&&l.x<(I.x-A.x)*(l.y-A.y)/(I.y-A.y)+A.x&&(p=!p),m=Math.min(m,As(l,A,I))}}return(p?1:-1)*Math.sqrt(m)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}const of=Number.POSITIVE_INFINITY,i1=Math.sqrt(2);function Dg(t,[e,i]){let n=0,s=0;if(i===of){e<0&&(e=0);const l=e/i1;switch(t){case"top-right":case"top-left":s=l-7;break;case"bottom-right":case"bottom-left":s=7-l;break;case"bottom":s=7-e;break;case"top":s=e-7}switch(t){case"top-right":case"bottom-right":n=-l;break;case"top-left":case"bottom-left":n=l;break;case"left":n=e;break;case"right":n=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,s]}function sf(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 r1(t,e,i,n,s,l,u,p,m,_,y,v,w,E,A){let I=l.textMaxSize.evaluate(e,{},v);void 0===I&&(I=u);const z=t.layers[0].layout,L=z.get("icon-offset").evaluate(e,{},v),N=Rg(i.horizontal)||i.vertical,G="globe"===w.name,X=u/24,W=t.tilePixelRatio*I/24,J=(we=t.overscaling,t.zoom>18&&we>2&&(we>>=1),Math.max(qe/(512*we),1)*z.get("symbol-spacing")),ie=z.get("text-padding")*t.tilePixelRatio,oe=z.get("icon-padding")*t.tilePixelRatio,he=qt(z.get("text-max-angle")),se="map"===z.get("text-rotation-alignment")&&"point"!==z.get("symbol-placement"),_e="map"===z.get("icon-rotation-alignment")&&"point"!==z.get("symbol-placement"),Me=z.get("symbol-placement"),fe=J/2;var we;const de=z.get("icon-text-fit").evaluate(e,{},v),be=z.get("icon-text-fit-padding").evaluate(e,{},v),Fe="none"!==de;let Se;!1===t.hasAnyIconTextFit&&Fe&&(t.hasAnyIconTextFit=!0),n&&Fe&&(t.allowVerticalPlacement&&i.vertical&&(Se=xg(n,i.vertical,de,be,L,X)),N&&(n=xg(n,N,de,be,L,X)));const Qe=(He,Ce,ft)=>{if(Ce.x<0||Ce.x>=qe||Ce.y<0||Ce.y>=qe)return;let st=null;if(G){const{x:Je,y:Pe,z:ut}=w.projectTilePoint(Ce.x,Ce.y,ft);st={anchor:new Yo(Je,Pe,ut,0,void 0),up:w.upVector(ft,Ce.x,Ce.y)}}!function(Je,Pe,ut,It,mt,Ct,xt,jt,wt,mi,Jt,ei,si,Qt,Si,hi,Bi,Yi,ur,Ti,zi,rr,nr,or,xi,Yr,Ns){const Lr=Je.addToLineVertexArray(Pe,It);let Mr,mn,Xh,Ud,Ry,ky,Oy,By=0,Fy=0,Ny=0,Vy=0,zf=-1,Df=-1;const vo={};let Uy=xh("");const Na=ut?ut.anchor:Pe,Lf="none"!==wt.layout.get("icon-text-fit").evaluate(zi,{},xi);let Rf=0,kf=0;if(void 0===wt._unevaluatedLayout.getValue("text-radial-offset")?[Rf,kf]=wt.layout.get("text-offset").evaluate(zi,{},xi).map(Kr=>24*Kr):(Rf=24*wt.layout.get("text-radial-offset").evaluate(zi,{},xi),kf=of),Je.allowVerticalPlacement&&mt.vertical){const Kr=mt.vertical;if(Si)ky=af(Kr),jt&&(Oy=af(jt));else{const Jr=wt.layout.get("text-rotate").evaluate(zi,{},xi)+90;Xh=bd(mi,Na,Pe,Jt,ei,si,Kr,Qt,Jr,hi),jt&&(Ud=bd(mi,Na,Pe,Jt,ei,si,jt,Yi,Jr))}}if(Ct){const Kr=wt.layout.get("icon-rotate").evaluate(zi,{},xi),Jr=Pg(Ct,Kr,nr,Lf),ql=jt?Pg(jt,Kr,nr,Lf):void 0;mn=bd(mi,Na,Pe,Jt,ei,si,Ct,Yi,Kr),By=4*Jr.length;const jy=Je.iconSizeData;let Va=null;"source"===jy.kind?(Va=[Nn*wt.layout.get("icon-size").evaluate(zi,{},xi)],Va[0]>Rs&&ki(`${Je.layerIds[0]}: Value for "icon-size" is >= ${Rh}. Reduce your "icon-size".`)):"composite"===jy.kind&&(Va=[Nn*rr.compositeIconSizes[0].evaluate(zi,{},xi),Nn*rr.compositeIconSizes[1].evaluate(zi,{},xi)],(Va[0]>Rs||Va[1]>Rs)&&ki(`${Je.layerIds[0]}: Value for "icon-size" is >= ${Rh}. Reduce your "icon-size".`)),Je.addSymbols(Je.icon,Jr,Va,Ti,ur,zi,!1,ut,Pe,Lr.lineStartIndex,Lr.lineLength,-1,or,xi,Yr,Ns),zf=Je.icon.placedSymbolArray.length-1,ql&&(Fy=4*ql.length,Je.addSymbols(Je.icon,ql,Va,Ti,ur,zi,pn.vertical,ut,Pe,Lr.lineStartIndex,Lr.lineLength,-1,or,xi,Yr,Ns),Df=Je.icon.placedSymbolArray.length-1)}for(const Kr in mt.horizontal){const Jr=mt.horizontal[Kr];Mr||(Uy=xh(Jr.text),Si?Ry=af(Jr):Mr=bd(mi,Na,Pe,Jt,ei,si,Jr,Qt,wt.layout.get("text-rotate").evaluate(zi,{},xi),hi));const ql=1===Jr.positionedLines.length;if(Ny+=Lg(Je,ut,Pe,Jr,xt,wt,Si,zi,hi,Lr,mt.vertical?pn.horizontal:pn.horizontalOnly,ql?Object.keys(mt.horizontal):[Kr],vo,zf,rr,or,xi,Yr),ql)break}mt.vertical&&(Vy+=Lg(Je,ut,Pe,mt.vertical,xt,wt,Si,zi,hi,Lr,pn.vertical,["vertical"],vo,Df,rr,or,xi,Yr));let Vs=-1;const Of=(Kr,Jr)=>Kr?Math.max(Kr,Jr):Jr;Vs=Of(Ry,Vs),Vs=Of(ky,Vs),Vs=Of(Oy,Vs);const bv=Vs>-1?1:0;Je.glyphOffsetArray.length>=65535&&ki("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==zi.sortKey&&Je.addToSortKeyRanges(Je.symbolInstances.length,zi.sortKey),Je.symbolInstances.emplaceBack(Pe.x,Pe.y,Na.x,Na.y,Na.z,vo.right>=0?vo.right:-1,vo.center>=0?vo.center:-1,vo.left>=0?vo.left:-1,vo.vertical>=0?vo.vertical:-1,zf,Df,Uy,void 0!==Mr?Mr:Je.collisionBoxArray.length,void 0!==Mr?Mr+1:Je.collisionBoxArray.length,void 0!==Xh?Xh:Je.collisionBoxArray.length,void 0!==Xh?Xh+1:Je.collisionBoxArray.length,void 0!==mn?mn:Je.collisionBoxArray.length,void 0!==mn?mn+1:Je.collisionBoxArray.length,Ud||Je.collisionBoxArray.length,Ud?Ud+1:Je.collisionBoxArray.length,Jt,Ny,Vy,By,Fy,bv,0,Rf,kf,Vs,0,Lf?1:0)}(t,Ce,st,He,i,n,s,Se,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,ie,se,m,0,oe,_e,L,e,l,_,y,v,E,A)};if("line"===Me)for(const He of Eg(e.geometry,0,0,qe,qe)){const Ce=Jx(He,J,he,i.vertical||N,n,24,W,t.overscaling,qe);for(const ft of Ce)N&&n1(t,N.text,fe,ft)||Qe(He,ft,v)}else if("line-center"===Me){for(const He of e.geometry)if(He.length>1){const Ce=Kx(He,he,i.vertical||N,n,24,W);Ce&&Qe(He,Ce,v)}}else if("Polygon"===e.type)for(const He of Zp(e.geometry,0)){const Ce=e1(He,16);Qe(He[0],new Yo(Ce.x,Ce.y,0,0,void 0),v)}else if("LineString"===e.type)for(const He of e.geometry)Qe(He,new Yo(He[0].x,He[0].y,0,0,void 0),v);else if("Point"===e.type)for(const He of e.geometry)for(const Ce of He)Qe([Ce],new Yo(Ce.x,Ce.y,0,0,void 0),v)}const Rh=255,Rs=Rh*Nn;function Lg(t,e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z,L){const N=function(X,W,J,ie,oe,he,se,_e){const Me=[];if(0===W.positionedLines.length)return Me;const fe=ie.layout.get("text-rotate").evaluate(he,{})*Math.PI/180,we=function(Qe){const He=Qe[0],Ce=Qe[1],ft=He*Ce;return ft>0?[He,-Ce]:ft<0?[-He,Ce]:0===He?[Ce,He]:[Ce,-He]}(J);let de=Math.abs(W.top-W.bottom);for(const Qe of W.positionedLines)de-=Qe.lineOffset;const be=W.positionedLines.length,Fe=de/be;let Se=W.top-J[1];for(let Qe=0;Qe<be;++Qe){const He=W.positionedLines[Qe];Se=Qx(W,Fe,Se,Qe);for(const Ce of He.positionedGlyphs){if(!Ce.rect)continue;const ft=Ce.rect||{};let st=4,Je=!0,Pe=1,ut=0;if(Ce.imageName){const Ti=se[Ce.imageName];if(!Ti)continue;if(Ti.sdf){ki("SDF images are not supported in formatted text and will be ignored.");continue}Je=!1,Pe=Ti.pixelRatio,st=1/Pe}const It=(oe||_e)&&Ce.vertical,mt=Ce.metrics.advance*Ce.scale/2,Ct=Ce.metrics,xt=Ce.rect;if(null===xt)continue;_e&&W.verticalizable&&(ut=Ce.imageName?mt-Ce.metrics.width*Ce.scale/2:0);const jt=oe?[Ce.x+mt,Ce.y]:[0,0];let wt=[0,0],mi=[0,0],Jt=!1;oe||(It?(mi=[Ce.x+mt+we[0],Ce.y+we[1]-ut],Jt=!0):wt=[Ce.x+mt+J[0],Ce.y+J[1]-ut]);const ei=xt.w*Ce.scale/(Pe*(Ce.localGlyph?2:1)),si=xt.h*Ce.scale/(Pe*(Ce.localGlyph?2:1));let Qt,Si,hi,Bi;if(It){const Ti=Ce.y-Se,zi=new Ue(-mt,mt-Ti),rr=-Math.PI/2,nr=new Ue(...mi);Qt=new Ue(-mt+wt[0],wt[1]),Qt._rotateAround(rr,zi)._add(nr),Qt.x+=-Ti+mt,Qt.y-=(Ct.left-st)*Ce.scale;const or=Ce.imageName?Ct.advance*Ce.scale:24*Ce.scale,xi=String.fromCodePoint(Ce.glyph);Lx(xi)?Qt.x+=(1-st)*Ce.scale:Rx(xi)?Qt.x+=or-Ct.height*Ce.scale+(-st-1)*Ce.scale:Qt.x+=Ce.imageName||Ct.width+2*st===xt.w&&Ct.height+2*st===xt.h?(or-si)/2:(or-(Ct.height+2*st)*Ce.scale)/2,Si=new Ue(Qt.x,Qt.y-ei),hi=new Ue(Qt.x+si,Qt.y),Bi=new Ue(Qt.x+si,Qt.y-ei)}else{const Ti=(Ct.left-st)*Ce.scale-mt+wt[0],zi=(-Ct.top-st)*Ce.scale+wt[1],rr=Ti+ei,nr=zi+si;Qt=new Ue(Ti,zi),Si=new Ue(rr,zi),hi=new Ue(Ti,nr),Bi=new Ue(rr,nr)}if(fe){let Ti;Ti=oe?new Ue(0,0):Jt?new Ue(we[0],we[1]):new Ue(J[0],J[1]),Qt._rotateAround(fe,Ti),Si._rotateAround(fe,Ti),hi._rotateAround(fe,Ti),Bi._rotateAround(fe,Ti)}const Yi=new Ue(0,0),ur=new Ue(0,0);Me.push({tl:Qt,tr:Si,bl:hi,br:Bi,texPrimary:ft,texSecondary:void 0,writingMode:W.writingMode,glyphOffset:jt,sectionIndex:Ce.sectionIndex,isSDF:Je,pixelOffsetTL:Yi,pixelOffsetBR:ur,minFontScaleX:0,minFontScaleY:0})}}return Me}(0,n,m,l,u,p,s,t.allowVerticalPlacement),G=t.textSizeData;let j=null;"source"===G.kind?(j=[Nn*l.layout.get("text-size").evaluate(p,{},z)],j[0]>Rs&&ki(`${t.layerIds[0]}: Value for "text-size" is >= ${Rh}. Reduce your "text-size".`)):"composite"===G.kind&&(j=[Nn*A.compositeTextSizes[0].evaluate(p,{},z),Nn*A.compositeTextSizes[1].evaluate(p,{},z)],(j[0]>Rs||j[1]>Rs)&&ki(`${t.layerIds[0]}: Value for "text-size" is >= ${Rh}. Reduce your "text-size".`)),t.addSymbols(t.text,N,j,m,u,p,y,e,i,_.lineStartIndex,_.lineLength,E,I,z,L,!1);for(const X of v)w[X]=t.text.placedSymbolArray.length-1;return 4*N.length}function Rg(t){for(const e in t)return t[e];return null}function bd(t,e,i,n,s,l,u,p,m,_){let y=u.top,v=u.bottom,w=u.left,E=u.right;const A=u.collisionPadding;if(A&&(w-=A[0],y-=A[1],E+=A[2],v+=A[3]),m){const I=new Ue(w,y),z=new Ue(E,y),L=new Ue(w,v),N=new Ue(E,v),G=qt(m);let j=new Ue(0,0);_&&(j=new Ue(_[0],_[1])),I._rotateAround(G,j),z._rotateAround(G,j),L._rotateAround(G,j),N._rotateAround(G,j),w=Math.min(I.x,z.x,L.x,N.x),E=Math.max(I.x,z.x,L.x,N.x),y=Math.min(I.y,z.y,L.y,N.y),v=Math.max(I.y,z.y,L.y,N.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,w,y,E,v,p,n,s,l),t.length-1}function af(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function n1(t,e,i,n){const s=t.compareText;if(e in s){const l=s[e];for(let u=l.length-1;u>=0;u--)if(n.dist(l[u])<i)return!0}else s[e]=[];return s[e].push(n),!1}function kg(t,e){const i=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(i)*s/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),u=Math.sin(t._pitch)*l+s;return Math.min(1.01*u,s*(1/t._horizonShift))}function kh(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};const i=Math.pow(2,-t.z),n=t.x*i,s=(t.x+1)*i,l=t.y*i,u=(t.y+1)*i,p=vt(n),m=vt(s),_=Zt(l),y=Zt(u),v=e.project(p,_),w=e.project(m,_),E=e.project(m,y),A=e.project(p,y);let I=Math.min(v.x,w.x,E.x,A.x),z=Math.min(v.y,w.y,E.y,A.y),L=Math.max(v.x,w.x,E.x,A.x),N=Math.max(v.y,w.y,E.y,A.y);const G=i/16;function j(W,J,ie,oe,he,se){const _e=(ie+he)/2,Me=(oe+se)/2,fe=e.project(vt(_e),Zt(Me)),we=Math.max(0,I-fe.x,z-fe.y,fe.x-L,fe.y-N);I=Math.min(I,fe.x),L=Math.max(L,fe.x),z=Math.min(z,fe.y),N=Math.max(N,fe.y),we>G&&(j(W,fe,ie,oe,_e,Me),j(fe,J,_e,Me,he,se))}j(v,w,n,l,s,l),j(w,E,s,l,s,u),j(E,A,s,u,n,u),j(A,v,n,u,n,l),I-=G,z-=G,L+=G,N+=G;const X=1/Math.max(L-I,N-z);return{scale:X,x:I*X,y:z*X,x2:L*X,y2:N*X,projection:e}}function Og(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*qe,(i*t.scale-t.y)*qe)}const o1=a.a6.identity(new Float32Array(16));class ks{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new ne(0,0)}projectTilePoint(e,i,n){return{x:e,y:i,z:0}}locationPoint(e,i,n=!0){return e._coordinatePoint(e.locationCoordinate(i),n)}pixelsPerMeter(e,i){return bt(1,e)*i}pixelSpaceConversion(e,i,n){return 1}farthestPixelDistance(e){return kg(e,e.pixelsPerMeter)}pointCoordinate(e,i,n,s){const l=e.horizonLineFromTop(!1),u=new Ue(i,Math.max(l,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,s))}pointCoordinate3D(e,i,n){const s=new Ue(i,n);if(e.elevation)return e.elevation.pointCoordinate(s);{const l=this.pointCoordinate(e,s.x,s.y,0);return[l.x,l.y,l.z]}}isPointAboveHorizon(e,i){if(e.elevation)return!this.pointCoordinate3D(e,i.x,i.y);const n=e.horizonLineFromTop();return i.y<n}createInversionMatrix(e,i){return o1}createTileMatrix(e,i,n){let s,l,u;const p=n.canonical,m=a.a6.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const _=kh(p,this);s=1,l=_.x+n.wrap*_.scale,u=_.y,a.a6.scale(m,m,[s/_.scale,s/_.scale,e.pixelsPerMeter/i])}else s=i/e.zoomScale(p.z),l=(p.x+Math.pow(2,p.z)*n.wrap)*s,u=p.y*s;return a.a6.translate(m,m,[l,u,0]),a.a6.scale(m,m,[s/qe,s/qe,1]),m}upVector(e,i,n){return[0,0,1]}upVectorScale(e,i,n){return{metersToTile:1}}}class s1 extends ks{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[i,n]=this.parallels=e.parallels||[29.5,45.5],s=Math.sin(qt(i));this.n=(s+Math.sin(qt(n)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,i){const{n,c:s,r0:l}=this,u=qt(e-this.center[0]),p=qt(i),m=Math.sqrt(s-2*n*Math.sin(p))/n;return{x:m*Math.sin(u*n),y:m*Math.cos(u*n)-l,z:0}}unproject(e,i){const{n,c:s,r0:l}=this,u=l+i;let p=Math.atan2(e,Math.abs(u))*Math.sign(u);u*n<0&&(p-=Math.PI*Math.sign(e)*Math.sign(u));const m=qt(this.center[0])*n;p=Hn(p,-Math.PI-m,Math.PI-m);const _=Dt(dr(p/n)+this.center[0],-180,180),y=Math.asin(Dt((s-(e*e+u*u)*n*n)/(2*n),-1,1)),v=Dt(dr(y),-Ot,Ot);return new ne(_,v)}}const Oh=1.340264,Bh=-.081106,Fh=893e-6,Nh=.003796,wd=Math.sqrt(3)/2;class a1 extends ks{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;const n=Math.asin(wd*Math.sin(i)),s=n*n,l=s*s*s;return{x:.5*(e*Math.cos(n)/(wd*(Oh+3*Bh*s+l*(7*Fh+9*Nh*s)))/Math.PI+.5),y:1-.5*(n*(Oh+Bh*s+l*(Fh+Nh*s))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,s=n*n,l=s*s*s;for(let y,v,w,E=0;E<12&&(v=n*(Oh+Bh*s+l*(Fh+Nh*s))-i,w=Oh+3*Bh*s+l*(7*Fh+9*Nh*s),y=v/w,n=Dt(n-y,-Math.PI/3,Math.PI/3),s=n*n,l=s*s*s,!(Math.abs(y)<1e-12));++E);const u=wd*e*(Oh+3*Bh*s+l*(7*Fh+9*Nh*s))/Math.cos(n),p=Math.asin(Math.sin(n)/wd),m=Dt(180*u/Math.PI,-180,180),_=Dt(180*p/Math.PI,-Ot,Ot);return new ne(m,_)}}class l1 extends ks{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){const n=360*(e-.5),s=Dt(360*(.5-i),-Ot,Ot);return new ne(n,s)}}const Nl=Math.PI/2;function Td(t){return Math.tan((Nl+t)/2)}class c1 extends ks{constructor(e){super(e),this.center=e.center||[0,30];const[i,n]=this.parallels=e.parallels||[30,30];let s=qt(i),l=qt(n);this.southernCenter=s+l<0,this.southernCenter&&(s=-s,l=-l);const u=Math.cos(s),p=Td(s);this.n=s===l?Math.sin(s):Math.log(u/Math.cos(l))/Math.log(Td(l)/p),this.f=u*Math.pow(Td(s),this.n)/this.n}project(e,i){i=qt(i),this.southernCenter&&(i=-i),e=qt(e-this.center[0]);const n=1e-6,{n:s,f:l}=this;l>0?i<-Nl+n&&(i=-Nl+n):i>Nl-n&&(i=Nl-n);const u=l/Math.pow(Td(i),s);let p=u*Math.sin(s*e),m=l-u*Math.cos(s*e);return p=.5*(p/Math.PI+.5),m=.5*(m/Math.PI+.5),{x:p,y:this.southernCenter?m:1-m,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;const{n,f:s}=this,l=s-i,u=Math.sign(l),p=Math.sign(n)*Math.sqrt(e*e+l*l);let m=Math.atan2(e,Math.abs(l))*u;l*n<0&&(m-=Math.PI*Math.sign(e)*u);const _=Dt(dr(m/n)+this.center[0],-180,180),y=Dt(dr(2*Math.atan(Math.pow(s/p,1/n))-Nl),-Ot,Ot);return new ne(_,this.southernCenter?-y:y)}}class Bg extends ks{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:Et(e),y:gt(i),z:0}}unproject(e,i){const n=vt(e),s=Zt(i);return new ne(n,s)}}const Fg=qt(Ot);class h1 extends ks{project(e,i){const n=(i=qt(i))*i,s=n*n;return{x:.5*((e=qt(e))*(.8707-.131979*n+s*(s*(.003971*n-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+n*(.015085+s*(.028874*n-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,s=25,l=0,u=n*n;do{u=n*n;const _=u*u;l=(n*(1.007226+u*(.015085+_*(.028874*u-.044475-.005916*_)))-i)/(1.007226+u*(.045255+_*(.259866*u-.311325-.005916*11*_))),n=Dt(n-l,-Fg,Fg)}while(Math.abs(l)>1e-6&&--s>0);u=n*n;const p=Dt(dr(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),m=dr(n);return new ne(p,m)}}const Ng=qt(Ot);class u1 extends ks{project(e,i){i=qt(i),e=qt(e);const n=Math.cos(i),s=2/Math.PI,l=Math.acos(n*Math.cos(e/2)),u=Math.sin(l)/l,p=.5*(e*s+2*n*Math.sin(e/2)/u)||0,m=.5*(i+Math.sin(i)/u)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(m/Math.PI+1),z:0}}unproject(e,i){let n=e=(2*e-.5)*Math.PI,s=i=(2*(1-i)-1)*Math.PI,l=25;const u=1e-6;let p=0,m=0;do{const _=Math.cos(s),y=Math.sin(s),v=2*y*_,w=y*y,E=_*_,A=Math.cos(n/2),I=Math.sin(n/2),z=2*A*I,L=I*I,N=1-E*A*A,G=N?1/N:0,j=N?Math.acos(_*A)*Math.sqrt(1/N):0,X=.5*(2*j*_*I+2*n/Math.PI)-e,W=.5*(j*y+s)-i,J=.5*G*(E*L+j*_*A*w)+1/Math.PI,ie=G*(z*v/4-j*y*I),oe=.125*G*(v*I-j*y*E*z),he=.5*G*(w*A+j*L*_)+.5,se=ie*oe-he*J;p=(W*ie-X*he)/se,m=(X*oe-W*J)/se,n=Dt(n-p,-Math.PI,Math.PI),s=Dt(s-m,-Ng,Ng)}while((Math.abs(p)>u||Math.abs(m)>u)&&--l>0);return new ne(dr(n),dr(s))}}class Vg extends ks{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(qt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){const{scale:n,cosPhi:s}=this;return{x:qt(e)*s*n+.5,y:-Math.sin(qt(i))/s*n+.5,z:0}}unproject(e,i){const{scale:n,cosPhi:s}=this,l=-(i-.5)/n,u=Dt(dr((e-.5)/n)/s,-180,180),p=Math.asin(Dt(l*s,-1,1)),m=Dt(dr(p),-Ot,Ot);return new ne(u,m)}}class d1 extends Bg{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const s=Th(e,i,n),l=td(xo(n));return a.N.transformMat4(s,s,l),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,i){const n=me(i.lat,i.lng),s=a.N.normalize([],n),l=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,u=bt(1,0)*qe*l;a.N.scaleAndAdd(n,n,s,u);const p=a.a6.identity(new Float64Array(16));return a.a6.multiply(p,e.pixelMatrix,e.globeMatrix),a.N.transformMat4(n,n,p),new Ue(n[0],n[1])}pixelsPerMeter(e,i){return bt(1,0)*i}pixelSpaceConversion(e,i,n){const s=bt(1,e)*i,l=Ut(bt(1,45)*i,s,n);return this.pixelsPerMeter(e,i)/l}createTileMatrix(e,i,n){const s=Op(xo(n.canonical));return a.a6.multiply(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,i){const{center:n}=e,s=td(xo(i));return a.a6.rotateY(s,s,qt(n.lng)),a.a6.rotateX(s,s,qt(n.lat)),a.a6.scale(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}pointCoordinate(e,i,n,s){return r_(e,i,n,!0)||new Yt(0,0)}pointCoordinate3D(e,i,n){const s=this.pointCoordinate(e,i,n,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,i){return!r_(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=function(s,l){const u=s.cameraToCenterDistance,p=s._centerAltitude*l,m=s._camera,_=s._camera.forward(),y=a.N.add([],a.N.scale([],_,-u),[0,0,p]),v=s.worldSize/(2*Math.PI),w=[0,0,-v],E=s.width/s.height,A=Math.tan(s.fovAboveCenter),I=a.N.scale([],m.up(),A),z=a.N.scale([],m.right(),A*E),L=a.N.normalize([],a.N.add([],a.N.add([],_,I),z)),N=[];let G;if(new zp(y,L).closestPointOnSphere(w,v,N)){const j=a.N.add([],N,w),X=a.N.sub([],j,y);G=Math.cos(s.fovAboveCenter)*a.N.length(X)}else{const j=a.N.sub([],y,w),X=a.N.sub([],w,y);a.N.normalize(X,X);const W=a.N.length(j)-v;G=Math.sqrt(W*(W+2*v));const J=Math.acos(G/(v+W))-Math.acos(a.N.dot(_,X));G*=Math.cos(J)}return 1.01*G}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Cs(e.zoom);if(n>0){const s=kg(e,bt(1,e.center.lat)*e.worldSize),l=e.worldSize/(2*Math.PI),u=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Ut(i,s+l*(1-Math.cos(u)),Math.pow(n,10))}return i}upVector(e,i,n){return Th(i,n,e,1)}upVectorScale(e){return{metersToTile:Ju(ed(xo(e)))}}}function Ug(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Bg(t);case"equirectangular":return new l1(t);case"naturalEarth":return new h1(t);case"equalEarth":return new a1(t);case"winkelTripel":return new u1(t);case"albers":return i?new Vg(t):new s1(t);case"lambertConformalConic":return i?new Vg(t):new c1(t);case"globe":return new d1(t)}throw new Error(`Invalid projection name: ${t.name}`)}const p1=ld.types,f1=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Md(t,e,i,n,s,l,u,p,m,_,y,v,w){const E=p?Math.min(Rs,Math.round(p[0])):0,A=p?Math.min(Rs,Math.round(p[1])):0;t.emplaceBack(e,i,Math.round(32*n),Math.round(32*s),l,u,(E<<1)+(m?1:0),A,16*_,16*y,256*v,256*w)}function Ed(t,e,i){t.emplaceBack(e,i)}function Sd(t,e,i,n,s,l,u){t.emplaceBack(e,i,n,s,l,u)}function Ad(t,e,i,n,s){t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s)}function m1(t){for(const e of t.sections)if(Wc(e.text))return!0;return!1}class lf{constructor(e){this.layoutVertexArray=new va,this.indexArray=new Ji,this.programConfigurations=e,this.segments=new Oi,this.dynamicLayoutVertexArray=new uo,this.opacityVertexArray=new hh,this.placedSymbolArray=new Lu,this.iconTransitioningVertexArray=new vn,this.globeExtVertexArray=new ch,this.zOffsetVertexArray=new wa}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,i,n,s,l){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Tx.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ex.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,f1,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Ax.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Mx.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||l)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Sx.members,!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(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}Ke(lf,"SymbolBuffers");class cf{constructor(e,i,n){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new n,this.segments=new Oi,this.collisionVertexArray=new dh,this.collisionVertexArrayExt=new uo}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ix.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Cx.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ke(cf,"CollisionBuffers");class Id{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.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=a.a6.identity([]),this.placementViewportMatrix=a.a6.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Kp(this.zoom,i["text-size"]),this.iconSizeData=Kp(this.zoom,i["icon-size"]);const 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="viewport-y"!==l&&void 0!==s.constantOr(1),this.sortFeaturesByY=("viewport-y"===l||"auto"===l&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(u=>pn[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate")}createArrays(){this.text=new lf(new k(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new lf(new k(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Ou,this.lineVertexArray=new Sa,this.symbolInstances=new ku}calculateGlyphDependencies(e,i,n,s,l){for(let u=0;u<e.length;u++){const p=e.codePointAt(u);if(void 0===p)break;if(i[p]=!0,s&&l&&p<=65535){const m=zh[e.charAt(u)];m&&(i[m.charCodeAt(0)]=!0)}}}populate(e,i,n,s){const l=this.layers[0],u=l.layout,p="globe"===this.projection.name,m=u.get("text-font"),_=u.get("text-field"),y=u.get("icon-image"),v=("constant"!==_.value.kind||_.value.value instanceof lr&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&("constant"!==m.value.kind||m.value.value.length>0),w="constant"!==y.value.kind||!!y.value.value||Object.keys(y.parameters).length>0,E=u.get("symbol-sort-key");if(this.features=[],!v&&!w)return;const A=i.iconDependencies,I=i.glyphDependencies,z=i.availableImages,L=new Ai(this.zoom);for(const{feature:N,id:G,index:j,sourceLayerIndex:X}of e){const W=l._featureFilter.needGeometry,J=Hi(N,W);if(!l._featureFilter.filter(L,J,n))continue;if(W||(J.geometry=er(N,n,s)),p&&1!==N.type&&n.z<=5){const se=J.geometry,_e=.98078528056,Me=(fe,we)=>{const de=Th(fe.x,fe.y,n,1),be=Th(we.x,we.y,n,1);return a.N.dot(de,be)<_e};for(let fe=0;fe<se.length;fe++)se[fe]=hr(se[fe],Me)}let ie,oe;if(v){const se=l.getValueAndResolveTokens("text-field",J,n,z),_e=lr.factory(se);m1(_e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ho()||this.hasRTLText&&Nr.isParsed())&&(ie=Dx(_e,l,J))}if(w){const se=l.getValueAndResolveTokens("icon-image",J,n,z);oe=se instanceof pt?se:pt.fromString(se)}if(!ie&&!oe)continue;const he=this.sortFeaturesByKey?E.evaluate(J,{},n):void 0;if(this.features.push({id:G,text:ie,icon:oe,index:j,sourceLayerIndex:X,geometry:J.geometry,properties:N.properties,type:p1[N.type],sortKey:he}),oe&&(A[oe.namePrimary]=!0,oe.nameSecondary&&(A[oe.nameSecondary]=!0)),ie){const se=m.evaluate(J,{},n).join(","),_e="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(pn.vertical)>=0;for(const Me of ie.sections)if(Me.image)A[Me.image.namePrimary]=!0;else{const fe=lo(ie.toString()),we=Me.fontStack||se,de=I[we]=I[we]||{};this.calculateGlyphDependencies(Me.text,de,_e,this.allowVerticalPlacement,fe)}}}"line"===u.get("symbol-placement")&&(this.features=function(N){const G={},j={},X=[];let W=0;function J(se){X.push(N[se]),W++}function ie(se,_e,Me){const fe=j[se];return delete j[se],j[_e]=fe,X[fe].geometry[0].pop(),X[fe].geometry[0]=X[fe].geometry[0].concat(Me[0]),fe}function oe(se,_e,Me){const fe=G[_e];return delete G[_e],G[se]=fe,X[fe].geometry[0].shift(),X[fe].geometry[0]=Me[0].concat(X[fe].geometry[0]),fe}function he(se,_e,Me){const fe=Me?_e[0][_e[0].length-1]:_e[0][0];return`${se}:${fe.x}:${fe.y}`}for(let se=0;se<N.length;se++){const _e=N[se],Me=_e.geometry,fe=_e.text?_e.text.toString():null;if(!fe){J(se);continue}const we=he(fe,Me),de=he(fe,Me,!0);if(we in j&&de in G&&j[we]!==G[de]){const be=oe(we,de,Me),Fe=ie(we,de,X[be].geometry);delete G[we],delete j[de],j[he(fe,X[Fe].geometry,!0)]=Fe,X[be].geometry=null}else we in j?ie(we,de,Me):de in G?oe(we,de,Me):(J(se),G[we]=W-1,j[de]=W-1)}return X.filter(se=>se.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((N,G)=>N.sortKey-G.sortKey)}update(e,i,n,s,l){const u=0!==Object.keys(e).length;if(u&&!this.stateDependentLayers.length)return;const p=u?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,i,p,n,s,l),this.icon.programConfigurations.updatePaintArrays(e,i,p,n,s,l)}updateZOffset(){const e=(l,u,p)=>{n+=u,n>l.length&&l.resize(n);for(let m=-u;m<0;m++)l.emplace(m+n,p)},i=(l,u,p)=>{s+=u,s>l.length&&l.resize(s);for(let m=-u;m<0;m++)l.emplace(m+s,p)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let n=0,s=0;for(let l=0;l<this.symbolInstances.length;l++){const u=this.symbolInstances.get(l),{numHorizontalGlyphVertices:p,numVerticalGlyphVertices:m,numIconVertices:_}=u,y=u.zOffset,v=_>0;if((p>0||m>0)&&(e(this.text.zOffsetVertexArray,p,y),e(this.text.zOffsetVertexArray,m,y)),v){const{placedIconSymbolIndex:w,verticalPlacedIconSymbolIndex:E}=u;w>=0&&i(this.icon.zOffsetVertexArray,_,y),E>=0&&i(this.icon.zOffsetVertexArray,u.numVerticalIconVertices,y)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!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.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Ug(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:s,y:l}of i)this.lineVertexArray.emplaceBack(s,l);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,i,n,s,l,u,p,m,_,y,v,w,E,A,I,z){const L=e.indexArray,N=e.layoutVertexArray,G=e.globeExtVertexArray,j=e.segments.prepareSegment(4*i.length,N,L,this.canOverlap?u.sortKey:void 0),X=this.glyphOffsetArray.length,W=j.vertexLength,J=this.allowVerticalPlacement&&p===pn.vertical?Math.PI/2:0,ie=u.text&&u.text.sections;for(let he=0;he<i.length;he++){const{tl:se,tr:_e,bl:Me,br:fe,texPrimary:we,texSecondary:de,pixelOffsetTL:be,pixelOffsetBR:Fe,minFontScaleX:Se,minFontScaleY:Qe,glyphOffset:He,isSDF:Ce,sectionIndex:ft}=i[he],st=j.vertexLength,Je=He[1];if(Md(N,_.x,_.y,se.x,Je+se.y,we.x,we.y,n,Ce,be.x,be.y,Se,Qe),Md(N,_.x,_.y,_e.x,Je+_e.y,we.x+we.w,we.y,n,Ce,Fe.x,be.y,Se,Qe),Md(N,_.x,_.y,Me.x,Je+Me.y,we.x,we.y+we.h,n,Ce,be.x,Fe.y,Se,Qe),Md(N,_.x,_.y,fe.x,Je+fe.y,we.x+we.w,we.y+we.h,n,Ce,Fe.x,Fe.y,Se,Qe),m){const{x:Pe,y:ut,z:It}=m.anchor,[mt,Ct,xt]=m.up;Sd(G,Pe,ut,It,mt,Ct,xt),Sd(G,Pe,ut,It,mt,Ct,xt),Sd(G,Pe,ut,It,mt,Ct,xt),Sd(G,Pe,ut,It,mt,Ct,xt),Ad(e.dynamicLayoutVertexArray,Pe,ut,It,J)}else Ad(e.dynamicLayoutVertexArray,_.x,_.y,_.z,J);if(z){const Pe=de||we;Ed(e.iconTransitioningVertexArray,Pe.x,Pe.y),Ed(e.iconTransitioningVertexArray,Pe.x+Pe.w,Pe.y),Ed(e.iconTransitioningVertexArray,Pe.x,Pe.y+Pe.h),Ed(e.iconTransitioningVertexArray,Pe.x+Pe.w,Pe.y+Pe.h)}L.emplaceBack(st,st+1,st+2),L.emplaceBack(st+1,st+2,st+3),j.vertexLength+=4,j.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(He[0]),he!==i.length-1&&ft===i[he+1].sectionIndex||e.programConfigurations.populatePaintArrays(N.length,u,u.index,{},E,A,I,ie&&ie[ft])}const oe=m?m.anchor:_;e.placedSymbolArray.emplaceBack(oe.x,oe.y,oe.z,_.x,_.y,X,this.glyphOffsetArray.length-X,W,y,v,_.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],p,0,!1,0,w,0)}_commitLayoutVertex(e,i,n,s,l,u,p){e.emplaceBack(i,n,s,l,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,i,n,s,l,u,p){const m=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),_=m.vertexLength,y=p.tileAnchorX,v=p.tileAnchorY;for(let E=0;E<4;E++)n.collisionVertexArray.emplaceBack(0,0,0,0);this._commitDebugCollisionVertexUpdate(n.collisionVertexArrayExt,i,e.padding,p.zOffset),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,y,v,new Ue(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,y,v,new Ue(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,y,v,new Ue(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,s,l,u,y,v,new Ue(e.x1,e.y2)),m.vertexLength+=4;const w=n.indexArray;w.emplaceBack(_,_+1),w.emplaceBack(_+1,_+2),w.emplaceBack(_+2,_+3),w.emplaceBack(_+3,_),m.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,n,s,l,u){for(let p=s;p<l;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,u,i,p);this._addCollisionDebugVertices(m,_,this.textCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,i,n,s,l,u){for(let p=s;p<l;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._addCollisionDebugVertices(m,_,this.iconCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new cf(ba,ag.members,vn),this.iconCollisionBox=new cf(ba,ag.members,vn);const n=Dl(this.iconSizeData,e),s=Dl(this.textSizeData,e);for(let l=0;l<this.symbolInstances.length;l++){const u=this.symbolInstances.get(l);this._addTextDebugCollisionBoxes(s,e,i,u.textBoxStartIndex,u.textBoxEndIndex,u),this._addTextDebugCollisionBoxes(s,e,i,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,i,u.iconBoxStartIndex,u.iconBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,i,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u)}}getSymbolInstanceTextSize(e,i,n,s){const l=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:s),u=fd(this.textSizeData,e,l)/24;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,i,n){const s=this.icon.placedSymbolArray.get(n),l=fd(this.iconSizeData,e,s);return this.tilePixelRatio*l}_commitDebugCollisionVertexUpdate(e,i,n,s){e.emplaceBack(i,-n,-n,s),e.emplaceBack(i,n,-n,s),e.emplaceBack(i,n,n,s),e.emplaceBack(i,-n,n,s)}_updateTextDebugCollisionBoxes(e,i,n,s,l,u){for(let p=s;p<l;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,u,i,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,_,m.padding,u.zOffset)}}_updateIconDebugCollisionBoxes(e,i,n,s,l,u){for(let p=s;p<l;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,_,m.padding,u.zOffset)}}updateCollisionDebugBuffers(e,i){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=Dl(this.iconSizeData,e),s=Dl(this.textSizeData,e);for(let l=0;l<this.symbolInstances.length;l++){const u=this.symbolInstances.get(l);this._updateTextDebugCollisionBoxes(s,e,i,u.textBoxStartIndex,u.textBoxEndIndex,u),this._updateTextDebugCollisionBoxes(s,e,i,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._updateIconDebugCollisionBoxes(n,e,i,u.iconBoxStartIndex,u.iconBoxEndIndex,u),this._updateIconDebugCollisionBoxes(n,e,i,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u)}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,i,n,s,l,u,p,m,_){const y={};if(i<n){const{x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j,featureIndex:X}=e.get(i);y.textBox={x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j},y.textFeatureIndex=X}if(s<l){const{x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j,featureIndex:X}=e.get(s);y.verticalTextBox={x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j},y.verticalTextFeatureIndex=X}if(u<p){const{x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j,featureIndex:X}=e.get(u);y.iconBox={x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j},y.iconFeatureIndex=X}if(m<_){const{x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j,featureIndex:X}=e.get(m);y.verticalIconBox={x1:v,y1:w,x2:E,y2:A,padding:I,projectedAnchorX:z,projectedAnchorY:L,projectedAnchorZ:N,tileAnchorX:G,tileAnchorY:j},y.verticalIconFeatureIndex=X}return y}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const n=this.symbolInstances.get(i);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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,i){const n=e.placedSymbolArray.get(i),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&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const i=Math.sin(e),n=Math.cos(e),s=[],l=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);const m=this.symbolInstances.get(p);s.push(0|Math.round(i*m.tileAnchorX+n*m.tileAnchorY)),l.push(m.featureIndex)}return u.sort((p,m)=>s[p]-s[m]||l[m]-l[p]),u}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,i)=>this.symbolInstances.get(i).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,i){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===i?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const n=this.symbolInstances.get(i);this.featureSortOrder.push(n.featureIndex);const{rightJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:l,leftJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:p,placedIconSymbolIndex:m,verticalPlacedIconSymbolIndex:_}=n;s>=0&&this.addIndicesForPlacedSymbol(this.text,s),l>=0&&l!==s&&this.addIndicesForPlacedSymbol(this.text,l),u>=0&&u!==l&&u!==s&&this.addIndicesForPlacedSymbol(this.text,u),p>=0&&this.addIndicesForPlacedSymbol(this.text,p),m>=0&&this.addIndicesForPlacedSymbol(this.icon,m),_>=0&&this.addIndicesForPlacedSymbol(this.icon,_)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ke(Id,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Id.addDynamicAttributes=Ad;const _1=new Ii({"symbol-placement":new Oe(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Oe(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Oe(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ht(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Oe(le.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Oe(le.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Oe(le.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Oe(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Oe(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Oe(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new ht(le.layout_symbol["icon-size"]),"icon-text-fit":new ht(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ht(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new ht(le.layout_symbol["icon-image"]),"icon-rotate":new ht(le.layout_symbol["icon-rotate"]),"icon-padding":new Oe(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Oe(le.layout_symbol["icon-keep-upright"]),"icon-offset":new ht(le.layout_symbol["icon-offset"]),"icon-anchor":new ht(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Oe(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Oe(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Oe(le.layout_symbol["text-rotation-alignment"]),"text-field":new ht(le.layout_symbol["text-field"]),"text-font":new ht(le.layout_symbol["text-font"]),"text-size":new ht(le.layout_symbol["text-size"]),"text-max-width":new ht(le.layout_symbol["text-max-width"]),"text-line-height":new ht(le.layout_symbol["text-line-height"]),"text-letter-spacing":new ht(le.layout_symbol["text-letter-spacing"]),"text-justify":new ht(le.layout_symbol["text-justify"]),"text-radial-offset":new ht(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Oe(le.layout_symbol["text-variable-anchor"]),"text-anchor":new ht(le.layout_symbol["text-anchor"]),"text-max-angle":new Oe(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Oe(le.layout_symbol["text-writing-mode"]),"text-rotate":new ht(le.layout_symbol["text-rotate"]),"text-padding":new Oe(le.layout_symbol["text-padding"]),"text-keep-upright":new Oe(le.layout_symbol["text-keep-upright"]),"text-transform":new ht(le.layout_symbol["text-transform"]),"text-offset":new ht(le.layout_symbol["text-offset"]),"text-allow-overlap":new Oe(le.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Oe(le.layout_symbol["text-ignore-placement"]),"text-optional":new Oe(le.layout_symbol["text-optional"]),visibility:new Oe(le.layout_symbol.visibility)});var hf={paint:new Ii({"icon-opacity":new ht(le.paint_symbol["icon-opacity"]),"icon-emissive-strength":new ht(le.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ht(le.paint_symbol["text-emissive-strength"]),"icon-color":new ht(le.paint_symbol["icon-color"]),"icon-halo-color":new ht(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new ht(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ht(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Oe(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Oe(le.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ht(le.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ht(le.paint_symbol["text-opacity"]),"text-color":new ht(le.paint_symbol["text-color"],{runtimeType:qr,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ht(le.paint_symbol["text-halo-color"]),"text-halo-width":new ht(le.paint_symbol["text-halo-width"]),"text-halo-blur":new ht(le.paint_symbol["text-halo-blur"]),"text-translate":new Oe(le.paint_symbol["text-translate"]),"text-translate-anchor":new Oe(le.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Oe(le.paint_symbol["icon-color-saturation"])}),layout:_1};class jg{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ns,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.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(jg,"FormatSectionOverride",{omit:["defaultValue"]});class Cd extends Cr{constructor(e,i,n){super(e,hf,i,n)}recalculate(e,i){super.recalculate(e,i),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const s=[];for(const l of n)s.indexOf(l)<0&&s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,i,n,s){const l=this.layout.get(e).evaluate(i,{},n,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||aa(u.value)||!l?l:(p=i.properties,l.replace(/{([^{}]+)}/g,(_,y)=>y in p?String(p[y]):""));var p}createBucket(e){return new Id(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of hf.paint.overridableProperties){if(!Cd.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),n=new jg(i),s=new dl(n,i.property.specification,this.scope,this.options);let l=null;l="constant"===i.value.kind||"source"===i.value.kind?new qc("source",s):new la("composite",s,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new Ts(i.property,l,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,n){return!(!this.layout||i.isDataDriven()||n.isDataDriven())&&Cd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const n=e.get("text-field"),s=hf.paint.properties[i];let l=!1;const u=p=>{for(const m of p)if(s.overrides&&s.overrides.hasOverride(m))return void(l=!0)};if("constant"===n.value.kind&&n.value.value instanceof lr)u(n.value.value.sections);else if("source"===n.value.kind){const p=_=>{l||(_ instanceof In&&$i(_.value)===ss?u(_.value.sections):_ instanceof ls?u(_.sections):_.eachChild(p))},m=n.value;m._styleExpression&&p(m._styleExpression.expression)}return l}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),i=0!==this.paint.get("text-opacity").constantOr(1),n=[];return e&&n.push("symbolIcon"),i&&n.push("symbolSDF"),n}getDefaultProgramParams(e,i){return{config:new P(this,i),overrideFog:!1}}}const g1=new Ii({visibility:new Oe(le.layout_background.visibility)});var y1={paint:new Ii({"background-color":new Oe(le.paint_background["background-color"]),"background-pattern":new Oe(le.paint_background["background-pattern"]),"background-opacity":new Oe(le.paint_background["background-opacity"]),"background-emissive-strength":new Oe(le.paint_background["background-emissive-strength"])}),layout:g1};const x1=new Ii({visibility:new Oe(le.layout_raster.visibility)});var v1={paint:new Ii({"raster-opacity":new Oe(le.paint_raster["raster-opacity"]),"raster-color":new Uo(le.paint_raster["raster-color"]),"raster-color-mix":new Oe(le.paint_raster["raster-color-mix"]),"raster-color-range":new Oe(le.paint_raster["raster-color-range"]),"raster-hue-rotate":new Oe(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Oe(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Oe(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Oe(le.paint_raster["raster-saturation"]),"raster-contrast":new Oe(le.paint_raster["raster-contrast"]),"raster-resampling":new Oe(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Oe(le.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Oe(le.paint_raster["raster-emissive-strength"]),"raster-array-band":new Oe(le.paint_raster["raster-array-band"]),"raster-elevation":new Oe(le.paint_raster["raster-elevation"])}),layout:x1},uf=li([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class df{constructor(e,i,n,s){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(i,s)}update(e,i,n){const{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&&(!i||!1!==i.premultiply)),n||this.size&&this.size[0]===s&&this.size[1]===l){const{x:m,y:_}=n||{x:0,y:0};if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap)p.texSubImage2D(p.TEXTURE_2D,0,m,_,p.RGBA,p.UNSIGNED_BYTE,e);else{let y=this.format,v=p.UNSIGNED_BYTE;this.format===p.R32F&&(y=p.RED,v=p.FLOAT),p.texSubImage2D(p.TEXTURE_2D,0,m,_,s,l,y,v,e.data)}}else if(this.size=[s,l],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap){let m=this.format;this.format===p.R8&&(m=p.RED),p.texImage2D(p.TEXTURE_2D,0,this.format,m,p.UNSIGNED_BYTE,e)}else{let m=this.format,_=this.format,y=p.UNSIGNED_BYTE;this.format===p.DEPTH_COMPONENT&&(m=p.DEPTH_COMPONENT16,y=p.UNSIGNED_SHORT),this.format===p.R8&&(_=p.RED),this.format===p.R32F&&(y=p.FLOAT,_=p.RED),p.texImage2D(p.TEXTURE_2D,0,m,s,l,0,_,y,e.data)}this.useMipmap=!(!i||!i.useMipmap),this.useMipmap&&p.generateMipmap(p.TEXTURE_2D)}bind(e,i,n=!1){const{context:s}=this,{gl:l}=s;l.bindTexture(l.TEXTURE_2D,this.texture),e!==this.minFilter&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,this.useMipmap&&!n?e===l.NEAREST?l.NEAREST_MIPMAP_NEAREST:l.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,n,s){const{context:l}=this,{gl:u}=l;u.bindTexture(u.TEXTURE_2D,this.texture),i!==this.magFilter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),this.magFilter=i),e!==this.minFilter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,this.useMipmap?e===u.NEAREST?u.NEAREST_MIPMAP_NEAREST:u.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),n!==this.wrapS&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,n),this.wrapS=n),s!==this.wrapT&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,s),this.wrapT=s)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Pd{constructor(e,i){this.context=e,this.texture=i}bind(e,i){const{context:n}=this,{gl:s}=n;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i),this.wrapS=i)}}function zd(t,e,i,n,s,l,u,p){const m=[t,e,1,i,n,1,s,l,1],_=[u,p,1],y=a.co.adjoint([],m),[v,w,E]=a.N.transformMat3(_,_,y);return a.co.multiply(m,m,[v,0,0,0,w,0,0,0,E])}function Gg(t,e,i,n,s,l,u,p){const m=function(_,y,v,w,E,A,I,z){const L=zd(0,0,1,0,1,1,0,1),N=zd(_,y,v,w,E,A,I,z),G=a.co.adjoint([],L);return a.co.multiply(N,N,G)}(t,e,i,n,s,l,u,p);return[m[2]/m[8]/qe,m[5]/m[8]/qe]}function Dd(t){return[t[0],Math.min(Math.max(t[1],-Ot),Ot)]}class Zg extends rs{constructor(e,i,n,s){super(),this.id=e,this.dispatcher=n,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(s),this.options=i,this._dirty=!1}load(e,i){if(this._loaded=i||!1,this.fire(new Io("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ze(this.map._requestManager.transformRequest(this.url,Er.Image),(n,s)=>{this._imageRequest=null,this._loaded=!0,n?this.fire(new Xl(n)):s&&(this.image=s instanceof HTMLImageElement?ze.getImageData(s):s,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Pd(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Io("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Pd||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=e[0][1],n=e[0][1];for(const l of e)l[1]>n&&(n=l[1]),l[1]<i&&(i=l[1]);const s=(n+i)/2;if(s>Ot?this.onNorthPole=!0:s<-Ot&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const l=e.map(Yt.fromLngLat);this.tileID=function(u){let p=1/0,m=1/0,_=-1/0,y=-1/0;for(const I of u)p=Math.min(p,I.x),m=Math.min(m,I.y),_=Math.max(_,I.x),y=Math.max(y,I.y);const v=Math.max(_-p,y-m),w=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),E=Math.pow(2,w);let A=Math.floor((p+_)/2*E);return A>1&&(A-=1),new Ie(w,A,Math.floor((m+y)/2*E))}(l),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Io("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const L in this.tiles){const N=this.tiles[L];"loaded"!==N.state&&(N.state="loaded",N.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=kh(new Ie(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(L){const N=L[1].x-L[0].x,G=L[1].y-L[0].y,j=L[2].x-L[1].x,X=L[2].y-L[1].y,W=L[3].x-L[2].x,J=L[3].y-L[2].y,ie=L[0].x-L[3].x,oe=L[0].y-L[3].y,he=N*X-j*G,se=j*J-W*X,_e=W*oe-ie*J,Me=ie*G-N*oe;return he>0&&se>0&&_e>0&&Me>0||he<0&&se<0&&_e<0&&Me<0}(n))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const s=kh(this.tileID,this.map.transform.projection),[l,u,p,m]=this.coordinates.map(L=>{const N=s.projection.project(L[0],L[1]);return Og(s,N)._round()});this.perspectiveTransform=Gg(l.x,l.y,u.x,u.y,p.x,p.y,m.x,m.y);const _=this._boundsArray=new Rn;_.emplaceBack(l.x,l.y,0,0),_.emplaceBack(u.x,u.y,qe,0),_.emplaceBack(m.x,m.y,0,qe),_.emplaceBack(p.x,p.y,qe,qe),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(_,uf.members),this.boundsSegments=Oi.simpleSegment(0,0,4,2);const y=[],v=[Dd((w=this.coordinates)[0]),Dd(w[1]),Dd(w[2]),Dd(w[3])];var w;const[E,A,I,z]=function(L){let N=L[0][0],G=N,j=L[0][1],X=j;for(let W=1;W<L.length;W++)L[W][0]<N?N=L[W][0]:L[W][0]>G&&(G=L[W][0]),L[W][1]<j?j=L[W][1]:L[W][1]>X&&(X=L[W][1]);return[N,j,G-N,X-j]}(v);{const L=new Rn,[N,G,j,X]=function(be){let Fe=be[0].x,Se=Fe,Qe=be[0].y,He=Qe;for(let Ce=1;Ce<be.length;Ce++)be[Ce].x<Fe?Fe=be[Ce].x:be[Ce].x>Se&&(Se=be[Ce].x),be[Ce].y<Qe?Qe=be[Ce].y:be[Ce].y>He&&(He=be[Ce].y);return[Fe,Qe,Se-Fe,He-Qe]}(n),W=be=>[(be.x-N)/j,(be.y-G)/X],[J,ie,oe,he]=n.map(W),se=function(be,Fe,Se,Qe,He,Ce,ft,st){const Je=zd(0,0,1,0,1,1,0,1),Pe=zd(be,Fe,Se,Qe,He,Ce,ft,st),ut=a.co.adjoint([],Pe);return a.co.multiply(Je,Je,ut)}(J[0],J[1],ie[0],ie[1],oe[0],oe[1],he[0],he[1]);this.elevatedGlobePerspectiveTransform=Gg(J[0],J[1],ie[0],ie[1],oe[0],oe[1],he[0],he[1]);const _e=(be,Fe)=>{y.push(be.lng);const Se=Math.round((be.lng-E)/I*qe),Qe=Math.round((be.lat-A)/z*qe),He=W(Fe),Ce=a.N.transformMat3([],[He[0],He[1],1],se),ft=Math.round(Ce[0]/Ce[2]*qe),st=Math.round(Ce[1]/Ce[2]*qe);L.emplaceBack(Se,Qe,ft,st)},Me=n[3].x-n[0].x,fe=n[3].y-n[0].y,we=n[2].x-n[1].x,de=n[2].y-n[1].y;for(let be=0;be<65;be++){const Fe=be/64,Se=[n[0].x+Fe*Me,n[0].y+Fe*fe],Qe=[n[1].x+Fe*we,n[1].y+Fe*de],He=Qe[0]-Se[0],Ce=Qe[1]-Se[1];for(let ft=0;ft<65;ft++){const st=ft/64,Je={x:Se[0]+He*st,y:Se[1]+Ce*st,z:0};_e(i.projection.unproject(Je.x,Je.y),Je)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(L,uf.members)}{this.maxLongitudeTriangleSize=0;let L=[],N=new Ji;const G=(j,X,W)=>{N.emplaceBack(j,X,W);const J=y[j],ie=y[X],oe=y[W],he=Math.min(Math.min(J,ie),oe),se=Math.max(Math.max(J,ie),oe)-he;se>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=se),L.push(he+se/2)};for(let j=0;j<64;j++)for(let X=0;X<64;X++){const W=65*j+X,J=W+1,ie=W+65,oe=ie+1;G(W,ie,J),G(J,ie,oe)}[L,N]=function(j,X){const W=Array.from({length:j.length},(oe,he)=>he);W.sort((oe,he)=>j[oe]-j[he]);const J=[],ie=new Ji;for(let oe=0;oe<W.length;oe++){const he=W[oe];J.push(j[he]);const se=3*he,_e=se+1;ie.emplaceBack(X.uint16[se],X.uint16[_e],X.uint16[_e+1])}return[J,ie]}(L,N),this.elevatedGlobeTrianglesCenterLongitudes=L,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(N)}this.elevatedGlobeSegments=Oi.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,I/qe,0,z/qe,0,0,A,E,0])}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const i=this.map.painter.context,n=i.gl;!this._dirty||this.texture instanceof Pd||(this.texture?this.texture.update(this.image):(this.texture=new df(i,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(i)}loadTile(e,i){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},i(null)):(e.state="errored",i(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){const i=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!i)return null;const n=this.elevatedGlobeTrianglesCenterLongitudes;let s=(y=e+180)+360*Math.round((n[0]-y)/360);var y;const l=new Oi,u=(y,v)=>{l.segments.push({vertexOffset:0,primitiveOffset:y,vertexLength:i.segments[0].vertexLength,primitiveLength:v,sortKey:void 0,vaos:{}})},p=.51*this.maxLongitudeTriangleSize;if(Math.abs(n[0]-s)<=p){const y=ye(n,0,n.length,s+p);return y===n.length||u(y,te(n,y+1,n.length,s+360-p)-y),l}s<n[0]&&(s+=360);const m=te(n,0,n.length,s-p);if(m===n.length)return u(0,n.length),l;u(0,m-0);const _=ye(n,m+1,n.length,s+p);return _!==n.length&&u(_,n.length-_),l}}const b1=(Math.pow(256,2)-1)/16907520;class qg extends Cr{constructor(e,i,n){super(e,v1,i,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isLayerDraped(e){return!(e&&e._source instanceof Zg&&(e._source.onNorthPole||e._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}updateColorRamp(e){if(!this.hasColorMap()||!this._curRampRange)return;const i=this._transitionablePaint._values["raster-color"].value.expression,[n,s]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(n)&&isNaN(s)||n===this._curRampRange[0]&&s===this._curRampRange[1]||(this.colorRamp=Mh({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:n,end:s}],resolution:256}),this.colorRampTexture=null,this._curRampRange=[n,s])}}const w1=new Ii({visibility:new Oe(le["layout_raster-particle"].visibility)});var T1={paint:new Ii({"raster-particle-array-band":new Oe(le["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Oe(le["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Uo(le["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Oe(le["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Oe(le["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Oe(le["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Oe(le["paint_raster-particle"]["raster-particle-reset-rate-factor"])}),layout:w1};class $g extends Cr{constructor(e,i,n){super(e,T1,i,n),this._updateColorRamp(),this.onRemove=s=>{this.colorRampTexture&&this.colorRampTexture.destroy(),this.transformFeedbackObject&&s.painter.context.gl.deleteTransformFeedback(this.transformFeedbackObject),this.tileFramebuffer&&this.tileFramebuffer.destroy()},this.lastInvalidatedAt=ze.now()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return"none"!==this.visibility}isLayerDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,i=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=Mh({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=ze.now()}}class M1 extends Cr{constructor(e,i){super(e,{},i),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}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)}}const E1=new Ii({visibility:new Oe(le.layout_sky.visibility)});var S1={paint:new Ii({"sky-type":new Oe(le.paint_sky["sky-type"]),"sky-atmosphere-sun":new Oe(le.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Oe(le.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Oe(le.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Oe(le.paint_sky["sky-gradient-radius"]),"sky-gradient":new Uo(le.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Oe(le.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Oe(le.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Oe(le.paint_sky["sky-opacity"])}),layout:E1};function pf(t,e,i){const n=[0,0,1],s=a.bi.identity([]);return a.bi.rotateY(s,s,i?-qt(t)+Math.PI:qt(t)),a.bi.rotateX(s,s,-qt(e)),a.N.transformQuat(n,n,s),a.N.normalize(n,n)}var A1={paint:new Ii({})};function Wg(t,e){const i=Ld(t.projection,t.zoom,t.width,t.height),n=function(l,u,p,m,_){const y=new ne(p.lng-180*Os,p.lat),v=new ne(p.lng+180*Os,p.lat),w=l.project(y.lng,y.lat),E=l.project(v.lng,v.lat),A=-Math.atan2(E.y-w.y,E.x-w.x),I=Yt.fromLngLat(p);I.y=Dt(I.y,-1+Os,1-Os);const z=I.toLngLat(),L=l.project(z.lng,z.lat),N=Yt.fromLngLat(z);N.x+=Os;const G=N.toLngLat(),j=l.project(G.lng,G.lat),X=Yg(j.x-L.x,j.y-L.y,A),W=Yt.fromLngLat(z);W.y+=Os;const J=W.toLngLat(),ie=l.project(J.lng,J.lat),oe=Yg(ie.x-L.x,ie.y-L.y,A),he=Math.abs(X.x)/Math.abs(oe.y),se=a.a6.identity([]);a.a6.rotateZ(se,se,-A*(1-(_?0:m)));const _e=a.a6.identity([]);return a.a6.scale(_e,_e,[1,1-(1-he)*m,1]),_e[4]=-oe.x/oe.y*m,a.a6.rotateZ(_e,_e,A),a.a6.multiply(_e,se,_e),_e}(t.projection,0,t.center,i,e),s=Hg(t);return a.a6.scale(n,n,[s,s,1]),n}function Hg(t){const e=t.projection,i=Ld(t.projection,t.zoom,t.width,t.height),n=Xg(e,t.center),s=Xg(e,ne.convert(e.center));return Math.pow(2,n*i+(1-i)*s)}function Ld(t,e,i,n,s=1/0){const l=t.range;if(!l)return 0;const u=Math.min(s,Math.max(i,n)),p=Math.log(u/1024)/Math.LN2;return Jo(l[0]+p,l[1]+p,e)}const Os=1/4e4;function Xg(t,e){const i=Dt(e.lat,-Ot,Ot),n=new ne(e.lng-180*Os,i),s=new ne(e.lng+180*Os,i),l=t.project(n.lng,i),u=t.project(s.lng,i),p=Yt.fromLngLat(n),m=Yt.fromLngLat(s),_=u.x-l.x,y=u.y-l.y,v=m.x-p.x,w=m.y-p.y,E=Math.sqrt((v*v+w*w)/(_*_+y*y));return Math.log(E)/Math.LN2}function Yg(t,e,i){const n=Math.cos(i),s=Math.sin(i);return{x:t*n-e*s,y:t*s+e*n}}function Kg(t,e,i){a.a6.identity(t),a.a6.rotateZ(t,t,qt(e[2])),a.a6.rotateX(t,t,qt(e[0])),a.a6.rotateY(t,t,qt(e[1])),a.a6.scale(t,t,i),a.a6.multiply(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Rd(t,e,i,n,s,l,u,p){const m=[i[0]-e[0],i[1]-e[1],0],_=[n[0]-e[0],n[1]-e[1],0];if(a.N.length(m)<1e-12||a.N.length(_)<1e-12)return a.bi.identity(t);const y=a.N.cross([],m,_);a.N.normalize(y,y),a.N.subtract(_,n,e),m[2]=(l-s)*p,_[2]=(u-s)*p;const v=m;return a.N.cross(v,m,_),a.N.normalize(v,v),a.bi.rotationTo(t,y,v)}function ff(t,e,i=!1){const n=Cs(e.zoom),s=function(l,u,p){const m=u.worldSize,_=[l[12],l[13],l[14]],y=Zt(_[1]/m),v=vt(_[0]/m),w=a.a6.identity([]),E=bt(1,y)*m,A=bt(1,0)*m*Bt(y,u.zoom),I=1/Bp(m);let z=A*I;if(p){const j=Ld(u.projection,u.zoom,u.width,u.height,1024);z=I*u.projection.pixelSpaceConversion(u.center.lat,m,j)}const L=me(y,v);a.N.add(L,L,a.N.scale([],a.N.normalize([],L),E*z*_[2]));const N=function(j){const X=[j[0],j[1],j[2]];let W=[0,1,0];const J=a.N.cross([],W,X);return a.N.cross(W,X,J),0===a.N.squaredLength(W)&&(W=[0,1,0],a.N.cross(J,X,W)),a.N.normalize(J,J),a.N.normalize(W,W),a.N.normalize(X,X),[J[0],J[1],J[2],0,W[0],W[1],W[2],0,X[0],X[1],X[2],0,j[0],j[1],j[2],1]}(L);a.a6.scale(w,w,[z,z,z*E]),a.a6.translate(w,w,[-_[0],-_[1],-_[2]]);const G=a.a6.multiply([],u.globeMatrix,N);return a.a6.multiply(G,G,w),a.a6.multiply(G,G,l),G}(t,e,i);return n>0?function(u,p,m){const _=(A,I,z)=>{const L=a.N.length(A),N=a.N.length(I),G=Ho(A,I,z);return a.N.scale(G,G,1/a.N.length(G)*Ut(L,N,z))},y=_([u[0],u[1],u[2]],[p[0],p[1],p[2]],m),v=_([u[4],u[5],u[6]],[p[4],p[5],p[6]],m),w=_([u[8],u[9],u[10]],[p[8],p[9],p[10]],m),E=Ho([u[12],u[13],u[14]],[p[12],p[13],p[14]],m);return[y[0],y[1],y[2],0,v[0],v[1],v[2],0,w[0],w[1],w[2],0,E[0],E[1],E[2],1]}(s,function(u,p){const m=p.worldSize,_=bt(1,0)*m*Bt(p.center.lat,p.zoom)/Bp(m),y=bt(1,p.center.lat)*m,v=a.a6.identity([]);return a.a6.rotateY(v,v,qt(p.center.lng)),a.a6.rotateX(v,v,qt(p.center.lat)),a.a6.translate(v,v,[0,0,V]),a.a6.scale(v,v,[_,_,_*y]),a.a6.translate(v,v,[p.point.x-.5*m,p.point.y-.5*m,0]),a.a6.multiply(v,v,u),a.a6.multiply(v,p.globeMatrix,v)}(t,e),n):s}function Jg(t,e,i,n){const s=Ri.projectAabbCorners(n,i);let l=Number.MAX_VALUE,u=-1;for(let _=0;_<s.length;++_){const y=s[_];y[0]=(.5*y[0]+.5)*e.width,y[1]=(.5-.5*y[1])*e.height,y[2]<l&&(u=_,l=y[2])}const p=_=>new Ue(s[_][0],s[_][1]);let m;switch(u){case 0:case 6:m=[p(1),p(5),p(4),p(7),p(3),p(2),p(1)];break;case 1:case 7:m=[p(0),p(4),p(5),p(6),p(2),p(3),p(0)];break;case 3:case 5:m=[p(1),p(0),p(4),p(7),p(6),p(2),p(1)];break;default:m=[p(1),p(5),p(6),p(7),p(3),p(0),p(1)]}if(wn(t,m))return l}const I1=li([{name:"a_pos_3f",components:3,type:"Float32"}]),C1=li([{name:"a_color_3f",components:3,type:"Float32"}]),P1=li([{name:"a_color_4f",components:4,type:"Float32"}]),z1=li([{name:"a_uv_2f",components:2,type:"Float32"}]),D1=li([{name:"a_normal_3f",components:3,type:"Float32"}]),L1=li([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),R1=li([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Qg{constructor(e,i){this.feature=e,this.instancedDataOffset=i,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class ey{constructor(){this.instancedDataArray=new mh,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class mf{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0}}populate(e,i,n,s){this.tileToMeter=Ft(n);const l=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:u,id:p,index:m,sourceLayerIndex:_}of e){const y=Hi(u,l);if(!this.layers[0]._featureFilter.filter(new Ai(this.zoom),y,n))continue;const v={id:p,sourceLayerIndex:_,index:m,geometry:l?y.geometry:er(u,n,s),properties:u.properties,type:u.type,patterns:{}},w=this.addFeature(v,v.geometry,y);w&&i.featureIndex.insert(u,v.geometry,m,_,this.index,this.instancesPerModel[w].instancedDataArray.length,256)}this.lookup=null}update(e,i,n,s){for(const l in this.instancesPerModel){const u=this.instancesPerModel[l];for(const p in e)u.idToFeaturesIndex.hasOwnProperty(p)&&this.evaluate(u.features[u.idToFeaturesIndex[p]],e[p],u,!0)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const s of n.features){const l=this.layers[0],u=s.feature,p=this.canonical,m=l.paint.get("model-rotation").evaluate(u,{},p),_=l.paint.get("model-scale").evaluate(u,{},p),y=l.paint.get("model-translation").evaluate(u,{},p);a.N.exactEquals(s.rotation,m)&&a.N.exactEquals(s.scale,_)&&a.N.exactEquals(s.translation,y)||(this.evaluate(s,s.featureStates,n,!0),e=!0)}}return e}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];n.instancedDataArray.length<0||0===n.instancedDataArray.length||(n.instancedDataBuffer?n.instancedDataBuffer.updateData(n.instancedDataArray):n.instancedDataBuffer=e.createVertexBuffer(n.instancedDataArray,L1.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];0!==i.instancedDataArray.length&&i.instancedDataBuffer&&i.instancedDataBuffer.destroy()}}addFeature(e,i,n){const s=this.layers[0],l=s.layout.get("model-id").evaluate(n,{},this.canonical);if(!l)return ki(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;this.instancesPerModel[l]||(this.instancesPerModel[l]=new ey);const u=this.instancesPerModel[l],p=u.instancedDataArray,m=new Qg(n,p.length);for(const _ of i)for(const y of _){if(y.x<0||y.x>=qe||y.y<0||y.y>=qe)continue;const v=(this.lookupDim-1)/qe,w=this.lookupDim*(y.y*v|0)+y.x*v|0;if(this.lookup){if(0!==this.lookup[w])continue;this.lookup[w]=1}this.instanceCount++;const E=p.length;p.resize(E+1),u.instancesEvaluatedElevation.push(0),p.float32[16*E]=y.x,p.float32[16*E+1]=y.y}return m.instancedDataCount=u.instancedDataArray.length-m.instancedDataOffset,m.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(m),this.evaluate(m,{},u,!1)),l}evaluate(e,i,n,s){const l=this.layers[0],u=e.feature,p=this.canonical,m=e.rotation=l.paint.get("model-rotation").evaluate(u,i,p),_=e.scale=l.paint.get("model-scale").evaluate(u,i,p),y=e.translation=l.paint.get("model-translation").evaluate(u,i,p),v=l.paint.get("model-color").evaluate(u,i,p);v.a=l.paint.get("model-color-mix-intensity").evaluate(u,i,p);const w=[];this.maxVerticalOffset<y[2]&&(this.maxVerticalOffset=y[2]),this.maxScale=Math.max(Math.max(this.maxScale,_[0]),Math.max(_[1],_[2])),Kg(w,m,_);const E=Math.round(100*v.a)+v.b/1.05;for(let A=0;A<e.instancedDataCount;++A){const I=e.instancedDataOffset+A,z=16*I,L=n.instancedDataArray.float32;let N=0;s&&(N=L[z+6]-n.instancesEvaluatedElevation[I]);const G=0|L[z+1];L[z]=(0|L[z])+v.r/1.05,L[z+1]=G+v.g/1.05,L[z+2]=E,L[z+3]=1/(p.z>10?this.tileToMeter:Ft(p,G)),L[z+4]=y[0],L[z+5]=y[1],L[z+6]=y[2]+N,L[z+7]=w[0],L[z+8]=w[1],L[z+9]=w[2],L[z+10]=w[4],L[z+11]=w[5],L[z+12]=w[6],L[z+13]=w[8],L[z+14]=w[9],L[z+15]=w[10],n.instancesEvaluatedElevation[I]=y[2]}}}Ke(mf,"ModelBucket",{omit:["layers"]}),Ke(ey,"PerModelAttributes"),Ke(Qg,"ModelFeature");const k1=new Ii({visibility:new Oe(le.layout_model.visibility),"model-id":new ht(le.layout_model["model-id"])});var O1={paint:new Ii({"model-opacity":new Oe(le.paint_model["model-opacity"]),"model-rotation":new ht(le.paint_model["model-rotation"]),"model-scale":new ht(le.paint_model["model-scale"]),"model-translation":new ht(le.paint_model["model-translation"]),"model-color":new ht(le.paint_model["model-color"]),"model-color-mix-intensity":new ht(le.paint_model["model-color-mix-intensity"]),"model-type":new Oe(le.paint_model["model-type"]),"model-cast-shadows":new Oe(le.paint_model["model-cast-shadows"]),"model-receive-shadows":new Oe(le.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Oe(le.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ht(le.paint_model["model-emissive-strength"]),"model-roughness":new ht(le.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ht(le.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Oe(le.paint_model["model-cutoff-fade-range"])}),layout:k1};const Vl={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function ty(t,e,i,n,s,l,u,p,m,_=!1){const y=i.zoom,v=i.project(n),w=Bt(n.lat,y),E=1/w;a.a6.identity(t),a.a6.translate(t,t,[v.x+u[0]*E,v.y+u[1]*E,u[2]]);let A=1,I=1;const z=i.worldSize;if(_){if("mercator"===i.projection.name){let j=0;i.elevation&&(j=i.elevation.getAtPointOrZero(new Yt(v.x/z,v.y/z),0));const X=a.a7.transformMat4([],[v.x,v.y,j,1],i.projMatrix)[3]/i.cameraToCenterDistance;A=X,I=X*Bt(i.center.lat,y)}else if("globe"===i.projection.name){const j=ff(t,i),X=a.a6.multiply([],i.projMatrix,j),W=[0,0,0,1];a.a7.transformMat4(W,W,X);const J=W[3]/i.cameraToCenterDistance,ie=Cs(y),oe=i.projection.pixelsPerMeter(n.lat,z)*Bt(n.lat,y),he=i.projection.pixelsPerMeter(i.center.lat,z)*Bt(i.center.lat,y);A=J/Ut(oe,Ci(i.center.lat),ie),I=J*w/oe,A*=he,I*=he}}else A=E;a.a6.scale(t,t,[A,A,I]);const L=[...t],N=e.orientation,G=[];if(Kg(G,[N[0]+s[0],N[1]+s[1],N[2]+s[2]],l),a.a6.multiply(t,L,G),p&&i.elevation){let j=0;const X=[];if(m&&i.elevation){j=function(ie,oe,he,se,_e){const Me=oe.elevation;if(!Me)return 0;const fe=Ri.projectAabbCorners(he,se),we=bt(1,_e.lat)*oe.worldSize,de=function(ut,It){const mt=[0,0,1],Ct=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const xt of Ct){const jt=ut[xt.corners[0]],wt=ut[xt.corners[1]],mi=ut[xt.corners[2]],Jt=[wt[0]-jt[0],wt[1]-jt[1],It*(wt[2]-jt[2])],ei=a.N.cross(Jt,Jt,[mi[0]-jt[0],mi[1]-jt[1],It*(mi[2]-jt[2])]);a.N.normalize(ei,ei),xt.dotProductWithUp=a.N.dot(ei,mt)}return Ct.sort((xt,jt)=>xt.dotProductWithUp-jt.dotProductWithUp),Ct[0].corners}(fe,we),be=fe[de[0]],Fe=fe[de[1]],Se=fe[de[2]],Qe=fe[de[3]],He=Me.getAtPointOrZero(new Yt(be[0]/oe.worldSize,be[1]/oe.worldSize),0),Ce=Me.getAtPointOrZero(new Yt(Fe[0]/oe.worldSize,Fe[1]/oe.worldSize),0),ft=Me.getAtPointOrZero(new Yt(Se[0]/oe.worldSize,Se[1]/oe.worldSize),0),st=Me.getAtPointOrZero(new Yt(Qe[0]/oe.worldSize,Qe[1]/oe.worldSize),0),Je=(He+st)/2,Pe=(Ce+ft)/2;return Je>Pe?Ce<ft?Rd(ie,Fe,Qe,be,Ce,st,He,we):Rd(ie,Se,be,Qe,ft,He,st,we):He<st?Rd(ie,be,Fe,Se,He,Ce,ft,we):Rd(ie,Qe,Se,Fe,st,ft,Ce,we),Math.max(Je,Pe)}(X,i,e.aabb,t,n);const W=a.a6.fromQuat([],X),J=a.a6.multiply([],W,G);a.a6.multiply(t,L,J)}else j=i.elevation.getAtPointOrZero(new Yt(v.x/z,v.y/z),0);0!==j&&(t[14]+=j)}}function Vh(t,e,i=!1){t.uploaded||(t.gfxTexture=new df(e,t.image,i?e.gl.R8:e.gl.RGBA,{useMipmap:t.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function B1(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,I1.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,D1.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,z1.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?C1:P1).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,R1.members,!0)),t.segments=Oi.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Vh(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Vh(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Vh(n.normalTexture,e),n.occlusionTexture&&Vh(n.occlusionTexture,e,i),n.emissionTexture&&Vh(n.emissionTexture,e)}function _f(t,e,i){if(t.meshes)for(const n of t.meshes)B1(n,e,i);if(t.children)for(const n of t.children)_f(n,e,i)}function kd(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)kd(e)}function gf(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const i of t.children)gf(i)}class F1{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(){this._channel=void 0,this._callback=()=>{}}}class N1{constructor(){this.tasks={},this.taskQueue=[],Eo(["process"],this),this.invoker=new F1(this.process),this.nextId=0}add(e,i){const n=this.nextId++,s=function({type:l,isSymbolTile:u,zoom:p}){return p=p||0,"message"===l?0:"maybePrepare"!==l||u?"parseTile"!==l||u?"parseTile"===l&&u?300-p:"maybePrepare"===l&&u?400-p:500:200-p:100-p}(i);return 0===s?(yn(),e(),null):(this.tasks[n]={fn:e,metadata:i,priority:s,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){yn();{if(this.taskQueue=this.taskQueue.filter(n=>!!this.tasks[n]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}}pick(){let e=null,i=1/0;for(let s=0;s<this.taskQueue.length;s++){const l=this.tasks[this.taskQueue[s]];l.priority<i&&(i=l.priority,e=s)}if(null===e)return null;const n=this.taskQueue[e];return this.taskQueue.splice(e,1),n}remove(){this.invoker.remove()}}class iy{constructor(e,i,n){this.target=e,this.parent=i,this.mapId=n,this.callbacks={},this.cancelCallbacks={},Eo(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new N1}send(e,i,n,s,l=!1,u){const p=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=u,this.callbacks[p]=n);const m=new Set;return this.target.postMessage({id:p,type:e,hasCallback:!!n,targetMapId:s,mustQueue:l,sourceMapId:this.mapId,data:ao(i,m)},m),{cancel:()=>{n&&delete this.callbacks[p],this.target.postMessage({id:p,type:"<cancel>",targetMapId:s,sourceMapId:this.mapId})}}}receive(e){const i=e.data,n=i.id;if(n&&(!i.targetMapId||this.mapId===i.targetMapId))if("<cancel>"===i.type){const s=this.cancelCallbacks[n];delete this.cancelCallbacks[n],s&&s.cancel()}else if(i.mustQueue||yn()){const s=this.callbacks[n],l=this.scheduler.add(()=>this.processTask(n,i),s&&s.metadata||{type:"message"});l&&(this.cancelCallbacks[n]=l)}else this.processTask(n,i)}processTask(e,i){if(delete this.cancelCallbacks[e],"<response>"===i.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(i.error?n(No(i.error)):n(null,No(i.data)))}else{const n=new Set,s=i.hasCallback?(u,p)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:u?ao(u):null,data:ao(p,n)},n)}:u=>{},l=No(i.data);if(this.parent[i.type])this.parent[i.type](i.sourceMapId,l,s);else if(this.parent.getWorkerSource){const u=i.type.split(".");this.parent.getWorkerSource(i.sourceMapId,u[0],l.source,l.scope)[u[1]](l,s)}else s(new Error(`Could not find function ${i.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}let yf=(()=>{class t{constructor(i,n){this.workerPool=i,this.actors=[],this.currentActor=0,this.id=Qo();const s=this.workerPool.acquire(this.id);for(let l=0;l<s.length;l++){const u=new t.Actor(s[l],n,this.id);u.name=`Worker ${l}`,this.actors.push(u)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(i,n,s){tn(this.actors,(l,u)=>{l.send(i,n,u)},s=s||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)}}return t.Actor=iy,t})();var Uh={workerUrl:"",workerClass:null,workerParams:void 0};function V1(){return null!=Uh.workerClass?new Uh.workerClass:new self.Worker(Uh.workerUrl,Uh.workerParams)}const xf="mapboxgl_preloaded_worker_pool";class jh{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<jh.workerCount;)this.workers.push(new V1);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach(i=>{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[xf]}numActive(){return Object.keys(this.active).length}}let Gh;function Od(){return Gh||(Gh=new jh),Gh}jh.workerCount=2;let Bd,vf,Un,Ul,bf,jl=null;function ry(){return yn()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:vf||zt.DRACO_URL}function ny(){if(yn()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Ul)return Ul;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Ul=WebAssembly.validate(t)?zt.MESHOPT_SIMD_URL:zt.MESHOPT_URL,Ul}const Fd={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},U1={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},Zh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function oy(t,e,i){const n=i.json.bufferViews.length,s=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:s,byteLength:t.byteLength},i.buffers[s]=t}const wf="KHR_draco_mesh_compression";function j1(t,e){const i=t.extensions&&t.extensions[wf];if(!i)return;const n=new Un.Decoder,s=cy(e,i.bufferView),l=new Un.Mesh;if(!n.DecodeArrayToMesh(s,s.byteLength,l))throw new Error("Failed to decode Draco mesh");const u=e.json.accessors[t.indices],p=Fd[u.componentType],m=u.count*p.BYTES_PER_ELEMENT,_=Un._malloc(m);p===Uint16Array?n.GetTrianglesUInt16Array(l,m,_):n.GetTrianglesUInt32Array(l,m,_),oy(Un.memory.buffer.slice(_,_+m),u,e),Un._free(_);for(const y of Object.keys(i.attributes)){const v=n.GetAttributeByUniqueId(l,i.attributes[y]),w=e.json.accessors[t.attributes[y]],E=U1[w.componentType],A=w.count*Zh[w.type]*Fd[w.componentType].BYTES_PER_ELEMENT,I=Un._malloc(A);n.GetAttributeDataArrayForAllPoints(l,v,Un[E],A,I),oy(Un.memory.buffer.slice(I,I+A),w,e),Un._free(I)}n.destroy(),l.destroy(),delete t.extensions[wf]}const Nd="EXT_meshopt_compression";function G1(t,e){if(!t.extensions||!t.extensions[Nd])return;const i=t.extensions[Nd],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),s=new Uint8Array(i.count*i.byteStride);bf.decodeGltfBuffer(s,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=s.buffer,delete t.extensions[Nd]}const sy=1179937895,ay=new TextDecoder("utf8");function ly(t,e){return new URL(t,e).href}function Z1(t,e,i,n){return fetch(ly(t.uri,n)).then(s=>s.arrayBuffer()).then(s=>{e.buffers[i]=s})}function cy(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function q1(t,e,i,n){if(t.uri){const s=ly(t.uri,n);return fetch(s).then(l=>l.blob()).then(l=>createImageBitmap(l)).then(l=>{e.images[i]=l})}if(void 0!==t.bufferView){const s=cy(e,t.bufferView),l=new Blob([s],{type:t.mimeType});return createImageBitmap(l).then(u=>{e.images[i]=u})}}function hy(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===sy){const y=new Uint32Array(t,e);let v=2;const w=(y[v++]>>2)-3,E=y[v++]>>2;if(v++,n.json=JSON.parse(ay.decode(y.subarray(v,v+E))),v+=E,v<w){const A=y[v++];v++;const I=e+(v<<2);n.buffers[0]=t.slice(I,I+A)}}else n.json=JSON.parse(ay.decode(new Uint8Array(t,e)));const{buffers:s,images:l,meshes:u,extensionsUsed:p,bufferViews:m}=n.json;let _=Promise.resolve();if(s){const y=[];for(let v=0;v<s.length;v++){const w=s[v];w.uri?y.push(Z1(w,n,v,i)):n.buffers[v]||(n.buffers[v]=null)}_=Promise.all(y)}return _.then(()=>{const y=[],v=p&&p.includes(wf),w=p&&p.includes(Nd);if(v&&y.push(function(){if(!Un)return Bd||(Bd=function(E){let A,I=null;function z(){A=new Uint8Array(I.buffer)}function L(){throw new Error("Unexpected Draco error.")}const N={a:{a:L,d:function(G,j,X){return A.copyWithin(G,j,j+X)},c:function(G){const j=A.length,X=Math.max(G>>>0,Math.ceil(1.2*j)),W=Math.ceil((X-j)/65536);try{return I.grow(W),z(),!0}catch{return!1}},b:L}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(E,N):E.then(G=>G.arrayBuffer()).then(G=>WebAssembly.instantiate(G,N))).then(G=>{const{Rb:j,Qb:X,P:W,T:J,X:ie,Ja:oe,La:he,Qa:se,Va:_e,Wa:Me,eb:fe,jb:we,f:de,e:be,yb:Fe,zb:Se,Ab:Qe,Bb:He,Db:Ce,Gb:ft}=G.instance.exports;I=be;const st=(()=>{let Je=0,Pe=0,ut=0,It=0;return mt=>{ut&&(j(It),j(Je),Pe+=ut,ut=Je=0),Je||(Pe+=128,Je=X(Pe));const Ct=mt.length+7&-8;let xt=Je;Ct>=Pe&&(ut=Ct,xt=It=X(Ct));for(let jt=0;jt<mt.length;jt++)A[xt+jt]=mt[jt];return xt}})();return z(),de(),{memory:be,_free:j,_malloc:X,Mesh:class{constructor(){this.ptr=W()}destroy(){J(this.ptr)}},Decoder:class{constructor(){this.ptr=oe()}destroy(){we(this.ptr)}DecodeArrayToMesh(Je,Pe,ut){const It=st(Je),mt=he(this.ptr,It,Pe,ut.ptr);return!!ie(mt)}GetAttributeByUniqueId(Je,Pe){return{ptr:se(this.ptr,Je.ptr,Pe)}}GetTrianglesUInt16Array(Je,Pe,ut){_e(this.ptr,Je.ptr,Pe,ut)}GetTrianglesUInt32Array(Je,Pe,ut){Me(this.ptr,Je.ptr,Pe,ut)}GetAttributeDataArrayForAllPoints(Je,Pe,ut,It,mt){fe(this.ptr,Je.ptr,Pe.ptr,ut,It,mt)}},DT_INT8:Fe(),DT_UINT8:Se(),DT_INT16:Qe(),DT_UINT16:He(),DT_UINT32:Ce(),DT_FLOAT32:ft()}})}(fetch(ry())),Bd.then(E=>{Un=E,Bd=void 0}))}()),w&&y.push(function(){if(bf)return;const E=function(A){let I;const z=WebAssembly.instantiateStreaming(A,{}).then(G=>{I=G.instance,I.exports.__wasm_call_ctors()}),L={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},N={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:z,supported:!0,decodeGltfBuffer(G,j,X,W,J,ie){!function(oe,he,se,_e,Me,fe,we){const de=oe.exports.sbrk,be=_e+3&-4,Fe=de(be*Me),Se=de(fe.length),Qe=new Uint8Array(oe.exports.memory.buffer);Qe.set(fe,Se);const He=he(Fe,_e,Me,Se,fe.length);if(0===He&&we&&we(Fe,be,Me),se.set(Qe.subarray(Fe,Fe+_e*Me)),de(Fe-de(0)),0!==He)throw new Error(`Malformed buffer data: ${He}`)}(I,I.exports[N[J]],G,j,X,W,I.exports[L[ie]])}}}(fetch(ny()));return E.ready.then(()=>{bf=E})}()),l)for(let E=0;E<l.length;E++)y.push(q1(l[E],n,E,i));return(y.length?Promise.all(y):Promise.resolve()).then(()=>{if(v&&u)for(const{primitives:E}of u)for(const A of E)j1(A,n);if(w&&u&&m)for(const E of m)G1(E,n);return n})})}class uy{constructor(e,i,n){if(this.triangleCount=i.length/3,this.min=new Ue(0,0),this.max=new Ue(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length||0===n)return;const s=e.map(y=>y.x),l=e.map(y=>y.y);this.min=new Ue(Math.min(...s),Math.min(...l)),this.max=new Ue(Math.max(...s),Math.max(...l));const u=this.max.sub(this.min);u.x=Math.max(u.x,1),u.y=Math.max(u.y,1);const p=Math.max(u.x,u.y)/n;this.cellsX=Math.max(1,Math.ceil(u.x/p)),this.cellsY=Math.max(1,Math.ceil(u.y/p)),this.xScale=1/p,this.yScale=1/p;const m=[];for(let y=0;y<this.triangleCount;y++){const v=e[i[3*y+0]].sub(this.min),w=e[i[3*y+1]].sub(this.min),E=e[i[3*y+2]].sub(this.min),A=Bs(Math.floor(Math.min(v.x,w.x,E.x)),this.xScale,this.cellsX),I=Bs(Math.floor(Math.max(v.x,w.x,E.x)),this.xScale,this.cellsX),z=Bs(Math.floor(Math.min(v.y,w.y,E.y)),this.yScale,this.cellsY),L=Bs(Math.floor(Math.max(v.y,w.y,E.y)),this.yScale,this.cellsY),N=new Ue(0,0),G=new Ue(0,0),j=new Ue(0,0),X=new Ue(0,0);for(let W=z;W<=L;++W){N.y=G.y=W*p,j.y=X.y=(W+1)*p;for(let J=A;J<=I;++J)N.x=j.x=J*p,G.x=X.x=(J+1)*p,(mp(v,w,E,N,G,X)||mp(v,w,E,N,X,j))&&m.push({cellIdx:W*this.cellsX+J,triIdx:y})}}if(0===m.length)return;m.sort((y,v)=>y.cellIdx-v.cellIdx||y.triIdx-v.triIdx);let _=0;for(;_<m.length;){const y=m[_].cellIdx,v={start:this.payload.length,len:0};for(;_<m.length&&m[_].cellIdx===y;)++v.len,this.payload.push(m[_++].triIdx);this.cells[y]=v}}query(e,i,n){if(0===this.triangleCount||0===this.cells.length||e.x>this.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let m=0;m<this.lookup.length;m++)this.lookup[m]=0;const s=Bs(e.x-this.min.x,this.xScale,this.cellsX),l=Bs(i.x-this.min.x,this.xScale,this.cellsX),u=Bs(e.y-this.min.y,this.yScale,this.cellsY),p=Bs(i.y-this.min.y,this.yScale,this.cellsY);for(let m=u;m<=p;m++)for(let _=s;_<=l;_++){const y=this.cells[m*this.cellsX+_];if(y)for(let v=0;v<y.len;v++){const w=this.payload[y.start+v],E=Math.floor(w/8),A=1<<w%8;if(!(this.lookup[E]&A)&&(this.lookup[E]|=A,n.push(w),n.length===this.triangleCount))return}}}}function Bs(t,e,i){return Math.max(0,Math.min(i-1,Math.floor(t*e)))}function Ba(t,e){const i=t.json.bufferViews[e.bufferView],n=Fd[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==Zh[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:Zh[e.type]))}function Tf(t,e,i,n){const s=Fd[e.componentType],l=function(y){switch(y){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(s),u=t.json.bufferViews[e.bufferView],p=u.byteStride?u.byteStride/s.BYTES_PER_ELEMENT:Zh[e.type],m=i.float32,_=m.length/i.capacity;for(let y=0,v=0;y<e.count*p;y+=p,v+=_)for(let w=0;w<_;w++)m[v+w]=n[y+w]*l;i._trim()}function $1(t,e,i){const n=t.indices,s=t.attributes,l={};l.indexArray=new Ji;const u=e.json.accessors[n],p=u.count/3;l.indexArray.reserve(p);const m=Ba(e,u);for(let w=0;w<p;w++)l.indexArray.emplaceBack(m[3*w],m[3*w+1],m[3*w+2]);l.indexArray._trim(),l.vertexArray=new jo;const _=e.json.accessors[s.POSITION];l.vertexArray.reserve(_.count);const y=Ba(e,_);for(let w=0;w<_.count;w++)l.vertexArray.emplaceBack(y[3*w],y[3*w+1],y[3*w+2]);if(l.vertexArray._trim(),l.aabb=new Ri(_.min,_.max),l.centroid=function(w,E){const A=[0,0,0],I=w.length;if(I>0){for(let z=0;z<I;z++){const L=3*w[z];A[0]+=E[L],A[1]+=E[L+1],A[2]+=E[L+2]}A[0]/=I,A[1]/=I,A[2]/=I}return A}(m,y),void 0!==s.COLOR_0){const w=e.json.accessors[s.COLOR_0],E=Zh[w.type],A=Ba(e,w);l.colorArray=3===E?new jo:new uo,l.colorArray.resize(w.count),Tf(e,w,l.colorArray,A)}if(void 0!==s.NORMAL){l.normalArray=new jo;const w=e.json.accessors[s.NORMAL];l.normalArray.resize(w.count);const E=Ba(e,w);Tf(e,w,l.normalArray,E)}if(void 0!==s.TEXCOORD_0&&i.length>0){l.texcoordArray=new Ma;const w=e.json.accessors[s.TEXCOORD_0];l.texcoordArray.resize(w.count);const E=Ba(e,w);Tf(e,w,l.texcoordArray,E)}if(void 0!==s._FEATURE_ID_RGBA4444){const w=e.json.accessors[s._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(l.featureData=Ba(e,w))}void 0!==s._FEATURE_RGBA4444&&(l.featureData=new Uint32Array(Ba(e,e.json.accessors[s._FEATURE_RGBA4444]).buffer));const v=t.material;return l.material=function(w,E){const{emissiveFactor:A=[0,0,0],alphaMode:I="OPAQUE",alphaCutoff:z=.5,normalTexture:L,occlusionTexture:N,emissiveTexture:G,doubleSided:j}=w,{baseColorFactor:X=[1,1,1,1],metallicFactor:W=1,roughnessFactor:J=1,baseColorTexture:ie,metallicRoughnessTexture:oe}=w.pbrMetallicRoughness||{},he=N?E[N.index]:void 0;if(N&&N.extensions&&N.extensions.KHR_texture_transform&&he){const se=N.extensions.KHR_texture_transform;he.offsetScale=[se.offset[0],se.offset[1],se.scale[0],se.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new ji(...X),metallicFactor:W,roughnessFactor:J,baseColorTexture:ie?E[ie.index]:void 0,metallicRoughnessTexture:oe?E[oe.index]:void 0},doubleSided:j,emissiveFactor:A,alphaMode:I,alphaCutoff:z,normalTexture:L?E[L.index]:void 0,occlusionTexture:he,emissionTexture:G?E[G.index]:void 0,defined:void 0===w.defined}}(void 0!==v?e.json.materials[v]:{defined:!1},i),l}function dy(t,e,i){const{matrix:n,rotation:s,translation:l,scale:u,mesh:p,extras:m,children:_}=t,y={};if(y.matrix=n||a.a6.fromRotationTranslationScale([],s||[0,0,0,1],l||[0,0,0],u||[1,1,1]),void 0!==p){y.meshes=i[p];const v=y.anchor=[0,0];for(const w of y.meshes){const{min:E,max:A}=w.aabb;v[0]+=E[0]+A[0],v[1]+=E[1]+A[1]}v[0]=Math.floor(v[0]/y.meshes.length/2),v[1]=Math.floor(v[1]/y.meshes.length/2)}if(m&&(m.id&&(y.id=m.id),m.lights&&(y.lights=function(v){if(!v.length)return[];const w=function(L){const N=atob(L),G=new Uint8Array(N.length);for(let j=0;j<N.length;j++)G[j]=N.codePointAt(j);return G}(v),E=[],A=w.length/24,I=new Uint16Array(w.buffer),z=new Float32Array(w.buffer);for(let L=0;L<A;L++){const N=I[2*L*6]/30,G=I[2*L*6+1]/30,j=I[2*L*6+10]/100,X=z[6*L+1],W=z[6*L+2],J=z[6*L+3],ie=z[6*L+4],oe=J-X,he=ie-W,se=Math.hypot(oe,he);E.push({pos:[X+.5*oe,W+.5*he,G],normal:[he/se,-oe/se,0],width:se,height:N,depth:j,points:[X,W,J,ie]})}return E}(m.lights))),_){const v=[];for(const w of _)v.push(dy(e.json.nodes[w],e,i));y.children=v}return y}function W1(t){if(0===t.vertices.length||0===t.indices.length)return null;const[e,i]=[t.vertices[0].clone(),t.vertices[0].clone()];for(let u=1;u<t.vertices.length;++u){const p=t.vertices[u];e.x=Math.min(e.x,p.x),e.y=Math.min(e.y,p.y),i.x=Math.max(i.x,p.x),i.y=Math.max(i.y,p.y)}const n=Math.ceil(Math.max(i.x-e.x,i.y-e.y)/256),s=Math.max(8,n),l=new uy(t.vertices,t.indices,s);return{vertices:t.vertices,indices:t.indices,grid:l,min:e,max:i}}function H1(t){if(!t.extras||!t.extras.ground)return null;const e=t.extras.ground;if(!e||!Array.isArray(e)||0===e.length)return null;const i=e[0];if(!i||!Array.isArray(i)||0===i.length)return null;const n=[];for(const u of i){if(!Array.isArray(u)||2!==u.length)continue;const p=u[0],m=u[1];"number"==typeof p&&"number"==typeof m&&n.push(new Ue(p,m))}if(n.length<3)return null;n.length>1&&n[n.length-1].equals(n[0])&&n.pop();let s=0;for(let u=0;u<n.length;u++){const p=n[u],m=n[(u+1)%n.length],_=n[(u+2)%n.length];s+=(p.x-m.x)*(_.y-m.y)-(_.x-m.x)*(p.y-m.y)}s>0&&n.reverse();const l=sd(n.flatMap(u=>[u.x,u.y]),[]);return 0===l.length?null:{vertices:n,indices:l}}function X1(t){const e=[],i=[];let n=0;for(const s of t){n=e.length;const l=s.vertexArray.float32,u=s.indexArray.uint16;for(let p=0;p<s.vertexArray.length;p++)e.push(new Ue(l[3*p+0],l[3*p+1]));for(let p=0;p<3*s.indexArray.length;p++)i.push(u[p]+n)}if(i.length%3!=0)return null;for(let s=0;s<i.length;s+=3){const l=e[i[s+0]],u=e[i[s+1]],p=e[i[s+2]];(l.x-u.x)*(p.y-u.y)-(p.x-u.x)*(l.y-u.y)>0&&([i[s+1],i[s+2]]=[i[s+2],i[s+1]])}return{vertices:e,indices:i}}function py(t){const i=function(m,_){const y=[];for(const v of m.json.meshes){const w=[];for(const E of v.primitives)w.push($1(E,m,_));y.push(w)}return y}(t,function(m,_){const y=[],v=WebGL2RenderingContext;if(m.json.textures)for(const w of m.json.textures){const E={magFilter:v.LINEAR,minFilter:v.NEAREST,wrapS:v.REPEAT,wrapT:v.REPEAT};void 0!==w.sampler&&Object.assign(E,m.json.samplers[w.sampler]),y.push({image:_[w.source],sampler:E,uploaded:!1})}return y}(t,t.images)),{scenes:n,scene:s,nodes:l}=t.json,u=n?n[s||0].nodes:l,p=[];for(const m of u)p.push(dy(l[m],t,i));return function(m,_,y){const v={},w=new Set;for(let E=0;E<m.length;E++){const A=y[_[E]];if(!A.extras)continue;const I=A.extras["mapbox:footprint:version"],z=A.extras["mapbox:footprint:id"];(I||z)&&w.add(E),"1.0.0"===I&&z&&(v[z]=E)}for(let E=0;E<m.length;E++){if(w.has(E))continue;const A=m[E],I=y[_[E]];if(!I.extras)continue;let z=null;A.id in v&&(z=X1(m[v[A.id]].meshes)),z||(z=H1(I)),z&&(A.footprint=W1(z))}if(w.size>0){const E=Array.from(w.values()).sort((A,I)=>A-I);for(let A=E.length-1;A>=0;A--)m.splice(E[A],1)}}(p,u,t.json.nodes),p}function Y1(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,s=64/(t.aabb.max[0]-i+2),l=64/(t.aabb.max[1]-n+2);for(let u=0;u<e.length;u+=3){const p=e[u+2],m=(e[u+0]-i)*s|0,_=(e[u+1]-n)*l|0;p>t.heightmap[64*_+m]&&(t.heightmap[64*_+m]=p)}}function K1(t,e){const i={};i.indexArray=new Ji,i.indexArray.reserve(4*t.length),i.vertexArray=new jo,i.vertexArray.reserve(10*t.length),i.colorArray=new uo,i.vertexArray.reserve(10*t.length);let n=0;for(const u of t){const p=Math.min(10,Math.max(4,1.3*u.height))*e,m=[-u.normal[1],u.normal[0],0],_=Math.min(.29,.1*u.width/u.depth),y=u.width-2*u.depth*e*(_+.01),v=a.N.scaleAndAdd([],u.pos,m,y/2),w=a.N.scaleAndAdd([],u.pos,m,-y/2),E=[v[0],v[1],v[2]+u.height],A=[w[0],w[1],w[2]+u.height],I=a.N.scaleAndAdd([],u.normal,m,_);a.N.scale(I,I,p);const z=a.N.scaleAndAdd([],u.normal,m,-_);a.N.scale(z,z,p),a.N.add(I,v,I),a.N.add(z,w,z),v[2]+=.1,w[2]+=.1,i.vertexArray.emplaceBack(I[0],I[1],I[2]),i.vertexArray.emplaceBack(z[0],z[1],z[2]),i.vertexArray.emplaceBack(v[0],v[1],v[2]),i.vertexArray.emplaceBack(w[0],w[1],w[2]),i.vertexArray.emplaceBack(E[0],E[1],E[2]),i.vertexArray.emplaceBack(A[0],A[1],A[2]),i.vertexArray.emplaceBack(v[0],v[1],v[2]),i.vertexArray.emplaceBack(w[0],w[1],w[2]),i.vertexArray.emplaceBack(I[0],I[1],I[2]),i.vertexArray.emplaceBack(z[0],z[1],z[2]);const L=y/p/2;i.colorArray.emplaceBack(-L-_,-1,L,.8),i.colorArray.emplaceBack(L+_,-1,L,.8),i.colorArray.emplaceBack(-L,0,L,1.3),i.colorArray.emplaceBack(L,0,L,1.3),i.colorArray.emplaceBack(L+_,-.8,L,.7),i.colorArray.emplaceBack(L+_,-.8,L,.7),i.colorArray.emplaceBack(0,0,L,1.3),i.colorArray.emplaceBack(0,0,L,1.3),i.colorArray.emplaceBack(L+_,-1.2,L,.8),i.colorArray.emplaceBack(L+_,-1.2,L,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const s={defined:!0,emissiveFactor:[0,0,0]},l={};return l.baseColorFactor=ji.white,s.pbrMetallicRoughness=l,i.material=s,i.aabb=new Ri([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}Ke(uy,"TriangleGridIndex");class fy{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const n=e[i];this._stringToNumber[n]=i,this._numberToString[i]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const J1=["tile","layer","source","sourceLayer","state"];class my{constructor(e,i,n,s,l){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=n,this._y=s,this.properties=e.properties,this.id=l}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const i of J1)void 0!==this[i]&&(e[i]=this[i]);return e}}class _y{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Dn(qe,16,0),this.featureIndexArray=new Fu,this.promoteId=i,this.is3DTile=!1}insert(e,i,n,s,l,u=0,p=0){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,l,u);const _=this.grid;for(let y=0;y<i.length;y++){const v=i[y],w=[1/0,1/0,-1/0,-1/0];for(let E=0;E<v.length;E++){const A=v[E];w[0]=Math.min(w[0],A.x),w[1]=Math.min(w[1],A.y),w[2]=Math.max(w[2],A.x),w[3]=Math.max(w[3],A.y)}0!==p&&(w[0]-=p,w[1]-=p,w[2]+=p,w[3]+=p),w[0]<qe&&w[1]<qe&&w[2]>=0&&w[3]>=0&&_.insert(m,w[0],w[1],w[2],w[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Hp(new kl(this.rawTileData)).layers,this.sourceLayerCoder=new fy(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i,n,s){this.loadVTLayers();const l=e.params||{},u=Vr(l.filter),p=e.tileResult,m=e.transform,_=p.bufferedTilespaceBounds,y=this.grid.query(_.min.x,_.min.y,_.max.x,_.max.y,(A,I,z,L)=>Bf(p.bufferedTilespaceGeometry,A,I,z,L));y.sort(Q1);let v=null;m.elevation&&y.length>0&&(v=Pl.create(m.elevation,this.tileID));const w={};let E;for(let A=0;A<y.length;A++){const I=y[A];if(I===E)continue;E=I;const z=this.featureIndexArray.get(I);let L=null;if(this.is3DTile){const N=this.bucketLayerIDs[0][0],G=i[N];if("model"!==G.type)continue;const{queryFeature:j,intersectionZ:X}=G.queryIntersectsMatchingFeature(p,z.featureIndex,u,m);j&&this.appendToResult(w,N,z.featureIndex,j,X)}else this.loadMatchingFeature(w,z,u,l.layers,l.availableImages,i,n,s,(N,G,j,X=0)=>(L||(L=er(N,this.tileID.canonical,e.tileTransform)),G.queryIntersectsFeature(p,N,j,L,this.z,e.transform,e.pixelPosMatrix,v,X)))}return w}loadMatchingFeature(e,i,n,s,l,u,p,m,_){const{featureIndex:y,bucketIndex:v,sourceLayerIndex:w,layoutVertexArrayOffset:E}=i,A=this.bucketLayerIDs[v];if(s&&!function(N,G){for(let j=0;j<N.length;j++)if(G.indexOf(N[j])>=0)return!0;return!1}(s,A))return;const I=this.sourceLayerCoder.decode(w),z=this.vtLayers[I].feature(y);if(n.needGeometry){const N=Hi(z,!0);if(!n.filter(new Ai(this.tileID.overscaledZ),N,this.tileID.canonical))return}else if(!n.filter(new Ai(this.tileID.overscaledZ),z))return;const L=this.getId(z,I);for(let N=0;N<A.length;N++){const G=A[N];if(s&&s.indexOf(G)<0)continue;const j=u[G];if(!j)continue;let X={};void 0!==L&&m&&(X=m.getState(j.sourceLayer||"_geojsonTileLayer",L));const W=!_||_(z,j,X,E);if(!W)continue;const J=new my(z,this.z,this.x,this.y,L),ie=pr({},p[G]);ie.paint=gy(ie.paint,j.paint,z,X,l),ie.layout=gy(ie.layout,j.layout,z,X,l),J.layer=ie,this.appendToResult(e,G,y,J,W)}}appendToResult(e,i,n,s,l){let u=e[i];void 0===u&&(u=e[i]=[]),u.push({featureIndex:n,feature:s,intersectionZ:l})}lookupSymbolFeatures(e,i,n,s,l,u,p,m){const _={};this.loadVTLayers();const y=Vr(l);for(const v of e)this.loadMatchingFeature(_,{bucketIndex:n,sourceLayerIndex:s,featureIndex:v,layoutVertexArrayOffset:0},y,u,p,m,i);return _}loadFeature(e){const{featureIndex:i,sourceLayerIndex:n}=e;this.loadVTLayers();const s=this.sourceLayerCoder.decode(n),l=this.vtFeatures[s];if(l[i])return l[i];const u=this.vtLayers[s].feature(i);return l[i]=u,u}hasLayer(e){for(const i of this.bucketLayerIDs)for(const n of i)if(e===n)return!0;return!1}getId(e,i){let n=e.id;if(this.promoteId){const s="string"==typeof this.promoteId?this.promoteId:this.promoteId[i];null!=s&&(n=e.properties[s]),"boolean"==typeof n&&(n=Number(n))}return n}}function gy(t,e,i,n,s){return fr(t,(l,u)=>{const p=e instanceof da?e.get(u):null;return p&&p.evaluate?p.evaluate(i,n,s):p})}function Q1(t,e){return e-t}Ke(_y,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Mf=new Float32Array(262144),Fa=new Uint8Array(262144);function yy(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,yy(i));return e}function xy(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)xy(n,e,i)}const vy=["","wall","door","roof","window","lamp","logo"];class by{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:yy(e)}}}getLocalBounds(){if(!this.node.meshes)return new Ri([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const i=new Ri([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const n of this.node.meshes)this.node.lightMeshIndex!==e&&i.encapsulate(n.aabb),e++;this.aabb=i}return this.aabb}}class Vd{constructor(e,i,n,s,l,u){this.id=i,this.modelTraits|=Vl.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Vl.HasMapboxMeshFeatures),s&&(this.modelTraits|=Vl.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=l,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const p of e)this.nodesInfo.push(new by(p)),xy(p,u.featureIndexArray.length,u.grid),u.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,u.bucketLayerIDs.length-1,0)}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const i=this.getNodesInfo();for(const n of i){const s=n.node;this.uploaded?this.updatePbrBuffer(s):_f(s,e,!0)}for(const n of i)kd(n.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let i=!1;if(!e.meshes)return i;for(const n of e.meshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),i=!0);return i}needsReEvaluation(e,i,n){const s=e.transform.projectionOptions,l=e.style.getBrightness(),u=this.brightness!==l;return!!(!this.uploaded||this.dirty||s.name!==this.projection.name||qh(n.paint.get("model-color").value,u)||qh(n.paint.get("model-color-mix-intensity").value,u)||qh(n.paint.get("model-roughness").value,u)||qh(n.paint.get("model-emissive-strength").value,u)||qh(n.paint.get("model-height-based-emissive-strength-multiplier").value,u))&&(this.projection=s,this.brightness=l,!0)}evaluateScale(e,i){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const n=this.getNodesInfo(),s=this.id.canonical;for(const l of n){const u=l.feature;l.evaluatedScale=i.paint.get("model-scale").evaluate(u,{},s)}}evaluate(e){const i=this.getNodesInfo();for(const n of i){if(!n.node.meshes)continue;const s=n.feature,l=n.node.meshes&&n.node.meshes[0].featureData,u=n.evaluatedColor[2],p=n.evaluatedRMEA[2],m=this.id.canonical;if(n.hasTranslucentParts=!1,l){for(let _=0;_<vy.length;_++){const y=vy[_];y.length&&(s.properties.part=y);const v=e.paint.get("model-color").evaluate(s,{},m),w=e.paint.get("model-color-mix-intensity").evaluate(s,{},m);n.evaluatedColor[_]=[v.r,v.g,v.b,w],n.evaluatedRMEA[_][0]=e.paint.get("model-roughness").evaluate(s,{},m),n.evaluatedRMEA[_][2]=e.paint.get("model-emissive-strength").evaluate(s,{},m),n.evaluatedRMEA[_][3]=v.a,n.emissionHeightBasedParams[_]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(s,{},m),!n.hasTranslucentParts&&v.a<1&&(n.hasTranslucentParts=!0)}delete s.properties.part,tv(n,u!==n.evaluatedColor[2]||p!==n.evaluatedRMEA[2],this.modelTraits)}else n.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(s,{},m);n.evaluatedScale=e.paint.get("model-scale").evaluate(s,{},m),this.updatePbrBuffer(n.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,i,n,s){const l=e.findDEMTileFor(n);if(l&&(l.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if(l.dem&&l.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=l.tileID.overscaledZ;const u=Pl.create(e,n,l);if(!u)return;this.modelTraits&Vl.HasMapboxMeshFeatures&&this.updateDEM(e,u,n,s);for(const p of this.getNodesInfo()){const m=p.node;if(!m.footprint||!m.footprint.vertices||!m.footprint.vertices.length)continue;const _=m.footprint.vertices;let y=u.getElevationAt(_[0].x,_[0].y,!0,!0);for(let v=1;v<_.length;v++)y=Math.min(y,u.getElevationAt(_[v].x,_[v].y,!0,!0));m.elevation=y}}this.terrainTile=l.tileID.canonical,this.terrainExaggeration=i}}updateDEM(e,i,n,s){let l=i._dem._modifiedForSources[s];if(void 0===l&&(i._dem._modifiedForSources[s]=[],l=i._dem._modifiedForSources[s]),l.includes(n.canonical))return;const u=i._dem.dim;l.push(n.canonical);let p=!1;for(const m of this.getNodesInfo()){const _=m.node;if(!_.footprint||!_.footprint.grid)continue;const y=_.footprint.grid,v=i.tileCoordToPixel(y.min.x,y.min.y),w=i.tileCoordToPixel(y.max.x,y.max.y),E=Math.min(Math.min(u-w.y,v.x),Math.min(v.y,u-w.x));if(E<0)continue;const A=Dt(E,2,5);let I=Math.max(0,v.x-A),z=Math.max(0,v.y-A),L=Math.min(w.x+A,u-1),N=Math.min(w.y+A,u-1);for(let W=z;W<=N;++W)for(let J=I;J<=L;++J)Fa[W*u+J]=255;let G=0,j=0;for(let W=0;W<y.cellsY;++W)for(let J=0;J<y.cellsX;++J){if(!y.cells[W*y.cellsX+J])continue;const ie=i.tileCoordToPixel(y.min.x+J/y.xScale,y.min.y+W/y.yScale),oe=i.tileCoordToPixel(y.min.x+(J+1)/y.xScale,y.min.y+(W+1)/y.yScale);for(let he=ie.y;he<=Math.min(oe.y+1,u-1);++he)for(let se=ie.x;se<=Math.min(oe.x+1,u-1);++se)255===Fa[he*u+se]&&(Fa[he*u+se]=0,G+=i.getElevationAtPixel(se,he),j++)}const X=G/j;I=Math.max(1,v.x-A),z=Math.max(1,v.y-A),L=Math.min(w.x+A,u-2),N=Math.min(w.y+A,u-2),p=!0;for(let W=z;W<=N;++W)for(let J=I;J<=L;++J)0===Fa[W*u+J]&&(Mf[W*u+J]=i._dem.set(J,W,X));for(let W=1;W<A;++W){I=Math.max(1,v.x-W),z=Math.max(1,v.y-W),L=Math.min(w.x+W,u-2),N=Math.min(w.y+W,u-2);for(let J=z;J<=N;++J)for(let ie=I;ie<=L;++ie){const oe=J*u+ie;if(255===Fa[oe]){let he=0,se=0,_e=-1,Me=-1;for(let fe=-1;fe<=1;++fe)for(let we=-1;we<=1;++we){const de=(J+fe)*u+ie+we;if(Fa[de]>=W)continue;const be=Mf[de],Fe=Math.abs(be);Fe>se&&(he=be,se=Fe,_e=we,Me=fe)}if(se>.1){const fe=1-(W+.5*Math.abs(_e*Me))/A;let we=i._dem.get(ie,J)+he*fe;const de=i._dem.get(ie+_e,J+Me),be=i._dem.get(ie-_e,J-Me,!0);(we-de)*(we-be)>0&&(we=(de+be)/2),Mf[oe]=i._dem.set(ie,J,we),Fa[oe]=W}}}}}p&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=ze.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const i of e)kd(i.node),gf(i.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;const n=i.getReplacementRegionsForTile(e.toUnwrapped()),s=this.getNodesInfo();for(let l=0;l<this.nodesInfo.length;l++){const u=s[l].node;s[l].hiddenByReplacement=!!u.footprint&&!n.find(p=>p.footprint===u.footprint)}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),s=[];for(let l=0;l<this.nodesInfo.length;l++){const u=n[l],p=u.node.meshes[0];if(e<p.aabb.min[0]||i<p.aabb.min[1]||e>p.aabb.max[0]||i>p.aabb.max[1])continue;const m=(e-p.aabb.min[0])/(p.aabb.max[0]-p.aabb.min[0])*64|0,_=64*Math.min(63,(i-p.aabb.min[1])/(p.aabb.max[1]-p.aabb.min[1])*64|0)+Math.min(63,m);if(!(p.heightmap[_]<0&&u.node.footprint))return u.hiddenByReplacement?void 0:{height:p.heightmap[_],maxHeight:u.feature.properties.height,hidden:!1,verticalScale:u.evaluatedScale[2]};if(u.node.footprint.grid.query(new Ue(e,i),new Ue(e,i),s),s.length>0)return{height:void 0,maxHeight:u.feature.properties.height,hidden:u.hiddenByReplacement,verticalScale:u.evaluatedScale[2]}}}}function qh(t,e){return!t.isLightConstant&&e}function ev(t,e,i,n,s,l,u,p){let m=(61440&e|(61440&e)>>4)>>8,_=(3840&e|(3840&e)>>4)>>4,y=240&e|(240&e)>>4;i[3]>0&&(m=Ut(m,255*i[0],i[3]),_=Ut(_,255*i[1],i[3]),y=Ut(y,255*i[2],i[3]));const v=m<<8|_,w=y<<8|Math.floor(255*n[3]),E=function(W){const J=Dt(W,0,2);return Math.min(Math.round(.5*J*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],A=Dt(s[0],0,1),I=Dt(s[1],0,1),z=Dt(s[2],0,1),L=Dt(s[3],0,1);let N,G,j,X;if(A!==I&&u!==l&&I!==A){const W=u-l;G=1/(W*(I-A)),j=-(l+W*A)/(W*(I-A));const J=Dt(s[4],-1,1);X=Math.pow(10,J),N=255*z<<8|255*L}else N=65535,G=0,j=1,X=1;if(t.emplaceBack(v,w,E,N,G,j,X),p){const W=p.length;p.clear();for(let J=0;J<W;J++)p.emplaceBack(v,w,E,N,G,j,X)}}function tv(t,e,i){const n=t.node;let s=0;const l=i&Vl.HasMeshoptCompression;for(const u of n.meshes){if(n.lights&&n.lightMeshIndex===s||!u.featureData)continue;u.featureArray=new Ea,u.featureArray.reserve(u.featureData.length);let p=e;for(const m of u.featureData){const _=l?65535&m:m>>16&65535,y=l?m>>16&65535:65535&m,v=(15&y)<8?15&y:0,w=t.evaluatedRMEA[v],E=t.evaluatedColor[v],A=t.emissionHeightBasedParams[v];let I;if(p&&2===v&&n.lights&&(I=new Ea,I.resize(10*n.lights.length)),ev(u.featureArray,_,E,w,A,u.aabb.min[2],u.aabb.max[2],I),I&&p){p=!1;const z=n.meshes[n.lightMeshIndex];z.featureArray=I,z.featureArray._trim()}}u.featureArray._trim(),s++}}function wy(t,e,i,n){const s=1<<t.z;e.lat=Zt((n/qe+t.y)/s),e.lng=vt((i/qe+t.x)/s)}Ke(Vd,"Tiled3dModelBucket",{omit:["layers"]}),Ke(by,"Tiled3dModelFeature");const iv={circle:class extends Cr{constructor(t,e,i){super(t,Hy,e,i)}createBucket(t){return new Dr(t)}queryRadius(t){const e=t;return Al("circle-radius",this,e)+Al("circle-stroke-width",this,e)+Wu(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,n,s,l,u,p){const m=Nf(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),_=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return d_(t,n,l,u,p,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),m,_)}getProgramIds(){return["circle"]}getDefaultProgramParams(t,e){const i=u_(this);return{config:new P(this,e),defines:i,overrideFog:!1}}},heatmap:class extends Cr{createBucket(t){return new f_(t)}constructor(t,e,i){super(t,E0,e,i),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Mh({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 Al("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,n,s,l,u,p){const m=this.paint.get("heatmap-radius").evaluate(e,i);return d_(t,n,l,u,p,!0,!0,new Ue(0,0),m)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(t,e){return"heatmap"===t?{config:new P(this,e),overrideFog:!1}:{}}},hillshade:class extends Cr{constructor(t,e,i){super(t,A0,e,i)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},fill:class extends Cr{constructor(t,e,i){super(t,U0,e,i)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(t,e){return{config:new P(this,e),overrideFog:!1}}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Wp(t)}queryRadius(){return Wu(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,n,s,l){return!t.queryGeometry.isAboveHorizon&&Go(Ff(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 Cr{constructor(t,e,i){super(t,mx,e,i),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new pd(t)}queryRadius(){return Wu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}hasShadowPass(){return!0}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(t,e,i,n,s,l,u,p,m){const _=Nf(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),y=this.paint.get("fill-extrusion-height").evaluate(e,i),v=this.paint.get("fill-extrusion-base").evaluate(e,i),w=[0,0],E=p&&l.elevation,A=l.elevation?l.elevation.exaggeration():1,I=t.tile.getBucket(this);if(E&&I instanceof pd){const j=I.centroidVertexArray,X=m+1;X<j.length&&(w[0]=j.geta_centroid_pos0(X),w[1]=j.geta_centroid_pos1(X))}if(0===w[0]&&1===w[1])return!1;"globe"===l.projection.name&&(n=X_([n],[new Ue(0,0),new Ue(qe,qe)],t.tileID.canonical).map(j=>j.polygon).flat());const z=E?p:null,[L,N]=(X=n,W=v,J=y,ie=_,oe=u,he=z,se=w,_e=A,Me=l.center.lat,"globe"===(j=l).projection.name?function(we,de,be,Fe,Se,Qe,He,Ce,ft,st,Je){const Pe=[],ut=[],It=we.projection.upVectorScale(Je,we.center.lat,we.worldSize).metersToTile,mt=[0,0,0,1],Ct=[0,0,0,1],xt=(wt,mi,Jt,ei)=>{wt[0]=mi,wt[1]=Jt,wt[2]=ei,wt[3]=1},jt=H_();be>0&&(be+=jt),Fe+=jt;for(const wt of de){const mi=[],Jt=[];for(const ei of wt){const si=ei.x+Se.x,Qt=ei.y+Se.y,Si=we.projection.projectTilePoint(si,Qt,Je),hi=we.projection.upVector(Je,ei.x,ei.y);let Bi=be,Yi=Fe;if(He){const ur=K_(si,Qt,be,Fe,He,Ce,ft,st);Bi+=ur.base,Yi+=ur.top}0!==be?xt(mt,Si.x+hi[0]*It*Bi,Si.y+hi[1]*It*Bi,Si.z+hi[2]*It*Bi):xt(mt,Si.x,Si.y,Si.z),xt(Ct,Si.x+hi[0]*It*Yi,Si.y+hi[1]*It*Yi,Si.z+hi[2]*It*Yi),a.N.transformMat4(mt,mt,Qe),a.N.transformMat4(Ct,Ct,Qe),mi.push(new zl(mt[0],mt[1],mt[2])),Jt.push(new zl(Ct[0],Ct[1],Ct[2]))}Pe.push(mi),ut.push(Jt)}return[Pe,ut]}(j,X,W,J,ie,oe,he,se,_e,Me,t.tileID.canonical):he?function(we,de,be,Fe,Se,Qe,He,Ce,ft){const st=[],Je=[],Pe=[0,0,0,1];for(const ut of we){const It=[],mt=[];for(const Ct of ut){const xt=Ct.x+Fe.x,jt=Ct.y+Fe.y,wt=K_(xt,jt,de,be,Qe,He,Ce,ft);Pe[0]=xt,Pe[1]=jt,Pe[2]=wt.base,Pe[3]=1,a.a7.transformMat4(Pe,Pe,Se),Pe[3]=Math.max(Pe[3],1e-5);const mi=new zl(Pe[0]/Pe[3],Pe[1]/Pe[3],Pe[2]/Pe[3]);Pe[0]=xt,Pe[1]=jt,Pe[2]=wt.top,Pe[3]=1,a.a7.transformMat4(Pe,Pe,Se),Pe[3]=Math.max(Pe[3],1e-5);const Jt=new zl(Pe[0]/Pe[3],Pe[1]/Pe[3],Pe[2]/Pe[3]);It.push(mi),mt.push(Jt)}st.push(It),Je.push(mt)}return[st,Je]}(X,W,J,ie,oe,he,se,_e,Me):function(we,de,be,Fe,Se){const Qe=[],He=[],Ce=Se[8]*de,ft=Se[9]*de,st=Se[10]*de,Je=Se[11]*de,Pe=Se[8]*be,ut=Se[9]*be,It=Se[10]*be,mt=Se[11]*be;for(const Ct of we){const xt=[],jt=[];for(const wt of Ct){const mi=wt.x+Fe.x,Jt=wt.y+Fe.y,ei=Se[0]*mi+Se[4]*Jt+Se[12],si=Se[1]*mi+Se[5]*Jt+Se[13],Qt=Se[2]*mi+Se[6]*Jt+Se[14],Si=Se[3]*mi+Se[7]*Jt+Se[15],hi=ei+Ce,Bi=si+ft,Yi=Qt+st,ur=Math.max(Si+Je,1e-5),Ti=ei+Pe,zi=si+ut,rr=Qt+It,nr=Math.max(Si+mt,1e-5);xt.push(new zl(hi/ur,Bi/ur,Yi/ur)),jt.push(new zl(Ti/nr,zi/nr,rr/nr))}Qe.push(xt),He.push(jt)}return[Qe,He]}(X,W,J,ie,oe)),G=t.queryGeometry;var j,X,W,J,ie,oe,he,se,_e,Me;return function(j,X,W){let J=1/0;Go(W,X)&&(J=Y_(W,X[0]));for(let ie=0;ie<X.length;ie++){const oe=X[ie],he=j[ie];for(let se=0;se<oe.length-1;se++){const _e=oe[se],Me=[_e,oe[se+1],he[se+1],he[se],_e];wn(W,Me)&&(J=Math.min(J,Y_(W,Me)))}}return J!==1/0&&J}(L,N,G.isPointQuery()?G.screenBounds:G.screenGeometry)}},line:class extends Cr{constructor(t,e,i){super(t,Q_,e,i),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof ra,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=og.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Yp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e){const i=rg(this);return{config:new P(this,e),defines:i,overrideFog:!1}}queryRadius(t){const e=t,i=sg(Al("line-width",this,e),Al("line-gap-width",this,e)),n=Al("line-offset",this,e);return i/2+Math.abs(n)+Wu(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,s,l){if(t.queryGeometry.isAboveHorizon)return!1;const u=Ff(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),l.angle,t.pixelToTileUnitsFactor),p=t.pixelToTileUnitsFactor/2*sg(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),m=this.paint.get("line-offset").evaluate(e,i);return m&&(n=function(_,y){const v=[],w=new Ue(0,0);for(let E=0;E<_.length;E++){const A=_[E],I=[];for(let z=0;z<A.length;z++){const L=A[z],N=A[z+1],G=0===z?w:L.sub(A[z-1])._unit()._perp(),j=z===A.length-1?w:N.sub(L)._unit()._perp(),X=G._add(j)._unit();X._mult(1/(X.x*j.x+X.y*j.y)),I.push(X._mult(y)._add(L))}v.push(I)}return v}(n,m*t.pixelToTileUnitsFactor)),function(_,y,v){for(let w=0;w<y.length;w++){const E=y[w];if(_.length>=3)for(let A=0;A<E.length;A++)if(On(_,E[A]))return!0;if(Pa(_,E,v))return!0}return!1}(u,n,p)}isTileClipped(){return!0}},symbol:Cd,background:class extends Cr{constructor(t,e,i){super(t,y1,e,i)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},raster:qg,"raster-particle":$g,sky:class extends Cr{constructor(t,e,i){super(t,S1,e,i),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Mh({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")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const n=this.paint.get("sky-atmosphere-sun"),s=!n,l=t.style.light,u=l.properties.get("position");return s&&"viewport"===l.properties.get("anchor")&&ki("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?pf(u.azimuthal,90-u.polar,e):pf(n[0],90-n[1],e)}const i=this.paint.get("sky-gradient-center");return pf(i[0],90-i[1],e)}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}},slot:class extends Cr{constructor(t,e,i){super(t,A1,e)}},model:class extends Cr{constructor(t,e,i){super(t,O1,e,i),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new mf(t)}getProgramIds(){return["model"]}is3D(){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(t){return t instanceof Vd?8191:0}queryIntersectsFeature(t,e,i,n,s,l){if(!this.modelManager)return!1;const u=this.modelManager,p=t.tile.getBucket(this);if(!(p&&p instanceof mf))return!1;const m=p;for(const _ in m.instancesPerModel){const y=m.instancesPerModel[_];if(y.idToFeaturesIndex.hasOwnProperty(e.id)){const v=y.features[y.idToFeaturesIndex[e.id]],w=u.getModel(_,this.scope);if(!w)return!1;let E=a.a6.create();const A=new ne(0,0),I=m.canonical;let z=Number.MAX_VALUE;for(let L=0;L<v.instancedDataCount;++L){const N=16*(v.instancedDataOffset+L),G=y.instancedDataArray.float32,j=[G[N+4],G[N+5],G[N+6]];wy(I,A,G[N],0|G[N+1]),ty(E,w,l,A,v.rotation,v.scale,j,!1,!1,!1),"globe"===l.projection.name&&(E=ff(E,l));const X=a.a6.multiply([],l.projMatrix,E),W=t.queryGeometry,J=Jg(W.isPointQuery()?W.screenBounds:W.screenGeometry,l,X,w.aabb);null!=J&&(z=Math.min(J,z))}return z!==Number.MAX_VALUE&&z}}return!1}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven()||"model-color"!==t&&"model-color-mix-intensity"!==t&&"model-rotation"!==t&&"model-scale"!==t&&"model-translation"!==t&&"model-emissive-strength"!==t)}_isPropertyZoomDependent(t){const e=this._transitionablePaint._values[t];return null!=e&&null!=e.value&&null!=e.value.expression&&e.value.expression instanceof la}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}queryIntersectsMatchingFeature(t,e,i,n){const s=t.tile,l=s.getBucket(this);let u=null,p=Number.MAX_VALUE;if(!(l&&l instanceof Vd))return{queryFeature:u,intersectionZ:p};const m=l.getNodesInfo()[e];if(m.hiddenByReplacement||!m.node.meshes||!i.filter(new Ai(s.tileID.overscaledZ),m.feature,s.tileID.canonical))return{queryFeature:u,intersectionZ:p};const _=m.node,y=n.calculatePosMatrix(s.tileID.toUnwrapped(),n.worldSize),v=m.evaluatedScale;let w=0;n.elevation&&_.elevation&&(w=_.elevation*n.elevation.exaggeration()),a.a6.translate(y,y,[(_.anchor?_.anchor[0]:0)*(v[0]-1),(_.anchor?_.anchor[1]:0)*(v[1]-1),w]),a.a6.scale(y,y,v),a.a6.multiply(y,y,_.matrix);const E=t.queryGeometry,A=E.isPointQuery()?E.screenBounds:E.screenGeometry,I=function(L){const N=a.a6.multiply([],y,L.matrix),G=a.a6.multiply(N,n.expandedFarZProjMatrix,N);for(let j=0;j<L.meshes.length;++j){const X=L.meshes[j];if(j===L.lightMeshIndex)continue;const W=Jg(A,n,G,X.aabb);null!=W&&(p=Math.min(W,p))}if(L.children)for(const j of L.children)I(j)};if(I(_),p===Number.MAX_VALUE)return{queryFeature:u,intersectionZ:p};const z=new ne(0,0);return wy(s.tileID.canonical,z,m.node.anchor[0],m.node.anchor[1]),u={type:"Feature",geometry:{type:"Point",coordinates:[z.lng,z.lat]},properties:m.feature.properties,id:m.feature.id,state:{},layer:this.serialize()},{queryFeature:u,intersectionZ:p}}}},Mt={read:function(t,e){return t.readFields(Mt._readField,{header_length:0,x:0,y:0,z:0,layers:[]},e)},_readField:function(t,e,i){1===t?e.header_length=i.readFixed32():2===t?e.x=i.readVarint():3===t?e.y=i.readVarint():4===t?e.z=i.readVarint():5===t&&e.layers.push(Mt.Layer.read(i,i.readVarint()+i.pos))},PixelFormat:{PIXEL_FORMAT_UNKNOWN:{value:0,options:{}},PIXEL_FORMAT_UINT32:{value:1,options:{}},PIXEL_FORMAT_UINT16:{value:2,options:{}},PIXEL_FORMAT_UINT8:{value:3,options:{}}},Filter:{}};Mt.Filter.read=function(t,e){return t.readFields(Mt.Filter._readField,{delta_filter:null,filter:null,zigzag_filter:null,bitshuffle_filter:null,byteshuffle_filter:null},e)},Mt.Filter._readField=function(t,e,i){1===t?(e.delta_filter=Mt.Filter.Delta.read(i,i.readVarint()+i.pos),e.filter="delta_filter"):2===t?(e.zigzag_filter=Mt.Filter.Zigzag.read(i,i.readVarint()+i.pos),e.filter="zigzag_filter"):3===t?(e.bitshuffle_filter=Mt.Filter.BitShuffle.read(i,i.readVarint()+i.pos),e.filter="bitshuffle_filter"):4===t&&(e.byteshuffle_filter=Mt.Filter.ByteShuffle.read(i,i.readVarint()+i.pos),e.filter="byteshuffle_filter")},Mt.Filter.Delta={},Mt.Filter.Delta.read=function(t,e){return t.readFields(Mt.Filter.Delta._readField,{block_size:0},e)},Mt.Filter.Delta._readField=function(t,e,i){1===t&&(e.block_size=i.readVarint())},Mt.Filter.Zigzag={},Mt.Filter.Zigzag.read=function(t,e){return t.readFields(Mt.Filter.Zigzag._readField,{},e)},Mt.Filter.Zigzag._readField=function(t,e,i){},Mt.Filter.BitShuffle={},Mt.Filter.BitShuffle.read=function(t,e){return t.readFields(Mt.Filter.BitShuffle._readField,{},e)},Mt.Filter.BitShuffle._readField=function(t,e,i){},Mt.Filter.ByteShuffle={},Mt.Filter.ByteShuffle.read=function(t,e){return t.readFields(Mt.Filter.ByteShuffle._readField,{},e)},Mt.Filter.ByteShuffle._readField=function(t,e,i){},Mt.Codec={},Mt.Codec.read=function(t,e){return t.readFields(Mt.Codec._readField,{gzip_data:null,codec:null,jpeg_image:null,webp_image:null,png_image:null},e)},Mt.Codec._readField=function(t,e,i){1===t?(e.gzip_data=Mt.Codec.GzipData.read(i,i.readVarint()+i.pos),e.codec="gzip_data"):2===t?(e.jpeg_image=Mt.Codec.JpegImage.read(i,i.readVarint()+i.pos),e.codec="jpeg_image"):3===t?(e.webp_image=Mt.Codec.WebpImage.read(i,i.readVarint()+i.pos),e.codec="webp_image"):4===t&&(e.png_image=Mt.Codec.PngImage.read(i,i.readVarint()+i.pos),e.codec="png_image")},Mt.Codec.GzipData={},Mt.Codec.GzipData.read=function(t,e){return t.readFields(Mt.Codec.GzipData._readField,{},e)},Mt.Codec.GzipData._readField=function(t,e,i){},Mt.Codec.JpegImage={},Mt.Codec.JpegImage.read=function(t,e){return t.readFields(Mt.Codec.JpegImage._readField,{},e)},Mt.Codec.JpegImage._readField=function(t,e,i){},Mt.Codec.WebpImage={},Mt.Codec.WebpImage.read=function(t,e){return t.readFields(Mt.Codec.WebpImage._readField,{},e)},Mt.Codec.WebpImage._readField=function(t,e,i){},Mt.Codec.PngImage={},Mt.Codec.PngImage.read=function(t,e){return t.readFields(Mt.Codec.PngImage._readField,{},e)},Mt.Codec.PngImage._readField=function(t,e,i){},Mt.DataIndexEntry={},Mt.DataIndexEntry.read=function(t,e){return t.readFields(Mt.DataIndexEntry._readField,{first_byte:0,last_byte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},e)},Mt.DataIndexEntry._readField=function(t,e,i){1===t?e.first_byte=i.readFixed64():2===t?e.last_byte=i.readFixed64():3===t?e.filters.push(Mt.Filter.read(i,i.readVarint()+i.pos)):4===t?e.codec=Mt.Codec.read(i,i.readVarint()+i.pos):5===t?e.offset=i.readFloat():6===t?e.scale=i.readFloat():7===t&&e.bands.push(i.readString())},Mt.Layer={},Mt.Layer.read=function(t,e){return t.readFields(Mt.Layer._readField,{version:0,name:"",units:"",tilesize:0,buffer:0,pixel_format:0,data_index:[]},e)},Mt.Layer._readField=function(t,e,i){1===t?e.version=i.readVarint():2===t?e.name=i.readString():3===t?e.units=i.readString():4===t?e.tilesize=i.readVarint():5===t?e.buffer=i.readVarint():6===t?e.pixel_format=i.readVarint():7===t&&e.data_index.push(Mt.DataIndexEntry.read(i,i.readVarint()+i.pos))};const jn={read:function(t,e){return t.readFields(jn._readField,{uint32_values:null,values:null,fixed32_values:null},e)},_readField:function(t,e,i){2===t?(e.uint32_values=jn.Uint32Values.read(i,i.readVarint()+i.pos),e.values="uint32_values"):3===t&&(e.fixed32_values=jn.Fixed32Values.read(i,i.readVarint()+i.pos),e.values="fixed32_values")},Uint32Values:{}};jn.Uint32Values.read=function(t,e){return t.readFields(jn.Uint32Values._readField,{values:[]},e)},jn.Uint32Values._readField=function(t,e,i){1===t&&(e.readValuesInto=function(n){if(2!==n.type)throw new Error(`Unsupported pbf type "${n.type}"`);const s=2===(u=n).type?u.readVarint()+u.pos:u.pos+1,l=n.pos;var u;return n.pos=s,function(u){n.pos=l;let p=0;for(;n.pos<s;){const m=n.readVarint();u[p++]=m}return u}}(i))},jn.Fixed32Values={},jn.Fixed32Values.read=function(t,e){return t.readFields(jn.Fixed32Values._readField,{values:[]},e)},jn.Fixed32Values._readField=function(t,e,i){throw new Error("Not implemented")};class rv{constructor(e=0,i=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=i}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const i=this.items[e];delete this.items[e],this.size--,null!==i.prev&&(i.prev.next=i.next),null!==i.next&&(i.next.prev=i.prev),this.first===i&&(this.first=i.next),this.last===i&&(this.last=i.prev)}return this}entries(e=this.keys()){return e.map(i=>[i,this.get(i)])}evict(e=!1){if(e||this.size>0){const i=this.first;delete this.items[i.key],0==--this.size?(this.first=null,this.last=null):(this.first=i.next,this.first.prev=null)}return this}expiresAt(e){let i;return this.has(e)&&(i=this.items[e].expiry),i}get(e){let i;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(i=n.value,this.set(e,i,!0))}return i}has(e){return e in this.items}keys(){const e=[];let i=this.first;for(;null!==i;)e.push(i.key),i=i.next;return e}set(e,i,n=!1,s=this.resetTtl){let l;if(n||this.has(e)){if(l=this.items[e],l.value=i,!1===n&&s&&(l.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==l){const u=this.last,p=l.next,m=l.prev;this.first===l&&(this.first=l.next),l.next=null,l.prev=this.last,u.next=l,null!==m&&(m.next=p),null!==p&&(p.prev=m)}}else this.max>0&&this.size===this.max&&this.evict(!0),l=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:i},1==++this.size?this.first=l:this.last.next=l;return this.last=l,this}values(e=this.keys()){return e.map(i=>this.get(i))}}function nv(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const s=1===n?1:0,l=2===n?1:0;for(let u=0;u<e[0];u++){const p=e[1]*u;for(let m=s;m<e[1];m++){const _=e[2]*(m+p);for(let y=l;y<e[2];y++){const v=e[3]*(y+_);for(let w=0;w<e[3];w++){const E=v+w;t[E]+=t[E-i]}}}}i*=e[n]}return t}function ov(t){for(let e=0,i=t.length;e<i;e++)t[e]=t[e]>>>1^-(1&t[e]);return t}function sv(t,e){switch(e){case"uint32":return t;case"uint16":for(let i=0;i<t.length;i+=2){const n=t[i],s=t[i+1];t[i]=(240&n)>>4|(61440&n)>>8|(240&s)<<4|61440&s,t[i+1]=15&n|(3840&n)>>4|(15&s)<<8|(3840&s)<<4}return t;case"uint8":for(let i=0;i<t.length;i+=4){const n=t[i],s=t[i+1],l=t[i+2],u=t[i+3];t[i+0]=(192&n)>>6|(192&s)>>4|(192&l)>>2|192&u,t[i+1]=(48&n)>>4|(48&s)>>2|48&l|(48&u)<<2,t[i+2]=(12&n)>>2|12&s|(12&l)<<2|(12&u)<<4,t[i+3]=3&n|(3&s)<<2|(3&l)<<4|(3&u)<<6}return t;default:throw new Error(`Invalid pixel format, "${e}"`)}}class Fs extends Error{constructor(e){super(e),this.name="MRTError"}}var fn=Uint8Array,Gl=Uint16Array,av=Int32Array,Ty=new fn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),My=new fn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),lv=new fn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ey=function(t,e){for(var i=new Gl(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];var s=new av(i[30]);for(n=1;n<30;++n)for(var l=i[n];l<i[n+1];++l)s[l]=l-i[n]<<5|n;return{b:i,r:s}},Sy=Ey(Ty,2),Ay=Sy.b,cv=Sy.r;Ay[28]=258,cv[258]=28;for(var hv=Ey(My,0).b,Ef=new Gl(32768),Gi=0;Gi<32768;++Gi){var Zl=(43690&Gi)>>1|(21845&Gi)<<1;Ef[Gi]=((65280&(Zl=(61680&(Zl=(52428&Zl)>>2|(13107&Zl)<<2))>>4|(3855&Zl)<<4))>>8|(255&Zl)<<8)>>1}var $h=function(t,e,i){for(var n=t.length,s=0,l=new Gl(e);s<n;++s)t[s]&&++l[t[s]-1];var u,p=new Gl(e);for(s=1;s<e;++s)p[s]=p[s-1]+l[s-1]<<1;if(i){u=new Gl(1<<e);var m=15-e;for(s=0;s<n;++s)if(t[s])for(var _=s<<4|t[s],y=e-t[s],v=p[t[s]-1]++<<y,w=v|(1<<y)-1;v<=w;++v)u[Ef[v]>>m]=_}else for(u=new Gl(n),s=0;s<n;++s)t[s]&&(u[s]=Ef[p[t[s]-1]++]>>15-t[s]);return u},Wh=new fn(288);for(Gi=0;Gi<144;++Gi)Wh[Gi]=8;for(Gi=144;Gi<256;++Gi)Wh[Gi]=9;for(Gi=256;Gi<280;++Gi)Wh[Gi]=7;for(Gi=280;Gi<288;++Gi)Wh[Gi]=8;var Iy=new fn(32);for(Gi=0;Gi<32;++Gi)Iy[Gi]=5;var uv=$h(Wh,9,1),dv=$h(Iy,5,1),Sf=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},Gn=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(7&e)&i},Af=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},pv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Zn=function(t,e,i){var n=new Error(e||pv[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,Zn),!i)throw n;return n},fv=new fn(0),mv=typeof TextDecoder<"u"&&new TextDecoder;try{mv.decode(fv,{stream:!0})}catch{}const _v={gzip_data:"gzip"},gv={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},yv={uint32:1,uint16:2,uint8:4},xv={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Cy{constructor(e=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const i=new Uint8Array(e),n=new DataView(e);if(13!==i[0])throw new Fs("File is not a valid MRT.");return n.getUint32(1,!0)}parseHeader(e){const i=new Uint8Array(e),n=this.getHeaderLength(e);if(i.length<n)throw new Fs(`Expected header with length >= ${n} but got buffer of length ${i.length}`);const s=new kl(i.subarray(0,n)),l=Mt.read(s);if(!isNaN(this.x)&&(this.x!==l.x||this.y!==l.y||this.z!==l.z))throw new Fs(`Invalid attempt to parse header ${l.z}/${l.x}/${l.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=l.x,this.y=l.y,this.z=l.z;for(const u of l.layers)this.layers[u.name]=new vv(u,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const i=[],n=this.getLayer(e.layerName);for(let s=0;s<n.dataIndex.length;s++){const l=n.dataIndex[s],u=l.first_byte-e.firstByte,p=l.last_byte+1-e.firstByte;if(s<e.firstBlock||s>e.lastBlock||n._blocksInProgress.has(s))continue;const m={layerName:n.name,firstByte:u,lastByte:p,pixelFormat:n.pixelFormat,blockIndex:s,blockShape:[l.bands.length].concat(n.bandShape),buffer:n.buffer,codec:l.codec.codec,filters:l.filters.map(_=>_.filter)};n._blocksInProgress.add(s),i.push(m)}return new Py(i,()=>{i.forEach(s=>n._blocksInProgress.delete(s.blockIndex))},(s,l)=>{if(i.forEach(u=>n._blocksInProgress.delete(u.blockIndex)),s)throw s;l.forEach(u=>{this.getLayer(u.layerName).processDecodedData(u)})})}}class vv{constructor({version:e,name:i,units:n,tilesize:s,pixel_format:l,buffer:u,data_index:p},m){if(this.version=e,1!==this.version)throw new Fs(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=n,this.tileSize=s,this.buffer=u,this.pixelFormat=gv[l],this.dataIndex=p,this.bandShape=[s+2*u,s+2*u,yv[this.pixelFormat]],this._decodedBlocks=function(_=1e3,y=0,v=!1){if(isNaN(_)||_<0)throw new TypeError("Invalid max value");if(isNaN(y)||y<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof v)throw new TypeError("Invalid resetTtl value");return new rv(_,y,v)}(m?m.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const i=e.blockIndex.toString();this._decodedBlocks.get(i)||this._decodedBlocks.set(i,e.data)}getBlockForBand(e){let i=0;switch(typeof e){case"string":for(const[n,s]of this.dataIndex.entries()){for(const[l,u]of s.bands.entries())if(u===e)return{bandIndex:i+l,blockIndex:n,blockBandIndex:l};i+=s.bands.length}break;case"number":for(const[n,s]of this.dataIndex.entries()){if(e>=i&&e<i+s.bands.length)return{bandIndex:e,blockIndex:n,blockBandIndex:e-i};i+=s.bands.length}break;default:throw new Fs(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}throw new Fs(`Band not found: ${JSON.stringify(e)}`)}getDataRange(e){let i=1/0,n=-1/0,s=1/0,l=-1/0;for(const u of e){const{blockIndex:p}=this.getBlockForBand(u);if(p<0)throw new Fs(`Invalid band: ${JSON.stringify(u)}`);const m=this.dataIndex[p];s=Math.min(s,p),l=Math.max(l,p),i=Math.min(i,m.first_byte),n=Math.max(n,m.last_byte)}return{layerName:this.name,firstByte:i,lastByte:n,firstBlock:s,lastBlock:l}}hasBand(e){const{blockIndex:i}=this.getBlockForBand(e);return i>=0}hasDataForBand(e){const{blockIndex:i}=this.getBlockForBand(e);return i>=0&&!!this._decodedBlocks.get(i.toString())}getBandView(e){const{blockIndex:i,blockBandIndex:n}=this.getBlockForBand(e),s=this._decodedBlocks.get(i.toString());if(!s)throw new Fs(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const l=this.dataIndex[i],u=this.bandShape.reduce((_,y)=>_*y,1),p=n*u,m=s.subarray(p,p+u);return{data:m,bytes:new Uint8Array(m.buffer).subarray(m.byteOffset,m.byteOffset+m.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:l.offset,scale:l.scale}}}class Py{constructor(e,i,n){this.tasks=e,this._onCancel=i,this._onComplete=n,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,i){this._finalized||(this._onComplete(e,i),this._finalized=!0)}}Cy.performDecoding=function(t,e){return Promise.all(e.tasks.map(i=>{const{layerName:n,firstByte:s,lastByte:l,pixelFormat:u,blockShape:p,blockIndex:m,filters:_,codec:y}=i,v=new Uint8Array(t).subarray(s,l+1),w=new Uint32Array(p[0]*p[1]*p[2]);let E;if("gzip_data"!==y)throw new Error(`Unhandled codec: ${y}`);return E=function(A,I){if(!globalThis.DecompressionStream&&"gzip_data"===I)return Promise.resolve(((G=function(W){31==W[0]&&139==W[1]&&8==W[2]||Zn(6,"invalid gzip data");var J=W[3],ie=10;4&J&&(ie+=2+(W[10]|W[11]<<8));for(var oe=(J>>3&1)+(J>>4&1);oe>0;oe-=!W[ie++]);return ie+(2&J)}(N=A))+8>N.length&&Zn(6,"invalid gzip data"),function(W,J,ie){var he=W.length;if(!he||J.f&&!J.l)return ie||new fn(0);var se=!ie,_e=se||2!=J.i,Me=J.i;se&&(ie=new fn(3*he));var Lr,Mr,mn,fe=function(Lr){var Mr=ie.length;if(Lr>Mr){var mn=new fn(Math.max(2*Mr,Lr));mn.set(ie),ie=mn}},we=J.f||0,de=J.p||0,be=J.b||0,Fe=J.l,Se=J.d,Qe=J.m,He=J.n,Ce=8*he;do{if(!Fe){we=Gn(W,de,1);var ft=Gn(W,de+1,3);if(de+=3,!ft){var st=W[(Jt=4+((de+7)/8|0))-4]|W[Jt-3]<<8,Je=Jt+st;if(Je>he){Me&&Zn(0);break}_e&&fe(be+st),ie.set(W.subarray(Jt,Je),be),J.b=be+=st,J.p=de=8*Je,J.f=we;continue}if(1==ft)Fe=uv,Se=dv,Qe=9,He=5;else if(2==ft){var Pe=Gn(W,de,31)+257,ut=Gn(W,de+10,15)+4,It=Pe+Gn(W,de+5,31)+1;de+=14;for(var mt=new fn(It),Ct=new fn(19),xt=0;xt<ut;++xt)Ct[lv[xt]]=Gn(W,de+3*xt,7);de+=3*ut;var jt=Sf(Ct),wt=(1<<jt)-1,mi=$h(Ct,jt,1);for(xt=0;xt<It;){var Jt,ei=mi[Gn(W,de,wt)];if(de+=15&ei,(Jt=ei>>4)<16)mt[xt++]=Jt;else{var si=0,Qt=0;for(16==Jt?(Qt=3+Gn(W,de,3),de+=2,si=mt[xt-1]):17==Jt?(Qt=3+Gn(W,de,7),de+=3):18==Jt&&(Qt=11+Gn(W,de,127),de+=7);Qt--;)mt[xt++]=si}}var Si=mt.subarray(0,Pe),hi=mt.subarray(Pe);Qe=Sf(Si),He=Sf(hi),Fe=$h(Si,Qe,1),Se=$h(hi,He,1)}else Zn(1);if(de>Ce){Me&&Zn(0);break}}_e&&fe(be+131072);for(var Bi=(1<<Qe)-1,Yi=(1<<He)-1,ur=de;;ur=de){var Ti=(si=Fe[Af(W,de)&Bi])>>4;if((de+=15&si)>Ce){Me&&Zn(0);break}if(si||Zn(2),Ti<256)ie[be++]=Ti;else{if(256==Ti){ur=de,Fe=null;break}var zi=Ti-254;Ti>264&&(zi=Gn(W,de,(1<<(or=Ty[xt=Ti-257]))-1)+Ay[xt],de+=or);var rr=Se[Af(W,de)&Yi],nr=rr>>4;if(rr||Zn(3),de+=15&rr,hi=hv[nr],nr>3){var or=My[nr];hi+=Af(W,de)&(1<<or)-1,de+=or}if(de>Ce){Me&&Zn(0);break}_e&&fe(be+131072);var xi=be+zi;if(be<hi){var Yr=0-hi,Ns=Math.min(hi,xi);for(Yr+be<0&&Zn(3);be<Ns;++be)ie[be]=(void 0)[Yr+be]}for(;be<xi;++be)ie[be]=ie[be-hi]}}J.l=Fe,J.p=ur,J.b=be,J.f=we,Fe&&(we=1,J.m=Qe,J.d=Se,J.n=He)}while(!we);return be!=ie.length&&se?(Lr=ie,(null==(Mr=0)||Mr<0)&&(Mr=0),(null==(mn=be)||mn>Lr.length)&&(mn=Lr.length),new fn(Lr.subarray(Mr,mn))):ie.subarray(0,be)}(N.subarray(G,-8),{i:2},new fn(((z=N)[(L=z.length)-4]|z[L-3]<<8|z[L-2]<<16|z[L-1]<<24)>>>0))));var z,L,N,G;const j=_v[I];if(!j)throw new Error(`Unhandled codec: ${I}`);const X=new globalThis.DecompressionStream(j);return new Response(new Blob([A]).stream().pipeThrough(X)).arrayBuffer().then(W=>new Uint8Array(W))}(v,y).then(A=>{const I=jn.read(new kl(A));if("uint32_values"===I.values)return I.uint32_values.readValuesInto(w),new xv[u](w.buffer);throw new Error(`Unhandled numeric data "${I.values}"`)}),E.then(A=>{for(let I=_.length-1;I>=0;I--)switch(_[I]){case"delta_filter":nv(A,p);break;case"zigzag_filter":ov(A);break;case"bitshuffle_filter":sv(A,u);break;default:throw new Error(`Unhandled filter "${_[I]}"`)}return{layerName:n,blockIndex:m,data:A}}).catch(A=>{throw A})}))},Ke(Py,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const zy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class If{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,n]=new Uint8Array(e,0,2);if(219!==i)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(1!==s)throw new Error(`Got v${s} data when expected v1.`);const l=zy[15&n];if(!l)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new If(p,u,l,e)}constructor(e,i=64,n=Float64Array,s){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const l=zy.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-p%8)%8;if(l<0)throw new Error(`Unexpected typed array class: ${n}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+p+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+l]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=i,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Cf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,n,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:u,nodeSize:p}=this,m=[0,l.length-1,0],_=[];for(;m.length;){const y=m.pop()||0,v=m.pop()||0,w=m.pop()||0;if(v-w<=p){for(let z=w;z<=v;z++){const L=u[2*z],N=u[2*z+1];L>=e&&L<=n&&N>=i&&N<=s&&_.push(l[z])}continue}const E=w+v>>1,A=u[2*E],I=u[2*E+1];A>=e&&A<=n&&I>=i&&I<=s&&_.push(l[E]),(0===y?e<=A:i<=I)&&(m.push(w),m.push(E-1),m.push(1-y)),(0===y?n>=A:s>=I)&&(m.push(E+1),m.push(v),m.push(1-y))}return _}within(e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:l,nodeSize:u}=this,p=[0,s.length-1,0],m=[],_=n*n;for(;p.length;){const y=p.pop()||0,v=p.pop()||0,w=p.pop()||0;if(v-w<=u){for(let z=w;z<=v;z++)Ly(l[2*z],l[2*z+1],e,i)<=_&&m.push(s[z]);continue}const E=w+v>>1,A=l[2*E],I=l[2*E+1];Ly(A,I,e,i)<=_&&m.push(s[E]),(0===y?e-n<=A:i-n<=I)&&(p.push(w),p.push(E-1),p.push(1-y)),(0===y?e+n>=A:i+n>=I)&&(p.push(E+1),p.push(v),p.push(1-y))}return m}}function Cf(t,e,i,n,s,l){if(s-n<=i)return;const u=n+s>>1;Dy(t,e,u,n,s,l),Cf(t,e,i,n,u-1,1-l),Cf(t,e,i,u+1,s,1-l)}function Dy(t,e,i,n,s,l){for(;s>n;){if(s-n>600){const _=s-n+1,y=i-n+1,v=Math.log(_),w=.5*Math.exp(2*v/3),E=.5*Math.sqrt(v*w*(_-w)/_)*(y-_/2<0?-1:1);Dy(t,e,i,Math.max(n,Math.floor(i-y*w/_+E)),Math.min(s,Math.floor(i+(_-y)*w/_+E)),l)}const u=e[2*i+l];let p=n,m=s;for(Hh(t,e,n,i),e[2*s+l]>u&&Hh(t,e,n,s);p<m;){for(Hh(t,e,p,m),p++,m--;e[2*p+l]<u;)p++;for(;e[2*m+l]>u;)m--}e[2*n+l]===u?Hh(t,e,n,m):(m++,Hh(t,e,m,s)),m<=i&&(n=m+1),i<=m&&(s=m-1)}}function Hh(t,e,i,n){Pf(t,i,n),Pf(e,2*i,2*n),Pf(e,2*i+1,2*n+1)}function Pf(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function Ly(t,e,i,n){const s=t-i,l=e-n;return s*s+l*l}a.$=Og,a.A=ul,a.B=jc,a.C=Gt,a.D=le,a.E=rs,a.F=Ii,a.G=Oe,a.H=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return Sn(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ut(t.x,e.x,i),y:Ut(t.y,e.y,i),z:Ut(t.z,e.z,i),azimuthal:Ut(t.azimuthal,e.azimuthal,i),polar:Ut(t.polar,e.polar,i)}}},a.I=rf,a.J=Ln,a.K=Ai,a.L=Yt,a.M=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new ne(e[0],e[1]):new ne(0,0),this.orientation=i??[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new Ri([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(a.a6.multiply(t.matrix,e,t.matrix),t.meshes)for(const i of t.meshes){const n=Ri.applyTransform(i.aabb,t.matrix);this.aabb.encapsulate(n)}if(t.children)for(const i of t.children)this._applyTransformations(i,t.matrix)}computeBoundsAndApplyParent(){const t=a.a6.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,s,l,u=!1){ty(this.matrix,this,t.transform,this.position,e,i,n,s,l,u)}upload(t){if(!this.uploaded){for(const e of this.nodes)_f(e,t);for(const e of this.nodes)kd(e);this.uploaded=!0}}destroy(){for(const t of this.nodes)gf(t)}},a.O=Jo,a.P=Ue,a.Q=da,a.R=Er,a.S=Cs,a.T=df,a.U=Ut,a.V=qe,a.W=Kh,a.X=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([i,n]){const s=Sn([1,i,n]);return{x:s.x,y:s.y,z:s.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ut(t.x,e.x,i),y:Ut(t.y,e.y,i),z:Ut(t.z,e.z,i)}}},a.Y=function(t,e,i=0,n=!0){const s=new Ue(i,i),l=t.sub(s),u=e.add(s),p=[l,new Ue(u.x,l.y),u,new Ue(l.x,u.y)];return n&&p.push(l.clone()),p},a.Z=la,a._=function(t,e){const i=[];for(let n=0;n<t.length;n++){const s=Hn(n-1,-1,t.length-1),l=Hn(n+1,-1,t.length-1),u=t[n],p=t[l],m=t[s].sub(u).unit(),_=p.sub(u).unit(),y=_.angleWithSep(m.x,m.y),v=m.add(_).unit().mult(-1*e/Math.sin(y/2));i.push(u.add(v))}return i},a.a=Xl,a.a$=function(t){const e=[];for(const i in t)e.push(t[i]);return e},a.a0=Bf,a.a1=function(t,e,i=0){return a.N.fromValues(((e.x-i)*t.scale-t.x)*qe,(e.y*t.scale-t.y)*qe,_i(e.z,e.y))},a.a2=zp,a.a3=eg,a.a4=function(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;for(const l of t)e=Math.min(e,l.x),i=Math.min(i,l.y),n=Math.max(n,l.x),s=Math.max(s,l.y);return{min:new Ue(e,i),max:new Ue(n,s)}},a.a5=Et,a.a8=On,a.a9=ii,a.aA=mu,a.aB=Oi,a.aC=Qo,a.aD=zu,a.aE=Id,a.aF=function(){Nr.isLoading()||Nr.isLoaded()||"deferred"!==ho()||eh()},a.aG=Vr,a.aH=Hi,a.aI=my,a.aJ=Ao,a.aK=Yp,a.aL=Wp,a.aM=er,a.aN=cn,a.aO=fh,a.aP=i_,a.aQ=sd,a.aR=uf,a.aS=function(t,e){const i=Cs(e.zoom);if(0===i)return xo(t);const n=Qu(t),s=kp(n),l=Et(n.getWest())*e.worldSize,u=Et(n.getEast())*e.worldSize,p=gt(n.getNorth())*e.worldSize,m=gt(n.getSouth())*e.worldSize,_=[l,p,0],y=[u,p,0],v=[l,m,0],w=[u,m,0],E=a.a6.invert([],e.globeMatrix);return a.N.transformMat4(_,_,E),a.N.transformMat4(y,y,E),a.N.transformMat4(v,v,E),a.N.transformMat4(w,w,E),s[0]=Ho(s[0],v,i),s[1]=Ho(s[1],w,i),s[2]=Ho(s[2],y,i),s[3]=Ho(s[3],_,i),Ri.fromPoints(s)},a.aT=td,a.aU=Th,a.aV=Ho,a.aW=wr,a.aX=m0,a.aY=Eo,a.aZ=Cy,a.a_=ve,a.aa=Dt,a.ab=V,a.ac=function(t,e){const i={};for(let n=0;n<e.length;n++){const s=e[n];s in t&&(i[s]=t[s])}return i},a.ad=ue,a.ae=gt,a.af=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const s=this.entries[t]=this.entries[t]||{callbacks:[]};if(s.result){const[l,u]=s.result;return this.scheduler?this.scheduler.add(()=>{n(l,u)},e):n(l,u),()=>{}}return s.callbacks.push(n),s.cancel||(s.cancel=i((l,u)=>{s.result=[l,u];for(const p of s.callbacks)this.scheduler?this.scheduler.add(()=>{p(l,u)},e):p(l,u);setTimeout(()=>delete this.entries[t],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(l=>l!==n),s.callbacks.length||(s.cancel(),delete this.entries[t]))}}},a.ag=sh,a.ah=function(t,e,i){const 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=>{const l=ve(t.request,(u,p,m,_)=>{u?s(u):p&&s(null,{vectorTile:i?void 0:new Hp(new kl(p)),rawData:p,cacheControl:m,expires:_})});return()=>{l.cancel(),s()}},e)},a.ai=function(t){ai++,ai>rt&&(t.getActor().send("enforceCacheSizeLimit",xe),ai=0)},a.aj=qi,a.ak=Ee,a.al=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},a.am=Le,a.an=qg,a.ao=$g,a.ap=Zg,a.aq=function(t,e){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let n=0;n<t.length;n++){const s=document.createElement("source");De(t[n])||(i.crossOrigin="Anonymous"),s.src=t[n],i.appendChild(s)}return{cancel:()=>{}}},a.ar=Pd,a.as=kh,a.at=vt,a.au=Zt,a.av=Rn,a.aw=Ji,a.ax=ji,a.ay=li,a.az=jo,a.b=Io,a.b$=Su,a.b0=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i},a.b1=tn,a.b2=["type","source","source-layer","minzoom","maxzoom","filter","layout"],a.b3=function(t,e){const{x:i,y:n}=t.point,s=l_(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return a.a6.multiply(s,s,Op(xo(e)))},a.b5=Dl,a.b6=pn,a.b7=fd,a.b8=function(t,e,i,n,s){const l=5*e+2;t.float32[l+0]=i,t.float32[l+1]=n,t.float32[l+2]=s},a.b9=Ad,a.bA=Ld,a.bB=Wg,a.bC=function(t){const e=Wg(t,!0);return a.b4.invert([],[e[0],e[1],e[4],e[5]])},a.bD=Dp,a.bE=function(t){const{x:e,y:i}=t.point,{lng:n,lat:s}=t._center;return l_(e,i,t.worldSize,n,s)},a.bF=dr,a.bG=5,a.bH=function(t){const e=Math.round((t+45+360)%360/90)%4;return ja[e]},a.bI=45,a.bJ=at,a.bK=h,a.bL=mo,a.bM=$u,a.bN=gr,a.bO=Ml,a.bP=c,a.bQ=function(t,e,i){const n=Math.sqrt(t*t+e*e+i*i),s=n>0?Math.acos(i/n)*Us:0;let l=0!==t||0!==e?Math.atan2(-e,-t)*Us+90:0;return l<0&&(l+=360),[n,l,s]},a.bR=Ft,a.bS=Ri,a.bT=Sn,a.bU=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},a.bV=function(t){return t({pluginStatus:Ir,pluginURL:co}),Qc.on("pluginStateChange",t),t},a.bW=yf,a.bX=Od,a.bY=Bl,a.bZ=nf,a.b_=Ui,a.ba=Eg,a.bb=wn,a.bc=24,a.bd=Dg,a.be=sf,a.bf=tf,a.bg=If,a.bh=Hn,a.bj=qt,a.bk=H,a.bl=bt,a.bm=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},a.bn=ne,a.bo=Ug,a.bp=Re,a.bq=Lp,a.br=Hg,a.bs=Ie,a.bt=o_,a.bu=function(t,e,i,n,s,l,u,p,m){if("globe"===m.name)return o_(t,e,new Ie(i,n,s),!1);const _=kh({z:i,x:n,y:s},m);return new Ri([(l+_.x/_.scale)*e,e*(_.y/_.scale),u],[(l+_.x2/_.scale)*e,e*(_.y2/_.scale),p])},a.bv=function(t,e,i){let n=0;for(let s=0;s<2;++s){const l=i?i[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.bw=Ot,a.bx=6,a.by=function(t){const e=a.a6.identity(new Float64Array(16));a.a6.multiply(e,t.pixelMatrix,t.globeMatrix);const i=[0,ee,0],n=[0,ce,0];return a.N.transformMat4(i,i,e),a.N.transformMat4(n,n,e),[i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!Fp(t,new ne(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Fp(t,new ne(t.center.lat,-90))]},a.bz=function(t,e){const{scale:i}=t.tileTransform,n=i*qe/(t.tileSize*Math.pow(2,e.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return a.b4.scale(new Float32Array(4),e.inverseAdjustmentMatrix,[n,n])},a.c=py,a.c$=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},a.c0=Wt,a.c1=Or,a.c2=function(t,e,i){return"custom"===t.type?new M1(t,e):new iv[t.type](t,e,i)},a.c3=function(t){const e=t.indexOf("\x1f");return e>=0?t.slice(0,e):t},a.c4=function(t){return t.indexOf("\x1f")>=0},a.c5=function(t){const e=t.indexOf("\x1f");return e>=0?t.slice(e+1):""},a.c6=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},a.c7=jr,a.c8=Qc,a.c9=ge,a.cA=rg,a.cB=(t,e,i,n,s,l)=>{const u=t.transform;return{u_matrix:ig(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_image:0,u_tile_units_to_pixels:tg(e,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:l}},a.cC=(t,e,i,n,s,l,u)=>{const p=t.transform,m=p.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:ig(t,e,i,n),u_pixels_to_tile_units:m,u_device_pixel_ratio:l,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:ng(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:tg(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:u,u_emissive_strength:i.paint.get("line-emissive-strength")}},a.cD=Gs,a.cE=Mh,a.cF=H_,a.cG=et,a.cH=pd,a.cI=Ds,a.cJ=450,a.cK=7,a.cL=b1,a.cM=256,a.cN=Op,a.cO=fo,a.cP=ph,a.cQ=function(t,e,i,n,s){return Dt((t-e)/(i-e)*(s-n)+n,n,s)},a.cR=Bt,a.cS=ff,a.cT=[1,1,1],a.cU=Pl,a.cV=Vl,a.cW=vn,a.cX=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t){const e=A_(new Ue(0,0),new Ue(qe,qe),t),i=[];for(const n of this._activeRegions){if(n.hiddenByOverlap||!S_(e,n))continue;const s=tx(n.min,n.max,t);i.push({min:s.min,max:s.max,sourceId:this._sourceIds[n.priority],footprint:n.footprint,footprintTileId:n.tileId})}return i}setSources(t){this._setSources(t.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const i=[];for(const n of e.cache.getVisibleCoordinates()){const s=e.cache.getTile(n).buckets[e.layer];if(s)for(const l of s.getNodesInfo()){const u=l.node;u.footprint&&i.push({footprint:u.footprint,id:n.toUnwrapped()})}}return i}})))}_addSource(t){const e=t.getFootprints();if(0!==e.length){for(const i of e){if(!i.footprint)continue;const n=A_(i.footprint.min,i.footprint.max,i.id);this._activeRegions.push({min:n.min,max:n.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:i.id,footprint:i.footprint})}this._sourceIds.push(t.getSourceId())}}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||hd(e.min,i.min)||hd(e.max,i.max));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0,i=0;for(;!t&&e!==this._activeRegions.length;){const n=this._activeRegions[e],s=this._prevRegions[i];t=n.priority!==s.priority||!E_(n,s),++e,++i}}if(t){++this._updateTime;const e=i=>{const n=this._activeRegions;if(i>=n.length)return i;const s=n[i].priority;for(;i<n.length&&n[i].priority===s;)++i;return i};if(this._sourceIds.length>1){let i=0,n=e(i);for(;i!==n;){let s=i;const l=i;for(;s!==n;){const u=this._activeRegions[s];u.hiddenByOverlap=!1;for(let p=0;p<l;p++){const m=this._activeRegions[p];if(!m.hiddenByOverlap&&S_(u,m)&&(u.hiddenByOverlap=C_(u.footprint,u.tileId,m.footprint,m.tileId),u.hiddenByOverlap))break}++s}i=n,n=e(i)}}}}_setSources(t){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=t.length-1;e>=0;e--)this._addSource(t[e]);this._computeReplacement()}},a.cY=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new cn,n=new Ji,s=[],l=t+1+2,u=e[0]+1,p=e[0]+1+(1+e.length),m=(_,y,v)=>{let w=_===l-1?_-2:0===_?_:_-1;return w+=v?24575:0,[w,y]};for(let _=0;_<l;++_)i.emplaceBack(...m(_,0,!0));for(let _=0;_<u;++_)for(let y=0;y<l;++y)i.emplaceBack(...m(y,_,(0===y||y===l-1)&&!0));for(let _=0;_<e.length;++_){const y=e[_];for(let v=0;v<l;++v)i.emplaceBack(...m(v,y,!0))}for(let _=0;_<e.length;++_){const y=n.length,v=e[_]+1+2,w=new Ji;for(let I=0;I<v-1;I++){const z=I===v-2,L=z?l*(p-e.length+_-I):l;for(let N=0;N<l-1;N++){const G=I*l+N;0===I||z||0===N||N===l-2?(w.emplaceBack(G+1,G,G+L),w.emplaceBack(G+L,G+L+1,G+1)):(n.emplaceBack(G+1,G,G+L),n.emplaceBack(G+L,G+L+1,G+1))}}const E=Oi.simpleSegment(0,y,i.length,n.length-y);for(let I=0;I<w.uint16.length;I+=3)n.emplaceBack(w.uint16[I],w.uint16[I+1],w.uint16[I+2]);const A=Oi.simpleSegment(0,y,i.length,n.length-y);s.push({withoutSkirts:E,withSkirts:A})}return{vertices:i,indices:n,segments:s}}_createGrid(t){const e=this._fillGridMeshWithLods(Y,K);this._gridSegments=e.segments,this._gridBuffer=t.createVertexBuffer(e.vertices,i_.members),this._gridIndexBuffer=t.createIndexBuffer(e.indices,!0)}_createPoles(t){const e=new Ji;for(let u=0;u<=Y;u++)e.emplaceBack(0,u+1,u+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new fo,n=new fo,s=new fo,l=new fo;this._poleSegments=[];for(let u=0,p=0;u<5;u++){const m=360/(1<<u);i.emplaceBack(0,-V,0,.5,0),n.emplaceBack(0,-V,0,.5,1),s.emplaceBack(0,-V,0,.5,.5),l.emplaceBack(0,-V,0,.5,.5);for(let _=0;_<=Y;_++){let y=_/Y,v=0;const w=Ut(0,m,y),[E,A,I]=re(y0,x0,w,V);i.emplaceBack(E,A,I,y,v),n.emplaceBack(E,A,I,y,1-v);const z=qt(w);y=.5+.5*Math.sin(z),v=.5+.5*Math.cos(z),s.emplaceBack(E,A,I,y,v),l.emplaceBack(E,A,I,y,1-v)}this._poleSegments.push(Oi.simpleSegment(p,0,66,64)),p+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(i,Ku,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(n,Ku,!1),this._texturedPoleNorthVertexBuffer=t.createVertexBuffer(s,Ku,!1),this._texturedPoleSouthVertexBuffer=t.createVertexBuffer(l,Ku,!1)}getGridBuffers(t,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}},a.cZ=function(t){return Yn.has(t)},a.c_=en,a.ca=r,a.cb=class extends kn{constructor(t){super(t),this.current=d}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let n=0;n<9;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},a.cc=$e,a.cd=function(t,e,i){const n=Cs(i.zoom),s=t.style.map._antialias,l=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!s&&!l},a.ce=function(t){const e=t.pixelsPerMeter,i=e/bt(1,t.center.lat),n=a.a6.identity(new Float64Array(16));return a.a6.translate(n,n,[t.point.x,t.point.y,0]),a.a6.scale(n,n,[i,i,e]),Float32Array.from(n)},a.cf=Qu,a.cg=function(t){const e=Ot-5;t=Dt(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(qt(t))),3);return Math.round(i*(K.length-1))},a.ch=function(t,e,i,n){const s=e.getNorth(),l=e.getSouth(),u=e.getWest(),p=e.getEast(),m=1<<t.z,_=p-u,y=s-l,v=_/Y,w=-y/K[i],E=[0,v,0,w,0,0,s,u,0];if(t.z>0){const A=180/n;a.co.multiply(E,E,[A/_+1,0,0,0,A/y+1,0,-.5*A/v,.5*A/w,1])}return E[2]=m,E[5]=t.x,E[8]=t.y,E},a.ci=xo,a.cj=function(t,e,i){const n=a.a6.identity(new Float64Array(16)),s=(e/(1<<t)-.5)*Math.PI*2;return a.a6.rotateY(n,i.globeMatrix,s),Float32Array.from(n)},a.ck=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,n=1<<i,s=Math.floor(t.x),l=Math.floor((t.x-s)*n),u=Math.floor(t.y*n),p=this.findDEMTileFor(new Le(i,s,i,l,u));return!(!p||!p.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){if(this.isUsingMockSource())return null;null==e&&(e=null);const n=this._source();if(!n||t.y<0||t.y>1)return e;const s=n.getSource().maxzoom,l=1<<s,u=Math.floor(t.x),p=t.x-u,m=new Le(s,u,s,Math.floor(p*l),Math.floor(t.y*l)),_=this.findDEMTileFor(m);if(!_||!_.dem)return e;const y=_.dem,v=1<<_.tileID.canonical.z,w=(p*v-_.tileID.canonical.x)*y.dim,E=(t.y*v-_.tileID.canonical.y)*y.dim,A=Math.floor(w),I=Math.floor(E);return(i?this.exaggeration():1)*Ut(Ut(y.get(A,I),y.get(A,I+1),E-I),Ut(y.get(A+1,I),y.get(A+1,I+1),E-I),w-A)}getAtTileOffset(t,e,i){const n=1<<t.canonical.z;return this.getAtPointOrZero(new Yt(t.wrap+(t.canonical.x+e/qe)/n,(t.canonical.y+i/qe)/n))}getAtTileOffsetFunc(t,e,i,n){return s=>{const l=this.getAtTileOffset(t,s.x,s.y),u=n.upVector(t.canonical,s.x,s.y),p=n.upVectorScale(t.canonical,e,i).metersToTile;return a.N.scale(u,u,l*p),u}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const s=Pl.create(this,t,n);return!!s&&(e.forEach(l=>{l[2]=this.exaggeration()*s.getElevationAt(l[0],l[1],i)}),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,s=1<<t.canonical.z-n.canonical.z;let 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&&!i.leaves[p];m++){l*=2,u*=2;const _=2*Math.floor(u)+Math.floor(l);p=i.childOffsets[p]+_,l%=1,u%=1}return{min:this.exaggeration()*i.minimums[p],max:this.exaggeration()*i.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){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.")}getMinMaxForVisibleTiles(){const t=this.visibleDemTiles;if(0===t.length)return null;let e=!1,i=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const s of t){const l=this.getMinMaxForTile(s.tileID);l&&(i=Math.min(i,l.min),n=Math.max(n,l.max),e=!0)}return e?{min:i,max:n}:null}},a.cl=Ju,a.cm=g_,a.cn=function(t,e){return[Math.pow(t[0],2.2)*e,Math.pow(t[1],2.2)*e,Math.pow(t[2],2.2)*e]},a.cp=a_,a.cq=256,a.cr=function(t,e){const i=[0,0,0],n=td(xo(e.canonical));return a.N.transformMat4(i,i,n),a.N.transformMat4(i,i,t),i},a.cs=t=>({u_camera_to_center_distance:new gr(t),u_extrude_scale:new g(t),u_device_pixel_ratio:new gr(t),u_matrix:new h(t),u_inv_rot_matrix:new h(t),u_merc_center:new mo(t),u_tile_id:new $u(t),u_zoom_transition:new gr(t),u_up_dir:new $u(t),u_emissive_strength:new gr(t)}),a.ct=t=>({u_matrix:new h(t),u_pixels_to_tile_units:new g(t),u_device_pixel_ratio:new gr(t),u_units_to_pixels:new mo(t),u_dash_image:new Ml(t),u_gradient_image:new Ml(t),u_image_height:new gr(t),u_texsize:new mo(t),u_tile_units_to_pixels:new gr(t),u_alpha_discard_threshold:new gr(t),u_trim_offset:new mo(t),u_emissive_strength:new gr(t)}),a.cu=t=>({u_matrix:new h(t),u_texsize:new mo(t),u_pixels_to_tile_units:new g(t),u_device_pixel_ratio:new gr(t),u_image:new Ml(t),u_units_to_pixels:new mo(t),u_tile_units_to_pixels:new gr(t),u_alpha_discard_threshold:new gr(t),u_trim_offset:new mo(t)}),a.cv=vl,a.cw=Px,a.cx=zx,a.cy=u_,a.cz=(t,e,i,n,s,l)=>{const u=t.transform,p="globe"===u.projection.name;let m;if("map"===l.paint.get("circle-pitch-alignment"))if(p){const y=a_(u.zoom,e.canonical)*u._pixelsPerMercatorPixel;m=Float32Array.from([y,0,0,y])}else m=u.calculatePixelsToTileUnitsMatrix(i);else m=new Float32Array([u.pixelsToGLUnits[0],0,0,u.pixelsToGLUnits[1]]);const _={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(u.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,l.paint.get("circle-translate"),l.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ze.devicePixelRatio,u_extrude_scale:m,u_inv_rot_matrix:v0,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:l.paint.get("circle-emissive-strength")};if(p){_.u_inv_rot_matrix=n,_.u_merc_center=s,_.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],_.u_zoom_transition=Cs(u.zoom);const y=s[0]*qe,v=s[1]*qe;_.u_up_dir=u.projection.upVector(new Ie(0,0,0),y,v)}return _},a.d=Ze,a.d0=xr,a.d1=Kt,a.d2=me,a.d3=function([t,e,i]){const n=Math.hypot(t,e,i),s=Math.atan2(t,i),l=.5*Math.PI-Math.acos(-e/n);return new ne(dr(s),dr(l))},a.d4=pe,a.d5=zt,a.d6=Fp,a.d7=c_,a.d8=function(t){const e=[0,0,0],i=a.a6.identity(new Float64Array(16));return a.a6.multiply(i,t.pixelMatrix,t.globeMatrix),a.N.transformMat4(e,e,i),new Ue(e[0],e[1])},a.d9=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(i){if(null==Te){const n=i.navigator?i.navigator.userAgent:null;Te=!!i.safari||!(!n||!(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match("Safari")&&!n.match("Chrome")))}return Te}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},a.dA=2,a.dB=fy,a.dC=_y,a.dD=J_,a.dE=fr,a.dF=Ag,a.dG=function(t,e,i,n,s,l,u,p,m,_,y){t.createArrays(),t.tilePixelRatio=qe/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const v=t.layers[0].layout,w=t.layers[0]._unevaluatedLayout._values,E={};if("composite"===t.textSizeData.kind){const{minZoom:L,maxZoom:N}=t.textSizeData;E.compositeTextSizes=[w["text-size"].possiblyEvaluate(new Ai(L),p),w["text-size"].possiblyEvaluate(new Ai(N),p)]}if("composite"===t.iconSizeData.kind){const{minZoom:L,maxZoom:N}=t.iconSizeData;E.compositeIconSizes=[w["icon-size"].possiblyEvaluate(new Ai(L),p),w["icon-size"].possiblyEvaluate(new Ai(N),p)]}E.layoutTextSize=w["text-size"].possiblyEvaluate(new Ai(m+1),p),E.layoutIconSize=w["icon-size"].possiblyEvaluate(new Ai(m+1),p),E.textMaxSize=w["text-size"].possiblyEvaluate(new Ai(18),p);const A="map"===v.get("text-rotation-alignment")&&"point"!==v.get("symbol-placement"),I=v.get("text-size");let z=!1;for(const L of t.features)if(L.icon&&L.icon.nameSecondary){z=!0;break}for(const L of t.features){const N=v.get("text-font").evaluate(L,{},p).join(","),G=I.evaluate(L,{},p),j=E.layoutTextSize.evaluate(L,{},p),X=(E.layoutIconSize.evaluate(L,{},p),{horizontal:{},vertical:void 0}),W=L.text;let J,ie=[0,0];if(W){const se=W.toString(),_e=24*v.get("text-letter-spacing").evaluate(L,{},p),Me=24*v.get("text-line-height").evaluate(L,{},p),fe=lp(se)?_e:0,we=v.get("text-anchor").evaluate(L,{},p),de=v.get("text-variable-anchor");if(!de){const He=v.get("text-radial-offset").evaluate(L,{},p);ie=He?Dg(we,[24*He,of]):v.get("text-offset").evaluate(L,{},p).map(Ce=>24*Ce)}let be=A?"center":v.get("text-justify").evaluate(L,{},p);const Fe="point"===v.get("symbol-placement"),Se=Fe?24*v.get("text-max-width").evaluate(L,{},p):1/0,Qe=He=>{t.allowVerticalPlacement&&lo(se)&&(X.vertical=ef(W,e,i,s,N,Se,Me,we,He,fe,ie,pn.vertical,!0,j,G))};if(!A&&de){const He="auto"===be?de.map(ft=>sf(ft)):[be];let Ce=!1;for(let ft=0;ft<He.length;ft++){const st=He[ft];if(!X.horizontal[st])if(Ce)X.horizontal[st]=X.horizontal[0];else{const Je=ef(W,e,i,s,N,Se,Me,"center",st,fe,ie,pn.horizontal,!1,j,G);Je&&(X.horizontal[st]=Je,Ce=1===Je.positionedLines.length)}}Qe("left")}else{if("auto"===be&&(be=sf(we)),Fe||v.get("text-writing-mode").indexOf("horizontal")>=0||!lo(se)){const He=ef(W,e,i,s,N,Se,Me,we,be,fe,ie,pn.horizontal,!1,j,G);He&&(X.horizontal[be]=He)}Qe(Fe?"left":be)}}let oe=!1;if(L.icon&&L.icon.namePrimary){const se=n[L.icon.namePrimary];se&&(J=Yx(s[L.icon.namePrimary],L.icon.nameSecondary?s[L.icon.nameSecondary]:void 0,v.get("icon-offset").evaluate(L,{},p),v.get("icon-anchor").evaluate(L,{},p)),oe=se.sdf,void 0===t.sdfIcons?t.sdfIcons=se.sdf:t.sdfIcons!==se.sdf&&ki("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(se.pixelRatio!==t.pixelRatio||0!==v.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const he=Rg(X.horizontal)||X.vertical;t.iconsInText||(t.iconsInText=!!he&&he.iconsInText),(he||J)&&r1(t,L,X,J,n,E,j,0,ie,oe,u,p,_,y,z)}l&&t.generateCollisionDebugBuffers(m,t.collisionBoxArray)},a.dH=Hp,a.dI=kl,a.dJ=ud,a.dK=kr,a.dL=ld,a.dM=ad,a.dN=Wn,a.dO=lg,a.dP=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==sy){const i=new Uint32Array(t,0,7),[,,n,s,l,u]=i;e=i.byteLength+s+l+u+l,(n!==t.byteLength||e>=t.byteLength)&&ki("Invalid b3dm header information.")}return hy(t,e)},a.dQ=function(t,e){const i=py(t);for(const n of i){for(const s of n.meshes)Y1(s);n.lights&&(n.lightMeshIndex=n.meshes.length,n.meshes.push(K1(n.lights,e)))}return i},a.dR=Vd,a.dS=iy,a.dT=Nr,a.dU=function(t){ui(),Ye&&Ye.then(e=>{e.keys().then(i=>{for(let n=0;n<i.length-t;n++)e.delete(i[n])})})},a.da=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let e="";for(let i=0;i<10;i++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Be,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(!Wt(t))return t;const i=_t(t);return i.params.push(`sdk=js-${Pt}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Wt(t))return t;const i=_t(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!Wt(t))return t;const i=_t(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!Wt(t))return t;const s=_t(t);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),i&&s.params.push(`language=${i}`),n&&s.params.push(`worldview=${n}`),this._makeAPIURL(s,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const s=_t(t);return Wt(t)?(s.path=`/styles/v1${s.path}/sprite${e}${i}`,this._makeAPIURL(s,this._customAccessToken||n)):(s.path+=`${e}${i}`,Vt(s))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Wt(t))return t;const n=_t(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==n.authority&&512===i?"@2x":""}${ri.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${zt.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${zt.RASTERARRAYS_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${zt.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(l){for(const u of l){const p=u.match(/^access_token=(.*)$/);if(p)return p[1]}return null}(n.params)||zt.ACCESS_TOKEN;return zt.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(t,e){const i=_t(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${zt.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${i.path.replace(`/${zt.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${zt.TILE_URL_VERSION}/`,"")}`;let s=i.params;return e&&(s=s.filter(l=>!l.match(/^access_token=/))),s.length&&(n+=`?${s.join("&")}`),n}canonicalizeTileset(t,e){const i=!!e&&Wt(e),n=[];for(const s of t.tiles||[])qn(s)?n.push(this.canonicalizeTileURL(s,i)):n.push(s);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=_t(zt.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){const s=t.params.indexOf("secure");s>=0&&t.params.splice(s,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!zt.REQUIRE_ACCESS_TOKEN)return Vt(t);if(e=e||zt.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter(s=>-1===s.indexOf("access_token")),t.params.push(`access_token=${e||""}`),Vt(t)}},a.db=function(t,e){e?Yn.add(t):Yn.delete(t)},a.dc=ri,a.dd=rn,a.de=qs,a.df=We,a.dg=ti,a.dh=function(t){Yn.delete(t)},a.di=ar,a.dj=sr,a.dk=Pt,a.dl=function(t,e){xe=t,rt=e},a.dm=function(t,e,i=!1){if(Ir===Hc||Ir===Xc||Ir===Yc)throw new Error("setRTLTextPlugin cannot be called multiple times.");co=ze.resolveURL(t),Ir=Hc,Kc=e,Jc(),i||eh()},a.dn=ho,a.dp=function(){Od().acquire(xf)},a.dq=function(){const t=Gh;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(xf),Gh=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()"))},a.dr=jh,a.ds=function(t){const e=Lt();if(!e)return;const i=e.delete(tt);t&&i.catch(t).then(()=>t())},a.dt=Uh,a.du=ry,a.dv=function(t){vf=ze.resolveURL(t),jl||(jl=new yf(Od(),new rs)),jl.broadcast("setDracoUrl",vf)},a.dw=ny,a.dx=function(t){Ul=ze.resolveURL(t),jl||(jl=new yf(Od(),new rs)),jl.broadcast("setMeshoptUrl",Ul)},a.dy=Ke,a.dz=Ps,a.e=pr,a.f=ze,a.g=function(t,e){return ge(pr(t,{type:"json"}),e)},a.h=dn,a.i=cs,a.j=Jl,a.k=hl,a.l=function(t){return fetch(t).then(e=>e.arrayBuffer()).then(e=>hy(e,0,t))},a.m=yu,a.n=aa,a.o=fa,a.p=Sg,a.q=fl,a.r=pl,a.s=Gc,a.t=ta,a.u=pa,a.v=cr,a.w=ki,a.x=fs,a.z=rh}),Gd(0,function(a){function Pt(Te){const U=Te?Te.url.toString():void 0;return U?performance.getEntriesByName(U):[]}function Qr(Te){if("number"==typeof Te||"boolean"==typeof Te||"string"==typeof Te||null==Te)return JSON.stringify(Te);if(Array.isArray(Te)){let H="[";for(const te of Te)H+=`${Qr(te)},`;return`${H}]`}let U="{";for(const H of Object.keys(Te).sort())U+=`${H}:${Qr(Te[H])},`;return`${U}}`}function zt(Te){let U="";for(const H of a.b2)U+=`/${Qr(Te[H])}`;return U}class qn{constructor(U){this.keyCache={},this._layers={},this._layerConfigs={},U&&this.replace(U)}replace(U,H){this._layerConfigs={},this._layers={},this.update(U,[],H)}update(U,H,te){this._options=te;for(const Ee of U)this._layerConfigs[Ee.id]=Ee,(this._layers[Ee.id]=a.c2(Ee,this.scope,this._options)).compileFilter(),this.keyCache[Ee.id]&&delete this.keyCache[Ee.id];for(const Ee of H)delete this.keyCache[Ee],delete this._layerConfigs[Ee],delete this._layers[Ee];this.familiesBySource={};const ye=function(Ee,ze){const tt={};for(let rt=0;rt<Ee.length;rt++){const Ye=ze&&ze[Ee[rt].id]||zt(Ee[rt]);ze&&(ze[Ee[rt].id]=Ye);let ot=tt[Ye];ot||(ot=tt[Ye]=[]),ot.push(Ee[rt])}const xe=[];for(const rt in tt)xe.push(tt[rt]);return xe}(a.a$(this._layerConfigs),this.keyCache);for(const Ee of ye){const ze=Ee.map(Lt=>this._layers[Lt.id]),tt=ze[0];if("none"===tt.visibility)continue;const xe=tt.source||"";let rt=this.familiesBySource[xe];rt||(rt=this.familiesBySource[xe]={});const Ye=tt.sourceLayer||"_geojsonTileLayer";let ot=rt[Ye];ot||(ot=rt[Ye]=[]),ot.push(ze)}}}const Wt=1*a.dA;class Rr{constructor(U){const H={},te=[];for(const tt in U){const xe=U[tt],rt=H[tt]={};for(const Ye in xe.glyphs){const ot=xe.glyphs[+Ye];if(!ot||0===ot.bitmap.width||0===ot.bitmap.height)continue;const Lt=ot.metrics.localGlyph?Wt:1,ui={x:0,y:0,w:ot.bitmap.width+2*Lt,h:ot.bitmap.height+2*Lt};te.push(ui),rt[Ye]=ui}}const{w:ye,h:Ee}=a.p(te),ze=new a.dz({width:ye||1,height:Ee||1});for(const tt in U){const xe=U[tt];for(const rt in xe.glyphs){const Ye=xe.glyphs[+rt];if(!Ye||0===Ye.bitmap.width||0===Ye.bitmap.height)continue;const ot=H[tt][rt],Lt=Ye.metrics.localGlyph?Wt:1;a.dz.copy(Ye.bitmap,ze,{x:0,y:0},{x:ot.x+Lt,y:ot.y+Lt},Ye.bitmap)}}this.image=ze,this.positions=H}}a.dy(Rr,"GlyphAtlas");class _n{constructor(U){this.tileID=new a.am(U.tileID.overscaledZ,U.tileID.wrap,U.tileID.canonical.z,U.tileID.canonical.x,U.tileID.canonical.y),this.tileZoom=U.tileZoom,this.uid=U.uid,this.zoom=U.zoom,this.canonical=U.tileID.canonical,this.pixelRatio=U.pixelRatio,this.tileSize=U.tileSize,this.source=U.source,this.scope=U.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=U.showCollisionBoxes,this.collectResourceTiming=!!U.collectResourceTiming,this.promoteId=U.promoteId,this.isSymbolTile=U.isSymbolTile,this.tileTransform=a.as(U.tileID.canonical,U.projection),this.projection=U.projection,this.brightness=U.brightness,this.extraShadowCaster=!!U.extraShadowCaster}parse(U,H,te,ye,Ee){this.status="parsing",this.data=U,this.collisionBoxArray=new a.aD;const ze=new a.dB(Object.keys(U.layers).sort()),tt=new a.dC(this.tileID,this.promoteId);tt.bucketLayerIDs=[];const xe={},rt=new a.dD(256,256),Ye={featureIndex:tt,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:rt,availableImages:te,brightness:this.brightness},ot=H.familiesBySource[this.source];for(const ci in ot){const gi=U.layers[ci];if(!gi)continue;let Ki=!1,vi=!1,vr=!1;for(const Zi of ot[ci])"symbol"===Zi[0].type?Ki=!0:vi=!0,Zi[0].is3D()&&"model"!==Zi[0].type&&(vr=!0);if(this.extraShadowCaster&&!vr||!0===this.isSymbolTile&&!Ki||!1===this.isSymbolTile&&!vi)continue;1===gi.version&&a.w(`Vector tile source "${this.source}" layer "${ci}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const _r=ze.encode(ci),Er=[];for(let Zi=0;Zi<gi.length;Zi++){const Ui=gi.feature(Zi),ge=tt.getId(Ui,ci);Er.push({feature:Ui,id:ge,index:Zi,sourceLayerIndex:_r})}for(const Zi of ot[ci]){const Ui=Zi[0];(!this.extraShadowCaster||Ui.is3D()&&"model"!==Ui.type)&&(void 0!==this.isSymbolTile&&"symbol"===Ui.type!==this.isSymbolTile||Ui.minzoom&&this.zoom<Math.floor(Ui.minzoom)||Ui.maxzoom&&this.zoom>=Ui.maxzoom||"none"!==Ui.visibility&&(gn(Zi,this.zoom,Ye.brightness,te),(xe[Ui.id]=Ui.createBucket({index:tt.bucketLayerIDs.length,layers:Zi,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:_r,sourceID:this.source,projection:this.projection.spec})).populate(Er,Ye,this.tileID.canonical,this.tileTransform),tt.bucketLayerIDs.push(Zi.map(ge=>ge.id))))}}let Lt,ui,bi,di;rt.trim();const ai={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},ri=()=>{if(Lt)return this.status="done",Ee(Lt);if(this.extraShadowCaster)this.status="done",Ee(null,{buckets:a.a$(xe).filter(ci=>!ci.isEmpty()),featureIndex:tt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Ye.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(ui&&bi&&di){const ci=new Rr(ui),gi=new a.dF(bi,di);for(const Ki in xe){const vi=xe[Ki];vi instanceof a.aE?(gn(vi.layers,this.zoom,Ye.brightness,te),a.dG(vi,ui,ci.positions,bi,gi.iconPositions,this.showCollisionBoxes,te,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):vi.hasPattern&&(vi instanceof a.aK||vi instanceof a.aL||vi instanceof a.cH)&&(gn(vi.layers,this.zoom,Ye.brightness,te),vi.addFeatures(Ye,this.tileID.canonical,gi.patternPositions,te,this.tileTransform,this.brightness))}this.status="done",Ee(null,{buckets:a.a$(xe).filter(Ki=>!Ki.isEmpty()),featureIndex:tt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ci.image,lineAtlas:rt,imageAtlas:gi,brightness:Ye.brightness})}};if(!this.extraShadowCaster){const ci=a.dE(Ye.glyphDependencies,vi=>Object.keys(vi).map(Number));Object.keys(ci).length?ye.send("getGlyphs",{uid:this.uid,stacks:ci,scope:this.scope},(vi,vr)=>{Lt||(Lt=vi,ui=vr,ri())},void 0,!1,ai):ui={};const gi=Object.keys(Ye.iconDependencies);gi.length?ye.send("getImages",{icons:gi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(vi,vr)=>{Lt||(Lt=vi,bi=vr,ri())},void 0,!1,ai):bi={};const Ki=Object.keys(Ye.patternDependencies);Ki.length?ye.send("getImages",{icons:Ki,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(vi,vr)=>{Lt||(Lt=vi,di=vr,ri())},void 0,!1,ai):di={}}ri()}}function gn(Te,U,H,te){const ye=new a.K(U,{brightness:H});for(const Ee of Te)Ee.recalculate(ye,te)}class bo extends a.E{constructor(U,H,te,ye,Ee,ze){super(),this.actor=U,this.layerIndex=H,this.availableImages=te,this.loadVectorData=Ee||a.ah,this.loading={},this.loaded={},this.deduped=new a.af(U.scheduler),this.isSpriteLoaded=ye,this.scheduler=U.scheduler,this.brightness=ze}loadTile(U,H){const te=U.uid,ye=U&&U.request,Ee=ye&&ye.collectResourceTiming,ze=this.loading[te]=new _n(U);ze.abort=this.loadVectorData(U,(tt,xe)=>{const rt=!this.loading[te];if(delete this.loading[te],rt||tt||!xe)return ze.status="done",rt||(this.loaded[te]=ze),H(tt);const Ye=xe.rawData,ot={};xe.expires&&(ot.expires=xe.expires),xe.cacheControl&&(ot.cacheControl=xe.cacheControl),ze.vectorTile=xe.vectorTile||new a.dH(new a.dI(Ye));const Lt=()=>{ze.parse(ze.vectorTile,this.layerIndex,this.availableImages,this.actor,(ui,bi)=>{if(ui||!bi)return H(ui);const di={};if(Ee){const ai=Pt(ye);ai.length>0&&(di.resourceTiming=JSON.parse(JSON.stringify(ai)))}H(null,a.e({rawTileData:Ye.slice(0)},bi,ot,di))})};this.isSpriteLoaded?Lt():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Lt,{type:"parseTile",isSymbolTile:U.isSymbolTile,zoom:U.tileZoom}):Lt()}),this.loaded=this.loaded||{},this.loaded[te]=ze})}reloadTile(U,H){const te=this.loaded,ye=U.uid,Ee=this;if(te&&te[ye]){const ze=te[ye];ze.showCollisionBoxes=U.showCollisionBoxes,ze.projection=U.projection,ze.brightness=U.brightness,ze.tileTransform=a.as(U.tileID.canonical,U.projection),ze.extraShadowCaster=U.extraShadowCaster;const tt=(xe,rt)=>{const Ye=ze.reloadCallback;Ye&&(delete ze.reloadCallback,ze.parse(ze.vectorTile,Ee.layerIndex,this.availableImages,Ee.actor,Ye)),H(xe,rt)};"parsing"===ze.status?ze.reloadCallback=tt:"done"===ze.status&&(ze.vectorTile?ze.parse(ze.vectorTile,this.layerIndex,this.availableImages,this.actor,tt):tt())}else H(null,void 0)}abortTile(U,H){const te=U.uid,ye=this.loading[te];ye&&(ye.abort&&ye.abort(),delete this.loading[te]),H()}removeTile(U,H){const te=this.loaded,ye=U.uid;te&&te[ye]&&delete te[ye],H()}}class Ua{loadTile(U,H){const{uid:te,encoding:ye,rawImageData:Ee,padding:ze}=U,tt=ImageBitmap&&Ee instanceof ImageBitmap?this.getImageData(Ee,ze):Ee;H(null,new a.dJ(te,tt,ye,ze<1))}getImageData(U,H){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(U.width,U.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=U.width,this.offscreenCanvas.height=U.height,this.offscreenCanvasContext.drawImage(U,0,0,U.width,U.height);const te=this.offscreenCanvasContext.getImageData(-H,-H,U.width+2*H,U.height+2*H);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),te}}class kr{decodeRasterArray({task:U,buffer:H},te){a.aZ.performDecoding(H,U).then(ye=>{te(null,ye)},ye=>{te(ye)})}}function Ko(Te,U){if(0!==Te.length){wo(Te[0],U);for(var H=1;H<Te.length;H++)wo(Te[H],!U)}}function wo(Te,U){for(var H=0,te=0,ye=0,Ee=Te.length,ze=Ee-1;ye<Ee;ze=ye++){var tt=(Te[ye][0]-Te[ze][0])*(Te[ze][1]+Te[ye][1]),xe=H+tt;te+=Math.abs(H)>=Math.abs(tt)?H-xe+tt:tt-xe+H,H=xe}H+te>=0!=!!U&&Te.reverse()}var $n=a.dK(function Te(U,H){var te,ye=U&&U.type;if("FeatureCollection"===ye)for(te=0;te<U.features.length;te++)Te(U.features[te],H);else if("GeometryCollection"===ye)for(te=0;te<U.geometries.length;te++)Te(U.geometries[te],H);else if("Feature"===ye)Te(U.geometry,H);else if("Polygon"===ye)Ko(U.coordinates,H);else if("MultiPolygon"===ye)for(te=0;te<U.coordinates.length;te++)Ko(U.coordinates[te],H);return U});const Wn=a.dL.prototype.toGeoJSON;let Mn=class{constructor(Te){this._feature=Te,this.extent=a.V,this.type=Te.type,this.properties=Te.tags,"id"in Te&&!isNaN(Te.id)&&(this.id=parseInt(Te.id,10))}loadGeometry(){if(1===this._feature.type){const Te=[];for(const U of this._feature.geometry)Te.push([new a.P(U[0],U[1])]);return Te}{const Te=[];for(const U of this._feature.geometry){const H=[];for(const te of U)H.push(new a.P(te[0],te[1]));Te.push(H)}return Te}}toGeoJSON(Te,U,H){return Wn.call(this,Te,U,H)}},Ue=class{constructor(Te){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.V,this.length=Te.length,this._features=Te}feature(Te){return new Mn(this._features[Te])}};var To={exports:{}},Us=a.dN,qt=a.dM.VectorTileFeature,dr=ja;function ja(Te,U){this.options=U||{},this.features=Te,this.length=Te.length}function $e(Te,U){this.id="number"==typeof Te.id?Te.id:void 0,this.type=Te.type,this.rawGeometry=1===Te.type?[Te.geometry]:Te.geometry,this.properties=Te.tags,this.extent=U||4096}ja.prototype.feature=function(Te){return new $e(this.features[Te],this.options.extent)},$e.prototype.loadGeometry=function(){var Te=this.rawGeometry;this.geometry=[];for(var U=0;U<Te.length;U++){for(var H=Te[U],te=[],ye=0;ye<H.length;ye++)te.push(new Us(H[ye][0],H[ye][1]));this.geometry.push(te)}return this.geometry},$e.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var Te=this.geometry,U=1/0,H=-1/0,te=1/0,ye=-1/0,Ee=0;Ee<Te.length;Ee++)for(var ze=Te[Ee],tt=0;tt<ze.length;tt++){var xe=ze[tt];U=Math.min(U,xe.x),H=Math.max(H,xe.x),te=Math.min(te,xe.y),ye=Math.max(ye,xe.y)}return[U,te,H,ye]},$e.prototype.toGeoJSON=qt.prototype.toGeoJSON;var en=a.dO,xr=dr;function Dt(Te){var U=new en;return function(H,te){for(var ye in H.layers)te.writeMessage(3,Jo,H.layers[ye])}(Te,U),U.finish()}function Jo(Te,U){var H;U.writeVarintField(15,Te.version||1),U.writeStringField(1,Te.name||""),U.writeVarintField(5,Te.extent||4096);var te={keys:[],values:[],keycache:{},valuecache:{}};for(H=0;H<Te.length;H++)te.feature=Te.feature(H),U.writeMessage(2,Hn,te);var ye=te.keys;for(H=0;H<ye.length;H++)U.writeStringField(3,ye[H]);var Ee=te.values;for(H=0;H<Ee.length;H++)U.writeMessage(4,js,Ee[H])}function Hn(Te,U){var H=Te.feature;void 0!==H.id&&U.writeVarintField(1,H.id),U.writeMessage(2,tn,Te),U.writeVarintField(3,H.type),U.writeMessage(4,Qo,H)}function tn(Te,U){var H=Te.feature,te=Te.keys,ye=Te.values,Ee=Te.keycache,ze=Te.valuecache;for(var tt in H.properties){var xe=H.properties[tt],rt=Ee[tt];if(null!==xe){void 0===rt&&(te.push(tt),Ee[tt]=rt=te.length-1),U.writeVarint(rt);var Ye=typeof xe;"string"!==Ye&&"boolean"!==Ye&&"number"!==Ye&&(xe=JSON.stringify(xe));var ot=Ye+":"+xe,Lt=ze[ot];void 0===Lt&&(ye.push(xe),ze[ot]=Lt=ye.length-1),U.writeVarint(Lt)}}}function pr(Te,U){return(U<<3)+(7&Te)}function Mo(Te){return Te<<1^Te>>31}function Qo(Te,U){for(var H=Te.loadGeometry(),te=Te.type,ye=0,Ee=0,ze=H.length,tt=0;tt<ze;tt++){var xe=H[tt],rt=1;1===te&&(rt=xe.length),U.writeVarint(pr(1,rt));for(var Ye=3===te?xe.length-1:xe.length,ot=0;ot<Ye;ot++){1===ot&&1!==te&&U.writeVarint(pr(2,Ye-1));var Lt=xe[ot].x-ye,ui=xe[ot].y-Ee;U.writeVarint(Mo(Lt)),U.writeVarint(Mo(ui)),ye+=Lt,Ee+=ui}3===te&&U.writeVarint(pr(7,1))}}function js(Te,U){var H=typeof Te;"string"===H?U.writeStringField(1,Te):"boolean"===H?U.writeBooleanField(7,Te):"number"===H&&(Te%1!=0?U.writeDoubleField(3,Te):Te<0?U.writeSVarintField(6,Te):U.writeVarintField(5,Te))}To.exports=Dt,To.exports.fromVectorTileJs=Dt,To.exports.fromGeojsonVt=function(Te,U){U=U||{};var H={};for(var te in Te)H[te]=new xr(Te[te].features,U),H[te].name=te,H[te].version=U.version,H[te].extent=U.extent;return Dt({layers:H})},To.exports.GeoJSONWrapper=xr;var Gs=a.dK(To.exports);const Zs={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Te=>Te},Eo=Math.fround||(En=new Float32Array(1),Te=>(En[0]=+Te,En[0]));var En;class Ga{constructor(U){this.options=Object.assign(Object.create(Zs),U),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(U){const{log:H,minZoom:te,maxZoom:ye}=this.options;H&&console.time("total time");const Ee=`prepare ${U.length} points`;H&&console.time(Ee),this.points=U;const ze=[];for(let xe=0;xe<U.length;xe++){const rt=U[xe];if(!rt.geometry)continue;const[Ye,ot]=rt.geometry.coordinates,Lt=Eo(So(Ye)),ui=Eo(Sn(ot));ze.push(Lt,ui,1/0,xe,-1,1),this.options.reduce&&ze.push(0)}let tt=this.trees[ye+1]=this._createTree(ze);H&&console.timeEnd(Ee);for(let xe=ye;xe>=te;xe--){const rt=+Date.now();tt=this.trees[xe]=this._createTree(this._cluster(tt,xe)),H&&console.log("z%d: %d clusters in %dms",xe,tt.numItems,+Date.now()-rt)}return H&&console.timeEnd("total time"),this}getClusters(U,H){let te=((U[0]+180)%360+360)%360-180;const ye=Math.max(-90,Math.min(90,U[1]));let Ee=180===U[2]?180:((U[2]+180)%360+360)%360-180;const ze=Math.max(-90,Math.min(90,U[3]));if(U[2]-U[0]>=360)te=-180,Ee=180;else if(te>Ee){const ot=this.getClusters([te,ye,180,ze],H),Lt=this.getClusters([-180,ye,Ee,ze],H);return ot.concat(Lt)}const tt=this.trees[this._limitZoom(H)],xe=tt.range(So(te),Sn(ze),So(Ee),Sn(ye)),rt=tt.data,Ye=[];for(const ot of xe){const Lt=this.stride*ot;Ye.push(rt[Lt+5]>1?ki(rt,Lt,this.clusterProps):this.points[rt[Lt+3]])}return Ye}getChildren(U){const H=this._getOriginId(U),te=this._getOriginZoom(U),ye="No cluster with the specified id.",Ee=this.trees[te];if(!Ee)throw new Error(ye);const ze=Ee.data;if(H*this.stride>=ze.length)throw new Error(ye);const tt=this.options.radius/(this.options.extent*Math.pow(2,te-1)),xe=Ee.within(ze[H*this.stride],ze[H*this.stride+1],tt),rt=[];for(const Ye of xe){const ot=Ye*this.stride;ze[ot+4]===U&&rt.push(ze[ot+5]>1?ki(ze,ot,this.clusterProps):this.points[ze[ot+3]])}if(0===rt.length)throw new Error(ye);return rt}getLeaves(U,H,te){const ye=[];return this._appendLeaves(ye,U,H=H||10,te=te||0,0),ye}getTile(U,H,te){const ye=this.trees[this._limitZoom(U)],Ee=Math.pow(2,U),{extent:ze,radius:tt}=this.options,xe=tt/ze,rt=(te-xe)/Ee,Ye=(te+1+xe)/Ee,ot={features:[]};return this._addTileFeatures(ye.range((H-xe)/Ee,rt,(H+1+xe)/Ee,Ye),ye.data,H,te,Ee,ot),0===H&&this._addTileFeatures(ye.range(1-xe/Ee,rt,1,Ye),ye.data,Ee,te,Ee,ot),H===Ee-1&&this._addTileFeatures(ye.range(0,rt,xe/Ee,Ye),ye.data,-1,te,Ee,ot),ot.features.length?ot:null}getClusterExpansionZoom(U){let H=this._getOriginZoom(U)-1;for(;H<=this.options.maxZoom;){const te=this.getChildren(U);if(H++,1!==te.length)break;U=te[0].properties.cluster_id}return H}_appendLeaves(U,H,te,ye,Ee){const ze=this.getChildren(H);for(const tt of ze){const xe=tt.properties;if(xe&&xe.cluster?Ee+xe.point_count<=ye?Ee+=xe.point_count:Ee=this._appendLeaves(U,xe.cluster_id,te,ye,Ee):Ee<ye?Ee++:U.push(tt),U.length===te)break}return Ee}_createTree(U){const H=new a.bg(U.length/this.stride|0,this.options.nodeSize,Float32Array);for(let te=0;te<U.length;te+=this.stride)H.add(U[te],U[te+1]);return H.finish(),H.data=U,H}_addTileFeatures(U,H,te,ye,Ee,ze){for(const tt of U){const xe=tt*this.stride,rt=H[xe+5]>1;let Ye,ot,Lt;if(rt)Ye=Gr(H,xe,this.clusterProps),ot=H[xe],Lt=H[xe+1];else{const di=this.points[H[xe+3]];Ye=di.properties;const[ai,ri]=di.geometry.coordinates;ot=So(ai),Lt=Sn(ri)}const ui={type:1,geometry:[[Math.round(this.options.extent*(ot*Ee-te)),Math.round(this.options.extent*(Lt*Ee-ye))]],tags:Ye};let bi;bi=rt||this.options.generateId?H[xe+3]:this.points[H[xe+3]].id,void 0!==bi&&(ui.id=bi),ze.features.push(ui)}}_limitZoom(U){return Math.max(this.options.minZoom,Math.min(Math.floor(+U),this.options.maxZoom+1))}_cluster(U,H){const{radius:te,extent:ye,reduce:Ee,minPoints:ze}=this.options,tt=te/(ye*Math.pow(2,H)),xe=U.data,rt=[],Ye=this.stride;for(let ot=0;ot<xe.length;ot+=Ye){if(xe[ot+2]<=H)continue;xe[ot+2]=H;const Lt=xe[ot],ui=xe[ot+1],bi=U.within(xe[ot],xe[ot+1],tt),di=xe[ot+5];let ai=di;for(const ri of bi){const ci=ri*Ye;xe[ci+2]>H&&(ai+=xe[ci+5])}if(ai>di&&ai>=ze){let ri,ci=Lt*di,gi=ui*di,Ki=-1;const vi=(ot/Ye<<5)+(H+1)+this.points.length;for(const vr of bi){const _r=vr*Ye;if(xe[_r+2]<=H)continue;xe[_r+2]=H;const Er=xe[_r+5];ci+=xe[_r]*Er,gi+=xe[_r+1]*Er,xe[_r+4]=vi,Ee&&(ri||(ri=this._map(xe,ot,!0),Ki=this.clusterProps.length,this.clusterProps.push(ri)),Ee(ri,this._map(xe,_r)))}xe[ot+4]=vi,rt.push(ci/ai,gi/ai,1/0,vi,-1,ai),Ee&&rt.push(Ki)}else{for(let ri=0;ri<Ye;ri++)rt.push(xe[ot+ri]);if(ai>1)for(const ri of bi){const ci=ri*Ye;if(!(xe[ci+2]<=H)){xe[ci+2]=H;for(let gi=0;gi<Ye;gi++)rt.push(xe[ci+gi])}}}}return rt}_getOriginId(U){return U-this.points.length>>5}_getOriginZoom(U){return(U-this.points.length)%32}_map(U,H,te){if(U[H+5]>1){const ze=this.clusterProps[U[H+6]];return te?Object.assign({},ze):ze}const ye=this.points[U[H+3]].properties,Ee=this.options.map(ye);return te&&Ee===ye?Object.assign({},Ee):Ee}}function ki(Te,U,H){return{type:"Feature",id:Te[U+3],properties:Gr(Te,U,H),geometry:{type:"Point",coordinates:[(te=Te[U],360*(te-.5)),yn(Te[U+1])]}};var te}function Gr(Te,U,H){const te=Te[U+5],ye=te>=1e4?`${Math.round(te/1e3)}k`:te>=1e3?Math.round(te/100)/10+"k":te,Ee=Te[U+6],ze=-1===Ee?{}:Object.assign({},H[Ee]);return Object.assign(ze,{cluster:!0,cluster_id:Te[U+3],point_count:te,point_count_abbreviated:ye})}function So(Te){return Te/360+.5}function Sn(Te){const U=Math.sin(Te*Math.PI/180),H=.5-.25*Math.log((1+U)/(1-U))/Math.PI;return H<0?0:H>1?1:H}function yn(Te){const U=(180-360*Te)*Math.PI/180;return 360*Math.atan(Math.exp(U))/Math.PI-90}var Ao={exports:{}};Ao.exports=function(){function Te(ge,ve,De,Ne){for(var ke,Ge=Ne,Ze=De-ve>>1,Be=De-ve,We=ge[ve],Ve=ge[ve+1],_t=ge[De],Vt=ge[De+1],lt=ve+3;lt<De;lt+=3){var pi=U(ge[lt],ge[lt+1],We,Ve,_t,Vt);if(pi>Ge)ke=lt,Ge=pi;else if(pi===Ge){var Mi=Math.abs(lt-Ze);Mi<Be&&(ke=lt,Be=Mi)}}Ge>Ne&&(ke-ve>3&&Te(ge,ve,ke,Ne),ge[ke+2]=Ge,De-ke>3&&Te(ge,ke,De,Ne))}function U(ge,ve,De,Ne,ke,Ge){var Ze=ke-De,Be=Ge-Ne;if(0!==Ze||0!==Be){var We=((ge-De)*Ze+(ve-Ne)*Be)/(Ze*Ze+Be*Be);We>1?(De=ke,Ne=Ge):We>0&&(De+=Ze*We,Ne+=Be*We)}return(Ze=ge-De)*Ze+(Be=ve-Ne)*Be}function H(ge,ve,De,Ne){var ke={id:void 0===ge?null:ge,type:ve,geometry:De,tags:Ne,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Ge){var Ze=Ge.geometry,Be=Ge.type;if("Point"===Be||"MultiPoint"===Be||"LineString"===Be)te(Ge,Ze);else if("Polygon"===Be||"MultiLineString"===Be)for(var We=0;We<Ze.length;We++)te(Ge,Ze[We]);else if("MultiPolygon"===Be)for(We=0;We<Ze.length;We++)for(var Ve=0;Ve<Ze[We].length;Ve++)te(Ge,Ze[We][Ve])}(ke),ke}function te(ge,ve){for(var De=0;De<ve.length;De+=3)ge.minX=Math.min(ge.minX,ve[De]),ge.minY=Math.min(ge.minY,ve[De+1]),ge.maxX=Math.max(ge.maxX,ve[De]),ge.maxY=Math.max(ge.maxY,ve[De+1])}function ye(ge,ve,De,Ne){if(ve.geometry){var ke=ve.geometry.coordinates,Ge=ve.geometry.type,Ze=Math.pow(De.tolerance/((1<<De.maxZoom)*De.extent),2),Be=[],We=ve.id;if(De.promoteId?We=ve.properties[De.promoteId]:De.generateId&&(We=Ne||0),"Point"===Ge)Ee(ke,Be);else if("MultiPoint"===Ge)for(var Ve=0;Ve<ke.length;Ve++)Ee(ke[Ve],Be);else if("LineString"===Ge)ze(ke,Be,Ze,!1);else if("MultiLineString"===Ge){if(De.lineMetrics){for(Ve=0;Ve<ke.length;Ve++)ze(ke[Ve],Be=[],Ze,!1),ge.push(H(We,"LineString",Be,ve.properties));return}tt(ke,Be,Ze,!1)}else if("Polygon"===Ge)tt(ke,Be,Ze,!0);else{if("MultiPolygon"!==Ge){if("GeometryCollection"===Ge){for(Ve=0;Ve<ve.geometry.geometries.length;Ve++)ye(ge,{id:We,geometry:ve.geometry.geometries[Ve],properties:ve.properties},De,Ne);return}throw new Error("Input data is not a valid GeoJSON object.")}for(Ve=0;Ve<ke.length;Ve++){var _t=[];tt(ke[Ve],_t,Ze,!0),Be.push(_t)}}ge.push(H(We,Ge,Be,ve.properties))}}function Ee(ge,ve){ve.push(xe(ge[0])),ve.push(rt(ge[1])),ve.push(0)}function ze(ge,ve,De,Ne){for(var ke,Ge,Ze=0,Be=0;Be<ge.length;Be++){var We=xe(ge[Be][0]),Ve=rt(ge[Be][1]);ve.push(We),ve.push(Ve),ve.push(0),Be>0&&(Ze+=Ne?(ke*Ve-We*Ge)/2:Math.sqrt(Math.pow(We-ke,2)+Math.pow(Ve-Ge,2))),ke=We,Ge=Ve}var _t=ve.length-3;ve[2]=1,Te(ve,0,_t,De),ve[_t+2]=1,ve.size=Math.abs(Ze),ve.start=0,ve.end=ve.size}function tt(ge,ve,De,Ne){for(var ke=0;ke<ge.length;ke++){var Ge=[];ze(ge[ke],Ge,De,Ne),ve.push(Ge)}}function xe(ge){return ge/360+.5}function rt(ge){var ve=Math.sin(ge*Math.PI/180),De=.5-.25*Math.log((1+ve)/(1-ve))/Math.PI;return De<0?0:De>1?1:De}function Ye(ge,ve,De,Ne,ke,Ge,Ze,Be){if(Ne/=ve,Ge>=(De/=ve)&&Ze<Ne)return ge;if(Ze<De||Ge>=Ne)return null;for(var We=[],Ve=0;Ve<ge.length;Ve++){var _t=ge[Ve],Vt=_t.geometry,lt=_t.type,pi=0===ke?_t.minX:_t.minY,Mi=0===ke?_t.maxX:_t.maxY;if(pi>=De&&Mi<Ne)We.push(_t);else if(!(Mi<De||pi>=Ne)){var Di=[];if("Point"===lt||"MultiPoint"===lt)ot(Vt,Di,De,Ne,ke);else if("LineString"===lt)Lt(Vt,Di,De,Ne,ke,!1,Be.lineMetrics);else if("MultiLineString"===lt)bi(Vt,Di,De,Ne,ke,!1);else if("Polygon"===lt)bi(Vt,Di,De,Ne,ke,!0);else if("MultiPolygon"===lt)for(var qi=0;qi<Vt.length;qi++){var sr=[];bi(Vt[qi],sr,De,Ne,ke,!0),sr.length&&Di.push(sr)}if(Di.length){if(Be.lineMetrics&&"LineString"===lt){for(qi=0;qi<Di.length;qi++)We.push(H(_t.id,lt,Di[qi],_t.tags));continue}"LineString"!==lt&&"MultiLineString"!==lt||(1===Di.length?(lt="LineString",Di=Di[0]):lt="MultiLineString"),"Point"!==lt&&"MultiPoint"!==lt||(lt=3===Di.length?"Point":"MultiPoint"),We.push(H(_t.id,lt,Di,_t.tags))}}}return We.length?We:null}function ot(ge,ve,De,Ne,ke){for(var Ge=0;Ge<ge.length;Ge+=3){var Ze=ge[Ge+ke];Ze>=De&&Ze<=Ne&&(ve.push(ge[Ge]),ve.push(ge[Ge+1]),ve.push(ge[Ge+2]))}}function Lt(ge,ve,De,Ne,ke,Ge,Ze){for(var Be,We,Ve=ui(ge),_t=0===ke?ai:ri,Vt=ge.start,lt=0;lt<ge.length-3;lt+=3){var pi=ge[lt],Mi=ge[lt+1],Di=ge[lt+2],qi=ge[lt+3],sr=ge[lt+4],ti=0===ke?pi:Mi,Br=0===ke?qi:sr,rn=!1;Ze&&(Be=Math.sqrt(Math.pow(pi-qi,2)+Math.pow(Mi-sr,2))),ti<De?Br>De&&(We=_t(Ve,pi,Mi,qi,sr,De),Ze&&(Ve.start=Vt+Be*We)):ti>Ne?Br<Ne&&(We=_t(Ve,pi,Mi,qi,sr,Ne),Ze&&(Ve.start=Vt+Be*We)):di(Ve,pi,Mi,Di),Br<De&&ti>=De&&(We=_t(Ve,pi,Mi,qi,sr,De),rn=!0),Br>Ne&&ti<=Ne&&(We=_t(Ve,pi,Mi,qi,sr,Ne),rn=!0),!Ge&&rn&&(Ze&&(Ve.end=Vt+Be*We),ve.push(Ve),Ve=ui(ge)),Ze&&(Vt+=Be)}var ar=ge.length-3;pi=ge[ar],Mi=ge[ar+1],Di=ge[ar+2],(ti=0===ke?pi:Mi)>=De&&ti<=Ne&&di(Ve,pi,Mi,Di),ar=Ve.length-3,Ge&&ar>=3&&(Ve[ar]!==Ve[0]||Ve[ar+1]!==Ve[1])&&di(Ve,Ve[0],Ve[1],Ve[2]),Ve.length&&ve.push(Ve)}function ui(ge){var ve=[];return ve.size=ge.size,ve.start=ge.start,ve.end=ge.end,ve}function bi(ge,ve,De,Ne,ke,Ge){for(var Ze=0;Ze<ge.length;Ze++)Lt(ge[Ze],ve,De,Ne,ke,Ge,!1)}function di(ge,ve,De,Ne){ge.push(ve),ge.push(De),ge.push(Ne)}function ai(ge,ve,De,Ne,ke,Ge){var Ze=(Ge-ve)/(Ne-ve);return ge.push(Ge),ge.push(De+(ke-De)*Ze),ge.push(1),Ze}function ri(ge,ve,De,Ne,ke,Ge){var Ze=(Ge-De)/(ke-De);return ge.push(ve+(Ne-ve)*Ze),ge.push(Ge),ge.push(1),Ze}function ci(ge,ve){for(var De=[],Ne=0;Ne<ge.length;Ne++){var ke,Ge=ge[Ne],Ze=Ge.type;if("Point"===Ze||"MultiPoint"===Ze||"LineString"===Ze)ke=gi(Ge.geometry,ve);else if("MultiLineString"===Ze||"Polygon"===Ze){ke=[];for(var Be=0;Be<Ge.geometry.length;Be++)ke.push(gi(Ge.geometry[Be],ve))}else if("MultiPolygon"===Ze)for(ke=[],Be=0;Be<Ge.geometry.length;Be++){for(var We=[],Ve=0;Ve<Ge.geometry[Be].length;Ve++)We.push(gi(Ge.geometry[Be][Ve],ve));ke.push(We)}De.push(H(Ge.id,Ze,ke,Ge.tags))}return De}function gi(ge,ve){var De=[];De.size=ge.size,void 0!==ge.start&&(De.start=ge.start,De.end=ge.end);for(var Ne=0;Ne<ge.length;Ne+=3)De.push(ge[Ne]+ve,ge[Ne+1],ge[Ne+2]);return De}function Ki(ge,ve){if(ge.transformed)return ge;var De,Ne,ke,Ge=1<<ge.z,Ze=ge.x,Be=ge.y;for(De=0;De<ge.features.length;De++){var We=ge.features[De],Ve=We.geometry,_t=We.type;if(We.geometry=[],1===_t)for(Ne=0;Ne<Ve.length;Ne+=2)We.geometry.push(vi(Ve[Ne],Ve[Ne+1],ve,Ge,Ze,Be));else for(Ne=0;Ne<Ve.length;Ne++){var Vt=[];for(ke=0;ke<Ve[Ne].length;ke+=2)Vt.push(vi(Ve[Ne][ke],Ve[Ne][ke+1],ve,Ge,Ze,Be));We.geometry.push(Vt)}}return ge.transformed=!0,ge}function vi(ge,ve,De,Ne,ke,Ge){return[Math.round(De*(ge*Ne-ke)),Math.round(De*(ve*Ne-Ge))]}function vr(ge,ve,De,Ne,ke){for(var Ge=ve===ke.maxZoom?0:ke.tolerance/((1<<ve)*ke.extent),Ze={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:De,y:Ne,z:ve,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Be=0;Be<ge.length;Be++){Ze.numFeatures++,_r(Ze,ge[Be],Ge,ke);var We=ge[Be].minX,Ve=ge[Be].minY,_t=ge[Be].maxX,Vt=ge[Be].maxY;We<Ze.minX&&(Ze.minX=We),Ve<Ze.minY&&(Ze.minY=Ve),_t>Ze.maxX&&(Ze.maxX=_t),Vt>Ze.maxY&&(Ze.maxY=Vt)}return Ze}function _r(ge,ve,De,Ne){var ke=ve.geometry,Ge=ve.type,Ze=[];if("Point"===Ge||"MultiPoint"===Ge)for(var Be=0;Be<ke.length;Be+=3)Ze.push(ke[Be]),Ze.push(ke[Be+1]),ge.numPoints++,ge.numSimplified++;else if("LineString"===Ge)Er(Ze,ke,ge,De,!1,!1);else if("MultiLineString"===Ge||"Polygon"===Ge)for(Be=0;Be<ke.length;Be++)Er(Ze,ke[Be],ge,De,"Polygon"===Ge,0===Be);else if("MultiPolygon"===Ge)for(var We=0;We<ke.length;We++){var Ve=ke[We];for(Be=0;Be<Ve.length;Be++)Er(Ze,Ve[Be],ge,De,!0,0===Be)}if(Ze.length){var _t=ve.tags||null;if("LineString"===Ge&&Ne.lineMetrics){for(var Vt in _t={},ve.tags)_t[Vt]=ve.tags[Vt];_t.mapbox_clip_start=ke.start/ke.size,_t.mapbox_clip_end=ke.end/ke.size}var lt={geometry:Ze,type:"Polygon"===Ge||"MultiPolygon"===Ge?3:"LineString"===Ge||"MultiLineString"===Ge?2:1,tags:_t};null!==ve.id&&(lt.id=ve.id),ge.features.push(lt)}}function Er(ge,ve,De,Ne,ke,Ge){var Ze=Ne*Ne;if(Ne>0&&ve.size<(ke?Ze:Ne))De.numPoints+=ve.length/3;else{for(var Be=[],We=0;We<ve.length;We+=3)(0===Ne||ve[We+2]>Ze)&&(De.numSimplified++,Be.push(ve[We]),Be.push(ve[We+1])),De.numPoints++;ke&&function(Ve,_t){for(var Vt=0,lt=0,pi=Ve.length,Mi=pi-2;lt<pi;Mi=lt,lt+=2)Vt+=(Ve[lt]-Ve[Mi])*(Ve[lt+1]+Ve[Mi+1]);if(Vt>0===_t)for(lt=0,pi=Ve.length;lt<pi/2;lt+=2){var Di=Ve[lt],qi=Ve[lt+1];Ve[lt]=Ve[pi-2-lt],Ve[lt+1]=Ve[pi-1-lt],Ve[pi-2-lt]=Di,Ve[pi-1-lt]=qi}}(Be,Ge),ge.push(Be)}}function Zi(ge,ve){var De=(ve=this.options=function(ke,Ge){for(var Ze in Ge)ke[Ze]=Ge[Ze];return ke}(Object.create(this.options),ve)).debug;if(De&&console.time("preprocess data"),ve.maxZoom<0||ve.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(ve.promoteId&&ve.generateId)throw new Error("promoteId and generateId cannot be used together.");var ke,Ge,Ze,Be,We,Ve,Ne=function(ke,Ge){var Ze=[];if("FeatureCollection"===ke.type)for(var Be=0;Be<ke.features.length;Be++)ye(Ze,ke.features[Be],Ge,Be);else ye(Ze,"Feature"===ke.type?ke:{geometry:ke},Ge);return Ze}(ge,ve);this.tiles={},this.tileCoords=[],De&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",ve.indexMaxZoom,ve.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(ke=Ne,Ge=ve,Ze=Ge.buffer/Ge.extent,Be=ke,We=Ye(ke,1,-1-Ze,Ze,0,-1,2,Ge),Ve=Ye(ke,1,1-Ze,2+Ze,0,-1,2,Ge),(We||Ve)&&(Be=Ye(ke,1,-Ze,1+Ze,0,-1,2,Ge)||[],We&&(Be=ci(We,1).concat(Be)),Ve&&(Be=Be.concat(ci(Ve,-1)))),Ne=Be).length&&this.splitTile(Ne,0,0,0),De&&(Ne.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 Ui(ge,ve,De){return 32*((1<<ge)*De+ve)+ge}return Zi.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Zi.prototype.splitTile=function(ge,ve,De,Ne,ke,Ge,Ze){for(var Be=[ge,ve,De,Ne],We=this.options,Ve=We.debug;Be.length;){Ne=Be.pop(),De=Be.pop(),ve=Be.pop(),ge=Be.pop();var _t=1<<ve,Vt=Ui(ve,De,Ne),lt=this.tiles[Vt];if(!lt&&(Ve>1&&console.time("creation"),lt=this.tiles[Vt]=vr(ge,ve,De,Ne,We),this.tileCoords.push({z:ve,x:De,y:Ne}),Ve)){Ve>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ve,De,Ne,lt.numFeatures,lt.numPoints,lt.numSimplified),console.timeEnd("creation"));var pi="z"+ve;this.stats[pi]=(this.stats[pi]||0)+1,this.total++}if(lt.source=ge,ke){if(ve===We.maxZoom||ve===ke)continue;var Mi=1<<ke-ve;if(De!==Math.floor(Ge/Mi)||Ne!==Math.floor(Ze/Mi))continue}else if(ve===We.indexMaxZoom||lt.numPoints<=We.indexMaxPoints)continue;if(lt.source=null,0!==ge.length){Ve>1&&console.time("clipping");var Di,qi,sr,ti,Br,rn,ar=.5*We.buffer/We.extent,qs=.5-ar,Yn=.5+ar,is=1+ar;Di=qi=sr=ti=null,Br=Ye(ge,_t,De-ar,De+Yn,0,lt.minX,lt.maxX,We),rn=Ye(ge,_t,De+qs,De+is,0,lt.minX,lt.maxX,We),ge=null,Br&&(Di=Ye(Br,_t,Ne-ar,Ne+Yn,1,lt.minY,lt.maxY,We),qi=Ye(Br,_t,Ne+qs,Ne+is,1,lt.minY,lt.maxY,We),Br=null),rn&&(sr=Ye(rn,_t,Ne-ar,Ne+Yn,1,lt.minY,lt.maxY,We),ti=Ye(rn,_t,Ne+qs,Ne+is,1,lt.minY,lt.maxY,We),rn=null),Ve>1&&console.timeEnd("clipping"),Be.push(Di||[],ve+1,2*De,2*Ne),Be.push(qi||[],ve+1,2*De,2*Ne+1),Be.push(sr||[],ve+1,2*De+1,2*Ne),Be.push(ti||[],ve+1,2*De+1,2*Ne+1)}}},Zi.prototype.getTile=function(ge,ve,De){var Ne=this.options,ke=Ne.extent,Ge=Ne.debug;if(ge<0||ge>24)return null;var Ze=1<<ge,Be=Ui(ge,ve=(ve%Ze+Ze)%Ze,De);if(this.tiles[Be])return Ki(this.tiles[Be],ke);Ge>1&&console.log("drilling down to z%d-%d-%d",ge,ve,De);for(var We,Ve=ge,_t=ve,Vt=De;!We&&Ve>0;)Ve--,_t=Math.floor(_t/2),Vt=Math.floor(Vt/2),We=this.tiles[Ui(Ve,_t,Vt)];return We&&We.source?(Ge>1&&console.log("found parent tile z%d-%d-%d",Ve,_t,Vt),Ge>1&&console.time("drilling down"),this.splitTile(We.source,Ve,_t,Vt,ge,ve,De),Ge>1&&console.timeEnd("drilling down"),this.tiles[Be]?Ki(this.tiles[Be],ke):null):null},function(ge,ve){return new Zi(ge,ve)}}();var Vi=a.dK(Ao.exports);function es(Te,U){const H=Te.tileID.canonical;if(!this._geoJSONIndex)return U(null,null);const te=this._geoJSONIndex.getTile(H.z,H.x,H.y);if(!te)return U(null,null);const ye=new Ue(te.features);let Ee=Gs(ye);0===Ee.byteOffset&&Ee.byteLength===Ee.buffer.byteLength||(Ee=new Uint8Array(Ee)),U(null,{vectorTile:ye,rawData:Ee.buffer})}class ts extends bo{constructor(U,H,te,ye,Ee,ze){super(U,H,te,ye,es,ze),Ee&&(this.loadGeoJSON=Ee)}loadData(U,H){const te=U&&U.request,ye=te&&te.collectResourceTiming;this.loadGeoJSON(U,(Ee,ze)=>{if(Ee||!ze)return H(Ee);if("object"!=typeof ze)return H(new Error(`Input data given to '${U.source}' is not a valid GeoJSON object.`));{$n(ze,!0);try{if(U.filter){const xe=a.r(U.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===xe.result)throw new Error(xe.value.map(Ye=>`${Ye.key}: ${Ye.message}`).join(", "));ze={type:"FeatureCollection",features:ze.features.filter(Ye=>xe.value.evaluate({zoom:0},Ye))}}this._geoJSONIndex=U.cluster?new Ga(function({superclusterOptions:xe,clusterProperties:rt}){if(!rt||!xe)return xe;const Ye={},ot={},Lt={accumulated:null,zoom:0},ui={properties:null},bi=Object.keys(rt);for(const di of bi){const[ai,ri]=rt[di],ci=a.r(ri),gi=a.r("string"==typeof ai?[ai,["accumulated"],["get",di]]:ai);Ye[di]=ci.value,ot[di]=gi.value}return xe.map=di=>{ui.properties=di;const ai={};for(const ri of bi)ai[ri]=Ye[ri].evaluate(Lt,ui);return ai},xe.reduce=(di,ai)=>{ui.properties=ai;for(const ri of bi)Lt.accumulated=di[ri],di[ri]=ot[ri].evaluate(Lt,ui)},xe}(U)).load(ze.features):Vi(ze,U.geojsonVtOptions)}catch(xe){return H(xe)}this.loaded={};const tt={};if(ye){const xe=Pt(te);xe&&(tt.resourceTiming={},tt.resourceTiming[U.source]=JSON.parse(JSON.stringify(xe)))}H(null,tt)}})}reloadTile(U,H){const te=this.loaded;return te&&te[U.uid]?super.reloadTile(U,H):this.loadTile(U,H)}loadGeoJSON(U,H){if(U.request)a.g(U.request,H);else{if("string"!=typeof U.data)return H(new Error(`Input data given to '${U.source}' is not a valid GeoJSON object.`));try{return H(null,JSON.parse(U.data))}catch{return H(new Error(`Input data given to '${U.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(U,H){try{H(null,this._geoJSONIndex.getClusterExpansionZoom(U.clusterId))}catch(te){H(te)}}getClusterChildren(U,H){try{H(null,this._geoJSONIndex.getChildren(U.clusterId))}catch(te){H(te)}}getClusterLeaves(U,H){try{H(null,this._geoJSONIndex.getLeaves(U.clusterId,U.limit,U.offset))}catch(te){H(te)}}}class Zr{constructor(U,H){this.tileID=new a.am(U.tileID.overscaledZ,U.tileID.wrap,U.tileID.canonical.z,U.tileID.canonical.x,U.tileID.canonical.y),this.tileZoom=U.tileZoom,this.uid=U.uid,this.zoom=U.zoom,this.canonical=U.tileID.canonical,this.pixelRatio=U.pixelRatio,this.tileSize=U.tileSize,this.source=U.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=U.projection,this.brightness=H}parse(U,H,te,ye){this.status="parsing";const Ee=new a.am(te.tileID.overscaledZ,te.tileID.wrap,te.tileID.canonical.z,te.tileID.canonical.x,te.tileID.canonical.y),ze={},tt=H.familiesBySource[te.source],xe=new a.dC(Ee,te.promoteId);return xe.bucketLayerIDs=[],xe.is3DTile=!0,a.dP(U).then(rt=>{if(!rt)return ye(new Error("Could not parse tile"));const Ye=a.dQ(rt,1/a.bR(te.tileID.canonical)),ot=rt.json.extensionsUsed&&rt.json.extensionsUsed.includes("MAPBOX_mesh_features")||rt.json.asset.extras&&rt.json.asset.extras.MAPBOX_mesh_features,Lt=rt.json.extensionsUsed&&rt.json.extensionsUsed.includes("EXT_meshopt_compression"),ui=new a.K(this.zoom,{brightness:this.brightness});for(const bi in tt)for(const di of tt[bi]){const ai=di[0];xe.bucketLayerIDs.push(di.map(ci=>ci.id)),ai.recalculate(ui,[]);const ri=new a.dR(Ye,Ee,ot,Lt,this.brightness,xe);ot||(ri.needsUpload=!0),ze[ai.fqid]=ri,ri.evaluate(ai)}this.status="done",ye(null,{buckets:ze,featureIndex:xe})}).catch(rt=>ye(new Error(rt.message)))}}class An{constructor(U,H,te,ye,Ee,ze){this.actor=U,this.layerIndex=H,this.brightness=ze,this.loading={},this.loaded={}}loadTile(U,H){const te=U.uid,ye=this.loading[te]=new Zr(U,this.brightness);a.a_(U.request,(Ee,ze)=>{const tt=!this.loading[te];return delete this.loading[te],tt||Ee?(ye.status="done",tt||(this.loaded[te]=ye),H(Ee)):ze&&0!==ze.byteLength?void ye.parse(ze,this.layerIndex,U,(xe,rt)=>{ye.status="done",this.loaded=this.loaded||{},this.loaded[te]=ye,xe||!rt?H(xe):H(null,rt)}):(ye.status="done",this.loaded[te]=ye,H())})}reloadTile(U,H){const te=this.loaded,ye=U.uid;if(te&&te[ye]){const Ee=te[ye];Ee.projection=U.projection,Ee.brightness=U.brightness;const ze=(tt,xe)=>{Ee.reloadCallback&&(delete Ee.reloadCallback,this.loadTile(U,H)),H(tt,xe)};"parsing"===Ee.status?Ee.reloadCallback=ze:"done"===Ee.status&&this.loadTile(U,H)}}abortTile(U,H){const te=U.uid;this.loading[te]&&delete this.loading[te],H()}removeTile(U,H){const te=this.loaded,ye=U.uid;te&&te[ye]&&delete te[ye],H()}}class Xn{constructor(U){this.self=U,this.actor=new a.dS(U,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.bo({name:"mercator"}),this.workerSourceTypes={vector:bo,geojson:ts,"batched-model":An},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(H,te)=>{if(this.workerSourceTypes[H])throw new Error(`Worker source with name "${H}" already registered.`);this.workerSourceTypes[H]=te},this.self.registerRTLTextPlugin=H=>{if(a.dT.isParsed())throw new Error("RTL text plugin already registered.");a.dT.applyArabicShaping=H.applyArabicShaping,a.dT.processBidirectionalText=H.processBidirectionalText,a.dT.processStyledBidirectionalText=H.processStyledBidirectionalText}}clearCaches(U,H,te){delete this.layerIndexes[U],delete this.availableImages[U],delete this.workerSources[U],delete this.demWorkerSources[U],delete this.rasterArrayWorkerSource,te()}checkIfReady(U,H,te){te()}setReferrer(U,H){this.referrer=H}spriteLoaded(U,{scope:H,isLoaded:te}){if(this.isSpriteLoaded[U]||(this.isSpriteLoaded[U]={}),this.isSpriteLoaded[U][H]=te,this.workerSources[U]&&this.workerSources[U][H])for(const ye in this.workerSources[U][H]){const Ee=this.workerSources[U][H][ye];for(const ze in Ee)Ee[ze]instanceof bo&&(Ee[ze].isSpriteLoaded=te,Ee[ze].fire(new a.b("isSpriteLoaded")))}}setImages(U,{scope:H,images:te},ye){if(this.availableImages[U]||(this.availableImages[U]={}),this.availableImages[U][H]=te,this.workerSources[U]&&this.workerSources[U][H]){for(const Ee in this.workerSources[U][H]){const ze=this.workerSources[U][H][Ee];for(const tt in ze)ze[tt].availableImages=te}ye()}else ye()}setProjection(U,H){this.projections[U]=a.bo(H)}setBrightness(U,H,te){this.brightness=H,te()}setLayers(U,H,te){this.getLayerIndex(U,H.scope).replace(H.layers,H.options),te()}updateLayers(U,H,te){this.getLayerIndex(U,H.scope).update(H.layers,H.removedIds,H.options),te()}loadTile(U,H,te){H.projection=this.projections[U]||this.defaultProjection,this.getWorkerSource(U,H.type,H.source,H.scope).loadTile(H,te)}loadDEMTile(U,H,te){this.getDEMWorkerSource(U,H.source,H.scope).loadTile(H,te)}decodeRasterArray(U,H,te){this.getRasterArrayWorkerSource().decodeRasterArray(H,te)}reloadTile(U,H,te){H.projection=this.projections[U]||this.defaultProjection,this.getWorkerSource(U,H.type,H.source,H.scope).reloadTile(H,te)}abortTile(U,H,te){this.getWorkerSource(U,H.type,H.source,H.scope).abortTile(H,te)}removeTile(U,H,te){this.getWorkerSource(U,H.type,H.source,H.scope).removeTile(H,te)}removeSource(U,H,te){if(!(this.workerSources[U]&&this.workerSources[U][H.scope]&&this.workerSources[U][H.scope][H.type]&&this.workerSources[U][H.scope][H.type][H.source]))return;const ye=this.workerSources[U][H.scope][H.type][H.source];delete this.workerSources[U][H.scope][H.type][H.source],void 0!==ye.removeSource?ye.removeSource(H,te):te()}loadWorkerSource(U,H,te){try{this.self.importScripts(H.url),te()}catch(ye){te(ye.toString())}}syncRTLPluginState(U,H,te){try{a.dT.setState(H);const ye=a.dT.getPluginURL();if(a.dT.isLoaded()&&!a.dT.isParsed()&&null!=ye){this.self.importScripts(ye);const Ee=a.dT.isParsed();te(Ee?void 0:new Error(`RTL Text Plugin failed to import scripts from ${ye}`),Ee)}}catch(ye){te(ye.toString())}}setDracoUrl(U,H){this.dracoUrl=H}getAvailableImages(U,H){this.availableImages[U]||(this.availableImages[U]={});let te=this.availableImages[U][H];return te||(te=[]),te}getLayerIndex(U,H){this.layerIndexes[U]||(this.layerIndexes[U]={});let te=this.layerIndexes[U][H];return te||(te=this.layerIndexes[U][H]=new qn,te.scope=H),te}getWorkerSource(U,H,te,ye){return this.workerSources[U]||(this.workerSources[U]={}),this.workerSources[U][ye]||(this.workerSources[U][ye]={}),this.workerSources[U][ye][H]||(this.workerSources[U][ye][H]={}),this.isSpriteLoaded[U]||(this.isSpriteLoaded[U]={}),this.workerSources[U][ye][H][te]||(this.workerSources[U][ye][H][te]=new this.workerSourceTypes[H]({send:(ze,tt,xe,rt,Ye,ot)=>{this.actor.send(ze,tt,xe,U,Ye,ot)},scheduler:this.actor.scheduler},this.getLayerIndex(U,ye),this.getAvailableImages(U,ye),this.isSpriteLoaded[U][ye],void 0,this.brightness)),this.workerSources[U][ye][H][te]}getDEMWorkerSource(U,H,te){return this.demWorkerSources[U]||(this.demWorkerSources[U]={}),this.demWorkerSources[U][te]||(this.demWorkerSources[U][te]={}),this.demWorkerSources[U][te][H]||(this.demWorkerSources[U][te][H]=new Ua),this.demWorkerSources[U][te][H]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new kr),this.rasterArrayWorkerSource}enforceCacheSizeLimit(U,H){a.dU(H)}getWorkerPerformanceMetrics(U,H,te){te(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new Xn(self)),Xn}),Gd(0,function(a){function Pt(c,r){if(Array.isArray(c)){if(!Array.isArray(r)||c.length!==r.length)return!1;for(let o=0;o<c.length;o++)if(!Pt(c[o],r[o]))return!1;return!0}if("object"==typeof c&&null!==c&&null!==r){if("object"!=typeof r||Object.keys(c).length!==Object.keys(r).length)return!1;for(const o in c)if(!Pt(c[o],r[o]))return!1;return!0}return c===r}var Qr=zt;function zt(c){return r=c,!(typeof window>"u"||typeof document>"u"||!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var h,d,f=new Blob([""],{type:"text/javascript"}),g=URL.createObjectURL(f);try{d=new Worker(g),h=!0}catch{h=!1}return d&&d.terminate(),URL.revokeObjectURL(g),h}()||!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}()||(void 0===qn[o=r&&r.failIfMajorPerformanceCaveat]&&(qn[o]=function(h){var d,g,x,b,f=(g=h,x=document.createElement("canvas"),(b=Object.create(zt.webGLContextAttributes)).failIfMajorPerformanceCaveat=g,x.getContext("webgl2",b));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),!0===f.getShaderParameter(d,f.COMPILE_STATUS))}(o)),!qn[o]||document.documentMode));var r,o}var qn={};function Wt(c,r,o){const h=document.createElement(c);return null!=r&&(h.className=r),o&&o.appendChild(h),h}function Rr(c,r,o){const h=document.createElementNS("http://www.w3.org/2000/svg",c);for(const d of Object.keys(r))h.setAttributeNS(null,d,String(r[d]));return o&&o.appendChild(h),h}zt.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const _n=typeof document<"u"?document.documentElement&&document.documentElement.style:null,gn=_n&&void 0!==_n.userSelect?"userSelect":"WebkitUserSelect";let bo;function Ua(){_n&&gn&&(bo=_n[gn],_n[gn]="none")}function kr(){_n&&gn&&(_n[gn]=bo)}function Ko(c){c.preventDefault(),c.stopPropagation(),window.removeEventListener("click",Ko,!0)}function wo(){window.addEventListener("click",Ko,!0),window.setTimeout(()=>{window.removeEventListener("click",Ko,!0)},0)}function $n(c,r){const o=c.getBoundingClientRect();return Ue(c,o,r)}function Wn(c,r){const o=c.getBoundingClientRect(),h=[];for(let d=0;d<r.length;d++)h.push(Ue(c,o,r[d]));return h}function Mn(c){return void 0!==window.InstallTrigger&&2===c.button&&c.ctrlKey&&window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:c.button}function Ue(c,r,o){const h=c.offsetWidth===r.width?1:c.offsetWidth/r.width;return new a.P((o.clientX-r.left)*h,(o.clientY-r.top)*h)}class To{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(r,o){this._updatedSourceCaches[r]=o,this.setDirty()}discardSourceCacheUpdate(r){delete this._updatedSourceCaches[r]}updateLayer(r){const o=r.scope;this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._updatedLayers[o].add(r.id),this.setDirty()}removeLayer(r){const o=r.scope;this._removedLayers[o]=this._removedLayers[o]||{},this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._removedLayers[o][r.id]=r,this._updatedLayers[o].delete(r.id),this._updatedPaintProps.delete(r.fqid),this.setDirty()}getRemovedLayer(r){return this._removedLayers[r.scope]?this._removedLayers[r.scope][r.id]:null}discardLayerRemoval(r){this._removedLayers[r.scope]&&delete this._removedLayers[r.scope][r.id]}getLayerUpdatesByScope(){const r={};for(const o in this._updatedLayers)r[o]=r[o]||{},r[o].updatedIds=Array.from(this._updatedLayers[o].values());for(const o in this._removedLayers)r[o]=r[o]||{},r[o].removedIds=Object.keys(this._removedLayers[o]);return r}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(r){this._updatedPaintProps.add(r.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(r){this._updatedImages.add(r),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}class Us extends a.E{constructor(r){super(),this.requestManager=r,this.models={"":{}},this.numModelsLoading={}}loadModel(r,o){return a.l(this.requestManager.transformRequest(o,a.R.Model).url).then(h=>{if(!h)return;const d=a.c(h),f=new a.M(r,void 0,void 0,d);return f.computeBoundsAndApplyParent(),f}).catch(h=>{this.fire(new a.a(new Error(`Could not load model ${r} from ${o}: ${h.message}`)))})}load(r,o){this.models[o]||(this.models[o]={});const h=Object.keys(r);this.numModelsLoading[o]=(this.numModelsLoading[o]||0)+h.length;const d=[];for(const f of h)d.push(this.loadModel(f,r[f]));Promise.allSettled(d).then(f=>{for(let g=0;g<f.length;g++){const{status:x,value:b}=f[g];"fulfilled"===x&&b&&(this.models[o][h[g]]=b)}this.numModelsLoading[o]-=h.length,this.fire(new a.b("data",{dataType:"style"}))}).catch(f=>{this.fire(new a.a(new Error(`Could not load models: ${f.message}`)))})}isLoaded(){for(const r in this.numModelsLoading)if(this.numModelsLoading[r]>0)return!1;return!0}hasModel(r,o){return!!this.getModel(r,o)}getModel(r,o){return this.models[o]||(this.models[o]={}),this.models[o][r]}addModel(r,o,h){this.models[h]||(this.models[h]={}),this.hasModel(r,h)&&this.removeModel(r,h),this.load({[r]:this.requestManager.normalizeModelURL(o)},h)}addModels(r,o){const h={};for(const d in r)h[d]=this.requestManager.normalizeModelURL(r[d]);this.load(h,o)}removeModel(r,o){this.models[o]||(this.models[o]={});const h=this.models[o][r];delete this.models[o][r],h.destroy()}listModels(r){return this.models[r]||(this.models[r]={}),Object.keys(this.models[r])}upload(r,o){this.models[o]||(this.models[o]={});for(const h in this.models[o])this.models[o][h].upload(r.context)}}class qt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(r,o,h){const d=String(o);if(this.stateChanges[r]=this.stateChanges[r]||{},this.stateChanges[r][d]=this.stateChanges[r][d]||{},a.e(this.stateChanges[r][d],h),null===this.deletedStates[r]){this.deletedStates[r]={};for(const f in this.state[r])f!==d&&(this.deletedStates[r][f]=null)}else if(this.deletedStates[r]&&null===this.deletedStates[r][d]){this.deletedStates[r][d]={};for(const f in this.state[r][d])h[f]||(this.deletedStates[r][d][f]=null)}else for(const f in h)this.deletedStates[r]&&this.deletedStates[r][d]&&null===this.deletedStates[r][d][f]&&delete this.deletedStates[r][d][f]}removeFeatureState(r,o,h){if(null===this.deletedStates[r])return;const d=String(o);if(this.deletedStates[r]=this.deletedStates[r]||{},h&&void 0!==o)null!==this.deletedStates[r][d]&&(this.deletedStates[r][d]=this.deletedStates[r][d]||{},this.deletedStates[r][d][h]=null);else if(void 0!==o)if(this.stateChanges[r]&&this.stateChanges[r][d])for(h in this.deletedStates[r][d]={},this.stateChanges[r][d])this.deletedStates[r][d][h]=null;else this.deletedStates[r][d]=null;else this.deletedStates[r]=null}getState(r,o){const h=String(o),d=a.e({},(this.state[r]||{})[h],(this.stateChanges[r]||{})[h]);if(null===this.deletedStates[r])return{};if(this.deletedStates[r]){const f=this.deletedStates[r][o];if(null===f)return{};for(const g in f)delete d[g]}return d}initializeTileState(r,o){r.setFeatureState(this.state,o)}coalesceChanges(r,o){const h={};for(const d in this.stateChanges){this.state[d]=this.state[d]||{};const f={};for(const g in this.stateChanges[d])this.state[d][g]||(this.state[d][g]={}),a.e(this.state[d][g],this.stateChanges[d][g]),f[g]=this.state[d][g];h[d]=f}for(const d in this.deletedStates){this.state[d]=this.state[d]||{};const f={};if(null===this.deletedStates[d])for(const g in this.state[d])f[g]={},this.state[d][g]={};else for(const g in this.deletedStates[d]){if(null===this.deletedStates[d][g])this.state[d][g]={};else if(this.state[d][g])for(const x of Object.keys(this.deletedStates[d][g]))delete this.state[d][g][x];f[g]=this.state[d][g]}h[d]=h[d]||{},a.e(h[d],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(h).length)for(const d in r)r[d].setFeatureState(h,o)}}function dr(c){const{userImage:r}=c;return!!(r&&r.render&&r.render())&&(c.data.replace(new Uint8Array(r.data.buffer)),!0)}class ja extends a.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(r){this.images[r]={},this.loaded[r]=!1,this.updatedImages[r]={},this.patterns[r]={},this.callbackDispatchedThisFrame[r]={},this.atlasImage[r]=new a.h({width:1,height:1})}isLoaded(){for(const r in this.loaded)if(!this.loaded[r])return!1;return!0}setLoaded(r,o){if(this.loaded[o]!==r&&(this.loaded[o]=r,r)){for(const{ids:h,callback:d}of this.requestors)this._notify(h,o,d);this.requestors=[]}}hasImage(r,o){return!!this.getImage(r,o)}getImage(r,o){return this.images[o][r]}addImage(r,o,h){this._validate(r,h)&&(this.images[o][r]=h)}_validate(r,o){let h=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new a.a(new Error(`Image "${r}" has invalid "stretchX" value`))),h=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new a.a(new Error(`Image "${r}" has invalid "stretchY" value`))),h=!1),this._validateContent(o.content,o)||(this.fire(new a.a(new Error(`Image "${r}" has invalid "content" value`))),h=!1),h}_validateStretch(r,o){if(!r)return!0;let h=0;for(const d of r){if(d[0]<h||d[1]<d[0]||o<d[1])return!1;h=d[1]}return!0}_validateContent(r,o){return!(r&&(4!==r.length||r[0]<0||o.data.width<r[0]||r[1]<0||o.data.height<r[1]||r[2]<0||o.data.width<r[2]||r[3]<0||o.data.height<r[3]||r[2]<r[0]||r[3]<r[1]))}updateImage(r,o,h){h.version=this.images[o][r].version+1,this.images[o][r]=h,this.updatedImages[o][r]=!0}removeImage(r,o){const h=this.images[o][r];delete this.images[o][r],delete this.patterns[o][r],h.userImage&&h.userImage.onRemove&&h.userImage.onRemove()}listImages(r){return Object.keys(this.images[r])}getImages(r,o,h){let d=!0;const f=!!this.loaded[o];if(!f)for(const g of r)this.images[o][g]||(d=!1);f||d?this._notify(r,o,h):this.requestors.push({ids:r,scope:o,callback:h})}getUpdatedImages(r){return this.updatedImages[r]}_notify(r,o,h){const d={};for(const f of r){this.images[o][f]||this.fire(new a.b("styleimagemissing",{id:f}));const g=this.images[o][f];g?d[f]={data:g.data.clone(),pixelRatio:g.pixelRatio,sdf:g.sdf,version:g.version,stretchX:g.stretchX,stretchY:g.stretchY,content:g.content,hasRenderCallback:!(!g.userImage||!g.userImage.render)}:a.w(`Image "${f}" 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.`)}h(null,d)}getPixelSize(r){const{width:o,height:h}=this.atlasImage[r];return{width:o,height:h}}getPattern(r,o){const h=this.patterns[o][r],d=this.getImage(r,o);if(!d)return null;if(h&&h.position.version===d.version)return h.position;if(h)h.position.version=d.version;else{const f={w:d.data.width+2,h:d.data.height+2,x:0,y:0},g=new a.I(f,d);this.patterns[o][r]={bin:f,position:g}}return this._updatePatternAtlas(o),this.patterns[o][r].position}bind(r,o){const h=r.gl;let d=this.atlasTexture[o];d?this.dirty&&(d.update(this.atlasImage[o]),this.dirty=!1):(d=new a.T(r,this.atlasImage[o],h.RGBA),this.atlasTexture[o]=d),d.bind(h.LINEAR,h.CLAMP_TO_EDGE)}_updatePatternAtlas(r){const o=[];for(const g in this.patterns[r])o.push(this.patterns[r][g].bin);const{w:h,h:d}=a.p(o),f=this.atlasImage[r];f.resize({width:h||1,height:d||1});for(const g in this.patterns[r]){const{bin:x}=this.patterns[r][g],b=x.x+1,T=x.y+1,M=this.images[r][g].data,S=M.width,C=M.height;a.h.copy(M,f,{x:0,y:0},{x:b,y:T},{width:S,height:C}),a.h.copy(M,f,{x:0,y:C-1},{x:b,y:T-1},{width:S,height:1}),a.h.copy(M,f,{x:0,y:0},{x:b,y:T+C},{width:S,height:1}),a.h.copy(M,f,{x:S-1,y:0},{x:b-1,y:T},{width:1,height:C}),a.h.copy(M,f,{x:0,y:0},{x:b+S,y:T},{width:1,height:C})}this.dirty=!0}beginFrame(){for(const r in this.images)this.callbackDispatchedThisFrame[r]={}}dispatchRenderCallbacks(r,o){for(const h of r){if(this.callbackDispatchedThisFrame[o][h])continue;this.callbackDispatchedThisFrame[o][h]=!0;const d=this.images[o][h];dr(d)&&this.updateImage(h,o,d)}}}class $e{constructor(r,o,h,d){this.message=(r?`${r}: `:"")+h,d&&(this.identifier=d),null!=o&&o.__line__&&(this.line=o.__line__)}}class en extends $e{}function xr(c){const r=c.key,o=c.value,h=c.valueSpec||{},d=c.objectElementValidators||{},f=c.style,g=c.styleSpec;let x=[];const b=a.i(o);if("object"!==b)return[new $e(r,o,`object expected, ${b} found`)];for(const T in o){const M=T.split(".")[0];let S;d[M]?S=d[M]:h[M]?S=Vi:d["*"]?S=d["*"]:h["*"]&&(S=Vi),S?x=x.concat(S({key:(r&&`${r}.`)+T,value:o[T],valueSpec:h[M]||h["*"],style:f,styleSpec:g,object:o,objectKey:T},o)):x.push(new en(r,o[T],`unknown property "${T}"`))}for(const T in h)d[T]||h[T].required&&void 0===h[T].default&&void 0===o[T]&&x.push(new $e(r,o,`missing required property "${T}"`));return x}function Dt(c){const r=c.value,o=c.valueSpec,h=c.style,d=c.styleSpec,f=c.key,g=c.arrayElementValidator||Vi;if("array"!==a.i(r))return[new $e(f,r,`array expected, ${a.i(r)} found`)];if(o.length&&r.length!==o.length)return[new $e(f,r,`array length ${o.length} expected, length ${r.length} found`)];if(o["min-length"]&&r.length<o["min-length"])return[new $e(f,r,`array length at least ${o["min-length"]} expected, length ${r.length} found`)];let x={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};d.$version<7&&(x.function=o.function),"object"===a.i(o.value)&&(x=o.value);let b=[];for(let T=0;T<r.length;T++)b=b.concat(g({array:r,arrayIndex:T,value:r[T],valueSpec:x,style:h,styleSpec:d,key:`${f}[${T}]`},!0));return b}function Jo(c){const r=c.key,o=c.value,h=c.valueSpec;let d=a.i(o);if("number"===d&&o!=o&&(d="NaN"),"number"!==d)return[new $e(r,o,`number expected, ${d} found`)];if("minimum"in h){let f=h.minimum;if("array"===a.i(h.minimum)&&(f=h.minimum[c.arrayIndex]),o<f)return[new $e(r,o,`${o} is less than the minimum value ${f}`)]}if("maximum"in h){let f=h.maximum;if("array"===a.i(h.maximum)&&(f=h.maximum[c.arrayIndex]),o>f)return[new $e(r,o,`${o} is greater than the maximum value ${f}`)]}return[]}function Hn(c){const r=c.valueSpec,o=a.u(c.value.type);let h,d,f,g={};const x="categorical"!==o&&void 0===c.value.property,b=!x,T="array"===a.i(c.value.stops)&&"array"===a.i(c.value.stops[0])&&"object"===a.i(c.value.stops[0][0]),M=xr({key:c.key,value:c.value,valueSpec:c.styleSpec.function,style:c.style,styleSpec:c.styleSpec,objectElementValidators:{stops:function(P){if("identity"===o)return[new $e(P.key,P.value,'identity function may not have a "stops" property')];let k=[];const R=P.value;return k=k.concat(Dt({key:P.key,value:R,valueSpec:P.valueSpec,style:P.style,styleSpec:P.styleSpec,arrayElementValidator:S})),"array"===a.i(R)&&0===R.length&&k.push(new $e(P.key,R,"array must have at least one stop")),k},default:function(P){return Vi({key:P.key,value:P.value,valueSpec:r,style:P.style,styleSpec:P.styleSpec})}}});return"identity"===o&&x&&M.push(new $e(c.key,c.value,'missing required property "property"')),"identity"===o||c.value.stops||M.push(new $e(c.key,c.value,'missing required property "stops"')),"exponential"===o&&c.valueSpec.expression&&!a.s(c.valueSpec)&&M.push(new $e(c.key,c.value,"exponential functions not supported")),c.styleSpec.$version>=8&&(b&&!a.k(c.valueSpec)?M.push(new $e(c.key,c.value,"property functions not supported")):x&&!a.m(c.valueSpec)&&M.push(new $e(c.key,c.value,"zoom functions not supported"))),"categorical"!==o&&!T||void 0!==c.value.property||M.push(new $e(c.key,c.value,'"property" property is required')),M;function S(P){let k=[];const R=P.value,O=P.key;if("array"!==a.i(R))return[new $e(O,R,`array expected, ${a.i(R)} found`)];if(2!==R.length)return[new $e(O,R,`array length 2 expected, length ${R.length} found`)];if(T){if("object"!==a.i(R[0]))return[new $e(O,R,`object expected, ${a.i(R[0])} found`)];if(void 0===R[0].zoom)return[new $e(O,R,"object stop key must have zoom")];if(void 0===R[0].value)return[new $e(O,R,"object stop key must have value")];const D=a.u(R[0].zoom);if("number"!=typeof D)return[new $e(O,R[0].zoom,"stop zoom values must be numbers")];if(f&&f>D)return[new $e(O,R[0].zoom,"stop zoom values must appear in ascending order")];D!==f&&(f=D,d=void 0,g={}),k=k.concat(xr({key:`${O}[0]`,value:R[0],valueSpec:{zoom:{}},style:P.style,styleSpec:P.styleSpec,objectElementValidators:{zoom:Jo,value:C}}))}else k=k.concat(C({key:`${O}[0]`,value:R[0],valueSpec:{},style:P.style,styleSpec:P.styleSpec},R));return a.n(a.o(R[1]))?k.concat([new $e(`${O}[1]`,R[1],"expressions are not allowed in function stops.")]):k.concat(Vi({key:`${O}[1]`,value:R[1],valueSpec:r,style:P.style,styleSpec:P.styleSpec}))}function C(P,k){const R=a.i(P.value),O=a.u(P.value),D=null!==P.value?P.value:k;if(h){if(R!==h)return[new $e(P.key,D,`${R} stop domain type must match previous stop domain type ${h}`)]}else h=R;if("number"!==R&&"string"!==R&&"boolean"!==R&&"number"!=typeof O&&"string"!=typeof O&&"boolean"!=typeof O)return[new $e(P.key,D,"stop domain value must be a number, string, or boolean")];if("number"!==R&&"categorical"!==o){let F=`number expected, ${R} found`;return a.k(r)&&void 0===o&&(F+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $e(P.key,D,F)]}return"categorical"!==o||"number"!==R||"number"==typeof O&&isFinite(O)&&Math.floor(O)===O?"categorical"!==o&&"number"===R&&"number"==typeof O&&"number"==typeof d&&void 0!==d&&O<d?[new $e(P.key,D,"stop domain values must appear in ascending order")]:(d=O,"categorical"===o&&O in g?[new $e(P.key,D,"stop domain values must be unique")]:(g[O]=!0,[])):[new $e(P.key,D,`integer expected, found ${String(O)}`)]}}function tn(c){const r=("property"===c.expressionContext?a.q:a.r)(a.o(c.value),c.valueSpec);if("error"===r.result)return r.value.map(h=>new $e(`${c.key}${h.key}`,c.value,h.message));const o=r.value.expression||r.value._styleExpression.expression;if("property"===c.expressionContext&&"text-font"===c.propertyKey&&!o.outputDefined())return[new $e(c.key,c.value,`Invalid data expression for "${c.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===c.expressionContext&&"layout"===c.propertyType&&!a.t(o))return[new $e(c.key,c.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===c.expressionContext)return pr(o,c);if(c.expressionContext&&0===c.expressionContext.indexOf("cluster")){if(!a.v(o,["zoom","feature-state"]))return[new $e(c.key,c.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===c.expressionContext&&!a.x(o))return[new $e(c.key,c.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function pr(c,r){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(r.valueSpec&&r.valueSpec.expression)for(const d of r.valueSpec.expression.parameters)o.delete(d);if(0===o.size)return[];const h=[];return c instanceof a.C&&o.has(c.name)?[new $e(r.key,r.value,`["${c.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`)]:(c.eachChild(d=>{h.push(...pr(d,r))}),h)}function Mo(c){const r=c.key,o=c.value,h=c.valueSpec,d=[];return Array.isArray(h.values)?-1===h.values.indexOf(a.u(o))&&d.push(new $e(r,o,`expected one of [${h.values.join(", ")}], ${JSON.stringify(o)} found`)):-1===Object.keys(h.values).indexOf(a.u(o))&&d.push(new $e(r,o,`expected one of [${Object.keys(h.values).join(", ")}], ${JSON.stringify(o)} found`)),d}function Qo(c){return a.z(a.o(c.value))?tn(a.j({},c,{expressionContext:"filter",valueSpec:c.styleSpec[`filter_${c.layerType||"fill"}`]})):js(c)}function js(c){const r=c.value,o=c.key;if("array"!==a.i(r))return[new $e(o,r,`array expected, ${a.i(r)} found`)];const h=c.styleSpec;let d,f=[];if(r.length<1)return[new $e(o,r,"filter array must have at least 1 element")];switch(f=f.concat(Mo({key:`${o}[0]`,value:r[0],valueSpec:h.filter_operator,style:c.style,styleSpec:c.styleSpec})),a.u(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===a.u(r[1])&&f.push(new $e(o,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&f.push(new $e(o,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&(d=a.i(r[1]),"string"!==d&&f.push(new $e(`${o}[1]`,r[1],`string expected, ${d} found`)));for(let g=2;g<r.length;g++)d=a.i(r[g]),"$type"===a.u(r[1])?f=f.concat(Mo({key:`${o}[${g}]`,value:r[g],valueSpec:h.geometry_type,style:c.style,styleSpec:c.styleSpec})):"string"!==d&&"number"!==d&&"boolean"!==d&&f.push(new $e(`${o}[${g}]`,r[g],`string, number, or boolean expected, ${d} found`));break;case"any":case"all":case"none":for(let g=1;g<r.length;g++)f=f.concat(js({key:`${o}[${g}]`,value:r[g],style:c.style,styleSpec:c.styleSpec}));break;case"has":case"!has":d=a.i(r[1]),2!==r.length?f.push(new $e(o,r,`filter array for "${r[0]}" operator must have 2 elements`)):"string"!==d&&f.push(new $e(`${o}[1]`,r[1],`string expected, ${d} found`))}return f}function Gs(c,r){const o=c.key,h=c.style,d=c.layer,f=c.styleSpec,g=c.value,x=c.objectKey,b=f[`${r}_${c.layerType}`];if(!b)return[];const T=x.match(/^(.*)-transition$/);if("paint"===r&&T&&b[T[1]]&&b[T[1]].transition)return Vi({key:o,value:g,valueSpec:f.transition,style:h,styleSpec:f});const M=c.valueSpec||b[x];if(!M)return[new en(o,g,`unknown property "${x}"`)];let S;if("string"===a.i(g)&&a.k(M)&&!M.tokens&&(S=/^{([^}]+)}$/.exec(g))){const P=`\`{ "type": "identity", "property": ${S?JSON.stringify(S[1]):'"_"'} }\``;return[new $e(o,g,`"${x}" does not support interpolation syntax\nUse an identity property function instead: ${P}.`)]}const C=[];if("symbol"===c.layerType)"text-field"!==x||!h||h.glyphs||h.imports||C.push(new $e(o,g,'use of "text-field" requires a style "glyphs" property')),"text-font"===x&&a.A(a.o(g))&&"identity"===a.u(g.type)&&C.push(new $e(o,g,'"text-font" does not support identity functions'));else if("model"===c.layerType&&"paint"===r&&d&&d.layout&&d.layout.hasOwnProperty("model-id")&&a.k(M)&&(a.B(M)||a.m(M))){const P=a.q(a.o(g),M),k=P.value.expression||P.value._styleExpression.expression;k&&!a.v(k,["measure-light"])&&("model-emissive-strength"===x&&a.x(k)&&a.t(k)||C.push(new $e(o,g,`${x} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return C.concat(Vi({key:c.key,value:g,valueSpec:M,style:h,styleSpec:f,expressionContext:"property",propertyType:r,propertyKey:x}))}function Zs(c){return Gs(c,"paint")}function Eo(c){return Gs(c,"layout")}function En(c){let r=[];const o=c.value,h=c.key,d=c.style,f=c.styleSpec;o.type||o.ref||r.push(new $e(h,o,'either "type" or "ref" is required'));let g=a.u(o.type);const x=a.u(o.ref);if(o.id){const b=a.u(o.id);for(let T=0;T<c.arrayIndex;T++){const M=d.layers[T];a.u(M.id)===b&&r.push(new $e(h,o.id,`duplicate layer id "${o.id}", previously used at line ${M.id.__line__}`))}}if("ref"in o){let b;["type","source","source-layer","filter","layout"].forEach(T=>{T in o&&r.push(new $e(h,o[T],`"${T}" is prohibited for ref layers`))}),d.layers.forEach(T=>{a.u(T.id)===x&&(b=T)}),b?b.ref?r.push(new $e(h,o.ref,"ref cannot reference another ref layer")):g=a.u(b.type):"string"==typeof x&&r.push(new $e(h,o.ref,`ref layer "${x}" not found`))}else if("background"!==g&&"sky"!==g&&"slot"!==g)if(o.source){const b=d.sources&&d.sources[o.source],T=b&&a.u(b.type);b?"vector"===T&&"raster"===g?r.push(new $e(h,o.source,`layer "${o.id}" requires a raster source`)):"raster"===T&&"raster"!==g?r.push(new $e(h,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==T||o["source-layer"]?"raster-dem"===T&&"hillshade"!==g?r.push(new $e(h,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==T||["raster","raster-particle"].includes(g)?"line"!==g||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||"geojson"===T&&b.lineMetrics?"raster-particle"===g&&"raster-array"!==T&&r.push(new $e(h,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):r.push(new $e(h,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new $e(h,o.source,"raster-array source can only be used with layer type 'raster'.")):r.push(new $e(h,o,`layer "${o.id}" must specify a "source-layer"`)):r.push(new $e(h,o.source,`source "${o.source}" not found`))}else r.push(new $e(h,o,'missing required property "source"'));return r=r.concat(xr({key:h,value:o,valueSpec:f.layer,style:c.style,styleSpec:c.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Vi({key:`${h}.type`,value:o.type,valueSpec:f.layer.type,style:c.style,styleSpec:c.styleSpec,object:o,objectKey:"type"}),filter:b=>Qo(a.j({layerType:g},b)),layout:b=>xr({layer:o,key:b.key,value:b.value,valueSpec:{},style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":T=>Eo(a.j({layerType:g},T))}}),paint:b=>xr({layer:o,key:b.key,value:b.value,valueSpec:{},style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":T=>Zs(a.j({layerType:g,layer:o},T))}})}})),r}function fr(c){const r=c.value,o=c.key,h=a.i(r);return"string"!==h?[new $e(o,r,`string expected, ${h} found`)]:[]}const jr={promoteId:function({key:c,value:r}){if("string"===a.i(r))return fr({key:c,value:r});{const o=[];for(const h in r)o.push(...fr({key:`${c}.${h}`,value:r[h]}));return o}}};function Or(c){const r=c.value,o=c.key,h=c.styleSpec,d=c.style;if(!r.type)return[new $e(o,r,'"type" is required')];const f=a.u(r.type);let g=[];switch(["vector","raster","raster-dem","raster-array"].includes(f)&&(r.url||r.tiles||g.push(new en(o,r,'Either "url" or "tiles" is required.'))),f){case"vector":case"raster":case"raster-dem":case"raster-array":return g=g.concat(xr({key:o,value:r,valueSpec:h[`source_${f.replace("-","_")}`],style:c.style,styleSpec:h,objectElementValidators:jr})),g;case"geojson":if(g=xr({key:o,value:r,valueSpec:h.source_geojson,style:d,styleSpec:h,objectElementValidators:jr}),r.cluster)for(const x in r.clusterProperties){const[b,T]=r.clusterProperties[x],M="string"==typeof b?[b,["accumulated"],["get",x]]:b;g.push(...tn({key:`${o}.${x}.map`,value:T,expressionContext:"cluster-map"})),g.push(...tn({key:`${o}.${x}.reduce`,value:M,expressionContext:"cluster-reduce"}))}return g;case"video":return xr({key:o,value:r,valueSpec:h.source_video,style:d,styleSpec:h});case"image":return xr({key:o,value:r,valueSpec:h.source_image,style:d,styleSpec:h});case"canvas":return[new $e(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Mo({key:`${o}.type`,value:r.type,valueSpec:{values:Ga(h)},style:d,styleSpec:h})}}function Ga(c){return c.source.reduce((r,o)=>{const h=c[o];return"enum"===h.type.type&&(r=r.concat(Object.keys(h.type.values))),r},[])}function ki(c){const r=c.value;let o=[];if(!r)return o;const h=a.i(r);return"string"!==h?(o=o.concat([new $e(c.key,r,`string expected, "${h}" found`)]),o):(function(d){const f=-1===d.indexOf("://");try{return new URL(d,f?"http://example.com":void 0),!0}catch{return!1}}(r)||(o=o.concat([new $e(c.key,r,`invalid url "${r}"`)])),o)}function Gr(c){const r=c.value,o=c.styleSpec,h=o.light,d=c.style;let f=[];const g=a.i(r);if(void 0===r)return f;if("object"!==g)return f=f.concat([new $e("light",r,`object expected, ${g} found`)]),f;for(const x in r){const b=x.match(/^(.*)-transition$/);f=f.concat(b&&h[b[1]]&&h[b[1]].transition?Vi({key:x,value:r[x],valueSpec:o.transition,style:d,styleSpec:o}):h[x]?Vi({key:x,value:r[x],valueSpec:h[x],style:d,styleSpec:o}):[new $e(x,r[x],`unknown property "${x}"`)])}return f}function So(c){const r=c.value;let o=[];if(!r)return o;const h=a.i(r);if("object"!==h)return o=o.concat([new $e("light-3d",r,`object expected, ${h} found`)]),o;const d=c.styleSpec,f=d["light-3d"],g=c.key,x=c.style,b=c.style.lights;for(const S of["type","id"])if(!(S in r))return o=o.concat([new $e("light-3d",r,`missing property ${S} on light`)]),o;if(r.type&&b)for(let S=0;S<c.arrayIndex;S++){const C=a.u(r.type),P=b[S];a.u(P.type)===C&&o.push(new $e(g,r.id,`duplicate light type "${r.type}", previously defined at line ${P.id.__line__}`))}const T=`properties_light_${r.type}`;if(!(T in d))return o=o.concat([new $e("light-3d",r,`Invalid light type ${r.type}`)]),o;const M=d[T];for(const S in r)if("properties"===S){const C=r[S],P=a.i(C);if("object"!==P)return o=o.concat([new $e("properties",C,`object expected, ${P} found`)]),o;for(const k in C)o=o.concat(M[k]?Vi({key:k,value:C[k],valueSpec:M[k],style:x,styleSpec:d}):[new en(c.key,C[k],`unknown property "${k}"`)])}else{const C=S.match(/^(.*)-transition$/);o=o.concat(C&&f[C[1]]&&f[C[1]].transition?Vi({key:S,value:r[S],valueSpec:d.transition,style:x,styleSpec:d}):f[S]?Vi({key:S,value:r[S],valueSpec:f[S],style:x,styleSpec:d}):[new en(S,r[S],`unknown property "${S}"`)])}return o}function Sn(c){const r=c.value,o=c.key,h=c.style,d=c.styleSpec,f=d.terrain;let g=[];const x=a.i(r);if(void 0===r||"null"===x)return g;if("object"!==x)return g=g.concat([new $e("terrain",r,`object expected, ${x} found`)]),g;for(const b in r){const T=b.match(/^(.*)-transition$/);g=g.concat(T&&f[T[1]]&&f[T[1]].transition?Vi({key:b,value:r[b],valueSpec:d.transition,style:h,styleSpec:d}):f[b]?Vi({key:b,value:r[b],valueSpec:f[b],style:h,styleSpec:d}):[new en(b,r[b],`unknown property "${b}"`)])}if(r.source){const b=h.sources&&h.sources[r.source],T=b&&a.u(b.type);b?"raster-dem"!==T&&g.push(new $e(o,r.source,`terrain cannot be used with a source of type ${String(T)}, it only be used with a "raster-dem" source type`)):g.push(new $e(o,r.source,`source "${r.source}" not found`))}else g.push(new $e(o,r,'terrain is missing required property "source"'));return g}function yn(c){const r=c.value,o=c.style,h=c.styleSpec,d=h.fog;let f=[];const g=a.i(r);if(void 0===r)return f;if("object"!==g)return f=f.concat([new $e("fog",r,`object expected, ${g} found`)]),f;for(const x in r){const b=x.match(/^(.*)-transition$/);f=f.concat(b&&d[b[1]]&&d[b[1]].transition?Vi({key:x,value:r[x],valueSpec:h.transition,style:o,styleSpec:h}):d[x]?Vi({key:x,value:r[x],valueSpec:d[x],style:o,styleSpec:h}):[new en(x,r[x],`unknown property "${x}"`)])}return f}const Ao={"*":()=>[],array:Dt,boolean:function(c){const r=c.value,o=c.key,h=a.i(r);return"boolean"!==h?[new $e(o,r,`boolean expected, ${h} found`)]:[]},number:Jo,color:function(c){const r=c.key,o=c.value,h=a.i(o);return"string"!==h?[new $e(r,o,`color expected, ${h} found`)]:null===a.y(o)?[new $e(r,o,`color expected, "${o}" found`)]:[]},enum:Mo,filter:Qo,function:Hn,layer:En,object:xr,source:Or,model:ki,light:Gr,"light-3d":So,terrain:Sn,fog:yn,string:fr,formatted:function(c){return 0===fr(c).length?[]:tn(c)},resolvedImage:function(c){return 0===fr(c).length?[]:tn(c)},projection:function(c){const r=c.value,o=c.styleSpec,h=o.projection,d=c.style;let f=[];const g=a.i(r);if("object"===g)for(const x in r)f=f.concat(Vi({key:x,value:r[x],valueSpec:h[x],style:d,styleSpec:o}));else"string"!==g&&(f=f.concat([new $e("projection",r,`object or string expected, ${g} found`)]));return f},import:function(c){const{value:r,styleSpec:o}=c,{data:h,...d}=r;Object.defineProperty(d,"__line__",{value:r.__line__,enumerable:!1});let f=xr(a.j({},c,{value:d,valueSpec:o.import}));return""===a.u(d.id)&&f.push(new $e(`${c.key}.id`,d,"import id can't be an empty string")),h&&(f=f.concat(ts(h,o,{key:`${c.key}.data`}))),f}};function Vi(c,r=!1){const o=c.value,h=c.valueSpec,d=c.styleSpec;if(h.expression&&a.A(a.u(o)))return Hn(c);if(h.expression&&a.n(a.o(o)))return tn(c);if(h.type&&Ao[h.type]){const f=Ao[h.type](c);return!0===r&&f.length>0&&"array"===a.i(c.value)?tn(c):f}return xr(a.j({},c,{valueSpec:h.type?d[h.type]:h}))}function es(c){const r=c.value,o=c.key,h=fr(c);return h.length||(-1===r.indexOf("{fontstack}")&&h.push(new $e(o,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&h.push(new $e(o,r,'"glyphs" url must include a "{range}" token'))),h}function ts(c,r=a.D,o={}){return Vi({key:o.key||"",value:c,valueSpec:r.$root,styleSpec:r,style:c,objectElementValidators:{glyphs:es,"*":()=>[]}})}function Zr(c,r=a.D){return xe(ts(c,r))}const An=c=>xe(Or(c)),Xn=c=>xe(Gr(c)),Te=c=>xe(So(c)),U=c=>xe(Sn(c)),H=c=>xe(yn(c)),te=c=>xe(En(c)),ye=c=>xe(Qo(c)),Ee=c=>xe(Zs(c)),ze=c=>xe(Eo(c)),tt=c=>xe(ki(c));function xe(c){return c.slice().sort((r,o)=>r.line&&o.line?r.line-o.line:0)}function rt(c,r){let o=!1;if(r&&r.length)for(const h of r)h instanceof en?a.w(h.message):(c.fire(new a.a(new Error(h.message))),o=!0);return o}const Ye=new a.F({anchor:new a.G(a.D.light.anchor),position:new a.H(a.D.light.position),color:new a.G(a.D.light.color),intensity:new a.G(a.D.light.intensity)});class ot extends a.E{constructor(r,o="flat"){super(),this._transitionable=new a.J(Ye),this.setLight(r,o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,o,h={}){this._validate(Xn,r,h)||(this._transitionable.setTransitionOrValue(r),this.id=o)}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,h){return(!h||!1!==h.validate)&&rt(this,r.call(Zr,a.e({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.D})))}}const Lt=new a.F({source:new a.G(a.D.terrain.source),exaggeration:new a.G(a.D.terrain.exaggeration)});let ui=class extends a.E{constructor(c,r,o,h){super(),this.scope=o,this._transitionable=new a.J(Lt,o,h),this._transitionable.setTransitionOrValue(c,h),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(c,r){this._transitionable.setTransitionOrValue(c,r)}updateTransitions(c){this._transitioning=this._transitionable.transitioned(c,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(c){this.properties=this._transitioning.possiblyEvaluate(c)}getExaggeration(c){return this._transitioning.possiblyEvaluate(new a.K(c)).get("exaggeration")}isZoomDependent(){const c=this._transitionable._values.exaggeration;return null!=c&&null!=c.value&&null!=c.value.expression&&c.value.expression instanceof a.Z}};const ai=.05;function ri(c,r,o,h){const d=a.O(45,65,o),[f,g]=ci(c,h);let x=1-Math.min(1,Math.exp((r-f)/(g-f)*-6));return x*=x*x,x=Math.min(1,1.00747*x),x*d*c.alpha}function ci(c,r){const o=.5/Math.tan(.5*r);return[c.range[0]+o,c.range[1]+o]}function gi(c,r,o,h,d){const f=a.N.transformMat4([],[r,o,h],d.mercatorFogMatrix);return ri(c,a.N.length(f),d.pitch,d._fov)}function Ki(c,r,o,h,d,f,g){const x=[[o,h,0],[d,h,0],[d,f,0],[o,f,0]];let b=Number.MAX_VALUE,T=-Number.MAX_VALUE;for(const M of x){const S=a.N.transformMat4([],M,r),C=a.N.length(S);b=Math.min(b,C),T=Math.max(T,C)}return[ri(c,b,g.pitch,g._fov),ri(c,T,g.pitch,g._fov)]}const vi=new a.F({range:new a.G(a.D.fog.range),color:new a.G(a.D.fog.color),"high-color":new a.G(a.D.fog["high-color"]),"space-color":new a.G(a.D.fog["space-color"]),"horizon-blend":new a.G(a.D.fog["horizon-blend"]),"star-intensity":new a.G(a.D.fog["star-intensity"]),"vertical-range":new a.G(a.D.fog["vertical-range"])});class vr extends a.E{constructor(r,o,h,d){super(),this._transitionable=new a.J(vi,h,new Map(d)),this.set(r,d),this._transitioning=this._transitionable.untransitioned(),this._transform=o,this.properties=new a.Q(vi)}get state(){const r=this._transform,o="globe"===r.projection.name,h=a.S(r.zoom),d=this.properties.get("range"),f=[.5,3];return{range:o?[a.U(f[0],d[0],h),a.U(f[1],d[1],h)]:d,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(r,o,h={}){if(this._validate(H,r,h))return;const d=a.e({},r);for(const f of Object.keys(a.D.fog))void 0===d[f]&&(d[f]=a.D.fog[f].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,o)}getOpacity(r){if(!this._transform.projection.supportsFog)return 0;const o=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:a.O(45,65,r))*o.a}getOpacityAtLatLng(r,o){return this._transform.projection.supportsFog?function(h,d,f){const g=a.L.fromLngLat(d),x=f.elevation?f.elevation.getAtPointOrZero(g):0;return gi(h,g.x,g.y,x,f)}(this.state,r,o):0}getOpacityForTile(r){if(!this._transform.projection.supportsFog)return[1,1];const o=this._transform.calculateFogTileMatrix(r.toUnwrapped());return Ki(this.state,o,0,0,a.V,a.V,this._transform)}getOpacityForBounds(r,o,h,d,f){return this._transform.projection.supportsFog?Ki(this.state,r,o,h,d,f,this._transform):[1,1]}getFovAdjustedRange(r){return this._transform.projection.supportsFog?ci(this.state,r):[0,1]}isVisibleOnFrustum(r){if(!this._transform.projection.supportsFog)return!1;const o=[4,5,6,7];for(const h of o){const d=r.points[h];let f;if(d[2]>=0)f=d;else{const g=r.points[h-4];f=a.W(g,d,g[2]/(g[2]-d[2]))}if(gi(this.state,f[0],f[1],0,this._transform)>=ai)return!0}return!1}updateConfig(r){this._transitionable.setTransitionOrValue(this._options,new Map(r))}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,h){return(!h||!1!==h.validate)&&rt(this,r.call(Zr,a.e({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.D})))}}class _r extends a.E{constructor(r,o,h,d){super(),this.scope=h,this._options=r,this.properties=new a.Q(o),this._transitionable=new a.J(o,h,new Map(d)),this._transitionable.setTransitionOrValue(r.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(r){this._transitionable.setTransitionOrValue(this._options.properties,new Map(r))}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(r,o){this._options=r,this._transitionable.setTransitionOrValue(r.properties,o)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const Er=new a.F({color:new a.G(a.D.properties_light_ambient.color),intensity:new a.G(a.D.properties_light_ambient.intensity)}),Zi=new a.F({direction:new a.X(a.D.properties_light_directional.direction),color:new a.G(a.D.properties_light_directional.color),intensity:new a.G(a.D.properties_light_directional.intensity),"cast-shadows":new a.G(a.D.properties_light_directional["cast-shadows"]),"shadow-intensity":new a.G(a.D.properties_light_directional["shadow-intensity"])});class Ui{constructor(r,o,h,d){this.screenBounds=r,this.cameraPoint=o,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=h,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,d)}static createFromScreenPoints(r,o){let h,d;if(r instanceof a.P||"number"==typeof r[0]){const f=a.P.convert(r);h=[f],d=o.isPointAboveHorizon(f)}else{const f=a.P.convert(r[0]),g=a.P.convert(r[1]);h=[f,g],d=a.Y(f,g).every(x=>o.isPointAboveHorizon(x))}return new Ui(h,o.getCameraPoint(),d,o)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return a.Y(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const o=this.screenBounds[0],h=1===this.screenBounds.length?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],d=a.Y(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._(d,r)}bufferedCameraGeometryGlobe(r){const o=this.screenBounds[0],h=1===this.screenBounds.length?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],d=a.Y(o,h,r),f=this.cameraPoint.clone();switch(3*((f.y>o.y)+(f.y>h.y))+((f.x>o.x)+(f.x>h.x))){case 0:d[0]=f,d[4]=f.clone();break;case 1:d.splice(1,0,f);break;case 2:d[1]=f;break;case 3:d.splice(4,0,f);break;case 5:d.splice(2,0,f);break;case 6:d[3]=f;break;case 7:d.splice(3,0,f);break;case 8:d[2]=f}return d}containsTile(r,o,h,d=0){const f=r.queryPadding/o._pixelsPerMercatorPixel+1,g=h?this._bufferedCameraMercator(f,o):this._bufferedScreenMercator(f,o);let x=r.tileID.wrap+(g.unwrapped?d:0);const b=g.polygon.map(O=>a.$(r.tileTransform,O,x));if(!a.a0(b,0,0,a.V,a.V))return;x=r.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);const T=this.screenGeometryMercator.polygon.map(O=>a.a1(r.tileTransform,O,x)),M=T.map(O=>new a.P(O[0],O[1])),S=o.getFreeCameraOptions().position||new a.L(0,0,0),C=a.a1(r.tileTransform,S,x),P=T.map(O=>{const D=a.N.sub(O,O,C);return a.N.normalize(D,D),new a.a2(C,D)}),k=a.a3(r,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:M,tilespaceRays:P,bufferedTilespaceGeometry:b,bufferedTilespaceBounds:(R=a.a4(b),R.min.x=a.aa(R.min.x,0,a.V),R.min.y=a.aa(R.min.y,0,a.V),R.max.x=a.aa(R.max.x,0,a.V),R.max.y=a.aa(R.max.y,0,a.V),R),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:k};var R}_bufferedScreenMercator(r,o){const h=De(r);if(this._screenRaycastCache[h])return this._screenRaycastCache[h];{let d;return d="globe"===o.projection.name?this._projectAndResample(this.bufferedScreenGeometry(r),o):{polygon:this.bufferedScreenGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._screenRaycastCache[h]=d,d}}_bufferedCameraMercator(r,o){const h=De(r);if(this._cameraRaycastCache[h])return this._cameraRaycastCache[h];{let d;return d="globe"===o.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(r),o):{polygon:this.bufferedCameraGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._cameraRaycastCache[h]=d,d}}_projectAndResample(r,o){const h=function(f,g){const x=a.a6.multiply([],g.pixelMatrix,g.globeMatrix),b=[0,-a.ab,0,1],T=[0,a.ab,0,1],M=[0,0,0,1];a.a7.transformMat4(b,b,x),a.a7.transformMat4(T,T,x),a.a7.transformMat4(M,M,x);const S=new a.P(b[0]/b[3],b[1]/b[3]),C=new a.P(T[0]/T[3],T[1]/T[3]),P=a.a8(f,S)&&b[3]<M[3],k=a.a8(f,C)&&T[3]<M[3];if(!P&&!k)return null;const R=function($,Y,K){for(let ee=1;ee<$.length;ee++){const ce=ve(Y.pointCoordinate3D($[ee-1]).x),re=ve(Y.pointCoordinate3D($[ee]).x);if(K<0){if(ce<re)return{idx:ee,t:-ce/(re-1-ce)}}else if(re<ce)return{idx:ee,t:(1-ce)/(re+1-ce)}}return null}(f,g,P?-1:1);if(!R)return null;const{idx:O,t:D}=R;let F=O>1?ge(f.slice(0,O),g):[],Z=O<f.length?ge(f.slice(O),g):[];F=F.map($=>new a.P(ve($.x),$.y)),Z=Z.map($=>new a.P(ve($.x),$.y));const V=[...F];0===V.length&&V.push(Z[Z.length-1]);const q=a.U(V[V.length-1].y,(0===Z.length?F[0]:Z[0]).y,D);let B;return B=P?[new a.P(0,q),new a.P(0,0),new a.P(1,0),new a.P(1,q)]:[new a.P(1,q),new a.P(1,1),new a.P(0,1),new a.P(0,q)],V.push(...B),0===Z.length?V.push(F[0]):V.push(...Z),{polygon:V.map($=>new a.L($.x,$.y)),unwrapped:!1}}(r,o);if(h)return h;const d=function(f,g){let x=!1,b=-1/0,T=0;for(let S=0;S<f.length-1;S++)f[S].x>b&&(b=f[S].x,T=S);for(let S=0;S<f.length-1;S++){const C=(T+S)%(f.length-1),P=f[C],k=f[C+1];Math.abs(P.x-k.x)>.5&&(P.x<k.x?(P.x+=1,0===C&&(f[f.length-1].x+=1)):(k.x+=1,C+1===f.length-1&&(f[0].x+=1)),x=!0)}const M=a.a5(g.center.lng);return x&&M<Math.abs(M-1)&&f.forEach(S=>{S.x-=1}),{polygon:f,unwrapped:x}}(ge(r,o).map(f=>new a.P(ve(f.x),f.y)),o);return{polygon:d.polygon.map(f=>new a.L(f.x,f.y)),unwrapped:d.unwrapped}}}function ge(c,r){return a.a9(c,o=>{const h=r.pointCoordinate3D(o);o.x=h.x,o.y=h.y},1/256)}function ve(c){return c<0?1+c%1:c%1}function De(c){return 100*c|0}function Ne(c,r,o,h,d){const f=function(g,x){if(g)return d(g);if(x){c.url&&x.tiles&&c.tiles&&delete c.tiles;const b=a.ac(a.e(x,c),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);x.vector_layers&&(b.vectorLayers=x.vector_layers,b.vectorLayerIds=b.vectorLayers.map(T=>T.id)),x.raster_layers&&(b.rasterLayers=x.raster_layers,b.rasterLayerIds=b.rasterLayers.map(T=>T.id)),b.tiles=r.canonicalizeTileset(b,c.url),d(null,b)}};return c.url?a.g(r.transformRequest(r.normalizeSourceURL(c.url,null,o,h),a.R.Source),f):a.f.frame(()=>f(null,c))}class ke{constructor(r,o,h){this.bounds=a.ad.convert(this.validateBounds(r)),this.minzoom=o||0,this.maxzoom=h||24}validateBounds(r){return Array.isArray(r)&&4===r.length?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const o=Math.pow(2,r.z),h=Math.floor(a.a5(this.bounds.getWest())*o),d=Math.floor(a.ae(this.bounds.getNorth())*o),f=Math.ceil(a.a5(this.bounds.getEast())*o),g=Math.ceil(a.ae(this.bounds.getSouth())*o);return r.x>=h&&r.x<f&&r.y>=d&&r.y<g}}class Ge extends a.E{constructor(r,o,h,d){if(super(),this.id=r,this.dispatcher=h,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.e(this,a.ac(o,["url","scheme","tileSize","promoteId"])),this._options=a.e({type:"vector"},o),this._collectResourceTiming=!!o.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new a.af}load(r){this._loaded=!1,this.fire(new a.b("dataloading",{dataType:"source"}));const o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,h=this.map._worldview;this._tileJSONRequest=Ne(this._options,this.map._requestManager,o,h,(d,f)=>{this._tileJSONRequest=null,this._loaded=!0,d?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),h&&2!==h.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${h}`),this.fire(new a.a(d))):f&&(a.e(this,f),f.bounds&&(this.tileBounds=new ke(f.bounds,this.minzoom,this.maxzoom)),a.aj(f.tiles,this.map._requestManager._customAccessToken),this.fire(new a.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.b("data",{dataType:"source",sourceDataType:"content"}))),r&&r(d)})}loaded(){return this._loaded}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest();const r=a.ag(this.id,this.scope);this.load(()=>this.map.style.clearSource(r))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return a.e({},this._options)}loadTile(r,o){const h=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),d={request:this.map._requestManager.transformRequest(h,a.R.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:a.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:r.isExtraShadowCaster};if(d.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=o:r.request=r.actor.send("reloadTile",d,f.bind(this));else if(r.actor=this._tileWorkers[h]=this._tileWorkers[h]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",d,f.bind(this),void 0,!0);else{const g=a.ah.call({deduped:this._deduped},d,(x,b)=>{x||!b?f.call(this,x):(d.data={cacheControl:b.cacheControl,expires:b.expires,rawData:b.rawData.slice(0)},r.actor&&r.actor.send("loadTile",d,f.bind(this),void 0,!0))},!0);r.request={cancel:g}}function f(g,x){return delete r.request,r.aborted?o(null):g&&404!==g.status?o(g):(x&&x.resourceTiming&&(r.resourceTiming=x.resourceTiming),this.map._refreshExpiredTiles&&x&&r.setExpiryData(x),r.loadVectorData(x,this.map.painter),a.ai(this.dispatcher),o(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(r){r.request&&(r.request.cancel(),delete r.request),r.actor&&r.actor.send("abortTile",{uid:r.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(r){r.actor&&r.actor.send("removeTile",{uid:r.uid,type:this.type,source:this.id,scope:this.scope}),r.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Ze extends a.E{constructor(r,o,h,d){super(),this.id=r,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.e({type:"raster"},o),a.e(this,a.ac(o,["url","scheme","tileSize"]))}load(r){this._loaded=!1,this.fire(new a.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Ne(this._options,this.map._requestManager,null,null,(o,h)=>{this._tileJSONRequest=null,this._loaded=!0,o?this.fire(new a.a(o)):h&&(a.e(this,h),h.bounds&&(this.tileBounds=new ke(h.bounds,this.minzoom,this.maxzoom)),a.aj(h.tiles),this.fire(new a.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.b("data",{dataType:"source",sourceDataType:"content"}))),r&&r(o)})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest();const r=a.ag(this.id,this.scope);this.load(()=>this.map.style.clearSource(r))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return a.e({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r,o){const h=a.f.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),h,this.tileSize);r.request=a.d(this.map._requestManager.transformRequest(d,a.R.Tile),(f,g,x,b)=>(delete r.request,r.aborted?(r.state="unloaded",o(null)):f?(r.state="errored",o(f)):g?(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:x,expires:b}),r.setTexture(g,this.map.painter),r.state="loaded",a.ai(this.dispatcher),void o(null)):o(null)))}abortTile(r,o){r.request&&(r.request.cancel(),delete r.request),o()}unloadTile(r,o){r.texture&&r.texture instanceof a.T?(r.destroy(!0),r.texture&&r.texture instanceof a.T&&this.map.painter.saveTileTexture(r.texture)):r.destroy(),o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Be extends Ze{constructor(r,o,h,d){super(r,o,h,d),this.type="raster-array",this.maxzoom=22,this._options=a.e({type:"raster-array"},o)}triggerRepaint(r){const o=this.map.painter._terrain,h=this.map.style.getSourceCache(this.id);o&&o.enabled&&h&&o._clearRenderCacheForTile(h.id,r.tileID),this.map.triggerRepaint()}loadTile(r,o){const h=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(h,a.R.Tile);r.requestParams=d,r.actor||(r.actor=this.dispatcher.getActor()),r.request=r.fetchHeader(void 0,(f,g,x,b)=>(delete r.request,r.aborted?(r.state="unloaded",o(null)):f?20===f.code?void 0:(r.state="errored",o(f)):(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:x,expires:b}),r.state="empty",void o(null))))}unloadTile(r){const o=r.texture;o&&o instanceof a.T?(r.destroy(!0),this.map.painter.saveTileTexture(o)):(r.destroy(),r.flushQueues(),r._isHeaderLoaded=!1,delete r._mrt,delete r.textureDescriptor),r.fbo&&(r.fbo.destroy(),delete r.fbo),delete r.request,delete r.requestParams,delete r.neighboringTiles,r.state="unloaded"}prepareTile(r,o,h){r._isHeaderLoaded&&("empty"!==r.state&&(r.state="reloading"),r.fetchBand(o,h,(d,f)=>{if(d)return r.state="errored",this.fire(new a.a(d)),void this.triggerRepaint(r);f&&(r.setTexture(f,this.map.painter),r.state="loaded",this.triggerRepaint(r))}))}getInitialBand(r){if(!this.rasterLayers)return 0;const o=this.rasterLayers.find(({id:f})=>f===r),h=o&&o.fields,d=h&&h.bands&&h.bands;return d?d[0]:0}getTextureDescriptor(r,o,h){if(!r)return;const d=o.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!d)return;let f=null;o instanceof a.an?f=o.paint.get("raster-array-band"):o instanceof a.ao&&(f=o.paint.get("raster-particle-array-band"));const g=f||this.getInitialBand(d);if(null!=g)if(r.textureDescriptor){if(!r.updateNeeded(d,g)||h)return Object.assign({},r.textureDescriptor,{texture:r.texture})}else this.prepareTile(r,d,g)}}const _t=new Uint16Array(8184);for(let c=0;c<2046;c++){let r=c+2,o=0,h=0,d=0,f=0,g=0,x=0;for(1&r?d=f=g=32:o=h=x=32;(r>>=1)>1;){const T=o+d>>1,M=h+f>>1;1&r?(d=o,f=h,o=g,h=x):(o=d,h=f,d=g,f=x),g=T,x=M}const b=4*c;_t[b+0]=o,_t[b+1]=h,_t[b+2]=d,_t[b+3]=f}const Vt=new Uint16Array(2178),lt=new Uint8Array(1089),pi=new Uint16Array(1089);function Mi(c){return 0===c?-.03125:32===c?.03125:0}let Di=(()=>{class c{constructor(o,h,d,f){this.id=c.uniqueIdxCounter,c.uniqueIdxCounter++,this.context=o;const g=o.gl;this.buffer=g.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),o.bindElementBuffer.set(this.buffer),g.bufferData(g.ELEMENT_ARRAY_BUFFER,h.arrayBuffer,this.dynamicDraw?g.DYNAMIC_DRAW:g.STATIC_DRAW),this.dynamicDraw||f||h.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(o){this.id=c.uniqueIdxCounter,c.uniqueIdxCounter++;const h=this.context.gl;this.context.unbindVAO(),this.bind(),h.bufferSubData(h.ELEMENT_ARRAY_BUFFER,0,o.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}return c.uniqueIdxCounter=0,c})();const qi={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class sr{constructor(r,o,h,d,f,g){this.length=o.length,this.attributes=h,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.instanceCount=g,this.context=r;const x=r.gl;this.buffer=x.createBuffer(),r.bindVertexBuffer.set(this.buffer),x.bufferData(x.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||f||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,o){for(let h=0;h<this.attributes.length;h++){const d=o.attributes[this.attributes[h].name];void 0!==d&&r.enableVertexAttribArray(d)}}setVertexAttribPointers(r,o,h){for(let d=0;d<this.attributes.length;d++){const f=this.attributes[d],g=o.attributes[f.name];void 0!==g&&r.vertexAttribPointer(g,f.components,r[qi[f.type]],!1,this.itemSize,f.offset+this.itemSize*(h||0))}}setVertexAttribDivisor(r,o,h){for(let d=0;d<this.attributes.length;d++){const f=o.attributes[this.attributes[d].name];void 0!==f&&this.instanceCount&&this.instanceCount>0&&r.vertexAttribDivisor(f,h)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ti{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Br extends ti{getDefault(){return a.ax.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class rn extends ti{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class ar extends ti{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class qs extends ti{getDefault(){return[!0,!0,!0,!0]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class Yn extends ti{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class is extends ti{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class Hl extends ti{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const o=this.current;(r.func!==o.func||r.ref!==o.ref||r.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class Io extends ti{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class Xl extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=r,this.dirty=!1}}class rs extends ti{getDefault(){return[0,1]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class Yh extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=r,this.dirty=!1}}class Za extends ti{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class Yl extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.BLEND):o.disable(o.BLEND),this.current=r,this.dirty=!1}}class qa extends ti{getDefault(){const r=this.gl;return[r.ONE,r.ZERO,r.ONE,r.ZERO]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.blendFuncSeparate(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class Kl extends ti{getDefault(){return a.ax.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class Sr extends ti{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(r,r),this.current=r,this.dirty=!1)}}class ji extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=r,this.dirty=!1}}class Ut extends ti{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class Kh extends ti{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}let $a=class extends ti{getDefault(){return null}set(c){(c!==this.current||this.dirty)&&(this.gl.useProgram(c),this.current=c,this.dirty=!1)}};class Jl extends ti{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class Zd extends ti{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class xn extends ti{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class Ql extends ti{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class qd extends ti{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindTexture(o.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class ns extends ti{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Xe extends ti{getDefault(){return null}set(r){const o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class ni extends ti{getDefault(){return null}set(r){this.gl&&(r!==this.current||this.dirty)&&(this.gl.bindVertexArray(r),this.current=r,this.dirty=!1)}}class oi extends ti{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class qr extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class os extends ti{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class Ht extends ti{constructor(r,o){super(r),this.context=r,this.parent=o}getDefault(){return null}}class Wa extends Ht{setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class ss extends Ht{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class $s extends Ht{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachment(),o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class Ar extends ss{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Ni{constructor(r,o,h,d,f){this.context=r,this.width=o,this.height=h;const g=this.framebuffer=r.gl.createFramebuffer();d&&(this.colorAttachment=new Wa(r,g)),f&&(this.depthAttachmentType=f,this.depthAttachment="renderbuffer"===f?new ss(r,g):new $s(r,g))}destroy(){const r=this.context.gl;if(this.colorAttachment){const o=this.colorAttachment.get();o&&r.deleteTexture(o)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const o=this.depthAttachment.get();o&&r.deleteRenderbuffer(o)}else{const o=this.depthAttachment.get();o&&r.deleteTexture(o)}r.deleteFramebuffer(this.framebuffer)}}class dt{constructor(r,o,h){this.func=r,this.mask=o,this.range=h}}dt.ReadOnly=!1,dt.ReadWrite=!0,dt.disabled=new dt(519,dt.ReadOnly,[0,1]);class yt{constructor(r,o,h,d,f,g){this.test=r,this.ref=o,this.mask=h,this.fail=d,this.depthFail=f,this.pass=g}}yt.disabled=new yt({func:519,mask:0},0,0,7680,7680,7680);class Rt{constructor(r,o,h,d){this.blendFunction=r,this.blendColor=o,this.mask=h,this.blendEquation=d}}Rt.Replace=[1,0,1,0],Rt.disabled=new Rt(Rt.Replace,a.ax.transparent,[!1,!1,!1,!1]),Rt.unblended=new Rt(Rt.Replace,a.ax.transparent,[!0,!0,!0,!0]),Rt.alphaBlended=new Rt([1,771,1,771],a.ax.transparent,[!0,!0,!0,!0]),Rt.multiply=new Rt([774,0,774,0],a.ax.transparent,[!0,!0,!0,!0]);class pt{constructor(r,o,h){this.enable=r,this.mode=o,this.frontFace=h}}pt.disabled=new pt(!1,1029,2305),pt.backCCW=new pt(!0,1029,2305),pt.backCW=new pt(!0,1029,2304),pt.frontCW=new pt(!0,1028,2304),pt.frontCCW=new pt(!0,1028,2305);class Jh{constructor(r,o){this.gl=r,this.clearColor=new Br(this),this.clearDepth=new rn(this),this.clearStencil=new ar(this),this.colorMask=new qs(this),this.depthMask=new Yn(this),this.stencilMask=new is(this),this.stencilFunc=new Hl(this),this.stencilOp=new Io(this),this.stencilTest=new Xl(this),this.depthRange=new rs(this),this.depthTest=new Yh(this),this.depthFunc=new Za(this),this.blend=new Yl(this),this.blendFunc=new qa(this),this.blendColor=new Kl(this),this.blendEquation=new Sr(this),this.cullFace=new ji(this),this.cullFaceSide=new Ut(this),this.frontFace=new Kh(this),this.program=new $a(this),this.activeTexture=new Jl(this),this.viewport=new Zd(this),this.bindFramebuffer=new xn(this),this.bindRenderbuffer=new Ql(this),this.bindTexture=new qd(this),this.bindVertexBuffer=new ns(this),this.bindElementBuffer=new Xe(this),this.bindVertexArrayOES=new ni(this),this.pixelStoreUnpack=new oi(this),this.pixelStoreUnpackPremultiplyAlpha=new qr(this),this.pixelStoreUnpackFlipY=new os(this),this.options=o?{...o}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=r.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=r.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=r.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=r.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=r.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=r.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE),this.maxPointSize=r.getParameter(r.ALIASED_POINT_SIZE_RANGE)[1]}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(r,o,h){return new Di(this,r,o,h)}createVertexBuffer(r,o,h,d,f){return new sr(this,r,o,h,d,f)}createRenderbuffer(r,o,h){const d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,r,o,h),this.bindRenderbuffer.set(null),f}createFramebuffer(r,o,h,d){return new Ni(this,r,o,h,d)}clear({color:r,depth:o,stencil:h,colorMask:d}){const f=this.gl;let g=0;r&&(g|=f.COLOR_BUFFER_BIT,this.clearColor.set(r),this.colorMask.set(d||[!0,!0,!0,!0])),void 0!==o&&(g|=f.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),void 0!==h&&(g|=f.STENCIL_BUFFER_BIT,this.clearStencil.set(h),this.stencilMask.set(255)),f.clear(g)}setCullFace(r){!1===r.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){Pt(r.blendFunction,Rt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor),r.blendEquation?this.blendEquation.set(r.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(r.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}var Po=a.ay([{name:"a_pos",type:"Float32",components:3}]);class $i{constructor(r,o,h,d){const f={width:h[0],height:h[1],data:null},g=r.gl;this.targetColorTexture=new a.T(r,f,g.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new a.T(r,f,g.RGBA,{useMipmap:!1}),this.context=r,this.setNumParticles(o,d),this.lastInvalidatedAt=0}setNumParticles(r,o){if(this.numParticles===o)return;(this.particleVertices0||this.particleVertices1||this.particleSegment)&&(this.particleVertices0.destroy(),this.particleVertices1.destroy(),this.particleSegment.destroy());const h=new a.az;h.reserve(Math.round(o));const d=a.aA(r.key);for(let f=0;f<o;f++)h.emplaceBack(d(),d(),d());this.particleVertices0=this.context.createVertexBuffer(h,Po.members,!0),this.particleVertices1=this.context.createVertexBuffer(h,Po.members,!0),this.particleSegment=a.aB.simpleSegment(0,0,this.particleVertices0.length,0),this.numParticles=o}update(r){return!(this.lastInvalidatedAt<r&&(this.lastInvalidatedAt=a.f.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleVertices0.destroy(),this.particleVertices1.destroy(),this.particleSegment.destroy()}}const $r={type:2,extent:a.V,loadGeometry:()=>[[new a.P(0,0),new a.P(a.V+1,0),new a.P(a.V+1,a.V+1),new a.P(0,a.V+1),new a.P(0,0)]]};class Jn{constructor(r,o,h,d,f){this.tileID=r,this.uid=a.aC(),this.uses=0,this.tileSize=o,this.tileZoom=h,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=f,d&&d.style&&(this._lastUpdatedBrightness=d.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection)}registerFadeDuration(r){const o=r+this.timeAdded;o<a.f.now()||this.fadeEndTime&&o<this.fadeEndTime||(this.fadeEndTime=o)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=a.as(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(r,o,h){if(this.unloadVectorData(),this.state="loaded",r){r.featureIndex&&(this.latestFeatureIndex=r.featureIndex,r.rawTileData?(this.latestRawTileData=r.rawTileData,this.latestFeatureIndex.rawTileData=r.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=r.collisionBoxArray,this.buckets=function(d,f){const g={};if(!f)return g;for(const x of d){const b=x.layerIds.map(T=>f.getLayer(T)).filter(Boolean);if(0!==b.length){x.layers=b,x.stateDependentLayerIds&&(x.stateDependentLayers=x.stateDependentLayerIds.map(T=>b.filter(M=>M.id===T)[0]));for(const T of b)g[T.fqid]=x}}return g}(r.buckets,o.style),this.hasSymbolBuckets=!1;for(const d in this.buckets){const f=this.buckets[d];if(f instanceof a.aE){if(this.hasSymbolBuckets=!0,!h)break;f.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const d in this.buckets){const f=this.buckets[d];if(f instanceof a.aE&&f.hasRTLText){this.hasRTLText=!0,a.aF();break}}this.queryPadding=0;for(const d in this.buckets){const f=this.buckets[d],g=o.style.getOwnLayer(d);if(!g)continue;const x=g.queryRadius(f);this.queryPadding=Math.max(this.queryPadding,x)}r.imageAtlas&&(this.imageAtlas=r.imageAtlas),r.glyphAtlasImage&&(this.glyphAtlasImage=r.glyphAtlasImage),r.lineAtlas&&(this.lineAtlas=r.lineAtlas),this._lastUpdatedBrightness=r.brightness}else this.collisionBoxArray=new a.aD}unloadVectorData(){if(this.hasData()){for(const r in this.buckets)this.buckets[r].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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(r){return this.buckets[r.fqid]}upload(r){for(const d in this.buckets){const f=this.buckets[d];f.uploadPending()&&f.upload(r)}const o=r.gl,h=this.imageAtlas;if(h&&!h.uploaded){const d=!!Object.keys(h.patternPositions).length;this.imageAtlasTexture=new a.T(r,h.image,o.RGBA,{useMipmap:d}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new a.T(r,this.glyphAtlasImage,o.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new a.T(r,this.lineAtlas.image,o.R8),this.lineAtlas.uploaded=!0)}prepare(r,o,h){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(r,this.imageAtlasTexture,h),!o||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const d=o.style.getBrightness();(this._lastUpdatedBrightness||d)&&(this._lastUpdatedBrightness&&d&&Math.abs(this._lastUpdatedBrightness-d)<.001||(this._lastUpdatedBrightness=d,this.updateBuckets(void 0,o)))}queryRenderedFeatures(r,o,h,d,f,g,x,b){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:x,transform:g,params:f,tileTransform:this.tileTransform},r,o,h):{}}querySourceFeatures(r,o){const h=this.latestFeatureIndex;if(!h||!h.rawTileData)return;const d=h.loadVTLayers(),f=o?o.sourceLayer:"",g=d._geojsonTileLayer||d[f];if(!g)return;const x=a.aG(o&&o.filter),{z:b,x:T,y:M}=this.tileID.canonical,S={z:b,x:T,y:M};for(let C=0;C<g.length;C++){const P=g.feature(C);if(x.needGeometry){const O=a.aH(P,!0);if(!x.filter(new a.K(this.tileID.overscaledZ),O,this.tileID.canonical))continue}else if(!x.filter(new a.K(this.tileID.overscaledZ),P))continue;const k=h.getId(P,f),R=new a.aI(P,b,T,M,k);R.tile=S,r.push(R)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}bucketsLoaded(){for(const r in this.buckets)if(this.buckets[r].uploadPending())return!1;return!0}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(r){const o=this.expirationTime;if(r.cacheControl){const h=a.aJ(r.cacheControl);h["max-age"]&&(this.expirationTime=Date.now()+1e3*h["max-age"])}else r.expires&&(this.expirationTime=new Date(r.expires).getTime());if(this.expirationTime){const h=Date.now();let d=!1;if(this.expirationTime>h)d=!1;else if(o)if(this.expirationTime<o)d=!0;else{const f=this.expirationTime-o;f?this.expirationTime=h+Math.max(f,3e4):d=!0}else d=!0;d?(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(r,o){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&0!==Object.keys(r).length&&o&&this.updateBuckets(r,o)}updateBuckets(r,o){if(!this.latestFeatureIndex)return;const h=this.latestFeatureIndex.loadVTLayers(),d=o.style.listImages(),f=o.style.getBrightness();for(const g in this.buckets){if(!o.style.hasLayer(g))continue;const x=this.buckets[g],b=x.layers[0].sourceLayer||"_geojsonTileLayer",T=h[b];let M={};if(r&&(M=r[b],!T||!M||0===Object.keys(M).length))continue;if(x.update(M,T,d,this.imageAtlas&&this.imageAtlas.patternPositions||{},f),x instanceof a.aK||x instanceof a.aL){const C=o.style.getOwnSourceCache(x.layers[0].source);o._terrain&&o._terrain.enabled&&C&&x.programConfigurations.needsUpload&&o._terrain._clearRenderCacheForTile(C.id,this.tileID)}const S=o&&o.style&&o.style.getOwnLayer(g);S&&(this.queryPadding=Math.max(this.queryPadding,S.queryRadius(x)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<a.f.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(r){this.symbolFadeHoldUntil=a.f.now()+r}setTexture(r,o){const h=o.context,d=h.gl;this.texture=this.texture||o.getTileTexture(r.width),this.texture&&this.texture instanceof a.T?this.texture.update(r,{useMipmap:!0}):(this.texture=new a.T(h,r,d.RGBA,{useMipmap:!0}),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE))}setDependencies(r,o){const h={};for(const d of o)h[d]=!0;this.dependencies[r]=h}hasDependency(r,o){for(const h of r){const d=this.dependencies[h];if(d)for(const f of o)if(d[f])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(r,o){if(!o||"mercator"===o.name||this._tileDebugBuffer)return;const h=a.aM($r,this.tileID.canonical,this.tileTransform)[0],d=new a.aN,f=new a.aO;for(let g=0;g<h.length;g++){const{x,y:b}=h[g];d.emplaceBack(x,b),f.emplaceBack(g)}f.emplaceBack(0),this._tileDebugIndexBuffer=r.createIndexBuffer(f),this._tileDebugBuffer=r.createVertexBuffer(d,a.aP.members),this._tileDebugSegments=a.aB.simpleSegment(0,0,d.length,f.length)}_makeTileBoundsBuffers(r,o){if(this._tileBoundsBuffer||!o||"mercator"===o.name)return;const h=a.aM($r,this.tileID.canonical,this.tileTransform)[0];let d,f;if(this.isRaster){const g=function(x,b){const T=a.as(x,b),M=Math.pow(2,x.z);for(let O=0;O<33;O++)for(let D=0;D<33;D++){const F=a.at((x.x+(D+Mi(D))/32)/M),Z=a.au((x.y+(O+Mi(O))/32)/M),V=b.project(F,Z),q=33*O+D;Vt[2*q+0]=Math.round((V.x*T.scale-T.x)*a.V),Vt[2*q+1]=Math.round((V.y*T.scale-T.y)*a.V)}lt.fill(0),pi.fill(0);for(let O=2045;O>=0;O--){const D=4*O,F=_t[D+0],Z=_t[D+1],V=_t[D+2],q=_t[D+3],B=F+V>>1,$=Z+q>>1,Y=B+$-Z,K=$+F-B,ee=33*Z+F,ce=33*q+V,re=33*$+B,me=Math.hypot((Vt[2*ee+0]+Vt[2*ce+0])/2-Vt[2*re+0],(Vt[2*ee+1]+Vt[2*ce+1])/2-Vt[2*re+1])>=16;lt[re]=lt[re]||(me?1:0),O<1022&&(lt[re]=lt[re]||lt[33*(Z+K>>1)+(F+Y>>1)]||lt[33*(q+K>>1)+(V+Y>>1)])}const S=new a.av,C=new a.aw;let P=0;function k(O,D){const F=33*D+O;return 0===pi[F]&&(S.emplaceBack(Vt[2*F+0],Vt[2*F+1],O*a.V/32,D*a.V/32),pi[F]=++P),pi[F]-1}function R(O,D,F,Z,V,q){const B=O+F>>1,$=D+Z>>1;if(Math.abs(O-V)+Math.abs(D-q)>1&&lt[33*$+B])R(V,q,O,D,B,$),R(F,Z,V,q,B,$);else{const Y=k(O,D),K=k(F,Z),ee=k(V,q);C.emplaceBack(Y,K,ee)}}return R(0,0,32,32,32,0),R(32,32,0,0,0,32),{vertices:S,indices:C}}(this.tileID.canonical,o);d=g.vertices,f=g.indices}else{d=new a.av,f=new a.aw;for(const{x,y:b}of h)d.emplaceBack(x,b,0,0);const g=a.aQ(d.int16,void 0,4);for(let x=0;x<g.length;x+=3)f.emplaceBack(g[x],g[x+1],g[x+2])}this._tileBoundsBuffer=r.createVertexBuffer(d,a.aR.members),this._tileBoundsIndexBuffer=r.createIndexBuffer(f),this._tileBoundsSegments=a.aB.simpleSegment(0,0,d.length,f.length)}_makeGlobeTileDebugBuffers(r,o){const h=o.projection;if(!h||"globe"!==h.name||o.freezeTileCoverage)return;const d=this.tileID.canonical,f=a.aS(d,o),g=a.aT(f),x=a.S(o.zoom);let b;x>0&&(b=a.a6.invert(new Float64Array(16),o.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(r,d,o,g,b,x),this._makeGlobeTileDebugTextBuffer(r,d,o,g,b,x)}_globePoint(r,o,h,d,f,g,x){let b=a.aU(r,o,h);if(g){const T=1<<h.z,M=a.a5(d.center.lng),S=a.ae(d.center.lat),C=(h.x+.5)/T-M;let P=0;C>.5?P=-1:C<-.5&&(P=1);let k=(r/a.V+h.x)/T+P,R=(o/a.V+h.y)/T;k=(k-M)*d._pixelsPerMercatorPixel+M,R=(R-S)*d._pixelsPerMercatorPixel+S;const O=[k*d.worldSize,R*d.worldSize,0];a.N.transformMat4(O,O,g),b=a.aV(b,O,x)}return a.N.transformMat4(b,b,f)}_makeGlobeTileDebugBorderBuffer(r,o,h,d,f,g){const x=new a.aN,b=new a.aO,T=new a.aW,M=(C,P,k,R,O)=>{const D=(k-C)/(O-1),F=(R-P)/(O-1),Z=x.length;for(let V=0;V<O;V++){const q=C+V*D,B=P+V*F;x.emplaceBack(q,B);const $=this._globePoint(q,B,o,h,d,f,g);T.emplaceBack($[0],$[1],$[2]),b.emplaceBack(Z+V)}},S=a.V;M(0,0,S,0,16),M(S,0,S,S,16),M(S,S,0,S,16),M(0,S,0,0,16),this._tileDebugIndexBuffer=r.createIndexBuffer(b),this._tileDebugBuffer=r.createVertexBuffer(x,a.aP.members),this._globeTileDebugBorderBuffer=r.createVertexBuffer(T,a.aX.members),this._tileDebugSegments=a.aB.simpleSegment(0,0,x.length,b.length)}_makeGlobeTileDebugTextBuffer(r,o,h,d,f,g){const x=a.V/4,b=new a.aN,T=new a.aw,M=new a.aW,S=25;T.reserve(32),b.reserve(S),M.reserve(S);const C=(P,k)=>S*P+k;for(let P=0;P<S;P++){const k=P*x;for(let R=0;R<S;R++){const O=R*x;b.emplaceBack(O,k);const D=this._globePoint(O,k,o,h,d,f,g);M.emplaceBack(D[0],D[1],D[2])}}for(let P=0;P<4;P++)for(let k=0;k<4;k++){const R=C(P,k),O=C(P,k+1),D=C(P+1,k),F=C(P+1,k+1);T.emplaceBack(R,O,D),T.emplaceBack(D,O,F)}this._tileDebugTextIndexBuffer=r.createIndexBuffer(T),this._tileDebugTextBuffer=r.createVertexBuffer(b,a.aP.members),this._globeTileDebugTextBuffer=r.createVertexBuffer(M,a.aX.members),this._tileDebugTextSegments=a.aB.simpleSegment(0,0,S,32)}destroy(r=!1){for(const o in this.buckets)this.buckets[o].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!r&&this.texture&&this.texture instanceof a.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}const In={vector:Ge,raster:Ze,"raster-dem":class extends Ze{constructor(c,r,o,h){super(c,r,o,h),this.type="raster-dem",this.maxzoom=22,this._options=a.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(c,r){const o=this.map._requestManager.normalizeTileURL(c.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function h(d,f){d&&(c.state="errored",r(d)),f&&(c.dem=f,c.dem.onDeserialize(),c.needsHillshadePrepare=!0,c.needsDEMTextureUpload=!0,c.state="loaded",r(null))}c.request=a.d(this.map._requestManager.transformRequest(o,a.R.Tile),function(d,f,g,x){if(delete c.request,c.aborted)c.state="unloaded",r(null);else if(d)c.state="errored",r(d);else if(f){this.map._refreshExpiredTiles&&c.setExpiryData({cacheControl:g,expires:x});const b=ImageBitmap&&f instanceof ImageBitmap&&a.ak(),T=1-(f.width-a.al(f.width))/2;T<1||c.neighboringTiles||(c.neighboringTiles=this._getNeighboringTiles(c.tileID));const M=b?f:a.f.getImageData(f,T),S={uid:c.uid,coord:c.tileID,source:this.id,scope:this.scope,rawImageData:M,encoding:this.encoding,padding:T};c.actor&&"expired"!==c.state||(c.actor=this.dispatcher.getActor(),c.actor.send("loadDEMTile",S,h.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(c){const r=c.canonical,o=Math.pow(2,r.z),h=(r.x-1+o)%o,d=0===r.x?c.wrap-1:c.wrap,f=(r.x+1+o)%o,g=r.x+1===o?c.wrap+1:c.wrap,x={};return x[new a.am(c.overscaledZ,d,r.z,h,r.y).key]={backfilled:!1},x[new a.am(c.overscaledZ,g,r.z,f,r.y).key]={backfilled:!1},r.y>0&&(x[new a.am(c.overscaledZ,d,r.z,h,r.y-1).key]={backfilled:!1},x[new a.am(c.overscaledZ,c.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},x[new a.am(c.overscaledZ,g,r.z,f,r.y-1).key]={backfilled:!1}),r.y+1<o&&(x[new a.am(c.overscaledZ,d,r.z,h,r.y+1).key]={backfilled:!1},x[new a.am(c.overscaledZ,c.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},x[new a.am(c.overscaledZ,g,r.z,f,r.y+1).key]={backfilled:!1}),x}},"raster-array":Be,geojson:class extends a.E{constructor(c,r,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=r.data,this._options=a.e({},r),this._collectResourceTiming=r.collectResourceTiming,void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const d=a.V/this.tileSize;this.workerOptions=a.e({source:this.id,scope:this.scope,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*d,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*d,extent:a.V,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:a.V,radius:(void 0!==r.clusterRadius?r.clusterRadius:50)*d,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}onAdd(c){this.map=c,this.setData(this._data)}setData(c){return this._data=c,this._updateWorkerData(),this}getClusterExpansionZoom(c,r){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:c,source:this.id,scope:this.scope},r),this}getClusterChildren(c,r){return this.actor.send("geojson.getClusterChildren",{clusterId:c,source:this.id,scope:this.scope},r),this}getClusterLeaves(c,r,o,h){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:c,limit:r,offset:o},h),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.b("dataloading",{dataType:"source"})),this._loaded=!1;const c=a.e({},this.workerOptions);c.scope=this.scope;const r=this._data;"string"==typeof r?(c.request=this.map._requestManager.transformRequest(a.f.resolveURL(r),a.R.Source),c.request.collectResourceTiming=this._collectResourceTiming):c.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,c,(o,h)=>{if(this._loaded=!0,this._pendingLoad=null,o)this.fire(new a.a(o));else{const 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.b("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(c,r){const o=c.actor?"reloadTile":"loadTile";c.actor=this.actor;const h={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,scope:this.scope,pixelRatio:a.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};c.request=this.actor.send(o,h,(d,f)=>(delete c.request,c.destroy(),c.aborted?r(null):d?r(d):(c.loadVectorData(f,this.map.painter,"reloadTile"===o),r(null))),void 0,"loadTile"===o)}abortTile(c){c.request&&(c.request.cancel(),delete c.request),c.aborted=!0}unloadTile(c){this.actor.send("removeTile",{uid:c.uid,type:this.type,source:this.id,scope:this.scope}),c.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends a.ap{constructor(c,r,o,h){super(c,r,o,h),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const c=this.options;this.urls=[];for(const r of c.urls)this.urls.push(this.map._requestManager.transformRequest(r,a.R.Source).url);a.aq(this.urls,(r,o)=>{this._loaded=!0,r?this.fire(new a.a(r)):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){const r=this.video.seekable;c<r.start(0)||c>r.end(0)?this.fire(new a.a(new $e(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.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(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const c=this.map.painter.context,r=c.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(c,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(c)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:a.ap,model:class extends a.E{constructor(c,r,o,h){super(),this.id=c,this.type="model",this.models=[],this._loaded=!1,this._options=r}load(){const c=[];for(const r in this._options.models){const o=this._options.models[r],h=a.l(this.map._requestManager.transformRequest(o.uri,a.R.Model).url).then(d=>{if(!d)return;const f=a.c(d),g=new a.M(r,o.position,o.orientation,f);g.computeBoundsAndApplyParent(),this.models.push(g)}).catch(d=>{this.fire(new a.a(new Error(`Could not load model ${r} from ${o.uri}: ${d.message}`)))});c.push(h)}return Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new a.b("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(r=>{this.fire(new a.a(new Error(`Could not load models: ${r.message}`)))})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(c,r){}serialize(){return{type:"model"}}},"batched-model":class extends a.E{constructor(c,r,o,h){super(),this.type="batched-model",this.id=c,this.tileSize=512,this._options=r,this.tiles=this._options.tiles,this.maxzoom=r.maxzoom||19,this.minzoom=r.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=o,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(h)}onAdd(c){this.map=c,this.load()}load(c){this._loaded=!1,this.fire(new a.b("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=Ne(this._options,this.map._requestManager,r,o,(h,d)=>{this._tileJSONRequest=null,this._loaded=!0,h?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new a.a(h))):d&&(a.e(this,d),d.bounds&&(this.tileBounds=new ke(d.bounds,this.minzoom,this.maxzoom)),a.aj(d.tiles,this.map._requestManager._customAccessToken),this.fire(new a.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.b("data",{dataType:"source",sourceDataType:"content"}))),c&&c(h)})}hasTransition(){return!1}hasTile(c){return!this.tileBounds||this.tileBounds.contains(c.canonical)}loaded(){return this._loaded}loadTile(c,r){const o=this.map._requestManager.normalizeTileURL(c.tileID.canonical.url(this.tiles,this.scheme)),h={request:this.map._requestManager.transformRequest(o,a.R.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,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:c.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(c.actor&&"expired"!==c.state)if("loading"===c.state)c.reloadCallback=r;else{if(c.buckets){const f=Object.values(c.buckets);for(const g of f)g.dirty=!0;return void(c.state="loaded")}c.request=c.actor.send("reloadTile",h,d.bind(this))}else c.actor=this.dispatcher.getActor(),c.request=c.actor.send("loadTile",h,d.bind(this),void 0,!0);function d(f,g){return c.aborted?r(null):f&&404!==f.status?r(f):(g&&(g.resourceTiming&&(c.resourceTiming=g.resourceTiming),this.map._refreshExpiredTiles&&c.setExpiryData(g),c.buckets={...c.buckets,...g.buckets},g.featureIndex&&(c.latestFeatureIndex=g.featureIndex)),c.state="loaded",void r(null))}}serialize(){return a.e({},this._options)}},canvas:class extends a.ap{constructor(c,r,o,h){super(c,r,o,h),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some(d=>!Array.isArray(d)||2!==d.length||d.some(f=>"number"!=typeof f))||this.fire(new a.a(new $e(`sources.${c}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.a(new $e(`sources.${c}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new a.a(new $e(`sources.${c}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new a.a(new $e(`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.a(new $e(`sources.${c}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.a(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()||0===Object.keys(this.tiles).length)return;const r=this.map.painter.context;this.texture?!c&&!this._playing||this.texture instanceof a.ar||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const c of[this.canvas.width,this.canvas.height])if(isNaN(c)||c<=0)return!0;return!1}},custom:class extends a.E{constructor(c,r,o,h){super(),this.id=c,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=r,this.setEventedParent(h),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new a.a(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new a.a(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ke(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),a.e(this,a.ac(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return a.ac(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new a.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.b("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(c){this._map=c,this._loaded=!1,this.fire(new a.b("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(c),this.load()}onRemove(c){this._implementation.onRemove&&this._implementation.onRemove(c)}hasTile(c){if(this._implementation.hasTile){const{x:r,y:o,z:h}=c.canonical;return this._implementation.hasTile({x:r,y:o,z:h})}return!this.tileBounds||this.tileBounds.contains(c.canonical)}loadTile(c,r){const{x:o,y:h,z:d}=c.tileID.canonical,f=new AbortController;c.request=Promise.resolve(this._implementation.loadTile({x:o,y:h,z:d},{signal:f.signal})).then(function(g){return delete c.request,c.aborted?(c.state="unloaded",r(null)):void 0===g?(c.state="errored",r(null)):null===g?(this.loadTileData(c,{width:this.tileSize,height:this.tileSize,data:null}),c.state="loaded",r(null)):(x=g)instanceof ImageData||x instanceof HTMLCanvasElement||x instanceof ImageBitmap||x instanceof HTMLImageElement?(this.loadTileData(c,g),c.state="loaded",void r(null)):(c.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)));var x}.bind(this)).catch(g=>{20!==g.code&&(c.state="errored",r(g))}),c.request.cancel=()=>f.abort()}loadTileData(c,r){c.setTexture(r,this._map.painter)}unloadTile(c,r){if(c.texture&&c.texture instanceof a.T?(c.destroy(!0),c.texture&&c.texture instanceof a.T&&this._map.painter.saveTileTexture(c.texture)):c.destroy(),this._implementation.unloadTile){const{x:o,y:h,z:d}=c.tileID.canonical;this._implementation.unloadTile({x:o,y:h,z:d})}r()}abortTile(c,r){c.request&&c.request.cancel&&(c.request.cancel(),delete c.request),r()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(c=>({x:c.canonical.x,y:c.canonical.y,z:c.canonical.z}))}_clearTiles(){const c=a.ag(this.id,this.scope);this._map.style.clearSource(c)}_update(){this.fire(new a.b("data",{dataType:"source",sourceDataType:"content"}))}}},Wi=function(c,r,o,h){const d=new In[r.type](c,r,o,h);if(d.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${d.id}`);return a.aY(["load","abort","unload","serialize","prepare"],d),d};function ec(c,r){const o=a.a6.identity([]);return a.a6.scale(o,o,[.5*c.width,.5*-c.height,1]),a.a6.translate(o,o,[1,-1,0]),a.a6.multiply(o,o,c.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(o)}function tc(c,r,o,h,d,f,g,x=!1){const b=c.tilesIn(h,g,x);b.sort(ls);const T=[];for(const S of b)T.push({wrappedTileID:S.tile.tileID.wrapped().key,queryResults:S.tile.queryRenderedFeatures(r,o,c._state,S,d,f,ec(c.transform,S.tile.tileID),x)});const M=function(S){const C={},P={};for(const k of S){const R=k.queryResults,O=k.wrappedTileID,D=P[O]=P[O]||{};for(const F in R){const Z=R[F],V=D[F]=D[F]||{},q=C[F]=C[F]||[];for(const B of Z)V[B.featureIndex]||(V[B.featureIndex]=!0,q.push(B))}}return C}(T);for(const S in M)M[S].forEach(C=>{const P=C.feature,k=P.layer;k&&"background"!==k.type&&"sky"!==k.type&&"slot"!==k.type&&(P.source=k.source,k["source-layer"]&&(P.sourceLayer=k["source-layer"]),P.state=void 0!==P.id?c.getFeatureState(k["source-layer"],P.id):{})});return M}function Cn(c,r){const o=c.getRenderableIds().map(f=>c.getTileByID(f)),h=[],d={};for(let f=0;f<o.length;f++){const g=o[f],x=g.tileID.canonical.key;d[x]||(d[x]=!0,g.querySourceFeatures(h,r))}return h}function ls(c,r){const o=c.tileID,h=r.tileID;return o.overscaledZ-h.overscaledZ||o.canonical.y-h.canonical.y||o.wrap-h.wrap||o.canonical.x-h.canonical.x}class zo extends Jn{constructor(r,o,h,d,f){super(r,o,h,d,f),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(r,o){const h=o.context,d=h.gl;this.texture=this.texture||o.getTileTexture(r.width),this.texture&&this.texture instanceof a.T?this.texture.update(r,{useMipmap:!1,premultiply:!1}):this.texture=new a.T(h,r,d.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(r=16384,o){const h=this._mrt=new a.aZ(30),d=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(r-1)}});return this.entireBuffer=null,this.request=a.a_(d,(f,g,x,b)=>{if(f)o(f);else try{const T=h.getHeaderLength(g);if(T>r)return void(this.request=this.fetchHeader(T,o));h.parseHeader(g),this._isHeaderLoaded=!0;let M=0;for(const S of Object.values(h.layers))M=Math.max(M,S.dataIndex[S.dataIndex.length-1].last_byte);g.byteLength>=M&&(this.entireBuffer=g),o(null,this.entireBuffer||g,x,b)}catch(T){o(T)}}),this.request}fetchBand(r,o,h){const d=this._mrt;if(!this._isHeaderLoaded||!d)return void h(new Error("Tile header is not ready"));const f=this.actor;if(!f)return void h(new Error("Can't fetch tile band without an actor"));let g;const x=(S,C)=>{g.complete(S,C),S?h(S):(this.updateTextureDescriptor(r,o),h(null,this.textureDescriptor&&this.textureDescriptor.img))},b=(S,C)=>{if(S)return h(S);const P=f.send("decodeRasterArray",{buffer:C,task:g},x,void 0,!0);this._workQueue.push(()=>{P&&P.cancel(),g.cancel()})},T=d.getLayer(r);if(!T)return void h(new Error(`Unknown sourceLayer "${r}"`));if(T.hasDataForBand(o))return this.updateTextureDescriptor(r,o),void h(null,this.textureDescriptor?this.textureDescriptor.img:null);const M=T.getDataRange([o]);if(g=d.createDecodingTask(M),!g||g.tasks.length)if(this.flushQueues(),this.entireBuffer)b(null,this.entireBuffer.slice(M.firstByte,M.lastByte+1));else{const S=Object.assign({},this.requestParams,{headers:{Range:`bytes=${M.firstByte}-${M.lastByte}`}}),C=a.a_(S,b);this._fetchQueue.push(()=>{C.cancel(),g.cancel()})}else h(null)}updateNeeded(r,o){return(!this.textureDescriptor||this.textureDescriptor.band!==o||this.textureDescriptor.layer!==r)&&"errored"!==this.state}updateTextureDescriptor(r,o){if(!this._mrt)return;const h=this._mrt.getLayer(r);if(!h||!h.hasBand(o)||!h.hasDataForBand(o))return;const{bytes:d,tileSize:f,buffer:g,offset:x,scale:b}=h.getBandView(o),T=f+2*g,M={data:d,width:T,height:T},S=this.texture;S&&S instanceof a.T&&S.update(M,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:r,band:o,img:M,buffer:g,offset:x,tileSize:f,format:h.pixelFormat,mix:[b,256*b,65536*b,16777216*b]}}}class cs{constructor(r,o){this.max=r,this.onRemove=o,this.reset()}reset(){for(const r in this.data)for(const o of this.data[r])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(r,o,h){const d=r.wrapped().key;void 0===this.data[d]&&(this.data[d]=[]);const f={value:o,timeout:void 0};if(void 0!==h&&(f.timeout=setTimeout(()=>{this.remove(r,f)},h)),this.data[d].push(f),this.order.push(d),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const o=this.data[r].shift();return o.timeout&&clearTimeout(o.timeout),0===this.data[r].length&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),o.value}getByKey(r){const o=this.data[r];return o?o[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,o){if(!this.has(r))return this;const h=r.wrapped().key,d=void 0===o?0:this.data[h].indexOf(o),f=this.data[h][d];return this.data[h].splice(d,1),f.timeout&&clearTimeout(f.timeout),0===this.data[h].length&&delete this.data[h],this.onRemove(f.value),this.order.splice(this.order.indexOf(h),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(r){const o=[];for(const h in this.data)for(const d of this.data[h])r(d.value)||o.push(d);for(const h of o)this.remove(h.value.tileID,h)}}class nn extends a.E{constructor(r,o,h){super(),this.id=r,this._onlySymbols=h,o.on("data",d=>{"source"===d.dataType&&"metadata"===d.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===d.dataType&&"content"===d.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new cs(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new qt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(r){this.map=r,this._minTileCacheSize=void 0===this._minTileCacheSize&&r?r._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&r?r._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const r in this._tiles){const o=this._tiles[r];if("errored"!==o.state&&("loaded"!==o.state||!o.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const r=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,r&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(r,o){return r.isSymbolTile=this._onlySymbols,r.isExtraShadowCaster=this._shadowCasterTiles[r.tileID.key],this._source.loadTile(r,o)}_unloadTile(r){if(this._source.unloadTile)return this._source.unloadTile(r,()=>{})}_abortTile(r){if(this._source.abortTile)return this._source.abortTile(r,()=>{})}serialize(){return this._source.serialize()}prepare(r){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const o in this._tiles){const h=this._tiles[o];h.upload(r),h.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return a.a$(this._tiles).map(r=>r.tileID).sort(Ha).map(r=>r.key)}getRenderableIds(r,o){const h=[];for(const d in this._tiles)this._isIdRenderable(+d,r,o)&&h.push(this._tiles[d]);return r?h.sort((d,f)=>{const g=d.tileID,x=f.tileID,b=new a.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle),T=new a.P(x.canonical.x,x.canonical.y)._rotate(this.transform.angle);return g.overscaledZ-x.overscaledZ||T.y-b.y||T.x-b.x}).map(d=>d.tileID.key):h.map(d=>d.tileID).sort(Ha).map(d=>d.key)}hasRenderableParent(r){const o=this.findLoadedParent(r,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(r,o,h){return this._tiles[r]&&this._tiles[r].hasData()&&!this._coveredTiles[r]&&(o||!this._tiles[r].holdingForFade())&&(h||!this._shadowCasterTiles[r])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const r in this._tiles)"errored"!==this._tiles[r].state&&this._reloadTile(+r,"reloading")}}_reloadTile(r,o){const h=this._tiles[r];h&&("loading"!==h.state&&(h.state=o),this._loadTile(h,this._tileLoaded.bind(this,h,r,o)))}_tileLoaded(r,o,h,d){if(d)if(r.state="errored",404!==d.status)this._source.fire(new a.a(d,{tile:r}));else{if(!(r.tileID.key in this._loadedParentTiles))return void this._source.fire(new a.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const f=this.map.painter.terrain;this.update(this.transform,f.getScaledDemTileSize(),!0),f.resetTileLookupCache(this.id)}else this.update(this.transform)}else r.timeAdded=a.f.now(),"expired"===h&&(r.refreshedUponExpiration=!0),this._setTileReloadTimer(o,r),"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),this._state.initializeTileState(r,this.map?this.map.painter:null),this._source.fire(new a.b("data",{dataType:"source",tile:r,coord:r.tileID,sourceCacheId:this.id}))}_backfillDEM(r){const o=this.getRenderableIds();for(let d=0;d<o.length;d++){const f=o[d];if(r.neighboringTiles&&r.neighboringTiles[f]){const g=this.getTileByID(f);h(r,g),h(g,r)}}function h(d,f){if(!d.dem||d.dem.borderReady)return;d.needsHillshadePrepare=!0,d.needsDEMTextureUpload=!0;let g=f.tileID.canonical.x-d.tileID.canonical.x;const x=f.tileID.canonical.y-d.tileID.canonical.y,b=Math.pow(2,d.tileID.canonical.z),T=f.tileID.key;0===g&&0===x||Math.abs(x)>1||(Math.abs(g)>1&&(1===Math.abs(g+b)?g+=b:1===Math.abs(g-b)&&(g-=b)),f.dem&&d.dem&&(d.dem.backfillBorder(f.dem,g,x),d.neighboringTiles&&d.neighboringTiles[T]&&(d.neighboringTiles[T].backfilled=!0)))}}getTile(r){return this.getTileByID(r.key)}getTileByID(r){return this._tiles[r]}_retainLoadedChildren(r,o,h,d){for(const f in this._tiles){let g=this._tiles[f];if(d[f]||!g.hasData()||g.tileID.overscaledZ<=o||g.tileID.overscaledZ>h)continue;let x=g.tileID;for(;g&&g.tileID.overscaledZ>o+1;){const T=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[T.key],g&&g.hasData()&&(x=T)}let b=x;for(;b.overscaledZ>o;)if(b=b.scaledTo(b.overscaledZ-1),r[b.key]){d[x.key]=x;break}}}findLoadedParent(r,o){if(r.key in this._loadedParentTiles){const h=this._loadedParentTiles[r.key];return h&&h.tileID.overscaledZ>=o?h:null}for(let h=r.overscaledZ-1;h>=o;h--){const d=r.scaledTo(h),f=this._getLoadedTile(d);if(f)return f}}_getLoadedTile(r){const o=this._tiles[r.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?r.wrapped().key:r.canonical.key)}updateCacheSize(r,o){o=o||this._source.tileSize;const h=Math.ceil(r.width/o)+1,d=Math.ceil(r.height/o)+1,f=Math.floor(h*d*5),g="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,f):f,x="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,g):g;this._cache.setMaxSize(x)}handleWrapJump(r){const o=Math.round((r-(void 0===this._prevLng?r:this._prevLng))/360);if(this._prevLng=r,o){const h={};for(const d in this._tiles){const f=this._tiles[d];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+o),h[f.tileID.key]=f}this._tiles=h;for(const d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(const d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(r,o,h,d){if(this.transform=r,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!h)return;let f;if(this.updateCacheSize(r,o),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)f=r.getVisibleUnwrappedCoordinates(this._source.tileID).map(b=>new a.am(b.canonical.z,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y));else if(0!==this.tileCoverLift){const b=r.clone();b.tileCoverLift=this.tileCoverLift,f=b.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!h,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===r.projection.name&&(f.push(new a.am(1,0,1,0,0)),f.push(new a.am(1,0,1,1,0)),f.push(new a.am(1,0,1,0,1)),f.push(new a.am(1,0,1,1,1)))}else f=r.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!h,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(f=f.filter(b=>this._source.hasTile(b)));else f=[];if(f.length>0&&this.castsShadows&&d&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Pn(this._source.type)){const b=r.coveringZoomLevel({tileSize:o||this._source.tileSize,roundZoom:this._source.roundZoom&&!h}),T=Math.min(b,this._source.maxzoom),M=r.extendTileCoverForShadows(f,d,T);for(const S of M)this._shadowCasterTiles[S.key]=!0,f.push(S)}const g=this._updateRetainedTiles(f);if(Pn(this._source.type)&&0!==f.length){const b={},T={},M=Object.keys(g);for(const C of M){const P=g[C],k=this._tiles[C];if(!k||k.fadeEndTime&&k.fadeEndTime<=a.f.now())continue;const R=this.findLoadedParent(P,Math.max(P.overscaledZ-nn.maxOverzooming,this._source.minzoom));R&&(this._addTile(R.tileID),b[R.tileID.key]=R.tileID),T[C]=P}const S=f[f.length-1].overscaledZ;for(const C in this._tiles){const P=this._tiles[C];if(g[C]||!P.hasData())continue;let k=P.tileID;for(;k.overscaledZ>S;){k=k.scaledTo(k.overscaledZ-1);const R=this._tiles[k.key];if(R&&R.hasData()&&T[k.key]){g[C]=P.tileID;break}}}for(const C in b)g[C]||(this._coveredTiles[C]=!0,g[C]=b[C])}for(const b in g)this._tiles[b].clearFadeHold();const x=a.b0(this._tiles,g);for(const b of x){const T=this._tiles[b];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+b)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const r in this._tiles)this._tiles[r].holdingForFade()&&this._removeTile(+r)}_updateRetainedTiles(r){const o={};if(0===r.length)return o;const h={},d=r.reduce((T,M)=>Math.min(T,M.overscaledZ),1/0),f=r[0].overscaledZ,g=Math.max(f-nn.maxOverzooming,this._source.minzoom),x=Math.max(f+nn.maxUnderzooming,this._source.minzoom),b={};for(const T of r){const M=this._addTile(T);o[T.key]=T,M.hasData()||d<this._source.maxzoom&&(b[T.key]=T)}this._retainLoadedChildren(b,d,x,o);for(const T of r){let M=this._tiles[T.key];if(M.hasData())continue;if(T.canonical.z>=this._source.maxzoom){const C=T.children(this._source.maxzoom)[0],P=this.getTile(C);if(P&&P.hasData()){o[C.key]=C;continue}}else{const C=T.children(this._source.maxzoom);if(o[C[0].key]&&o[C[1].key]&&o[C[2].key]&&o[C[3].key])continue}let S=M.wasRequested();for(let C=T.overscaledZ-1;C>=g;--C){const P=T.scaledTo(C);if(h[P.key]||(h[P.key]=!0,M=this.getTile(P),!M&&S&&(M=this._addTile(P)),M&&(o[P.key]=P,S=M.wasRequested(),M.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const r in this._tiles){const o=[];let h,d=this._tiles[r].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){h=this._loadedParentTiles[d.key];break}o.push(d.key);const f=d.scaledTo(d.overscaledZ-1);if(h=this._getLoadedTile(f),h)break;d=f}for(const f of o)this._loadedParentTiles[f]=h}}_addTile(r){let o=this._tiles[r.key];if(o)return!0!==o.isExtraShadowCaster||this._shadowCasterTiles[r.key]||this._reloadTile(r.key,"reloading"),o;o=this._cache.getAndRemove(r),o&&(this._setTileReloadTimer(r.key,o),o.tileID=r,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[r.key]&&(clearTimeout(this._cacheTimers[r.key]),delete this._cacheTimers[r.key],this._setTileReloadTimer(r.key,o)));const h=!!o;if(!h){const d=this.map?this.map.painter:null,f=this._source.tileSize*r.overscaleFactor();o="raster-array"===this._source.type?new zo(r,f,this.transform.tileZoom,d,this._isRaster):new Jn(r,f,this.transform.tileZoom,d,this._isRaster),this._loadTile(o,this._tileLoaded.bind(this,o,r.key,o.state))}return o?(o.uses++,this._tiles[r.key]=o,h||this._source.fire(new a.b("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o):null}_setTileReloadTimer(r,o){r in this._timers&&(clearTimeout(this._timers[r]),delete this._timers[r]);const h=o.getExpiryTimeout();h&&(this._timers[r]=setTimeout(()=>{this._reloadTile(r,"expired"),delete this._timers[r]},h))}_removeTile(r){const o=this._tiles[r];o&&(o.uses--,delete this._tiles[r],this._timers[r]&&(clearTimeout(this._timers[r]),delete this._timers[r]),o.uses>0||(o.hasData()&&"reloading"!==o.state||"empty"===o.state?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const r in this._tiles)this._removeTile(+r);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(r,o,h){const d=[],f=this.transform;if(!f)return d;const g="globe"===f.projection.name,x=a.a5(f.center.lng);for(const b in this._tiles){const T=this._tiles[b];if(h&&T.clearQueryDebugViz(),T.holdingForFade())continue;let M;if(g){const S=T.tileID.canonical;if(0===S.z){const C=[Math.abs(a.aa(x,...Ws(S,-1))-x),Math.abs(a.aa(x,...Ws(S,1))-x)];M=[0,2*C.indexOf(Math.min(...C))-1]}else{const C=[Math.abs(a.aa(x,...Ws(S,-1))-x),Math.abs(a.aa(x,...Ws(S,0))-x),Math.abs(a.aa(x,...Ws(S,1))-x)];M=[C.indexOf(Math.min(...C))-1]}}else M=[0];for(const S of M){const C=r.containsTile(T,f,o,S);C&&d.push(C)}}return d}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(r){return this._getRenderableCoordinates(r)}_getRenderableCoordinates(r,o){const h=this.getRenderableIds(r,o).map(f=>this._tiles[f].tileID),d="globe"===this.transform.projection.name;for(const f of h)f.projMatrix=this.transform.calculateProjMatrix(f.toUnwrapped()),f.expandedProjMatrix=d?this.transform.calculateProjMatrix(f.toUnwrapped(),!1,!0):f.projMatrix;return h}sortCoordinatesByDistance(r){const o=r.slice(),h=this.transform._camera.position,d=this.transform._camera.forward(),f={};for(const g of o){const x=1/(1<<g.canonical.z);f[g.key]=((g.canonical.x+.5)*x+g.wrap-h[0])*d[0]+((g.canonical.y+.5)*x-h[1])*d[1]-h[2]*d[2]}return o.sort((g,x)=>f[g.key]-f[x.key]),o}hasTransition(){if(this._source.hasTransition())return!0;if(Pn(this._source.type))for(const r in this._tiles){const o=this._tiles[r];if(void 0!==o.fadeEndTime&&o.fadeEndTime>=a.f.now())return!0}return!1}setFeatureState(r,o,h){this._state.updateState(r=r||"_geojsonTileLayer",o,h)}removeFeatureState(r,o,h){this._state.removeFeatureState(r=r||"_geojsonTileLayer",o,h)}getFeatureState(r,o){return this._state.getState(r=r||"_geojsonTileLayer",o)}setDependencies(r,o,h){const d=this._tiles[r];d&&d.setDependencies(o,h)}reloadTilesForDependencies(r,o){for(const h in this._tiles)this._tiles[h].hasDependency(r,o)&&this._reloadTile(+h,"reloading");this._cache.filter(h=>!h.hasDependency(r,o))}_preloadTiles(r,o){if(!this._sourceLoaded){const b=()=>{this._sourceLoaded&&(this._source.off("data",b),this._preloadTiles(r,o))};return void this._source.on("data",b)}const h=new Map,d=Array.isArray(r)?r:[r],f=this.map.painter.terrain,g=this.usedForTerrain&&f?f.getScaledDemTileSize():this._source.tileSize;for(const b of d){const T=b.coveringTiles({tileSize:g,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const M of T)h.set(M.key,M);this.usedForTerrain&&b.updateElevation(!1)}const x=Array.from(h.values());a.b1(x,(b,T)=>{const M=new Jn(b,this._source.tileSize*b.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(M,S=>{"raster-dem"===this._source.type&&M.dem&&this._backfillDEM(M),T(S,M)})},o)}}function Ha(c,r){const o=Math.abs(2*c.wrap)-+(c.wrap<0),h=Math.abs(2*r.wrap)-+(r.wrap<0);return c.overscaledZ-r.overscaledZ||h-o||r.canonical.y-c.canonical.y||r.canonical.x-c.canonical.x}function Pn(c){return"raster"===c||"image"===c||"video"===c||"custom"===c}function Ws(c,r){const o=1<<c.z;return[c.x/o+r,(c.x+1)/o+r]}nn.maxOverzooming=10,nn.maxUnderzooming=3;class Qh{constructor(r){this.style=r,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const r=!1,o=!1;for(const h in this.style._mergedLayers){const d=this.style._mergedLayers[h];if("fill-extrusion"===d.type)this.layers.push({layer:d,visible:r,visibilityChanged:o});else if("model"===d.type){const f=this.style.getLayerSource(d);f&&"batched-model"===f.type&&this.layers.push({layer:d,visible:r,visibilityChanged:o})}}}onNewFrame(r){this.layersGotHidden=!1;for(const o of this.layers){const h=o.layer;let d=!1;"fill-extrusion"===h.type?d=!h.isHidden(r)&&h.paint.get("fill-extrusion-opacity")>0:"model"===h.type&&(d=!h.isHidden(r)&&h.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!d&&o.visible,o.visible=d}}updateZOffset(r,o){this.currentBuildingBuckets=[];for(const d of this.layers){const f=d.layer,g=this.style.getLayerSourceCache(f);let x=1;"fill-extrusion"===f.type&&(x=d.visible?f.paint.get("fill-extrusion-vertical-scale"):0);let b=g?g.getTile(o):null;if(!b&&g&&o.canonical.z>g.getSource().minzoom){let T=o.scaledTo(Math.min(g.getSource().maxzoom,o.overscaledZ-1));for(;T.overscaledZ>=g.getSource().minzoom&&(b=g.getTile(T),!b&&0!==T.overscaledZ);)T=T.scaledTo(T.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:b?b.getBucket(f):null,tileID:b?b.tileID:o,verticalScale:x})}r.hasAnyZOffset=!1;let h=!1;for(let d=0;d<r.symbolInstances.length;d++){const f=r.symbolInstances.get(d),g=f.zOffset,x=this._getHeightAtTileOffset(o,f.tileAnchorX,f.tileAnchorY);f.zOffset=x!==Number.NEGATIVE_INFINITY?x:g,h||g===f.zOffset||(h=!0),r.hasAnyZOffset||0===f.zOffset||(r.hasAnyZOffset=!0)}h&&(r.zOffsetBuffersNeedUpload=!0,r.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(r,o,h,d){let f=o,g=h;if(r.canonical.z!==d.canonical.z){const x=d.canonical,b=1/(1<<r.canonical.z-x.z);f=(o+r.canonical.x*a.V)*b-x.x*a.V|0,g=(h+r.canonical.y*a.V)*b-x.y*a.V|0}return{tileX:f,tileY:g}}_getHeightAtTileOffset(r,o,h){let d,f;for(let g=0;g<this.layers.length;++g){if("fill-extrusion"!==this.layers[g].layer.type)continue;const{bucket:x,tileID:b,verticalScale:T}=this.currentBuildingBuckets[g];if(!x)continue;const{tileX:M,tileY:S}=this._mapCoordToOverlappingTile(r,o,h,b),C=x.getHeightAtTileCoord(M,S);C&&void 0!==C.height&&(C.hidden?d=C.height:f=Math.max(C.height*T,f||0))}if(void 0!==f)return f;for(let g=0;g<this.layers.length;++g){const x=this.layers[g];if("model"!==x.layer.type||!x.visible)continue;const{bucket:b,tileID:T}=this.currentBuildingBuckets[g];if(!b)continue;const{tileX:M,tileY:S}=this._mapCoordToOverlappingTile(r,o,h,T),C=b.getHeightAtTileCoord(M,S);if(C&&!C.hidden)return void 0===C.height&&void 0!==d?Math.min(C.maxHeight,d)*C.verticalScale:(C.height||0)*C.verticalScale}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Do(c,r){const o={};for(const h in c)"ref"!==h&&(o[h]=c[h]);return a.b2.forEach(h=>{h in r&&(o[h]=r[h])}),o}function eu(c){c=c.slice();const r=Object.create(null);for(let o=0;o<c.length;o++)r[c[o].id]=c[o];for(let o=0;o<c.length;o++)"ref"in c[o]&&(c[o]=Do(c[o],r[c[o].ref]));return c}const Gt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",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",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport"};function Hs(c,r,o){o.push({command:Gt.addSource,args:[c,r[c]]})}function ic(c,r,o){r.push({command:Gt.removeSource,args:[c]}),o[c]=!0}function $d(c,r,o,h){ic(c,o,h),Hs(c,r,o)}function Wd(c,r,o){let h;for(h in c[o])if(c[o].hasOwnProperty(h)&&"data"!==h&&!Pt(c[o][h],r[o][h]))return!1;for(h in r[o])if(r[o].hasOwnProperty(h)&&"data"!==h&&!Pt(c[o][h],r[o][h]))return!1;return!0}function Qn(c,r,o,h,d,f){let g;for(g in r=r||{},c=c||{})c.hasOwnProperty(g)&&(Pt(c[g],r[g])||o.push({command:f,args:[h,g,r[g],d]}));for(g in r)r.hasOwnProperty(g)&&!c.hasOwnProperty(g)&&(Pt(c[g],r[g])||o.push({command:f,args:[h,g,r[g],d]}))}function eo(c){return c.id}function Xa(c,r){return c[r.id]=r,c}class hs{constructor(r,o){this.reset(r,o)}reset(r,o){this.points=r||[],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(r){if(1===this.points.length)return this.points[0];r=a.aa(r,0,1);let o=1,h=this._distances[o];const d=r*this.paddedLength+this.padding;for(;h<d&&o<this._distances.length;)h=this._distances[++o];const f=o-1,g=this._distances[f],x=h-g,b=x>0?(d-g)/x:0;return this.points[f].mult(1-b).add(this.points[o].mult(b))}}class rc{constructor(r,o,h){const d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(r/h),this.yCellCount=Math.ceil(o/h);for(let g=0;g<this.xCellCount*this.yCellCount;g++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=r,this.height=o,this.xScale=this.xCellCount/r,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(r,o,h,d,f){this._forEachCell(o,h,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(r),this.bboxes.push(o),this.bboxes.push(h),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(r,o,h,d){this._forEachCell(o-d,h-d,o+d,h+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(r),this.circles.push(o),this.circles.push(h),this.circles.push(d)}_insertBoxCell(r,o,h,d,f,g){this.boxCells[f].push(g)}_insertCircleCell(r,o,h,d,f,g){this.circleCells[f].push(g)}_query(r,o,h,d,f,g){if(h<0||r>this.width||d<0||o>this.height)return!f&&[];const x=[];if(r<=0&&o<=0&&this.width<=h&&this.height<=d){if(f)return!0;for(let b=0;b<this.boxKeys.length;b++)x.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const T=this.circles[3*b],M=this.circles[3*b+1],S=this.circles[3*b+2];x.push({key:this.circleKeys[b],x1:T-S,y1:M-S,x2:T+S,y2:M+S})}return g?x.filter(g):x}return this._forEachCell(r,o,h,d,this._queryCell,x,{hitTest:f,seenUids:{box:{},circle:{}}},g),f?x.length>0:x}_queryCircle(r,o,h,d,f){const g=r-h,x=r+h,b=o-h,T=o+h;if(x<0||g>this.width||T<0||b>this.height)return!d&&[];const M=[];return this._forEachCell(g,b,x,T,this._queryCellCircle,M,{hitTest:d,circle:{x:r,y:o,radius:h},seenUids:{box:{},circle:{}}},f),d?M.length>0:M}query(r,o,h,d,f){return this._query(r,o,h,d,!1,f)}hitTest(r,o,h,d,f){return this._query(r,o,h,d,!0,f)}hitTestCircle(r,o,h,d){return this._queryCircle(r,o,h,!0,d)}_queryCell(r,o,h,d,f,g,x,b){const T=x.seenUids,M=this.boxCells[f];if(null!==M){const C=this.bboxes;for(const P of M)if(!T.box[P]){T.box[P]=!0;const k=4*P;if(r<=C[k+2]&&o<=C[k+3]&&h>=C[k+0]&&d>=C[k+1]&&(!b||b(this.boxKeys[P]))){if(x.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[P],x1:C[k],y1:C[k+1],x2:C[k+2],y2:C[k+3]})}}}const S=this.circleCells[f];if(null!==S){const C=this.circles;for(const P of S)if(!T.circle[P]){T.circle[P]=!0;const k=3*P;if(this._circleAndRectCollide(C[k],C[k+1],C[k+2],r,o,h,d)&&(!b||b(this.circleKeys[P]))){if(x.hitTest)return g.push(!0),!0;{const R=C[k],O=C[k+1],D=C[k+2];g.push({key:this.circleKeys[P],x1:R-D,y1:O-D,x2:R+D,y2:O+D})}}}}}_queryCellCircle(r,o,h,d,f,g,x,b){const T=x.circle,M=x.seenUids,S=this.boxCells[f];if(null!==S){const P=this.bboxes;for(const k of S)if(!M.box[k]){M.box[k]=!0;const R=4*k;if(this._circleAndRectCollide(T.x,T.y,T.radius,P[R+0],P[R+1],P[R+2],P[R+3])&&(!b||b(this.boxKeys[k])))return g.push(!0),!0}}const C=this.circleCells[f];if(null!==C){const P=this.circles;for(const k of C)if(!M.circle[k]){M.circle[k]=!0;const R=3*k;if(this._circlesCollide(P[R],P[R+1],P[R+2],T.x,T.y,T.radius)&&(!b||b(this.circleKeys[k])))return g.push(!0),!0}}}_forEachCell(r,o,h,d,f,g,x,b){const T=this._convertToXCellCoord(r),M=this._convertToYCellCoord(o),S=this._convertToXCellCoord(h),C=this._convertToYCellCoord(d);for(let P=T;P<=S;P++)for(let k=M;k<=C;k++)if(f.call(this,r,o,h,d,this.xCellCount*k+P,g,x,b))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,o,h,d,f,g){const x=d-r,b=f-o,T=h+g;return T*T>x*x+b*b}_circleAndRectCollide(r,o,h,d,f,g,x){const b=(g-d)/2,T=Math.abs(r-(d+b));if(T>b+h)return!1;const M=(x-f)/2,S=Math.abs(o-(f+M));if(S>M+h)return!1;if(T<=b||S<=M)return!0;const C=T-b,P=S-M;return C*C+P*P<=h*h}}const zn_unknown=0,zn_flipRequired=1,zn_flipNotRequired=2,to=Math.tan(85*Math.PI/180);function Xs(c,r,o,h,d,f,g){const x=a.a6.create();if(o)if("globe"===f.name){const b=a.b3(d,r);a.a6.multiply(x,x,b)}else{const b=a.b4.invert([],g);x[0]=b[0],x[1]=b[1],x[4]=b[2],x[5]=b[3],h||a.a6.rotateZ(x,x,d.angle)}else a.a6.multiply(x,d.labelPlaneMatrix,c);return x}function nc(c,r,o,h,d,f,g){const x=Xs(c,r,o,h,d,f,g);return"globe"===f.name&&o||(x[2]=x[6]=x[10]=x[14]=0),x}function oc(c,r,o,h,d,f,g){if(o){if("globe"===f.name){const x=Xs(c,r,o,h,d,f,g);return a.a6.invert(x,x),a.a6.multiply(x,c,x),x}{const x=a.a6.clone(c),b=a.a6.identity([]);return b[0]=g[0],b[1]=g[1],b[4]=g[2],b[5]=g[3],a.a6.multiply(x,x,b),h||a.a6.rotateZ(x,x,-d.angle),x}}return d.glCoordMatrix}function Wr(c,r,o,h){const d=[c,r,o,1];o?a.a7.transformMat4(d,d,h):uc(d,d,h);const f=d[3];return d[0]/=f,d[1]/=f,d[2]/=f,d}function tu(c,r){return Math.min(.5+c/r*.5,1.5)}function sc(c,r){const o=c[0]/c[3],h=c[1]/c[3];return o>=-r[0]&&o<=r[0]&&h>=-r[1]&&h<=r[1]}function ac(c,r,o,h,d,f,g,x,b,T){const M=o.transform,S=h?c.textSizeData:c.iconSizeData,C=a.b5(S,o.transform.zoom),P="globe"===M.projection.name,k=[256/o.width*2+1,256/o.height*2+1],R=h?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;R.clear();let O=null;P&&(O=h?c.text.globeExtVertexArray:c.icon.globeExtVertexArray);const D=c.lineVertexArray,F=h?c.text.placedSymbolArray:c.icon.placedSymbolArray,Z=o.transform.width/o.transform.height;let V,q=!1;for(let B=0;B<F.length;B++){const $=F.get(B),{numGlyphs:Y,writingMode:K}=$;if(K!==a.b6.vertical||q||V===a.b6.horizontal||(q=!0),V=K,($.hidden||K===a.b6.vertical)&&!q){io(Y,R);continue}q=!1;const ee=new a.P($.tileAnchorX,$.tileAnchorY);let{x:ce,y:re,z:me}=M.projection.projectTilePoint(ee.x,ee.y,T.canonical);if(b){const[je,et,ct]=b(ee);ce+=je,re+=et,me+=ct}const pe=[ce,re,me,1];if(a.a7.transformMat4(pe,pe,r),!sc(pe,k)){io(Y,R);continue}const Ae=pe[3],ne=tu(o.transform.getCameraToCenterDistance(M.projection),Ae),ue=a.b7(S,C,$),Q=g?ue/ne:ue*ne,ae=Wr(ce,re,me,d);if(ae[3]<=0){io(Y,R);continue}let Ie={};const Re=g?null:b,Le=hc($,Q,!1,x,r,d,f,c.glyphOffsetArray,D,R,O,ae,ee,Ie,Z,Re,M.projection,T,g);q=Le.useVertical,Re&&Le.needsFlipping&&(Ie={}),(Le.notEnoughRoom||q||Le.needsFlipping&&hc($,Q,!0,x,r,d,f,c.glyphOffsetArray,D,R,O,ae,ee,Ie,Z,Re,M.projection,T,g).notEnoughRoom)&&io(Y,R)}h?(c.text.dynamicLayoutVertexBuffer.updateData(R),O&&c.text.globeExtVertexBuffer&&c.text.globeExtVertexBuffer.updateData(O)):(c.icon.dynamicLayoutVertexBuffer.updateData(R),O&&c.icon.globeExtVertexBuffer&&c.icon.globeExtVertexBuffer.updateData(O))}function lc(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R){const{lineStartIndex:O,glyphStartIndex:D,segment:F}=x,Z=D+x.numGlyphs,V=O+x.lineLength,q=r.getoffsetX(D),B=r.getoffsetX(Z-1),$=Ys(c*q,o,h,d,f,g,F,O,V,b,T,M,S,C,!0,P,k,R);if(!$)return null;const Y=Ys(c*B,o,h,d,f,g,F,O,V,b,T,M,S,C,!0,P,k,R);return Y?{first:$,last:Y}:null}function cc(c,r,o,h){return c===a.b6.horizontal&&Math.abs(h)>Math.abs(o)?{useVertical:!0}:c===a.b6.vertical?h>0?{needsFlipping:!0}:null:r!==zn_unknown&&(0===(d=o)||Math.abs(h/d)>to)?r===zn_flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null;var d}function hc(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D,F){const Z=r/24,V=c.lineOffsetX*Z,q=c.lineOffsetY*Z,{lineStartIndex:B,glyphStartIndex:$,numGlyphs:Y,segment:K,writingMode:ee,flipState:ce}=c,re=B+c.lineLength,me=pe=>{if(M){const[Q,ae,Ie]=pe.up,Re=T.length;a.b8(M,Re+0,Q,ae,Ie),a.b8(M,Re+1,Q,ae,Ie),a.b8(M,Re+2,Q,ae,Ie),a.b8(M,Re+3,Q,ae,Ie)}const[Ae,ne,ue]=pe.point;a.b9(T,Ae,ne,ue,pe.angle)};if(Y>1){const pe=lc(Z,x,V,q,o,S,C,c,b,f,P,R,!1,O,D,F);if(!pe)return{notEnoughRoom:!0};if(h&&!o){let[Ae,ne,ue]=pe.first.point,[Q,ae,Ie]=pe.last.point;[Ae,ne]=Wr(Ae,ne,ue,g),[Q,ae]=Wr(Q,ae,Ie,g);const Re=cc(ee,ce,(Q-Ae)*k,ae-ne);if(c.flipState=Re&&Re.needsFlipping?zn_flipRequired:zn_flipNotRequired,Re)return Re}me(pe.first);for(let Ae=$+1;Ae<$+Y-1;Ae++){const ne=Ys(Z*x.getoffsetX(Ae),V,q,o,S,C,K,B,re,b,f,P,R,!1,!1,O,D,F);if(!ne)return T.length-=4*(Ae-$),{notEnoughRoom:!0};me(ne)}me(pe.last)}else{if(h&&!o){const Ae=Wr(C.x,C.y,0,d),ne=B+K+1,ue=new a.P(b.getx(ne),b.gety(ne)),Q=Wr(ue.x,ue.y,0,d),ae=Q[3]>0?Q:Ya(C,ue,Ae,1,d,void 0,O,D.canonical),Ie=cc(ee,ce,(ae[0]-Ae[0])*k,ae[1]-Ae[1]);if(c.flipState=Ie&&Ie.needsFlipping?zn_flipRequired:zn_flipNotRequired,Ie)return Ie}const pe=Ys(Z*x.getoffsetX($),V,q,o,S,C,K,B,re,b,f,P,R,!1,!1,O,D,F);if(!pe)return{notEnoughRoom:!0};me(pe)}return{}}function us(c,r,o,h,d){const{x:f,y:g,z:x}=h.projectTilePoint(c.x,c.y,r);if(!d)return Wr(f,g,x,o);const[b,T,M]=d(c);return Wr(f+b,g+T,x+M,o)}function Ya(c,r,o,h,d,f,g,x){const b=us(c.sub(r)._unit()._add(c),x,d,g,f);return a.N.sub(b,o,b),a.N.normalize(b,b),a.N.scaleAndAdd(b,o,b,h)}function Ys(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D){const F=h?c-r:c+r;let Z=F>0?1:-1,V=0;h&&(Z*=-1,V=Math.PI),Z<0&&(V+=Math.PI);let q=x+g+(Z>0?0:1)|0,B=d,$=d,Y=0,K=0;const ee=Math.abs(F),ce=[],re=[];let me=f,pe=me;const Ae=()=>Ya(pe,me,$,ee-Y+1,M,C,R,O.canonical);for(;Y+K<=ee;){if(q+=Z,q<x||q>=b)return null;if($=B,pe=me,ce.push($),P&&re.push(pe),me=new a.P(T.getx(q),T.gety(q)),B=S[q],!B){const et=us(me,O.canonical,M,R,C);B=et[3]>0?S[q]=et:Ae()}Y+=K,K=a.N.distance($,B)}k&&C&&(S[q]&&(B=Ae(),K=a.N.distance($,B)),S[q]=B);const ne=(ee-Y)/K,ue=me.sub(pe)._mult(ne)._add(pe),Q=a.N.sub([],B,$),ae=a.N.scaleAndAdd([],$,Q,ne);let Ie=[0,0,1],Re=Q[0],Le=Q[1];if(D&&(Ie=R.upVector(O.canonical,ue.x,ue.y),0!==Ie[0]||0!==Ie[1]||1!==Ie[2])){const et=[Ie[2],0,-Ie[0]],ct=a.N.cross([],Ie,et);a.N.normalize(et,et),a.N.normalize(ct,ct),Re=a.N.dot(Q,et),Le=a.N.dot(Q,ct)}if(o){const et=a.N.cross([],Ie,Q);a.N.normalize(et,et),a.N.scaleAndAdd(ae,ae,et,o*Z)}const je=V+Math.atan2(Le,Re);return ce.push(ae),P&&re.push(ue),{point:ae,angle:je,path:ce,tilePath:re,up:Ie}}function io(c,r){const o=r.length,h=o+4*c;r.resize(h),r.float32.fill(-1/0,4*o,4*h)}function uc(c,r,o){const h=r[0],d=r[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}const Hr=100;class qe{constructor(r,o,h=new rc(r.width+200,r.height+200,25),d=new rc(r.width+200,r.height+200,25)){this.transform=r,this.grid=h,this.ignoredGrid=d,this.pitchfactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+Hr,this.screenBottomBoundary=r.height+Hr,this.gridRightBoundary=r.width+200,this.gridBottomBoundary=r.height+200,this.fogState=o}placeCollisionBox(r,o,h,d,f,g,x,b){let T=h.projectedAnchorX,M=h.projectedAnchorY,S=h.projectedAnchorZ;const C=h.elevation,P=h.tileID,k=r.getProjection();if(C&&P){const[B,$,Y]=k.upVector(P.canonical,h.tileAnchorX,h.tileAnchorY),K=k.upVectorScale(P.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;T+=B*C*K,M+=$*C*K,S+=Y*C*K}const R=this.projectAndGetPerspectiveRatio(x,T,M,S,h.tileID,"globe"===k.name||!!C||this.transform.pitch>0,k),O=g*R.perspectiveRatio,D=(h.x1*o+d.x-h.padding)*O+R.point.x,F=(h.y1*o+d.y-h.padding)*O+R.point.y,Z=(h.x2*o+d.x+h.padding)*O+R.point.x,V=(h.y2*o+d.y+h.padding)*O+R.point.y,q=R.perspectiveRatio<=.55||R.occluded;return!this.isInsideGrid(D,F,Z,V)||!f&&this.grid.hitTest(D,F,Z,V,b)||q?{box:[],offscreen:!1,occluded:R.occluded}:{box:[D,F,Z,V],offscreen:this.isOffscreen(D,F,Z,V),occluded:!1}}placeCollisionCircles(r,o,h,d,f,g,x,b,T,M,S,C,P,k,R){const O=[],D=this.transform.elevation,F=r.getProjection(),Z=D?D.getAtTileOffsetFunc(R,this.transform.center.lat,this.transform.worldSize,F):null,V=new a.P(h.tileAnchorX,h.tileAnchorY);let{x:q,y:B,z:$}=F.projectTilePoint(V.x,V.y,R.canonical);if(Z){const[ue,Q,ae]=Z(V);q+=ue,B+=Q,$+=ae}const Y="globe"===F.name,K=this.projectAndGetPerspectiveRatio(x,q,B,$,R,Y||!!D||this.transform.pitch>0,F),{perspectiveRatio:ee}=K,ce=(S?g/ee:g*ee)/a.bc,re=Wr(q,B,$,b),me=K.signedDistanceFromCamera>0?lc(ce,f,h.lineOffsetX*ce,h.lineOffsetY*ce,!1,re,V,h,d,b,{},D&&!S?Z:null,S&&!!D,F,R,S):null;let pe=!1,Ae=!1,ne=!0;if(me&&!K.occluded){const ue=.5*P*ee+k,Q=new a.P(-100,-100),ae=new a.P(this.screenRightBoundary,this.screenBottomBoundary),Ie=new hs,{first:Re,last:Le}=me,je=Re.path.length;let et=[];for(let at=je-1;at>=1;at--)et.push(Re.path[at]);for(let at=1;at<Le.path.length;at++)et.push(Le.path[at]);const ct=2.5*ue;T&&(et=et.map(([at,Et,gt],bt)=>(Z&&!Y&&(gt=Z(bt<je-1?Re.tilePath[je-1-bt]:Le.tilePath[bt-je+2])[2]),Wr(at,Et,gt,T))),et.some(at=>at[3]<=0)&&(et=[]));let nt=[];if(et.length>0){let at=1/0,Et=-1/0,gt=1/0,bt=-1/0;for(const vt of et)at=Math.min(at,vt[0]),gt=Math.min(gt,vt[1]),Et=Math.max(Et,vt[0]),bt=Math.max(bt,vt[1]);Et>=Q.x&&at<=ae.x&&bt>=Q.y&&gt<=ae.y&&(nt=[et.map(vt=>new a.P(vt[0],vt[1]))],(at<Q.x||Et>ae.x||gt<Q.y||bt>ae.y)&&(nt=a.ba(nt,Q.x,Q.y,ae.x,ae.y)))}for(const at of nt){Ie.reset(at,.25*ue);let Et=0;Et=Ie.length<=.5*ue?1:Math.ceil(Ie.paddedLength/ct)+1;for(let gt=0;gt<Et;gt++){const bt=gt/Math.max(Et-1,1),vt=Ie.lerp(bt),Zt=vt.x+Hr,_i=vt.y+Hr;O.push(Zt,_i,ue,0);const Ot=Zt-ue,Ci=_i-ue,Bt=Zt+ue,Kt=_i+ue;if(ne=ne&&this.isOffscreen(Ot,Ci,Bt,Kt),Ae=Ae||this.isInsideGrid(Ot,Ci,Bt,Kt),!o&&this.grid.hitTestCircle(Zt,_i,ue,C)&&(pe=!0,!M))return{circles:[],offscreen:!1,collisionDetected:pe,occluded:!1}}}}return{circles:!M&&pe||!Ae?[]:O,offscreen:ne,collisionDetected:pe,occluded:K.occluded}}queryRenderedSymbols(r){if(0===r.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const o=[];let h=1/0,d=1/0,f=-1/0,g=-1/0;for(const M of r){const S=new a.P(M.x+Hr,M.y+Hr);h=Math.min(h,S.x),d=Math.min(d,S.y),f=Math.max(f,S.x),g=Math.max(g,S.y),o.push(S)}const x=this.grid.query(h,d,f,g).concat(this.ignoredGrid.query(h,d,f,g)),b={},T={};for(const M of x){const S=M.key;if(void 0===b[S.bucketInstanceId]&&(b[S.bucketInstanceId]={}),b[S.bucketInstanceId][S.featureIndex])continue;const C=[new a.P(M.x1,M.y1),new a.P(M.x2,M.y1),new a.P(M.x2,M.y2),new a.P(M.x1,M.y2)];a.bb(o,C)&&(b[S.bucketInstanceId][S.featureIndex]=!0,void 0===T[S.bucketInstanceId]&&(T[S.bucketInstanceId]=[]),T[S.bucketInstanceId].push(S.featureIndex))}return T}insertCollisionBox(r,o,h,d,f){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:h,featureIndex:d,collisionGroupID:f},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,o,h,d,f){const g=o?this.ignoredGrid:this.grid,x={bucketInstanceId:h,featureIndex:d,collisionGroupID:f};for(let b=0;b<r.length;b+=4)g.insertCircle(x,r[b],r[b+1],r[b+2])}projectAndGetPerspectiveRatio(r,o,h,d,f,g,x){const b=[o,h,d,1];let T=!1;d||this.transform.pitch>0?(a.a7.transformMat4(b,b,r),this.fogState&&f&&"globe"!==x.name&&(T=function(C,P,k,R,O,D){const F=D.calculateFogTileMatrix(O),Z=[P,k,R];return a.N.transformMat4(Z,Z,F),ri(C,a.N.length(Z),D.pitch,D._fov)}(this.fogState,o,h,d,f.toUnwrapped(),this.transform)>.9)):uc(b,b,r);const M=b[3];return{point:new a.P((b[0]/M+1)/2*this.transform.width+Hr,(-b[1]/M+1)/2*this.transform.height+Hr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(x)/M*.5,1.5),signedDistanceFromCamera:M,occluded:g&&b[2]>M||T}}isOffscreen(r,o,h,d){return h<Hr||r>=this.screenRightBoundary||d<Hr||o>this.screenBottomBoundary}isInsideGrid(r,o,h,d){return h>=0&&r<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){const r=a.a6.identity([]);return a.a6.translate(r,r,[-100,-100,0]),r}}function Ka(c,r,o){const h=r.createTileMatrix(c,c.worldSize,o.toUnwrapped());return a.a6.multiply(new Float32Array(16),c.projMatrix,h)}function dc(c,r,o){if(r.projection.name===o.projection.name)return c.projMatrix;const h=o.clone();return h.setProjection(r.projection),Ka(h,r.getProjection(),c)}function Ks(c,r,o){return r.name===o.projection.name?c.projMatrix:Ka(o,r,c)}class pc{constructor(r,o,h,d){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?o:-o))):d&&h?1:0,this.placed=h}isHidden(){return 0===this.opacity&&!this.placed}}class ro{constructor(r,o,h,d,f,g=!1){this.text=new pc(r?r.text:null,o,h,f),this.icon=new pc(r?r.icon:null,o,d,f),this.clipped=g}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class on{constructor(r,o,h,d=!1){this.text=r,this.icon=o,this.skipFade=h,this.clipped=d}}class fc{constructor(){this.invProjMatrix=a.a6.create(),this.viewportMatrix=a.a6.create(),this.circles=[]}}class Lo{constructor(r,o,h,d,f){this.bucketInstanceId=r,this.featureIndex=o,this.sourceLayerIndex=h,this.bucketIndex=d,this.tileID=f}}class Ja{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const o=++this.maxGroupID;this.collisionGroups[r]={ID:o,predicate:h=>h.collisionGroupID===o}}return this.collisionGroups[r]}}function Ro(c,r,o,h,d){const{horizontalAlign:f,verticalAlign:g}=a.bf(c),x=-(f-.5)*r,b=-(g-.5)*o,T=a.bd(c,h);return new a.P(x+T[0]*d,b+T[1]*d)}function mc(c,r,o,h,d){const f=new a.P(c,r);return o&&f._rotate(h?d:-d),f}class Hd{constructor(r,o,h,d,f,g){this.transform=r.clone(),this.projection=r.projection.name,this.collisionIndex=new qe(this.transform,f),this.buildingIndex=g,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Ja(h),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,o,h,d){const f=h.getBucket(o),g=h.latestFeatureIndex;if(!f||!g||o.fqid!==f.layerIds[0])return;const x=f.layers[0].layout,b=h.collisionBoxArray,T=Math.pow(2,this.transform.zoom-h.tileID.overscaledZ),M=h.tileSize/a.V,S=h.tileID.toUnwrapped();this.transform.setProjection(f.projection);const C=(P=h.tileID,k=f.getProjection(),R=this.transform,k.name===this.projection?R.calculateProjMatrix(P.toUnwrapped()):Ka(R,k,P));var P,k,R;const O="map"===x.get("text-pitch-alignment"),D="map"===x.get("text-rotation-alignment");o.compileFilter();const F=o.dynamicFilter(),Z=o.dynamicFilterNeedsFeature(),V=this.transform.calculatePixelsToTileUnitsMatrix(h),q=nc(C,h.tileID.canonical,O,D,this.transform,f.getProjection(),V);let B=null;if(O){const K=oc(C,h.tileID.canonical,O,D,this.transform,f.getProjection(),V);B=a.a6.multiply([],this.transform.labelPlaneMatrix,K)}let $=null;F&&h.latestFeatureIndex&&($={unwrappedTileID:S,dynamicFilter:F,dynamicFilterNeedsFeature:Z,featureIndex:h.latestFeatureIndex}),this.retainedQueryData[f.bucketInstanceId]=new Lo(f.bucketInstanceId,g,f.sourceLayerIndex,f.index,h.tileID);const Y={bucket:f,layout:x,posMatrix:C,textLabelPlaneMatrix:q,labelToScreenMatrix:B,clippingData:$,scale:T,textPixelRatio:M,holdingForFade:h.holdingForFade(),collisionBoxArray:b,partiallyEvaluatedTextSize:a.b5(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.b5(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(d)for(const K of f.sortKeyRanges){const{sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:re}=K;r.push({sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:re,parameters:Y})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:Y})}attemptAnchorPlacement(r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D,F){const{textOffset0:Z,textOffset1:V,crossTileID:q}=C,B=[Z,V],$=Ro(r,h,d,B,f),Y=this.collisionIndex.placeCollisionBox(k,f,o,mc($.x,$.y,g,x,this.transform.angle),S,b,T,M.predicate);if(O){const K=k.getSymbolInstanceIconSize(F,this.transform.zoom,C.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(k,K,O,mc($.x,$.y,g,x,this.transform.angle),S,b,T,M.predicate).box.length)return}if(Y.box.length>0){let K;return this.prevPlacement&&this.prevPlacement.variableOffsets[q]&&this.prevPlacement.placements[q]&&this.prevPlacement.placements[q].text&&(K=this.prevPlacement.variableOffsets[q].anchor),this.variableOffsets[q]={textOffset:B,width:h,height:d,anchor:r,textScale:f,prevAnchor:K},this.markUsedJustification(k,r,C,R),k.allowVerticalPlacement&&(this.markUsedOrientation(k,R,C),this.placedOrientations[q]=R),{shift:$,placedGlyphBoxes:Y}}}placeLayerBucketPart(r,o,h,d){const{bucket:f,layout:g,posMatrix:x,textLabelPlaneMatrix:b,labelToScreenMatrix:T,clippingData:M,textPixelRatio:S,holdingForFade:C,collisionBoxArray:P,partiallyEvaluatedTextSize:k,partiallyEvaluatedIconSize:R,collisionGroup:O}=r.parameters,D=g.get("text-optional"),F=g.get("icon-optional"),Z=g.get("text-allow-overlap"),V=g.get("icon-allow-overlap"),q="map"===g.get("text-rotation-alignment"),B="map"===g.get("text-pitch-alignment"),$="viewport-y"===g.get("symbol-z-order"),Y=g.get("symbol-z-elevate");this.transform.setProjection(f.projection);let K=Z&&(V||!f.hasIconData()||F),ee=V&&(Z||!f.hasTextData()||D);!f.collisionArrays&&P&&f.deserializeCollisionBoxes(P),h&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,P);const ce=(re,me,pe)=>{const{crossTileID:Ae,numVerticalGlyphVertices:ne}=re;if(M){const Bt={zoom:this.transform.zoom,pitch:this.transform.pitch};let Kt=null;if(M.dynamicFilterNeedsFeature){const Ft=this.retainedQueryData[f.bucketInstanceId];Kt=M.featureIndex.loadFeature({featureIndex:re.featureIndex,bucketIndex:Ft.bucketIndex,sourceLayerIndex:Ft.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,M.dynamicFilter)(Bt,Kt,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new a.P(re.tileAnchorX,re.tileAnchorY),this.transform.calculateDistanceTileData(M.unwrappedTileID)))return this.placements[Ae]=new on(!1,!1,!1,!0),void o.add(Ae)}if(o.has(Ae))return;if(C)return void(this.placements[Ae]=new on(!1,!1,!1));let ue=!1,Q=!1,ae=!0,Ie=!1,Re=!1,Le=null,je={box:null,offscreen:null,occluded:null},et={box:null,offscreen:null,occluded:null},ct=null,nt=null,at=null,Et=0,gt=0,bt=0;pe.textFeatureIndex?Et=pe.textFeatureIndex:re.useRuntimeCollisionCircles&&(Et=re.featureIndex),pe.verticalTextFeatureIndex&&(gt=pe.verticalTextFeatureIndex);const vt=Bt=>{Bt.tileID=this.retainedQueryData[f.bucketInstanceId].tileID;const Kt=this.transform.elevation;Bt.elevation=re.zOffset+(Kt?Kt.getAtTileOffset(Bt.tileID,Bt.tileAnchorX,Bt.tileAnchorY):0)},Zt=pe.textBox;if(Zt){vt(Zt);const Bt=Ft=>{let Yt=a.b6.horizontal;if(f.allowVerticalPlacement&&!Ft&&this.prevPlacement){const yi=this.prevPlacement.placedOrientations[Ae];yi&&(this.placedOrientations[Ae]=yi,Yt=yi,this.markUsedOrientation(f,Yt,re))}return Yt},Kt=(Ft,Yt)=>{if(f.allowVerticalPlacement&&ne>0&&pe.verticalTextBox){for(const yi of f.writingModes)if(yi===a.b6.vertical?(je=Yt(),et=je):je=Ft(),je&&je.box&&je.box.length)break}else je=Ft()};if(g.get("text-variable-anchor")){let Ft=g.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ae]){const ii=this.prevPlacement.variableOffsets[Ae];Ft.indexOf(ii.anchor)>0&&(Ft=Ft.filter(Qi=>Qi!==ii.anchor),Ft.unshift(ii.anchor))}const Yt=(ii,Qi,hr)=>{const Pr=f.getSymbolInstanceTextSize(k,re,this.transform.zoom,me),bn=(ii.x2-ii.x1)*Pr+2*ii.padding,zr=(ii.y2-ii.y1)*Pr+2*ii.padding,er=re.hasIconTextFit&&!V?Qi:null;er&&vt(er);let Hi={box:[],offscreen:!1,occluded:!1};const yr=Z?2*Ft.length:Ft.length;for(let Tr=0;Tr<yr;++Tr){const Dr=this.attemptAnchorPlacement(Ft[Tr%Ft.length],ii,bn,zr,Pr,q,B,S,x,O,Tr>=Ft.length,re,me,f,hr,er,k,R);if(Dr&&(Hi=Dr.placedGlyphBoxes,Hi&&Hi.box&&Hi.box.length)){ue=!0,Le=Dr.shift;break}}return Hi};Kt(()=>Yt(Zt,pe.iconBox,a.b6.horizontal),()=>{const ii=pe.verticalTextBox;return ii&&vt(ii),f.allowVerticalPlacement&&!(je&&je.box&&je.box.length)&&ne>0&&ii?Yt(ii,pe.verticalIconBox,a.b6.vertical):{box:null,offscreen:null,occluded:null}}),je&&(ue=je.box,ae=je.offscreen,Ie=je.occluded);const yi=Bt(!(!je||!je.box));if(!ue&&this.prevPlacement){const ii=this.prevPlacement.variableOffsets[Ae];ii&&(this.variableOffsets[Ae]=ii,this.markUsedJustification(f,ii.anchor,re,yi))}}else{const Ft=(Yt,yi)=>{const ii=f.getSymbolInstanceTextSize(k,re,this.transform.zoom,me),Qi=this.collisionIndex.placeCollisionBox(f,ii,Yt,new a.P(0,0),Z,S,x,O.predicate);return Qi&&Qi.box&&Qi.box.length&&(this.markUsedOrientation(f,yi,re),this.placedOrientations[Ae]=yi),Qi};Kt(()=>Ft(Zt,a.b6.horizontal),()=>{const Yt=pe.verticalTextBox;return f.allowVerticalPlacement&&ne>0&&Yt?(vt(Yt),Ft(Yt,a.b6.vertical)):{box:null,offscreen:null,occluded:null}}),Bt(!!(je&&je.box&&je.box.length))}}if(ct=je,ue=ct&&ct.box&&ct.box.length>0,ae=ct&&ct.offscreen,Ie=ct&&ct.occluded,re.useRuntimeCollisionCircles){const Bt=f.text.placedSymbolArray.get(re.centerJustifiedTextSymbolIndex>=0?re.centerJustifiedTextSymbolIndex:re.verticalPlacedTextSymbolIndex),Kt=a.b7(f.textSizeData,k,Bt),Ft=g.get("text-padding");nt=this.collisionIndex.placeCollisionCircles(f,Z,Bt,f.lineVertexArray,f.glyphOffsetArray,Kt,x,b,T,h,B,O.predicate,re.collisionCircleDiameter*Kt/a.bc,Ft,this.retainedQueryData[f.bucketInstanceId].tileID),ue=Z||nt.circles.length>0&&!nt.collisionDetected,ae=ae&&nt.offscreen,Ie=nt.occluded}if(pe.iconFeatureIndex&&(bt=pe.iconFeatureIndex),pe.iconBox){const Bt=Kt=>{vt(Kt);const Ft=re.hasIconTextFit&&Le?mc(Le.x,Le.y,q,B,this.transform.angle):new a.P(0,0),Yt=f.getSymbolInstanceIconSize(R,this.transform.zoom,re.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(f,Yt,Kt,Ft,V,S,x,O.predicate)};et&&et.box&&et.box.length&&pe.verticalIconBox?(at=Bt(pe.verticalIconBox),Q=at.box.length>0):(at=Bt(pe.iconBox),Q=at.box.length>0),ae=ae&&at.offscreen,Re=at.occluded}const _i=D||0===re.numHorizontalGlyphVertices&&0===ne,Ot=F||0===re.numIconVertices;if(_i||Ot?Ot?_i||(Q=Q&&ue):ue=Q&&ue:Q=ue=Q&&ue,ue&&ct&&ct.box&&this.collisionIndex.insertCollisionBox(ct.box,g.get("text-ignore-placement"),f.bucketInstanceId,et&&et.box&&gt?gt:Et,O.ID),Q&&at&&this.collisionIndex.insertCollisionBox(at.box,g.get("icon-ignore-placement"),f.bucketInstanceId,bt,O.ID),nt&&(ue&&this.collisionIndex.insertCollisionCircles(nt.circles,g.get("text-ignore-placement"),f.bucketInstanceId,Et,O.ID),h)){const Bt=f.bucketInstanceId;let Kt=this.collisionCircleArrays[Bt];void 0===Kt&&(Kt=this.collisionCircleArrays[Bt]=new fc);for(let Ft=0;Ft<nt.circles.length;Ft+=4)Kt.circles.push(nt.circles[Ft+0]),Kt.circles.push(nt.circles[Ft+1]),Kt.circles.push(nt.circles[Ft+2]),Kt.circles.push(nt.collisionDetected?1:0)}const Ci="globe"!==f.projection.name;K=K&&(Ci||!Ie),ee=ee&&(Ci||!Re),this.placements[Ae]=new on(ue||K,Q||ee,ae||f.justReloaded),o.add(Ae)};if(Y&&this.buildingIndex&&(this.buildingIndex.updateZOffset(f,this.retainedQueryData[f.bucketInstanceId].tileID),f.updateZOffset()),$){const re=f.getSortedSymbolIndexes(this.transform.angle);for(let me=re.length-1;me>=0;--me){const pe=re[me];ce(f.symbolInstances.get(pe),pe,f.collisionArrays[pe])}f.hasAnyZOffset&&a.w(`${f.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(f.hasAnyZOffset){const re=f.getSortedIndexesByZOffset();for(let me=0;me<re.length;++me){const pe=re[me];ce(f.symbolInstances.get(pe),pe,f.collisionArrays[pe])}}else for(let re=r.symbolInstanceStart;re<r.symbolInstanceEnd;re++)ce(f.symbolInstances.get(re),re,f.collisionArrays[re]);if(h&&f.bucketInstanceId in this.collisionCircleArrays){const re=this.collisionCircleArrays[f.bucketInstanceId];a.a6.invert(re.invProjMatrix,x),re.viewportMatrix=this.collisionIndex.getViewportMatrix()}f.justReloaded=!1}markUsedJustification(r,o,h,d){const{leftJustifiedTextSymbolIndex:f,centerJustifiedTextSymbolIndex:g,rightJustifiedTextSymbolIndex:x,verticalPlacedTextSymbolIndex:b,crossTileID:T}=h,M=a.be(o),S=d===a.b6.vertical?b:"left"===M?f:"center"===M?g:"right"===M?x:-1;f>=0&&(r.text.placedSymbolArray.get(f).crossTileID=S>=0&&f!==S?0:T),g>=0&&(r.text.placedSymbolArray.get(g).crossTileID=S>=0&&g!==S?0:T),x>=0&&(r.text.placedSymbolArray.get(x).crossTileID=S>=0&&x!==S?0:T),b>=0&&(r.text.placedSymbolArray.get(b).crossTileID=S>=0&&b!==S?0:T)}markUsedOrientation(r,o,h){const d=o===a.b6.horizontal||o===a.b6.horizontalOnly?o:0,f=o===a.b6.vertical?o:0,{leftJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:x,rightJustifiedTextSymbolIndex:b,verticalPlacedTextSymbolIndex:T}=h,M=r.text.placedSymbolArray;g>=0&&(M.get(g).placedOrientation=d),x>=0&&(M.get(x).placedOrientation=d),b>=0&&(M.get(b).placedOrientation=d),T>=0&&(M.get(T).placedOrientation=f)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const o=this.prevPlacement;let h=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;const d=o?o.symbolFadeChange(r):1,f=o?o.opacities:{},g=o?o.variableOffsets:{},x=o?o.placedOrientations:{};for(const b in this.placements){const T=this.placements[b],M=f[b];M?(this.opacities[b]=new ro(M,d,T.text,T.icon,null,T.clipped),h=h||T.text!==M.text.placed||T.icon!==M.icon.placed):(this.opacities[b]=new ro(null,d,T.text,T.icon,T.skipFade,T.clipped),h=h||T.text||T.icon)}for(const b in f){const T=f[b];if(!this.opacities[b]){const M=new ro(T,d,!1,!1);M.isHidden()||(this.opacities[b]=M,h=h||T.text.placed||T.icon.placed)}}for(const b in g)this.variableOffsets[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.variableOffsets[b]=g[b]);for(const b in x)this.placedOrientations[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.placedOrientations[b]=x[b]);h?this.lastPlacementChangeTime=r:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:r)}updateLayerOpacities(r,o){const h=new Set;for(const d of o){const f=d.getBucket(r);f&&d.latestFeatureIndex&&r.fqid===f.layerIds[0]&&(this.updateBucketOpacities(f,h,d.collisionBoxArray),f.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(f,d.tileID),f.updateZOffset()))}}updateBucketOpacities(r,o,h){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const d=r.layers[0].layout,f=!!r.layers[0].dynamicFilter(),g=new ro(null,0,!1,!1,!0),x=d.get("text-allow-overlap"),b=d.get("icon-allow-overlap"),T=d.get("text-variable-anchor"),M="map"===d.get("text-rotation-alignment"),S="map"===d.get("text-pitch-alignment"),C=new ro(null,0,x&&(b||!r.hasIconData()||d.get("icon-optional")),b&&(x||!r.hasTextData()||d.get("text-optional")),!0);!r.collisionArrays&&h&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(h);const P=(R,O,D)=>{for(let F=0;F<O/4;F++)R.opacityVertexArray.emplaceBack(D)};let k=0;for(let R=0;R<r.symbolInstances.length;R++){const O=r.symbolInstances.get(R),{numHorizontalGlyphVertices:D,numVerticalGlyphVertices:F,crossTileID:Z,numIconVertices:V}=O,q=o.has(Z);let B=this.opacities[Z];q?B=g:B||(B=C,this.opacities[Z]=B),o.add(Z);const $=D>0||F>0,Y=V>0,K=this.placedOrientations[Z],ee=K===a.b6.vertical,ce=K===a.b6.horizontal||K===a.b6.horizontalOnly;if(!$&&!Y||B.isHidden()||k++,$){const re=nu(B.text);P(r.text,D,ee?Js:re),P(r.text,F,ce?Js:re);const me=B.text.isHidden(),{leftJustifiedTextSymbolIndex:pe,centerJustifiedTextSymbolIndex:Ae,rightJustifiedTextSymbolIndex:ne,verticalPlacedTextSymbolIndex:ue}=O,Q=r.text.placedSymbolArray,ae=me||ee?1:0;pe>=0&&(Q.get(pe).hidden=ae),Ae>=0&&(Q.get(Ae).hidden=ae),ne>=0&&(Q.get(ne).hidden=ae),ue>=0&&(Q.get(ue).hidden=me||ce?1:0);const Ie=this.variableOffsets[Z];Ie&&this.markUsedJustification(r,Ie.anchor,O,K);const Re=this.placedOrientations[Z];Re&&(this.markUsedJustification(r,"left",O,Re),this.markUsedOrientation(r,Re,O))}if(Y){const re=nu(B.icon),{placedIconSymbolIndex:me,verticalPlacedIconSymbolIndex:pe}=O,Ae=r.icon.placedSymbolArray,ne=B.icon.isHidden()?1:0;me>=0&&(P(r.icon,V,ee?Js:re),Ae.get(me).hidden=ne),pe>=0&&(P(r.icon,O.numVerticalIconVertices,ce?Js:re),Ae.get(pe).hidden=ne)}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const re=r.collisionArrays[R];if(re){let me=new a.P(0,0),pe=!0;if(re.textBox||re.verticalTextBox){if(T){const ne=this.variableOffsets[Z];ne?(me=Ro(ne.anchor,ne.width,ne.height,ne.textOffset,ne.textScale),M&&me._rotate(S?this.transform.angle:-this.transform.angle)):pe=!1}f&&(pe=!B.clipped),re.textBox&&ds(r.textCollisionBox.collisionVertexArray,B.text.placed,!pe||ee,me.x,me.y),re.verticalTextBox&&ds(r.textCollisionBox.collisionVertexArray,B.text.placed,!pe||ce,me.x,me.y)}const Ae=pe&&!(ce||!re.verticalIconBox);re.iconBox&&ds(r.iconCollisionBox.collisionVertexArray,B.icon.placed,Ae,O.hasIconTextFit?me.x:0,O.hasIconTextFit?me.y:0),re.verticalIconBox&&ds(r.iconCollisionBox.collisionVertexArray,B.icon.placed,!Ae,O.hasIconTextFit?me.x:0,O.hasIconTextFit?me.y:0)}}}if(r.fullyClipped=0===k,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const R=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=R.invProjMatrix,r.placementViewportMatrix=R.viewportMatrix,r.collisionCircleArray=R.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return 0===this.fadeDuration?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,o){const h=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*h>r}setStale(){this.stale=!0}}function ds(c,r,o,h,d){c.emplaceBack(r?1:0,o?1:0,h||0,d||0),c.emplaceBack(r?1:0,o?1:0,h||0,d||0),c.emplaceBack(r?1:0,o?1:0,h||0,d||0),c.emplaceBack(r?1:0,o?1:0,h||0,d||0)}const Xd=Math.pow(2,25),iu=Math.pow(2,24),ru=Math.pow(2,17),_c=Math.pow(2,16),Yd=Math.pow(2,9),Kd=Math.pow(2,8),Jd=Math.pow(2,1);function nu(c){if(0===c.opacity&&!c.placed)return 0;if(1===c.opacity&&c.placed)return 4294967295;const r=c.placed?1:0,o=Math.floor(127*c.opacity);return o*Xd+r*iu+o*ru+r*_c+o*Yd+r*Kd+o*Jd+r}const Js=0;class Qd{constructor(r){this._sortAcrossTiles="viewport-y"!==r.layout.get("symbol-z-order")&&void 0!==r.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(r,o,h,d,f){const g=this._bucketParts;for(;this._currentTileIndex<r.length;)if(o.getBucketParts(g,d,r[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((x,b)=>x.sortKey-b.sortKey));this._currentPartIndex<g.length;){const x=g[this._currentPartIndex];if(o.placeLayerBucketPart(x,this._seenCrossTileIDs,h,0===x.symbolInstanceStart),this._currentPartIndex++,f())return!0}return!1}}class Qa{constructor(r,o,h,d,f,g,x,b,T){this.placement=new Hd(r,f,g,x,b,T),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=h,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(r,o,h,d){const f=a.f.now(),g=()=>{const x=a.f.now()-f;return!this._forceFullPlacement&&x>2};for(;this._currentPlacementIndex>=0;){const x=o[r[this._currentPlacementIndex]],b=this.placement.collisionIndex.transform.zoom;if("symbol"===x.type&&(!x.minzoom||x.minzoom<=b)&&(!x.maxzoom||x.maxzoom>b)){const T=x,M=T.layout.get("symbol-z-elevate"),S=this._inProgressLayer=this._inProgressLayer||new Qd(T),C=a.ag(x.source,x.scope);if(S.continuePlacement(M?d[C]:h[C],this.placement,this._showCollisionBoxes,x,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const gc=512/a.V/2;class ou{constructor(r,o,h){this.tileID=r,this.bucketInstanceId=h,this.index=new a.bg(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const d=r.canonical.x*a.V,f=r.canonical.y*a.V;for(let g=0;g<o.length;g++){const{key:x,crossTileID:b,tileAnchorX:T,tileAnchorY:M}=o.get(g),S=Math.floor((d+T)*gc),C=Math.floor((f+M)*gc);this.index.add(S,C),this.keys.push(x),this.crossTileIDs.push(b)}this.index.finish()}findMatches(r,o,h){const d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),f=gc/Math.pow(2,o.canonical.z-this.tileID.canonical.z),g=o.canonical.x*a.V,x=o.canonical.y*a.V;for(let b=0;b<r.length;b++){const T=r.get(b);if(T.crossTileID)continue;const{key:M,tileAnchorX:S,tileAnchorY:C}=T,P=Math.floor((g+S)*f),k=Math.floor((x+C)*f),R=this.index.range(P-d,k-d,P+d,k+d);for(const O of R){const D=this.crossTileIDs[O];if(this.keys[O]===M&&!h.has(D)){h.add(D),T.crossTileID=D;break}}}}}class yc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class el{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const o=Math.round((r-this.lng)/360);if(0!==o)for(const h in this.indexes){const d=this.indexes[h],f={};for(const g in d){const x=d[g];x.tileID=x.tileID.unwrapTo(x.tileID.wrap+o),f[x.tileID.key]=x}this.indexes[h]=f}this.lng=r}addBucket(r,o,h){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let f=0;f<o.symbolInstances.length;f++)o.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]=new Set);const d=this.usedCrossTileIDs[r.overscaledZ];for(const f in this.indexes){const g=this.indexes[f];if(Number(f)>r.overscaledZ)for(const x in g){const b=g[x];b.tileID.isChildOf(r)&&b.findMatches(o.symbolInstances,r,d)}else{const x=g[r.scaledTo(Number(f)).key];x&&x.findMatches(o.symbolInstances,r,d)}}for(let f=0;f<o.symbolInstances.length;f++){const g=o.symbolInstances.get(f);g.crossTileID||(g.crossTileID=h.generate(),d.add(g.crossTileID))}return void 0===this.indexes[r.overscaledZ]&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new ou(r,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(r,o){for(const h of o.crossTileIDs)this.usedCrossTileIDs[r].delete(h)}removeStaleBuckets(r){let o=!1;for(const h in this.indexes){const d=this.indexes[h];for(const f in d)r[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(h,d[f]),delete d[f],o=!0)}return o}}class xc{constructor(){this.layerIndexes={},this.crossTileIDs=new yc,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,o,h,d){let f=this.layerIndexes[r.fqid];void 0===f&&(f=this.layerIndexes[r.fqid]=new el);let g=!1;const x={};"globe"!==d.name&&f.handleWrapJump(h);for(const b of o){const T=b.getBucket(r);T&&r.fqid===T.layerIds[0]&&(T.bucketInstanceId||(T.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(b.tileID,T,this.crossTileIDs)&&(g=!0),x[T.bucketInstanceId]=!0)}return f.removeStaleBuckets(x)&&(g=!0),g}pruneUnusedLayers(r){const o={};r.forEach(h=>{o[h]=!0});for(const h in this.layerIndexes)o[h]||delete this.layerIndexes[h]}}class ko{constructor(r=0,o=0,h=0,d=0){if(isNaN(r)||r<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=r,this.bottom=o,this.left=h,this.right=d}interpolate(r,o,h){return null!=o.top&&null!=r.top&&(this.top=a.U(r.top,o.top,h)),null!=o.bottom&&null!=r.bottom&&(this.bottom=a.U(r.bottom,o.bottom,h)),null!=o.left&&null!=r.left&&(this.left=a.U(r.left,o.left,h)),null!=o.right&&null!=r.right&&(this.right=a.U(r.right,o.right,h)),this}getCenter(r,o){const h=a.aa((this.left+r-this.right)/2,0,r),d=a.aa((this.top+o-this.bottom)/2,0,o);return new a.P(h,d)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new ko(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function tl(c,r){const o=a.bk(c,3);a.a6.fromQuat(c,r),a.bm(c,3,o)}function Qs(c,r){const o=a.bi.identity([]);return a.bi.rotateZ(o,o,-r),a.bi.rotateX(o,o,-c),o}function vc(c,r){const o=[c[0],c[1],0],h=[r[0],r[1],0];if(a.N.length(o)>=1e-15){const g=a.N.normalize([],o);a.N.scale(h,g,a.N.dot(h,g)),r[0]=h[0],r[1]=h[1]}const d=a.N.cross([],r,c);if(a.N.len(d)<1e-15)return null;const f=Math.atan2(-d[1],d[0]);return Qs(Math.atan2(Math.sqrt(c[0]*c[0]+c[1]*c[1]),-c[2]),f)}class ea{constructor(r,o){this.position=r,this.orientation=o}get position(){return this._position}set position(r){if(r){const o=r instanceof a.L?r:new a.L(r[0],r[1],r[2]);this._renderWorldCopies&&(o.x=a.bh(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(r,o){if(this.orientation=null,!this.position)return;const h=this.position,d=this._elevation?this._elevation.getAtPointOrZero(a.L.fromLngLat(r)):0,f=a.L.fromLngLat(r,d),g=[f.x-h.x,f.y-h.y,f.z-h.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=vc(g,o)}setPitchBearing(r,o){this.orientation=Qs(a.bj(r),a.bj(-o))}}class ps{constructor(r,o){this._transform=a.a6.identity([]),this.orientation=o,this.position=r}get mercatorPosition(){const r=this.position;return new a.L(r[0],r[1],r[2])}get position(){const r=a.bk(this._transform,3);return[r[0],r[1],r[2]]}set position(r){var o;r&&a.bm(this._transform,3,[(o=r)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(r){this._orientation=r||a.bi.identity([]),r&&tl(this._transform,this._orientation)}getPitchBearing(){const r=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2])}}setPitchBearing(r,o){this._orientation=Qs(r,o),tl(this._transform,this._orientation)}forward(){const r=a.bk(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=a.bk(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=a.bk(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,o){const h=new Float64Array(16);return a.a6.invert(h,this.getWorldToCamera(r,o)),h}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(r,o,h){const d=this.position;a.N.scale(d,d,-r);const f=new Float64Array(16);return a.a6.fromScaling(f,[h,h,h]),a.a6.translate(f,f,d),f[10]*=o,f}getWorldToCamera(r,o){const h=new Float64Array(16),d=new Float64Array(4),f=this.position;return a.bi.conjugate(d,this._orientation),a.N.scale(f,f,-r),a.a6.fromQuat(h,d),a.a6.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(r,o,h,d){const f=new Float64Array(16);return a.a6.perspective(f,r,o,h,d),f}getCameraToClipOrthographic(r,o,h,d,f,g){const x=new Float64Array(16);return a.a6.ortho(x,r,o,h,d,f,g),x}getDistanceToElevation(r,o=!1){const h=0===r?0:a.bl(r,o?a.au(this.position[1]):this.position[1]),d=this.forward();return(h-this.position[2])/d[2]}clone(){return new ps([...this.position],[...this.orientation])}}const fs=(c,r,o)=>(1-o)*c+o*r,ta=c=>c*c*c*c*c;class ia{constructor(r,o,h,d,f,g,x){this.tileSize=512,this._renderWorldCopies=void 0===f||f,this._minZoom=r||0,this._maxZoom=o||22,this._minPitch=h??0,this._maxPitch=d??60,this.setProjection(g),this.setMaxBounds(x),this.width=0,this.height=0,this._center=new a.bn(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 ko,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ps,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const r=new ia(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return r._elevation=this._elevation,r._centerAltitude=this._centerAltitude,r._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,r.tileSize=this.tileSize,r.mercatorFromTransition=this.mercatorFromTransition,r.width=this.width,r.height=this.height,r.cameraElevationReference=this.cameraElevationReference,r._center=this._center,r._setZoom(this.zoom),r._seaLevelZoom=this._seaLevelZoom,r.angle=this.angle,r._fov=this._fov,r._pitch=this._pitch,r._nearZ=this._nearZ,r._farZ=this._farZ,r._averageElevation=this._averageElevation,r._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,r._unmodified=this._unmodified,r._edgeInsets=this._edgeInsets.clone(),r._camera=this._camera.clone(),r._calcMatrices(),r.freezeTileCoverage=this.freezeTileCoverage,r.frustumCorners=this.frustumCorners,r}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(r){this._elevation!==r&&(this._elevation=r,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(r,o=!1){const h=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||h)&&this._updateCameraOnTerrain(),(r||h)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return a.ac(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const o=this.projection?this.getProjection():void 0;this.projection=a.bo(this.projectionOptions);const h=!Pt(o,this.getProjection());return h&&this._calcMatrices(),this.mercatorFromTransition=!1,h}setOrthographicProjectionAtLowPitch(r){return this._orthographicProjectionAtLowPitch!==r&&(this._orthographicProjectionAtLowPitch=r,this._calcMatrices(),!0)}setMercatorFromTransition(){const r=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=a.bo({name:"mercator"});const o=r!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(r){void 0===r?r=!0:null===r&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get cameraWorldSize(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return a.bl(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this.width,this.height)}get bearing(){return a.bh(this.rotation,-180,180)}set bearing(r){this.rotation=r}get rotation(){return-this.angle/Math.PI*180}set rotation(r){const o=-r*Math.PI/180;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=a.b4.create(),a.b4.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const o=a.aa(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const r=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/r)}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=a.bj(r),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(r){this._averageElevation=r,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(r){const o=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(r){this._zoom=r,this.scale=this.zoomScale(r),this.tileZoom=Math.floor(r),this.zoomFraction=r-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(r){this._tileCoverLift!==r&&(this._tileCoverLift=r)}_updateCameraOnTerrain(){const r=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,o=this.elevation&&r===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||r===Number.NEGATIVE_INFINITY&&(!o||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const h=this._elevation;o||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&h.exaggeration()&&this._centerAltitudeValidForExaggeration!==h.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*h.exaggeration(),this._centerAltitudeValidForExaggeration=h.exaggeration()):(this._centerAltitude=r||0,this._centerAltitudeValidForExaggeration=h.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],h=this.horizonLineFromTop();let d=0,f=0;for(let g=0;g<o.length;g++){const x=new a.P(o[g][0]*this.width,h+o[g][1]*(this.height-h)),b=r.pointCoordinate(x);if(!b)continue;const T=1/Math.hypot(b[0]-this._camera.position[0],b[1]-this._camera.position[1]);d+=b[3]*T,f+=T}return 0===f?NaN:d/f}get center(){return this._center}set center(r){r.lat===this._center.lat&&r.lng===this._center.lng||(this._unmodified=!1,this._center=r,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const r=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),h=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(r),f=this._mercatorZfromZoom(this._maxZoom),g=Math.max(d-h,f);this._setZoom(this._zoomFromMercatorZ(g))}get padding(){return this._edgeInsets.toJSON()}set padding(r){this._edgeInsets.equals(r)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,r,1),this._calcMatrices())}computeZoomRelativeTo(r){const o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,r.toAltitude()));let h;h=r.z<this._camera.position[2]?[o.x,o.y,o.z]:[r.x,r.y,r.z];const d=a.N.length(a.N.sub([],this._camera.position,h));return a.aa(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(r){if(!this.height||!r.position&&!r.orientation)return;this._updateCameraState();let o=!1;if(r.orientation&&!a.bi.exactEquals(r.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(r.orientation)),r.position){const h=[r.position.x,r.position.y,r.position.z];a.N.exactEquals(h,this._camera.position)||(this._setCameraPosition(h),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const r=this._camera.position,o=new ea;return o.position=new a.L(r[0],r[1],r[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(r){if(!a.bi.length(r))return!1;a.bi.normalize(r,r);const o=a.N.transformQuat([],[0,0,-1],r),h=a.N.transformQuat([],[0,-1,0],r);if(h[2]<0)return!1;const d=vc(o,h);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(r){const o=this.zoomScale(this.minZoom)*this.tileSize,h=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;r[2]=a.aa(r[2],d/h,d/o),this._camera.position=r}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(r){return this._edgeInsets.equals(r)}interpolatePadding(r,o,h){this._unmodified=!1,this._edgeInsets.interpolate(r,o,h),this._constrain(),this._calcMatrices()}coveringZoomLevel(r){const o=(r.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/r.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(r){const o=[new a.bp(0,r)];if(this.renderWorldCopies){const h=this.pointCoordinate(new a.P(0,0)),d=this.pointCoordinate(new a.P(this.width,0)),f=this.pointCoordinate(new a.P(this.width,this.height)),g=this.pointCoordinate(new a.P(0,this.height)),x=Math.floor(Math.min(h.x,d.x,f.x,g.x)),b=Math.floor(Math.max(h.x,d.x,f.x,g.x)),T=1;for(let M=x-T;M<=b+T;M++)0!==M&&o.push(new a.bp(M,r))}return o}isLODDisabled(r){return(!r||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(r,o,h){let d=[];if(0===o[0]&&0===o[1])return d;for(const g of r){const x=g.canonical,b=g.overscaledZ,T=g.wrap,M=1<<x.z,S=x.x+1<M,C=x.x>0,P=x.y+1<M,k=x.y>0,R=g.wrap-(C?0:1),O=g.wrap+(S?0:1),D=C?x.x-1:M-1,F=S?x.x+1:0;o[0]<0?(d.push(new a.am(b,O,x.z,F,x.y)),o[1]<0&&P&&(d.push(new a.am(b,T,x.z,x.x,x.y+1)),d.push(new a.am(b,O,x.z,F,x.y+1))),o[1]>0&&k&&(d.push(new a.am(b,T,x.z,x.x,x.y-1)),d.push(new a.am(b,O,x.z,F,x.y-1)))):o[0]>0?(d.push(new a.am(b,R,x.z,D,x.y)),o[1]<0&&P&&(d.push(new a.am(b,T,x.z,x.x,x.y+1)),d.push(new a.am(b,R,x.z,D,x.y+1))),o[1]>0&&k&&(d.push(new a.am(b,T,x.z,x.x,x.y-1)),d.push(new a.am(b,R,x.z,D,x.y-1)))):o[1]<0&&P?d.push(new a.am(b,T,x.z,x.x,x.y+1)):k&&d.push(new a.am(b,T,x.z,x.x,x.y-1))}if(d.length>1){d.sort((b,T)=>b.overscaledZ-T.overscaledZ||b.wrap-T.wrap||b.canonical.z-T.canonical.z||b.canonical.x-T.canonical.x||b.canonical.y-T.canonical.y);let g=0,x=0;for(;x<d.length;)d[x].equals(d[g])?++x:d[++g]=d[x++];d.length=g+1}const f=[];for(const g of d)d.some(x=>g.isChildOf(x))||f.push(g);return d=f.filter(g=>!r.some(x=>!!(g.overscaledZ<h&&x.isChildOf(g))||g.equals(x)||g.isChildOf(x))),d}coveringTiles(r){let o=this.coveringZoomLevel(r);const h=o,d=this.elevation&&this.elevation.exaggeration(),f=d&&!r.isTerrainDEM,g="mercator"===this.projection.name;if(void 0!==r.minzoom&&o<r.minzoom)return[];void 0!==r.maxzoom&&o>r.maxzoom&&(o=r.maxzoom);const x=this.locationCoordinate(this.center),b=this.center.lat,T=1<<o,M=[T*x.x,T*x.y,0],S="globe"===this.projection.name,C=!S,P=a.bq.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,C),k=S?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),R=T*a.bl(1,this.center.lat),O=this._camera.position[2]/a.bl(1,this.center.lat),D=[T*k.x,T*k.y,O*(C?1:R)],F=S||d,Z=this.cameraToCenterDistance/r.tileSize*(r.roundZoom?1:.502),V=this.isLODDisabled(!0)?o:0;let q;if(this._elevation&&r.isTerrainDEM)q=1e4*this._elevation.exaggeration();else if(this._elevation){const Q=this._elevation.getMinMaxForVisibleTiles();q=Q?Q.max:this._centerAltitude}else q=this._centerAltitude;const B=r.isTerrainDEM?-q:this._elevation?this._elevation.getMinElevationBelowMSL():0,$=this.projection.isReprojectedInTileSpace?a.br(this):1,Y=Q=>{const Ie=new a.L(Q.x+25e-6,Q.y,Q.z),Re=new a.L(Q.x,Q.y+25e-6,Q.z),Le=Q.toLngLat(),je=Ie.toLngLat(),et=Re.toLngLat(),ct=this.locationCoordinate(Le),nt=this.locationCoordinate(je),at=this.locationCoordinate(et),Et=Math.hypot(nt.x-ct.x,nt.y-ct.y),gt=Math.hypot(at.x-ct.x,at.y-ct.y);return Math.sqrt(Et*gt)*$/25e-6},K=Q=>{const ae=q,Ie=B;return{aabb:a.bu(this,T,0,0,0,Q,Ie,ae,this.projection),zoom:0,x:0,y:0,minZ:Ie,maxZ:ae,wrap:Q,fullyVisible:!1}},ee=[];let ce=[];const re=o,me=r.reparseOverscaled?h:o,pe=Q=>Q*Q,Ae=pe((O-this._centerAltitude)*R),ne=Q=>{if(!this._elevation||!Q.tileID||!g)return;const ae=this._elevation.getMinMaxForTile(Q.tileID),Ie=Q.aabb;ae?(Ie.min[2]=ae.min,Ie.max[2]=ae.max,Ie.center[2]=(Ie.min[2]+Ie.max[2])/2):(Q.shouldSplit=ue(Q),Q.shouldSplit||(Ie.min[2]=Ie.max[2]=Ie.center[2]=this._centerAltitude))},ue=Q=>{if(Q.zoom<V)return!0;if(Q.zoom===re)return!1;if(null!=Q.shouldSplit)return Q.shouldSplit;const ae=Q.aabb.distanceX(D),Ie=Q.aabb.distanceY(D);let Re=Ae,Le=1;if(S){Re=pe(Q.aabb.distanceZ(D));const ct=Math.pow(2,Q.zoom),nt=a.au((Q.y+1)/ct),at=a.au(Q.y/ct),Et=Math.min(Math.max(b,nt),at),gt=a.bJ(Et)/a.bJ(b);if(Le=Et===b?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,gt/this._mercatorScaleRatio),this.zoom<=a.bG&&Q.zoom===re-1&&gt>=.9)return!0}else if(f&&(Re=pe(Q.aabb.distanceZ(D)*R)),this.projection.isReprojectedInTileSpace&&h<=5){const ct=Math.pow(2,Q.zoom),nt=Y(new a.L((Q.x+.5)/ct,(Q.y+.5)/ct));Le=nt>.85?1:nt}const je=ae*ae+Ie*Ie+Re;return je<pe((1<<re-Q.zoom)*Z*Le*((ct,nt)=>{if(nt*pe(.707)<ct)return 1;const at=Math.sqrt(nt/ct);return at/(1.4144271570014144+(Math.pow(1.1,at-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Re,Ae),je))};if(this.renderWorldCopies)for(let Q=1;Q<=3;Q++)ee.push(K(-Q)),ee.push(K(Q));for(ee.push(K(0));ee.length>0;){const Q=ee.pop(),ae=Q.x,Ie=Q.y;let Re=Q.fullyVisible;const Le=()=>"globe"===this.projection.name&&(0===Q.y||Q.y===(1<<Q.zoom)-1);if(!Re){let je=F?Q.aabb.intersects(P):Q.aabb.intersectsFlat(P);if(0===je&&Le()){const et=new a.bs(Q.zoom,ae,Ie);je=a.bt(this,T,et,!0).intersects(P)}if(0===je)continue;Re=2===je}if(Q.zoom!==re&&ue(Q))for(let je=0;je<4;je++){const et=(ae<<1)+je%2,ct=(Ie<<1)+(je>>1),nt={aabb:g?Q.aabb.quadrant(je):a.bu(this,T,Q.zoom+1,et,ct,Q.wrap,Q.minZ,Q.maxZ,this.projection),zoom:Q.zoom+1,x:et,y:ct,wrap:Q.wrap,fullyVisible:Re,tileID:void 0,shouldSplit:void 0,minZ:Q.minZ,maxZ:Q.maxZ};f&&!S&&(nt.tileID=new a.am(Q.zoom+1===re?me:Q.zoom+1,Q.wrap,Q.zoom+1,et,ct),ne(nt)),ee.push(nt)}else{const je=Q.zoom===re?me:Q.zoom;if(r.minzoom&&r.minzoom>je)continue;if(!Re){let at=F?Q.aabb.intersectsPrecise(P):Q.aabb.intersectsPreciseFlat(P);if(0===at&&Le()){const Et=new a.bs(Q.zoom,ae,Ie);at=a.bt(this,T,Et,!0).intersectsPrecise(P)}if(0===at)continue}const et=M[0]-(.5+ae+(Q.wrap<<Q.zoom))*(1<<o-Q.zoom),ct=M[1]-.5-Ie,nt=Q.tileID?Q.tileID:new a.am(je,Q.wrap,Q.zoom,ae,Ie);ce.push({tileID:nt,distanceSq:et*et+ct*ct})}}if(this.fogCullDistSq){const Q=this.fogCullDistSq,ae=this.horizonLineFromTop();ce=ce.filter(Ie=>{const Re=[0,0,0,1],Le=[a.V,a.V,0,1],je=this.calculateFogTileMatrix(Ie.tileID.toUnwrapped());a.a7.transformMat4(Re,Re,je),a.a7.transformMat4(Le,Le,je);const et=a.a7.min([],Re,Le),ct=a.a7.max([],Re,Le),nt=a.bv(et,ct);if(0===nt)return!0;let at=!1;const Et=this._elevation;if(Et&&nt>Q&&0!==ae){const gt=this.calculateProjMatrix(Ie.tileID.toUnwrapped());let bt;r.isTerrainDEM||(bt=Et.getMinMaxForTile(Ie.tileID)),bt||(bt={min:B,max:q});const vt=a.bH(this.rotation),Zt=[vt[0]*a.V,vt[1]*a.V,bt.max];a.N.transformMat4(Zt,Zt,gt),at=(1-Zt[1])*this.height*.5<ae}return nt<Q||at})}return ce.sort((Q,ae)=>Q.distanceSq-ae.distanceSq).map(Q=>Q.tileID)}resize(r,o){this.width=r,this.height=o,this.pixelsToGLUnits=[2/r,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const o=a.aa(r.lat,-a.bw,a.bw),h=this.projection.project(r.lng,o);return new a.P(h.x*this.worldSize,h.y*this.worldSize)}unproject(r){return this.projection.unproject(r.x/this.worldSize,r.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/a.bl(1,this.center.lat)/this.worldSize}setLocationAtPoint(r,o){let h,d;const f=this.centerPoint;if("globe"===this.projection.name){const x=this.worldSize;h=(o.x-f.x)/x,d=(o.y-f.y)/x}else{const x=this.pointCoordinate(o),b=this.pointCoordinate(f);h=x.x-b.x,d=x.y-b.y}const g=this.locationCoordinate(r);this.setLocation(new a.L(g.x-h,g.y-d))}setLocation(r){this.center=this.coordinateLocation(r),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(r){return this.projection.locationPoint(this,r)}locationPoint3D(r){return this.projection.locationPoint(this,r,!0)}pointLocation(r){return this.coordinateLocation(this.pointCoordinate(r))}pointLocation3D(r){return this.coordinateLocation(this.pointCoordinate3D(r))}locationCoordinate(r,o){const h=o?a.bl(o,r.lat):void 0,d=this.projection.project(r.lng,r.lat);return new a.L(d.x,d.y,h)}coordinateLocation(r){return this.projection.unproject(r.x,r.y)}pointRayIntersection(r,o){const h=o??this._centerAltitude,d=[r.x,r.y,0,1],f=[r.x,r.y,1,1];a.a7.transformMat4(d,d,this.pixelMatrixInverse),a.a7.transformMat4(f,f,this.pixelMatrixInverse);const g=f[3];a.a7.scale(d,d,1/d[3]),a.a7.scale(f,f,1/g);const x=d[2],b=f[2];return{p0:d,p1:f,t:x===b?0:(h-x)/(b-x)}}screenPointToMercatorRay(r){const o=[r.x,r.y,0,1],h=[r.x,r.y,1,1];return a.a7.transformMat4(o,o,this.pixelMatrixInverse),a.a7.transformMat4(h,h,this.pixelMatrixInverse),a.a7.scale(o,o,1/o[3]),a.a7.scale(h,h,1/h[3]),o[2]=a.bl(o[2],this._center.lat)*this.worldSize,h[2]=a.bl(h[2],this._center.lat)*this.worldSize,a.a7.scale(o,o,1/this.worldSize),a.a7.scale(h,h,1/this.worldSize),new a.a2([o[0],o[1],o[2]],a.N.normalize([],a.N.sub([],h,o)))}rayIntersectionCoordinate(r){const{p0:o,p1:h,t:d}=r,f=a.bl(o[2],this._center.lat),g=a.bl(h[2],this._center.lat);return new a.L(a.U(o[0],h[0],d)/this.worldSize,a.U(o[1],h[1],d)/this.worldSize,a.U(f,g,d))}pointCoordinate(r,o=this._centerAltitude){return this.projection.pointCoordinate(this,r.x,r.y,o)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);let o=this.projection.pointCoordinate3D(this,r.x,r.y);if(o)return new a.L(o[0],o[1],o[2]);let h=0,d=this.horizonLineFromTop();if(r.y>d)return this.pointCoordinate(r);const f=.02*d,g=r.clone();for(let x=0;x<10&&d-h>f;x++){g.y=a.U(h,d,.66);const b=this.projection.pointCoordinate3D(this,g.x,g.y);b?(d=g.y,o=b):h=g.y}return o?new a.L(o[0],o[1],o[2]):this.pointCoordinate(r)}isPointAboveHorizon(r){return this.projection.isPointAboveHorizon(this,r)}isPointOnSurface(r){if(r.y<0||r.y>this.height||r.x<0||r.x>this.width)return!1;if(this.elevation||this.zoom>=a.bx)return!this.isPointAboveHorizon(r);const o=this.pointCoordinate(r);return o.y>=0&&o.y<=1}_coordinatePoint(r,o){const h=o&&this.elevation?this.elevation.getAtPointOrZero(r,this._centerAltitude):this._centerAltitude,d=[r.x*this.worldSize,r.y*this.worldSize,h+r.toAltitude(),1];return a.a7.transformMat4(d,d,this.pixelMatrix),d[3]>0?new a.P(d[0]/d[3],d[1]/d[3]):new a.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:r,left:o}=this._edgeInsets,h=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,f=this.pointLocation3D(new a.P(o,r)),g=this.pointLocation3D(new a.P(d,r)),x=this.pointLocation3D(new a.P(d,h)),b=this.pointLocation3D(new a.P(o,h));let T=Math.min(f.lng,g.lng,x.lng,b.lng),M=Math.max(f.lng,g.lng,x.lng,b.lng),S=Math.min(f.lat,g.lat,x.lat,b.lat),C=Math.max(f.lat,g.lat,x.lat,b.lat);const P=Math.pow(2,-this.zoom)/16*270,k="globe"===this.projection.name?1:4,R=(O,D,F,Z,V)=>{const q=(O+F)/2,B=(D+Z)/2,$=new a.P(q,B),{lng:Y,lat:K}=this.pointLocation3D($),ee=Math.max(0,T-Y,S-K,Y-M,K-C);T=Math.min(T,Y),M=Math.max(M,Y),S=Math.min(S,K),C=Math.max(C,K),(V<k||ee>P)&&(R(O,D,q,B,V+1),R(q,B,F,Z,V+1))};if(R(o,r,d,r,1),R(d,r,d,h,1),R(d,h,o,h,1),R(o,h,o,r,1),"globe"===this.projection.name){const[O,D]=a.by(this);O?(C=90,M=180,T=-180):D&&(S=-90,M=180,T=-180)}return new a.ad(new a.bn(T,S),new a.bn(M,C))}_getBoundsRectangular(r,o){const{top:h,left:d}=this._edgeInsets,f=this.height-this._edgeInsets.bottom,g=this.width-this._edgeInsets.right,x=new a.P(d,h),b=new a.P(g,h),T=new a.P(g,f),M=new a.P(d,f);let S=this.pointCoordinate(x,r),C=this.pointCoordinate(b,r);const P=this.pointCoordinate(T,o),k=this.pointCoordinate(M,o),R=(O,D)=>(D.y-O.y)/(D.x-O.x);return S.y>1&&C.y>=0?S=new a.L((1-k.y)/R(k,S)+k.x,1):S.y<0&&C.y<=1&&(S=new a.L(-k.y/R(k,S)+k.x,0)),C.y>1&&S.y>=0?C=new a.L((1-P.y)/R(P,C)+P.x,1):C.y<0&&S.y<=1&&(C=new a.L(-P.y/R(P,C)+P.x,0)),(new a.ad).extend(this.coordinateLocation(S)).extend(this.coordinateLocation(C)).extend(this.coordinateLocation(k)).extend(this.coordinateLocation(P))}_getBoundsRectangularTerrain(){const r=this.elevation;if(!r.visibleDemTiles.length||r.isUsingMockSource())return this._getBoundsRectangular(0,0);const o=r.visibleDemTiles.reduce((h,d)=>{if(d.dem){const 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._getBoundsRectangular(o.min*r.exaggeration(),o.max*r.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(r=!0){const 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 r?Math.max(0,h):h}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-a.bw,this.maxLat=a.bw,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.a5(this.minLng)*this.tileSize,this.worldMaxX=a.a5(this.maxLng)*this.tileSize,this.worldMinY=a.ae(this.maxLat)*this.tileSize,this.worldMaxY=a.ae(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(r,o){return this.projection.createTileMatrix(this,o,r)}calculateDistanceTileData(r){const o=r.key,h=this._distanceTileDataCache;if(h[o])return h[o];const d=r.canonical,f=1/this.height,g=this.cameraWorldSize,x=g/this.zoomScale(d.z),b=(d.x+Math.pow(2,d.z)*r.wrap)*x,T=d.y*x,M=this.point;M.x*=g/this.worldSize,M.y*=g/this.worldSize;const S=this.angle,C=Math.sin(-S),P=-Math.cos(-S);return h[o]={bearing:[C,P],center:[(M.x-b)*f,(M.y-T)*f],scale:x/a.V*f},h[o]}calculateFogTileMatrix(r){const o=r.key,h=this._fogTileMatrixCache;if(h[o])return h[o];const d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,r);return a.a6.multiply(d,this.worldToFogMatrix,d),h[o]=new Float32Array(d),h[o]}calculateProjMatrix(r,o=!1,h=!1){const d=r.key;let f;if(f=h?this._expandedProjMatrixCache:o?this._alignedProjMatrixCache:this._projMatrixCache,f[d])return f[d];const g=this.calculatePosMatrix(r,this.worldSize);let x;return x=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:h?this.expandedFarZProjMatrix:o?this.alignedProjMatrix:this.projMatrix,a.a6.multiply(g,x,g),f[d]=new Float32Array(g),f[d]}calculatePixelsToTileUnitsMatrix(r){const o=r.tileID.key,h=this._pixelsToTileUnitsCache;if(h[o])return h[o];const d=a.bz(r,this);return h[o]=d,h[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const r=1/this.worldSize,o=a.a6.fromScaling([],[r,r,r]);return a.a6.multiply(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const r=this._elevation;this._updateCameraState();const o=a.bl(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=this._camera.forward(),f=a.bl(1,this._center.lat);h[2]/=f,d[2]/=f,a.N.normalize(d,d);const g=r.raycast(h,d,r.exaggeration());if(g){const x=a.N.scaleAndAdd([],h,d,g),b=new a.L(x[0],x[1],a.bl(x[2],a.au(x[1]))),T=(b.z+a.N.length([b.x-h[0],b.y-h[1],b.z-h[2]*f]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(T),this._centerAltitude=b.toAltitude(),this._center=this.coordinateLocation(b),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(r=!1){if(!this._elevation)return;const o=this._elevation,h=a.bl(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(h),f=o.getAtPointOrZero(new a.L(...d)),g=this.pixelsPerMeter/this.worldSize*f,x=this._minimumHeightOverTerrain(),b=d[2]-g;if(b<=x)if(b<0||r){const T=this.locationCoordinate(this._center,this._centerAltitude),M=[d[0],d[1],T.z-d[2]],S=a.N.length(M);M[2]-=(x-b)/this._pixelsPerMercatorPixel;const C=a.N.length(M);if(0===C)return;a.N.scale(M,M,S/C*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],T.z*this._pixelsPerMercatorPixel-M[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const r="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||r){const C=this.center;return C.lat=a.aa(C.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!r)&&(C.lng=a.aa(C.lng,this.minLng,this.maxLng)),this.center=C,void(this._constraining=!1)}const o=this._unmodified,{x:h,y:d}=this.point;let f=0,g=h,x=d;const b=this.width/2,T=this.height/2,M=this.worldMinY*this.scale,S=this.worldMaxY*this.scale;if(d-T<M&&(x=M+T),d+T>S&&(x=S-T),S-M<this.height&&(f=Math.max(f,this.height/(S-M)),x=(S+M)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const C=this.worldMinX*this.scale,P=this.worldMaxX*this.scale,k=this.worldSize/2-(C+P)/2;g=(h+k+this.worldSize)%this.worldSize-k,g-b<C&&(g=C+b),g+b>P&&(g=P-b),P-C<this.width&&(f=Math.max(f,this.width/(P-C)),g=(P+C)/2)}g===h&&x===d||(this.center=this.unproject(new a.P(g,x))),f&&(this.zoom+=this.scaleZoom(f)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let r=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(r=Math.max(r,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),r}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const r=this.centerOffset,o="globe"===this.projection.name,h=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=a.bl(1,this.center.lat)/a.bl(1,a.bI));const d=a.bA(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,d),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const f="meters"===this.projection.zAxisUnit?h:1,g=this._camera.getWorldToCamera(this.worldSize,f);let x;const b=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(b[8]=2*-r.x/this.width,b[9]=2*r.y/this.height,this.isOrthographic){let K=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),ee=K*this.aspect,ce=-ee,re=-K;ee-=r.x,ce-=r.x,K+=r.y,re+=r.y,x=this._camera.getCameraToClipOrthographic(ce,ee,re,K,this._nearZ,this._farZ),((me,pe,Ae,ne)=>{for(let ue=0;ue<16;ue++)me[ue]=fs(pe[ue],Ae[ue],ne)})(x,x,b,ta(this.pitch>=15?1:this.pitch/15))}else x=b;const T=a.a6.mul([],b,g);let M=a.a6.mul([],x,g);if(this.projection.isReprojectedInTileSpace){const K=this.locationCoordinate(this.center),ee=a.a6.identity([]);a.a6.translate(ee,ee,[K.x*this.worldSize,K.y*this.worldSize,0]),a.a6.multiply(ee,ee,a.bB(this)),a.a6.translate(ee,ee,[-K.x*this.worldSize,-K.y*this.worldSize,0]),a.a6.multiply(M,M,ee),a.a6.multiply(T,T,ee),this.inverseAdjustmentMatrix=a.bC(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=a.a6.scale([],M,[this.worldSize,this.worldSize,this.worldSize/f,1]),this.projMatrix=M,this.invProjMatrix=a.a6.invert(new Float64Array(16),this.projMatrix),o){const K=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);K[8]=2*-r.x/this.width,K[9]=2*r.y/this.height,this.expandedFarZProjMatrix=a.a6.mul([],K,g)}else this.expandedFarZProjMatrix=this.projMatrix;const S=a.a6.invert([],x);this.frustumCorners=a.bD.fromInvProjectionMatrix(S,this.horizonLineFromTop(),this.height),this.cameraFrustum=a.bq.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!o);const C=new Float32Array(16);a.a6.identity(C),a.a6.scale(C,C,[1,-1,1]),a.a6.rotateX(C,C,this._pitch),a.a6.rotateZ(C,C,this.angle);const P=a.a6.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=a.a6.clone(P);const k=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;P[8]=2*-r.x/this.width,P[9]=2*(r.y+k)/this.height,this.skyboxMatrix=a.a6.multiply(C,P,C);const R=this.point,O=R.x,D=R.y,F=this.width%2/2,Z=this.height%2/2,V=Math.cos(this.angle),q=Math.sin(this.angle),B=O-Math.round(O)+V*F+q*Z,$=D-Math.round(D)+V*Z+q*F,Y=new Float64Array(M);if(a.a6.translate(Y,Y,[B>.5?B-1:B,$>.5?$-1:$,0]),this.alignedProjMatrix=Y,M=a.a6.create(),a.a6.scale(M,M,[this.width/2,-this.height/2,1]),a.a6.translate(M,M,[1,-1,0]),this.labelPlaneMatrix=M,M=a.a6.create(),a.a6.scale(M,M,[1,-1,1]),a.a6.translate(M,M,[-1,-1,0]),a.a6.scale(M,M,[2/this.width,2/this.height,1]),this.glCoordMatrix=M,this.pixelMatrix=a.a6.multiply(new Float64Array(16),this.labelPlaneMatrix,T),this._calcFogMatrices(),this._distanceTileDataCache={},M=a.a6.invert(new Float64Array(16),this.pixelMatrix),!M)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=M,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=a.bE(this);const K=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=a.N.transformMat4(K,K,g),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=M;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,h=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,f=[r,r,o];a.N.scale(f,f,d),a.N.scale(h,h,-1),a.N.multiply(h,h,f);const g=a.a6.create();a.a6.translate(g,g,h),a.a6.scale(g,g,f),this.mercatorFogMatrix=g,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,o,d)}_computeCameraPosition(r){const o=(r=r||this.pixelsPerMeter)/this.pixelsPerMeter,h=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-r/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-h[0]*f,d.y/this.worldSize-h[1]*f,r/this.worldSize*this._centerAltitude-h[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),h=this._camera.position[2],d=r[2];let f=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(f=Math.min((o-h)/d,1)),this._camera.position=a.N.scaleAndAdd([],this._camera.position,r,f),this._updateStateFromCamera()}_updateStateFromCamera(){const r=this._camera.position,o=this._camera.forward(),{pitch:h,bearing:d}=this._camera.getPitchBearing(),f=a.bl(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,g=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.bj(this._maxPitch)),x=Math.max((r[2]-f)/Math.cos(h),g),b=this._zoomFromMercatorZ(x);a.N.scaleAndAdd(r,r,o,x),this._pitch=a.aa(h,a.bj(this.minPitch),a.bj(this.maxPitch)),this.angle=a.bh(d,-Math.PI,Math.PI),this._setZoom(a.aa(b,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new a.L(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(r){return Math.pow(2,r)*this.tileSize}_mercatorZfromZoom(r){return this.cameraToCenterDistance/this._worldSizeFromZoom(r)}_minimumHeightOverTerrain(){const r=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(r)}_zoomFromMercatorZ(r){return this.scaleZoom(this.cameraToCenterDistance/(r*this.tileSize))}zoomFromMercatorZAdjusted(r){let o=0,h=a.bx,d=0,f=1/0;for(;h-o>1e-6&&h>o;){const g=o+.5*(h-o),x=this.tileSize*Math.pow(2,g),b=this.getCameraToCenterDistance(this.projection,g,x),T=this.scaleZoom(b/(r*this.tileSize)),M=Math.abs(g-T);M<f&&(f=M,d=g),g<T?o=g:h=g}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(a.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(r,o){const h=Math.min(r.x,o.x),d=Math.max(r.x,o.x),f=Math.min(r.y,o.y),g=Math.max(r.y,o.y);if(f<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const x=[new a.P(h,f),new a.P(d,g),new a.P(h,g),new a.P(d,f)],b=this.renderWorldCopies?-3:0,T=this.renderWorldCopies?4:1;for(const M of x){const S=this.pointRayIntersection(M);if(S.t<0)return!0;const C=this.rayIntersectionCoordinate(S);if(C.x<b||C.y<0||C.x>T||C.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.bF(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.P(0,0),new a.P(this.width,this.height))}zoomDeltaToMovement(r,o){const h=a.N.length(a.N.sub([],this._camera.position,r)),d=this._zoomFromMercatorZ(h)+o;return h-this._mercatorZfromZoom(d)}getCameraPoint(){if("globe"===this.projection.name){const r=function([o,h,d],f){const g=[o,h,d,1];a.a7.transformMat4(g,g,f);const x=g[3]=Math.max(g[3],1e-6);return g[0]/=x,g[1]/=x,g[2]/=x,g}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new a.P(r[0],r[1])}{const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.P(0,r))}}getCameraToCenterDistance(r,o=this.zoom,h=this.worldSize){const d=a.bA(r,o,this.width,this.height,1024),f=r.pixelSpaceConversion(this.center.lat,h,d);let g=.5/Math.tan(.5*this._fov)*this.height*f;return this.isOrthographic&&(g=fs(1,g,ta(this.pitch>=15?1:this.pitch/15))),g}getWorldToCameraMatrix(){const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&a.a6.multiply(r,r,this.globeMatrix),r}getFrustum(r){return a.bq.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,"meters"===this.projection.zAxisUnit)}}const cr_BaseColor=5,cr_MetallicRoughness=6,cr_Normal=7,cr_Occlusion=8,cr_Emission=9,cr_ShadowMap0=10,no=(c,r)=>{if(r>0&&c.terrain&&a.w("Cutoff is currently disabled on terrain"),r<=0||c.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=c.transform,h=Math.max(Math.abs(o._zoom-(c.minCutoffZoom-1)),1),d=o.isLODDisabled(!1)?a.O(60,45,o.pitch):a.O(30,15,o.pitch),f=o._farZ-o._nearZ,g=r*o.height,x=((1-(b=d))*o.cameraToCenterDistance+b*(o._farZ+g))*h;var b;return{shouldRenderCutoff:d<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(x-o._nearZ)/f,(x-g-o._nearZ)/f]}}},br={cascadeCount:2,shadowMapResolution:2048};class bc{constructor(r,o){this.aabb=r,this.lastCascade=o}}class su{add(r,o){const h=this.receivers[r.key];void 0!==h?(h.aabb.min[0]=Math.min(h.aabb.min[0],o.min[0]),h.aabb.min[1]=Math.min(h.aabb.min[1],o.min[1]),h.aabb.min[2]=Math.min(h.aabb.min[2],o.min[2]),h.aabb.max[0]=Math.max(h.aabb.max[0],o.max[0]),h.aabb.max[1]=Math.max(h.aabb.max[1],o.max[1]),h.aabb.max[2]=Math.max(h.aabb.max[2],o.max[2])):this.receivers[r.key]=new bc(o,null)}clear(){this.receivers={}}get(r){return this.receivers[r.key]}computeRequiredCascades(r,o,h){const d=a.bS.fromPoints(r.points);let f=0;for(const g in this.receivers){const x=this.receivers[g];if(!x||!d.intersectsAabb(x.aabb))continue;x.aabb.min=d.closestPoint(x.aabb.min),x.aabb.max=d.closestPoint(x.aabb.max);const b=x.aabb.getCorners();for(let T=0;T<h.length;T++){let M=!0;for(const S of b){const C=[S[0]*o,S[1]*o,S[2]];if(a.N.transformMat4(C,C,h[T].matrix),C[0]<-1||C[0]>1||C[1]<-1||C[1]>1){M=!1;break}}if(x.lastCascade=T,f=Math.max(f,T),M)break}}return f+1}}class wc{constructor(r){this.painter=r,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new su,this._depthMode=new dt(r.context.gl.LEQUAL,dt.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1,r.tp.registerParameter(br,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),r.tp.registerParameter(br,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32})}destroy(){for(const r of this._cascades)r.texture.destroy(),r.framebuffer.destroy();this._cascades=[]}updateShadowParameters(r,o){const h=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!o||!o.properties)return;const d=o.properties.get("shadow-intensity");if(!o.shadowsEnabled()||d<=0||(this._shadowLayerCount=h.style.order.reduce((k,R)=>{const O=h.style._mergedLayers[R];return k+(O.hasShadowPass()&&!O.isHidden(r.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this._enabled))return;const f=h.context,g=br.shadowMapResolution,x=br.shadowMapResolution;if(0===this._cascades.length||br.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let k=0;k<br.cascadeCount;++k){const R=h._shadowMapDebug,O=f.gl,D=f.createFramebuffer(g,x,R,"texture"),F=new a.T(f,{width:g,height:x,data:null},O.DEPTH_COMPONENT);if(D.depthAttachment.set(F.texture),R){const Z=new a.T(f,{width:g,height:x,data:null},O.RGBA);D.colorAttachment.set(Z.texture)}this._cascades.push({framebuffer:D,texture:F,matrix:[],far:0,boundingSphereRadius:0,frustum:new a.bq,scale:0})}}this.shadowDirection=il(o);let b=0;if(r.elevation){const k=r.elevation,R=[1e4,-1e4];k.visibleDemTiles.filter(O=>O.dem).forEach(O=>{const D=O.dem.tree;R[0]=Math.min(R[0],D.minimums[0]),R[1]=Math.max(R[1],D.maximums[0])}),1e4!==R[0]&&(b=(R[1]-R[0])*k.exaggeration())}const T=1.5*r.cameraToCenterDistance,M=3*T,S=new Float64Array(16);for(let k=0;k<this._cascades.length;++k){const R=this._cascades[k];let O=r.height/50,D=1;1===br.cascadeCount?D=M:0===k?D=T:(O=T,D=M);const[F,Z]=au(r,this.shadowDirection,O,D,br.shadowMapResolution,b);R.scale=r.scale,R.matrix=F,R.boundingSphereRadius=Z,a.a6.invert(S,R.matrix),R.frustum=a.bq.fromInvProjectionMatrix(S,1,0,!0),R.far=D}const C=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[C].far,this._cascades[C].far],this._uniformValues.u_shadow_intensity=d,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/br.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=br.shadowMapResolution,this._uniformValues.u_shadowmap_0=cr_ShadowMap0,this._uniformValues.u_shadowmap_1=cr_ShadowMap0+1,this._groundShadowTiles=h.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const P=h.transform.elevation;for(const k of this._groundShadowTiles){let R={min:0,max:0};if(P){const O=P.getMinMaxForTile(k);O&&(R=O)}this.addShadowReceiver(k.toUnwrapped(),R.min,R.max)}}get enabled(){return this._enabled}set enabled(r){this._enabled=r}drawShadowPass(r,o){if(!this._enabled)return;const h=this.painter,d=h.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(h.transform.getFrustum(0),h.transform.worldSize,this._cascades),d.viewport.set([0,0,br.shadowMapResolution,br.shadowMapResolution]);for(let f=0;f<this._numCascadesToRender;++f){h.currentShadowCascade=f,d.bindFramebuffer.set(this._cascades[f].framebuffer.framebuffer),d.clear({color:a.ax.white,depth:1});for(const g of r.order){const x=r._mergedLayers[g];if(!x.hasShadowPass()||x.isHidden(h.transform.zoom))continue;const b=r.getLayerSourceCache(x),T=b?o[b.id]:void 0;("model"===x.type||T&&T.length)&&h.renderLayer(h,b,x,T)}}h.currentShadowCascade=0}drawGroundShadows(){if(!this._enabled)return;const r=this.painter,o=r.style,h=r.context,d=o.directionalLight,f=o.ambientLight;if(!d||!f)return;const g=[],x=no(r,r.longestCutoffRange);x.shouldRenderCutoff&&g.push("RENDER_CUTOFF");const b=ra(d,f),T=new dt(h.gl.LEQUAL,dt.ReadOnly,r.depthRangeFor3D);for(const M of this._groundShadowTiles){const S=M.toUnwrapped(),C=r.isTileAffectedByFog(M),P=r.getOrCreateProgram("groundShadow",{defines:g,overrideFog:C});this.setupShadows(S,P),r.uploadCommonUniforms(h,P,S,null,x);const k={u_matrix:r.transform.calculateProjMatrix(S),u_ground_shadow_factor:b};P.draw(r,h.gl.TRIANGLES,T,yt.disabled,Rt.multiply,pt.disabled,k,"ground_shadow",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments,{},r.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Rt.unblended:Rt.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(r){const o=this.painter.transform,h=o.calculatePosMatrix(r,o.worldSize);return a.a6.multiply(h,this._cascades[this.painter.currentShadowCascade].matrix,h),Float32Array.from(h)}calculateShadowPassMatrixFromMatrix(r){return a.a6.multiply(r,this._cascades[this.painter.currentShadowCascade].matrix,r),Float32Array.from(r)}setupShadows(r,o,h,d=0){if(!this._enabled)return;const f=this.painter.transform,g=this.painter.context,x=g.gl,b=this._uniformValues,T=new Float64Array(16),M=f.calculatePosMatrix(r,f.worldSize);for(let S=0;S<this._cascades.length;S++)a.a6.multiply(T,this._cascades[S].matrix,M),b[0===S?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(T),g.activeTexture.set(x.TEXTURE0+cr_ShadowMap0+S),this._cascades[S].texture.bind(x.NEAREST,x.CLAMP_TO_EDGE);if(this.useNormalOffset=!!h,this.useNormalOffset){const S=a.bR(r.canonical),C=2/f.tileSize*a.V/br.shadowMapResolution,P=C*this._cascades[0].boundingSphereRadius,k=C*this._cascades[this._cascades.length-1].boundingSphereRadius,R=("vector-tile"===h?1:3)/Math.pow(2,d-r.canonical.z-(1-f.zoom+Math.floor(f.zoom)));b.u_shadow_normal_offset=[S,P*R,k*R],b.u_shadow_bias=[6e-5,.0012,.012]}else b.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(g,b)}setupShadowsFromMatrix(r,o,h=!1){if(!this._enabled)return;const d=this.painter.context,f=d.gl,g=this._uniformValues,x=new Float64Array(16);for(let b=0;b<br.cascadeCount;b++)a.a6.multiply(x,this._cascades[b].matrix,r),g[0===b?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(x),d.activeTexture.set(f.TEXTURE0+cr_ShadowMap0+b),this._cascades[b].texture.bind(f.NEAREST,f.CLAMP_TO_EDGE);this.useNormalOffset=h,h?(g.u_shadow_normal_offset=[1,5,5],g.u_shadow_bias=[6e-5,.0012,.012]):g.u_shadow_bias=[36e-5,.0012,.012],o.setShadowUniformValues(d,g)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(r,o,h,d){if(d[2]>=0)return{};const f=function(b,T,M){const S=M/(1<<b.canonical.z);return new a.bS([b.canonical.x*S+b.wrap*M,b.canonical.y*S+b.wrap*M,0],[(b.canonical.x+1)*S+b.wrap*M,(b.canonical.y+1)*S+b.wrap*M,T])}(r,o,h).getCorners(),g=o/-d[2];d[0]<0?(a.N.add(f[0],f[0],[d[0]*g,0,0]),a.N.add(f[3],f[3],[d[0]*g,0,0])):d[0]>0&&(a.N.add(f[1],f[1],[d[0]*g,0,0]),a.N.add(f[2],f[2],[d[0]*g,0,0])),d[1]<0?(a.N.add(f[0],f[0],[0,d[1]*g,0]),a.N.add(f[1],f[1],[0,d[1]*g,0])):d[1]>0&&(a.N.add(f[2],f[2],[0,d[1]*g,0]),a.N.add(f[3],f[3],[0,d[1]*g,0]));const x={};return x.vertices=f,x.planes=[Oo(f[1],f[0],f[4]),Oo(f[2],f[1],f[5]),Oo(f[3],f[2],f[6]),Oo(f[0],f[3],f[7])],x}addShadowReceiver(r,o,h){this._receivers.add(r,a.bS.fromTileIdAndHeight(r,o,h))}getMaxCascadeForTile(r){const o=this._receivers.get(r);return o&&o.lastCascade?o.lastCascade:0}}function Oo(c,r,o){const h=a.N.sub([],o,r),d=a.N.sub([],c,r),f=a.N.cross([],h,d),g=a.N.length(f);return 0===g?[0,0,1,0]:(a.N.scale(f,f,1/g),[f[0],f[1],f[2],-a.N.dot(f,r)])}function il(c){const r=c.properties.get("direction"),o=a.bQ(r.x,r.y,r.z);o[2]=a.aa(o[2],0,75);const h=a.bT([o[0],o[1],o[2]]);return a.N.fromValues(h.x,h.y,h.z)}function ra(c,r){const o=c.properties.get("color"),h=c.properties.get("intensity"),d=c.properties.get("direction"),f=[d.x,d.y,d.z],g=r.properties.get("color"),x=r.properties.get("intensity"),b=Math.max(a.N.dot([0,0,1],f),0),T=[0,0,0];a.N.scale(T,g.toArray01Linear().slice(0,3),x);const M=[0,0,0];return a.N.scale(M,o.toArray01Linear().slice(0,3),b*h),a.bU([T[0]>0?T[0]/(T[0]+M[0]):0,T[1]>0?T[1]/(T[1]+M[1]):0,T[2]>0?T[2]/(T[2]+M[2]):0])}function au(c,r,o,h,d,f){const g=c.zoom,x=c.scale,b=c.worldSize,T=1/b,M=c.aspect,S=Math.sqrt(1+M*M)*Math.tan(.5*c.fovX),C=S*S,P=h-o,k=h+o;let R,O;C>P/k?(R=h,O=h*S):(R=.5*k*(1+C),O=.5*Math.sqrt(P*P+2*(h*h+o*o)*C+k*k*C*C));const D=c.projection.pixelsPerMeter(c.center.lat,b),F=c._camera.getCameraToWorldMercator(),Z=[0,0,-R*T];a.N.transformMat4(Z,Z,F);let V=O*T;const q=c._edgeInsets;if(!(0===q.left&&0===q.top&&0===q.right&&0===q.bottom||q.left===q.right&&q.top===q.bottom)){const Re=c._camera.getWorldToCamera(c.worldSize,"meters"===c.projection.zAxisUnit?D:1),Le=c._camera.getCameraToClipPerspective(c._fov,c.width/c.height,o,h);Le[8]=2*-c.centerOffset.x/c.width,Le[9]=2*c.centerOffset.y/c.height;const je=new Float64Array(16);a.a6.mul(je,Le,Re);const et=new Float64Array(16);a.a6.invert(et,je);const ct=a.bq.fromInvProjectionMatrix(et,b,g,!0);for(const nt of ct.points){const at=((B=nt)[0]/=x,B[1]/=x,B[2]=a.bl(B[2],c._center.lat),B);V=Math.max(V,a.N.len(a.N.subtract([],Z,at)))}}var B;V*=d/(d-1);const $=Math.acos(r[2]),Y=Math.atan2(-r[0],-r[1]),K=new ps;K.position=Z,K.setPitchBearing($,Y);const ee=K.getWorldToCamera(b,D),ce=V*b,re=Math.min(c._mercatorZfromZoom(17)*b*-2,-2*ce),me=K.getCameraToClipOrthographic(-ce,ce,-ce,ce,re,(ce+f*D)/r[2]),pe=new Float64Array(16);a.a6.multiply(pe,me,ee);const Ae=a.N.fromValues(Math.floor(1e6*Z[0])/1e6*b,Math.floor(1e6*Z[1])/1e6*b,0),ne=.5*d,ue=[0,0,0];a.N.transformMat4(ue,Ae,pe),a.N.scale(ue,ue,ne);const Q=[Math.floor(ue[0]),Math.floor(ue[1]),Math.floor(ue[2])],ae=[0,0,0];a.N.sub(ae,ue,Q),a.N.scale(ae,ae,-1/ne);const Ie=new Float64Array(16);return a.a6.identity(Ie),a.a6.translate(Ie,Ie,ae),a.a6.multiply(pe,Ie,pe),[pe,ce]}const oo=(c,r)=>rt(c,r&&r.filter(o=>"source.canvas"!==o.identifier)),lu=a.ac(Gt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),ms=a.ac(Gt,["setCenter","setZoom","setBearing","setPitch"]),Tc={version:8,layers:[],sources:{}},cu={duration:300,delay:0},ep=new Set(["fill","line","background","hillshade","raster"]);class sn extends a.E{constructor(r,o={}){super(),this.map=r,this.scope=o.scope||"",this.fragments=[],this.importDepth=o.importDepth||0,this.importsCache=o.importsCache||new Map,this.resolvedImports=o.resolvedImports||new Set,this.transition=a.e({},cu),this._buildingIndex=new Qh(this),this.crossTileSymbolIndex=new xc,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=o.styleChanges||new To,this.dispatcher=o.dispatcher?o.dispatcher:new a.bW(a.bX(),this),o.imageManager?this.imageManager=o.imageManager:(this.imageManager=new ja,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=o.glyphManager?o.glyphManager:new a.bY(r._requestManager,o.localFontFamily?a.bZ.all:o.localIdeographFontFamily?a.bZ.ideographs:a.bZ.none,o.localFontFamily||o.localIdeographFontFamily),o.modelManager?this.modelManager=o.modelManager:(this.modelManager=new Us(r._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=o.configOptions?o.configOptions:new Map,this._configDependentLayers=o.configDependentLayers?o.configDependentLayers:new Set,this._config=o.config,this.dispatcher.broadcast("setReferrer",a.b_());const h=this;this._rtlTextPluginCallback=sn.registerForPluginStateChange(d=>{h.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,g)=>{if(a.b$(f),g&&g.every(x=>x))for(const x in h._sourceCaches){const b=h._sourceCaches[x],T=b.getSource().type;"vector"!==T&&"geojson"!==T||b.reload()}})}),this.on("data",d=>{if("source"!==d.dataType||"metadata"!==d.sourceDataType)return;const f=this.getOwnSource(d.sourceId);if(f&&f.vectorLayerIds)for(const g in this._layers){const x=this._layers[g];x.source===f.id&&this._validateLayer(x)}})}loadURL(r,o={}){this.fire(new a.b("dataloading",{dataType:"style"}));const h="boolean"==typeof o.validate?o.validate:!a.c0(r);r=this.map._requestManager.normalizeStyleURL(r,o.accessToken),this.resolvedImports.add(r);const d=this.importsCache.get(r);if(d)return this._load(d,h);const f=this.map._requestManager.transformRequest(r,a.R.Style);this._request=a.g(f,(g,x)=>{if(this._request=null,g)this.fire(new a.a(g));else if(x)return this.importsCache.set(r,x),this._load(x,h)})}loadJSON(r,o={}){this.fire(new a.b("dataloading",{dataType:"style"})),this._request=a.f.frame(()=>{this._request=null,this._load(r,!1!==o.validate)})}loadEmpty(){this.fire(new a.b("dataloading",{dataType:"style"})),this._load(Tc,!1)}_loadImports(r,o,h){if(this.importDepth>=4)return a.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const d=[];for(const f of r){const g=this._createFragmentStyle(f),x=new Promise(M=>{g.once("style.import.load",M),g.once("error",M)}).then(()=>this.mergeAll());if(d.push(x),this.resolvedImports.has(f.url)){g.loadEmpty();continue}const b=f.data||this.importsCache.get(f.url);b?g.loadJSON(b,{validate:o}):f.url?g.loadURL(f.url,{validate:o}):g.loadEmpty();const T={style:g,id:f.id,config:f.config};if(h){const M=this.fragments.findIndex(({id:S})=>S===h);this.fragments=this.fragments.slice(0,M).concat(T).concat(this.fragments.slice(M))}else this.fragments.push(T)}return Promise.allSettled(d)}_createFragmentStyle(r){const o=this.scope?a.ag(r.id,this.scope):r.id,h=new sn(this.map,{scope:o,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:r.config,configOptions:this.options,configDependentLayers:this._configDependentLayers});return h.setEventedParent(this.map,{style:h}),h}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const r=this.isRootStyle();this._shouldPrecompile=r,this.fire(new a.b(r?"style.load":"style.import.load"))}_load(r,o){const h=r.schema;if(this.isRootStyle()&&(r.fragment||h&&!1!==r.fragment)){const g=a.e({},Tc,{imports:[{id:"basemap",data:r,url:""}]});return void this._load(g,o)}if(this.setConfig(this._config,h),o&&oo(this,Zr(r)))return;this._loaded=!0,this.stylesheet=a.c1(r);for(const g in r.sources)this.addSource(g,r.sources[g],{validate:!1,isInitialLoad:!0});r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(r.glyphs,this.scope);const d=eu(this.stylesheet.layers);if(this._order=d.map(g=>g.id),this.stylesheet.light&&a.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const g=this.stylesheet.lights[0];this.light=new ot(g.properties,g.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new ot(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const g of d){const x=a.c2(g,this.scope,this.options);x.isConfigDependent&&this._configDependentLayers.add(x.fqid),x.setEventedParent(this,{layer:{id:x.id}}),this._layers[x.id]=x,this._serializedLayers[x.id]=x.serialize();const b=this.getOwnLayerSourceCache(x),T=!!this.directionalLight&&this.directionalLight.shadowsEnabled();b&&x.canCastShadows()&&T&&(b.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const f=this.stylesheet.terrain;f&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=a.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?a.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(f,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new a.b("data",{dataType:"style"})),r.imports?this._loadImports(r.imports,o).then(()=>this._reloadImports()):this._reloadImports()}isRootStyle(){return 0===this.importDepth}mergeAll(){let r,o,h,d,f,g,x,b;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(T=>{if(T.stylesheet){if(null!=T.light&&(r=T.light),T.stylesheet.lights)for(const M of T.stylesheet.lights)"ambient"===M.type&&null!=T.ambientLight&&(o=T.ambientLight),"directional"===M.type&&null!=T.directionalLight&&(h=T.directionalLight);d=this._prioritizeTerrain(d,T.terrain,T.stylesheet.terrain),T.stylesheet.fog&&null!=T.fog&&(f=T.fog),null!=T.stylesheet.camera&&(b=T.stylesheet.camera),null!=T.stylesheet.projection&&(g=T.stylesheet.projection),null!=T.stylesheet.transition&&(x=T.stylesheet.transition)}}),this.light=r,this.ambientLight=o,this.directionalLight=h,this.fog=f,null===d?delete this.terrain:this.terrain=d,this.camera=b||{"camera-projection":"perspective"},this.projection=g||{name:"mercator"},this.transition=a.e({},cu,x),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(r){const o=h=>{for(const d of h.fragments)o(d.style);r(h)};o(this)}_prioritizeTerrain(r,o,h){const d=r&&0===r.drapeRenderMode;return null===h?o&&0===o.drapeRenderMode?o:d?r:null:null!=o&&(!r||d||o&&1===o.drapeRenderMode)?o:r}mergeTerrain(){let r;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(o=>{r=this._prioritizeTerrain(r,o.terrain,o.stylesheet.terrain)}),null===r?delete this.terrain:this.terrain=r}mergeProjection(){let r;this.forEachFragmentStyle(o=>{null!=o.stylesheet.projection&&(r=o.stylesheet.projection)}),this.projection=r||{name:"mercator"}}mergeSources(){const r={},o={},h={};this.forEachFragmentStyle(d=>{for(const f in d._sourceCaches){const g=a.ag(f,d.scope);r[g]=d._sourceCaches[f]}for(const f in d._otherSourceCaches){const g=a.ag(f,d.scope);o[g]=d._otherSourceCaches[f]}for(const f in d._symbolSourceCaches){const g=a.ag(f,d.scope);h[g]=d._symbolSourceCaches[f]}}),this._mergedSourceCaches=r,this._mergedOtherSourceCaches=o,this._mergedSymbolSourceCaches=h}mergeLayers(){const r={},o=[],h={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(f=>{for(const g of f._order){const x=f._layers[g];if("slot"===x.type){const b=a.c3(g);if(r[b])continue;r[b]=[]}x.slot&&r[x.slot]?r[x.slot].push(x):o.push(x)}}),this._mergedOrder=[];const d=(f=[])=>{for(const g of f)if("slot"===g.type){const x=a.c3(g.id);r[x]&&d(r[x])}else{const x=a.ag(g.id,g.scope);this._mergedOrder.push(x),h[x]=g,g.is3D()&&(this._has3DLayers=!0),"circle"===g.type&&(this._hasCircleLayers=!0),"symbol"===g.type&&(this._hasSymbolLayers=!0)}};d(o),this._mergedLayers=h,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(r){return this.stylesheet.camera=a.e({},this.stylesheet.camera,r),this.camera=this.stylesheet.camera,this}setProjection(r){r?this.stylesheet.projection=r:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(r){this._spriteRequest=function(o,h,d){let f,g,x;const b=a.f.devicePixelRatio>1?"@2x":"";let T=a.g(h.transformRequest(h.normalizeSpriteURL(o,b,".json"),a.R.SpriteJSON),(C,P)=>{T=null,x||(x=C,f=P,S())}),M=a.d(h.transformRequest(h.normalizeSpriteURL(o,b,".png"),a.R.SpriteImage),(C,P)=>{M=null,x||(x=C,g=P,S())});function S(){if(x)d(x);else if(f&&g){const C=a.f.getImageData(g),P={};for(const k in f){const{width:R,height:O,x:D,y:F,sdf:Z,pixelRatio:V,stretchX:q,stretchY:B,content:$}=f[k],Y=new a.h({width:R,height:O});a.h.copy(C,Y,{x:D,y:F},{x:0,y:0},{width:R,height:O}),P[k]={data:Y,pixelRatio:V,sdf:Z,stretchX:q,stretchY:B,content:$}}d(null,P)}}return{cancel(){T&&(T.cancel(),T=null),M&&(M.cancel(),M=null)}}}(r,this.map._requestManager,(o,h)=>{if(this._spriteRequest=null,o)this.fire(new a.a(o));else if(h)for(const d in h)this.imageManager.addImage(d,this.scope,h[d]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new a.b("data",{dataType:"style"}))})}_validateLayer(r){const o=this.getOwnSource(r.source);if(!o)return;const h=r.sourceLayer;h&&("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(h))&&this.fire(new a.a(new Error(`Source layer "${h}" does not exist on source "${o.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;if(!this.imageManager.isLoaded()||!this.modelManager.isLoaded())return!1;for(const{style:r}of this.fragments)if(!r.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((r,o)=>{const h=this.fragments[o];return h&&h.style&&(r.data=h.style.serialize()),r})}_serializeSources(){const r={};for(const o in this._sourceCaches){const h=this._sourceCaches[o].getSource();r[h.id]||(r[h.id]=h.serialize())}return r}_serializeLayers(r){const o=[];for(const h of r){const d=this._layers[h];d&&"custom"!==d.type&&o.push(d.serialize())}return o}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition())return!0;for(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(r){return!!this.terrain&&("function"==typeof r.isLayerDraped?r.isLayerDraped(this.getLayerSourceCache(r)):ep.has(r.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(r){const o=this.getOwnLayer(r);if(o)return o;this.fire(new a.a(new Error(`The layer '${r}' does not exist in the map's style.`)))}_checkSource(r){const o=this.getOwnSource(r);if(o)return o;this.fire(new a.a(new Error(`The source '${r}' does not exist in the map's style.`)))}update(r){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r);const o=this.calculateLightsBrightness();r.brightness=o||0,o!==this._brightness&&(this._brightness=o,this.dispatcher.broadcast("setBrightness",o));const h=this._changes.isDirty();if(this._changes.isDirty()){const f=this._changes.getLayerUpdatesByScope();for(const g in f){const{updatedIds:x,removedIds:b}=f[g];(x||b)&&this._updateWorkerLayers(g,x,b)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(r),this.light&&this.light.updateTransitions(r),this.ambientLight&&this.ambientLight.updateTransitions(r),this.directionalLight&&this.directionalLight.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._changes.reset()}const d={};for(const f in this._mergedSourceCaches){const g=this._mergedSourceCaches[f];d[f]=g.used,g.used=!1,g.tileCoverLift=0}for(const f of this._mergedOrder){const g=this._mergedLayers[f];if(g.recalculate(r,this._availableImages),!g.isHidden(r.zoom)){const x=this.getLayerSourceCache(g);x&&(x.used=!0,x.tileCoverLift=Math.max(x.tileCoverLift,g.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let x=g.minzoom||0;x<(g.maxzoom||25.5);x++){const b=this.map.painter;if(b){const T=g.getProgramIds();if(!T)continue;for(const M of T){const S=g.getDefaultProgramParams(M,r.zoom);S&&(b.style=this,this.fog&&(b._fogVisible=!0,S.overrideFog=!0,b.getOrCreateProgram(M,S)),b._fogVisible=!1,S.overrideFog=!1,b.getOrCreateProgram(M,S),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(S.overrideRtt=!0,b.getOrCreateProgram(M,S)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const f in d){const g=this._mergedSourceCaches[f];d[f]!==g.used&&g.getSource().fire(new a.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:g.getSource().id}))}this.light&&this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),h&&this.fire(new a.b("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=this._changes.getUpdatedImages();if(r.length){for(const o in this._sourceCaches)this._sourceCaches[o].reloadTilesForDependencies(["icons","patterns"],r);this._changes.resetUpdatedImages()}}_updateWorkerLayers(r,o,h){const d=this.getFragmentStyle(r);d&&this.dispatcher.broadcast("updateLayers",{layers:o?d._serializeLayers(o):[],scope:r,removedIds:h||[],options:d.options})}setState(r){if(this._checkLoaded(),oo(this,Zr(r)))return!1;(r=a.c1(r)).layers=eu(r.layers);const o=function(d,f){if(!d)return[{command:Gt.setStyle,args:[f]}];let g=[];try{if(!Pt(d.version,f.version))return[{command:Gt.setStyle,args:[f]}];Pt(d.center,f.center)||g.push({command:Gt.setCenter,args:[f.center]}),Pt(d.zoom,f.zoom)||g.push({command:Gt.setZoom,args:[f.zoom]}),Pt(d.bearing,f.bearing)||g.push({command:Gt.setBearing,args:[f.bearing]}),Pt(d.pitch,f.pitch)||g.push({command:Gt.setPitch,args:[f.pitch]}),Pt(d.sprite,f.sprite)||g.push({command:Gt.setSprite,args:[f.sprite]}),Pt(d.glyphs,f.glyphs)||g.push({command:Gt.setGlyphs,args:[f.glyphs]}),Pt(d.imports,f.imports)||function(S=[],C=[],P){C=C||[];const k=(S=S||[]).map(eo),R=C.map(eo),O=S.reduce(Xa,{}),D=C.reduce(Xa,{}),F=k.slice();let Z,V,q,B;for(Z=0,V=0;Z<k.length;Z++)q=k[Z],D.hasOwnProperty(q)?V++:(P.push({command:Gt.removeImport,args:[q]}),F.splice(F.indexOf(q,V),1));for(Z=0,V=0;Z<R.length;Z++)q=R[R.length-1-Z],F[F.length-1-Z]!==q&&(O.hasOwnProperty(q)?(P.push({command:Gt.removeImport,args:[q]}),F.splice(F.lastIndexOf(q,F.length-V),1)):V++,B=F[F.length-Z],P.push({command:Gt.addImport,args:[D[q],B]}),F.splice(F.length-Z,0,q));for(const $ of C){const Y=O[$.id];Y&&!Pt(Y,$)&&P.push({command:Gt.updateImport,args:[$.id,$]})}}(d.imports,f.imports,g),Pt(d.transition,f.transition)||g.push({command:Gt.setTransition,args:[f.transition]}),Pt(d.light,f.light)||g.push({command:Gt.setLight,args:[f.light]}),Pt(d.fog,f.fog)||g.push({command:Gt.setFog,args:[f.fog]}),Pt(d.projection,f.projection)||g.push({command:Gt.setProjection,args:[f.projection]}),Pt(d.lights,f.lights)||g.push({command:Gt.setLights,args:[f.lights]}),Pt(d.camera,f.camera)||g.push({command:Gt.setCamera,args:[f.camera]});const x={},b=[];!function(S,C,P,k){let R;for(R in C=C||{},S=S||{})S.hasOwnProperty(R)&&(C.hasOwnProperty(R)||ic(R,P,k));for(R in C){if(!C.hasOwnProperty(R))continue;const O=C[R];S.hasOwnProperty(R)?Pt(S[R],O)||("geojson"===S[R].type&&"geojson"===O.type&&Wd(S,C,R)?P.push({command:Gt.setGeoJSONSourceData,args:[R,O.data]}):$d(R,C,P,k)):Hs(R,C,P)}}(d.sources,f.sources,b,x);const T=[];d.layers&&d.layers.forEach(S=>{S.source&&x[S.source]?g.push({command:Gt.removeLayer,args:[S.id]}):T.push(S)});let M=d.terrain;M&&x[M.source]&&(g.push({command:Gt.setTerrain,args:[void 0]}),M=void 0),g=g.concat(b),Pt(M,f.terrain)||g.push({command:Gt.setTerrain,args:[f.terrain]}),function(S,C,P){C=C||[];const k=(S=S||[]).map(eo),R=C.map(eo),O=S.reduce(Xa,{}),D=C.reduce(Xa,{}),F=k.slice(),Z=Object.create(null);let V,q,B,$,Y,K,ee;for(V=0,q=0;V<k.length;V++)B=k[V],D.hasOwnProperty(B)?q++:(P.push({command:Gt.removeLayer,args:[B]}),F.splice(F.indexOf(B,q),1));for(V=0,q=0;V<R.length;V++)B=R[R.length-1-V],F[F.length-1-V]!==B&&(O.hasOwnProperty(B)?(P.push({command:Gt.removeLayer,args:[B]}),F.splice(F.lastIndexOf(B,F.length-q),1)):q++,K=F[F.length-V],P.push({command:Gt.addLayer,args:[D[B],K]}),F.splice(F.length-V,0,B),Z[B]=!0);for(V=0;V<R.length;V++)if(B=R[V],$=O[B],Y=D[B],!Z[B]&&!Pt($,Y))if(Pt($.source,Y.source)&&Pt($["source-layer"],Y["source-layer"])&&Pt($.type,Y.type)){for(ee in Qn($.layout,Y.layout,P,B,null,Gt.setLayoutProperty),Qn($.paint,Y.paint,P,B,null,Gt.setPaintProperty),Pt($.slot,Y.slot)||P.push({command:Gt.setSlot,args:[B,Y.slot]}),Pt($.filter,Y.filter)||P.push({command:Gt.setFilter,args:[B,Y.filter]}),Pt($.minzoom,Y.minzoom)&&Pt($.maxzoom,Y.maxzoom)||P.push({command:Gt.setLayerZoomRange,args:[B,Y.minzoom,Y.maxzoom]}),$)$.hasOwnProperty(ee)&&"layout"!==ee&&"paint"!==ee&&"filter"!==ee&&"metadata"!==ee&&"minzoom"!==ee&&"maxzoom"!==ee&&"slot"!==ee&&(0===ee.indexOf("paint.")?Qn($[ee],Y[ee],P,B,ee.slice(6),Gt.setPaintProperty):Pt($[ee],Y[ee])||P.push({command:Gt.setLayerProperty,args:[B,ee,Y[ee]]}));for(ee in Y)Y.hasOwnProperty(ee)&&!$.hasOwnProperty(ee)&&"layout"!==ee&&"paint"!==ee&&"filter"!==ee&&"metadata"!==ee&&"minzoom"!==ee&&"maxzoom"!==ee&&"slot"!==ee&&(0===ee.indexOf("paint.")?Qn($[ee],Y[ee],P,B,ee.slice(6),Gt.setPaintProperty):Pt($[ee],Y[ee])||P.push({command:Gt.setLayerProperty,args:[B,ee,Y[ee]]}))}else P.push({command:Gt.removeLayer,args:[B]}),K=F[F.lastIndexOf(B)+1],P.push({command:Gt.addLayer,args:[Y,K]})}(T,f.layers,g)}catch(x){console.warn("Unable to compute style diff:",x),g=[{command:Gt.setStyle,args:[f]}]}return g}(this.serialize(),r).filter(d=>!(d.command in ms));if(0===o.length)return!1;const h=o.filter(d=>!(d.command in lu));if(h.length>0)throw new Error(`Unimplemented: ${h.map(d=>d.command).join(", ")}.`);return o.forEach(d=>{this[d.command].apply(this,d.args)}),this.stylesheet=r,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(r,o){return this.getImage(r)?this.fire(new a.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(r,this.scope,o),this._afterImageUpdated(r),this)}updateImage(r,o){this.imageManager.updateImage(r,this.scope,o)}getImage(r){return this.imageManager.getImage(r,this.scope)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r,this.scope),this._afterImageUpdated(r),this):this.fire(new a.a(new Error("No image with this name exists.")))}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(r),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new a.b("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(r,o,h={}){return this._checkLoaded(),this._validate(tt,`models.${r}`,o,null,h)||(this.modelManager.addModel(r,o,this.scope),this._changes.setDirty()),this}hasModel(r){return this.modelManager.hasModel(r,this.scope)}removeModel(r){return this.hasModel(r)?(this.modelManager.removeModel(r,this.scope),this):this.fire(new a.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(r,o,h={}){if(this._checkLoaded(),void 0!==this.getOwnSource(r))throw new Error(`There is already a source with ID "${r}".`);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(An,`sources.${r}`,o,null,h))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);const d=Wi(r,o,this.dispatcher,this);d.scope=this.scope,d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(d.id),source:d.serialize(),sourceId:d.id}));const f=g=>{const x=(g?"symbol:":"other:")+d.id,b=a.ag(x,this.scope),T=this._sourceCaches[x]=new nn(b,d,g);(g?this._symbolSourceCaches:this._otherSourceCaches)[d.id]=T,T.onAdd(this.map)};f(!1),"vector"!==o.type&&"geojson"!==o.type||f(!0),d.onAdd&&d.onAdd(this.map),h.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(r){this._checkLoaded();const o=this.getOwnSource(r);if(!o)throw new Error("There is no source with this ID");for(const d in this._layers)if(this._layers[d].source===r)return this.fire(new a.a(new Error(`Source "${r}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===r)return this.fire(new a.a(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));const h=this.getOwnSourceCaches(r);for(const d of h){const f=a.c3(d.id);delete this._sourceCaches[f],this._changes.discardSourceCacheUpdate(d.id),d.fire(new a.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles()}return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],this.mergeSources(),o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(r,o){this._checkLoaded(),this.getOwnSource(r).setData(o),this._changes.setDirty()}getOwnSource(r){const o=this.getOwnSourceCache(r);return o&&o.getSource()}getOwnSources(){const r=[];for(const o in this._otherSourceCaches){const h=this.getOwnSourceCache(o);h&&r.push(h.getSource())}return r}areTilesLoaded(){const r=this._mergedSourceCaches;for(const o in r){const h=r[o]._tiles;for(const d in h){const f=h[d];if("loaded"!==f.state&&"errored"!==f.state)return!1}}return!0}setLights(r){if(this._checkLoaded(),!r)return delete this.ambientLight,void delete this.directionalLight;const o=this._getTransitionParameters();for(const d of r){if(this._validate(Te,"lights",d))return;switch(d.type){case"ambient":if(this.ambientLight){const f=this.ambientLight;f.set(d),f.updateTransitions(o)}else this.ambientLight=new _r(d,Er,this.scope,this.options);break;case"directional":if(this.directionalLight){const f=this.directionalLight;f.set(d),f.updateTransitions(o)}else this.directionalLight=new _r(d,Zi,this.scope,this.options)}}const h=new a.K(this.z||0,o);this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const r=this.directionalLight,o=this.ambientLight;if(!r||!o)return;const h=S=>.2126*(S[0]<=.03928?S[0]/12.92:Math.pow((S[0]+.055)/1.055,2.4))+.7152*(S[1]<=.03928?S[1]/12.92:Math.pow((S[1]+.055)/1.055,2.4))+.0722*(S[2]<=.03928?S[2]/12.92:Math.pow((S[2]+.055)/1.055,2.4)),d=r.properties.get("color").toArray01(),f=r.properties.get("intensity"),g=r.properties.get("direction"),x=1-a.bQ(g.x,g.y,g.z)[2]/90,b=h(d)*f*x,T=o.properties.get("color").toArray01(),M=o.properties.get("intensity");return(b+h(T)*M)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const r=[];return this.directionalLight&&r.push(this.directionalLight.get()),this.ambientLight&&r.push(this.ambientLight.get()),r}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(r){if(!r)return this;if(a.c4(r)){const o=a.c5(r),h=this.fragments.find(({id:f})=>f===o);if(!h)throw new Error(`Style import not found: ${r}`);const d=a.c3(r);return h.style.getFragmentStyle(d)}{const o=this.fragments.find(({id:h})=>h===r);if(!o)throw new Error(`Style import not found: ${r}`);return o.style}}getConfigProperty(r,o){const h=this.getFragmentStyle(r);if(!h)return null;const d=a.ag(o,h.scope),f=h.options.get(d),g=f?f.value||f.default:null;return g?g.serialize():null}setConfigProperty(r,o,h){const d=a.r(h);if("success"!==d.result)return void oo(this,d.value);const f=d.value.expression,g=this.getFragmentStyle(r);if(!g)return;const x=a.ag(o,g.scope),b=g.options.get(x);b&&(this.options.set(x,{...b,value:f}),this.updateConfigDependencies())}setConfig(r,o){if(this._config=r,r||o)if(o)for(const h in o){let d,f;const g=a.r(o[h].default);if("success"===g.result&&(d=g.value.expression),r&&void 0!==r[h]){const C=a.r(r[h]);"success"===C.result&&(f=C.value.expression)}const{minValue:x,maxValue:b,stepValue:T,type:M,values:S}=o[h];if(d){const C=a.ag(h,this.scope);this.options.set(C,{default:d,value:f,minValue:x,maxValue:b,stepValue:T,type:M,values:S})}else this.fire(new a.a(new Error(`No schema defined for config option "${h}".`)))}else this.fire(new a.a(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const r of this._configDependentLayers){const o=this.getLayer(r);o&&(o.possiblyEvaluateVisibility(),this._updateLayer(o))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty()}addLayer(r,o,h={}){this._checkLoaded();const d=r.id;if(this._layers[d])return void this.fire(new a.a(new Error(`Layer with id "${d}" already exists on this map`)));let f;if("custom"===r.type){if(oo(this,a.c6(r)))return;f=a.c2(r,this.scope,this.options)}else{if("object"==typeof r.source&&(this.addSource(d,r.source),r=a.c1(r),r=a.e(r,{source:d})),this._validate(te,`layers.${d}`,r,{arrayIndex:-1},h))return;f=a.c2(r,this.scope,this.options),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize()}f.isConfigDependent&&this._configDependentLayers.add(f.fqid);let g=this._order.length;if(o){const M=this._order.indexOf(o);if(-1===M)return void this.fire(new a.a(new Error(`Layer with id "${o}" does not exist on this map.`)));f.slot===this._layers[o].slot?g=M:a.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(g,0,d),this._layerOrderChanged=!0,this._layers[d]=f;const x=this.getOwnLayerSourceCache(f),b=!!this.directionalLight&&this.directionalLight.shadowsEnabled();x&&f.canCastShadows()&&b&&(x.castsShadows=!0);const T=this._changes.getRemovedLayer(f);if(T&&f.source&&x&&"custom"!==f.type){this._changes.discardLayerRemoval(f);const M=a.ag(f.source,f.scope);T.type!==f.type?this._changes.updateSourceCache(M,"clear"):(this._changes.updateSourceCache(M,"reload"),x.pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map),f.scope=this.scope,this.mergeLayers()}moveLayer(r,o){this._checkLoaded();const h=this._checkLayer(r);if(!h||r===o)return;const d=this._order.indexOf(r);this._order.splice(d,1);let f=this._order.length;if(o){const g=this._order.indexOf(o);if(-1===g)return void this.fire(new a.a(new Error(`Layer with id "${o}" does not exist on this map.`)));h.slot===this._layers[o].slot?f=g:a.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(f,0,r),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(r){this._checkLoaded();const o=this._checkLayer(r);if(!o)return;o.setEventedParent(null);const h=this._order.indexOf(r);this._order.splice(h,1),delete this._layers[r],delete this._serializedLayers[r],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(o.fqid),this._changes.removeLayer(o);const d=this.getOwnLayerSourceCache(o);if(d&&d.castsShadows){let f=!1;for(const g in this._layers)if(this._layers[g].source===o.source&&this._layers[g].canCastShadows()){f=!0;break}d.castsShadows=f}o.onRemove&&o.onRemove(this.map),this.mergeLayers()}getOwnLayer(r){return this._layers[r]}hasLayer(r){return r in this._mergedLayers}hasLayerType(r){for(const o in this._layers)if(this._layers[o].type===r)return!0;return!1}setLayerZoomRange(r,o,h){this._checkLoaded();const d=this._checkLayer(r);d&&(d.minzoom===o&&d.maxzoom===h||(null!=o&&(d.minzoom=o),null!=h&&(d.maxzoom=h),this._updateLayer(d)))}setSlot(r,o){this._checkLoaded();const h=this._checkLayer(r);h&&h.slot!==o&&(h.slot=o,this._updateLayer(h))}setFilter(r,o,h={}){this._checkLoaded();const d=this._checkLayer(r);if(d&&!Pt(d.filter,o))return null==o?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(ye,`layers.${d.id}.filter`,o,{layerType:d.type},h)||(d.filter=a.c1(o),this._updateLayer(d)))}getFilter(r){const o=this._checkLayer(r);if(o)return a.c1(o.filter)}setLayoutProperty(r,o,h,d={}){this._checkLoaded();const f=this._checkLayer(r);if(f&&!Pt(f.getLayoutProperty(o),h)){if(null!=h&&(!d||!1!==d.validate)&&oo(f,ze.call(Zr,{key:`layers.${r}.layout.${o}`,layerType:f.type,objectKey:o,value:h,styleSpec:a.D,style:{glyphs:!0,sprite:!0}})))return;f.setLayoutProperty(o,h),f.isConfigDependent&&this._configDependentLayers.add(f.fqid),this._updateLayer(f)}}getLayoutProperty(r,o){const h=this._checkLayer(r);if(h)return h.getLayoutProperty(o)}setPaintProperty(r,o,h,d={}){this._checkLoaded();const f=this._checkLayer(r);if(!f||Pt(f.getPaintProperty(o),h)||null!=h&&(!d||!1!==d.validate)&&oo(f,Ee.call(Zr,{key:`layers.${r}.paint.${o}`,layerType:f.type,objectKey:o,value:h,styleSpec:a.D})))return;const g=f.setPaintProperty(o,h);f.isConfigDependent&&this._configDependentLayers.add(f.fqid),g&&this._updateLayer(f),this._changes.updatePaintProperties(f)}getPaintProperty(r,o){const h=this._checkLayer(r);if(h)return h.getPaintProperty(o)}setFeatureState(r,o){this._checkLoaded();const h=r.source,d=r.sourceLayer,f=this._checkSource(h);if(!f)return;const g=f.type;if("geojson"===g&&d)return void this.fire(new a.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===g&&!d)return void this.fire(new a.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new a.a(new Error("The feature id parameter must be provided.")));const x=this.getOwnSourceCaches(h);for(const b of x)b.setFeatureState(d,r.id,o)}removeFeatureState(r,o){this._checkLoaded();const h=r.source,d=this._checkSource(h);if(!d)return;const f=d.type,g="vector"===f?r.sourceLayer:void 0;if("vector"===f&&!g)return void this.fire(new a.a(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new a.a(new Error("A feature id is required to remove its specific state property.")));const x=this.getOwnSourceCaches(h);for(const b of x)b.removeFeatureState(g,r.id,o)}getFeatureState(r){this._checkLoaded();const o=r.source,h=r.sourceLayer,d=this._checkSource(o);if(d){if("vector"!==d.type||h)return void 0===r.id&&this.fire(new a.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(h,r.id);this.fire(new a.a(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(r){return this.stylesheet.transition=a.e({},this.stylesheet.transition,r),this.transition=this.stylesheet.transition,this}getTransition(){return a.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const r=this.getTerrain(),o=r&&this.terrain&&this.terrain.scope===this.scope?r:this.stylesheet.terrain;return a.c7({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:o,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:this._serializeSources(),layers:this._serializeLayers(this._order)},h=>void 0!==h)}_updateLayer(r){this._changes.updateLayer(r);const o=this.getLayerSourceCache(r),h=a.ag(r.source,r.scope),d=this._changes.getUpdatedSourceCaches();r.source&&!d[h]&&o&&"raster"!==o.getSource().type&&(this._changes.updateSourceCache(h,"reload"),o.pause()),r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const o=x=>"fill-extrusion"===this._mergedLayers[x].type||"model"===this._mergedLayers[x].type,h=this.order,d={},f=[];for(let x=h.length-1;x>=0;x--){const b=h[x];if(o(b)){d[b]=x;for(const T of r){const M=T[b];if(M)for(const S of M)f.push(S)}}}f.sort((x,b)=>b.intersectionZ-x.intersectionZ);const g=[];for(let x=h.length-1;x>=0;x--){const b=h[x];if(o(b))for(let T=f.length-1;T>=0;T--){const M=f[T].feature;if(d[M.layer.id]<x)break;g.push(M),f.pop()}else for(const T of r){const M=T[b];if(M)for(const S of M)g.push(S.feature)}}return g}queryRenderedFeatures(r,o,h){o&&o.filter&&this._validate(ye,"queryRenderedFeatures.filter",o.filter,null,o),o.scope=this.scope,o.availableImages=this._availableImages,o.serializedLayers=this._serializedLayers;const d={};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new a.a(new Error("parameters.layers must be an Array."))),[];for(const T of o.layers){const M=this._mergedLayers[T];if(!M)return this.fire(new a.a(new Error(`The layer '${T}' does not exist in the map's style and cannot be queried for features.`))),[];d[M.source]=!0}}const f=[],g=o.serializedLayers||{},x=o&&o.layers?o.layers.some(T=>{const M=this.getLayer(T);return M&&M.is3D()}):this.has3DLayers(),b=Ui.createFromScreenPoints(r,h);for(const T in this._mergedSourceCaches){const M=this._mergedSourceCaches[T].getSource();if(!M||M.scope!==o.scope)continue;const S=this._mergedSourceCaches[T].getSource().id;o.layers&&!d[S]||f.push(tc(this._mergedSourceCaches[T],this._mergedLayers,g,b,o,h,x,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(T,M,S,C,P,k,R){const O={},D=k.queryRenderedSymbols(C),F=[];for(const Z of Object.keys(D).map(Number))F.push(R[Z]);F.sort(ls);for(const Z of F){const V=Z.featureIndex.lookupSymbolFeatures(D[Z.bucketInstanceId],M,Z.bucketIndex,Z.sourceLayerIndex,P.filter,P.layers,P.availableImages,T);for(const q in V){const B=O[q]=O[q]||[],$=V[q];$.sort((Y,K)=>{const ee=Z.featureSortOrder;if(ee){const ce=ee.indexOf(Y.featureIndex);return ee.indexOf(K.featureIndex)-ce}return K.featureIndex-Y.featureIndex});for(const Y of $)B.push(Y)}}for(const Z in O)O[Z].forEach(V=>{const q=V.feature,B=S(T[Z]);if(!B)return;const $=B.getFeatureState(q.layer["source-layer"],q.id);q.source=q.layer.source,q.layer["source-layer"]&&(q.sourceLayer=q.layer["source-layer"]),q.state=$});return O}(this._mergedLayers,g,this.getLayerSourceCache.bind(this),b.screenGeometry,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(r,o){o&&o.filter&&this._validate(ye,"querySourceFeatures.filter",o.filter,null,o);const h=this.getOwnSourceCaches(r);let d=[];for(const f of h)d=d.concat(Cn(f,o));return d}addSourceType(r,o,h){return sn.getSourceType(r)?h(new Error(`A source type called "${r}" already exists.`)):(sn.setSourceType(r,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:r,url:o.workerSourceURL},h):h(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(r,o,h={}){this._checkLoaded();const d=this.light.getLight();let f=!1;for(const x in r)if(!Pt(r[x],d[x])){f=!0;break}if(!f)return;const g=this._getTransitionParameters();this.light.setLight(r,o,h),this.light.updateTransitions(g)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,o=1){if(this._checkLoaded(),!r)return this.terrainSetForDrapingOnly()&&0!==o||delete this.terrain,null===r?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let h=r;const d=null==r.source;if(1===o){if("object"==typeof h.source){const x="terrain-dem-src";this.addSource(x,h.source),h=a.c1(h),h=a.e(h,{source:x})}const f=a.e({},h),g={};if(this.terrain&&d){f.source=this.terrain.get().source;const x=this.terrain?this.getFragmentStyle(this.terrain.scope):null;x&&(g.style=x.serialize())}if(this._validate(U,"terrain",f,g))return}if(!this.terrain||this.terrain.scope!==this.scope&&!d||this.terrain&&o!==this.terrain.drapeRenderMode){if(!h)return;this._createTerrain(h,o),this.fire(new a.b("data",{dataType:"style"}))}else{const f=this.terrain,g=f.get();for(const x of Object.keys(a.D.terrain))!h.hasOwnProperty(x)&&a.D.terrain[x].default&&(h[x]=a.D.terrain[x].default);for(const x in r)if(!Pt(r[x],g[x])){f.set(r,this.options),this.stylesheet.terrain=r;const b=this._getTransitionParameters({duration:0});f.updateTransitions(b),this.fire(new a.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const o=this.fog=new vr(r,this.map.transform,this.scope,this.options);this.stylesheet.fog=o.get();const h=this._getTransitionParameters({duration:0});o.updateTransitions(h)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const o=this.fog;if(!Pt(o.get(),r)){o.set(r,this.options),this.stylesheet.fog=o.get();const h=this._getTransitionParameters({duration:0});o.updateTransitions(h)}}else this._createFog(r);this._markersNeedUpdate=!0}_getTransitionParameters(r){return{now:a.f.now(),transition:a.e(this.transition,r)}}updateDrapeFirstLayers(){if(!this.terrain)return;const r=[],o=[];for(const h in this._mergedLayers)this.isLayerDraped(this._mergedLayers[h])?r.push(h):o.push(h);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...o)}_createTerrain(r,o){const h=this.terrain=new ui(r,o,this.scope,this.options);1===o&&(this.stylesheet.terrain=r),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const d=this._getTransitionParameters({duration:0});h.updateTransitions(d)}_force3DLayerUpdate(){for(const r in this._layers){const o=this._layers[r];"fill-extrusion"===o.type&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const o=this._layers[r];"symbol"===o.type&&this._updateLayer(o)}}_validate(r,o,h,d,f={}){if(f&&!1===f.validate)return!1;const g=a.e({},this.serialize());return oo(this,r.call(Zr,a.e({key:o,style:g,value:h,styleSpec:a.D},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.c8.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._mergedLayers)this._mergedLayers[r].setEventedParent(null);for(const r in this._mergedSourceCaches)this._mergedSourceCaches[r].clearTiles(),this._mergedSourceCaches[r].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(r){const o=this.getSourceCaches(r);for(const h of o)h.clearTiles()}clearSources(){for(const r in this._mergedSourceCaches)this._mergedSourceCaches[r].clearTiles()}reloadSource(r){const o=this.getSourceCaches(r);for(const h of o)h.resume(),h.reload()}reloadSources(){for(const r of this.getSources())r.reload&&r.reload()}updateSources(r){let o;this.directionalLight&&(o=il(this.directionalLight));for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].update(r,void 0,void 0,o)}_generateCollisionBoxes(){for(const r in this._sourceCaches){const o=this._sourceCaches[r];o.resume(),o.reload()}}_updatePlacement(r,o,h,d,f=!1){let g=!1,x=!1;const b={},T={};for(const M of this._mergedOrder){const S=this._mergedLayers[M];if("symbol"!==S.type)continue;const C=a.ag(S.source,S.scope);let P=b[C];if(!P){const R=this.getLayerSourceCache(S);if(!R)continue;const O=R.getRenderableIds(!0).map(D=>R.getTileByID(D));T[C]=O.slice(),P=b[C]=O.sort((D,F)=>F.tileID.overscaledZ-D.tileID.overscaledZ||(D.tileID.isLessThan(F.tileID)?-1:1))}const k=this.crossTileSymbolIndex.addLayer(S,P,r.center.lng,r.projection);g=g||k}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),f=f||this._layerOrderChanged||0===h,this._layerOrderChanged&&this.fire(new a.b("neworder")),(f||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.f.now(),r.zoom))&&(this.pauseablePlacement=new Qa(r,this._mergedOrder,f,o,h,d,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,b,T),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.f.now()),x=!0),g&&this.pauseablePlacement.placement.setStale()),x||g){this._buildingIndex.onNewFrame(r.zoom);for(const M of this._mergedOrder){const S=this._mergedLayers[M];"symbol"===S.type&&this.placement.updateLayerOpacities(S,b[a.ag(S.source,S.scope)])}}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.f.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}addImport(r,o){this._checkLoaded();const h=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==h.findIndex(({id:f})=>f===r.id))return this.fire(new a.a(new Error(`Import with id '${r.id}' already exists in the map's style.`)));if(!o)return h.push(r),this._loadImports([r],!0),this;const d=h.findIndex(({id:f})=>f===o);return-1===d?this.fire(new a.a(new Error(`Import with id "${o}" does not exist on this map.`))):(this.stylesheet.imports=h.slice(0,d).concat(r).concat(h.slice(d)),this._loadImports([r],!0,o),this)}updateImport(r,o){this._checkLoaded();const h=this.stylesheet.imports||[],d=this.getImportIndex(r);return-1===d?this:"string"==typeof o?(this.setImportUrl(r,o),this):(o.url&&o.url!==h[d].url&&this.setImportUrl(r,o.url),Pt(o.config,h[d].config)||this.setImportConfig(r,o.config),Pt(o.data,h[d].data)||this.setImportData(r,o.data),this)}moveImport(r,o){this._checkLoaded();let h=this.stylesheet.imports||[];const d=this.getImportIndex(r);if(-1===d)return this;const f=this.getImportIndex(o);if(-1===f)return this;const g=h[d],x=this.fragments[d];return h=h.filter(({id:b})=>b!==r),this.fragments=this.fragments.filter(({id:b})=>b!==r),this.stylesheet.imports=h.slice(0,f).concat(g).concat(h.slice(f)),this.fragments=this.fragments.slice(0,f).concat(x).concat(this.fragments.slice(f)),this.mergeLayers(),this}setImportUrl(r,o){this._checkLoaded();const h=this.stylesheet.imports||[],d=this.getImportIndex(r);if(-1===d)return this;h[d].url=o;const f=this.fragments[d];return f.style=this._createFragmentStyle(h[d]),f.style.on("style.import.load",()=>this.mergeAll()),f.style.loadURL(o),this}setImportData(r,o){this._checkLoaded();const h=this.getImportIndex(r),d=this.stylesheet.imports||[];return-1===h?this:o?(this.fragments[h].style.setState(o),this._reloadImports(),this):(delete d[h].data,this.setImportUrl(r,d[h].url))}setImportConfig(r,o){this._checkLoaded();const h=this.getImportIndex(r),d=this.stylesheet.imports||[];if(-1===h)return this;o?d[h].config=o:delete d[h].config;const f=this.fragments[h],g=f.style.stylesheet&&f.style.stylesheet.schema;return f.config=o,f.style.setConfig(o,g),this.updateConfigDependencies(),this}removeImport(r){this._checkLoaded();const o=this.stylesheet.imports||[],h=this.getImportIndex(r);return-1===h||(o.splice(h,1),this.fragments[h].style._remove(),this.fragments.splice(h,1),this._reloadImports()),this}getImportIndex(r){const o=(this.stylesheet.imports||[]).findIndex(h=>h.id===r);return-1===o&&this.fire(new a.a(new Error(`Import '${r}' does not exist in the map's style and cannot be updated.`))),o}getLayer(r){return this._mergedLayers[r]}getSources(){const r=[];for(const o in this._mergedOtherSourceCaches){const h=this._mergedOtherSourceCaches[o];h&&r.push(h.getSource())}return r}getSource(r,o){const h=this.getSourceCache(r,o);return h&&h.getSource()}getLayerSource(r){const o=this.getLayerSourceCache(r);return o&&o.getSource()}getSourceCache(r,o){const h=a.ag(r,o);return this._mergedOtherSourceCaches[h]}getLayerSourceCache(r){const o=a.ag(r.source,r.scope);return"symbol"===r.type?this._mergedSymbolSourceCaches[o]:this._mergedOtherSourceCaches[o]}getSourceCaches(r){const o=[];return this._mergedOtherSourceCaches[r]&&o.push(this._mergedOtherSourceCaches[r]),this._mergedSymbolSourceCaches[r]&&o.push(this._mergedSymbolSourceCaches[r]),o}updateSourceCaches(){const r=this._changes.getUpdatedSourceCaches();for(const o in r){const h=r[o];"reload"===h?this.reloadSource(o):"clear"===h&&this.clearSource(o)}}updateLayers(r){const o=this._changes.getUpdatedPaintProperties();for(const h of o){const d=this.getLayer(h);d&&d.updateTransitions(r)}}getImages(r,o,h){this.imageManager.getImages(o.icons,o.scope,h),this._updateTilesForChangedImages();const d=f=>{f&&f.setDependencies(o.tileID.key,o.type,o.icons)};d(this._otherSourceCaches[o.source]),d(this._symbolSourceCaches[o.source])}getGlyphs(r,o,h){this.glyphManager.getGlyphs(o.stacks,o.scope,h)}getResource(r,o,h){return a.c9(o,h)}getOwnSourceCache(r){return this._otherSourceCaches[r]}getOwnLayerSourceCache(r){return"symbol"===r.type?this._symbolSourceCaches[r.source]:this._otherSourceCaches[r.source]}getOwnSourceCaches(r){const o=[];return this._otherSourceCaches[r]&&o.push(this._otherSourceCaches[r]),this._symbolSourceCaches[r]&&o.push(this._symbolSourceCaches[r]),o}_isSourceCacheLoaded(r){const o=this.getOwnSourceCaches(r);return 0===o.length?(this.fire(new a.a(new Error(`There is no source with ID '${r}'`))),!1):o.every(h=>h.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(r=>{r.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}sn.getSourceType=function(c){return In[c]},sn.setSourceType=function(c,r){In[c]=r},sn.registerForPluginStateChange=a.bV;var rl="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",nl="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",ol="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat 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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat 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;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}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);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",sl="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",Mc="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform 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(\nmix(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;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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 currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat 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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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*texture(u_dem_prev,pos).r;\n#else\nfloat 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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.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(texture(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(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);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) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;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;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);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",Ec="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out 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);}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);}\n#endif",hu="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;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;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);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",_s="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",gs="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform vec2 u_velocity_res;uniform float u_max_speed;const vec2 INVALID_VELOCITY=vec2(-1);uniform vec2 u_texture_offset;uniform float u_data_offset;uniform vec4 u_data_scale;vec2 lookup_velocity(vec2 uv) {uv=u_texture_offset.x+u_texture_offset.y*uv;vec2 fxy;ivec4 c=_raTexLinearCoord(uv,u_velocity_res,fxy);vec4 tl=texelFetch(u_velocity,c.yz,0);vec4 tr=texelFetch(u_velocity,c.xz,0);vec4 bl=texelFetch(u_velocity,c.yw,0);vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NODATA) {return INVALID_VELOCITY;}if (tr==NODATA) {return INVALID_VELOCITY;}if (bl==NODATA) {return INVALID_VELOCITY;}if (br==NODATA) {return INVALID_VELOCITY;}vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);\n#ifdef DATA_FORMAT_UINT32\nvec2 velocity=vec2(u_data_offset+dot(t,u_data_scale),0);return velocity;\n#else\nvec2 velocity=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));\n#endif\nreturn velocity/max(u_max_speed,length(velocity));}\n#endif",Sc="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",na="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const ys=[];so(rl,ys),so(ol,ys),so(nl,ys);const Fr={"_prelude_fog.vertex.glsl":Ec,"_prelude_terrain.vertex.glsl":Mc,"_prelude_shadow.vertex.glsl":Sc,"_prelude_fog.fragment.glsl":hu,"_prelude_shadow.fragment.glsl":na,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":_s,"_prelude_raster_particle.glsl":gs},xs={};Xt("",Mc),Xt(hu,Ec),Xt(na,Sc),Xt(_s,""),Xt(gs,"");const Ac=Xt(nl,ol),al=rl;var Ic={background:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 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) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}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);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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(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);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(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);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Xt("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Xt('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Xt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Xt("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.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:Xt("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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(\nmix(-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(\n0.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:Xt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout 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;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;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));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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*h);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);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=max(0.01,cutoff_opacity(u_cutoff_params,ground.z));if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff < 0.01 && centroid_pos.x !=0.0));gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Xt("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;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;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool 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);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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;\n#endif\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;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=(pattern_br-pattern_tl)/pixel_ratio;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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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);\n#endif\nfloat 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\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Xt('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Xt("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Xt("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}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+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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 pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin 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;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),0.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;vec2 uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nvec2 uv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Xt("precision highp float;uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'precision highp float;\n#include "_prelude_raster_array.glsl"\n#include "_prelude_raster_particle.glsl"\nin vec3 a_pos;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {vec2 pos=a_pos.xy+u_tile_offset;vec2 tex_coords=fract(pos);gl_PointSize=1.0;vec2 velocity=lookup_velocity(tex_coords);if (velocity==INVALID_VELOCITY) {v_particle_speed=0.0;gl_Position=vec4(2.0,2.0,2.0,1.0);} else {v_particle_speed=length(velocity);gl_Position=vec4(2.0*pos-vec2(1.0),0.0,1.0);}}'),rasterParticleTexture:Xt("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {v_tex_pos=0.5*a_pos+vec2(0.5);gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Xt("void main() {}",'#include "_prelude_raster_array.glsl"\n#include "_prelude_raster_particle.glsl"\nin vec3 a_pos;uniform float u_speed_factor;uniform float u_lifetime_delta;uniform float u_rand_seed;out vec3 v_new_particle;const vec3 rand_constants=vec3(12.9898,78.233,4375.85453);float rand(const vec2 co) {float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {float lifetime=a_pos.z;vec2 pos=a_pos.xy;vec2 uv=clamp(pos,vec2(0.0),vec2(1.0));vec2 velocity=lookup_velocity(uv);float next_lifetime=lifetime-u_lifetime_delta;float t=step(0.0,next_lifetime);\n#ifdef DATA_FORMAT_UINT32\nvec2 dp=vec2(0);\n#else\nvec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;\n#endif\nvec2 seed=pos*u_rand_seed;vec2 next_pos=pos+dp;vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));v_new_particle=vec3(\nvec2(mix(random_pos,next_pos,t)),mix(1.0,next_lifetime,t)\n);}'),symbolIcon:Xt('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nuniform mediump float u_icon_saturation;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef SATURATION\nvec3 luma=vec3(dot(out_color.rgb,vec3(0.2126,0.7152,0.0722)));out_color.rgb=mix(luma,out_color.rgb,u_icon_saturation);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\nuniform 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 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_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:Xt('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 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[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.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 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 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 out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:Xt('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 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[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:Xt("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Xt('#include "_prelude_fog.fragment.glsl"\nin 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(\ncos_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=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',sl),skyboxGradient:Xt('#include "_prelude_fog.fragment.glsl"\nin 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=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',sl),skyboxCapture:Xt("\nin 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;precision highp float;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat 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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:Xt('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:Xt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Xt("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Xt("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function so(c,r){const o=c.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let h of o)if(h=h.trim(),"#"===h[0]&&h.includes("if")&&!h.includes("endif")){h=h.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const d=h.split(" ");for(const f of d)r.includes(f)||r.push(f)}}function Xt(c,r){const o=/#include\s+"([^"]+)"/g,h=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let d=r.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);d&&(d=d.map(T=>{const M=T.split(" ");return M[M.length-1]}),d=[...new Set(d)]);const f={},g=[],x=[];if(c=c.replace(o,(T,M)=>(x.push(M),"")),(r=r.replace(o,(T,M)=>(g.push(M),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let b=[...ys];so(c,b),so(r,b);for(const T of[...g,...x])Fr[T]||console.error(`Undefined include: ${T}`),xs[T]||(xs[T]=[],so(Fr[T],xs[T])),b=[...b,...xs[T]];return{fragmentSource:c=c.replace(h,(T,M,S,C,P)=>(f[P]=!0,"define"===M?`\n#ifndef HAS_UNIFORM_u_${P}\nin ${S} ${C} ${P};\n#else\nuniform ${S} ${C} u_${P};\n#endif\n`:"initialize"===M?`\n#ifdef HAS_UNIFORM_u_${P}\n ${S} ${C} ${P} = u_${P};\n#endif\n`:"define-attribute"===M?`\n#ifdef HAS_ATTRIBUTE_a_${P}\n in ${S} ${C} ${P};\n#endif\n`:"initialize-attribute"===M?"":void 0)),vertexSource:r=r.replace(h,(T,M,S,C,P)=>{const k="float"===C?"vec2":C,R=P.match(/color/)?"color":k;return"define-attribute-vertex-shader-only"===M?`\n#ifdef HAS_ATTRIBUTE_a_${P}\nin ${S} ${C} a_${P};\n#endif\n`:f[P]?"define"===M?`\n#ifndef HAS_UNIFORM_u_${P}\nuniform lowp float u_${P}_t;\nin ${S} ${k} a_${P};\nout ${S} ${C} ${P};\n#else\nuniform ${S} ${C} u_${P};\n#endif\n`:"initialize"===M?"vec4"===R?`\n#ifndef HAS_UNIFORM_u_${P}\n ${P} = a_${P};\n#else\n ${S} ${C} ${P} = u_${P};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${P}\n ${P} = unpack_mix_${R}(a_${P}, u_${P}_t);\n#else\n ${S} ${C} ${P} = u_${P};\n#endif\n`:"define-attribute"===M?`\n#ifdef HAS_ATTRIBUTE_a_${P}\n in ${S} ${C} a_${P};\n out ${S} ${C} ${P};\n#endif\n`:"initialize-attribute"===M?`\n#ifdef HAS_ATTRIBUTE_a_${P}\n ${P} = a_${P};\n#endif\n`:void 0:"define"===M?`\n#ifndef HAS_UNIFORM_u_${P}\nuniform lowp float u_${P}_t;\nin ${S} ${k} a_${P};\n#else\nuniform ${S} ${C} u_${P};\n#endif\n`:"define-instanced"===M?"mat4"===R?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${P}0;\nin vec4 a_${P}1;\nin vec4 a_${P}2;\nin vec4 a_${P}3;\n#else\nuniform ${S} ${C} u_${P};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${S} ${k} a_${P};\n#else\nuniform ${S} ${C} u_${P};\n#endif\n`:"initialize-attribute-custom"===M?`\n#ifdef HAS_ATTRIBUTE_a_${P}\n ${S} ${C} ${P} = a_${P};\n#endif\n`:"vec4"===R?`\n#ifndef HAS_UNIFORM_u_${P}\n ${S} ${C} ${P} = a_${P};\n#else\n ${S} ${C} ${P} = u_${P};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${P}\n ${S} ${C} ${P} = unpack_mix_${R}(a_${P}, u_${P}_t);\n#else\n ${S} ${C} ${P} = u_${P};\n#endif\n`}),staticAttributes:d,usedDefines:b,vertexIncludes:g,fragmentIncludes:x}}class Cc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(r,o,h,d,f,g,x,b){this.context=r;let T=this.boundPaintVertexBuffers.length!==d.length;for(let S=0;!T&&S<d.length;S++)this.boundPaintVertexBuffers[S]!==d[S]&&(T=!0);let M=this.boundDynamicVertexBuffers.length!==x.length;for(let S=0;!M&&S<x.length;S++)this.boundDynamicVertexBuffers[S]!==x[S]&&(M=!0);if(!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==h||T||M||this.boundIndexBuffer!==f||this.boundVertexOffset!==g)this.freshBind(o,h,d,f,g,x,b);else{r.bindVertexArrayOES.set(this.vao);for(const S of x)S&&(S.bind(),b&&S.instanceCount&&S.setVertexAttribDivisor(r.gl,o,b));f&&f.dynamicDraw&&f.bind()}}freshBind(r,o,h,d,f,g,x){const b=r.numAttributes,T=this.context,M=T.gl;this.vao&&this.destroy(),this.vao=T.gl.createVertexArray(),T.bindVertexArrayOES.set(this.vao),this.boundProgram=r,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffers=g,o.enableAttributes(M,r),o.bind(),o.setVertexAttribPointers(M,r,f);for(const S of h)S.enableAttributes(M,r),S.bind(),S.setVertexAttribPointers(M,r,f);for(const S of g)S&&(S.enableAttributes(M,r),S.bind(),S.setVertexAttribPointers(M,r,f),x&&S.instanceCount&&S.setVertexAttribDivisor(M,r,x));d&&d.bind(),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function tp(c,r){const o=Math.pow(2,r.canonical.z),h=r.canonical.y;return[new a.L(0,h/o).toLngLat().lat,new a.L(0,(h+1)/o).toLngLat().lat]}function ll(c,r,o,h,d,f,g){const x=c.context,b=x.gl,T=o.hillshadeFBO;if(!T)return;c.prepareDrawTile();const M=c.isTileAffectedByFog(r),S=c.getOrCreateProgram("hillshade",{overrideFog:M});x.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,T.colorAttachment.get());const C=((O,D,F,Z)=>{const V=F.paint.get("hillshade-shadow-color"),q=F.paint.get("hillshade-highlight-color"),B=F.paint.get("hillshade-accent-color"),$=F.paint.get("hillshade-emissive-strength");let Y=a.bj(F.paint.get("hillshade-illumination-direction"));if("viewport"===F.paint.get("hillshade-illumination-anchor"))Y-=O.transform.angle;else if(O.style&&O.style.enable3dLights()&&O.style.directionalLight){const ee=O.style.directionalLight.properties.get("direction"),ce=a.bQ(ee.x,ee.y,ee.z);Y=a.bj(ce[1])}const K=!O.options.moving;return{u_matrix:Z||O.transform.calculateProjMatrix(D.tileID.toUnwrapped(),K),u_image:0,u_latrange:tp(0,D.tileID),u_light:[F.paint.get("hillshade-exaggeration"),Y],u_shadow:V,u_highlight:q,u_emissive_strength:$,u_accent:B}})(c,o,h,c.terrain?r.projMatrix:null);c.uploadCommonUniforms(x,S,r.toUnwrapped());const{tileBoundsBuffer:P,tileBoundsIndexBuffer:k,tileBoundsSegments:R}=c.getTileBoundsBuffers(o);S.draw(c,b.TRIANGLES,d,f,g,pt.disabled,C,h.id,P,k,R)}function uu(c,r,o){if(!r.needsDEMTextureUpload)return;const h=c.context,d=h.gl;h.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||c.getTileTexture(o.stride);const f=o.getPixels();r.demTexture?r.demTexture.update(f,{premultiply:!1}):r.demTexture=new a.T(h,f,d.R32F,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Pc(c,r,o){const h=c.context,d=h.gl;if(!r.dem)return;const f=r.dem;if(h.activeTexture.set(d.TEXTURE1),uu(c,r,f),!r.demTexture)return;r.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const g=f.dim;h.activeTexture.set(d.TEXTURE0);let x=r.hillshadeFBO;if(!x){const C=new a.T(h,{width:g,height:g,data:null},d.RGBA);C.bind(d.LINEAR,d.CLAMP_TO_EDGE),x=r.hillshadeFBO=h.createFramebuffer(g,g,!0,"renderbuffer"),x.colorAttachment.set(C.texture)}h.bindFramebuffer.set(x.framebuffer),h.viewport.set([0,0,g,g]);const{tileBoundsBuffer:b,tileBoundsIndexBuffer:T,tileBoundsSegments:M}=c.getMercatorTileBoundsBuffers(),S=[];c.linearFloatFilteringSupported()&&S.push("TERRAIN_DEM_FLOAT_FORMAT"),c.getOrCreateProgram("hillshadePrepare",{defines:S}).draw(c,d.TRIANGLES,dt.disabled,yt.disabled,Rt.unblended,pt.disabled,((C,P)=>{const k=P.stride,R=a.a6.create();return a.a6.ortho(R,0,a.V,-a.V,0,0,1),a.a6.translate(R,R,[0,-a.V,0]),{u_matrix:R,u_image:1,u_dimension:[k,k],u_zoom:C.overscaledZ}})(r.tileID,f),o.id,b,T,M),r.needsHillshadePrepare=!1}const du=c=>({u_matrix:new a.bK(c),u_image0:new a.bO(c),u_skirt_height:new a.bN(c),u_ground_shadow_factor:new a.bM(c)}),cl=(c,r,o)=>({u_matrix:c,u_image0:0,u_skirt_height:r,u_ground_shadow_factor:o}),pu=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R)=>({u_proj_matrix:Float32Array.from(c),u_globe_matrix:r,u_normalize_matrix:Float32Array.from(h),u_merc_matrix:o,u_zoom_transition:d,u_merc_center:f,u_image0:0,u_frustum_tl:g,u_frustum_tr:x,u_frustum_br:b,u_frustum_bl:T,u_globe_pos:M,u_globe_radius:S,u_viewport:C,u_grid_matrix:R?Float32Array.from(R):new Float32Array(9),u_skirt_height:P,u_far_z_cutoff:k});function oa(c,r){return null!=c&&null!=r&&!(!c.hasData()||!r.hasData())&&null!=c.demTexture&&null!=r.demTexture&&c.tileID.key!==r.tileID.key}const vs=new class{constructor(){this.operations={}}newMorphing(c,r,o,h,d){if(c in this.operations){const 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:r,to:o,queued:null}}getMorphValuesForProxy(c){if(!(c in this.operations))return null;const r=this.operations[c];return{from:r.from,to:r.to,phase:r.phase}}update(c){for(const r in this.operations){const o=this.operations[r];for(o.phase=(c-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,c)){delete this.operations[r];break}}}_nextOp(c,r){return!!c.queued&&(c.from=c.to,c.to=c.queued,c.queued=null,c.phase=0,c.startTime=r,!0)}_validOp(c){return c.from.hasData()&&c.to.hasData()}},zc={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Dc(c,r,o){if(0===r)return 0;const h=r<1&&514===o?.25/r:1;return 6*Math.pow(1.5,22-c)*Math.max(r,1)*h}function bs(c,r){const o=1<<c.z;return!r&&(0===c.x||c.x===o-1)||0===c.y||c.y===o-1}const Lc=c=>({u_matrix:c});function Rc(c,r,o,h,d){if(d>0){const f=a.f.now(),g=(f-c.timeAdded)/d,x=r?(f-r.timeAdded)/d:-1,b=o.getSource(),T=h.coveringZoomLevel({tileSize:b.tileSize,roundZoom:b.roundZoom}),M=!r||Math.abs(r.tileID.overscaledZ-T)>Math.abs(c.tileID.overscaledZ-T),S=M&&c.refreshedUponExpiration?1:a.aa(M?g:1-x,0,1);return c.refreshedUponExpiration&&g>=1&&(c.refreshedUponExpiration=!1),r?{opacity:1,mix:1-S}:{opacity:S,mix:0}}return{opacity:1,mix:0}}class ip extends nn{constructor(r){const o={type:"raster-dem",maxzoom:r.transform.maxZoom},h=new a.bW(a.bX(),null),d=Wi("mock-dem",o,h,r.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,o){r.state="loaded",o(null)}}class rp extends nn{constructor(r){const o=Wi("proxy",{type:"geojson",maxzoom:r.transform.maxZoom},new a.bW(a.bX(),null),r.style);super("proxy",o,!1),o.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,o,h){if(r.freezeTileCoverage)return;this.transform=r;const d=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((f,g)=>{if(f[g.key]="",!this._tiles[g.key]){const x=new Jn(g,this._source.tileSize*g.overscaleFactor(),r.tileZoom);x.state="loaded",this._tiles[g.key]=x}return f},{});for(const f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(r){const o=this.proxyCachedFBO[r];if(void 0!==o){const h=Object.values(o);this.renderCachePool.push(...h),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class fu extends a.am{constructor(r,o,h){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=o,this.projMatrix=h}}class np extends a.ck{constructor(r,o){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},r.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),r.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),r.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[h,d,f]=function(){const T=new a.aN,M=new a.aw,S=131;T.reserve(17161),M.reserve(33800);const C=a.V/128,P=a.V+C/2,k=P+C;for(let O=-C;O<k;O+=C)for(let D=-C;D<k;D+=C){const F=D<0||D>P||O<0||O>P?24575:0,Z=a.aa(Math.round(D),0,a.V),V=a.aa(Math.round(O),0,a.V);T.emplaceBack(Z+F,V)}const R=(O,D)=>{const F=D*S+O;M.emplaceBack(F+1,F,F+S),M.emplaceBack(F+S,F+S+1,F+1)};for(let O=1;O<129;O++)for(let D=1;D<129;D++)R(D,O);return[0,129].forEach(O=>{for(let D=0;D<130;D++)R(D,O),R(O,D)}),[T,M,32768]}(),g=r.context;this.gridBuffer=g.createVertexBuffer(h,a.aP.members),this.gridIndexBuffer=g.createIndexBuffer(d),this.gridSegments=a.aB.simpleSegment(0,0,h.length,d.length),this.gridNoSkirtSegments=a.aB.simpleSegment(0,0,h.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new rp(o.map),this.orthoMatrix=a.a6.create(),a.a6.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,a.V,0,a.V,0,1);const x=g.gl;this._overlapStencilMode=new yt({func:x.GEQUAL,mask:255},0,255,x.KEEP,x.KEEP,x.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new ip(o.map),this._pendingGroundEffectLayers=[]}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),this._style=r,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(r,o,h){if(r&&r.terrain){this._style!==r&&(this.style=r,this._evaluationZoom=void 0);const d=r.terrain.properties,f=0===r.terrain.drapeRenderMode,g=r.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=a.f.now();const x=r.terrain&&r.terrain.scope,b=d.get("source"),T=f?this._mockSourceCache:r.getSourceCache(b,x);if(!T)return void a.w(`Couldn't find terrain source "${b}".`);if(this.sourceCache=T,this._exaggeration=g?this.calculateExaggeration(o):d.get("exaggeration"),!o.projection.requiresDraping&&g&&0===this._exaggeration)return void this._disable();this.enabled=!0;const M=()=>{this.sourceCache.used&&a.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const S=this.getScaledDemTileSize();this.sourceCache.update(o,S,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,M(),this._initializing=!0),M(),o.updateElevation(!0,h),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0,this._previousZoom=o.zoom}else this._disable()}calculateExaggeration(r){const o=this._previousCameraAltitude,h=r.getFreeCameraOptions().position.z/r.pixelsPerMeter*r.worldSize;this._previousCameraAltitude=h;const d=null!=o?h-o:Number.MAX_VALUE;if(Math.abs(d)<2)return this._exaggeration;const f=r.zoom,g=this._style.terrain;if(!this._previousUpdateTimestamp)return g.getExaggeration(f);let x=f-this._previousZoom;const b=this._previousUpdateTimestamp;let T=f;null!=this._evaluationZoom&&(T=this._evaluationZoom,Math.abs(f-T)>.5&&(x=.5*(f-T+x)),x*d<0&&(T+=x)),this._evaluationZoom=T;const M=g.getExaggeration(T),S=M===g.getExaggeration(Math.max(0,T-.1));if(S&&Math.abs(M-this._exaggeration)<.01)return M;let C=Math.min(.1,.00375*(this._updateTimestamp-b));return(S||M<.1||Math.abs(x)<1e-4)&&(C=Math.min(.2,4*C)),a.U(this._exaggeration,M,C)}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(r){r.coord&&"source"===r.dataType?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):"style"===r.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const r in this._style._mergedSourceCaches)this._style._mergedSourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(r=>r.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const o=this.proxySourceCache,h=this.painter.transform;this._initializing&&(this._initializing=0===h._centerAltitude&&-1===this.getAtPointOrZero(a.L.fromLngLat(h.center),-1),this._emptyDEMTextureDirty=!this._initializing);const d=this.proxyCoords=o.getIds().map(b=>{const T=o.getTileByID(b).tileID;return T.projMatrix=h.calculateProjMatrix(T.toUnwrapped()),T});!function(b,T){const M=T.transform.pointCoordinate(T.transform.getCameraPoint()),S=new a.P(M.x,M.y);b.sort((C,P)=>{if(P.overscaledZ-C.overscaledZ)return P.overscaledZ-C.overscaledZ;const k=new a.P(C.canonical.x+(1<<C.canonical.z)*C.wrap,C.canonical.y),R=new a.P(P.canonical.x+(1<<P.canonical.z)*P.wrap,P.canonical.y),O=S.mult(1<<C.canonical.z);return O.x-=.5,O.y-=.5,O.distSqr(k)-O.distSqr(R)})}(d,this.painter);const f=this.proxyToSource||{};this.proxyToSource={},d.forEach(b=>{this.proxyToSource[b.key]={}}),this.terrainTileForTile={};const g=this._style._mergedSourceCaches;for(const b in g){const T=g[b];if(!T.used||(T!==this.sourceCache&&this.resetTileLookupCache(T.id),this._setupProxiedCoordsForOrtho(T,r[b],f),T.usedForTerrain))continue;const M=r[b];T.getSource().reparseOverscaled&&this._assignTerrainTiles(M)}this.proxiedCoords[o.id]=d.map(b=>new fu(b,b.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1;const x={};this._visibleDemTiles=[];for(const b of this.proxyCoords){const T=this.terrainTileForTile[b.key];if(!T)continue;const M=T.tileID.key;M in x||(this._visibleDemTiles.push(T),x[M]=M)}}_assignTerrainTiles(r){this._initializing||r.forEach(o=>{if(this.terrainTileForTile[o.key])return;const h=this._findTileCoveringTileID(o,this.sourceCache);h&&(this.terrainTileForTile[o.key]=h)})}_prepareDEMTextures(){const r=this.painter.context,o=r.gl;for(const h in this.terrainTileForTile){const d=this.terrainTileForTile[h],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(r.activeTexture.set(o.TEXTURE1),uu(this.painter,d,f))}}_prepareDemTileUniforms(r,o,h,d){if(!o||null==o.demTexture)return!1;const f=r.tileID.canonical,g=Math.pow(2,o.tileID.canonical.z-f.z),x=d||"";return h[`u_dem_tl${x}`]=[f.x*g%1,f.y*g%1],h[`u_dem_scale${x}`]=g,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,o=r.gl;if(!this._emptyDepthBufferTexture){const h=new a.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new a.T(r,h,o.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const o=this._visibleDemTiles.reduce((h,d)=>{if(!d.dem)return h;const f=d.dem.tree.minimums[0];return f>0&&r++,h+f},0);return r?o/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,o=r.gl;r.activeTexture.set(o.TEXTURE2);const h=this._getLoadedAreaMinimum(),[d,f]=(()=>{const x=new a.cm({width:1,height:1},new Float32Array([h]));return[o.R32F,x]})();this._emptyDEMTextureDirty=!1;let g=this._emptyDEMTexture;return g?g.update(f,{premultiply:!1}):g=this._emptyDEMTexture=new a.T(r,f,d,{premultiply:!1}),g}setupElevationDraw(r,o,h){const d=this.painter.context,f=d.gl,g={u_dem:2,u_dem_prev:4,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};g.u_exaggeration=this.exaggeration();let x=null,b=null,T=1;if(h&&h.morphing&&this._useVertexMorphing){const C=h.morphing.srcDemTile,P=h.morphing.dstDemTile;T=h.morphing.phase,C&&P&&(this._prepareDemTileUniforms(r,C,g,"_prev")&&(b=C),this._prepareDemTileUniforms(r,P,g)&&(x=P))}const M=C=>C&&C.demTexture&&this.painter.linearFloatFilteringSupported()?f.LINEAR:f.NEAREST,S=C=>{g.u_dem_size=1===C.size[0]?1:C.size[0]-2};if(b&&x)d.activeTexture.set(f.TEXTURE2),x.demTexture.bind(M(x),f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE4),b.demTexture.bind(M(b),f.CLAMP_TO_EDGE),x.demTexture&&S(x.demTexture),g.u_dem_lerp=T;else{x=this.terrainTileForTile[r.tileID.key],d.activeTexture.set(f.TEXTURE2);const C=this._prepareDemTileUniforms(r,x,g)?x.demTexture:this.emptyDEMTexture;C.bind(M(x),f.CLAMP_TO_EDGE),S(C)}if(d.activeTexture.set(f.TEXTURE3),h&&h.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),this._depthFBO&&(g.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.u_depth_size_inv=[1,1]),h&&h.useMeterToDem&&x){const C=(1<<x.tileID.canonical.z)*a.bl(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;g.u_meter_to_dem=C}if(h&&h.labelPlaneMatrixInv&&(g.u_label_plane_matrix_inv=h.labelPlaneMatrixInv),o.setTerrainUniformValues(d,g),"globe"===this.painter.transform.projection.name){const C=this.globeUniformValues(this.painter.transform,r.tileID.canonical,h&&h.useDenormalizedUpVectorScale);o.setGlobeUniformValues(d,C)}}globeUniformValues(r,o,h){const d=r.projection;return{u_tile_tl_up:d.upVector(o,0,0),u_tile_tr_up:d.upVector(o,a.V,0),u_tile_br_up:d.upVector(o,a.V,a.V),u_tile_bl_up:d.upVector(o,0,a.V),u_tile_up_scale:h?a.cl(1):d.upVectorScale(o,r.center.lat,r.worldSize).metersToTile}}renderToBackBuffer(r){const o=this.painter,h=this.painter.context;0!==r.length&&(h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,f,g,x,b){if("globe"===d.transform.projection.name)!function(T,M,S,C,P){const k=T.context,R=k.gl;let O,D;const F=T.transform,Z=a.cd(T,k,F),V=(me,pe)=>{if(D===pe)return;const Ae=[zc[pe],"PROJECTION_GLOBE_VIEW"];Z&&Ae.push("CUSTOM_ANTIALIASING");const ne=T.isTileAffectedByFog(me);O=T.getOrCreateProgram("globeRaster",{defines:Ae,overrideFog:ne}),D=pe},q=T.colorModeForRenderPass(),B=new dt(R.LEQUAL,dt.ReadWrite,T.depthRangeFor3D);vs.update(P);const $=a.ce(F),Y=[a.a5(F.center.lng),a.ae(F.center.lat)],K=T.globeSharedBuffers,ee=[F.width*a.f.devicePixelRatio,F.height*a.f.devicePixelRatio],ce=Float32Array.from(F.globeMatrix),re={useDenormalizedUpVectorScale:!0};{const me=T.transform,pe=Dc(me.zoom,M.exaggeration(),M.sourceCache._source.tileSize);D=-1;const Ae=R.TRIANGLES;for(const ne of C){const ue=S.getTile(ne),Q=yt.disabled,ae=M.prevTerrainTileForTile[ne.key],Ie=M.terrainTileForTile[ne.key];oa(ae,Ie)&&vs.newMorphing(ne.key,ae,Ie,P,250),k.activeTexture.set(R.TEXTURE0),ue.texture&&ue.texture.bind(R.LINEAR,R.CLAMP_TO_EDGE);const Re=vs.getMorphValuesForProxy(ne.key),Le=Re?1:0;Re&&a.j(re,{morphing:{srcDemTile:Re.from,dstDemTile:Re.to,phase:a.cc(Re.phase)}});const je=a.cf(ne.canonical),et=a.cg(je.getCenter().lat),ct=a.ch(ne.canonical,je,et,me.worldSize/me._pixelsPerMercatorPixel),nt=a.aT(a.ci(ne.canonical)),at=pu(me.expandedFarZProjMatrix,ce,$,nt,a.S(me.zoom),Y,me.frustumCorners.TL,me.frustumCorners.TR,me.frustumCorners.BR,me.frustumCorners.BL,me.globeCenterInViewSpace,me.globeRadius,ee,pe,me._farZ,ct);if(V(ne,Le),O&&(M.setupElevationDraw(ue,O,re),T.uploadCommonUniforms(k,O,ne.toUnwrapped()),K)){const[Et,gt,bt]=K.getGridBuffers(et,0!==pe);O.draw(T,Ae,B,Q,q,pt.backCCW,at,"globe_raster",Et,gt,bt)}}}if(K&&(T.renderDefaultNorthPole||T.renderDefaultSouthPole)){const me=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Z&&me.push("CUSTOM_ANTIALIASING"),O=T.getOrCreateProgram("globeRaster",{defines:me});for(const pe of C){const{x:Ae,y:ne,z:ue}=pe.canonical,Q=0===ne,ae=ne===(1<<ue)-1,[Ie,Re,Le,je]=K.getPoleBuffers(ue,!1);if(je&&(Q||ae)){const et=S.getTile(pe);k.activeTexture.set(R.TEXTURE0),et.texture&&et.texture.bind(R.LINEAR,R.CLAMP_TO_EDGE);let ct=a.cj(ue,Ae,F);const nt=a.aT(a.ci(pe.canonical)),at=(Et,gt)=>Et.draw(T,R.TRIANGLES,B,yt.disabled,q,pt.disabled,pu(F.expandedFarZProjMatrix,ct,ct,nt,0,Y,F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.globeCenterInViewSpace,F.globeRadius,ee,0,F._farZ),"globe_pole_raster",gt,Le,je);M.setupElevationDraw(et,O,re),T.uploadCommonUniforms(k,O,pe.toUnwrapped()),Q&&T.renderDefaultNorthPole&&at(O,Ie),ae&&T.renderDefaultSouthPole&&(ct=a.a6.scale(a.a6.create(),ct,[1,-1,1]),at(O,Re))}}}}(d,f,g,x,b);else{const T=d.context,M=T.gl;let S,C;const P=d.shadowRenderer,k=no(d,d.longestCutoffRange),R=q=>{if(C===q)return;const B=[];B.push(zc[q]),k.shouldRenderCutoff&&B.push("RENDER_CUTOFF"),S=d.getOrCreateProgram("terrainRaster",{defines:B}),C=q},O=d.colorModeForRenderPass(),D=new dt(M.LEQUAL,dt.ReadWrite,d.depthRangeFor3D);vs.update(b);const F=d.transform,Z=Dc(F.zoom,f.exaggeration(),f.sourceCache._source.tileSize);let V=[0,0,0];if(P){const q=d.style.directionalLight,B=d.style.ambientLight;q&&B&&(V=ra(q,B))}{C=-1;const q=M.TRIANGLES,[B,$]=[f.gridIndexBuffer,f.gridSegments];for(const Y of x){const K=g.getTile(Y),ee=yt.disabled,ce=f.prevTerrainTileForTile[Y.key],re=f.terrainTileForTile[Y.key];oa(ce,re)&&vs.newMorphing(Y.key,ce,re,b,250),T.activeTexture.set(M.TEXTURE0),K.texture&&K.texture.bind(M.LINEAR,M.CLAMP_TO_EDGE);const me=vs.getMorphValuesForProxy(Y.key),pe=me?1:0;let Ae;me&&(Ae={morphing:{srcDemTile:me.from,dstDemTile:me.to,phase:a.cc(me.phase)}});const ne=cl(Y.projMatrix,bs(Y.canonical,F.renderWorldCopies)?Z/10:Z,V);if(R(pe),!S)continue;f.setupElevationDraw(K,S,Ae);const ue=Y.toUnwrapped();P&&P.setupShadows(ue,S),d.uploadCommonUniforms(T,S,ue,null,k),S.draw(d,q,D,ee,O,pt.backCCW,ne,"terrain_raster",f.gridBuffer,B,$)}}}}(o,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),r.splice(0,r.length))}renderBatch(r){if(0===this._drapedRenderBatches.length)return r+1;this.renderingToTexture=!0;const o=this.painter,h=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],g=this._drapedRenderBatches.shift(),x=o.style.order,b=[];let T=0;for(const M of f){const S=d.getTileByID(M.proxyTileKey),C=d.proxyCachedFBO[M.key]?d.proxyCachedFBO[M.key][r]:void 0,P=void 0!==C?d.renderCache[C]:this.pool[T++],k=void 0!==C;if(S.texture=P.tex,k&&!P.dirty){b.push(S.tileID);continue}let R;h.bindFramebuffer.set(P.fb.framebuffer),this.renderedToTile=!1,P.dirty&&(h.clear({color:a.ax.transparent,stencil:0}),P.dirty=!1);for(let O=g.start;O<=g.end;++O){const D=o.style._mergedLayers[x[O]];if(D.isHidden(o.transform.zoom))continue;const F=o.style.getLayerSourceCache(D),Z=F?this.proxyToSource[M.key][F.id]:[M];if(!Z)continue;const V=Z;h.viewport.set([0,0,P.fb.width,P.fb.height]),R!==(F?F.id:null)&&(this._setupStencil(P,Z,D,F),R=F?F.id:null),o.renderLayer(o,F,D,V)}if(0===this._drapedRenderBatches.length)for(const O of this._pendingGroundEffectLayers){const D=o.style._mergedLayers[x[O]];if(D.isHidden(o.transform.zoom))continue;const F=o.style.getLayerSourceCache(D),Z=F?this.proxyToSource[M.key][F.id]:[M];if(!Z)continue;const V=Z;h.viewport.set([0,0,P.fb.width,P.fb.height]),R!==(F?F.id:null)&&(this._setupStencil(P,Z,D,F),R=F?F.id:null),o.renderLayer(o,F,D,V)}this.renderedToTile?(P.dirty=!0,b.push(S.tileID)):k||--T,5===T&&(T=0,this.renderToBackBuffer(b))}return this.renderToBackBuffer(b),this.renderingToTexture=!1,h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),g.end+1}postRender(){}isLayerOrderingCorrect(r){const o=r.order.length;let h=-1,d=o;for(let f=0;f<o;++f)this._style.isLayerDraped(r._mergedLayers[r.order[f]])?h=Math.max(h,f):d=Math.min(d,f);return d>h}getMinElevationBelowMSL(){let r=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{r=Math.min(r,o.dem.tree.minimums[0])}),0===r?r:(r-30)*this._exaggeration}raycast(r,o,h){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{const g=f.tileID,x=1<<g.overscaledZ,{x:b,y:T}=g.canonical,M=b/x,S=(b+1)/x,C=T/x,P=(T+1)/x;return{minx:M,miny:C,maxx:S,maxy:P,t:f.dem.tree.raycastRoot(M,C,S,P,r,o,h),tile:f}});d.sort((f,g)=>(null!==f.t?f.t:Number.MAX_VALUE)-(null!==g.t?g.t:Number.MAX_VALUE));for(const f of d){if(null==f.t)return null;const g=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,r,o,h);if(null!=g)return g}return null}_createFBO(){const r=this.painter.context,o=r.gl,h=this.drapeBufferSize;r.activeTexture.set(o.TEXTURE0);const d=new a.T(r,{width:h[0],height:h[1],data:null},o.RGBA);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);const f=r.createFramebuffer(h[0],h[1],!0,null);return f.colorAttachment.set(d.texture),f.depthAttachment=new Ar(r,f.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,h[0],h[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.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._debugParams.disableRenderCache||this._style.hasLightTransitions())return!0;for(const r in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[r].hasTransition())return!0;return this._style.order.some(r=>{const o=this._style._mergedLayers[r],h=o.isHidden(this.painter.transform.zoom);return"custom"===o.type?!h&&o.shouldRedrape():!h&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let r=!1;for(const h of this._style.getSources())if(h instanceof Ge){r=!0;break}if(!r)return;const o={};for(let h=0;h<this._style.order.length;++h){const d=this._style._mergedLayers[this._style.order[h]],f=this._style.getLayerSourceCache(d);if(f&&!o[f.id]&&!d.isHidden(this.painter.transform.zoom)&&"line"===d.type&&d.widthExpression()instanceof a.Z){o[f.id]=!0;for(const g of this.proxyCoords){const x=this.proxyToSource[g.key][f.id];if(x)for(const b of x)this._clearRenderCacheForTile(f.id,b)}}}}_clearRasterLayersFromRenderCache(){let r=!1;for(const h in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[h]._source instanceof Ze){r=!0;break}if(!r)return;const o={};for(let h=0;h<this._style.order.length;++h){const d=this._style._mergedLayers[this._style.order[h]],f=this._style.getLayerSourceCache(d);if(!f||o[f.id]||d.isHidden(this.painter.transform.zoom)||"raster"!==d.type)continue;const g=d.paint.get("raster-fade-duration");for(const x of this.proxyCoords){const b=this.proxyToSource[x.key][f.id];if(b)for(const T of b){const M=Rc(f.getTile(T),f.findLoadedParent(T,0),f,this.painter.transform,g);(1!==M.opacity||0!==M.mix)&&this._clearRenderCacheForTile(f.id,T)}}}}_setupDrapedRenderBatches(){const r=this._style.order,o=r.length;if(0===o)return;const h=[];this._pendingGroundEffectLayers=[];let d,f=0,g=this._style._mergedLayers[r[f]];for(;!this._style.isLayerDraped(g)&&g.isHidden(this.painter.transform.zoom)&&++f<o;)g=this._style._mergedLayers[r[f]];for(;f<o;++f){const x=this._style._mergedLayers[r[f]];x.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(x)?void 0===d&&(d=f):("fill-extrusion"===x.type&&this._pendingGroundEffectLayers.push(f),void 0!==d&&(h.push({start:d,end:f-1}),d=void 0)))}if(void 0!==d&&h.push({start:d,end:f-1}),0!==h.length){const x=h[h.length-1];this._pendingGroundEffectLayers.every(b=>b>x.end)||a.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=h}_setupRenderCache(r){const o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){const g=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let x=0;x<g.length;++x){const b=Object.values(g[x]);o.renderCachePool.push(...b)}}return}this._clearRasterLayersFromRenderCache();const h=this.proxyCoords,d=this._tilesDirty;for(let g=h.length-1;g>=0;g--){const x=h[g];if(o.getTileByID(x.key),void 0!==o.proxyCachedFBO[x.key]){const b=r[x.key],T=this.proxyToSource[x.key];let M=0;for(const S in T){const C=T[S],P=b[S];if(!P||P.length!==C.length||C.some((k,R)=>k!==P[R]||d[S]&&d[S].hasOwnProperty(k.key))){M=-1;break}++M}for(const S in o.proxyCachedFBO[x.key])o.renderCache[o.proxyCachedFBO[x.key][S]].dirty=M<0||M!==Object.values(b).length}}const f=[...this._drapedRenderBatches];f.sort((g,x)=>x.end-x.start-(g.end-g.start));for(const g of f)for(const x of h){if(o.proxyCachedFBO[x.key])continue;let b=o.renderCachePool.pop();void 0===b&&o.renderCache.length<50&&(b=o.renderCache.length,o.renderCache.push(this._createFBO())),void 0!==b&&(o.proxyCachedFBO[x.key]={},o.proxyCachedFBO[x.key][g.start]=b,o.renderCache[b].dirty=!0)}this._tilesDirty={}}_setupStencil(r,o,h,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const f=this.painter.context,g=f.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let x;if(h.isTileClipped())x=o.length,this._overlapStencilMode.test={func:g.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o[o.length-1].overscaledZ))return void(this._overlapStencilType=!1);x=1,this._overlapStencilMode.test={func:g.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+x>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=x,this._overlapStencilMode.ref=this._stencilRef,h.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):yt.disabled}_renderTileClippingMasks(r,o){const h=this.painter,d=this.painter.context,f=d.gl;h._tileClippingMaskIDs={},d.setColorMode(Rt.disabled),d.setDepthMode(dt.disabled);const g=h.getOrCreateProgram("clippingMask");for(const x of r){const b=h._tileClippingMaskIDs[x.key]=--o;g.draw(h,f.TRIANGLES,dt.disabled,new yt({func:f.ALWAYS,mask:0},b,255,f.KEEP,f.KEEP,f.REPLACE),Rt.disabled,pt.disabled,Lc(x.projMatrix),"$clipping",h.tileExtentBuffer,h.quadTriangleIndexBuffer,h.tileExtentSegments)}}pointCoordinate(r){const o=this.painter.transform;if(r.x<0||r.x>o.width||r.y<0||r.y>o.height)return null;const h=[r.x,r.y,1,1];a.a7.transformMat4(h,h,o.pixelMatrixInverse),a.a7.scale(h,h,1/h[3]),h[0]/=o.worldSize,h[1]/=o.worldSize;const d=o._camera.position,f=a.bl(1,o.center.lat),g=[d[0],d[1],d[2]/f,0],x=a.N.subtract([],h.slice(0,3),g);a.N.normalize(x,x);const b=this.raycast(g,x,this._exaggeration);return null!==b&&b?(a.N.scaleAndAdd(g,g,x,b),g[3]=g[2],g[2]*=f,g):null}drawDepth(){const r=this.painter,o=r.context,h=this.proxySourceCache,d=Math.ceil(r.width),f=Math.ceil(r.height);if(!this._depthFBO||this._depthFBO.width===d&&this._depthFBO.height===f||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const g=o.gl,x=o.createFramebuffer(d,f,!0,"renderbuffer");o.activeTexture.set(g.TEXTURE0);const b=new a.T(o,{width:d,height:f,data:null},g.RGBA);b.bind(g.NEAREST,g.CLAMP_TO_EDGE),x.colorAttachment.set(b.texture);const T=o.createRenderbuffer(o.gl.DEPTH_COMPONENT16,d,f);x.depthAttachment.set(T),this._depthFBO=x,this._depthTexture=b}o.bindFramebuffer.set(this._depthFBO.framebuffer),o.viewport.set([0,0,d,f]),function(g,x,b,T){if("globe"===g.transform.projection.name)return;const M=g.context,S=M.gl;M.clear({depth:1});const C=g.getOrCreateProgram("terrainDepth"),P=new dt(S.LESS,dt.ReadWrite,g.depthRangeFor3D);for(const k of T){const R=b.getTile(k),O=cl(k.projMatrix,0,[0,0,0]);x.setupElevationDraw(R,C),C.draw(g,S.TRIANGLES,P,yt.disabled,Rt.unblended,pt.backCCW,O,"terrain_depth",x.gridBuffer,x.gridIndexBuffer,x.gridNoSkirtSegments)}}(r,this,h,this.proxyCoords)}_setupProxiedCoordsForOrtho(r,o,h){if(r.getSource()instanceof a.ap)return this._setupProxiedCoordsForImageSource(r,o,h);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords;for(let b=0;b<f.length;b++){const T=f[b],M=this._findTileCoveringTileID(T,r);if(M){const S=this._createProxiedId(T,M,h[T.key]&&h[T.key][r.id]);d.push(S),this.proxyToSource[T.key][r.id]=[S]}}let g=!1;const x=new Set;for(let b=0;b<o.length;b++){const T=r.getTile(o[b]);if(!T||!T.hasData())continue;const M=this._findTileCoveringTileID(T.tileID,this.proxySourceCache);if(M&&M.tileID.canonical.z!==T.tileID.canonical.z){const S=this.proxyToSource[M.tileID.key][r.id],C=this._createProxiedId(M.tileID,T,h[M.tileID.key]&&h[M.tileID.key][r.id]);S?S.splice(S.length-1,0,C):this.proxyToSource[M.tileID.key][r.id]=[C];const P=this.proxyToSource[M.tileID.key][r.id];x.has(P)||x.add(P),d.push(C),g=!0}}if(this._sourceTilesOverlap[r.id]=g,g&&this._debugParams.sortTilesHiZFirst)for(const b of x)b.sort((T,M)=>M.overscaledZ-T.overscaledZ)}_setupProxiedCoordsForImageSource(r,o,h){if(!r.getSource().loaded())return;const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords,g=r.getSource(),x=g.tileID;if(!x)return;const b=new a.P(x.x,x.y)._div(1<<x.z),T=g.coordinates.map(a.L.fromLngLat).reduce((S,C)=>(S.min.x=Math.min(S.min.x,C.x-b.x),S.min.y=Math.min(S.min.y,C.y-b.y),S.max.x=Math.max(S.max.x,C.x-b.x),S.max.y=Math.max(S.max.y,C.y-b.y),S),{min:new a.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),M=(S,C)=>{const P=S.wrap+S.canonical.x/(1<<S.canonical.z),k=S.canonical.y/(1<<S.canonical.z),R=a.V/(1<<S.canonical.z),O=C.wrap+C.canonical.x/(1<<C.canonical.z),D=C.canonical.y/(1<<C.canonical.z);return P+R<O+T.min.x||P>O+T.max.x||k+R<D+T.min.y||k>D+T.max.y};for(let S=0;S<f.length;S++){const C=f[S];for(let P=0;P<o.length;P++){const k=r.getTile(o[P]);if(!k||!k.hasData()||M(C,k.tileID))continue;const R=this._createProxiedId(C,k,h[C.key]&&h[C.key][r.id]),O=this.proxyToSource[C.key][r.id];O?O.push(R):this.proxyToSource[C.key][r.id]=[R],d.push(R)}}}_createProxiedId(r,o,h){let d=this.orthoMatrix;if(h){const f=h.find(g=>g.key===o.tileID.key);if(f)return f}if(o.tileID.key!==r.key){const f=r.canonical.z-o.tileID.canonical.z;let g,x,b;d=a.a6.create();const T=o.tileID.wrap-r.wrap<<r.overscaledZ;f>0?(g=a.V>>f,x=g*((o.tileID.canonical.x<<f)-r.canonical.x+T),b=g*((o.tileID.canonical.y<<f)-r.canonical.y)):(g=a.V<<-f,x=a.V*(o.tileID.canonical.x-(r.canonical.x+T<<-f)),b=a.V*(o.tileID.canonical.y-(r.canonical.y<<-f))),a.a6.ortho(d,0,g,0,g,0,1),a.a6.translate(d,d,[x,b,0])}return new fu(o.tileID,r.key,d)}_findTileCoveringTileID(r,o){let h=o.getTile(r);if(h&&h.hasData())return h;const d=this._findCoveringTileCache[o.id],f=d[r.key];if(h=f?o.getTileByID(f):null,h&&h.hasData()||null===f)return h;let g=h?h.tileID:r,x=g.overscaledZ;const b=o.getSource().minzoom,T=[];if(!f){const S=o.getSource().maxzoom;if(r.canonical.z>=S){const C=r.canonical.z-S;o.getSource().reparseOverscaled?(x=Math.max(r.canonical.z+2,o.transform.tileZoom),g=new a.am(x,r.wrap,S,r.canonical.x>>C,r.canonical.y>>C)):0!==C&&(x=S,g=new a.am(x,r.wrap,S,r.canonical.x>>C,r.canonical.y>>C))}g.key!==r.key&&(T.push(g.key),h=o.getTile(g))}const M=S=>{T.forEach(C=>{d[C]=S}),T.length=0};for(x-=1;x>=b&&(!h||!h.hasData());x--){h&&M(h.tileID.key);const S=g.calculateScaledKey(x);if(h=o.getTileByID(S),h&&h.hasData())break;const C=d[S];if(null===C)break;void 0===C?T.push(S):h=o.getTileByID(C)}return M(h?h.tileID.key:null),h&&h.hasData()?h:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,o){let h=this._tilesDirty[r];h||(h=this._tilesDirty[r]={}),h[o.key]=!0}}function kc(c,r,o){const h=function(x,b,T){const M=a.N.dot(b,x),S=a.N.dot(T,[.2126,.7152,.0722]),C=(k,R,O)=>(1-O)*k+O*R,P=C(1-.3*Math.min(S,1),1,Math.min(M+1,1));return C(.92,1,Math.asin(a.aa(b[2],-1,1))/Math.PI+.5)*P}(c,[0,0,1],r),d=[0,0,0];a.N.scale(d,o.slice(0,3),h);const f=[0,0,0];a.N.scale(f,r.slice(0,3),c[2]);const g=[0,0,0];return a.N.add(g,d,f),a.bU(g)}const Oc=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],mu=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class Bc{static cacheKey(r,o,h,d){let f=`${o}${d?d.cacheKey:""}`;for(const g of h)r.usedDefines.includes(g)&&(f+=`/${g}`);return f}constructor(r,o,h,d,f,g,x){const b=r.gl;this.program=b.createProgram(),this.configuration=d,this.name=o,this.fixedDefines=[...g];const T=d?d.getBinderAttributes():[],M=(h.staticAttributes||[]).concat(T);let S=d?d.defines():[];S=S.concat(g.map(D=>`#define ${D}`));const C="#version 300 es\n";let P=C+S.concat("precision mediump float;",al,Ac.fragmentSource).join("\n");for(const D of h.fragmentIncludes)P+=`\n${Fr[D]}`;P+=`\n${h.fragmentSource}`;let k=C+S.concat("precision highp float;",al,Ac.vertexSource).join("\n");for(const D of h.vertexIncludes)k+=`\n${Fr[D]}`;k+=`\n${h.vertexSource}`;const R=b.createShader(b.FRAGMENT_SHADER);if(b.isContextLost())return void(this.failedToCreate=!0);b.shaderSource(R,P),b.compileShader(R),b.attachShader(this.program,R);const O=b.createShader(b.VERTEX_SHADER);if(b.isContextLost())this.failedToCreate=!0;else{b.shaderSource(O,k),b.compileShader(O),b.attachShader(this.program,O),this.attributes={},this.numAttributes=M.length;for(let D=0;D<this.numAttributes;D++)if(M[D]){const F=M[D].startsWith("a_")?M[D]:`a_${M[D]}`;b.bindAttribLocation(this.program,D,F),this.attributes[F]=D}x&&x.shaderVaryings.length>0&&b.transformFeedbackVaryings(this.program,x.shaderVaryings,x.bufferMode),b.linkProgram(this.program),b.deleteShader(O),b.deleteShader(R),this.fixedUniforms=f(r),this.binderUniforms=d?d.getUniforms(r):[],g.includes("TERRAIN")&&(this.terrainUniforms={u_dem:new a.bO(D=r),u_dem_prev:new a.bO(D),u_dem_tl:new a.bL(D),u_dem_scale:new a.bN(D),u_dem_tl_prev:new a.bL(D),u_dem_scale_prev:new a.bN(D),u_dem_size:new a.bN(D),u_dem_lerp:new a.bN(D),u_exaggeration:new a.bN(D),u_depth:new a.bO(D),u_depth_size_inv:new a.bL(D),u_meter_to_dem:new a.bN(D),u_label_plane_matrix_inv:new a.bK(D)}),g.includes("GLOBE")&&(this.globeUniforms=(D=>({u_tile_tl_up:new a.bM(D),u_tile_tr_up:new a.bM(D),u_tile_br_up:new a.bM(D),u_tile_bl_up:new a.bM(D),u_tile_up_scale:new a.bN(D)}))(r)),g.includes("FOG")&&(this.fogUniforms=(D=>({u_fog_matrix:new a.bK(D),u_fog_range:new a.bL(D),u_fog_color:new a.bP(D),u_fog_horizon_blend:new a.bN(D),u_fog_vertical_limit:new a.bL(D),u_fog_temporal_offset:new a.bN(D),u_frustum_tl:new a.bM(D),u_frustum_tr:new a.bM(D),u_frustum_br:new a.bM(D),u_frustum_bl:new a.bM(D),u_globe_pos:new a.bM(D),u_globe_radius:new a.bN(D),u_globe_transition:new a.bN(D),u_is_globe:new a.bO(D),u_viewport:new a.bL(D)}))(r)),g.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(D=>({u_cutoff_params:new a.bP(D)}))(r)),g.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(D=>({u_lighting_ambient_color:new a.bM(D),u_lighting_directional_dir:new a.bM(D),u_lighting_directional_color:new a.bM(D),u_ground_radiance:new a.bM(D)}))(r)),g.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(D=>({u_light_matrix_0:new a.bK(D),u_light_matrix_1:new a.bK(D),u_fade_range:new a.bL(D),u_shadow_normal_offset:new a.bM(D),u_shadow_intensity:new a.bN(D),u_shadow_texel_size:new a.bN(D),u_shadow_map_resolution:new a.bN(D),u_shadow_direction:new a.bM(D),u_shadow_bias:new a.bM(D),u_shadowmap_0:new a.bO(D),u_shadowmap_1:new a.bO(D)}))(r))}var D}setTerrainUniformValues(r,o){if(!this.terrainUniforms)return;const h=this.terrainUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d]&&h[d].set(this.program,d,o[d])}}setGlobeUniformValues(r,o){if(!this.globeUniforms)return;const h=this.globeUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d]&&h[d].set(this.program,d,o[d])}}setFogUniformValues(r,o){if(!this.fogUniforms)return;const h=this.fogUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d].set(this.program,d,o[d])}}setCutoffUniformValues(r,o){if(!this.cutoffUniforms)return;const h=this.cutoffUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d].set(this.program,d,o[d])}}setLightsUniformValues(r,o){if(!this.lightsUniforms)return;const h=this.lightsUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d].set(this.program,d,o[d])}}setShadowUniformValues(r,o){if(this.failedToCreate||!this.shadowUniforms)return;const h=this.shadowUniforms;r.program.set(this.program);for(const d in o)h[d].set(this.program,d,o[d])}_drawDebugWireframe(r,o,h,d,f,g,x,b,T,M){const S=r.options.wireframe;if(!1===S.terrain&&!1===S.layers2D&&!1===S.layers3D)return;const C=r.context;if(!(S.terrain&&("terrainRaster"===this.name||"globeRaster"===this.name)||!(!S.layers2D||r._terrain&&r._terrain.renderingToTexture)&&Oc.includes(this.name)||S.layers3D&&mu.includes(this.name)))return;const P=C.gl,k=r.wireframeDebugCache.getLinesFromTrianglesBuffer(r.frameCounter,f,C);if(!k)return;const R=[...this.fixedDefines];R.push("DEBUG_WIREFRAME");const O=r.getOrCreateProgram(this.name,{config:this.configuration,defines:R});C.program.set(O.program);const D=(V,q,B)=>{if(q[V]&&B[V])for(const $ in q[V])B[V][$]&&B[V][$].set(B.program,$,q[V][$].current)};T&&T.setUniforms(O.program,C,O.binderUniforms,x,{zoom:b}),D("fixedUniforms",this,O),D("terrainUniforms",this,O),D("globeUniforms",this,O),D("fogUniforms",this,O),D("lightsUniforms",this,O),D("shadowUniforms",this,O),k.bind(),C.setColorMode(new Rt([P.ONE,P.ONE_MINUS_SRC_ALPHA,P.ZERO,P.ONE],a.ax.transparent,[!0,!0,!0,!1])),C.setDepthMode(new dt(o.func===P.LESS?P.LEQUAL:o.func,dt.ReadOnly,o.range)),C.setStencilMode(yt.disabled);const F=3*g.primitiveLength*2,Z=3*g.primitiveOffset*2*2;M&&M>1?P.drawElementsInstanced(P.LINES,F,P.UNSIGNED_SHORT,Z,M):P.drawElements(P.LINES,F,P.UNSIGNED_SHORT,Z),f.bind(),C.program.set(this.program),C.setDepthMode(o),C.setStencilMode(h),C.setColorMode(d)}draw(r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D){const F=r.context,Z=F.gl;if(this.failedToCreate)return;F.program.set(this.program),F.setDepthMode(h),F.setStencilMode(d),F.setColorMode(f),F.setCullFace(g);for(const $ of Object.keys(this.fixedUniforms))this.fixedUniforms[$].set(this.program,$,x[$]);k&&k.setUniforms(this.program,F,this.binderUniforms,C,{zoom:P});const V={[Z.POINTS]:1,[Z.LINES]:2,[Z.TRIANGLES]:3,[Z.LINE_STRIP]:1}[o],q=D&&D.length>0;if(q){for(const $ of D)Z.bindBufferBase(Z.TRANSFORM_FEEDBACK_BUFFER,$.targetIndex,$.buffer.buffer);Z.beginTransformFeedback(o)}const B=O&&O>0?1:void 0;for(const $ of S.get()){const Y=$.vaos||($.vaos={});(Y[b]||(Y[b]=new Cc)).bind(F,this,T,k?k.getPaintVertexBuffers():[],M,$.vertexOffset,R||[],B),O&&O>1?Z.drawElementsInstanced(o,$.primitiveLength*V,Z.UNSIGNED_SHORT,$.primitiveOffset*V*2,O):M?Z.drawElements(o,$.primitiveLength*V,Z.UNSIGNED_SHORT,$.primitiveOffset*V*2):Z.drawArrays(o,$.vertexOffset,$.vertexLength),o===Z.TRIANGLES&&M&&this._drawDebugWireframe(r,h,d,f,M,$,C,P,k,O)}q&&Z.endTransformFeedback()}}function Fc(c,r){const o=Math.pow(2,r.tileID.overscaledZ),h=r.tileSize*Math.pow(2,c.transform.tileZoom)/o,d=h*(r.tileID.canonical.x+r.tileID.wrap*o),f=h*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/a.a3(r,1,c.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}const _u=a.a6.create(),Nc=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R)=>{const O=r.style.light,D=O.properties.get("position"),F=[D.x,D.y,D.z],Z=a.co.create();"viewport"===O.properties.get("anchor")&&(a.co.fromRotation(Z,-r.transform.angle),a.N.transformMat3(F,F,Z));const V=O.properties.get("color"),q=r.transform,B={u_matrix:c,u_lightpos:F,u_lightintensity:O.properties.get("intensity"),u_lightcolor:[V.r,V.g,V.b],u_vertical_gradient:+o,u_opacity:h,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:_u,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:d,u_edge_radius:f,u_flood_light_color:S,u_vertical_scale:C,u_flood_light_intensity:P,u_ground_shadow_factor:k,u_emissive_strength:R};return"globe"===q.projection.name&&(B.u_tile_id=[g.canonical.x,g.canonical.y,1<<g.canonical.z],B.u_zoom_transition=b,B.u_inv_rot_matrix=M,B.u_merc_center=T,B.u_up_dir=q.projection.upVector(new a.bs(0,0,0),T[0]*a.V,T[1]*a.V),B.u_height_lift=x),B},Vc=(c,r,o)=>({u_matrix:c,u_edge_radius:r,u_vertical_scale:o}),Bo=(c,r,o,h,d,f,g,x,b,T,M,S,C,P)=>{const k=Nc(c,r,o,h,d,f,g,b,T,M,S,C,P,1,[0,0,0],0),R={u_height_factor:-Math.pow(2,g.overscaledZ)/x.tileSize/8};return a.e(k,Fc(r,x),R)},ws=(c,r)=>({u_matrix:c,u_emissive_strength:r}),Uc=(c,r,o,h)=>a.e(ws(c,r),Fc(o,h)),Fo=(c,r,o)=>({u_matrix:c,u_world:o,u_emissive_strength:r}),gu=(c,r,o,h,d)=>a.e(Uc(c,r,o,h),{u_world:d}),hl=(c,r,o,h)=>{const d=a.V/o.tileSize;return{u_matrix:c,u_camera_to_center_distance:r.getCameraToCenterDistance(h),u_extrude_scale:[r.pixelsToGLUnits[0]/d,r.pixelsToGLUnits[1]/d]}},jc=(c,r,o=1)=>({u_matrix:c,u_color:r,u_overlay:0,u_overlay_scale:o}),yu=a.a6.create(),Gc=(c,r,o,h,d,f,g)=>{const x=c.transform,b="globe"===x.projection.name,T=b?a.cp(x.zoom,r.canonical)*x._pixelsPerMercatorPixel:a.a3(o,1,f),M={u_matrix:r.projMatrix,u_extrude_scale:T,u_intensity:g,u_inv_rot_matrix:yu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(b){M.u_inv_rot_matrix=h,M.u_merc_center=d,M.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],M.u_zoom_transition=a.S(x.zoom);const S=d[0]*a.V,C=d[1]*a.V;M.u_up_dir=x.projection.upVector(new a.bs(0,0,0),S,C)}return M};function ul(c,[r,o,h,d],[f,g]){if(f===g)return[0,0,0,0];const x=255*(c-1)/(c*(g-f));return[r*x,o*x,h*x,d*x]}function xu(c,r,[o,h]){return o===h?0:.5/c+(r-o)*(c-1)/(c*(h-o))}const Zc=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D,F,Z,V)=>{return{u_matrix:c,u_normalize_matrix:r,u_globe_matrix:o,u_merc_matrix:h,u_grid_matrix:d,u_tl_parent:f,u_scale_parent:T,u_fade_t:M.mix,u_opacity:M.opacity*S.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:S.paint.get("raster-brightness-min"),u_brightness_high:S.paint.get("raster-brightness-max"),u_saturation_factor:(B=S.paint.get("raster-saturation"),B>0?1-1/(1.001-B):-B),u_contrast_factor:(q=S.paint.get("raster-contrast"),q>0?1/(1-q):1+q),u_spin_weights:sa(S.paint.get("raster-hue-rotate")),u_perspective_transform:C,u_raster_elevation:P,u_zoom_transition:g,u_merc_center:x,u_cutoff_params:b,u_colorization_mix:ul(a.cq,R,D),u_colorization_offset:xu(a.cq,O,D),u_color_ramp:k,u_texture_offset:[Z/(F+2*Z),F/(F+2*Z)],u_texture_res:[F+2*Z,F+2*Z],u_emissive_strength:V};var q,B};function sa(c){c*=Math.PI/180;const r=Math.sin(c),o=Math.cos(c);return[(2*o+1)/3,(-Math.sqrt(3)*r-o+1)/3,(Math.sqrt(3)*r-o+1)/3]}const op=(c,r,o,h,d,f,g,x,b,T,M,S)=>({u_matrix:c,u_normalize_matrix:r,u_globe_matrix:o,u_merc_matrix:h,u_grid_matrix:d,u_tl_parent:f,u_scale_parent:T,u_fade_t:M.mix,u_opacity:M.opacity,u_image0:0,u_image1:1,u_raster_elevation:S,u_zoom_transition:g,u_merc_center:x,u_cutoff_params:b}),sp=(c,r,o,h,d,f,g,x)=>({u_tile_offset:c,u_velocity:r,u_color_ramp:h,u_velocity_res:o,u_max_speed:d,u_texture_offset:f,u_data_scale:g,u_data_offset:x}),vu=(c,r,o,h,d,f,g,x)=>({u_velocity:c,u_velocity_res:r,u_max_speed:o,u_speed_factor:h,u_lifetime_delta:d,u_rand_seed:Math.random(),u_texture_offset:f,u_data_scale:g,u_data_offset:x}),bu=a.a6.create(),dl=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D)=>{const F=d.transform,Z={u_is_size_zoom_constant:+("constant"===c||"source"===c),u_is_size_feature_constant:+("constant"===c||"camera"===c),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:F.getCameraToCenterDistance(R),u_rotate_symbol:+o,u_aspect_ratio:F.width/F.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:g,u_coord_matrix:x,u_is_text:+b,u_pitch_with_map:+h,u_texsize:T,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:bu,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:bu,u_up_vector:[0,-1,0],u_icon_transition:D||0,u_icon_saturation:O};return"globe"===R.name&&(Z.u_tile_id=[M.canonical.x,M.canonical.y,1<<M.canonical.z],Z.u_zoom_transition=S,Z.u_inv_rot_matrix=P,Z.u_merc_center=C,Z.u_camera_forward=F._camera.forward(),Z.u_ecef_origin=a.cr(F.globeMatrix,M.toUnwrapped()),Z.u_tile_matrix=Float32Array.from(F.globeMatrix),Z.u_up_vector=k),Z},aa=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O)=>a.e(dl(c,r,o,h,d,f,g,x,b,T,S,C,P,k,R,O,1),{u_gamma_scale:h?d.transform.getCameraToCenterDistance(O)*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:a.f.devicePixelRatio,u_is_halo:+M,undefined:void 0}),pl=(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R)=>a.e(aa(c,r,o,h,d,f,g,x,!0,b,!0,M,S,C,P,k,R),{u_texsize_icon:T,u_texture_icon:1}),qc=(c,r,o,h)=>({u_matrix:c,u_emissive_strength:r,u_opacity:o,u_color:h}),la=(c,r,o,h,d,f,g)=>a.e(function(x,b,T,M){const S=T.imageManager.getPattern(x.toString(),b),{width:C,height:P}=T.imageManager.getPixelSize(b),k=Math.pow(2,M.tileID.overscaledZ),R=M.tileSize*Math.pow(2,T.transform.tileZoom)/k,O=R*(M.tileID.canonical.x+M.tileID.wrap*k),D=R*M.tileID.canonical.y;return{u_image:0,u_pattern_tl:S.tl,u_pattern_br:S.br,u_texsize:[C,P],u_pattern_size:S.displaySize,u_tile_units_to_pixels:1/a.a3(M,1,T.transform.tileZoom),u_pixel_coord_upper:[O>>16,D>>16],u_pixel_coord_lower:[65535&O,65535&D]}}(d,f,h,g),{u_matrix:c,u_emissive_strength:r,u_opacity:o}),fl=(c,r,o,h,d,f,g,x,b,T,M,S,C=[0,0,0],P)=>{const k=h.style.light,R=k.properties.get("position"),O=[-R.x,-R.y,R.z],D=a.co.create();"viewport"===k.properties.get("anchor")&&(a.co.fromRotation(D,-h.transform.angle),a.N.transformMat3(O,O,D));const F="MASK"===T.alphaMode,Z=k.properties.get("color"),V=S.paint.get("model-ambient-occlusion-intensity"),q=S.paint.get("model-color").constantOr(a.ax.white),B=S.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:c,u_lighting_matrix:r,u_normal_matrix:o,u_lightpos:O,u_lightintensity:k.properties.get("intensity"),u_lightcolor:[Z.r,Z.g,Z.b],u_camera_pos:C,u_opacity:d,u_baseTextureIsAlpha:0,u_alphaMask:+F,u_alphaCutoff:T.alphaCutoff,u_baseColorFactor:[f.r,f.g,f.b,f.a],u_emissiveFactor:[g[0],g[1],g[2],1],u_metallicFactor:x,u_roughnessFactor:b,u_baseColorTexture:cr_BaseColor,u_metallicRoughnessTexture:cr_MetallicRoughness,u_normalTexture:cr_Normal,u_occlusionTexture:cr_Occlusion,u_emissionTexture:cr_Emission,u_color_mix:[q.r,q.g,q.b,B],u_aoIntensity:V,u_emissive_strength:M,u_occlusionTextureTransform:P||[0,0,0,0]}},ca=new Float32Array(16),ha=(c,r=ca,o=ca)=>({u_matrix:c,u_instance:r,u_node_matrix:o}),ap={fillExtrusion:c=>({u_matrix:new a.bK(c),u_lightpos:new a.bM(c),u_lightintensity:new a.bN(c),u_lightcolor:new a.bM(c),u_vertical_gradient:new a.bN(c),u_opacity:new a.bN(c),u_edge_radius:new a.bN(c),u_ao:new a.bL(c),u_tile_id:new a.bM(c),u_zoom_transition:new a.bN(c),u_inv_rot_matrix:new a.bK(c),u_merc_center:new a.bL(c),u_up_dir:new a.bM(c),u_height_lift:new a.bN(c),u_flood_light_color:new a.bM(c),u_vertical_scale:new a.bN(c),u_flood_light_intensity:new a.bN(c),u_ground_shadow_factor:new a.bM(c),u_emissive_strength:new a.bN(c)}),fillExtrusionDepth:c=>({u_matrix:new a.bK(c),u_edge_radius:new a.bN(c),u_vertical_scale:new a.bN(c)}),fillExtrusionPattern:c=>({u_matrix:new a.bK(c),u_lightpos:new a.bM(c),u_lightintensity:new a.bN(c),u_lightcolor:new a.bM(c),u_vertical_gradient:new a.bN(c),u_height_factor:new a.bN(c),u_edge_radius:new a.bN(c),u_ao:new a.bL(c),u_tile_id:new a.bM(c),u_zoom_transition:new a.bN(c),u_inv_rot_matrix:new a.bK(c),u_merc_center:new a.bL(c),u_up_dir:new a.bM(c),u_height_lift:new a.bN(c),u_image:new a.bO(c),u_texsize:new a.bL(c),u_pixel_coord_upper:new a.bL(c),u_pixel_coord_lower:new a.bL(c),u_tile_units_to_pixels:new a.bN(c),u_opacity:new a.bN(c)}),fillExtrusionGroundEffect:c=>({u_matrix:new a.bK(c),u_opacity:new a.bN(c),u_ao_pass:new a.bN(c),u_meter_to_tile:new a.bN(c),u_ao:new a.bL(c),u_flood_light_intensity:new a.bN(c),u_flood_light_color:new a.bM(c),u_attenuation:new a.bN(c),u_edge_radius:new a.bN(c),u_fb:new a.bO(c),u_fb_size:new a.bN(c)}),fill:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c)}),fillPattern:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c),u_image:new a.bO(c),u_texsize:new a.bL(c),u_pixel_coord_upper:new a.bL(c),u_pixel_coord_lower:new a.bL(c),u_tile_units_to_pixels:new a.bN(c)}),fillOutline:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c),u_world:new a.bL(c)}),fillOutlinePattern:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c),u_world:new a.bL(c),u_image:new a.bO(c),u_texsize:new a.bL(c),u_pixel_coord_upper:new a.bL(c),u_pixel_coord_lower:new a.bL(c),u_tile_units_to_pixels:new a.bN(c)}),circle:a.cs,collisionBox:c=>({u_matrix:new a.bK(c),u_camera_to_center_distance:new a.bN(c),u_extrude_scale:new a.bL(c)}),collisionCircle:c=>({u_matrix:new a.bK(c),u_inv_matrix:new a.bK(c),u_camera_to_center_distance:new a.bN(c),u_viewport_size:new a.bL(c)}),debug:c=>({u_color:new a.ca(c),u_matrix:new a.bK(c),u_overlay:new a.bO(c),u_overlay_scale:new a.bN(c)}),clippingMask:c=>({u_matrix:new a.bK(c)}),heatmap:c=>({u_extrude_scale:new a.bN(c),u_intensity:new a.bN(c),u_matrix:new a.bK(c),u_inv_rot_matrix:new a.bK(c),u_merc_center:new a.bL(c),u_tile_id:new a.bM(c),u_zoom_transition:new a.bN(c),u_up_dir:new a.bM(c)}),heatmapTexture:c=>({u_image:new a.bO(c),u_color_ramp:new a.bO(c),u_opacity:new a.bN(c)}),hillshade:c=>({u_matrix:new a.bK(c),u_image:new a.bO(c),u_latrange:new a.bL(c),u_light:new a.bL(c),u_shadow:new a.ca(c),u_highlight:new a.ca(c),u_emissive_strength:new a.bN(c),u_accent:new a.ca(c)}),hillshadePrepare:c=>({u_matrix:new a.bK(c),u_image:new a.bO(c),u_dimension:new a.bL(c),u_zoom:new a.bN(c)}),line:a.ct,linePattern:a.cu,raster:c=>({u_matrix:new a.bK(c),u_normalize_matrix:new a.bK(c),u_globe_matrix:new a.bK(c),u_merc_matrix:new a.bK(c),u_grid_matrix:new a.cb(c),u_tl_parent:new a.bL(c),u_scale_parent:new a.bN(c),u_fade_t:new a.bN(c),u_opacity:new a.bN(c),u_image0:new a.bO(c),u_image1:new a.bO(c),u_brightness_low:new a.bN(c),u_brightness_high:new a.bN(c),u_saturation_factor:new a.bN(c),u_contrast_factor:new a.bN(c),u_spin_weights:new a.bM(c),u_perspective_transform:new a.bL(c),u_raster_elevation:new a.bN(c),u_zoom_transition:new a.bN(c),u_merc_center:new a.bL(c),u_cutoff_params:new a.bP(c),u_colorization_mix:new a.bP(c),u_colorization_offset:new a.bN(c),u_color_ramp:new a.bO(c),u_texture_offset:new a.bL(c),u_texture_res:new a.bL(c),u_emissive_strength:new a.bN(c)}),rasterParticle:c=>({u_matrix:new a.bK(c),u_normalize_matrix:new a.bK(c),u_globe_matrix:new a.bK(c),u_merc_matrix:new a.bK(c),u_grid_matrix:new a.cb(c),u_tl_parent:new a.bL(c),u_scale_parent:new a.bN(c),u_fade_t:new a.bN(c),u_opacity:new a.bN(c),u_image0:new a.bO(c),u_image1:new a.bO(c),u_raster_elevation:new a.bN(c),u_zoom_transition:new a.bN(c),u_merc_center:new a.bL(c),u_cutoff_params:new a.bP(c)}),rasterParticleTexture:c=>({u_texture:new a.bO(c),u_opacity:new a.bN(c)}),rasterParticleDraw:c=>({u_tile_offset:new a.bL(c),u_velocity:new a.bO(c),u_color_ramp:new a.bO(c),u_velocity_res:new a.bL(c),u_max_speed:new a.bN(c),u_texture_offset:new a.bL(c),u_data_scale:new a.bP(c),u_data_offset:new a.bN(c)}),rasterParticleUpdate:c=>({u_velocity:new a.bO(c),u_velocity_res:new a.bL(c),u_max_speed:new a.bN(c),u_speed_factor:new a.bN(c),u_lifetime_delta:new a.bN(c),u_rand_seed:new a.bN(c),u_texture_offset:new a.bL(c),u_data_scale:new a.bP(c),u_data_offset:new a.bN(c)}),symbolIcon:c=>({u_is_size_zoom_constant:new a.bO(c),u_is_size_feature_constant:new a.bO(c),u_size_t:new a.bN(c),u_size:new a.bN(c),u_camera_to_center_distance:new a.bN(c),u_rotate_symbol:new a.bO(c),u_aspect_ratio:new a.bN(c),u_fade_change:new a.bN(c),u_matrix:new a.bK(c),u_label_plane_matrix:new a.bK(c),u_coord_matrix:new a.bK(c),u_is_text:new a.bO(c),u_pitch_with_map:new a.bO(c),u_texsize:new a.bL(c),u_tile_id:new a.bM(c),u_zoom_transition:new a.bN(c),u_inv_rot_matrix:new a.bK(c),u_merc_center:new a.bL(c),u_camera_forward:new a.bM(c),u_tile_matrix:new a.bK(c),u_up_vector:new a.bM(c),u_ecef_origin:new a.bM(c),u_texture:new a.bO(c),u_icon_transition:new a.bN(c),u_icon_saturation:new a.bN(c)}),symbolSDF:c=>({u_is_size_zoom_constant:new a.bO(c),u_is_size_feature_constant:new a.bO(c),u_size_t:new a.bN(c),u_size:new a.bN(c),u_camera_to_center_distance:new a.bN(c),u_rotate_symbol:new a.bO(c),u_aspect_ratio:new a.bN(c),u_fade_change:new a.bN(c),u_matrix:new a.bK(c),u_label_plane_matrix:new a.bK(c),u_coord_matrix:new a.bK(c),u_is_text:new a.bO(c),u_pitch_with_map:new a.bO(c),u_texsize:new a.bL(c),u_texture:new a.bO(c),u_gamma_scale:new a.bN(c),u_device_pixel_ratio:new a.bN(c),u_tile_id:new a.bM(c),u_zoom_transition:new a.bN(c),u_inv_rot_matrix:new a.bK(c),u_merc_center:new a.bL(c),u_camera_forward:new a.bM(c),u_tile_matrix:new a.bK(c),u_up_vector:new a.bM(c),u_ecef_origin:new a.bM(c),u_is_halo:new a.bO(c)}),symbolTextAndIcon:c=>({u_is_size_zoom_constant:new a.bO(c),u_is_size_feature_constant:new a.bO(c),u_size_t:new a.bN(c),u_size:new a.bN(c),u_camera_to_center_distance:new a.bN(c),u_rotate_symbol:new a.bO(c),u_aspect_ratio:new a.bN(c),u_fade_change:new a.bN(c),u_matrix:new a.bK(c),u_label_plane_matrix:new a.bK(c),u_coord_matrix:new a.bK(c),u_is_text:new a.bO(c),u_pitch_with_map:new a.bO(c),u_texsize:new a.bL(c),u_texsize_icon:new a.bL(c),u_texture:new a.bO(c),u_texture_icon:new a.bO(c),u_gamma_scale:new a.bN(c),u_device_pixel_ratio:new a.bN(c),u_is_halo:new a.bO(c)}),background:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c),u_opacity:new a.bN(c),u_color:new a.ca(c)}),backgroundPattern:c=>({u_matrix:new a.bK(c),u_emissive_strength:new a.bN(c),u_opacity:new a.bN(c),u_image:new a.bO(c),u_pattern_tl:new a.bL(c),u_pattern_br:new a.bL(c),u_texsize:new a.bL(c),u_pattern_size:new a.bL(c),u_pixel_coord_upper:new a.bL(c),u_pixel_coord_lower:new a.bL(c),u_tile_units_to_pixels:new a.bN(c)}),terrainRaster:du,terrainDepth:du,skybox:c=>({u_matrix:new a.bK(c),u_sun_direction:new a.bM(c),u_cubemap:new a.bO(c),u_opacity:new a.bN(c),u_temporal_offset:new a.bN(c)}),skyboxGradient:c=>({u_matrix:new a.bK(c),u_color_ramp:new a.bO(c),u_center_direction:new a.bM(c),u_radius:new a.bN(c),u_opacity:new a.bN(c),u_temporal_offset:new a.bN(c)}),skyboxCapture:c=>({u_matrix_3f:new a.cb(c),u_sun_direction:new a.bM(c),u_sun_intensity:new a.bN(c),u_color_tint_r:new a.bP(c),u_color_tint_m:new a.bP(c),u_luminance:new a.bN(c)}),globeRaster:c=>({u_proj_matrix:new a.bK(c),u_globe_matrix:new a.bK(c),u_normalize_matrix:new a.bK(c),u_merc_matrix:new a.bK(c),u_zoom_transition:new a.bN(c),u_merc_center:new a.bL(c),u_image0:new a.bO(c),u_grid_matrix:new a.cb(c),u_skirt_height:new a.bN(c),u_far_z_cutoff:new a.bN(c),u_frustum_tl:new a.bM(c),u_frustum_tr:new a.bM(c),u_frustum_br:new a.bM(c),u_frustum_bl:new a.bM(c),u_globe_pos:new a.bM(c),u_globe_radius:new a.bN(c),u_viewport:new a.bL(c)}),globeAtmosphere:c=>({u_frustum_tl:new a.bM(c),u_frustum_tr:new a.bM(c),u_frustum_br:new a.bM(c),u_frustum_bl:new a.bM(c),u_horizon:new a.bN(c),u_transition:new a.bN(c),u_fadeout_range:new a.bN(c),u_color:new a.bP(c),u_high_color:new a.bP(c),u_space_color:new a.bP(c),u_temporal_offset:new a.bN(c),u_horizon_angle:new a.bN(c)}),model:c=>({u_matrix:new a.bK(c),u_lighting_matrix:new a.bK(c),u_normal_matrix:new a.bK(c),u_lightpos:new a.bM(c),u_lightintensity:new a.bN(c),u_lightcolor:new a.bM(c),u_camera_pos:new a.bM(c),u_opacity:new a.bN(c),u_baseColorFactor:new a.bP(c),u_emissiveFactor:new a.bP(c),u_metallicFactor:new a.bN(c),u_roughnessFactor:new a.bN(c),u_baseTextureIsAlpha:new a.bO(c),u_alphaMask:new a.bO(c),u_alphaCutoff:new a.bN(c),u_baseColorTexture:new a.bO(c),u_metallicRoughnessTexture:new a.bO(c),u_normalTexture:new a.bO(c),u_occlusionTexture:new a.bO(c),u_emissionTexture:new a.bO(c),u_color_mix:new a.bP(c),u_aoIntensity:new a.bN(c),u_emissive_strength:new a.bN(c),u_occlusionTextureTransform:new a.bP(c)}),modelDepth:c=>({u_matrix:new a.bK(c),u_instance:new a.bK(c),u_node_matrix:new a.bK(c)}),groundShadow:c=>({u_matrix:new a.bK(c),u_ground_shadow_factor:new a.bM(c)}),stars:c=>({u_matrix:new a.bK(c),u_up:new a.bM(c),u_right:new a.bM(c),u_intensity_multiplier:new a.bN(c)})};let an;function ln(c,r,o,h,d,f,g){const x=c.context,b=x.gl,T=c.transform,M=c.getOrCreateProgram("collisionBox"),S=[];let C=0,P=0;for(let V=0;V<h.length;V++){const q=h[V],B=r.getTile(q),$=B.getBucket(o);if(!$)continue;const Y=dc(q,$,T);let K=Y;0===d[0]&&0===d[1]||(K=c.translatePosMatrix(Y,B,d,f));const ee=g?$.textCollisionBox:$.iconCollisionBox,ce=$.collisionCircleArray;if(ce.length>0){const re=a.a6.create(),me=K;a.a6.mul(re,$.placementInvProjMatrix,T.glCoordMatrix),a.a6.mul(re,re,$.placementViewportMatrix),S.push({circleArray:ce,circleOffset:P,transform:me,invTransform:re,projection:$.getProjection()}),C+=ce.length/4,P=C}ee&&(c.terrain&&c.terrain.setupElevationDraw(B,M),M.draw(c,b.LINES,dt.disabled,yt.disabled,c.colorModeForRenderPass(),pt.disabled,hl(K,T,B,$.getProjection()),o.id,ee.layoutVertexBuffer,ee.indexBuffer,ee.segments,null,T.zoom,null,[ee.collisionVertexBuffer,ee.collisionVertexBufferExt]))}if(!g||!S.length)return;const k=c.getOrCreateProgram("collisionCircle"),R=new a.cv;R.resize(4*C),R._trim();let O=0;for(const V of S)for(let q=0;q<V.circleArray.length/4;q++){const B=4*q,$=V.circleArray[B+0],Y=V.circleArray[B+1],K=V.circleArray[B+2],ee=V.circleArray[B+3];R.emplace(O++,$,Y,K,ee,0),R.emplace(O++,$,Y,K,ee,1),R.emplace(O++,$,Y,K,ee,2),R.emplace(O++,$,Y,K,ee,3)}(!an||an.length<2*C)&&(an=function(V){const q=2*V,B=new a.aw;B.resize(q),B._trim();for(let $=0;$<q;$++){const Y=6*$;B.uint16[Y+0]=4*$+0,B.uint16[Y+1]=4*$+1,B.uint16[Y+2]=4*$+2,B.uint16[Y+3]=4*$+2,B.uint16[Y+4]=4*$+3,B.uint16[Y+5]=4*$+0}return B}(C));const D=x.createIndexBuffer(an,!0),F=x.createVertexBuffer(R,a.cw.members,!0);for(const V of S){const q={u_matrix:V.transform,u_inv_matrix:V.invTransform,u_camera_to_center_distance:(Z=T).getCameraToCenterDistance(V.projection),u_viewport_size:[Z.width,Z.height]};k.draw(c,b.TRIANGLES,dt.disabled,yt.disabled,c.colorModeForRenderPass(),pt.disabled,q,o.id,F,D,a.aB.simpleSegment(0,2*V.circleOffset,V.circleArray.length,V.circleArray.length/2),null,T.zoom)}var Z;F.destroy(),D.destroy()}const Dn=a.a6.create();function ua(c){const r=c._camera.getWorldToCamera(c.worldSize,1),o=a.a6.multiply([],r,c.globeMatrix);a.a6.invert(o,o);const h=[0,0,0],d=[0,1,0,0];return a.a7.transformMat4(d,d,o),h[0]=d[0],h[1]=d[1],h[2]=d[2],a.N.normalize(h,h),h}function Ke({width:c,height:r,anchor:o,textOffset:h,textScale:d},f){const{horizontalAlign:g,verticalAlign:x}=a.bf(o),b=-(g-.5)*c,T=-(x-.5)*r,M=a.bd(o,h);return new a.P((b/d+M[0])*f,(T/d+M[1])*f)}function wu(c,r,o,h,d,f,g,x,b,T,M){const S=c.text.placedSymbolArray,C=c.text.dynamicLayoutVertexArray,P=c.icon.dynamicLayoutVertexArray,k={},R=c.getProjection(),O=Ks(x,R,f),D=f.elevation,F=R.upVectorScale(x.canonical,f.center.lat,f.worldSize).metersToTile;C.clear();for(let Z=0;Z<S.length;Z++){const V=S.get(Z),{tileAnchorX:q,tileAnchorY:B,numGlyphs:$}=V,Y=V.hidden||!V.crossTileID||c.allowVerticalPlacement&&!V.placedOrientation?null:h[V.crossTileID];if(Y){let K=0,ee=0,ce=0;if(D){const Ie=D?D.getAtTileOffset(x,q,B):0,[Re,Le,je]=R.upVector(x.canonical,q,B);K=Ie*Re*F,ee=Ie*Le*F,ce=Ie*je*F}let[re,me,pe,Ae]=Wr(V.projectedAnchorX+K,V.projectedAnchorY+ee,V.projectedAnchorZ+ce,o?O:g);const ne=tu(f.getCameraToCenterDistance(R),Ae);let ue=d.evaluateSizeForFeature(c.textSizeData,T,V)*ne/a.bc;o&&(ue*=c.tilePixelRatio/b);const Q=Ke(Y,ue);o?(({x:re,y:me,z:pe}=R.projectTilePoint(q+Q.x,B+Q.y,x.canonical)),[re,me,pe]=Wr(re+K,me+ee,pe+ce,g)):(r&&Q._rotate(-f.angle),re+=Q.x,me+=Q.y,pe=0);const ae=c.allowVerticalPlacement&&V.placedOrientation===a.b6.vertical?Math.PI/2:0;for(let Ie=0;Ie<$;Ie++)a.b9(C,re,me,pe,ae);M&&V.associatedIconIndex>=0&&(k[V.associatedIconIndex]={x:re,y:me,z:pe,angle:ae})}else io($,C)}if(M){P.clear();const Z=c.icon.placedSymbolArray;for(let V=0;V<Z.length;V++){const q=Z.get(V),{numGlyphs:B}=q,$=k[V];if(q.hidden||!$)io(B,P);else{const{x:Y,y:K,z:ee,angle:ce}=$;for(let re=0;re<B;re++)a.b9(P,Y,K,ee,ce)}}c.icon.dynamicLayoutVertexBuffer.updateData(P)}c.text.dynamicLayoutVertexBuffer.updateData(C)}function ml(c,r,o,h,d,f,g={}){const x=o.paint.get("icon-translate"),b=o.paint.get("text-translate"),T=o.paint.get("icon-translate-anchor"),M=o.paint.get("text-translate-anchor"),S=o.layout.get("icon-rotation-alignment"),C=o.layout.get("text-rotation-alignment"),P=o.layout.get("icon-pitch-alignment"),k=o.layout.get("text-pitch-alignment"),R=o.layout.get("icon-keep-upright"),O=o.layout.get("text-keep-upright"),D=o.paint.get("icon-color-saturation"),F=c.context,Z=F.gl,V=c.transform,q="map"===S,B="map"===C,$="map"===P,Y="map"===k,K=void 0!==o.layout.get("symbol-sort-key").constantOr(1);let ee=!1;const ce=c.depthModeForSublayer(0,dt.ReadOnly),re=[a.a5(V.center.lng),a.ae(V.center.lat)],me=o.layout.get("text-variable-anchor"),pe="globe"===V.projection.name,Ae=[],ne=[0,-1,0];for(const ue of h){const Q=r.getTile(ue),ae=Q.getBucket(o);if(!ae||"mercator"===ae.projection.name&&pe||ae.fullyClipped)continue;const Ie="globe"===ae.projection.name,Re=Ie?a.S(V.zoom):0,Le=Ks(ue,ae.getProjection(),V),je=V.calculatePixelsToTileUnitsMatrix(Q),et=me&&ae.hasTextData(),ct=ae.hasIconTextFit()&&et&&ae.hasIconData(),nt=ae.getProjection().createInversionMatrix(V,ue.canonical),at=()=>{const Ci=q&&"point"!==o.layout.get("symbol-placement"),Bt=[],Kt=Ci||ct,Ft=o.paint.get("icon-image-cross-fade").constantOr(0);c.terrainRenderModeElevated()&&$&&Bt.push("PITCH_WITH_MAP_TERRAIN"),Ie&&(Bt.push("PROJECTION_GLOBE_VIEW"),Kt&&Bt.push("PROJECTED_POS_ON_VIEWPORT")),Ft>0&&Bt.push("ICON_TRANSITION"),ae.icon.zOffsetVertexBuffer&&Bt.push("Z_OFFSET"),D<1&&Bt.push("SATURATION");const Yt=ae.icon.programConfigurations.get(o.id),yi=c.getOrCreateProgram(ae.sdfIcons?"symbolSDF":"symbolIcon",{config:Yt,defines:Bt});let ii;const Qi=Q.imageAtlasTexture?Q.imageAtlasTexture.size:[0,0],hr=ae.iconSizeData,Pr=a.b5(hr,V.zoom),bn=$||0!==V.pitch,zr=Xs(Le,Q.tileID.canonical,$,q,V,ae.getProjection(),je),er=oc(Le,Q.tileID.canonical,$,q,V,ae.getProjection(),je),Hi=c.translatePosMatrix(er,Q,x,T,!0),yr=c.translatePosMatrix(Le,Q,x,T),Tr=Kt?Dn:zr,Dr=q&&!$&&!Ci;let wn=ne;!pe&&!V.mercatorFromTransition||q||(wn=ua(V));const _o=Ie?wn:ne;ii=ae.sdfIcons&&!ae.iconsInText?aa(hr.kind,Pr,Dr,$,c,yr,Tr,Hi,!1,Qi,!0,ue,Re,re,nt,_o,ae.getProjection()):dl(hr.kind,Pr,Dr,$,c,yr,Tr,Hi,!1,Qi,ue,Re,re,nt,_o,ae.getProjection(),D,Ft);const Go=Q.imageAtlasTexture?Q.imageAtlasTexture:null,Pa=1!==o.layout.get("icon-size").constantOr(0)||ae.iconsNeedLinear,za=ae.sdfIcons||c.options.rotating||c.options.zooming||Pa||bn?Z.LINEAR:Z.NEAREST,bh=ae.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),Da=c.terrain&&$&&Ci?a.a6.invert(a.a6.create(),zr):Dn;if(Ci&&ae.icon){const As=V.elevation,El=As?As.getAtTileOffsetFunc(ue,V.center.lat,V.worldSize,ae.getProjection()):null,On=nc(Le,Q.tileID.canonical,$,q,V,ae.getProjection(),je);ac(ae,Le,c,!1,On,er,$,R,El,ue)}return{program:yi,buffers:ae.icon,uniformValues:ii,atlasTexture:Go,atlasTextureIcon:null,atlasInterpolation:za,atlasInterpolationIcon:null,isSDF:ae.sdfIcons,hasHalo:bh,tile:Q,labelPlaneMatrixInv:Da}},Et=()=>{const Ci=B&&"point"!==o.layout.get("symbol-placement"),Bt=[],Kt=Ci||me||ct;c.terrainRenderModeElevated()&&Y&&Bt.push("PITCH_WITH_MAP_TERRAIN"),Ie&&(Bt.push("PROJECTION_GLOBE_VIEW"),Kt&&Bt.push("PROJECTED_POS_ON_VIEWPORT")),ae.text.zOffsetVertexBuffer&&Bt.push("Z_OFFSET");const Ft=ae.text.programConfigurations.get(o.id),Yt=c.getOrCreateProgram(ae.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:Ft,defines:Bt});let yi,ii=[0,0],Qi=null;const hr=ae.textSizeData;ae.iconsInText&&(ii=Q.imageAtlasTexture?Q.imageAtlasTexture.size:[0,0],Qi=Q.imageAtlasTexture?Q.imageAtlasTexture:null,yi=Y||0!==V.pitch||c.options.rotating||c.options.zooming||"composite"===hr.kind||"camera"===hr.kind?Z.LINEAR:Z.NEAREST);const Pr=Q.glyphAtlasTexture?Q.glyphAtlasTexture.size:[0,0],bn=a.b5(hr,V.zoom),zr=Xs(Le,Q.tileID.canonical,Y,B,V,ae.getProjection(),je),er=oc(Le,Q.tileID.canonical,Y,B,V,ae.getProjection(),je),Hi=c.translatePosMatrix(er,Q,b,M,!0),yr=c.translatePosMatrix(Le,Q,b,M),Tr=Kt?Dn:zr,Dr=B&&!Y&&!Ci;let wn=ne;!pe&&!V.mercatorFromTransition||B||(wn=ua(V));const _o=Ie?wn:ne;let Go;Go=ae.iconsInText?pl(hr.kind,bn,Dr,Y,c,yr,Tr,Hi,Pr,ii,ue,Re,re,nt,_o,ae.getProjection()):aa(hr.kind,bn,Dr,Y,c,yr,Tr,Hi,!0,Pr,!0,ue,Re,re,nt,_o,ae.getProjection());const Pa=Q.glyphAtlasTexture?Q.glyphAtlasTexture:null,za=Z.LINEAR,bh=0!==o.paint.get("text-halo-width").constantOr(1),Da=c.terrain&&Y&&Ci?a.a6.invert(a.a6.create(),zr):Dn;if(Ci&&ae.text){const As=V.elevation,El=As?As.getAtTileOffsetFunc(ue,V.center.lat,V.worldSize,ae.getProjection()):null,On=nc(Le,Q.tileID.canonical,Y,B,V,ae.getProjection(),je);ac(ae,Le,c,!0,On,er,Y,O,El,ue)}return{program:Yt,buffers:ae.text,uniformValues:Go,atlasTexture:Pa,atlasTextureIcon:Qi,atlasInterpolation:za,atlasInterpolationIcon:yi,isSDF:!0,hasHalo:bh,tile:Q,labelPlaneMatrixInv:Da}},gt=ae.icon.segments.get().length,bt=ae.text.segments.get().length,vt=gt&&!g.onlyText?at():null,Zt=bt&&!g.onlyIcons?Et():null,_i=o.paint.get("icon-opacity").constantOr(1),Ot=o.paint.get("text-opacity").constantOr(1);if(K&&ae.canOverlap){ee=!0;const Ci=_i&&!g.onlyText?ae.icon.segments.get():[],Bt=Ot&&!g.onlyIcons?ae.text.segments.get():[];for(const Kt of Ci)Ae.push({segments:new a.aB([Kt]),sortKey:Kt.sortKey,state:vt});for(const Kt of Bt)Ae.push({segments:new a.aB([Kt]),sortKey:Kt.sortKey,state:Zt})}else g.onlyText||Ae.push({segments:_i?ae.icon.segments:new a.aB([]),sortKey:0,state:vt}),g.onlyIcons||Ae.push({segments:Ot?ae.text.segments:new a.aB([]),sortKey:0,state:Zt})}ee&&Ae.sort((ue,Q)=>ue.sortKey-Q.sortKey);for(const ue of Ae){const Q=ue.state;if(Q)if(c.terrain&&c.terrain.setupElevationDraw(Q.tile,Q.program,{useDepthForOcclusion:V.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Q.labelPlaneMatrixInv}),F.activeTexture.set(Z.TEXTURE0),Q.atlasTexture&&Q.atlasTexture.bind(Q.atlasInterpolation,Z.CLAMP_TO_EDGE,!0),Q.atlasTextureIcon&&(F.activeTexture.set(Z.TEXTURE1),Q.atlasTextureIcon&&Q.atlasTextureIcon.bind(Q.atlasInterpolationIcon,Z.CLAMP_TO_EDGE,!0)),c.uploadCommonLightUniforms(c.context,Q.program),Q.hasHalo){const ae=Q.uniformValues;ae.u_is_halo=1,ao(Q.buffers,ue.segments,o,c,Q.program,ce,d,f,ae,2),ae.u_is_halo=0}else{if(Q.isSDF){const ae=Q.uniformValues;Q.hasHalo&&(ae.u_is_halo=1,ao(Q.buffers,ue.segments,o,c,Q.program,ce,d,f,ae,1)),ae.u_is_halo=0}ao(Q.buffers,ue.segments,o,c,Q.program,ce,d,f,Q.uniformValues,1)}}}function ao(c,r,o,h,d,f,g,x,b,T){const M=[c.dynamicLayoutVertexBuffer,c.opacityVertexBuffer,c.iconTransitioningVertexBuffer,c.globeExtVertexBuffer,c.zOffsetVertexBuffer];d.draw(h,h.context.gl.TRIANGLES,f,g,x,pt.disabled,b,o.id,c.layoutVertexBuffer,c.indexBuffer,r,o.paint,h.transform.zoom,c.programConfigurations.get(o.id),M,T)}function No(c,r,o,h,d,f,g){const x=c.context.gl,b=o.paint.get("fill-pattern"),T=b&&b.constantOr(1);let M,S,C,P,k;g?(S=T&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=x.LINES):(S=T?"fillPattern":"fill",M=x.TRIANGLES);for(const R of h){const O=r.getTile(R);if(T&&!O.patternsLoaded())continue;const D=O.getBucket(o);if(!D)continue;c.prepareDrawTile();const F=D.programConfigurations.get(o.id),Z=c.isTileAffectedByFog(R),V=c.getOrCreateProgram(S,{config:F,overrideFog:Z});T&&(c.context.activeTexture.set(x.TEXTURE0),O.imageAtlasTexture&&O.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),F.updatePaintBuffers());const q=b.constantOr(null);if(q&&O.imageAtlas){const Y=O.imageAtlas.patternPositions[q.toString()];Y&&F.setConstantPatternPositions(Y)}const B=c.translatePosMatrix(R.projMatrix,O,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),$=o.paint.get("fill-emissive-strength");if(g){P=D.indexBuffer2,k=D.segments2;const Y=c.terrain&&c.terrain.renderingToTexture?c.terrain.drapeBufferSize:[x.drawingBufferWidth,x.drawingBufferHeight];C="fillOutlinePattern"===S&&T?gu(B,$,c,O,Y):Fo(B,$,Y)}else P=D.indexBuffer,k=D.segments,C=T?Uc(B,$,c,O):ws(B,$);c.uploadCommonUniforms(c.context,V,R.toUnwrapped()),V.draw(c,M,d,c.stencilModeForClipping(R),f,pt.disabled,C,o.id,D.layoutVertexBuffer,P,k,o.paint,c.transform.zoom,F,void 0)}}function it(c,r,o,h,d,f,g,x){o.resetLayerRenderingStats(c);const b=c.context,T=b.gl,M=c.transform,S=o.paint.get("fill-extrusion-pattern"),C=S.constantOr(1),P=o.paint.get("fill-extrusion-opacity"),k=c.style.enable3dLights(),R=o.paint.get(k&&!C?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),O=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),R],D=o.layout.get("fill-extrusion-edge-radius"),F=D>0&&!o.paint.get("fill-extrusion-rounded-roof"),Z=F?0:D,V="globe"===M.projection.name?a.cF():0,q="globe"===M.projection.name,B=q?a.S(M.zoom):0,$=[a.a5(M.center.lng),a.ae(M.center.lat)],Y=o.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),K=o.paint.get("fill-extrusion-flood-light-intensity"),ee=o.paint.get("fill-extrusion-vertical-scale"),ce=no(c,o.paint.get("fill-extrusion-cutoff-fade-range")),re=o.paint.get("fill-extrusion-emissive-strength"),me=[];let pe;q&&me.push("PROJECTION_GLOBE_VIEW"),O[0]>0&&me.push("FAUX_AO"),F&&me.push("ZERO_ROOF_RADIUS"),x&&me.push("HAS_CENTROID"),K>0&&me.push("FLOOD_LIGHT"),ce.shouldRenderCutoff&&me.push("RENDER_CUTOFF");const Ae="shadow"===c.renderPass,ne=c.shadowRenderer,ue=Ae&&!!ne;c.shadowRenderer&&(c.shadowRenderer.useNormalOffset=!0);let Q=[0,0,0];if(ne){const Re=c.style.directionalLight,Le=c.style.ambientLight;Re&&Le&&(Q=ra(Re,Le)),pe=me.concat(["SHADOWS_SINGLE_CASCADE"])}const ae=ue?"fillExtrusionDepth":C?"fillExtrusionPattern":"fillExtrusion",Ie=o.getLayerRenderingStats();for(const Re of h){const Le=r.getTile(Re),je=Le.getBucket(o);if(!je||je.projection.name!==M.projection.name)continue;let et=!1;ne&&(et=0===ne.getMaxCascadeForTile(Re.toUnwrapped()));const ct=c.isTileAffectedByFog(Re),nt=je.programConfigurations.get(o.id),at=c.getOrCreateProgram(ae,{config:nt,defines:et?pe:me,overrideFog:ct});if(c.terrain&&c.terrain.setupElevationDraw(Le,at,{useMeterToDem:!0}),!je.centroidVertexBuffer){const _i=at.attributes.a_centroid_pos;void 0!==_i&&T.vertexAttrib2f(_i,0,0)}!Ae&&ne&&ne.setupShadows(Le.tileID.toUnwrapped(),at,"vector-tile",Le.tileID.overscaledZ),C&&(c.context.activeTexture.set(T.TEXTURE0),Le.imageAtlasTexture&&Le.imageAtlasTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),nt.updatePaintBuffers());const Et=S.constantOr(null);if(Et&&Le.imageAtlas){const _i=Le.imageAtlas.patternPositions[Et.toString()];_i&&nt.setConstantPatternPositions(_i)}const gt=o.paint.get("fill-extrusion-vertical-gradient");let bt;if(Ae&&ne){if(Mu(Le.tileID,je,c))continue;const _i=ne.calculateShadowPassMatrixFromTile(Le.tileID.toUnwrapped());bt=Vc(_i,Z,ee)}else{const _i=c.translatePosMatrix(Re.expandedProjMatrix,Le,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),Ot=M.projection.createInversionMatrix(M,Re.canonical);bt=C?Bo(_i,c,gt,P,O,Z,Re,Le,V,B,$,Ot,Y,ee):Nc(_i,c,gt,P,O,Z,Re,V,B,$,Ot,Y,ee,K,Q,re)}c.uploadCommonUniforms(b,at,Re.toUnwrapped(),null,ce);let vt=je.segments;if("mercator"===M.projection.name&&!Ae&&(vt=je.getVisibleSegments(Le.tileID,c.terrain,c.transform.getFrustum(0)),!vt.get().length))continue;if(Ie)if(Ae)for(const _i of vt.get())Ie.numRenderedVerticesInShadowPass+=_i.primitiveLength;else for(const _i of vt.get())Ie.numRenderedVerticesInTransparentPass+=_i.primitiveLength;const Zt=[];(c.terrain||x)&&Zt.push(je.centroidVertexBuffer),q&&Zt.push(je.layoutVertexExtBuffer),at.draw(c,b.gl.TRIANGLES,d,f,g,pt.backCCW,bt,o.id,je.layoutVertexBuffer,je.indexBuffer,vt,o.paint,c.transform.zoom,nt,Zt)}c.shadowRenderer&&(c.shadowRenderer.useNormalOffset=!1)}function lo(c,r,o,h,d,f,g,x,b,T,M,S,C,P,k,R,O,D,F){const Z=c.context,V=Z.gl,q=c.transform,B=c.transform.zoom,$=[],Y=no(c,o.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===T?($.push("CLEAR_SUBPASS"),F&&($.push("CLEAR_FROM_TEXTURE"),Z.activeTexture.set(V.TEXTURE0),F.bind(V.LINEAR,V.CLAMP_TO_EDGE))):"sdf"===T&&$.push("SDF_SUBPASS"),O&&$.push("HAS_CENTROID"),Y.shouldRenderCutoff&&$.push("RENDER_CUTOFF");const K=o.layout.get("fill-extrusion-edge-radius"),ee=(ce,re,me,pe,Ae)=>{const ne=re.programConfigurations.get(o.id),ue=c.isTileAffectedByFog(ce),Q=c.getOrCreateProgram("fillExtrusionGroundEffect",{config:ne,defines:$,overrideFog:ue}),ae=((Re,Le,je,et,ct,nt,at,Et,gt,bt,vt)=>({u_matrix:Le,u_opacity:je,u_ao_pass:et?1:0,u_meter_to_tile:ct,u_ao:nt,u_flood_light_intensity:at,u_flood_light_color:Et,u_attenuation:gt,u_edge_radius:bt,u_fb:0,u_fb_size:vt}))(0,pe,M,b,Ae,[S,C*Ae],P,k,R,B>=17?0:K*Ae,F?F.size[0]:0),Ie=[];O&&Ie.push(re.hiddenByLandmarkVertexBuffer),c.uploadCommonUniforms(Z,Q,ce.toUnwrapped(),null,Y),Q.draw(c,Z.gl.TRIANGLES,d,f,g,x,ae,o.id,re.vertexBuffer,re.indexBuffer,me,o.paint,B,ne,Ie)};for(const ce of h){const re=r.getTile(ce),me=re.getBucket(o);if(!me||me.projection.name!==q.projection.name||!me.groundEffect||me.groundEffect&&!me.groundEffect.hasData())continue;const pe=me.groundEffect,Ae=1/me.tileToMeter;{const ne=c.translatePosMatrix(ce.projMatrix,re,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),ue=pe.getDefaultSegment();ee(ce,pe,ue,ne,Ae)}if(D)for(let ne=0;ne<4;ne++){const ue=a.cG[ne](ce),Q=r.getTile(ue);if(!Q)continue;const ae=Q.getBucket(o);if(!ae||ae.projection.name!==q.projection.name||!ae.groundEffect||ae.groundEffect&&!ae.groundEffect.hasData())continue;const Ie=ae.groundEffect;let Re,Le;0===ne?(Re=[-a.V,0,0],Le=1):1===ne?(Re=[a.V,0,0],Le=0):2===ne?(Re=[0,-a.V,0],Le=3):(Re=[0,a.V,0],Le=2);const je=Ie.regionSegments[Le];if(!je)continue;const et=new Float32Array(16);a.a6.translate(et,ce.projMatrix,Re),ee(ce,Ie,je,c.translatePosMatrix(et,re,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),Ae)}}}function lp(c,r,o,h,d,f,g){0===h.centroidVertexArray.length&&h.createCentroidsBuffer();const x=f?f.findDEMTileFor(o):null;if(!(x&&x.dem||g))return;const b=D=>new a.P(Math.ceil((D+a.cJ)*a.cK),0),T=D=>{const F=r.getSource().minzoom,Z=q=>{const B=r.getTileByID(q);if(B&&B.hasData())return B.getBucket(d)},V=[0,-1,1];for(const q of V){if(D.overscaledZ+q<F)continue;const B=Z(D.calculateScaledKey(D.overscaledZ+q));if(B)return B}},M=[0,0,0],S=(D,F)=>(M[0]=Math.min(D.min.y,F.min.y),M[1]=Math.max(D.max.y,F.max.y),M[2]=a.V-F.min.x>D.max.x?F.min.x-a.V:D.max.x,M),C=(D,F)=>(M[0]=Math.min(D.min.x,F.min.x),M[1]=Math.max(D.max.x,F.max.x),M[2]=a.V-F.min.y>D.max.y?F.min.y-a.V:D.max.y,M),P=[(D,F)=>S(D,F),(D,F)=>S(F,D),(D,F)=>C(D,F),(D,F)=>C(F,D)],k=(D,F,Z,V,q,B,$)=>{if(!f)return 0;const Y=[[B?Z:D,B?D:Z,0],[B?Z:F,B?F:Z,0]],K=$<0?a.V+$:$,ee=[B?K:(D+F)/2,B?(D+F)/2:K,0];return 0===Z&&$<0||0!==Z&&$>0?f.getForTilePoints(q,[ee],!0,V):Y.push(ee),f.getForTilePoints(o,Y,!0,x),Math.max(Y[0][2],Y[1][2],ee[2])/f.exaggeration()};for(let D=0;D<4;D++){const F=h.borderFeatureIndices[D];if(0===F.length)continue;const Z=a.cG[D](o),V=T(Z);if(!(V&&V instanceof a.cH)||h.borderDoneWithNeighborZ[D]===V.canonical.z)continue;0===V.centroidVertexArray.length&&V.createCentroidsBuffer();const q=f?f.findDEMTileFor(Z):null;if(!(q&&q.dem||g))continue;const B=(D<2?1:5)-D,$=V.borderDoneWithNeighborZ[B]!==h.canonical.z,Y=V.borderFeatureIndices[B];let K=0;if(h.canonical.z!==V.canonical.z){for(const ee of F)h.showCentroid(h.featuresOnBorder[ee]);if($)for(const ee of Y)V.showCentroid(V.featuresOnBorder[ee]);h.borderDoneWithNeighborZ[D]=V.canonical.z,V.borderDoneWithNeighborZ[B]=h.canonical.z}for(const ee of F){const ce=h.featuresOnBorder[ee],re=h.centroidData[ce.centroidDataIndex],me=ce.borders[D];let pe;for(;K<Y.length;){pe=V.featuresOnBorder[Y[K]];const Ae=pe.borders[B];if(Ae[1]>me[0]+3||Ae[0]>me[0]-3)break;V.showCentroid(pe),K++}if(pe&&K<Y.length){const Ae=K;let ne=0;for(;!(pe.borders[B][0]>me[1]-3)&&(ne++,++K!==Y.length);)pe=V.featuresOnBorder[Y[K]];if(pe=V.featuresOnBorder[Y[Ae]],ne>1){const ae=pe.borders[B];Math.abs(me[0]-ae[0])<3&&Math.abs(me[1]-ae[1])<3&&(ne=1,K=Ae+1)}else if(0===ne){h.showCentroid(ce);continue}const ue=V.centroidData[pe.centroidDataIndex];g&&1===ne&&(((R=re).flags|(O=ue).flags)&a.cI?(R.flags|=a.cI,O.flags|=a.cI):(R.flags&=~a.cI,O.flags&=~a.cI));const Q=ce.intersectsCount()>1||pe.intersectsCount()>1;if(ne>1)K=Ae,re.centroidXY=ue.centroidXY=new a.P(0,0);else if(q&&q.dem&&!Q){const ae=P[D](re,ue),Ie=D%2?a.V-1:0,Re=k(ae[0],Math.min(a.V-1,ae[1]),Ie,q,Z,D<2,ae[2]);re.centroidXY=ue.centroidXY=b(Re)}else Q?re.centroidXY=ue.centroidXY=new a.P(0,0):(re.centroidXY=h.encodeBorderCentroid(ce),ue.centroidXY=V.encodeBorderCentroid(pe));h.writeCentroidToBuffer(re),V.writeCentroidToBuffer(ue)}else h.showCentroid(ce)}h.borderDoneWithNeighborZ[D]=V.canonical.z,V.borderDoneWithNeighborZ[B]=h.canonical.z}var R,O;(h.needsCentroidUpdate||!h.centroidVertexBuffer&&0!==h.centroidVertexArray.length)&&h.uploadCentroid(c)}const cp=[1,0,0],$c=[0,1,0],Tu=[0,0,1];function Mu(c,r,o){const h=o.transform,d=o.shadowRenderer;if(!d)return!0;const f=c.toUnwrapped(),g=h.tileSize*d._cascades[o.currentShadowCascade].scale;let x=r.maxHeight;if(h.elevation){const R=h.elevation.getMinMaxForTile(c);R&&(x+=R.max)}const b=[...d.shadowDirection];b[2]=-b[2];const T=d.computeSimplifiedTileShadowVolume(f,x,g,b);if(!T)return!1;const M=[cp,$c,Tu,b,[b[0],0,b[2]],[0,b[1],b[2]]],S="globe"===h.projection.name,C=h.scaleZoom(g),P=a.bq.fromInvProjectionMatrix(h.invProjMatrix,h.worldSize,C,!S),k=d.getCurrentCascadeFrustum();return 0===P.intersectsPrecise(T.vertices,T.planes,M)||0===k.intersectsPrecise(T.vertices,T.planes,M)}function Eu(c){return[c[0]*a.cL,c[1]*a.cL,c[2]*a.cL,0]}function Wc(c,r,o,h,d,f,g,x,b){const T=h.getSource(),M=o.globeSharedBuffers;if(!M)return;let S,C,P;if(r&&(S=h.getTile(r)),T instanceof a.ap?(C=T.texture,P=a.cj(0,0,o.transform)):S&&r&&(C=S.texture,P=a.cj(r.canonical.z,r.canonical.x,o.transform)),!C||!P)return;c||(P=a.a6.scale(a.a6.create(),P,[1,-1,1]));const k=o.context,R=k.gl,O="nearest"===d.paint.get("raster-resampling")?R.NEAREST:R.LINEAR,D=o.colorModeForDrapableLayerRenderPass(f),F=g.defines;F.push("GLOBE_POLES");const Z=new dt(R.LEQUAL,dt.ReadWrite,o.depthRangeFor3D),V=Float32Array.from(o.transform.expandedFarZProjMatrix),q=Float32Array.from(a.aT(a.ci(new a.bs(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),k.activeTexture.set(R.TEXTURE0),C.bind(O,R.CLAMP_TO_EDGE),k.activeTexture.set(R.TEXTURE1),C.bind(O,R.CLAMP_TO_EDGE),C.useMipmap&&k.extTextureFilterAnisotropic&&o.transform.pitch>20&&R.texParameterf(R.TEXTURE_2D,k.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,k.extTextureFilterAnisotropicMax);const[B,$,Y,K]=r?M.getPoleBuffers(r.canonical.z,!1):M.getPoleBuffers(0,!0),ee=d.paint.get("raster-elevation");let ce;c?(ce=B,o.renderDefaultNorthPole=0!==ee):(ce=$,o.renderDefaultSouthPole=0!==ee);const re=Eu(g.mix),me=(Ae=V,ne=q,ue=P,Q=a.S(o.transform.zoom),Ie=d,Le=ee,et=re,ct=g.offset,nt=g.range,at=f,Zc(Ae,ne,ue,new Float32Array(16),new Float32Array(9),[0,0],Q,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Ie,[0,0],Le,2,et,ct,nt,1,0,at)),pe=o.getOrCreateProgram("raster",{defines:F});var Ae,ne,ue,Q,Ie,Le,et,ct,nt,at;o.uploadCommonUniforms(k,pe,null),pe.draw(o,R.TRIANGLES,Z,b,D,x,me,d.id,ce,Y,K)}function Hc(c){const r=c._nearZ,o=c.projection.farthestPixelDistance(c),h=o-r,d=.2*c.height,f=r+d;return[r,o,(f-d-r)/h,(f-r)/h]}function Xc(c,r,o,h){if(c)return r instanceof Be&&c instanceof zo?r.getTextureDescriptor(c,o,!0):{texture:c.texture,mix:Eu(h.mix),offset:h.offset,buffer:0,tileSize:1}}function Yc(c,r,o){if(!c)return null;const h=r.getTextureDescriptor(c,o,!0);if(!h)return null;let{texture:d,mix:f,offset:g,tileSize:x,buffer:b,format:T}=h;if(!d||!T)return null;let M=!1;return"uint32"===T&&(M=!0,f[3]=0,f=ul(a.cM,f,[0,o.paint.get("raster-particle-max-speed")]),g=xu(a.cM,g,[0,o.paint.get("raster-particle-max-speed")])),{texture:d,textureOffset:[b/(x+2*b),x/(x+2*b)],tileSize:x,scalarData:M,scale:f,offset:g,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[T]]}}function Kc(c){const r=c._nearZ,o=c.projection.farthestPixelDistance(c),h=o-r,d=.2*c.height,f=r+d;return[r,o,(f-d-r)/h,(f-r)/h]}const Ir=new a.ax(1,0,0,1),co=new a.ax(0,1,0,1),Su=new a.ax(0,0,1,1),Jc=new a.ax(1,0,1,1),Qc=new a.ax(0,1,1,1);function ho(c,r,o,h,d,f,g){const x=c.context,b=c.transform,T=x.gl,M="globe"===b.projection.name,S=M?["PROJECTION_GLOBE_VIEW"]:[];let C=a.a6.clone(o.projMatrix);if(M&&a.S(b.zoom)>0){const re=a.aS(o.canonical,b),me=a.cN(re);C=a.a6.multiply(new Float32Array(16),b.globeMatrix,me),a.a6.multiply(C,b.projMatrix,C)}const P=a.a6.create();P[12]+=2*d/(a.f.devicePixelRatio*b.width),P[13]+=2*f/(a.f.devicePixelRatio*b.height),a.a6.multiply(C,P,C);const k=c.getOrCreateProgram("debug",{defines:S}),R=r.getTileByID(o.key);c.terrain&&c.terrain.setupElevationDraw(R,k);const O=dt.disabled,D=yt.disabled,F=c.colorModeForRenderPass(),Z="$debug";x.activeTexture.set(T.TEXTURE0),c.emptyTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),M?R._makeGlobeTileDebugBuffers(c.context,b):R._makeDebugTileBoundsBuffers(c.context,b.projection);const V=R._tileDebugBuffer||c.debugBuffer,q=R._tileDebugIndexBuffer||c.debugIndexBuffer,B=R._tileDebugSegments||c.debugSegments;if(k.draw(c,T.LINE_STRIP,O,D,F,pt.disabled,jc(C,h),Z,V,q,B,null,null,null,[R._globeTileDebugBorderBuffer]),g){const re=R.latestRawTileData,me=Math.floor((re&&re.byteLength||0)/1024);let pe=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(pe+=` => ${o.overscaledZ}`),pe+=` ${R.state}`,pe+=` ${me}kb`,function(Ae,ne){Ae.initDebugOverlayCanvas();const ue=Ae.debugOverlayCanvas,Q=Ae.context.gl,ae=Ae.debugOverlayCanvas.getContext("2d");ae.clearRect(0,0,ue.width,ue.height),ae.shadowColor="white",ae.shadowBlur=2,ae.lineWidth=1.5,ae.strokeStyle="white",ae.textBaseline="top",ae.font="bold 36px Open Sans, sans-serif",ae.fillText(ne,5,5),ae.strokeText(ne,5,5),Ae.debugOverlayTexture.update(ue),Ae.debugOverlayTexture.bind(Q.LINEAR,Q.CLAMP_TO_EDGE)}(c,pe)}const $=r.getTile(o).tileSize,Y=512/Math.min($,512)*(o.overscaledZ/b.zoom)*.5,K=R._tileDebugTextBuffer||c.debugBuffer,ee=R._tileDebugTextIndexBuffer||c.quadTriangleIndexBuffer,ce=R._tileDebugTextSegments||c.debugSegments;k.draw(c,T.TRIANGLES,O,D,Rt.alphaBlended,pt.disabled,jc(C,a.ax.transparent,Y),Z,K,ee,ce,null,null,null,[R._globeTileDebugTextBuffer])}function eh(c,r,o,h){Ai(c,0,r+o/2,c.transform.width,o,h)}function Nr(c,r,o,h){Ai(c,r-o/2,0,o,c.transform.height,h)}function Ai(c,r,o,h,d,f){const g=c.context,x=g.gl;x.enable(x.SCISSOR_TEST),x.scissor(r*a.f.devicePixelRatio,o*a.f.devicePixelRatio,h*a.f.devicePixelRatio,d*a.f.devicePixelRatio),g.clear({color:f}),x.disable(x.SCISSOR_TEST)}const _l=a.ay([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:th}=_l;function Ln(c,r,o,h){c.emplaceBack(r,o,h)}class ih{constructor(r){this.vertexArray=new a.az,this.indices=new a.aw,Ln(this.vertexArray,-1,-1,1),Ln(this.vertexArray,1,-1,1),Ln(this.vertexArray,-1,1,1),Ln(this.vertexArray,1,1,1),Ln(this.vertexArray,-1,-1,-1),Ln(this.vertexArray,1,-1,-1),Ln(this.vertexArray,-1,1,-1),Ln(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=r.createVertexBuffer(this.vertexArray,th),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=a.aB.simpleSegment(0,0,36,12)}}function Vo(c,r,o,h,d,f){const g=c.context.gl,x=r.paint.get("sky-atmosphere-color"),b=r.paint.get("sky-atmosphere-halo-color"),T=r.paint.get("sky-atmosphere-sun-intensity"),M={u_matrix_3f:a.co.fromMat4(a.co.create(),h),u_sun_direction:d,u_sun_intensity:T,u_color_tint_r:[(k=x).r,k.g,k.b,k.a],u_color_tint_m:[(R=b).r,R.g,R.b,R.a],u_luminance:5e-5};var k,R;g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_CUBE_MAP_POSITIVE_X+f,r.skyboxTexture,0),o.draw(c,g.TRIANGLES,dt.disabled,yt.disabled,Rt.unblended,pt.frontCW,M,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const hp=a.ay([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ts{constructor(r){const o=new a.cO;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);const h=new a.aw;h.emplaceBack(0,1,2),h.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(o,hp.members),this.indexBuffer=r.createIndexBuffer(h),this.segments=a.aB.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const da=a.ay([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class Oe{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class ht{constructor(r){this.colorModeAlphaBlendedWriteRGB=new Rt([1,771,1,771],a.ax.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Rt([1,0,1,0],a.ax.transparent,[!1,!1,!1,!0]),this.params=new Oe,this.updateNeeded=!0,r.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),r.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),r.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),r.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(r){const o=r.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Ts(o);const h=this.params.sizeRange,d=this.params.intensityRange,f=function(M){const S=a.aA(30),C=[];for(let P=0;P<M;++P){const k=2*Math.PI*S(),R=Math.acos(1-2*S())-.5*Math.PI;C.push(a.N.fromValues(Math.cos(R)*Math.cos(k),Math.cos(R)*Math.sin(k),Math.sin(R)))}return C}(this.params.starsCount),g=a.aA(300),x=new a.cP,b=new a.aw;let T=0;for(let M=0;M<f.length;++M){const S=a.N.scale([],f[M],200),C=Math.max(0,1+.01*h*(1*g()-.5)),P=Math.max(0,1+.01*d*(1*g()-.5));x.emplaceBack(S[0],S[1],S[2],-1,-1,C,P),x.emplaceBack(S[0],S[1],S[2],1,-1,C,P),x.emplaceBack(S[0],S[1],S[2],1,1,C,P),x.emplaceBack(S[0],S[1],S[2],-1,1,C,P),b.emplaceBack(T+0,T+1,T+2),b.emplaceBack(T+0,T+2,T+3),T+=4}this.starsVx=o.createVertexBuffer(x,da.members),this.starsIdx=o.createIndexBuffer(b),this.starsSegments=a.aB.simpleSegment(0,0,x.length,b.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(r,o){const h=r.context,d=h.gl,f=r.transform,g=new dt(d.LEQUAL,dt.ReadOnly,[0,1]),x=a.S(f.zoom),b=o.properties.get("color").toArray01(),T=o.properties.get("high-color").toArray01(),M=o.properties.get("space-color").toArray01PremultipliedAlpha(),S=5e-4,C=a.cQ(o.properties.get("horizon-blend"),0,1,S,.25),P=a.cd(r,h,f)&&C===S?f.worldSize/(2*Math.PI*1.025)-1:f.globeRadius,k=r.frameCounter/1e3%1,R=a.N.length(f.globeCenterInViewSpace),O=Math.sqrt(Math.pow(R,2)-Math.pow(P,2)),D=Math.acos(O/R),F=Z=>{const V="globe"===f.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Z&&V.push("ALPHA_PASS");const q=r.getOrCreateProgram("globeAtmosphere",{defines:V}),B=((Y,K,ee,ce,re,me,pe,Ae,ne,ue,Q,ae)=>({u_frustum_tl:Y,u_frustum_tr:K,u_frustum_br:ee,u_frustum_bl:ce,u_horizon:re,u_transition:me,u_fadeout_range:pe,u_color:Ae,u_high_color:ne,u_space_color:ue,u_temporal_offset:Q,u_horizon_angle:ae}))(f.frustumCorners.TL,f.frustumCorners.TR,f.frustumCorners.BR,f.frustumCorners.BL,f.frustumCorners.horizon,x,C,b,T,M,k,D);r.uploadCommonUniforms(h,q);const $=this.atmosphereBuffer;$&&q.draw(r,d.TRIANGLES,g,yt.disabled,Z?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,pt.backCW,B,Z?"atmosphere_glow_alpha":"atmosphere_glow",$.vertexBuffer,$.indexBuffer,$.segments)};F(!1),F(!0)}drawStars(r,o){const h=a.aa(o.properties.get("star-intensity"),0,1);if(0===h)return;const d=r.context,f=d.gl,g=r.transform,x=r.getOrCreateProgram("stars"),b=a.bi.identity([]);a.bi.rotateX(b,b,-g._pitch),a.bi.rotateZ(b,b,-g.angle),a.bi.rotateX(b,b,a.bj(g._center.lat)),a.bi.rotateY(b,b,-a.bj(g._center.lng));const T=a.a6.fromQuat(new Float32Array(16),b),M=a.a6.multiply([],g.starsProjMatrix,T),S=a.co.fromMat4([],T),C=a.co.invert([],S),P=[0,1,0];a.N.transformMat3(P,P,C),a.N.scale(P,P,this.params.sizeMultiplier);const k=[1,0,0];a.N.transformMat3(k,k,C),a.N.scale(k,k,this.params.sizeMultiplier);const R=(O=P,D=k,F=h,{u_matrix:Float32Array.from(M),u_up:O,u_right:D,u_intensity_multiplier:F});var O,D,F;r.uploadCommonUniforms(d,x),this.starsVx&&this.starsIdx&&x.draw(r,f.TRIANGLES,dt.disabled,yt.disabled,this.colorModeAlphaBlendedWriteRGB,pt.disabled,R,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Uo(c,r){const o=[...c],h=r.cameraWorldSizeForFog/r.worldSize,d=a.a6.identity([]);return a.a6.scale(d,d,[h,h,1]),a.a6.multiply(o,d,o),a.a6.multiply(o,r.worldToFogMatrix,o),o}function Ii(c,r,o,h){const d=o.material,f=h.context,{baseColorTexture:g,metallicRoughnessTexture:x}=d.pbrMetallicRoughness,{normalTexture:b,occlusionTexture:T,emissionTexture:M}=d;function S(C,P,k){if(C&&(c.push(P),f.activeTexture.set(f.gl.TEXTURE0+k),C.gfxTexture)){const{minFilter:R,magFilter:O,wrapS:D,wrapT:F}=C.sampler;C.gfxTexture.bindExtraParam(R,O,D,F)}}S(g,"HAS_TEXTURE_u_baseColorTexture",cr_BaseColor),S(x,"HAS_TEXTURE_u_metallicRoughnessTexture",cr_MetallicRoughness),S(b,"HAS_TEXTURE_u_normalTexture",cr_Normal),S(T,"HAS_TEXTURE_u_occlusionTexture",cr_Occlusion),S(M,"HAS_TEXTURE_u_emissionTexture",cr_Emission),o.texcoordBuffer&&(c.push("HAS_ATTRIBUTE_a_uv_2f"),r.push(o.texcoordBuffer)),o.colorBuffer&&(c.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),r.push(o.colorBuffer)),o.normalBuffer&&(c.push("HAS_ATTRIBUTE_a_normal_3f"),r.push(o.normalBuffer)),o.pbrBuffer&&(c.push("HAS_ATTRIBUTE_a_pbr"),c.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),r.push(o.pbrBuffer)),"OPAQUE"!==d.alphaMode&&"MASK"!==d.alphaMode||c.push("UNPREMULT_TEXTURE_IN_SHADER"),d.defined||c.push("DIFFUSE_SHADED"),c.push("USE_STANDARD_DERIVATIVES")}function pa(c,r,o,h,d,f){const g=o.paint.get("model-opacity"),x=r.context,b=new dt(r.context.gl.LEQUAL,dt.ReadWrite,r.depthRangeFor3D),T=r.transform,M=c.mesh,S=M.material,C=S.pbrMetallicRoughness,P=r.style.fog;let k;k="pixels"===r.transform.projection.zAxisUnit?[...c.nodeModelMatrix]:a.a6.multiply([],h.zScaleMatrix,c.nodeModelMatrix),a.a6.multiply(k,h.negCameraPosMatrix,k);const R=a.a6.invert([],k);a.a6.transpose(R,R);const O=o.paint.get("model-emissive-strength").constantOr(0),D=fl(new Float32Array(c.worldViewProjection),new Float32Array(k),new Float32Array(R),r,g,C.baseColorFactor,S.emissiveFactor,C.metallicFactor,C.roughnessFactor,S,O,o),F={defines:[]},Z=[];Ii(F.defines,Z,M,r);const V=r.shadowRenderer;V&&(V.useNormalOffset=!1);let q=null;if(P){const Y=Uo(c.nodeModelMatrix,r.transform);if(q=new Float32Array(Y),"globe"!==T.projection.name){const K=M.aabb.min,ee=M.aabb.max,[ce,re]=P.getOpacityForBounds(Y,K[0],K[1],ee[0],ee[1]);F.overrideFog=ce>=ai||re>=ai}}const B=no(r,o.paint.get("model-cutoff-fade-range"));B.shouldRenderCutoff&&F.defines.push("RENDER_CUTOFF");const $=r.getOrCreateProgram("model",F);r.uploadCommonUniforms(x,$,null,q,B),"shadow"!==r.renderPass&&V&&V.setupShadowsFromMatrix(c.nodeModelMatrix,$),$.draw(r,x.gl.TRIANGLES,b,d,f,M.material.doubleSided?pt.disabled:pt.backCCW,D,o.id,M.vertexBuffer,M.indexBuffer,M.segments,o.paint,r.transform.zoom,void 0,Z)}function fa(c,r,o,h,d,f,g){let x;x="globe"===c.projection.name?a.cS(o,c):[...o],a.a6.multiply(x,x,r.matrix);const b=a.a6.multiply([],h,x);if(r.meshes)for(const T of r.meshes){if("BLEND"!==T.material.alphaMode){g.push({mesh:T,depth:0,modelIndex:d,worldViewProjection:b,nodeModelMatrix:x});continue}const M=a.N.transformMat4([],T.centroid,b);M[2]>0&&f.push({mesh:T,depth:M[2],modelIndex:d,worldViewProjection:b,nodeModelMatrix:x})}if(r.children)for(const T of r.children)fa(c,T,o,h,d,f,g)}function le(c,r,o,h){const d=o.shadowRenderer;if(!d)return;const f=d.getShadowPassDepthMode(),g=d.getShadowPassColorMode(),x=d.calculateShadowPassMatrixFromMatrix(r),b=ha(x);o.getOrCreateProgram("modelDepth",{defines:o._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(o,o.context.gl.TRIANGLES,f,yt.disabled,g,pt.backCCW,b,h.id,c.vertexBuffer,c.indexBuffer,c.segments,h.paint,o.transform.zoom,void 0,void 0)}function rh(c,r,o){const h=r.updateZoomBasedPaintProperties(),d=function(f,g,x){let b,T,M,S=f.terrain?f.terrain.exaggeration():0;if(f.terrain&&S>0){const C=f.terrain,P=C.findDEMTileFor(x);P&&P.dem?b=a.cU.create(C,x,P):S=0}if(0===S&&(g.terrainElevationMin=0,g.terrainElevationMax=0),S===g.validForExaggeration&&(0===S||b&&b._demTile&&b._demTile.tileID===g.validForDEMTile.id&&b._dem._timestamp===g.validForDEMTile.timestamp))return!1;for(const C in g.instancesPerModel){const P=g.instancesPerModel[C];for(let k=0;k<P.instancedDataArray.length;++k){const R=(b?S*b.getElevationAt(0|P.instancedDataArray.float32[16*k],0|P.instancedDataArray.float32[16*k+1],!0,!0):0)+P.instancesEvaluatedElevation[k];P.instancedDataArray.float32[16*k+6]=R,T=T?Math.min(g.terrainElevationMin,R):R,M=M?Math.max(g.terrainElevationMax,R):R}}return g.terrainElevationMin=T||0,g.terrainElevationMax=M||0,g.validForExaggeration=S,g.validForDEMTile=b&&b._demTile?{id:b._demTile.tileID,timestamp:b._dem._timestamp}:{id:void 0,timestamp:0},!0}(c,r,o);(h||d)&&(r.uploaded=!1,r.upload(c.context))}const Vr={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new a.bS([0,0,0],[a.V,a.V,0])};function Au(c,r){const o=1<<c.canonical.z,h=r.getFreeCameraOptions().position,d=r.elevation,f=c.canonical.x/o,g=(c.canonical.x+1)/o,x=c.canonical.y/o,b=(c.canonical.y+1)/o;let T=r._centerAltitude;if(d){const P=d.getMinMaxForTile(c);P&&P.max>T&&(T=P.max)}const M=a.aa(h.x,f,g)-h.x,S=a.aa(h.y,x,b)-h.y,C=a.bl(T,r.center.lat)-h.z;return r._zoomFromMercatorZ(Math.sqrt(M*M+S*S+C*C))}function nh(c,r,o,h,d,f,g){const x=c.context,b="shadow"===c.renderPass,T=c.shadowRenderer,M=b&&T?T.getShadowPassDepthMode():new dt(x.gl.LEQUAL,dt.ReadWrite,c.depthRangeFor3D),S=c.isTileAffectedByFog(f);if(o.meshes)for(const C of o.meshes){const P=["MODEL_POSITION_ON_GPU"],k=[];let R,O,D;h.instancedDataArray.length>20&&P.push("INSTANCED_ARRAYS");const F=no(c,r.paint.get("model-cutoff-fade-range"));if(F.shouldRenderCutoff&&P.push("RENDER_CUTOFF"),b&&T)R=c.getOrCreateProgram("modelDepth",{defines:P}),O=ha(g.shadowTileMatrix,g.shadowTileMatrix,Float32Array.from(o.matrix)),D=T.getShadowPassColorMode();else{Ii(P,k,C,c),R=c.getOrCreateProgram("model",{defines:P,overrideFog:S});const V=C.material,q=V.pbrMetallicRoughness,B=r.paint.get("model-opacity"),$=r.paint.get("model-emissive-strength").constantOr(0);O=fl(f.expandedProjMatrix,Float32Array.from(o.matrix),new Float32Array(16),c,B,q.baseColorFactor,V.emissiveFactor,q.metallicFactor,q.roughnessFactor,V,$,r,d),T&&(g.shadowUniformsInitialized?R.setShadowUniformValues(x,T.getShadowUniformValues()):(T.setupShadows(f.toUnwrapped(),R,"model-tile",f.overscaledZ),g.shadowUniformsInitialized=!0)),D=F.shouldRenderCutoff||B<1||"OPAQUE"!==V.alphaMode?Rt.alphaBlended:Rt.unblended}c.uploadCommonUniforms(x,R,f.toUnwrapped(),null,F);const Z=C.material.doubleSided?pt.disabled:pt.backCCW;if(h.instancedDataArray.length>20)k.push(h.instancedDataBuffer),R.draw(c,x.gl.TRIANGLES,M,yt.disabled,D,Z,O,r.id,C.vertexBuffer,C.indexBuffer,C.segments,r.paint,c.transform.zoom,void 0,k,h.instancedDataArray.length);else{const V=b?"u_instance":"u_normal_matrix";for(let q=0;q<h.instancedDataArray.length;++q)O[V]=new Float32Array(h.instancedDataArray.arrayBuffer,64*q,16),R.draw(c,x.gl.TRIANGLES,M,yt.disabled,D,Z,O,r.id,C.vertexBuffer,C.indexBuffer,C.segments,r.paint,c.transform.zoom,void 0,k)}}if(o.children)for(const C of o.children)nh(c,r,C,h,d,f,g)}const Ms=[1,-1,1];function up(c,r,o,h){if(!o.modelManager)return!0;const d=o.modelManager;if(!o.shadowRenderer)return!0;const f=o.shadowRenderer,g=r.aabb;let x=!0,b=c.maxHeight;if(0===b){let M=0;for(const S in c.instancesPerModel){const C=d.getModel(S,h);C?M=Math.max(M,Math.max(Math.max(C.aabb.max[0],C.aabb.max[1]),C.aabb.max[2])):x=!1}b=c.maxScale*M*1.41+c.maxVerticalOffset,x&&(c.maxHeight=b)}g.max[2]=b,g.min[2]+=c.terrainElevationMin,g.max[2]+=c.terrainElevationMax,a.N.transformMat4(g.min,g.min,r.tileMatrix),a.N.transformMat4(g.max,g.max,r.tileMatrix);const T=g.intersects(f.getCurrentCascadeFrustum());return 0===o.currentShadowCascade&&(c.isInsideFirstShadowMapFrustum=2===T),0===T}class dp{}class Iu{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(r,o,h){{const S=this._storage.get(o.id);if(S)return S.lastUsedFrameIdx=r,S.buf}const d=h.gl,f=d.getBufferParameter(d.ELEMENT_ARRAY_BUFFER,d.BUFFER_SIZE),g=new ArrayBuffer(f),x=new Int16Array(g);d.getBufferSubData(d.ELEMENT_ARRAY_BUFFER,0,new Int16Array(g));const b=new a.cW;for(let S=0;S<f/2;S+=3){const C=x[S],P=x[S+1],k=x[S+2];b.emplaceBack(C,P),b.emplaceBack(P,k),b.emplaceBack(k,C)}const T=h.bindVertexArrayOES.current,M=new dp;return M.buf=new Di(h,b),M.lastUsedFrameIdx=r,this._storage.set(o.id,M),h.bindVertexArrayOES.set(T),M.buf}update(r){for(const[o,h]of this._storage)r-h.lastUsedFrameIdx>30&&(h.buf.destroy(),this._storage.delete(o))}destroy(){for(const[r,o]of this._storage)o.buf.destroy(),this._storage.delete(r)}}class ma{registerParameter(r,o,h,d,f){}registerButton(r,o,h){}}const _a={symbol:function(c,r,o,h,d){if("translucent"!==c.renderPass)return;const f=yt.disabled,g=c.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(T,M,S,C,P,k,R){const O=M.transform,D="map"===P,F="map"===k;for(const Z of T){const V=C.getTile(Z),q=V.getBucket(S);if(!q||!q.text||!q.text.segments.get().length)continue;const B=a.b5(q.textSizeData,O.zoom),$=Ks(Z,q.getProjection(),O),Y=O.calculatePixelsToTileUnitsMatrix(V),K=Xs($,V.tileID.canonical,F,D,O,q.getProjection(),Y),ee=q.hasIconTextFit()&&q.hasIconData();if(B){const ce=Math.pow(2,O.zoom-V.tileID.overscaledZ);wu(q,D,F,R,a.cx,O,K,Z,ce,B,ee)}}}(h,c,o,r,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d);const x=0!==o.paint.get("icon-opacity").constantOr(1),b=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(x||b)?ml(c,r,o,h,f,g):(x&&ml(c,r,o,h,f,g,{onlyIcons:!0}),b&&ml(c,r,o,h,f,g,{onlyText:!0})),r.map.showCollisionBoxes&&(ln(c,r,o,h,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),ln(c,r,o,h,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(c,r,o,h){if("translucent"!==c.renderPass)return;const d=o.paint.get("circle-opacity"),f=o.paint.get("circle-stroke-width"),g=o.paint.get("circle-stroke-opacity"),x=void 0!==o.layout.get("circle-sort-key").constantOr(1),b=o.paint.get("circle-emissive-strength");if(0===d.constantOr(1)&&(0===f.constantOr(1)||0===g.constantOr(1)))return;const T=c.context,M=T.gl,S=c.transform,C=c.depthModeForSublayer(0,dt.ReadOnly),P=yt.disabled,k=c.colorModeForDrapableLayerRenderPass(b),R="globe"===S.projection.name,O=[a.a5(S.center.lng),a.ae(S.center.lat)],D=[];for(let Z=0;Z<h.length;Z++){const V=h[Z],q=r.getTile(V),B=q.getBucket(o);if(!B||B.projection.name!==S.projection.name)continue;const $=B.programConfigurations.get(o.id),Y=a.cy(o),K=c.isTileAffectedByFog(V);R&&Y.push("PROJECTION_GLOBE_VIEW");const ee=c.getOrCreateProgram("circle",{config:$,defines:Y,overrideFog:K}),ce=B.layoutVertexBuffer,re=B.globeExtVertexBuffer,me=B.indexBuffer,pe=S.projection.createInversionMatrix(S,V.canonical),Ae={programConfiguration:$,program:ee,layoutVertexBuffer:ce,globeExtVertexBuffer:re,indexBuffer:me,uniformValues:a.cz(c,V,q,pe,O,o),tile:q};if(x){const ne=B.segments.get();for(const ue of ne)D.push({segments:new a.aB([ue]),sortKey:ue.sortKey,state:Ae})}else D.push({segments:B.segments,sortKey:0,state:Ae})}x&&D.sort((Z,V)=>Z.sortKey-V.sortKey);const F={useDepthForOcclusion:S.depthOcclusionForSymbolsAndCircles};for(const Z of D){const{programConfiguration:V,program:q,layoutVertexBuffer:B,globeExtVertexBuffer:$,indexBuffer:Y,uniformValues:K,tile:ee}=Z.state,ce=Z.segments;c.terrain&&c.terrain.setupElevationDraw(ee,q,F),c.uploadCommonUniforms(T,q,ee.tileID.toUnwrapped()),q.draw(c,M.TRIANGLES,C,P,k,pt.disabled,K,o.id,B,Y,ce,o.paint,S.zoom,V,[$])}},heatmap:function(c,r,o,h){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===c.renderPass){const d=c.context,f=d.gl,g=yt.disabled,x=new Rt([f.ONE,f.ONE,f.ONE,f.ONE],a.ax.transparent,[!0,!0,!0,!0]);(function(P,k,R,O){const D=P.gl,F=k.width*O,Z=k.height*O;P.activeTexture.set(D.TEXTURE1),P.viewport.set([0,0,F,Z]);let V=R.heatmapFbo;if(!V||V&&(V.width!==F||V.height!==Z)){V&&V.destroy();const q=D.createTexture();D.bindTexture(D.TEXTURE_2D,q),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_S,D.CLAMP_TO_EDGE),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_T,D.CLAMP_TO_EDGE),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,D.LINEAR),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,D.LINEAR),V=R.heatmapFbo=P.createFramebuffer(F,Z,!0,null),function(B,$,Y,K,ee,ce){const re=B.gl;re.texImage2D(re.TEXTURE_2D,0,B.extRenderToTextureHalfFloat?re.RGBA16F:re.RGBA,ee,ce,0,re.RGBA,B.extRenderToTextureHalfFloat?re.HALF_FLOAT:re.UNSIGNED_BYTE,null),K.colorAttachment.set(Y)}(P,0,q,V,F,Z)}else D.bindTexture(D.TEXTURE_2D,V.colorAttachment.get()),P.bindFramebuffer.set(V.framebuffer)})(d,c,o,"globe"===c.transform.projection.name?.5:.25),d.clear({color:a.ax.transparent});const b=c.transform,T="globe"===b.projection.name,M=T?["PROJECTION_GLOBE_VIEW"]:[],S=T?pt.frontCCW:pt.disabled,C=[a.a5(b.center.lng),a.ae(b.center.lat)];for(let P=0;P<h.length;P++){const k=h[P];if(r.hasRenderableParent(k))continue;const R=r.getTile(k),O=R.getBucket(o);if(!O||O.projection.name!==b.projection.name)continue;const D=c.isTileAffectedByFog(k),F=O.programConfigurations.get(o.id),Z=c.getOrCreateProgram("heatmap",{config:F,defines:M,overrideFog:D}),{zoom:V}=c.transform;c.terrain&&c.terrain.setupElevationDraw(R,Z),c.uploadCommonUniforms(d,Z,k.toUnwrapped());const q=b.projection.createInversionMatrix(b,k.canonical);Z.draw(c,f.TRIANGLES,dt.disabled,g,x,S,Gc(c,k,R,q,C,V,o.paint.get("heatmap-intensity")),o.id,O.layoutVertexBuffer,O.indexBuffer,O.segments,o.paint,c.transform.zoom,F,T?[O.globeExtVertexBuffer]:null)}d.viewport.set([0,0,c.width,c.height])}else"translucent"===c.renderPass&&(c.context.setColorMode(c.colorModeForRenderPass()),function(d,f){const g=d.context,x=g.gl,b=f.heatmapFbo;if(!b)return;g.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,b.colorAttachment.get()),g.activeTexture.set(x.TEXTURE1);let T=f.colorRampTexture;T||(T=f.colorRampTexture=new a.T(g,f.colorRamp,x.RGBA)),T.bind(x.LINEAR,x.CLAMP_TO_EDGE),d.getOrCreateProgram("heatmapTexture").draw(d,x.TRIANGLES,dt.disabled,yt.disabled,d.colorModeForRenderPass(),pt.disabled,{u_image:0,u_color_ramp:1,u_opacity:f.paint.get("heatmap-opacity")},f.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,f.paint,d.transform.zoom)}(c,o))},line:function(c,r,o,h){if("translucent"!==c.renderPass)return;const d=o.paint.get("line-opacity"),f=o.paint.get("line-width");if(0===d.constantOr(1)||0===f.constantOr(1))return;const g=o.paint.get("line-emissive-strength"),x=c.depthModeForSublayer(0,dt.ReadOnly),b=c.colorModeForDrapableLayerRenderPass(g),T=c.terrain&&c.terrain.renderingToTexture?1:a.f.devicePixelRatio,M=o.paint.get("line-dasharray"),S=M.constantOr(1),C=o.layout.get("line-cap"),P=o.paint.get("line-pattern"),k=P.constantOr(1),R=o.paint.get("line-pattern").constantOr(1),O=1!==o.paint.get("line-opacity").constantOr(1);let D=!R&&O;const F=o.paint.get("line-gradient"),Z=k?"linePattern":"line",V=c.context,q=V.gl,B=a.cA(o);c.terrain&&c.terrain.clipOrMaskOverlapStencilType()&&(D=!1);for(const $ of h){const Y=r.getTile($);if(k&&!Y.patternsLoaded())continue;const K=Y.getBucket(o);if(!K)continue;c.prepareDrawTile();const ee=K.programConfigurations.get(o.id),ce=c.isTileAffectedByFog($),re=c.getOrCreateProgram(Z,{config:ee,defines:B,overrideFog:ce}),me=P.constantOr(null);if(me&&Y.imageAtlas){const Re=Y.imageAtlas.patternPositions[me.toString()];Re&&ee.setConstantPatternPositions(Re)}const pe=M.constantOr(null),Ae=C.constantOr(null);if(!k&&pe&&Ae&&Y.lineAtlas){const Re=Y.lineAtlas.getDash(pe,Ae);Re&&ee.setConstantPatternPositions(Re)}let[ne,ue]=o.paint.get("line-trim-offset");("round"===Ae||"square"===Ae)&&ne!==ue&&(0===ne&&(ne-=1),1===ue&&(ue+=1));const Q=c.terrain?$.projMatrix:null,ae=k?a.cB(c,Y,o,Q,T,[ne,ue]):a.cC(c,Y,o,Q,K.lineClipsArray.length,T,[ne,ue]);if(F){const Re=K.gradients[o.id];let Le=Re.texture;if(o.gradientVersion!==Re.version){let je=256;if(o.stepInterpolant){const et=r.getSource().maxzoom,ct=$.canonical.z===et?Math.ceil(1<<c.transform.maxZoom-$.canonical.z):1;je=a.aa(a.cD(K.maxLineLength/a.V*1024*ct),256,V.maxTextureSize)}Re.gradient=a.cE({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:je,image:Re.gradient||void 0,clips:K.lineClipsArray}),Re.texture?Re.texture.update(Re.gradient):Re.texture=new a.T(V,Re.gradient,q.RGBA),Re.version=o.gradientVersion,Le=Re.texture}V.activeTexture.set(q.TEXTURE1),Le.bind(o.stepInterpolant?q.NEAREST:q.LINEAR,q.CLAMP_TO_EDGE)}S&&(V.activeTexture.set(q.TEXTURE0),Y.lineAtlasTexture&&Y.lineAtlasTexture.bind(q.LINEAR,q.REPEAT),ee.updatePaintBuffers()),k&&(V.activeTexture.set(q.TEXTURE0),Y.imageAtlasTexture&&Y.imageAtlasTexture.bind(q.LINEAR,q.CLAMP_TO_EDGE),ee.updatePaintBuffers()),c.uploadCommonUniforms(V,re,$.toUnwrapped());const Ie=Re=>{re.draw(c,q.TRIANGLES,x,Re,b,pt.disabled,ae,o.id,K.layoutVertexBuffer,K.indexBuffer,K.segments,o.paint,c.transform.zoom,ee,[K.layoutVertexBuffer2])};if(D){const Re=c.stencilModeForClipping($).ref;0===Re&&c.terrain&&V.clear({stencil:0});const Le={func:q.EQUAL,mask:255};ae.u_alpha_discard_threshold=.8,Ie(new yt(Le,Re,255,q.KEEP,q.KEEP,q.INVERT)),ae.u_alpha_discard_threshold=0,Ie(new yt(Le,Re,255,q.KEEP,q.KEEP,q.KEEP))}else Ie(c.stencilModeForClipping($))}D&&(c.resetStencilClippingMasks(),c.terrain&&V.clear({stencil:0}))},fill:function(c,r,o,h){const d=o.paint.get("fill-color"),f=o.paint.get("fill-opacity");if(0===f.constantOr(1))return;const g=o.paint.get("fill-emissive-strength"),x=c.colorModeForDrapableLayerRenderPass(g),b=o.paint.get("fill-pattern"),T=c.opaquePassEnabledForLayer()&&!b.constantOr(1)&&1===d.constantOr(a.ax.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(c.renderPass===T){const M=c.depthModeForSublayer(1,"opaque"===c.renderPass?dt.ReadWrite:dt.ReadOnly);No(c,r,o,h,M,x,!1)}if("translucent"===c.renderPass&&o.paint.get("fill-antialias")){const M=c.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,dt.ReadOnly);No(c,r,o,h,M,x,!0)}},"fill-extrusion":function(c,r,o,h){const d=o.paint.get("fill-extrusion-opacity"),f=c.context,g=f.gl,x=c.terrain,b=x&&x.renderingToTexture;if(0===d)return;const T=c.conflationActive&&c.layerUsedInConflation(o,r.getSource());if(T&&function(M,S,C,P){for(const k of P){const R=S.getTile(k).getBucket(C);R&&(R.updateReplacement(k,M.replacementSource),R.uploadCentroid(M.context))}}(c,r,o,h),x||T)for(const M of h){const S=r.getTile(M).getBucket(o);S&&lp(c.context,r,M,S,o,x,T)}if("shadow"===c.renderPass&&c.shadowRenderer){const M=c.shadowRenderer;if(x&&d<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof a.Z)return;const S=M.getShadowPassDepthMode(),C=M.getShadowPassColorMode();it(c,r,o,h,S,yt.disabled,C,T)}else if("translucent"===c.renderPass){const M=!o.paint.get("fill-extrusion-pattern").constantOr(1),S=o.paint.get("fill-extrusion-color").constantOr(a.ax.white);if(!b&&0!==S.a){const C=new dt(c.context.gl.LEQUAL,dt.ReadWrite,c.depthRangeFor3D);1===d&&M?it(c,r,o,h,C,yt.disabled,Rt.unblended,T):(it(c,r,o,h,C,yt.disabled,Rt.disabled,T),it(c,r,o,h,C,c.stencilModeFor3D(),c.colorModeForRenderPass(),T),c.resetStencilClippingMasks())}if(c.style.enable3dLights()&&M&&(!x&&"globe"!==c.transform.projection.name||b)){const C=o.paint.get("fill-extrusion-opacity"),P=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),k=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),R=o.paint.get("fill-extrusion-flood-light-intensity"),O=o.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),D=P>0&&k>0,F=R>0,Z=(q,B,$)=>(1-$)*q+$*B,V=q=>{const B=c.depthModeForSublayer(1,dt.ReadOnly,g.LEQUAL,!0),$=o.paint.get(q?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Y=Z(.1,3,$),K=c._showOverdrawInspector;if(!K){const ee=new yt({func:g.ALWAYS,mask:255},255,255,g.KEEP,g.KEEP,g.REPLACE),ce=new Rt([g.ONE,g.ONE,g.ONE,g.ONE],a.ax.transparent,[!1,!1,!1,!0],g.MIN);lo(c,r,o,h,B,ee,ce,pt.disabled,q,"sdf",C,P,k,R,O,Y,T,!1)}{const ee=K?yt.disabled:new yt({func:g.EQUAL,mask:255},255,255,g.KEEP,g.DECR,g.DECR),ce=K?c.colorModeForRenderPass():new Rt([g.ONE_MINUS_DST_ALPHA,g.DST_ALPHA,g.ONE,g.ONE],a.ax.transparent,[!0,!0,!0,!0]);lo(c,r,o,h,B,ee,ce,pt.disabled,q,"color",C,P,k,R,O,Y,T,!1)}};if(b){const q=(B,$,Y)=>{const K=c.depthModeForSublayer(1,dt.ReadOnly,g.LEQUAL,!1),ee=o.paint.get(B?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),ce=Z(.1,3,ee);{const re=new Rt([g.ONE,g.ONE,g.ONE,g.ONE],a.ax.transparent,[!1,!1,!1,!0]);lo(c,r,o,h,K,yt.disabled,re,pt.disabled,B,"clear",C,P,k,R,O,ce,T,$)}{const re=new yt({func:g.ALWAYS,mask:255},255,255,g.KEEP,g.KEEP,g.REPLACE),me=new Rt([g.ONE,g.ONE,g.ONE,g.ONE],a.ax.transparent,[!1,!1,!1,!0],g.MIN);lo(c,r,o,h,K,re,me,pt.disabled,B,"sdf",C,P,k,R,O,ce,T,$)}{const re=B?g.ZERO:g.ONE_MINUS_DST_ALPHA,me=new yt({func:g.EQUAL,mask:255},255,255,g.KEEP,g.DECR,g.DECR),pe=new Rt([re,g.DST_ALPHA,g.ONE_MINUS_DST_ALPHA,g.ZERO],a.ax.transparent,[!0,!0,!0,!0]);lo(c,r,o,h,K,me,pe,pt.disabled,B,"color",C,P,k,R,O,ce,T,$)}{const re=new Rt([g.ONE,g.ONE,g.ONE,B?g.ZERO:g.ONE],a.ax.transparent,[!1,!1,!1,!0],B?g.FUNC_ADD:g.MAX);lo(c,r,o,h,K,yt.disabled,re,pt.disabled,B,"clear",C,P,k,R,O,ce,T,$,Y)}};if(D||F){let B;if(c.prepareDrawTile(),x){const $=x.drapeBufferSize[0],Y=x.drapeBufferSize[1];B=x.framebufferCopyTexture,B&&(!B||B.size[0]===$&&B.size[1]===Y)||(B&&B.destroy(),B=x.framebufferCopyTexture=new a.T(f,new a.h({width:$,height:Y}),g.RGBA)),B.bind(g.LINEAR,g.CLAMP_TO_EDGE),g.copyTexImage2D(g.TEXTURE_2D,0,g.RGBA,0,0,$,Y,0)}D&&q(!0,!1,B),F&&q(!1,!0,B)}}else D&&V(!0),F&&V(!1)}}},hillshade:function(c,r,o,h){if("offscreen"!==c.renderPass&&"translucent"!==c.renderPass||c.style.disableElevatedTerrain)return;const d=c.context,f=c.terrain&&c.terrain.renderingToTexture,[g,x]="translucent"!==c.renderPass||f?[{},h]:c.stencilConfigForOverlap(h);for(const b of x){const T=r.getTile(b);if(T.needsHillshadePrepare&&"offscreen"===c.renderPass)Pc(c,T,o);else if("translucent"===c.renderPass){const M=c.depthModeForSublayer(0,dt.ReadOnly),S=o.paint.get("hillshade-emissive-strength"),C=c.colorModeForDrapableLayerRenderPass(S),P=f&&c.terrain?c.terrain.stencilModeForRTTOverlap(b):g[b.overscaledZ];ll(c,b,T,o,M,P,C)}}d.viewport.set([0,0,c.width,c.height]),c.resetStencilClippingMasks()},raster:function(c,r,o,h,d,f){if("translucent"!==c.renderPass||0===o.paint.get("raster-opacity"))return;const g="globe"===c.transform.projection.name,x=0!==o.paint.get("raster-elevation"),b=x&&g;if(c.renderElevatedRasterBackface&&!b)return;const T=c.context,M=T.gl,S=r.getSource(),C=function(B,$,Y,K){const ee=$.paint.get("raster-color"),ce="raster-array"===B.type,re=[],me=$.paint.get("raster-resampling"),pe=$.paint.get("raster-color-mix");let Ae=$.paint.get("raster-color-range");const ne=[pe[0],pe[1],pe[2],0],ue=pe[3];let Q="nearest"===me?K.NEAREST:K.LINEAR;if(ce&&(re.push("RASTER_ARRAY"),ee||re.push("RASTER_COLOR"),"linear"===me&&re.push("RASTER_ARRAY_LINEAR"),Q=K.NEAREST,!Ae&&B.rasterLayers)){const ae=B.rasterLayers.find(({id:Ie})=>Ie===$.sourceLayer);ae&&ae.fields&&ae.fields.range&&(Ae=ae.fields.range)}if(Ae=Ae||[0,1],ee){re.push("RASTER_COLOR"),Y.activeTexture.set(K.TEXTURE2),$.updateColorRamp(Ae);let ae=$.colorRampTexture;ae||(ae=$.colorRampTexture=new a.T(Y,$.colorRamp,K.RGBA)),ae.bind(K.LINEAR,K.CLAMP_TO_EDGE)}return{mix:ne,range:Ae,offset:ue,defines:re,resampling:Q}}(S,o,T,M);if(S instanceof a.ap&&!h.length&&!g)return;const P=o.paint.get("raster-emissive-strength"),k=c.colorModeForDrapableLayerRenderPass(P),R=c.terrain&&c.terrain.renderingToTexture,O=!c.options.moving,D="nearest"===o.paint.get("raster-resampling")?M.NEAREST:M.LINEAR;if(S instanceof a.ap&&!h.length&&(S.onNorthPole||S.onSouthPole)){const B=x?c.stencilModeFor3D():yt.disabled;return void Wc(!!S.onNorthPole,null,c,r,o,P,C,pt.disabled,B)}if(!h.length)return;const[F,Z]=S instanceof a.ap||R?[{},h]:c.stencilConfigForOverlap(h),V=Z[Z.length-1].overscaledZ;b&&C.defines.push("PROJECTION_GLOBE_VIEW"),x&&C.defines.push("RENDER_CUTOFF");const q=(B,$,Y)=>{for(const K of B){const ee=K.toUnwrapped(),ce=r.getTile(K);if(R&&(!ce||!ce.hasData()))continue;T.activeTexture.set(M.TEXTURE0);const re=Xc(ce,S,o,C);if(!re||!re.texture)continue;const{texture:me,mix:pe,offset:Ae,tileSize:ne,buffer:ue}=re;let Q,ae;R?(Q=dt.disabled,ae=K.projMatrix):x?(Q=new dt(M.LEQUAL,dt.ReadWrite,c.depthRangeFor3D),ae=g?Float32Array.from(c.transform.expandedFarZProjMatrix):c.transform.calculateProjMatrix(ee,O)):(Q=c.depthModeForSublayer(K.overscaledZ-V,1===o.paint.get("raster-opacity")?dt.ReadWrite:dt.ReadOnly,M.LESS),ae=c.transform.calculateProjMatrix(ee,O));const Ie=c.terrain&&R?c.terrain.stencilModeForRTTOverlap(K):F[K.overscaledZ],Re=f?0:o.paint.get("raster-fade-duration");ce.registerFadeDuration(Re);const Le=r.findLoadedParent(K,0),je=Rc(ce,Le,r,c.transform,Re);let et,ct;c.terrain&&c.terrain.prepareDrawTile(),T.activeTexture.set(M.TEXTURE0),me.bind(D,M.CLAMP_TO_EDGE),T.activeTexture.set(M.TEXTURE1),Le?(Le.texture&&Le.texture.bind(D,M.CLAMP_TO_EDGE),et=Math.pow(2,Le.tileID.overscaledZ-ce.tileID.overscaledZ),ct=[ce.tileID.canonical.x*et%1,ce.tileID.canonical.y*et%1]):me.bind(D,M.CLAMP_TO_EDGE),me.useMipmap&&T.extTextureFilterAnisotropic&&c.transform.pitch>20&&M.texParameterf(M.TEXTURE_2D,T.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,T.extTextureFilterAnisotropicMax);const nt=c.transform;let at;const Et=x?Hc(nt):[0,0,0,0];let gt,bt,vt,Zt,_i,Ot=0;if(b&&S instanceof a.ap&&S.coordinates.length>3)gt=Float32Array.from(a.aT(a.ci(new a.bs(0,0,0)))),bt=Float32Array.from(nt.globeMatrix),vt=Float32Array.from(a.ce(nt)),Zt=[a.a5(nt.center.lng),a.ae(nt.center.lat)],at=S.elevatedGlobePerspectiveTransform,_i=S.elevatedGlobeGridMatrix||new Float32Array(9);else if(b){const Ft=a.cf(K.canonical);Ot=a.cg(Ft.getCenter().lat),gt=Float32Array.from(a.aT(a.ci(K.canonical))),bt=Float32Array.from(nt.globeMatrix),vt=Float32Array.from(a.ce(nt)),Zt=[a.a5(nt.center.lng),a.ae(nt.center.lat)],at=[0,0],_i=Float32Array.from(a.ch(K.canonical,Ft,Ot,nt.worldSize/nt._pixelsPerMercatorPixel))}else at=S instanceof a.ap?S.perspectiveTransform:[0,0],gt=new Float32Array(16),bt=new Float32Array(9),vt=new Float32Array(16),Zt=[0,0],_i=new Float32Array(9);const Ci=Zc(ae,gt,bt,vt,_i,ct||[0,0],a.S(c.transform.zoom),Zt,Et,et||1,je,o,at,x?o.paint.get("raster-elevation"):0,2,pe,Ae,C.range,ne,ue,P),Bt=c.isTileAffectedByFog(K),Kt=c.getOrCreateProgram("raster",{defines:C.defines,overrideFog:Bt});if(c.uploadCommonUniforms(T,Kt,ee),S instanceof a.ap){const Ft=S.elevatedGlobeVertexBuffer,Yt=S.elevatedGlobeIndexBuffer;if(R||!g)S.boundsBuffer&&S.boundsSegments&&Kt.draw(c,M.TRIANGLES,Q,yt.disabled,k,pt.disabled,Ci,o.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments);else if(Ft&&Yt){const yi=nt.zoom<=a.bG?S.elevatedGlobeSegments:S.getSegmentsForLongitude(nt.center.lng);yi&&Kt.draw(c,M.TRIANGLES,Q,yt.disabled,k,$,Ci,o.id,Ft,Yt,yi)}}else if(b){Q=new dt(M.LEQUAL,dt.ReadOnly,c.depthRangeFor3D);const Ft=c.globeSharedBuffers;if(Ft){const[Yt,yi,ii]=Ft.getGridBuffers(Ot,!1);Kt.draw(c,M.TRIANGLES,Q,Y||Ie,c.colorModeForRenderPass(),$,Ci,o.id,Yt,yi,ii)}}else{const{tileBoundsBuffer:Ft,tileBoundsIndexBuffer:Yt,tileBoundsSegments:yi}=c.getTileBoundsBuffers(ce);Kt.draw(c,M.TRIANGLES,Q,Ie,k,pt.disabled,Ci,o.id,Ft,Yt,yi)}}if(!(S instanceof a.ap)&&b)for(const K of B){const ee=K.canonical.y===(1<<K.canonical.z)-1;0===K.canonical.y&&Wc(!0,K,c,r,o,P,C,$,Y||yt.disabled),ee&&Wc(!1,K,c,r,o,P,C,$===pt.frontCW?pt.backCW:pt.frontCW,Y||yt.disabled)}};b?q(Z,c.renderElevatedRasterBackface?pt.backCW:pt.frontCW,c.stencilModeFor3D()):q(Z,pt.disabled,void 0),c.resetStencilClippingMasks()},"raster-particle":function(c,r,o,h,d,f){"offscreen"===c.renderPass&&function(g,x,b,T){if(!T.length)return;const M=g.context,S=M.gl,C=x.getSource();if(!(C instanceof Be))return;const P=[];for(const O of T){const D=x.getTile(O);if(!(D instanceof zo))continue;const F=Yc(D,C,b);if(!F)continue;const Z=[F.tileSize,F.tileSize];let V=b.tileFramebuffer;V||(V=b.tileFramebuffer=M.createFramebuffer(Z[0],Z[1],!0,null));let q=D.rasterParticleState;const B=b.paint.get("raster-particle-count");q||(q=D.rasterParticleState=new $i(M,O,Z,B));const $=q.update(b.lastInvalidatedAt);q.numParticles!==B&&q.setNumParticles(O,B);const Y=q.targetColorTexture;q.targetColorTexture=q.backgroundColorTexture,q.backgroundColorTexture=Y;const K=q.particleVertices0;q.particleVertices0=q.particleVertices1,q.particleVertices1=K,P.push([O,F,q,$])}if(0===P.length)return;const k=a.f.now(),R=b.previousDrawTimestamp?.001*(k-b.previousDrawTimestamp):.0167;if(b.previousDrawTimestamp=k,b.hasColorMap()){M.activeTexture.set(S.TEXTURE0+2);let O=b.colorRampTexture;O||(O=b.colorRampTexture=new a.T(M,b.colorRamp,S.RGBA)),O.bind(S.LINEAR,S.CLAMP_TO_EDGE)}M.bindFramebuffer.set(b.tileFramebuffer.framebuffer),M.activeTexture.set(S.TEXTURE0),function(O,D,F){const Z=O.context,V=Z.gl,q=D.tileFramebuffer;Z.activeTexture.set(V.TEXTURE0);const B={u_texture:0,u_opacity:1.05*(Y=D.paint.get("raster-particle-fade-opacity-factor"))/(Y+.05)},$=O.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var Y;for(const K of F){const[,,ee,ce]=K;q.colorAttachment.set(ee.targetColorTexture.texture),Z.viewport.set([0,0,q.width,q.height]),Z.clear({color:a.ax.transparent}),ce&&(ee.backgroundColorTexture.bind(V.NEAREST,V.CLAMP_TO_EDGE),$.draw(O,V.TRIANGLES,dt.disabled,yt.disabled,Rt.alphaBlended,pt.disabled,B,D.id,O.viewportBuffer,O.quadTriangleIndexBuffer,O.viewportSegments))}}(g,b,P),function(O,D,F,Z){const V=O.context.gl,q=F.tileFramebuffer,B="globe"===O.transform.projection.name,$=F.paint.get("raster-particle-max-speed");for(const Y of Z){const[K,ee,ce]=Y;ee.texture.bind(V.LINEAR,V.CLAMP_TO_EDGE),q.colorAttachment.set(ce.targetColorTexture.texture);const re=O.getOrCreateProgram("rasterParticleDraw",{defines:ee.defines,overrideFog:!1}),me=ee.scalarData?[]:[0,1,2,3].map(ne=>a.cG[ne](K));me.push(K);const pe=K.canonical.x,Ae=K.canonical.y;for(const ne of me){const ue=D.getTile(B?ne.wrapped():ne);if(!ue)continue;const Q=ue.rasterParticleState;if(!Q)continue;const ae=sp([ne.canonical.x+(1<<ne.canonical.z)*(ne.wrap-K.wrap)-pe,ne.canonical.y-Ae],0,ee.texture.size,2,$,ee.textureOffset,ee.scale,ee.offset);re.draw(O,V.POINTS,dt.disabled,yt.disabled,Rt.alphaBlended,pt.disabled,ae,F.id,Q.particleVertices0,void 0,Q.particleSegment)}}}(g,x,b,P),function(O,D,F,Z){const V=O.context.gl;let q=D.transformFeedbackObject;q||(q=D.transformFeedbackObject=V.createTransformFeedback()),V.bindTransformFeedback(V.TRANSFORM_FEEDBACK,D.transformFeedbackObject);const B=D.paint.get("raster-particle-max-speed"),$=Z*D.paint.get("raster-particle-speed-factor")*.3,Y=(K=D.paint.get("raster-particle-reset-rate-factor"),Math.pow(K,6));var K;for(const ee of F){const[,ce,re]=ee;ce.texture.bind(V.LINEAR,V.CLAMP_TO_EDGE);const me=vu(0,ce.texture.size,B,$,Y,ce.textureOffset,ce.scale,ce.offset);O.getOrCreateProgram("rasterParticleUpdate",{defines:ce.defines,transformFeedback:{bufferMode:V.SEPARATE_ATTRIBS,shaderVaryings:["v_new_particle"]}}).draw(O,V.POINTS,dt.disabled,yt.disabled,Rt.disabled,pt.disabled,me,D.id,re.particleVertices0,void 0,re.particleSegment,{},void 0,void 0,void 0,void 0,[{buffer:re.particleVertices1,targetIndex:0}])}V.bindTransformFeedback(V.TRANSFORM_FEEDBACK,null)}(g,b,P,R)}(c,r,o,h),"translucent"===c.renderPass&&(function(g,x,b,T){const S=g.context,C=S.gl,P=!g.options.moving,k="globe"===g.transform.projection.name;if(!T.length)return;const[R,O]=g.stencilConfigForOverlap(T),D=[];k&&D.push("PROJECTION_GLOBE_VIEW");for(const F of O){const Z=F.toUnwrapped(),V=x.getTile(F);if(!V.rasterParticleState)continue;const q=V.rasterParticleState,B=100;V.registerFadeDuration(B);const $=x.findLoadedParent(F,0),Y=Rc(V,$,x,g.transform,B);let K,ee;g.terrain&&g.terrain.prepareDrawTile(),S.activeTexture.set(C.TEXTURE0),q.targetColorTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE),S.activeTexture.set(C.TEXTURE1),$&&$.rasterParticleState?($.rasterParticleState.targetColorTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE),K=Math.pow(2,$.tileID.overscaledZ-V.tileID.overscaledZ),ee=[V.tileID.canonical.x*K%1,V.tileID.canonical.y*K%1]):q.targetColorTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE);const ce=k?Float32Array.from(g.transform.expandedFarZProjMatrix):g.transform.calculateProjMatrix(Z,P),re=g.transform,me=Kc(re),pe=a.cf(F.canonical),Ae=a.cg(pe.getCenter().lat);let ne,ue,Q,ae,Ie;k?(ne=Float32Array.from(a.aT(a.ci(F.canonical))),ue=Float32Array.from(re.globeMatrix),Q=Float32Array.from(a.ce(re)),ae=[a.a5(re.center.lng),a.ae(re.center.lat)],Ie=Float32Array.from(a.ch(F.canonical,pe,Ae,re.worldSize/re._pixelsPerMercatorPixel))):(ne=new Float32Array(16),ue=new Float32Array(9),Q=new Float32Array(16),ae=[0,0],Ie=new Float32Array(9));const Re=op(ce,ne,ue,Q,Ie,ee||[0,0],a.S(g.transform.zoom),ae,me,K||1,Y,250),Le=g.isTileAffectedByFog(F),je=g.getOrCreateProgram("rasterParticle",{defines:D,overrideFog:Le});if(g.uploadCommonUniforms(S,je,Z),k){const et=new dt(C.LEQUAL,dt.ReadWrite,g.depthRangeFor3D),ct=0,nt=g.globeSharedBuffers;if(nt){const[at,Et,gt]=nt.getGridBuffers(Ae,0!==ct);je.draw(g,C.TRIANGLES,et,yt.disabled,Rt.alphaBlended,pt.backCCW,Re,b.id,at,Et,gt)}}else{const et=g.depthModeForSublayer(0,dt.ReadOnly),ct=R[F.overscaledZ],{tileBoundsBuffer:nt,tileBoundsIndexBuffer:at,tileBoundsSegments:Et}=g.getTileBoundsBuffers(V);je.draw(g,C.TRIANGLES,et,ct,Rt.alphaBlended,pt.disabled,Re,b.id,nt,at,Et)}}g.resetStencilClippingMasks()}(c,r,o,h),c.style.map.triggerRepaint())},background:function(c,r,o,h){const d=o.paint.get("background-color"),f=o.paint.get("background-opacity"),g=o.paint.get("background-emissive-strength");if(0===f)return;const x=c.context,b=x.gl,T=c.transform,M=T.tileSize,S=o.paint.get("background-pattern");if(c.isPatternMissing(S,o.scope))return;const C=!S&&1===d.a&&1===f&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==C)return;const P=yt.disabled,k=c.depthModeForSublayer(0,"opaque"===C?dt.ReadWrite:dt.ReadOnly),R=c.colorModeForDrapableLayerRenderPass(g),O=S?"backgroundPattern":"background";let D,F=h;F||(D=c.getBackgroundTiles(),F=Object.values(D).map(Z=>Z.tileID)),S&&(x.activeTexture.set(b.TEXTURE0),c.imageManager.bind(c.context,o.scope));for(const Z of F){const V=c.isTileAffectedByFog(Z),q=c.getOrCreateProgram(O,{overrideFog:V}),B=Z.toUnwrapped(),$=h?Z.projMatrix:c.transform.calculateProjMatrix(B);c.prepareDrawTile();const Y=r?r.getTile(Z):D?D[Z.key]:new Jn(Z,M,T.zoom,c),K=S?la($,g,f,c,S,o.scope,{tileID:Z,tileSize:M}):qc($,g,f,d);c.uploadCommonUniforms(x,q,B);const{tileBoundsBuffer:ee,tileBoundsIndexBuffer:ce,tileBoundsSegments:re}=c.getTileBoundsBuffers(Y);q.draw(c,b.TRIANGLES,k,P,R,pt.disabled,K,o.id,ee,ce,re)}},sky:function(c,r,o){const h=c._atmosphere?a.S(c.transform.zoom):1,d=o.paint.get("sky-opacity")*h;if(0===d)return;const f=c.context,g=o.paint.get("sky-type"),x=new dt(f.gl.LEQUAL,dt.ReadOnly,[0,1]),b=c.frameCounter/1e3%1;"atmosphere"===g?"offscreen"===c.renderPass?o.needsSkyboxCapture(c)&&(function(T,M){const P=T.context,k=P.gl;let R=M.skyboxFbo;if(!R){R=M.skyboxFbo=P.createFramebuffer(32,32,!0,null),M.skyboxGeometry=new ih(P),M.skyboxTexture=P.gl.createTexture(),k.bindTexture(k.TEXTURE_CUBE_MAP,M.skyboxTexture),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_MIN_FILTER,k.LINEAR),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_MAG_FILTER,k.LINEAR);for(let Z=0;Z<6;++Z)k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,k.RGBA,32,32,0,k.RGBA,k.UNSIGNED_BYTE,null)}P.bindFramebuffer.set(R.framebuffer),P.viewport.set([0,0,32,32]);const O=M.getCenter(T,!0),D=T.getOrCreateProgram("skyboxCapture"),F=new Float64Array(16);a.a6.identity(F),a.a6.rotateY(F,F,.5*-Math.PI),Vo(T,M,D,F,O,0),a.a6.identity(F),a.a6.rotateY(F,F,.5*Math.PI),Vo(T,M,D,F,O,1),a.a6.identity(F),a.a6.rotateX(F,F,.5*-Math.PI),Vo(T,M,D,F,O,2),a.a6.identity(F),a.a6.rotateX(F,F,.5*Math.PI),Vo(T,M,D,F,O,3),a.a6.identity(F),Vo(T,M,D,F,O,4),a.a6.identity(F),a.a6.rotateY(F,F,Math.PI),Vo(T,M,D,F,O,5),P.viewport.set([0,0,T.width,T.height])}(c,o),o.markSkyboxValid(c)):"sky"===c.renderPass&&function(T,M,S,C,P){const k=T.context,R=k.gl,O=T.transform,D=T.getOrCreateProgram("skybox");k.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_CUBE_MAP,M.skyboxTexture);const F=((Z,V,q,B,$)=>({u_matrix:Z,u_sun_direction:V,u_cubemap:0,u_opacity:B,u_temporal_offset:$}))(O.skyboxMatrix,M.getCenter(T,!1),0,C,P);T.uploadCommonUniforms(k,D),D.draw(T,R.TRIANGLES,S,yt.disabled,T.colorModeForRenderPass(),pt.backCW,F,"skybox",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(c,o,x,d,b):"gradient"===g&&"sky"===c.renderPass&&function(T,M,S,C,P){const k=T.context,R=k.gl,O=T.transform,D=T.getOrCreateProgram("skyboxGradient");M.skyboxGeometry||(M.skyboxGeometry=new ih(k)),k.activeTexture.set(R.TEXTURE0);let F=M.colorRampTexture;F||(F=M.colorRampTexture=new a.T(k,M.colorRamp,R.RGBA)),F.bind(R.LINEAR,R.CLAMP_TO_EDGE);const Z=(V=O.skyboxMatrix,q=M.getCenter(T,!1),B=M.paint.get("sky-gradient-radius"),$=C,Y=P,{u_matrix:V,u_color_ramp:0,u_center_direction:q,u_radius:a.bj(B),u_opacity:$,u_temporal_offset:Y});var V,q,B,$,Y;T.uploadCommonUniforms(k,D),D.draw(T,R.TRIANGLES,S,yt.disabled,T.colorModeForRenderPass(),pt.backCW,Z,"skyboxGradient",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(c,o,x,d,b)},debug:function(c,r,o,h,d,f){for(let g=0;g<o.length;g++)if(d){const T=new a.ax(.8*h.r,.8*h.g,.8*h.b,1);ho(c,r,o[g],h,-1,-1,f),ho(c,r,o[g],h,-1,1,f),ho(c,r,o[g],h,1,1,f),ho(c,r,o[g],h,1,-1,f),ho(c,r,o[g],T,0,0,f)}else ho(c,r,o[g],h,0,0,f)},custom:function(c,r,o,h){const d=c.context,f=o.implementation;if(!c.transform.projection.unsupportedLayers||!c.transform.projection.unsupportedLayers.includes("custom")||c.terrain&&(c.terrain.renderingToTexture||"offscreen"===c.renderPass)&&o.isLayerDraped(r)){if("offscreen"===c.renderPass){const g=f.prerender;if(g){if(c.setCustomLayerDefaults(),d.setColorMode(c.colorModeForRenderPass()),"globe"===c.transform.projection.name){const x=c.transform.pointMerc;g.call(f,d.gl,c.transform.customLayerMatrix(),c.transform.getProjection(),c.transform.globeToMercatorMatrix(),a.S(c.transform.zoom),[x.x,x.y],c.transform.pixelsPerMeterRatio)}else g.call(f,d.gl,c.transform.customLayerMatrix());d.setDirty(),c.setBaseState()}}else if("translucent"===c.renderPass){if(c.terrain&&c.terrain.renderingToTexture){const x=f.renderToTile;if(x){const b=h[0].canonical,T=new a.L(b.x+h[0].wrap*(1<<b.z),b.y,b.z);d.setDepthMode(dt.disabled),d.setStencilMode(yt.disabled),d.setColorMode(c.colorModeForRenderPass()),c.setCustomLayerDefaults(),x.call(f,d.gl,T),d.setDirty(),c.setBaseState()}return}c.setCustomLayerDefaults(),d.setColorMode(c.colorModeForRenderPass()),d.setStencilMode(yt.disabled);const g="3d"===f.renderingMode?new dt(c.context.gl.LEQUAL,dt.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,dt.ReadOnly);if(d.setDepthMode(g),"globe"===c.transform.projection.name){const x=c.transform.pointMerc;f.render(d.gl,c.transform.customLayerMatrix(),c.transform.getProjection(),c.transform.globeToMercatorMatrix(),a.S(c.transform.zoom),[x.x,x.y],c.transform.pixelsPerMeterRatio)}else f.render(d.gl,c.transform.customLayerMatrix());d.setDirty(),c.setBaseState(),d.bindFramebuffer.set(null)}}else a.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(c,r,o,h){if("opaque"===c.renderPass)return;const d=o.paint.get("model-opacity");if(0===d)return;const f=o.paint.get("model-cast-shadows");if("shadow"===c.renderPass&&(!f||c.terrain&&d<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof a.Z))return;const g=c.shadowRenderer,x=o.paint.get("model-receive-shadows");g&&(g.useNormalOffset=!0,x||(g.enabled=!1));const b=()=>{g&&(g.useNormalOffset=!0,x||(g.enabled=!0))},T=r.getSource();if("light-beam"===c.renderPass&&"batched-model"!==T.type)return;if("vector"===T.type||"geojson"===T.type)return function(D,F,Z,V){const q=D.transform;if("mercator"!==q.projection.name)return void a.w(`Drawing 3D models for ${q.projection.name} projection is not yet implemented`);const B=q.getFreeCameraOptions().position;if(!D.modelManager)return;const $=D.modelManager;Z.modelManager=$;const Y=D.shadowRenderer;if(!Z._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const K=Z._unevaluatedLayout._values["model-id"],ee={...Z.layout.get("model-id").parameters};for(const ce of V){const re=F.getTile(ce).getBucket(Z);if(!re||re.projection.name!==q.projection.name)continue;const me=Au(ce,q);ee.zoom=me;const pe=K.possiblyEvaluate(ee);if(rh(D,re,ce),Vr.shadowUniformsInitialized=!1,Vr.useSingleShadowCascade=!!Y&&0===Y.getMaxCascadeForTile(ce.toUnwrapped()),"shadow"===D.renderPass&&Y){if(1===D.currentShadowCascade&&re.isInsideFirstShadowMapFrustum)continue;const ue=q.calculatePosMatrix(ce.toUnwrapped(),q.worldSize);if(Vr.tileMatrix.set(ue),Vr.shadowTileMatrix=Float32Array.from(Y.calculateShadowPassMatrixFromMatrix(ue)),Vr.aabb.min.fill(0),Vr.aabb.max[0]=Vr.aabb.max[1]=a.V,Vr.aabb.max[2]=0,up(re,Vr,D,Z.scope))continue}const Ae=1<<ce.canonical.z,ne=[((B.x-ce.wrap)*Ae-ce.canonical.x)*a.V,(B.y*Ae-ce.canonical.y)*a.V,B.z*Ae*a.V];for(let ue in re.instancesPerModel){const Q=re.instancesPerModel[ue];Q.features.length>0&&(ue=pe.evaluate(Q.features[0].feature,{}));const ae=$.getModel(ue,Z.scope);if(ae&&ae.uploaded)for(const Ie of ae.nodes)nh(D,Z,Ie,Q,ne,ce,Vr)}}}(c,r,o,h),void b();if(!T.loaded())return;if("batched-model"===T.type)return function(D,F,Z,V){Z.resetLayerRenderingStats(D);const q=D.context,B=D.transform,$=D.style.fog,Y=D.shadowRenderer;if("mercator"!==B.projection.name)return void a.w(`Drawing 3D landmark models for ${B.projection.name} projection is not yet implemented`);const K=D.transform.getFreeCameraOptions().position,ee=a.N.scale([],[K.x,K.y,K.z],D.transform.worldSize);a.N.negate(ee,ee);const ce=a.a6.identity([]),re=a.cR(B.center.lat,B.zoom),me=a.a6.fromScaling([],[1,1,1/re]);a.a6.translate(ce,ce,ee);const pe=Z.paint.get("model-opacity"),Ae=new dt(q.gl.LEQUAL,dt.ReadWrite,D.depthRangeFor3D),ne=new dt(q.gl.LEQUAL,dt.ReadOnly,D.depthRangeFor3D),ue=new a.bS([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Q="shadow"===D.renderPass,ae=Q&&Y?Y.getCurrentCascadeFrustum():B.getFrustum(B.scaleZoom(B.worldSize)),Ie=Z.getLayerRenderingStats(),Re=function(Le,je){for(const et of V){const ct=F.getTile(et).getBucket(Z);if(!ct||!ct.uploaded)continue;let nt=!1;Y&&(nt=0===Y.getMaxCascadeForTile(et.toUnwrapped()));const at=B.calculatePosMatrix(et.toUnwrapped(),B.worldSize),Et=ct.modelTraits;for(const gt of ct.getNodesInfo()){if(gt.hiddenByReplacement||!gt.node.meshes)continue;const bt=gt.evaluatedScale,vt=gt.node;let Zt=0;if(D.terrain&&vt.elevation&&(Zt=vt.elevation*D.terrain.exaggeration()),bt[0]<=1&&bt[1]<=1&&bt[2]<=1&&0===(()=>{const yi=gt.getLocalBounds();return ue.min=[...yi.min],ue.max=[...yi.max],ue.min[2]+=Zt,ue.max[2]+=Zt,a.N.transformMat4(ue.min,ue.min,at),a.N.transformMat4(ue.max,ue.max,at),ue})().intersects(ae))continue;const _i="light-beam"===D.renderPass,Ot=[...at];a.a6.translate(Ot,Ot,[(vt.anchor?vt.anchor[0]:0)*(bt[0]-1),(vt.anchor?vt.anchor[1]:0)*(bt[1]-1),Zt]),a.N.exactEquals(bt,a.cT)||a.a6.scale(Ot,Ot,bt),a.a6.multiply(Ot,Ot,vt.matrix);const Ci=a.a6.multiply([],me,Ot);a.a6.multiply(Ci,ce,Ci);const Bt=a.a6.invert([],Ci);a.a6.transpose(Bt,Bt),a.a6.scale(Bt,Bt,Ms);const Kt=a.a6.multiply([],B.expandedFarZProjMatrix,Ot),Ft=Et&a.cV.HasMapboxMeshFeatures,Yt=Ft?0:gt.evaluatedRMEA[0][2];for(let yi=0;yi<vt.meshes.length;++yi){const ii=vt.meshes[yi],Qi=yi===vt.lightMeshIndex;if(Qi){if(!_i&&!D.terrain&&D.shadowRenderer){D.currentLayer<D.firstLightBeamLayer&&(D.firstLightBeamLayer=D.currentLayer);continue}}else if(_i)continue;const hr={defines:[]},Pr=[];if(Ii(hr.defines,Pr,ii,D),Ft||hr.defines.push("DIFFUSE_SHADED"),nt&&hr.defines.push("SHADOWS_SINGLE_CASCADE"),Ie&&(Q?Ie.numRenderedVerticesInShadowPass+=ii.vertexArray.length:Ie.numRenderedVerticesInTransparentPass+=ii.vertexArray.length),Q){le(ii,Ot,D,Z);continue}let bn=null;if($){const Dr=Uo(Ot,D.transform);if(bn=new Float32Array(Dr),"globe"!==B.projection.name){const wn=ii.aabb.min,_o=ii.aabb.max,[Go,Pa]=$.getOpacityForBounds(Dr,wn[0],wn[1],_o[0],_o[1]);hr.overrideFog=Go>=ai||Pa>=ai}}const zr=ii.material;let er;zr.occlusionTexture&&zr.occlusionTexture.offsetScale&&(er=zr.occlusionTexture.offsetScale,hr.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!Q&&Y&&(Y.useNormalOffset=!!ii.normalBuffer);const Hi=D.getOrCreateProgram("model",hr);!Q&&Y&&Y.setupShadowsFromMatrix(Ot,Hi,Y.useNormalOffset),D.uploadCommonUniforms(q,Hi,et.toUnwrapped(),bn);const yr=zr.pbrMetallicRoughness;yr.metallicFactor=.9,yr.roughnessFactor=.5;const Tr=fl(new Float32Array(Kt),new Float32Array(Ci),new Float32Array(Bt),D,pe,yr.baseColorFactor,zr.emissiveFactor,yr.metallicFactor,yr.roughnessFactor,zr,Yt,Z,[0,0,0],er);Hi.draw(D,q.gl.TRIANGLES,je&&!Qi?Ae:ne,yt.disabled,Le?Qi||pe<1||gt.hasTranslucentParts?Rt.alphaBlended:Rt.unblended:Rt.disabled,pt.backCCW,Tr,Z.id,ii.vertexBuffer,ii.indexBuffer,ii.segments,Z.paint,D.transform.zoom,void 0,Pr)}}}};(function(Le,je,et,ct){const nt=Le.terrain?Le.terrain.exaggeration():0,at=Le.transform.zoom;for(const Et of ct){const gt=je.getTile(Et).getBucket(et);gt&&(Le.conflationActive&&gt.updateReplacement(Et,Le.replacementSource),gt.evaluateScale(Le,et),Le.terrain&&nt>0&&gt.elevationUpdate(Le.terrain,nt,Et,et.source),gt.needsReEvaluation(Le,at,et)&&gt.evaluate(et))}})(D,F,Z,V),1===pe?Re(!0,!0):(Re(!1,!0),Re(!0,!1))}(c,r,o,h),void b();const M=T.getModels(),S=[],C=c.transform.getFreeCameraOptions().position,P=a.N.scale([],[C.x,C.y,C.z],c.transform.worldSize);a.N.negate(P,P);const k=[],R=[];let O=0;for(const D of M){const F=o.paint.get("model-rotation").constantOr(null),Z=o.paint.get("model-scale").constantOr(null),V=o.paint.get("model-translation").constantOr(null);D.computeModelMatrix(c,F,Z,V,!0,!0,!1);const q=a.a6.identity([]),B=a.cR(D.position.lat,c.transform.zoom),$=a.a6.fromScaling([],[1,1,1/B]);a.a6.translate(q,q,P),S.push({zScaleMatrix:$,negCameraPosMatrix:q});for(const Y of D.nodes)fa(c.transform,Y,D.matrix,c.transform.expandedFarZProjMatrix,O,k,R);O++}if(k.sort((D,F)=>F.depth-D.depth),"shadow"!==c.renderPass){if(1===d)for(const D of R)pa(D,c,o,S[D.modelIndex],yt.disabled,c.colorModeForRenderPass());else{for(const D of R)pa(D,c,o,S[D.modelIndex],yt.disabled,Rt.disabled);for(const D of R)pa(D,c,o,S[D.modelIndex],c.stencilModeFor3D(),c.colorModeForRenderPass());c.resetStencilClippingMasks()}for(const D of k)pa(D,c,o,S[D.modelIndex],yt.disabled,c.colorModeForRenderPass());b()}else{for(const D of R)le(D.mesh,D.nodeModelMatrix,c,o);for(const D of k)le(D.mesh,D.nodeModelMatrix,c,o);b()}}},oh={model:function(c,r,o){const h=c.scope,d=r.getSource();if(!d.loaded())return;if("vector"===d.type||"geojson"===d.type)return void(o.modelManager&&o.modelManager.upload(o,h));if("batched-model"===d.type)return;const f=d.getModels();for(const g of f)g.upload(o.context)},raster:function(c,r,o){const h=r.getSource();if(!(h instanceof Be&&h.loaded()))return;const d=c.sourceLayer||h.rasterLayerIds&&h.rasterLayerIds[0];if(!d)return;const f=c.paint.get("raster-array-band")||h.getInitialBand(d);if(null==f)return;const g=r.getIds().map(x=>r.getTileByID(x));for(const x of g)x.updateNeeded(d,f)&&h.prepareTile(x,d,f)},"raster-particle":function(c,r,o){const h=r.getSource();if(!(h instanceof Be&&h.loaded()))return;const d=c.sourceLayer||h.rasterLayerIds&&h.rasterLayerIds[0];if(!d)return;const f=c.paint.get("raster-particle-array-band")||h.getInitialBand(d);if(null==f)return;const g=r.getIds().map(x=>r.getTileByID(x));for(const x of g)x.updateNeeded(d,f)&&h.prepareTile(x,d,f)}};class Cu{constructor(r,o,h,d){this.context=new Jh(r,o),this.transform=h,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=d,this._debugParams={showTerrainProxyTiles:!1},d.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),this.setup(),this.numSublayers=nn.maxUnderzooming+nn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new a.cX,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new wc(this),this._wireframeDebugCache=new Iu,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(r,o){const h=!!r&&!!r.terrain&&this.transform.projection.supportsTerrain;if(!(h||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new np(this,r));const d=this._terrain;this.transform.elevation=h?d:null,d.update(r,this.transform,o),this.transform.elevation&&!d.enabled&&(this.transform.elevation=null)}_updateFog(r){const o=r.fog;if(!o||"globe"===this.transform.projection.name||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[h,d]=o.getFovAdjustedRange(this.transform._fov);if(h>d)return void(this.transform.fogCullDistSq=null);const f=h+.78*(d-h);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(r,o){if(this.width=r*a.f.devicePixelRatio,this.height=o*a.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const h of this.style.order)this.style._mergedLayers[h].resize()}setup(){const r=this.context,o=new a.aN;o.emplaceBack(0,0),o.emplaceBack(a.V,0),o.emplaceBack(0,a.V),o.emplaceBack(a.V,a.V),this.tileExtentBuffer=r.createVertexBuffer(o,a.aP.members),this.tileExtentSegments=a.aB.simpleSegment(0,0,4,2);const h=new a.aN;h.emplaceBack(0,0),h.emplaceBack(a.V,0),h.emplaceBack(0,a.V),h.emplaceBack(a.V,a.V),this.debugBuffer=r.createVertexBuffer(h,a.aP.members),this.debugSegments=a.aB.simpleSegment(0,0,4,5);const d=new a.aN;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(d,a.aP.members),this.viewportSegments=a.aB.simpleSegment(0,0,4,2);const f=new a.av;f.emplaceBack(0,0,0,0),f.emplaceBack(a.V,0,a.V,0),f.emplaceBack(0,a.V,0,a.V),f.emplaceBack(a.V,a.V,a.V,a.V),this.mercatorBoundsBuffer=r.createVertexBuffer(f,a.aR.members),this.mercatorBoundsSegments=a.aB.simpleSegment(0,0,4,2);const g=new a.aw;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(g);const x=new a.aO;for(const T of[0,1,3,2,0])x.emplaceBack(T);this.debugIndexBuffer=r.createIndexBuffer(x),this.emptyTexture=new a.T(r,new a.h({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA),this.identityMat=a.a6.create();const b=this.context.gl;this.stencilClearMode=new yt({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,r.TRIANGLES,dt.disabled,this.stencilClearMode,Rt.disabled,pt.disabled,Lc(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,o,h){if(!o||this.currentStencilSource===o.id||!r.isTileClipped()||!h||0===h.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let x=!1;for(const b of h)if(void 0===this._tileClippingMaskIDs[b.key]){x=!0;break}if(!x)return}this.currentStencilSource=o.id;const d=this.context,f=d.gl;this.nextStencilID+h.length>256&&this.clearStencil(),d.setColorMode(Rt.disabled),d.setDepthMode(dt.disabled);const g=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const x of h){const b=o.getTile(x),T=this._tileClippingMaskIDs[x.key]=this.nextStencilID++,{tileBoundsBuffer:M,tileBoundsIndexBuffer:S,tileBoundsSegments:C}=this.getTileBoundsBuffers(b);g.draw(this,f.TRIANGLES,dt.disabled,new yt({func:f.ALWAYS,mask:0},T,255,f.KEEP,f.KEEP,f.REPLACE),Rt.disabled,pt.disabled,Lc(x.projMatrix),"$clipping",M,S,C)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,o=this.context.gl;return new yt({func:o.NOTEQUAL,mask:255},r,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const o=this.context.gl;return new yt({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(r){const o=this.context.gl,h=r.sort((g,x)=>x.overscaledZ-g.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();const g={};for(let x=0;x<f;x++)g[x+d]=new yt({func:o.GEQUAL,mask:255},x+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=f,[g,h]}return[{[d]:yt.disabled},h]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new Rt([r.CONSTANT_COLOR,r.ONE,r.CONSTANT_COLOR,r.ONE],new a.ax(.125,.125,.125,0),[!0,!0,!0,!0]):"opaque"===this.renderPass?Rt.unblended:Rt.alphaBlended}colorModeForDrapableLayerRenderPass(r){const o=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&"translucent"===this.renderPass?new Rt([o.ONE,o.ONE_MINUS_SRC_ALPHA,o.CONSTANT_ALPHA,o.ONE_MINUS_SRC_ALPHA],new a.ax(0,0,0,void 0===r?0:r),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(r,o,h,d=!1){if(!this.opaquePassEnabledForLayer()&&!d)return dt.disabled;const f=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new dt(h||this.context.gl.LEQUAL,o,[f,f])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,o){this._wireframeDebugCache.update(this.frameCounter),this.style=r,this.options=o;const h=this.style._mergedLayers,d=this.style.order,f=d.map(B=>h[B]),g=this.style._mergedSourceCaches;this.imageManager=r.imageManager,this.modelManager=r.modelManager,this.symbolFadeChange=r.placement.symbolFadeChange(a.f.now()),this.imageManager.beginFrame();let x=0,b=!1;for(const B in g){const $=g[B];$.used&&($.prepare(this.context),$.getSource().usedInConflation&&++x)}for(const B of f)B.isHidden(this.transform.zoom)||this.prepareLayer(B);const T={},M={},S={},C={},P={};for(const B in g){const $=g[B];T[B]=$.getVisibleCoordinates(),M[B]=T[B].slice().reverse(),S[B]=$.getVisibleCoordinates(!0).reverse(),C[B]=$.getShadowCasterCoordinates(),P[B]=$.sortCoordinatesByDistance(T[B])}const k=B=>{const $=this.style.getLayerSourceCache(B);return $&&$.used?$.getSource():null};if(x){const B=[];for(const $ of f)this.layerUsedInConflation($,k($))&&B.push($);if(B&&B.length>1){const $=[];for(const Y of B){const K=this.style.getLayerSourceCache(Y);K&&K.used&&K.getSource().usedInConflation&&$.push({layer:Y.fqid,cache:K})}this.replacementSource.setSources($),b=!0}}b||this.replacementSource.clear(),this.conflationActive=b,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const B of f){const $=B.cutoffRange();if(this.longestCutoffRange=Math.max($,this.longestCutoffRange),$>0){const Y=k(B);Y&&(this.minCutoffZoom=Math.max(Y.minzoom,this.minCutoffZoom)),B.minzoom&&(this.minCutoffZoom=Math.max(B.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let B=0;B<f.length;B++)if(f[B].is3D()){this.opaquePassCutoff=B;break}const R=this.style&&this.style.fog;R?(this._fogVisible=0!==R.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=R.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(S),this.opaquePassCutoff=0);const O=this._shadowRenderer;if(O){O.updateShadowParameters(this.transform,this.style.directionalLight);for(const B in g)for(const $ of T[B]){let Y={min:0,max:0};this.terrain&&(Y=this.terrain.getMinMaxForTile($)||Y),O.addShadowReceiver($.toUnwrapped(),Y.min,Y.max)}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new a.cY(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new ht(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!a.cZ(this.context.gl))return;this.renderPass="offscreen";for(const B of f){const $=r.getLayerSourceCache(B);if(!B.hasOffscreenPass()||B.isHidden(this.transform.zoom))continue;const Y=$?M[$.id]:void 0;("custom"===B.type||"raster"===B.type||"raster-particle"===B.type||B.isSky()||Y&&Y.length)&&this.renderLayer(this,$,B,Y)}this.depthRangeFor3D=[0,1-(f.length+2)*this.numSublayers*this.depthEpsilon];const D=this.terrain;D&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&!this.transform.isOrthographic&&D.drawDepth(),this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,C)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const F="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),Z=(()=>{if(o.showOverdrawInspector)return a.ax.black;if(this.style.fog&&this.transform.projection.supportsFog&&!F){const B=this.style.fog.properties.get("color").toArray01();return new a.ax(...B)}if(this.style.fog&&this.transform.projection.supportsFog&&F){const B=this.style.fog.properties.get("space-color").toArray01();return new a.ax(...B)}return a.ax.transparent})();if(this.context.clear({color:Z,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&F&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){const B=f[this.currentLayer],$=r.getLayerSourceCache(B);if(B.isSky())continue;const Y=$?(B.is3D()?P:M)[$.id]:void 0;this._renderTileClippingMasks(B,$,Y),this.renderLayer(this,$,B,Y)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&F&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||a.S(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const B=f[this.currentLayer],$=r.getLayerSourceCache(B);B.isSky()&&this.renderLayer(this,$,B,$?M[$.id]:void 0)}function V(B,$){let Y;return $&&(Y=("symbol"===B.type?S:B.is3D()?P:M)[$.id]),Y}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<d.length;){const B=f[this.currentLayer];if("raster"===B.type){const $=r.getLayerSourceCache(B);this.renderLayer(this,$,B,V(B,$))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let q=0;for(O&&(q=O.getShadowCastingLayerCount());this.currentLayer<d.length;){const B=f[this.currentLayer],$=r.getLayerSourceCache(B);if(B.isSky())++this.currentLayer;else if(D&&this.style.isLayerDraped(B)){if(B.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=D.renderBatch(this.currentLayer)}else{if(this._renderTileClippingMasks(B,$,$?T[$.id]:void 0),this.renderLayer(this,$,B,V(B,$)),!D&&O&&q>0&&B.hasShadowPass()&&0==--q&&(O.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const Y=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=Y;this.currentLayer++){const K=f[this.currentLayer];if(!K.hasLightBeamPass())continue;const ee=r.getLayerSourceCache(K);this.renderLayer(this,ee,K,ee?M[ee.id]:void 0)}this.currentLayer=Y,this.renderPass="translucent"}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let B=null;f.forEach($=>{const Y=r.getLayerSourceCache($);Y&&!$.isHidden(this.transform.zoom)&&Y.getVisibleCoordinates().length&&(!B||B.getSource().maxzoom<Y.getSource().maxzoom)&&(B=Y)}),B&&this.options.showTileBoundaries&&_a.debug(this,B,B.getVisibleCoordinates(),a.ax.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&_a.debug(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new a.ax(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(B){const $=B.transform.padding;eh(B,B.transform.height-($.top||0),3,Ir),eh(B,$.bottom||0,3,co),Nr(B,$.left||0,3,Su),Nr(B,B.transform.width-($.right||0),3,Jc);const Y=B.transform.centerPoint;var K,ee,ce,re;Ai(K=B,(ee=Y.x)-1,(ce=B.transform.height-Y.y)-10,2,20,re=Qc),Ai(K,ee-10,ce-1,20,2,re)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),b||(this.conflationActive=!1)}prepareLayer(r){this.gpuTimingStart(r);const{unsupportedLayers:o}=this.transform.projection,h=!o||!o.includes(r.type);if(oh[r.type]&&(h||this.terrain&&"custom"===r.type)){const d=this.style.getLayerSourceCache(r);oh[r.type](r,d,this)}this.gpuTimingEnd()}renderLayer(r,o,h,d){h.isHidden(this.transform.zoom)||("background"===h.type||"sky"===h.type||"custom"===h.type||"model"===h.type||"raster"===h.type||"raster-particle"===h.type||d&&d.length)&&(this.id=h.id,this.gpuTimingStart(h),(!r.transform.projection.unsupportedLayers||!r.transform.projection.unsupportedLayers.includes(h.type)||r.terrain&&"custom"===h.type)&&_a[h.type](r,o,h,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(r){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery,h=this.context.gl;let d=this.gpuTimers[r.id];d||(d=this.gpuTimers[r.id]={calls:0,cpuTime:0,query:h.createQuery()}),d.calls++,h.beginQuery(o.TIME_ELAPSED_EXT,d.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const r=this.context.extTimerQuery,o=this.context.gl,h=o.createQuery();this.deferredRenderGpuTimeQueries.push(h),o.beginQuery(r.TIME_ELAPSED_EXT,h)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const r=this.gpuTimers;return this.gpuTimers={},r}collectDeferredRenderGpuQueries(){const r=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],r}queryGpuTimers(r){const o={};for(const h in r){const d=r[h],f=this.context.extTimerQuery,g=f.getQueryParameter(d.query,this.context.gl.QUERY_RESULT)/1e6;f.deleteQueryEXT(d.query),o[h]=g}return o}queryGpuTimeDeferredRender(r){if(!this.options.gpuTimingDeferredRender)return 0;const o=this.context.extTimerQuery,h=this.context.gl;let d=0;for(const f of r)d+=o.getQueryParameter(f,h.QUERY_RESULT)/1e6,o.deleteQueryEXT(f);return d}translatePosMatrix(r,o,h,d,f){if(!h[0]&&!h[1])return r;const g=f?"map"===d?this.transform.angle:0:"viewport"===d?-this.transform.angle:0;if(g){const T=Math.sin(g),M=Math.cos(g);h=[h[0]*M-h[1]*T,h[0]*T+h[1]*M]}const x=[f?h[0]:a.a3(o,h[0],this.transform.zoom),f?h[1]:a.a3(o,h[1],this.transform.zoom),0],b=new Float32Array(16);return a.a6.translate(b,r,x),b}saveTileTexture(r){const o=r.size[0],h=this._tileTextures[o];h?h.push(r):this._tileTextures[o]=[r]}getTileTexture(r){const o=this._tileTextures[r];return o&&o.length>0?o.pop():null}isPatternMissing(r,o){return null===r||void 0!==r&&!this.imageManager.getPattern(r.toString(),o)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(r,o,h){const d=void 0===h?this.terrain&&this.terrain.renderingToTexture:h,f=this.terrain&&0===this.terrain.exaggeration(),g=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===r||"terrainRaster"===r?(g.push("LIGHTING_3D_MODE"),g.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):d||g.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||g.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?g.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):g.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(g.push("TERRAIN"),this.linearFloatFilteringSupported()&&g.push("TERRAIN_DEM_FLOAT_FORMAT"),f&&g.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&g.push("GLOBE"),!this._fogVisible||d||void 0!==o&&!o||g.push("FOG","FOG_DITHERING"),d&&g.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&g.push("OVERDRAW_INSPECTOR"),g}getOrCreateProgram(r,o){this.cache=this.cache||{};const h=o&&o.defines||[],d=o&&o.config,f=o&&o.transformFeedback,g=this.currentGlobalDefines(r,o&&o.overrideFog,o&&o.overrideRtt).concat(h),x=Bc.cacheKey(Ic[r],r,g,d);return this.cache[x]||(this.cache[x]=new Bc(this.context,r,Ic[r],d,ap[r],g,f)),this.cache[x]}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(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(r,o){if(this.style.enable3dLights()){const h=this.style.directionalLight,d=this.style.ambientLight;if(h&&d){const f=((g,x)=>{const b=g.properties.get("direction"),T=g.properties.get("color").toArray01(),M=g.properties.get("intensity"),S=x.properties.get("color").toArray01(),C=x.properties.get("intensity"),P=[b.x,b.y,b.z],k=a.cn(S,C),R=a.cn(T,M);return{u_lighting_ambient_color:k,u_lighting_directional_dir:P,u_lighting_directional_color:R,u_ground_radiance:kc(P,R,k)}})(h,d);o.setLightsUniformValues(r,f)}}}uploadCommonUniforms(r,o,h,d,f){if(this.uploadCommonLightUniforms(r,o),this.terrain&&this.terrain.renderingToTexture)return;const g=this.style.fog;if(g){const x=g.getOpacity(this.transform.pitch),b=((T,M,S,C,P,k,R,O,D,F,Z,V)=>{const q=T.transform,B=M.properties.get("color").toArray01();B[3]=C;const $=T.frameCounter/1e3%1,[Y,K]=M.properties.get("vertical-range");return{u_fog_matrix:S?q.calculateFogTileMatrix(S):V||T.identityMat,u_fog_range:M.getFovAdjustedRange(q._fov),u_fog_color:B,u_fog_horizon_blend:M.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(Y,K),K],u_fog_temporal_offset:$,u_frustum_tl:P,u_frustum_tr:k,u_frustum_br:R,u_frustum_bl:O,u_globe_pos:D,u_globe_radius:F,u_viewport:Z,u_globe_transition:a.S(q.zoom),u_is_globe:+("globe"===q.projection.name)}})(this,g,h,x,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*a.f.devicePixelRatio,this.transform.height*a.f.devicePixelRatio],d);o.setFogUniformValues(r,b)}f&&o.setCutoffUniformValues(r,f.uniformValues)}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){const r=this.canvasCopy();r&&(this.frameCopies.push(r),this.tileLoaded=!1)}canvasCopy(){const r=this.context.gl,o=r.createTexture();return r.bindTexture(r.TEXTURE_2D,o),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&0!==r.getOpacity(this.transform.pitch)}getBackgroundTiles(){const r=this._backgroundTiles,o=this._backgroundTiles={},h=this.transform.coveringTiles({tileSize:512});for(const d of h)o[d.key]=r[d.key]||new Jn(d,512,this.transform.tileZoom,this);return o}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(r,o){return!(!r.is3D()||r.minzoom&&r.minzoom>this.transform.zoom||"building"!==r.sourceLayer&&(!o||"batched-model"!==o.type))}isTileAffectedByFog(r){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let o=this._cachedTileFogOpacities[r.key];return o||(this._cachedTileFogOpacities[r.key]=o=this.style.fog.getOpacityForTile(r)),o[0]>=ai||o[1]>=ai}}function ga(c,r){let o=!1,h=null;const d=()=>{h=null,o&&(c(),h=setTimeout(d,r),o=!1)};return()=>(o=!0,h||d(),h)}class gl{constructor(r){this._hashName=r&&encodeURIComponent(r),a.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=ga(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,window.addEventListener("hashchange",this._onHashChange,!1),r.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const r=this._map;if(!r)return"";const o=sh(r);if(this._hashName){const h=this._hashName;let d=!1;const f=location.hash.slice(1).split("&").map(g=>{const x=g.split("=")[0];return x===h?(d=!0,`${x}=${o}`):g}).filter(g=>g);return d||f.push(`${h}=${o}`),`#${f.join("&")}`}return`#${o}`}_getCurrentHash(){const r=location.hash.replace("#","");if(this._hashName){let o;return r.split("&").map(h=>h.split("=")).forEach(h=>{h[0]===this._hashName&&(o=h)}),(o&&o[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const o=this._getCurrentHash();if(o.length>=3&&!o.some(h=>isNaN(h))){const h=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(o[3]||0):r.getBearing();return r.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:h,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function sh(c,r){const o=c.getCenter(),h=Math.round(100*c.getZoom())/100,d=Math.ceil((h*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,d),g=Math.round(o.lng*f)/f,x=Math.round(o.lat*f)/f,b=c.getBearing(),T=c.getPitch();let M=r?`/${g}/${x}/${h}`:`${h}/${x}/${g}`;return(b||T)&&(M+="/"+Math.round(10*b)/10),T&&(M+=`/${Math.round(T)}`),M}const ya={linearity:.3,easing:a.c_(0,0,.3,1)},Cr=a.e({deceleration:2500,maxSpeed:1400},ya),pp=a.e({deceleration:20,maxSpeed:1400},ya),yl=a.e({deceleration:1e3,maxSpeed:360},ya),wi=a.e({deceleration:1e3,maxSpeed:90},ya);class li{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.f.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,o=a.f.now();for(;r.length>0&&o-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const o={zoom:0,bearing:0,pitch:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{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);const h=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){const f=cn(o.pan.mag(),h,a.e({},Cr,r||{}));d.offset=o.pan.mult(f.amount/o.pan.mag()),d.center=this._map.transform.center,xa(d,f)}if(o.zoom){const f=cn(o.zoom,h,pp);d.zoom=this._map.transform.zoom+f.amount,xa(d,f)}if(o.bearing){const f=cn(o.bearing,h,yl);d.bearing=this._map.transform.bearing+a.aa(f.amount,-179,179),xa(d,f)}if(o.pitch){const f=cn(o.pitch,h,wi);d.pitch=this._map.transform.pitch+f.amount,xa(d,f)}if(d.zoom||d.bearing){const f=void 0===o.pinchAround?o.around:o.pinchAround;d.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function xa(c,r){(!c.duration||c.duration<r.duration)&&(c.duration=r.duration,c.easing=r.easing)}function cn(c,r,o){const{maxSpeed:h,linearity:d,deceleration:f}=o,g=a.aa(c*d/(r/1e3),-h,h),x=Math.abs(g)/(f*d);return{easing:o.easing,duration:1e3*x,amount:g*(x/2)}}class wr extends a.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h,d={}){const f=$n(o.getCanvasContainer(),h),g=o.unproject(f);super(r,a.e({point:f,lngLat:g,originalEvent:h},d)),this._defaultPrevented=!1,this.target=o}}class Rn extends a.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h){const d="touchend"===r?h.changedTouches:h.touches,f=Wn(o.getCanvasContainer(),d),g=f.map(b=>o.unproject(b)),x=f.reduce((b,T,M,S)=>b.add(T.div(S.length)),new a.P(0,0));super(r,{points:f,point:x,lngLats:g,lngLat:o.unproject(x),originalEvent:h}),this._defaultPrevented=!1}}class ah extends a.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h){super(r,{originalEvent:h}),this._defaultPrevented=!1}}class lh{constructor(r,o){this._map=r,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new ah(r.type,this._map,r))}mousedown(r,o){return this._mousedownPos=o,this._firePreventable(new wr(r.type,this._map,r))}mouseup(r){this._map.fire(new wr(r.type,this._map,r))}preclick(r){const o=a.e({},r);o.type="preclick",this._map.fire(new wr(o.type,this._map,o))}click(r,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(r),this._map.fire(new wr(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new wr(r.type,this._map,r))}mouseover(r){this._map.fire(new wr(r.type,this._map,r))}mouseout(r){this._map.fire(new wr(r.type,this._map,r))}touchstart(r){return this._firePreventable(new Rn(r.type,this._map,r))}touchmove(r){this._map.fire(new Rn(r.type,this._map,r))}touchend(r){this._map.fire(new Rn(r.type,this._map,r))}touchcancel(r){this._map.fire(new Rn(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class uo{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new wr(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new wr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new wr(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class po{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._container=r.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(r,o){this.isEnabled()&&r.shiftKey&&0===r.button&&(Ua(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(r,o){if(!this._active)return;const h=o,d=this._startPos,f=this._lastPos;if(!d||!f||f.equals(h)||!this._box&&h.dist(d)<this._clickTolerance)return;this._lastPos=h,this._box||(this._box=Wt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",r));const g=Math.min(d.x,h.x),x=Math.max(d.x,h.x),b=Math.min(d.y,h.y),T=Math.max(d.y,h.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${g}px,${b}px)`,this._box.style.width=x-g+"px",this._box.style.height=T-b+"px")})}mouseupWindow(r,o){if(!this._active)return;const h=this._startPos,d=o;if(h&&0===r.button){if(this.reset(),wo(),h.x!==d.x||h.y!==d.y)return this._map.fire(new a.b("boxzoomend",{originalEvent:r})),{cameraAnimation:f=>f.fitScreenCoordinates(h,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}}keydown(r){this._active&&27===r.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),kr(),delete this._startPos,delete this._lastPos}_fireEvent(r,o){return this._map.fire(new a.b(r,{originalEvent:o}))}}function Es(c,r){const o={};for(let h=0;h<c.length;h++)o[c[h].identifier]=r[h];return o}class xl{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(r,o,h){(this.centroid||h.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=r.timeStamp),h.length===this.numTouches&&(this.centroid=function(d){const f=new a.P(0,0);for(const g of d)f._add(g);return f.div(d.length)}(o),this.touches=Es(h,o)))}touchmove(r,o,h){if(this.aborted||!this.centroid)return;const d=Es(h,o);for(const f in this.touches){const g=d[f];(!g||g.dist(this.touches[f])>30)&&(this.aborted=!0)}}touchend(r,o,h){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),0===h.length){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class va{constructor(r){this.singleTap=new xl(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,o,h){this.singleTap.touchstart(r,o,h)}touchmove(r,o,h){this.singleTap.touchmove(r,o,h)}touchend(r,o,h){const d=this.singleTap.touchend(r,o,h);if(d){const f=r.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(d)<30;if(f&&g||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class ch{constructor(){this._zoomIn=new va({numTouches:1,numTaps:2}),this._zoomOut=new va({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,o,h){this._zoomIn.touchstart(r,o,h),this._zoomOut.touchstart(r,o,h)}touchmove(r,o,h){this._zoomIn.touchmove(r,o,h),this._zoomOut.touchmove(r,o,h)}touchend(r,o,h){const d=this._zoomIn.touchend(r,o,h),f=this._zoomOut.touchend(r,o,h);return d?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()+1,around:g.unproject(d)},{originalEvent:r})}):f?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()-1,around:g.unproject(f)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const hh={0:1,2:2};class vn{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,o){return!1}_move(r,o){return{}}mousedown(r,o){if(this._lastPoint)return;const h=Mn(r);this._correctButton(r,h)&&(this._lastPoint=o,this._eventButton=h)}mousemoveWindow(r,o){const h=this._lastPoint;if(h)if(r.preventDefault(),null!=this._eventButton&&function(d,f){const g=hh[f];return void 0===d.buttons||(d.buttons&g)!==g}(r,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(r){this._lastPoint&&Mn(r)===this._eventButton&&(this._moved&&wo(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class uh extends vn{mousedown(r,o){super.mousedown(r,o),this._lastPoint&&(this._active=!0)}_correctButton(r,o){return 0===o&&!r.ctrlKey}_move(r,o){return{around:o,panDelta:o.sub(r)}}}class ba extends vn{_correctButton(r,o){return 0===o&&r.ctrlKey||2===o}_move(r,o){const h=.8*(o.x-r.x);if(h)return this._active=!0,{bearingDelta:h}}contextmenu(r){r.preventDefault()}}class vl extends vn{_correctButton(r,o){return 0===o&&r.ctrlKey||2===o}_move(r,o){const h=-.5*(o.y-r.y);if(h)return this._active=!0,{pitchDelta:h}}contextmenu(r){r.preventDefault()}}class dh{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),a.aY(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}touchstart(r,o,h){return this._calculateTransform(r,o,h)}touchmove(r,o,h){if(this._active&&!(h.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===h.length&&!a.c$())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return r.cancelable&&r.preventDefault(),this._calculateTransform(r,o,h)}}touchend(r,o,h){this._calculateTransform(r,o,h),this._active&&h.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,o,h){h.length>0&&(this._active=!0);const d=Es(h,o),f=new a.P(0,0),g=new a.P(0,0);let x=0;for(const T in d){const M=d[T],S=this._touches[T];S&&(f._add(M),g._add(M.sub(S)),x++,d[T]=M)}if(this._touches=d,x<this._minTouches||!g.mag())return;const b=g.div(x);return this._sum._add(b),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(x),panDelta:b}}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=Wt("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="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Ji{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,o,h){return{}}touchstart(r,o,h){this._firstTwoTouches||h.length<2||(this._firstTwoTouches=[h[0].identifier,h[1].identifier],this._start([o[0],o[1]]))}touchmove(r,o,h){const d=this._firstTwoTouches;if(!d)return;r.preventDefault();const[f,g]=d,x=Ss(h,o,f),b=Ss(h,o,g);if(!x||!b)return;const T=this._aroundCenter?null:x.add(b).div(2);return this._move([x,b],T,r)}touchend(r,o,h){if(!this._firstTwoTouches)return;const[d,f]=this._firstTwoTouches,g=Ss(h,o,d),x=Ss(h,o,f);g&&x||(this._active&&wo(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&"center"===r.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ss(c,r,o){for(let h=0;h<c.length;h++)if(c[h].identifier===o)return r[h]}function bl(c,r){return Math.log(c/r)/Math.LN2}class wa extends Ji{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,o){const h=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(bl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:bl(this._distance,h),pinchAround:o}}}function fo(c,r){return 180*c.angleWith(r)/Math.PI}class ph extends Ji{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,o){const h=this._vector;if(this._vector=r[0].sub(r[1]),h&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:fo(this._vector,h),pinchAround:o}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const o=25/(Math.PI*this._minDiameter)*360,h=this._startVector;if(!h)return!1;const d=fo(r,h);return Math.abs(d)<o}}function Ta(c){return Math.abs(c.y)>Math.abs(c.x)}class fh extends Ji{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,Ta(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,o,h){const d=this._lastPoints;if(!d)return;const f=r[0].sub(d[0]),g=r[1].sub(d[1]);return this._map._cooperativeGestures&&!a.c$()&&h.touches.length<3||(this._valid=this.gestureBeginsVertically(f,g,h.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(f.y+g.y)/2*-.5})}gestureBeginsVertically(r,o,h){if(void 0!==this._valid)return this._valid;const d=r.mag()>=2,f=o.mag()>=2;if(!d&&!f)return;if(!d||!f)return null==this._firstMove&&(this._firstMove=h),h-this._firstMove<100&&void 0;const g=r.y>0==o.y>0;return Ta(r)&&Ta(o)&&g}}const jo={panStep:100,bearingStep:15,pitchStep:10};class Ma{constructor(){const r=jo;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let o=0,h=0,d=0,f=0,g=0;switch(r.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:r.shiftKey?h=-1:(r.preventDefault(),f=-1);break;case 39:r.shiftKey?h=1:(r.preventDefault(),f=1);break;case 38:r.shiftKey?d=1:(r.preventDefault(),g=-1);break;case 40:r.shiftKey?d=-1:(r.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(h=0,d=0),{cameraAnimation:x=>{const b=x.getZoom();x.easeTo({duration:300,easeId:"keyboardHandler",easing:mh,zoom:o?Math.round(b)+o*(r.shiftKey?2:1):b,bearing:x.getBearing()+h*this._bearingStep,pitch:x.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-g*this._panStep],center:x.getCenter()},{originalEvent:r})}}}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 mh(c){return c*(2-c)}const Ea=4.000244140625,_h=1/450;class Pu{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._handler=o,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=_h,a.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&"center"===r.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||a.c$()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=r.deltaMode===WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const h=a.f.now(),d=h-(this._lastWheelEventTime||0);this._lastWheelEventTime=h,0!==o&&o%Ea==0?this._type="wheel":0!==o&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),r.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=r,this._delta-=o,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const o=$n(this._el,r);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;const r=this._map.transform;"wheel"===this._type&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const o=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(0!==this._delta){const T="wheel"===this._type&&Math.abs(this._delta)>Ea?this._wheelZoomRate:this._defaultZoomRate;let M=2/(1+Math.exp(-Math.abs(this._delta*T)));this._delta<0&&0!==M&&(M=1/M);const S=o(),C=Math.pow(2,S),P="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):C;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(P*M))),"wheel"===this._type&&(this._startZoom=S,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const h="number"==typeof this._targetZoom?this._targetZoom:o(),d=this._startZoom,f=this._easing;let g,x=!1;if("wheel"===this._type&&d&&f){const T=Math.min((a.f.now()-this._lastWheelEventTime)/200,1),M=f(T);g=a.U(d,h,M),T<1?this._frameId||(this._frameId=!0):x=!0}else g=h,x=!0;this._active=!0,x&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let b=g-o();return b*this._lastDelta<0&&(b=0),{noInertia:!0,needsRenderFrame:!x,zoomDelta:b,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let o=a.d0;if(this._prevEase){const h=this._prevEase,d=(a.f.now()-h.start)/h.duration,f=h.easing(d+.01)-h.easing(d),g=.27/Math.sqrt(f*f+1e-4)*.01,x=Math.sqrt(.0729-g*g);o=a.c_(g,x,.25,1)}return this._prevEase={start:a.f.now(),duration:r,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Wt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(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`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class zu{constructor(r,o){this._clickZoom=r,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 Du{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,o){return r.preventDefault(),{cameraAnimation:h=>{h.easeTo({duration:300,zoom:h.getZoom()+(r.shiftKey?-1:1),around:h.unproject(o)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Lu{constructor(){this._tap=new va({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,o,h){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?h.length>0&&(this._swipePoint=o[0],this._swipeTouch=h[0].identifier):this._tap.touchstart(r,o,h))}touchmove(r,o,h){if(this._tapTime){if(this._swipePoint){if(h[0].identifier!==this._swipeTouch)return;const d=o[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,r.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(r,o,h)}touchend(r,o,h){this._tapTime?this._swipePoint&&0===h.length&&this.reset():this._tap.touchend(r,o,h)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ru{constructor(r,o,h){this._el=r,this._mousePan=o,this._touchPan=h}enable(r){this._inertiaOptions=r||{},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 ku{constructor(r,o,h){this._pitchWithRotate=r.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 Ou{constructor(r,o,h,d){this._el=r,this._touchZoom=o,this._touchRotate=h,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),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()}}const Sa=c=>c.zoom||c.drag||c.pitch||c.rotate;class Bu extends a.b{}class Fu{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,o){const h=a.N.sub([],o,r);this.radius=a.N.length(h[2]<0?a.N.div([],h,this.constants):[h[0],h[1],0])}projectRay(r){a.N.div(r,r,this.constants),a.N.normalize(r,r),a.N.mul(r,r,this.constants);const o=a.N.scale([],r,this.radius);if(o[2]>0){const h=a.N.scale([],[0,0,1],a.N.dot(o,[0,0,1])),d=a.N.scale([],a.N.normalize([],[o[0],o[1],0]),this.radius),f=a.N.add([],o,a.N.scale([],a.N.sub([],a.N.add([],d,h),o),2));o[0]=f[0],o[1]=f[1]}return o}}function Aa(c){return c.panDelta&&c.panDelta.mag()||c.zoomDelta||c.bearingDelta||c.pitchDelta}class fp{constructor(r,o){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new li(r),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Fu,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),a.aY(["handleEvent","handleWindowEvent"],this);const 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],[document,"mousemove",{capture:!0}],[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],[window,"blur",void 0]];for(const[d,f,g]of this._listeners){const x=d===document?this.handleWindowEvent:this.handleEvent;d.addEventListener(f,x,g)}}destroy(){for(const[r,o,h]of this._listeners){const d=r===document?this.handleWindowEvent:this.handleEvent;r.removeEventListener(o,d,h)}}_addDefaultHandlers(r){const o=this._map,h=o.getCanvasContainer();this._add("mapEvent",new lh(o,r));const d=o.boxZoom=new po(o,r);this._add("boxZoom",d);const f=new ch,g=new Du;o.doubleClickZoom=new zu(g,f),this._add("tapZoom",f),this._add("clickZoom",g);const x=new Lu;this._add("tapDragZoom",x);const b=o.touchPitch=new fh(o);this._add("touchPitch",b);const T=new ba(r),M=new vl(r);o.dragRotate=new ku(r,T,M),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",M,["mouseRotate"]);const S=new uh(r),C=new dh(o,r);o.dragPan=new Ru(h,S,C),this._add("mousePan",S),this._add("touchPan",C,["touchZoom","touchRotate"]);const P=new ph,k=new wa;o.touchZoomRotate=new Ou(h,k,P,x),this._add("touchRotate",P,["touchPan","touchZoom"]),this._add("touchZoom",k,["touchPan","touchRotate"]),this._add("blockableMapEvent",new uo(o));const R=o.scrollZoom=new Pu(o,this);this._add("scrollZoom",R,["mousePan"]);const O=o.keyboard=new Ma;this._add("keyboard",O);for(const D of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[D]&&o[D].enable(r[D])}_add(r,o,h){this._handlers.push({handlerName:r,handler:o,allowed:h}),this._handlersById[r]=o}stop(r){if(!this._updatingCamera){for(const{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Sa(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(r,o,h){for(const d in r)if(d!==h&&(!o||o.indexOf(d)<0))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const o=[];for(const h of r)this._el.contains(h.target)&&o.push(h);return o}handleEvent(r,o){this._updatingCamera=!0;const h="renderFrame"===r.type,d=h?void 0:r,f={needsRenderFrame:!1},g={},x={},b=r.touches?this._getMapTouches(r.touches):void 0,T=b?Wn(this._el,b):h?void 0:$n(this._el,r);for(const{handlerName:C,handler:P,allowed:k}of this._handlers){if(!P.isEnabled())continue;let R;this._blockedByActive(x,k,C)?P.reset():P[o||r.type]&&(R=P[o||r.type](r,T,b),this.mergeHandlerResult(f,g,R,C,d),R&&R.needsRenderFrame&&this._triggerRenderFrame()),(R||P.isActive())&&(x[C]=P)}const M={};for(const C in this._previousActiveHandlers)x[C]||(M[C]=d);this._previousActiveHandlers=x,(Object.keys(M).length||Aa(f))&&(this._changes.push([f,g,M]),this._triggerRenderFrame()),(Object.keys(x).length||Aa(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:S}=f;S&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],S(this._map))}mergeHandlerResult(r,o,h,d,f){if(!h)return;a.e(r,h);const g={handlerName:d,originalEvent:h.originalEvent||f};void 0!==h.zoomDelta&&(o.zoom=g),void 0!==h.panDelta&&(o.drag=g),void 0!==h.pitchDelta&&(o.pitch=g),void 0!==h.bearingDelta&&(o.rotate=g)}_applyChanges(){const r={},o={},h={};for(const[d,f,g]of this._changes)d.panDelta&&(r.panDelta=(r.panDelta||new a.P(0,0))._add(d.panDelta)),d.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+d.pitchDelta),void 0!==d.around&&(r.around=d.around),void 0!==d.aroundCoord&&(r.aroundCoord=d.aroundCoord),void 0!==d.pinchAround&&(r.pinchAround=d.pinchAround),d.noInertia&&(r.noInertia=d.noInertia),a.e(o,f),a.e(h,g);this._updateMapTransform(r,o,h),this._changes=[]}_updateMapTransform(r,o,h){const d=this._map,f=d.transform,g=F=>[F.x,F.y,F.z];if((()=>{const Z=this._eventsInProgress.drag;return Z&&!this._handlersById[Z.handlerName].isActive()})()&&!Aa(r)){const F=f.zoom;f.cameraElevationReference="sea",null!=this._originalZoom&&f._orthographicProjectionAtLowPitch&&"globe"!==f.projection.name&&0===f.pitch?(f.cameraElevationReference="ground",f.zoom=this._originalZoom):(f.recenterOnTerrain(),f.cameraElevationReference="ground"),F!==f.zoom&&this._map._update(!0)}if(f._isCameraConstrained&&d._stop(!0),!Aa(r))return void this._fireEvents(o,h,!0);let{panDelta:x,zoomDelta:b,bearingDelta:T,pitchDelta:M,around:S,aroundCoord:C,pinchAround:P}=r;f._isCameraConstrained&&(b>0&&(b=0),f._isCameraConstrained=!1),void 0!==P&&(S=P),(b||(F=>o[F]&&!this._eventsInProgress[F])("drag"))&&S&&(this._dragOrigin=g(f.pointCoordinate3D(S)),this._originalZoom=f.zoom,this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),S=S||d.transform.centerPoint,T&&(f.bearing+=T),M&&(f.pitch+=M),f._updateCameraState();const k=[0,0,0];if(x)if("mercator"===f.projection.name){const F=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(S).dir),Z=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(S.sub(x)).dir);k[0]=Z[0]-F[0],k[1]=Z[1]-F[1]}else{const F=f.pointCoordinate(S);if("globe"===f.projection.name){x=x.rotate(-f.angle);const Z=f._pixelsPerMercatorPixel/f.worldSize;k[0]=-x.x*a.d1(a.au(F.y))*Z,k[1]=-x.y*a.d1(f.center.lat)*Z}else{const Z=f.pointCoordinate(S.sub(x));F&&Z&&(k[0]=Z.x-F.x,k[1]=Z.y-F.y)}}const R=f.zoom,O=[0,0,0];if(b){const F=g(C||f.pointCoordinate3D(S)),Z={dir:a.N.normalize([],a.N.sub([],F,f._camera.position))};if(Z.dir[2]<0){const V=f.zoomDeltaToMovement(F,b);a.N.scale(O,Z.dir,V)}}const D=a.N.add(k,k,O);f._translateCameraConstrained(D),b&&Math.abs(f.zoom-R)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(o,h,!0)}_fireEvents(r,o,h){const d=Sa(this._eventsInProgress),f=Sa(r),g={};for(const M in r){const{originalEvent:S}=r[M];this._eventsInProgress[M]||(g[`${M}start`]=S),this._eventsInProgress[M]=r[M]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(const M in g)this._fireEvent(M,g[M]);f&&this._fireEvent("move",f.originalEvent);for(const M in r){const{originalEvent:S}=r[M];this._fireEvent(M,S)}const x={};let b;for(const M in this._eventsInProgress){const{handlerName:S,originalEvent:C}=this._eventsInProgress[M];this._handlersById[S].isActive()||(delete this._eventsInProgress[M],b=o[S]||C,x[`${M}end`]=b)}for(const M in x)this._fireEvent(M,x[M]);const T=Sa(this._eventsInProgress);if(h&&(d||f)&&!T){this._updatingCamera=!0;const M=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),S=C=>0!==C&&-this._bearingSnap<C&&C<this._bearingSnap;M?(S(M.bearing||this._map.getBearing())&&(M.bearing=0),this._map.easeTo(M,{originalEvent:b})):(this._map.fire(new a.b("moveend",{originalEvent:b})),S(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(r,o){this._map.fire(new a.b(r,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{this._frameId=void 0,this.handleEvent(new Bu("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Nu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Oi extends a.E{constructor(r,o){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=!1!==o.respectPrefersReducedMotion,a.aY(["_renderFrameCallback"],this)}getCenter(){return new a.bn(this.transform.center.lng,this.transform.center.lat)}setCenter(r,o){return this.jumpTo({center:r},o)}panBy(r,o,h){return r=a.P.convert(r).mult(-1),this.panTo(this.transform.center,a.e({offset:r},o),h)}panTo(r,o,h){return this.easeTo(a.e({center:r},o),h)}getZoom(){return this.transform.zoom}setZoom(r,o){return this.jumpTo({zoom:r},o),this}zoomTo(r,o,h){return this.easeTo(a.e({zoom:r},o),h)}zoomIn(r,o){return this.zoomTo(this.getZoom()+1,r,o),this}zoomOut(r,o){return this.zoomTo(this.getZoom()-1,r,o),this}getBearing(){return this.transform.bearing}setBearing(r,o){return this.jumpTo({bearing:r},o),this}getPadding(){return this.transform.padding}setPadding(r,o){return this.jumpTo({padding:r},o),this}rotateTo(r,o,h){return this.easeTo(a.e({bearing:r},o),h)}resetNorth(r,o){return this.rotateTo(0,a.e({duration:1e3},r),o),this}resetNorthPitch(r,o){return this.easeTo(a.e({bearing:0,pitch:0,duration:1e3},r),o),this}snapToNorth(r,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,o):this}getPitch(){return this.transform.pitch}setPitch(r,o){return this.jumpTo({pitch:r},o),this}cameraForBounds(r,o){r=a.ad.convert(r);const h=o&&o.bearing||0,d=o&&o.pitch||0,f=r.getNorthWest(),g=r.getSouthEast();return this._cameraForBounds(this.transform,f,g,h,d,o)}_extendCameraOptions(r){const o={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=a.e({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){const h=r.padding;r.padding={top:h,bottom:h,right:h,left:h}}return r.padding=a.e(o,r.padding),r}_minimumAABBFrustumDistance(r,o){const h=o.max[0]-o.min[0],d=o.max[1]-o.min[1];return h/d>r.aspect?h/(2*Math.tan(.5*r.fovX)*r.aspect):d/(2*Math.tan(.5*r.fovY)*r.aspect)}_cameraForBoundsOnGlobe(r,o,h,d,f,g){const x=r.clone(),b=this._extendCameraOptions(g);x.bearing=d,x.pitch=f;const T=a.bn.convert(o),M=a.bn.convert(h),S=.5*(T.lat+M.lat),C=.5*(T.lng+M.lng),P=a.d2(S,C),k=a.N.normalize([],P),R=a.N.normalize([],a.N.cross([],k,[0,1,0])),O=a.N.cross([],R,k),D=[R[0],R[1],R[2],0,O[0],O[1],O[2],0,k[0],k[1],k[2],0,0,0,0,1],F=[P,a.d2(T.lat,T.lng),a.d2(M.lat,T.lng),a.d2(M.lat,M.lng),a.d2(T.lat,M.lng),a.d2(S,T.lng),a.d2(S,M.lng),a.d2(T.lat,C),a.d2(M.lat,C)];let Z=a.bS.fromPoints(F.map(ae=>[a.N.dot(R,ae),a.N.dot(O,ae),a.N.dot(k,ae)]));const V=a.N.transformMat4([],Z.center,D);0===a.N.squaredLength(V)&&a.N.set(V,0,0,1),a.N.normalize(V,V),a.N.scale(V,V,a.ab),x.center=a.d3(V);const q=x.getWorldToCameraMatrix(),B=a.a6.invert(new Float64Array(16),q);Z=a.bS.applyTransform(Z,a.a6.multiply([],q,D)),a.N.transformMat4(V,V,q);const $=.5*(Z.max[2]-Z.min[2]),Y=this._minimumAABBFrustumDistance(x,Z),K=a.N.scale([],[0,0,1],$),ee=a.N.add(K,V,K),ce=Y+(0===x.pitch?0:a.N.distance(V,ee)),re=x.globeCenterInViewSpace,me=a.N.sub([],V,[re[0],re[1],re[2]]);a.N.normalize(me,me),a.N.scale(me,me,ce);const pe=a.N.add([],V,me);a.N.transformMat4(pe,pe,B);const Ae=a.d4/a.ab,ne=a.N.length(pe),ue=a.bl(Math.max(ne*Ae-a.d4,Number.EPSILON),0),Q=Math.min(x.zoomFromMercatorZAdjusted(ue),b.maxZoom);return Q>.5*(a.bG+a.bx)?(x.setProjection({name:"mercator"}),x.zoom=Q,this._cameraForBounds(x,o,h,d,f,g)):{center:x.center,zoom:Q,bearing:d,pitch:f}}queryTerrainElevation(r,o){const h=this.transform.elevation;return h?(o=a.e({},{exaggerated:!0},o),h.getAtPoint(a.L.fromLngLat(r),null,o.exaggerated)):null}_cameraForBounds(r,o,h,d,f,g){if("globe"===r.projection.name)return this._cameraForBoundsOnGlobe(r,o,h,d,f,g);const x=r.clone(),b=this._extendCameraOptions(g),T=x.padding;x.bearing=d,x.pitch=f;const M=a.bn.convert(o),S=a.bn.convert(h),C=new a.bn(M.lng,S.lat),P=new a.bn(S.lng,M.lat),k=x.project(M),R=x.project(S),O=this.queryTerrainElevation(M),D=this.queryTerrainElevation(S),F=this.queryTerrainElevation(C),Z=this.queryTerrainElevation(P),V=[[k.x,k.y,Math.min(O||0,D||0,F||0,Z||0)],[R.x,R.y,Math.max(O||0,D||0,F||0,Z||0)]];let q=a.bS.fromPoints(V);const B=x.getWorldToCameraMatrix(),$=a.a6.invert(new Float64Array(16),B);q=a.bS.applyTransform(q,B);const Y=a.N.sub([],q.max,q.min),K=T.left||0,ee=T.right||0,ce=T.bottom||0,re=T.top||0,{left:me,right:pe,top:Ae,bottom:ne}=b.padding,ue=.5*(K+ee),Q=.5*(re+ce),ae=Math.min(x.scaleZoom(x.scale*Math.min((x.width-(K+ee+me+pe))/Y[0],(x.height-(ce+re+ne+Ae))/Y[1])),b.maxZoom),Ie=x.scale/x.zoomScale(ae);q=new a.bS([q.min[0]-(me+ue)*Ie,q.min[1]-(ne+Q)*Ie,q.min[2]],[q.max[0]+(pe+ue)*Ie,q.max[1]+(Ae+Q)*Ie,q.max[2]]);const Re=.5*Y[2],Le=this._minimumAABBFrustumDistance(x,q),je=[0,0,1,0];a.a7.transformMat4(je,je,B),a.a7.normalize(je,je);const et=a.N.scale([],je,Le+Re),ct=a.N.add([],q.center,et),nt=("number"==typeof b.offset.x&&"number"==typeof b.offset.y?new a.P(b.offset.x,b.offset.y):a.P.convert(b.offset)).rotate(-a.bj(d));q.center[0]-=nt.x*Ie,q.center[1]+=nt.y*Ie,a.N.transformMat4(q.center,q.center,$),a.N.transformMat4(ct,ct,$);const at=[q.center[0],q.center[1],ct[2]*x.pixelsPerMeter];a.N.scale(at,at,1/x.worldSize);const Et=a.at(at[0]),gt=a.au(at[1]),bt=Math.min(x._zoomFromMercatorZ(at[2]),b.maxZoom),vt=new a.bn(Et,gt);return x.mercatorFromTransition&&bt<.5*(a.bG+a.bx)?(x.setProjection({name:"globe"}),x.zoom=bt,this._cameraForBounds(x,o,h,d,f,g)):{center:vt,zoom:bt,bearing:d,pitch:f}}fitBounds(r,o,h){const d=this.cameraForBounds(r,o);return this._fitInternal(d,o,h)}fitScreenCoordinates(r,o,h,d,f){const g=a.P.convert(r),x=a.P.convert(o),b=new a.P(Math.min(g.x,x.x),Math.min(g.y,x.y)),T=new a.P(Math.max(g.x,x.x),Math.max(g.y,x.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(g,x))return this;const M=this.transform.pointLocation3D(b),S=this.transform.pointLocation3D(T),C=this.transform.pointLocation3D(new a.P(b.x,T.y)),P=this.transform.pointLocation3D(new a.P(T.x,b.y)),k=[Math.min(M.lng,S.lng,C.lng,P.lng),Math.min(M.lat,S.lat,C.lat,P.lat)],R=[Math.max(M.lng,S.lng,C.lng,P.lng),Math.max(M.lat,S.lat,C.lat,P.lat)],O=d&&d.pitch?d.pitch:this.getPitch(),D=this._cameraForBounds(this.transform,k,R,h,O,d);return this._fitInternal(D,d,f)}_fitInternal(r,o,h){return r?(delete(o=a.e(r,o)).padding,o.linear?this.easeTo(o,h):this.flyTo(o,h)):this}jumpTo(r,o){this.stop();const h=r.preloadOnly?this.transform.clone():this.transform;let d=!1,f=!1,g=!1;return"zoom"in r&&h.zoom!==+r.zoom&&(d=!0,h.zoom=+r.zoom),void 0!==r.center&&(h.center=a.bn.convert(r.center)),"bearing"in r&&h.bearing!==+r.bearing&&(f=!0,h.bearing=+r.bearing),"pitch"in r&&h.pitch!==+r.pitch&&(g=!0,h.pitch=+r.pitch),null==r.padding||h.isPaddingEqual(r.padding)||(h.padding=r.padding),r.preloadOnly?(this._preloadTiles(h),this):(this.fire(new a.b("movestart",o)).fire(new a.b("move",o)),d&&this.fire(new a.b("zoomstart",o)).fire(new a.b("zoom",o)).fire(new a.b("zoomend",o)),f&&this.fire(new a.b("rotatestart",o)).fire(new a.b("rotate",o)).fire(new a.b("rotateend",o)),g&&this.fire(new a.b("pitchstart",o)).fire(new a.b("pitch",o)).fire(new a.b("pitchend",o)),this.fire(new a.b("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.w(Nu),this.transform.getFreeCameraOptions()}setFreeCameraOptions(r,o){const h=this.transform;if(!h.projection.supportsFreeCamera)return a.w(Nu),this;this.stop();const d=h.zoom,f=h.pitch,g=h.bearing;h.setFreeCameraOptions(r);const x=d!==h.zoom,b=f!==h.pitch,T=g!==h.bearing;return this.fire(new a.b("movestart",o)).fire(new a.b("move",o)),x&&this.fire(new a.b("zoomstart",o)).fire(new a.b("zoom",o)).fire(new a.b("zoomend",o)),T&&this.fire(new a.b("rotatestart",o)).fire(new a.b("rotate",o)).fire(new a.b("rotateend",o)),b&&this.fire(new a.b("pitchstart",o)).fire(new a.b("pitch",o)).fire(new a.b("pitchend",o)),this.fire(new a.b("moveend",o)),this}easeTo(r,o){this._stop(!1,r.easeId),(!1===(r=a.e({offset:[0,0],duration:500,easing:a.d0},r)).animate||this._prefersReducedMotion(r))&&(r.duration=0);const h=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),x=this.getPadding(),b="zoom"in r?+r.zoom:d,T="bearing"in r?this._normalizeBearing(r.bearing,f):f,M="pitch"in r?+r.pitch:g,S="padding"in r?r.padding:h.padding,C=a.P.convert(r.offset);let P,k,R;if("globe"===h.projection.name){const K=a.L.fromLngLat(h.center),ee=C.rotate(-h.angle);K.x+=ee.x/h.worldSize,K.y+=ee.y/h.worldSize;const ce=K.toLngLat(),re=a.bn.convert(r.center||ce);this._normalizeCenter(re),P=h.centerPoint.add(ee),k=new a.P(K.x,K.y).mult(h.worldSize),R=new a.P(a.a5(re.lng),a.ae(re.lat)).mult(h.worldSize).sub(k)}else{P=h.centerPoint.add(C);const K=h.pointLocation(P),ee=a.bn.convert(r.center||K);this._normalizeCenter(ee),k=h.project(K),R=h.project(ee).sub(k)}const O=h.zoomScale(b-d);let D,F;r.around&&(D=a.bn.convert(r.around),F=h.locationPoint(D));const Z=this._zooming||b!==d,V=this._rotating||f!==T,q=this._pitching||M!==g,B=!h.isPaddingEqual(S),$=K=>ee=>{if(Z&&(K.zoom=a.U(d,b,ee)),V&&(K.bearing=a.U(f,T,ee)),q&&(K.pitch=a.U(g,M,ee)),B&&(K.interpolatePadding(x,S,ee),P=K.centerPoint.add(C)),D)K.setLocationAtPoint(D,F);else{const ce=K.zoomScale(K.zoom-d),re=b>d?Math.min(2,O):Math.max(.5,O),me=Math.pow(re,1-ee),pe=K.unproject(k.add(R.mult(ee*me)).mult(ce));K.setLocationAtPoint(K.renderWorldCopies?pe.wrap():pe,P)}return r.preloadOnly||this._fireMoveEvents(o),K};if(r.preloadOnly){const K=this._emulate($,r.duration,h);return this._preloadTiles(K),this}const Y={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Z,this._rotating=V,this._pitching=q,this._easeId=r.easeId,this._prepareEase(o,r.noMoveStart,Y),this._ease($(h),K=>{"sea"===h.cameraElevationReference&&h.recenterOnTerrain(),this._afterEase(o,K)},r),this}_prepareEase(r,o,h={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),o||h.moving||this.fire(new a.b("movestart",r)),this._zooming&&!h.zooming&&this.fire(new a.b("zoomstart",r)),this._rotating&&!h.rotating&&this.fire(new a.b("rotatestart",r)),this._pitching&&!h.pitching&&this.fire(new a.b("pitchstart",r))}_fireMoveEvents(r){this.fire(new a.b("move",r)),this._zooming&&this.fire(new a.b("zoom",r)),this._rotating&&this.fire(new a.b("rotate",r)),this._pitching&&this.fire(new a.b("pitch",r))}_afterEase(r,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const h=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,h&&this.fire(new a.b("zoomend",r)),d&&this.fire(new a.b("rotateend",r)),f&&this.fire(new a.b("pitchend",r)),this.fire(new a.b("moveend",r))}flyTo(r,o){if(this._prefersReducedMotion(r)){const ne=a.ac(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(ne,o)}this.stop(),r=a.e({offset:[0,0],speed:1.2,curve:1.42,easing:a.d0},r);const h=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),x="zoom"in r?a.aa(+r.zoom,h.minZoom,h.maxZoom):d,b="bearing"in r?this._normalizeBearing(r.bearing,f):f,T="pitch"in r?+r.pitch:g,M=h.zoomScale(x-d),S=a.P.convert(r.offset),C=h.centerPoint.add(S),P=h.pointLocation(C);let k=r.center;if(k&&r.padding){const ne=this._cameraForBounds(this.transform,k,k,b,T,r);ne&&(k=ne.center)}k=a.bn.convert(k||P),this._normalizeCenter(k);const R=h.project(P),O=h.project(k).sub(R);let D=r.curve;const F=Math.max(h.width,h.height),Z=F/M,V=O.mag();if("minZoom"in r){const ne=a.aa(Math.min(r.minZoom,d,x),h.minZoom,h.maxZoom),ue=F/h.zoomScale(ne-d);D=Math.sqrt(ue/V*2)}const q=D*D;function B(ne){const ue=(Z*Z-F*F+(ne?-1:1)*q*q*V*V)/(2*(ne?Z:F)*q*V);return Math.log(Math.sqrt(ue*ue+1)-ue)}function $(ne){return(Math.exp(ne)-Math.exp(-ne))/2}function Y(ne){return(Math.exp(ne)+Math.exp(-ne))/2}const K=B(0);let ee=function(ne){return Y(K)/Y(K+D*ne)},ce=function(ne){return F*((Y(K)*($(ue=K+D*ne)/Y(ue))-$(K))/q)/V;var ue},re=(B(1)-K)/D;if(Math.abs(V)<1e-6||!isFinite(re)){if(Math.abs(F-Z)<1e-6)return this.easeTo(r,o);const ne=Z<F?-1:1;re=Math.abs(Math.log(Z/F))/D,ce=function(){return 0},ee=function(ue){return Math.exp(ne*D*ue)}}r.duration="duration"in r?+r.duration:1e3*re/("screenSpeed"in r?+r.screenSpeed/D:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0);const me=f!==b,pe=T!==g,Ae=ne=>ue=>{const Q=ue*re,ae=1/ee(Q);ne.zoom=1===ue?x:d+ne.scaleZoom(ae),me&&(ne.bearing=a.U(f,b,ue)),pe&&(ne.pitch=a.U(g,T,ue));const Ie=1===ue?k:ne.unproject(R.add(O.mult(ce(Q))).mult(ae));return ne.setLocationAtPoint(ne.renderWorldCopies?Ie.wrap():Ie,C),ne._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(o),ne};if(r.preloadOnly){const ne=this._emulate(Ae,r.duration,h);return this._preloadTiles(ne),this}return this._zooming=!0,this._rotating=me,this._pitching=pe,this._prepareEase(o,!1),this._ease(Ae(h),()=>this._afterEase(o),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const h=this._onEaseEnd;this._onEaseEnd=void 0,h.call(this,o)}if(!r){const h=this.handlers;h&&h.stop(!1)}return this}_ease(r,o,h){!1===h.animate||0===h.duration?(r(1),o()):(this._easeStart=a.f.now(),this._easeOptions=h,this._onEaseFrame=r,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((a.f.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,o){r=a.bh(r,-180,180);const h=Math.abs(r-o);return Math.abs(r-360-o)<h&&(r-=360),Math.abs(r+360-o)<h&&(r+=360),r}_normalizeCenter(r){const o=this.transform;if(o.maxBounds||"globe"!==o.projection.name&&!o.renderWorldCopies)return;const h=r.lng-o.center.lng;r.lng+=h>180?-360:h<-180?360:0}_prefersReducedMotion(r){return this._respectPrefersReducedMotion&&a.f.prefersReducedMotion&&!(r&&r.essential)}_emulate(r,o,h){const d=Math.ceil(15*o/1e3),f=[],g=r(h.clone());for(let x=0;x<=d;x++){const b=g(x/d);f.push(b.clone())}return f}}class gh{constructor(r={}){this.options=r,a.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const o=this.options&&this.options.compact;return this._map=r,this._container=Wt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Wt("button","mapboxgl-ctrl-attrib-button",this._container),Wt("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Wt("div","mapboxgl-ctrl-attrib-inner",this._container),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),void 0===o&&(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(r,o){const h=this._map._getUIString(`AttributionControl.${o}`);r.removeAttribute("title"),r.firstElementChild&&r.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 r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.d5.ACCESS_TOKEN}];if(r){const h=o.reduce((d,f,g)=>(f.value&&(d+=`${f.key}=${f.value}${g<o.length-1?"&":""}`),d),"?");r.href=`${a.d5.FEEDBACK_URL}/${h}#${sh(this._map,!0)}`,r.rel="noopener nofollow",this._setElementTitle(r,"MapFeedback")}}_updateData(r){!r||"metadata"!==r.sourceDataType&&"visibility"!==r.sourceDataType&&"style"!==r.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}const o=this._map.style._mergedSourceCaches;for(const d in o){const f=o[d];if(f.used){const g=f.getSource();g.attribution&&r.indexOf(g.attribution)<0&&r.push(g.attribution)}}r.sort((d,f)=>d.length-f.length),r=r.filter((d,f)=>{for(let g=f+1;g<r.length;g++)if(r[g].indexOf(d)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const h=r.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,r.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 Vu{constructor(){a.aY(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=Wt("div","mapboxgl-ctrl");const o=Wt("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(r){r&&"metadata"!==r.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(0===Object.entries(r).length)return!0;for(const o in r){const h=r[o].getSource();if(h.hasOwnProperty("mapbox_logo")&&!h.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const o=r[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class Uu{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const o=++this._id;return this._queue.push({callback:r,id:o,cancelled:!1}),o}remove(r){const o=this._currentlyRunning,h=o?this._queue.concat(o):this._queue;for(const d of h)if(d.id===r)return void(d.cancelled=!0)}run(r=0){const o=this._currentlyRunning=this._queue;this._queue=[];for(const h of o)if(!h.cancelled&&(h.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ia(c,r,o){if(c=new a.bn(c.lng,c.lat),r){const h=new a.bn(c.lng-360,c.lat),d=new a.bn(c.lng+360,c.lat),f=360*Math.ceil(Math.abs(c.lng-o.center.lng)/360),g=o.locationPoint(c).distSqr(r),x=r.x<0||r.y<0||r.x>o.width||r.y>o.height;o.locationPoint(h).distSqr(r)<g&&(x||Math.abs(h.lng-o.center.lng)<f)?c=h:o.locationPoint(d).distSqr(r)<g&&(x||Math.abs(d.lng-o.center.lng)<f)&&(c=d)}for(;Math.abs(c.lng-o.center.lng)>180;){const 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}const wl={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 yh extends a.E{constructor(r,o){if(super(),(r instanceof HTMLElement||o)&&(r=a.e({element:r},o)),a.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=r&&r.occludedOpacity||.2,r&&r.element)this._element=r.element,this._offset=a.P.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=Wt("div");const f=41,g=27,x=Rr("svg",{display:"block",height:f*this._scale+"px",width:g*this._scale+"px",viewBox:`0 0 ${g} ${f}`},this._element),b=Rr("radialGradient",{id:"shadowGradient"},Rr("defs",{},x));Rr("stop",{offset:"10%","stop-opacity":.4},b),Rr("stop",{offset:"100%","stop-opacity":.05},b),Rr("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x),Rr("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"},x),Rr("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"},x),Rr("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},x),this._offset=a.P.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",f=>{f.preventDefault()}),this._element.addEventListener("mousedown",f=>{f.preventDefault()});const h=this._element.classList;for(const f in wl)h.remove(`mapboxgl-marker-anchor-${f}`);h.add(`mapboxgl-marker-anchor-${this._anchor}`);const d=r&&r.className?r.className.trim().split(/\s+/):[];h.add(...d),this._popup=null}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=a.bn.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(r){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")),r){if(!("offset"in r.options)){const d=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(24.6+d)],"bottom-right":[-d,-1*(24.6+d)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=r,r._marker=this,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(r){const o=r.code,h=r.charCode||r.keyCode;"Space"!==o&&"Enter"!==o&&32!==h&&13!==h||this.togglePopup()}_onMapClick(r){const o=r.originalEvent.target,h=this._element;this._popup&&(o===h||h.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const r=this._map,o=this._pos;if(!r||!o)return!1;const h=r.unproject(o),d=r.getFreeCameraOptions();if(!d.position)return!1;const f=d.position.toLngLat();return f.distanceTo(h)<.9*f.distanceTo(this._lngLat)}_evaluateOpacity(){const r=this._map;if(!r)return;const o=this._pos;if(!o||o.x<0||o.x>r.transform.width||o.y<0||o.y>r.transform.height)return void this._clearFadeTimer();const h=r.unproject(o);let d;r._showingGlobe()&&a.d6(r.transform,this._lngLat)?d=0:(d=1-r._queryFogOpacity(h),r.transform._terrainEnabled()&&r.getTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r||!this._map)return;const o=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${r.x}px,${r.y}px)\n ${wl[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${o.x}px,${o.y}px)\n `}_calculateXYTransform(){const r=this._pos,o=this._map,h=this.getPitchAlignment();if(!o||!r||"map"!==h)return"";if(!o._showingGlobe()){const b=o.getPitch();return b?`rotateX(${b}deg)`:""}const d=a.bF(a.d7(o.transform,this._lngLat)),f=r.sub(a.d8(o.transform)),g=Math.abs(f.x)+Math.abs(f.y);if(0===g)return"";const x=d/g;return`rotateX(${-f.y*x}deg) rotateY(${f.x*x}deg)`}_calculateZTransform(){const r=this._pos,o=this._map;if(!o||!r)return"";let h=0;const d=this.getRotationAlignment();if("map"===d)if(o._showingGlobe()){const f=o.project(new a.bn(this._lngLat.lng,this._lngLat.lat+.001)),g=o.project(new a.bn(this._lngLat.lng,this._lngLat.lat-.001)).sub(f);h=a.bF(Math.atan2(g.y,g.x))-90}else h=-o.getBearing();else if("horizon"===d){const f=a.O(4,6,o.getZoom()),g=a.d8(o.transform);g.y+=f*o.transform.height;const x=r.sub(g),b=a.bF(Math.atan2(x.y,x.x));h=(b>90?b-270:b+90)*(1-f)}return h+=this._rotation,h?`rotateZ(${h}deg)`:""}_update(r){cancelAnimationFrame(this._updateFrameId);const o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=Ia(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat),!0===r?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=a.P.convert(r),this._update(),this}addClassName(r){return this._element.classList.add(r),this}removeClassName(r){return this._element.classList.remove(r),this}toggleClassName(r){return this._element.classList.toggle(r)}_onMove(r){const o=this._map;if(!o)return;const h=this._pointerdownPos,d=this._positionDelta;if(h&&d){if(!this._isDragging){const f=this._clickTolerance||o._clickTolerance;if(r.point.dist(h)<f)return;this._isDragging=!0}this._pos=r.point.sub(d),this._lngLat=o.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.b("dragstart"))),this.fire(new a.b("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new a.b("dragend")),this._state="inactive"}_addDragHandler(r){const o=this._map,h=this._pos;o&&h&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(h),this._pointerdownPos=r.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(r){this._draggable=!!r;const o=this._map;return o&&(r?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(r){return this._occludedOpacity=r||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const ju={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Gu=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Zu(c=new a.P(0,0),r="bottom"){if("number"==typeof c){const o=Math.round(Math.sqrt(.5*Math.pow(c,2)));switch(r){case"top":return new a.P(0,c);case"top-left":return new a.P(o,o);case"top-right":return new a.P(-o,o);case"bottom":return new a.P(0,-c);case"bottom-left":return new a.P(o,-o);case"bottom-right":return new a.P(-o,-o);case"left":return new a.P(c,0);case"right":return new a.P(-c,0)}return new a.P(0,0)}return c instanceof a.P||Array.isArray(c)?a.P.convert(c):a.P.convert(c[r]||[0,0])}class xh{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const o=a.cc((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,o,h){this._start=this.getValue(o),this._end=r,this._startTime=o,this._endTime=o+h}}const Ca={"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","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","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"},qu={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,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1};class vh{constructor(){this.showOverdrawInspector=!1,this.showTileBoundaries=!1,this.showParseStatus=!1,this.continuousRedraw=!1,this.showTileAABBs=!1,this.showPadding=!1,this.showTerrainWireframe=!1,this.showLayers2DWireframe=!1,this.showLayers3DWireframe=!1}}const Tl={showCompass:!0,showZoom:!0,visualizePitch:!1};class kn{constructor(r,o,h=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new ba({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,h&&(this.mousePitch=new vl({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),a.aY(["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(r,o){this.mouseRotate.mousedown(r,o),this.mousePitch&&this.mousePitch.mousedown(r,o),Ua()}move(r,o){const h=this.map,d=this.mouseRotate.mousemoveWindow(r,o),f=d&&d.bearingDelta;if(f&&h.setBearing(h.getBearing()+f),this.mousePitch){const g=this.mousePitch.mousemoveWindow(r,o),x=g&&g.pitchDelta;x&&h.setPitch(h.getPitch()+x)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart,{passive:!1}),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){kr(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(a.e({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),$n(this.element,r)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,$n(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){1!==r.targetTouches.length?this.reset():(this._startPos=this._lastPos=Wn(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){1!==r.targetTouches.length?this.reset():(this._lastPos=Wn(this.element,r.targetTouches)[0],this.move({preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){0===r.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const Ml={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},gr={maxWidth:100,unit:"metric"},mo={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"};return{version:a.dk,supported:Qr,setRTLTextPlugin:a.dm,getRTLTextPluginStatus:a.dn,Map:class extends Oi{constructor(c){const r=c;if(null!=(c=a.e({},qu,c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(c.antialias&&a.d9(window)&&(c.antialias=!1,a.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new ia(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._repaint=!1,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._collectResourceTiming=c.collectResourceTiming,this._language=this._parseLanguage(c.language),this._worldview=c.worldview,this._renderTaskQueue=new Uu,this._domRenderTaskQueue=new Uu,this._controls=[],this._markers=[],this._popups=[],this._mapId=a.aC(),this._locale=a.e({},Ca,c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._performanceMetricsCollection=c.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new xh(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new a.da(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,this._contextCreateOptions=c.contextCreateOptions?{...c.contextCreateOptions}:{},"string"==typeof c.container){const o=document.getElementById(c.container);if(!o)throw new Error(`Container '${c.container.toString()}' not found.`);this._container=o}else{if(!(c.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.w("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.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._debugParams=new vh,this._tp=c.devtools?new ma(this):new ma,this._tp.registerParameter(this._debugParams,["Debug"],"showOverdrawInspector",void 0,()=>{this._update()}),this._tp.registerParameter(this._debugParams,["Debug"],"showTileBoundaries",void 0,()=>{this._update()}),this._tp.registerParameter(this._debugParams,["Debug"],"showParseStatus",void 0,()=>{this._update()}),this._tp.registerParameter(this._debugParams,["Debug"],"continuousRedraw",void 0,o=>{this.repaint=o}),this._tp.registerParameter(this._debugParams,["Debug"],"showTileAABBs",void 0,o=>{this.showTileAABBs=o}),this._tp.registerParameter(this._debugParams,["Debug"],"showPadding",void 0,o=>{this.showPadding=o}),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showTerrainWireframe",void 0,()=>{this._update()}),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showLayers2DWireframe",void 0,()=>{this._update()}),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showLayers3DWireframe",void 0,()=>{this._update()}),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new fp(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,(c.style||!c.testMode)&&this.setStyle(c.style||a.d5.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),c.hash&&(this._hash=new gl("string"==typeof c.hash&&c.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch});const o=c.bounds;o&&(this.resize(),this.fitBounds(o,a.e({},c.fitBoundsOptions,{duration:0})))}this.resize(),c.attributionControl&&this.addControl(new gh({customAttribution:c.customAttribution})),this._logoControl=new Vu,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",o=>{this._update("style"===o.dataType),this.fire(new a.b(`${o.dataType}data`,o))}),this.on("dataloading",o=>{this.fire(new a.b(`${o.dataType}dataloading`,o))})}_getMapId(){return this._mapId}addControl(c,r){if(void 0===r&&(r=c.getDefaultPosition?c.getDefaultPosition():"top-right"),!c||!c.onAdd)return this.fire(new a.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=c.onAdd(this);this._controls.push(c);const h=this._controlPositions[r];return-1!==r.indexOf("bottom")?h.insertBefore(o,h.firstChild):h.appendChild(o),this}removeControl(c){if(!c||!c.onRemove)return this.fire(new a.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(c);return r>-1&&this._controls.splice(r,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));const r=!this._moving;return r&&this.fire(new a.b("movestart",c)).fire(new a.b("move",c)),this.fire(new a.b("resize",c)),r&&this.fire(new a.b("moveend",c)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(c){return this.transform.setMaxBounds(a.ad.convert(c)),this._update()}setMinZoom(c){if((c=c??-2)>=-2&&c<=this.transform.maxZoom)return this.transform.minZoom=c,this._update(),this.getZoom()<c?this.setZoom(c):this.fire(new a.b("zoomstart")).fire(new a.b("zoom")).fire(new a.b("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??22)>=this.transform.minZoom)return this.transform.maxZoom=c,this._update(),this.getZoom()>c?this.setZoom(c):this.fire(new a.b("zoomstart")).fire(new a.b("zoom")).fire(new a.b("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(c){if((c=c??0)<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.b("pitchstart")).fire(new a.b("pitch")).fire(new a.b("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??85)>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.b("pitchstart")).fire(new a.b("pitch")).fire(new a.b("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(c){return this.transform.renderWorldCopies=c,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(c){return"auto"===c?navigator.language:Array.isArray(c)?0===c.length?void 0:c.map(r=>"auto"===r?navigator.language:r):c}setLanguage(c){const r=this._parseLanguage(c);if(!this.style||r===this._language)return this;this._language=r,this.style.reloadSources();for(const o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(c){return this.style&&c!==this._worldview?(this._worldview=c,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(c){return this._lazyInitEmptyStyle(),c?"string"==typeof c&&(c={name:c}):c=null,this._useExplicitProjection=!!c,this._prioritizeAndUpdateProjection(c,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const c=this.transform,r=c.projection.name;let o;"globe"===r&&c.zoom>=a.bx?(c.setMercatorFromTransition(),o=!0):"mercator"===r&&c.zoom<a.bx&&(c.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(c,r){return this._updateProjection(c||r||{name:"mercator"})}_updateProjection(c){let r;return r="globe"===c.name&&this.transform.zoom>=a.bx?this.transform.setMercatorFromTransition():this.transform.setProjection(c),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(c){return this.transform.locationPoint3D(a.bn.convert(c))}unproject(c){return this.transform.pointLocation3D(a.P.convert(c))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(c,r,o){if("mouseenter"===c||"mouseover"===c){let h=!1;const d=g=>{const x=r.filter(T=>this.getLayer(T)),b=x.length?this.queryRenderedFeatures(g.point,{layers:x}):[];b.length?h||(h=!0,o.call(this,new wr(c,this,g.originalEvent,{features:b}))):h=!1},f=()=>{h=!1};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}if("mouseleave"===c||"mouseout"===c){let h=!1;const d=g=>{const x=r.filter(b=>this.getLayer(b));(x.length?this.queryRenderedFeatures(g.point,{layers:x}):[]).length?h=!0:h&&(h=!1,o.call(this,new wr(c,this,g.originalEvent)))},f=g=>{h&&(h=!1,o.call(this,new wr(c,this,g.originalEvent)))};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}{const h=d=>{const f=r.filter(x=>this.getLayer(x)),g=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];g.length&&(d.features=g,o.call(this,d),delete d.features)};return{layers:new Set(r),listener:o,delegates:{[c]:h}}}}on(c,r,o){if(void 0===o)return super.on(c,r);if(Array.isArray(r)||(r=[r]),r)for(const d of r)if(!this._isValidId(d))return this;const h=this._createDelegatedListener(c,r,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[c]=this._delegatedListeners[c]||[],this._delegatedListeners[c].push(h);for(const d in h.delegates)this.on(d,h.delegates[d]);return this}once(c,r,o){if(void 0===o)return super.once(c,r);if(Array.isArray(r)||(r=[r]),r)for(const d of r)if(!this._isValidId(d))return this;const h=this._createDelegatedListener(c,r,o);for(const d in h.delegates)this.once(d,h.delegates[d]);return this}off(c,r,o){if(void 0===o)return super.off(c,r);r=new Set(Array.isArray(r)?r:[r]);for(const f of r)if(!this._isValidId(f))return this;const h=(f,g)=>{if(f.size!==g.size)return!1;for(const x of f)if(!g.has(x))return!1;return!0},d=this._delegatedListeners?this._delegatedListeners[c]:void 0;return d&&(f=>{for(let g=0;g<f.length;g++){const x=f[g];if(x.listener===o&&h(x.layers,r)){for(const b in x.delegates)this.off(b,x.delegates[b]);return f.splice(g,1),this}}})(d),this}queryRenderedFeatures(c,r){if(!this.style)return[];if(void 0!==r||void 0===c||c instanceof a.P||Array.isArray(c)||(r=c,c=void 0),c=c||[[0,0],[this.transform.width,this.transform.height]],(r=r||{}).layers&&Array.isArray(r.layers))for(const o of r.layers)if(!this._isValidId(o))return[];return this.style.queryRenderedFeatures(c,r,this.transform)}querySourceFeatures(c,r){return this._isValidId(c)?this.style.querySourceFeatures(c,r):[]}isPointOnSurface(c){const{name:r}=this.transform.projection;return"globe"!==r&&"mercator"!==r&&a.w(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(a.P.convert(c))}setStyle(c,r){return!1!==(r=a.e({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r)).diff&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.localFontFamily===this._localFontFamily&&this.style&&c?(this._diffStyle(c,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(c,r))}_getUIString(c){const r=this._locale[c];if(null==r)throw new Error(`Missing UI string '${c}'`);return r}_updateStyle(c,r){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),c&&(this.style=new sn(this,r||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof c?this.style.loadURL(c):this.style.loadJSON(c)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new sn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(c,r){if("string"==typeof c){const o=this._requestManager.normalizeStyleURL(c),h=this._requestManager.transformRequest(o,a.R.Style);a.g(h,(d,f)=>{d?this.fire(new a.a(d)):f&&this._updateDiff(f,r)})}else"object"==typeof c&&this._updateDiff(c,r)}_updateDiff(c,r){try{this.style.setState(c)&&this._update(!0)}catch(o){a.w(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(c,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(a.w("There is no style added to the map."),!1)}_isValidId(c){return null==c?(this.fire(new a.a(new Error("IDs can't be empty."))),!1):!a.c4(c)||(this.fire(new a.a(new Error(`IDs can't contain special symbols: "${c}".`))),!1)}addSource(c,r){return this._isValidId(c)?(this._lazyInitEmptyStyle(),this.style.addSource(c,r),this._update(!0)):this}isSourceLoaded(c){return!!this._isValidId(c)&&!!this.style&&this.style._isSourceCacheLoaded(c)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(c,r,o){this._lazyInitEmptyStyle(),this.style.addSourceType(c,r,o)}removeSource(c){return this._isValidId(c)?(this.style.removeSource(c),this._updateTerrain(),this._update(!0)):this}getSource(c){return this._isValidId(c)?this.style.getOwnSource(c):null}addImage(c,r,{pixelRatio:o=1,sdf:h=!1,stretchX:d,stretchY:f,content:g}={}){if(this._lazyInitEmptyStyle(),r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){const{width:x,height:b,data:T}=a.f.getImageData(r);this.style.addImage(c,{data:new a.h({width:x,height:b},T),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:h,version:0})}else if(void 0===r.width||void 0===r.height)this.fire(new a.a(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`")));else{const{width:x,height:b}=r,T=r;this.style.addImage(c,{data:new a.h({width:x,height:b},new Uint8Array(T.data)),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:h,version:0,userImage:T}),T.onAdd&&T.onAdd(this,c)}}updateImage(c,r){this._lazyInitEmptyStyle();const o=this.style.getImage(c);if(!o)return void this.fire(new a.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const h=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?a.f.getImageData(r):r,{width:d,height:f}=h,g=h.data;if(void 0===d||void 0===f)return void this.fire(new a.a(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(d!==o.data.width||f!==o.data.height)return void this.fire(new a.a(new Error(`The width and height of the updated image (${d}, ${f})\n must be that same as the previous version of the image\n (${o.data.width}, ${o.data.height})`)));const x=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);o.data.replace(g,x),this.style.updateImage(c,o)}hasImage(c){return c?!!this.style&&!!this.style.getImage(c):(this.fire(new a.a(new Error("Missing required image id"))),!1)}removeImage(c){this.style.removeImage(c)}loadImage(c,r){a.d(this._requestManager.transformRequest(c,a.R.Image),(o,h)=>{r(o,h instanceof HTMLImageElement?a.f.getImageData(h):h)})}listImages(){return this.style.listImages()}addModel(c,r){this._lazyInitEmptyStyle(),this.style.addModel(c,r)}hasModel(c){return c?this.style.hasModel(c):(this.fire(new a.a(new Error("Missing required model id"))),!1)}removeModel(c){this.style.removeModel(c)}listModels(){return this.style.listModels()}addLayer(c,r){return this._isValidId(c.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(c,r),this._update(!0)):this}getSlot(c){const r=this.getLayer(c);return r&&r.slot||null}setSlot(c,r){return this.style.setSlot(c,r),this.style.mergeLayers(),this._update(!0)}addImport(c,r){return this.style.addImport(c,r),this}updateImport(c,r){return"string"!=typeof r&&r.id!==c?(this.removeImport(c),this.addImport(r)):(this.style.updateImport(c,r),this._update(!0))}removeImport(c){return this.style.removeImport(c),this}moveImport(c,r){return this.style.moveImport(c,r),this._update(!0)}moveLayer(c,r){return this._isValidId(c)?(this.style.moveLayer(c,r),this._update(!0)):this}removeLayer(c){return this._isValidId(c)?(this.style.removeLayer(c),this._update(!0)):this}getLayer(c){return this._isValidId(c)?this.style.getOwnLayer(c):null}setLayerZoomRange(c,r,o){return this._isValidId(c)?(this.style.setLayerZoomRange(c,r,o),this._update(!0)):this}setFilter(c,r,o={}){return this._isValidId(c)?(this.style.setFilter(c,r,o),this._update(!0)):this}getFilter(c){return this._isValidId(c)?this.style.getFilter(c):null}setPaintProperty(c,r,o,h={}){return this._isValidId(c)?(this.style.setPaintProperty(c,r,o,h),this._update(!0)):this}getPaintProperty(c,r){return this._isValidId(c)?this.style.getPaintProperty(c,r):null}setLayoutProperty(c,r,o,h={}){return this._isValidId(c)?(this.style.setLayoutProperty(c,r,o,h),this._update(!0)):this}getLayoutProperty(c,r){return this._isValidId(c)?this.style.getLayoutProperty(c,r):null}getConfigProperty(c,r){return this.style.getConfigProperty(c,r)}setConfigProperty(c,r,o){return this.style.setConfigProperty(c,r,o),this._update(!0)}setLights(c){if(this._lazyInitEmptyStyle(),c&&1===c.length&&"flat"===c[0].type){const r=c[0];r.properties?this.style.setFlatLight(r.properties,r.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(c),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const c=this.style.getLights()||[];return 0===c.length&&c.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),c}setLight(c,r={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:c}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(c){return this._lazyInitEmptyStyle(),!c&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(c),this._averageElevationLastSampledAt=-1/0,this._update(!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}setCamera(c){return this.style.setCamera(c),this._triggerCameraUpdate(c)}_triggerCameraUpdate(c){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===c["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(c){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.bn.convert(c),this.transform):0}setFeatureState(c,r){return this._isValidId(c.source)?(this.style.setFeatureState(c,r),this._update()):this}removeFeatureState(c,r){return this._isValidId(c.source)?(this.style.removeFeatureState(c,r),this._update()):this}getFeatureState(c){return this._isValidId(c.source)?this.style.getFeatureState(c):null}_updateContainerDimensions(){if(!this._container)return;const c=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let o,h,d,f=this._container;for(;f&&(!h||!d);){const g=window.getComputedStyle(f).transform;g&&"none"!==g&&(o=g.match(/matrix.*\((.+)\)/)[1].split(", "),o[0]&&"0"!==o[0]&&"1"!==o[0]&&(h=o[0]),o[3]&&"0"!==o[3]&&"1"!==o[3]&&(d=o[3])),f=f.parentElement}this._containerWidth=h?Math.abs(c/h):c,this._containerHeight=d?Math.abs(r/d):r}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.w("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(){const c=this._container;c.classList.add("mapboxgl-map"),(this._missingCSSCanary=Wt("div","mapboxgl-canary",c)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=Wt("div","mapboxgl-canvas-container",c);this._canvas=Wt("canvas","mapboxgl-canvas",r),this._interactive&&(r.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const o=this._controlContainer=Wt("div","mapboxgl-control-container",c),h=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{h[d]=Wt("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(c,r){const o=a.f.devicePixelRatio||1;this._canvas.width=o*Math.ceil(c),this._canvas.height=o*Math.ceil(r),this._canvas.style.width=`${c}px`,this._canvas.style.height=`${r}px`}_addMarker(c){this._markers.push(c)}_removeMarker(c){const r=this._markers.indexOf(c);-1!==r&&this._markers.splice(r,1)}_addPopup(c){this._popups.push(c)}_removePopup(c){const r=this._popups.indexOf(c);-1!==r&&this._popups.splice(r,1)}_setupPainter(){const c=a.e({},Qr.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl2",c);r?(a.db(r,!0),this.painter=new Cu(r,this._contextCreateOptions,this.transform,this._tp),this.on("data",o=>{"source"===o.dataType&&this.painter.setTileLoadedFlag(!0)}),a.dc.testSupport(r)):this.fire(new a.a(new Error("Failed to initialize WebGL")))}_contextLost(c){c.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.b("webglcontextlost",{originalEvent:c}))}_contextRestored(c){this._setupPainter(),this.resize(),this._update(),this.fire(new a.b("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 r;this.fire(new a.b("renderstart"));const o=this.painter.context.extTimerQuery,h=a.f.now(),d=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=d.createQuery(),d.beginQuery(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(c),this._domRenderTaskQueue.run(c),this._removed)return;this._updateProjectionTransition();const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const b=this.transform.zoom,T=this.transform.pitch,M=a.f.now(),S=new a.K(b,{now:M,fadeDuration:f,pitch:T,transition:this.style.transition});this.style.update(S)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let g=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),g=this._updateAverageElevation(h),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):g=this._updateAverageElevation(h),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries||this._debugParams.showTileBoundaries,showParseStatus:this.showParseStatus||this._debugParams.showParseStatus,wireframe:{terrain:this.showTerrainWireframe||this._debugParams.showTerrainWireframe,layers2D:this.showLayers2DWireframe||this._debugParams.showLayers2DWireframe,layers3D:this.showLayers3DWireframe||this._debugParams.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector||this._debugParams.showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs||this._debugParams.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding||this._debugParams.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const b=a.f.now()-h;d.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const T=d.getQueryParameter(r,d.QUERY_RESULT)/1e6;d.deleteQuery(r),this.fire(new a.b("gpu-timing-frame",{cpuTime:b,gpuTime:T}))},50)}if(this.listens("gpu-timing-layer")){const b=this.painter.collectGpuTimers();setTimeout(()=>{const T=this.painter.queryGpuTimers(b);this.fire(new a.b("gpu-timing-layer",{layerTimes:T}))},50)}if(this.listens("gpu-timing-deferred-render")){const b=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const T=this.painter.queryGpuTimeDeferredRender(b);this.fire(new a.b("gpu-timing-deferred-render",{gpuTime:T}))},50)}const x=this._sourcesDirty||this._styleDirty||this._placementDirty||g;if(x||this._repaint)this.triggerRepaint();else{const b=!this.isMoving()&&this.loaded();if(b&&(g=this._updateAverageElevation(h,!0)),g)this.triggerRepaint();else if(this._triggerFrame(!1),b&&(this.fire(new a.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const T=this._calculateSpeedIndex();this.fire(new a.b("speedindexcompleted",{speedIndex:T})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||x||(this._fullyLoaded=!0,this._performanceMetricsCollection&&a.dd(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(c){for(const r of this._markers)c&&!this.getRenderWorldCopies()&&(r._lngLat=r._lngLat.wrap()),r._update();for(const r of this._popups)!c||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}_updateAverageElevation(c,r=!1){const o=d=>(this.transform.averageElevation=d,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&o(0);const h=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(h||(r||c-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(c)){const d=this.transform.averageElevation;let f=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(f)?f=0:this._averageElevationLastSampledAt=c;const g=Math.abs(d-f);if(g>1){if(this._isInitialLoad||h)return this._averageElevation.jumpTo(f),o(f);this._averageElevation.easeTo(f,c,300)}else if(g>1e-4)return this._averageElevation.jumpTo(f),o(f)}return!!this._averageElevation.isEasing(c)&&o(this._averageElevation.getValue(c))}_authenticate(){a.de(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.df||401===c.status)){const r=this.painter.context.gl;a.db(r,!1),this._logoControl instanceof Vu&&this._logoControl._updateLogo(),r&&r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.a(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.dg(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const c=this._isDragging();this.painter.updateTerrain(this.style,c)}_calculateSpeedIndex(){const c=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const o=this.painter.context.gl,h=o.createFramebuffer();function d(f){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0);const g=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,g),g}return o.bindFramebuffer(o.FRAMEBUFFER,h),this._canvasPixelComparison(d(c),r.canvasCopies.map(d),r.timeStamps)}_canvasPixelComparison(c,r,o){let h=o[1]-o[0];const d=c.length/4;for(let f=0;f<r.length;f++){const g=r[f];let x=0;for(let b=0;b<g.length;b+=4)g[b]===c[b]&&g[b+1]===c[b+1]&&g[b+2]===c[b+2]&&g[b+3]===c[b+3]&&(x+=1);h+=(o[f+2]-o[f+1])*(1-x/d)}return h}remove(){this._hash&&this._hash.remove();for(const r of this._controls)r.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&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const c=this.painter.context.gl.getExtension("WEBGL_lose_context");c&&c.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),a.dh(this.painter.context.gl),a.di.remove(),a.dj.remove(),this._removed=!0,this.fire(new a.b("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(c){this._renderNextFrame=this._renderNextFrame||c,this.style&&!this._frame&&(this._frame=a.f.frame(r=>{const o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(r)}))}_preloadTiles(c){const r=this.style?Object.values(this.style._sourceCaches):[];return a.b1(r,(o,h)=>o._preloadTiles(c,h),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(c){this._trackResize&&this.resize({originalEvent:c})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(c){this._showTileBoundaries!==c&&(this._showTileBoundaries=c,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(c){this._showParseStatus!==c&&(this._showParseStatus=c,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(c){this._showTerrainWireframe!==c&&(this._showTerrainWireframe=c,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(c){this._showLayers2DWireframe!==c&&(this._showLayers2DWireframe=c,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(c){this._showLayers3DWireframe!==c&&(this._showLayers3DWireframe=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()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(c){this._showTileAABBs!==c&&(this._showTileAABBs=c,c&&this._update())}_setCacheLimits(c,r){a.dl(c,r)}get version(){return a.dk}},NavigationControl:class{constructor(c){this.options=a.e({},Tl,c),this._container=Wt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(a.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),Wt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),Wt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(a.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:r}):o.resetNorth({},{originalEvent:r}))}),this._compassIcon=Wt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const c=this._map;if(!c)return;const r=c.getZoom(),o=r===c.getMaxZoom(),h=r===c.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=h,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",h.toString())}_rotateCompassArrow(){const c=this._map;if(!c)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(c.transform.pitch*(Math.PI/180)),.5)}) rotateX(${c.transform.pitch}deg) rotateZ(${c.transform.angle*(180/Math.PI)}deg)`:`rotate(${c.transform.angle*(180/Math.PI)}deg)`;c._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=r)})}onAdd(c){return this._map=c,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),c.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&c.on("pitch",this._rotateCompassArrow),c.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new kn(c,this._compass,this.options.visualizePitch)),this._container}onRemove(){const c=this._map;c&&(this._container.remove(),this.options.showZoom&&c.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&c.off("pitch",this._rotateCompassArrow),c.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(c,r){const o=Wt("button",c,this._container);return o.type="button",o.addEventListener("click",r),o}_setButtonTitle(c,r){if(!this._map)return;const o=this._map._getUIString(`NavigationControl.${r}`);c.setAttribute("aria-label",o),c.firstElementChild&&c.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends a.E{constructor(c){super();const r=navigator.geolocation;this.options=a.e({geolocation:r},Ml,c),a.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=ga(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(c){return this._map=c,this._container=Wt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.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,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(c){const r=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,c(o)};void 0!==this._supportsGeolocation?c(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(o=>r("denied"!==o.state)).catch(()=>r()):r()}_isOutOfMapMaxBounds(c){const r=this._map.getMaxBounds(),o=c.coords;return!!r&&(o.longitude<r.getWest()||o.longitude>r.getEast()||o.latitude<r.getSouth()||o.latitude>r.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.b("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&&"OFF"!==this._watchState&&this._updateMarker(c),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(c),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.b("geolocate",c)),this._finish()}}_updateCamera(c){const r=new a.bn(c.coords.longitude,c.coords.latitude),o=c.coords.accuracy,h=this._map.getBearing(),d=a.e({bearing:h},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(o),d,{geolocateSource:!0})}_updateMarker(c){if(c){const r=new a.bn(c.coords.longitude,c.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=c.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const c=this._map.transform,r=a.bl(1,c._center.lat)*c.worldSize,o=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(c){if(this._map){if(this.options.trackUserLocation)if(1===c.code){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;const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===c.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.b("error",c)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(c){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=Wt("button","mapboxgl-ctrl-geolocate",this._container),Wt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===c){a.w("Geolocation support is not available so the GeolocateControl will be disabled.");const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}else{const r=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Wt("div","mapboxgl-user-location"),this._dotElement.appendChild(Wt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Wt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new yh({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Wt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new yh({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",r=>{r.geolocateSource||"ACTIVE_LOCK"!==this._watchState||r.originalEvent&&"resize"===r.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.b("trackuserlocationend")))})}}_onDeviceOrientation(c){this._userLocationDotMarker&&(c.webkitCompassHeading?this._heading=c.webkitCompassHeading:!0===c.absolute&&(this._heading=-1*c.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.b("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!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.b("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.b("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("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let c;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(c={maximumAge:6e5,timeout:0},this._noTimeout=!0):(c=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,c),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const c=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(r=>{"granted"===r&&c()}).catch(console.error):c()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),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:gh,ScaleControl:class{constructor(c){this.options=a.e({},gr,c),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),a.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const c=this.options.maxWidth||100,r=this._map,o=r._containerHeight/2,h=r._containerWidth/2-c/2,d=r.unproject([h,o]),f=r.unproject([h+c,o]),g=d.distanceTo(f);if("imperial"===this.options.unit){const x=3.2808*g;x>5280?this._setScale(c,x/5280,"mile"):this._setScale(c,x,"foot")}else"nautical"===this.options.unit?this._setScale(c,g/1852,"nautical-mile"):g>=1e3?this._setScale(c,g/1e3,"kilometer"):this._setScale(c,g,"meter")}_setScale(c,r,o){this._map._requestDomTask(()=>{const h=function(f){const g=Math.pow(10,`${Math.floor(f)}`.length-1);let x=f/g;return x=x>=10?10:x>=5?5:x>=3?3:x>=2?2:x>=1?1:function(b){const T=Math.pow(10,Math.ceil(-Math.log(b)/Math.LN10));return Math.round(b*T)/T}(x),g*x}(r),d=h/r;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==o?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(h):`${h}&nbsp;${mo[o]}`,this._container.style.width=c*d+"px"})}onAdd(c){return this._map=c,this._language=c.getLanguage(),this._container=Wt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",c.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(c){this._language=c,this._update()}setUnit(c){this.options.unit=c,this._update()}},FullscreenControl:class{constructor(c){this._fullscreen=!1,c&&c.container&&(c.container instanceof HTMLElement?this._container=c.container:a.w("Full screen control 'container' must be a DOM element.")),a.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=Wt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const c=this._fullscreenButton=Wt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Wt("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden","true"),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const 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(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.E{constructor(c){super(),this.options=a.e(Object.create(ju),c),a.aY(["_update","_onClose","remove","_onMouseEvent"],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&&c.on("preclick",this._onClose),this.options.closeOnMove&&c.on("move",this._onClose),c.on("remove",this.remove),this._update(),c._addPopup(this),this._focusFirstElement(),this._trackPointer?(c.on("mousemove",this._onMouseEvent),c.on("mouseup",this._onMouseEvent),c._canvasContainer.classList.add("mapboxgl-track-pointer")):c.on("move",this._update),this.fire(new a.b("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const c=this._map;return c&&(c.off("move",this._update),c.off("move",this._onClose),c.off("preclick",this._onClose),c.off("click",this._onClose),c.off("remove",this.remove),c.off("mousemove",this._onMouseEvent),c.off("mouseup",this._onMouseEvent),c.off("drag",this._onMouseEvent),c._canvasContainer&&c._canvasContainer.classList.remove("mapboxgl-track-pointer"),c._removePopup(this),this._map=void 0),this.fire(new a.b("close")),this}getLngLat(){return this._lngLat}setLngLat(c){this._lngLat=a.bn.convert(c),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const c=this._map;return c&&(c.off("move",this._update),c.on("mousemove",this._onMouseEvent),c.on("drag",this._onMouseEvent),c._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(c){return this.setDOMContent(document.createTextNode(c))}setHTML(c){const r=document.createDocumentFragment(),o=document.createElement("body");let h;for(o.innerHTML=c;h=o.firstChild,h;)r.appendChild(h);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(c){return this.options.maxWidth=c,this._update(),this}setDOMContent(c){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=Wt("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(c),this.options.closeButton){const o=this._closeButton=Wt("button","mapboxgl-popup-close-button",r);o.type="button",o.setAttribute("aria-label","Close popup"),o.setAttribute("aria-hidden","true"),o.innerHTML="&#215;",o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(c){return this._classList.add(c),this._updateClassList(),this}removeClassName(c){return this._classList.delete(c),this._updateClassList(),this}setOffset(c){return this.options.offset=c,this._update(),this}toggleClassName(c){let r;return this._classList.delete(c)?r=!1:(this._classList.add(c),r=!0),this._updateClassList(),r}_onMouseEvent(c){this._update(c.point)}_getAnchor(c){if(this.options.anchor)return this.options.anchor;const r=this._map,o=this._container,h=this._pos;if(!r||!o||!h)return"bottom";const d=o.offsetWidth,f=o.offsetHeight,g=h.x<d/2,x=h.x>r.transform.width-d/2;if(h.y+c<f)return g?"top-left":x?"top-right":"top";if(h.y>r.transform.height-f){if(g)return"bottom-left";if(x)return"bottom-right"}return g?"left":x?"right":"bottom"}_updateClassList(){const c=this._container;if(!c)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),c.className=r.join(" ")}_update(c){const r=this._map,o=this._content;if(!r||!this._lngLat&&!this._trackPointer||!o)return;let h=this._container;if(h||(h=this._container=Wt("div","mapboxgl-popup",r.getContainer()),this._tip=Wt("div","mapboxgl-popup-tip",h),h.appendChild(o)),this.options.maxWidth&&h.style.maxWidth!==this.options.maxWidth&&(h.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ia(this._lngLat,this._pos,r.transform)),!this._trackPointer||c){const d=this._pos=this._trackPointer&&c?c:r.project(this._lngLat),f=Zu(this.options.offset),g=this._anchor=this._getAnchor(f.y),x=Zu(this.options.offset,g),b=d.add(x).round();r._requestDomTask(()=>{this._container&&g&&(this._container.style.transform=`${wl[g]} translate(${b.x}px,${b.y}px)`)})}if(!this._marker&&r._showingGlobe()){const d=a.d6(r.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const c=this._container.querySelector(Gu);c&&c.focus()}_onClose(){this.remove()}_setOpacity(c){this._container&&(this._container.style.opacity=`${c}`),this._content&&(this._content.style.pointerEvents=c?"auto":"none")}},Marker:yh,Style:sn,LngLat:a.bn,LngLatBounds:a.ad,Point:a.P,MercatorCoordinate:a.L,FreeCameraOptions:ea,Evented:a.E,config:a.d5,prewarm:a.dp,clearPrewarmedResources:a.dq,get accessToken(){return a.d5.ACCESS_TOKEN},set accessToken(c){a.d5.ACCESS_TOKEN=c},get baseApiUrl(){return a.d5.API_URL},set baseApiUrl(c){a.d5.API_URL=c},get workerCount(){return a.dr.workerCount},set workerCount(c){a.dr.workerCount=c},get maxParallelImageRequests(){return a.d5.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(c){a.d5.MAX_PARALLEL_IMAGE_REQUESTS=c},clearStorage(c){a.ds(c)},get workerUrl(){return a.dt.workerUrl},set workerUrl(c){a.dt.workerUrl=c},get workerClass(){return a.dt.workerClass},set workerClass(c){a.dt.workerClass=c},get workerParams(){return a.dt.workerParams},set workerParams(c){a.dt.workerParams=c},get dracoUrl(){return a.du()},set dracoUrl(c){a.dv(c)},get meshoptUrl(){return a.dw()},set meshoptUrl(c){a.dx(c)},setNow:a.f.setNow,restoreNow:a.f.restoreNow}}),jd}()}}]);