@kvass/widgets 1.3.71 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/map.js CHANGED
@@ -1,11 +1,11 @@
1
- import{q as ES,r as Jp,b as kn,i as MS,D as SS,o as Kp,c as ev,a as AS,t as IS,d as CS,y as zS,_ as DS,h as kS,e as PS,w as RS,j as LS,v as tv,p as BS}from"./_plugin-vue_export-helper.js";import{T as OS}from"./index.es.js";var rv={},FS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},iv={exports:{}};(function(Bi,Zt){(function(bi,Ur){Bi.exports=Ur()})(FS,function(){var bi,Ur,Qo;function to(we,$){if(!bi)bi=$;else if(!Ur)Ur=$;else{var Vr="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 = {}; ("+bi+")(sharedChunk); ("+Ur+")(sharedChunk); self.onerror = null;",Ti={};bi(Ti),Qo=$(Ti),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(Qo.workerUrl=window.URL.createObjectURL(new Blob([Vr],{type:"text/javascript"})))}}to(["exports"],function(we){var $=typeof self<"u"?self:{},Vr="3.1.2";let Ti;const Ke={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Ti==null){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Ti=rv.API_URL_REGEX!=null?new RegExp(rv.API_URL_REGEX):t}catch{Ti=t}}return Ti},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(!Ke.API_URL)return null;try{const t=new URL(Ke.API_URL);return t.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":t.hostname==="api.mapbox.com"?"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",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",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},Mr={supported:!1,testSupport:function(t){!Ei&&vr&&(ai?ja(t):kr=t)}};let kr,vr,Ei=!1,ai=!1;function ja(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,vr),t.isContextLost())return;Mr.supported=!0}catch{}t.deleteTexture(e),Ei=!0}$.document&&(vr=$.document.createElement("img"),vr.onload=function(){kr&&ja(kr),kr=null,ai=!0},vr.onerror=function(){Ei=!0,kr=null},vr.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Pn="01";function li(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ga=es;function es(t,e,r,i){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(i-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=i}es.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(e===void 0&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,i=0;i<8;i++){var o=this.sampleCurveX(r)-t;if(Math.abs(o)<e)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=o/s}var n=0,a=1;for(r=t,i=0;i<20&&(o=this.sampleCurveX(r),!(Math.abs(o-t)<e));i++)t>o?n=r:a=r,r=.5*(a-n)+n;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var qa=li(Ga),Ps=Oi;function Oi(t,e){this.x=t,this.y=e}Oi.prototype={clone:function(){return new Oi(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-i*(this.y-e.y),this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Oi.convert=function(t){return t instanceof Oi?t:Array.isArray(t)?new Oi(t[0],t[1]):t};var N=li(Ps);function dt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!dt(t[r],e[r]))return!1;return!0}if(typeof t=="object"&&t!==null&&e!==null){if(typeof e!="object"||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(!dt(t[r],e[r]))return!1;return!0}return t===e}const lu=Math.PI/180,ts=180/Math.PI;function $e(t){return t*lu}function br(t){return t*ts}const cu=[[0,0],[1,0],[1,1],[0,1]];function Rs(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function uu(t){let e=1/0,r=1/0,i=-1/0,o=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),i=Math.max(i,s.x),o=Math.max(o,s.y);return{min:new N(e,r),max:new N(i,o)}}function rs(t,e,r=0,i=!0){const o=new N(r,r),s=t.sub(o),n=e.add(o),a=[s,new N(n.x,s.y),n,new N(s.x,n.y)];return i&&a.push(s.clone()),a}function is(t,e,r,i){const o=new qa(t,e,r,i);return function(s){return o.solve(s)}}const ci=is(.25,.1,.25,1);function Se(t,e,r){return Math.min(r,Math.max(e,t))}function Fi(t,e,r){return(r=Se((r-t)/(e-t),0,1))*r*(3-2*r)}function Ni(t,e,r){const i=r-e,o=((t-e)%i+i)%i+e;return o===e?r:o}function os(t,e,r){if(!t.length)return r(null,[]);let i=t.length;const o=new Array(t.length);let s=null;t.forEach((n,a)=>{e(n,(l,c)=>{l&&(s=l),o[a]=c,--i==0&&r(s,o)})})}function ss(t){const e=[];for(const r in t)e.push(t[r]);return e}function Te(t,...e){for(const r of e)for(const i in r)t[i]=r[i];return t}function jr(t,e){const r={};for(let i=0;i<e.length;i++){const o=e[i];o in t&&(r[o]=t[o])}return r}let hu=1;function Ls(){return hu++}function Za(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function $a(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ha(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 pr(t,e){t.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function Bs(t,e){return t.indexOf(e,t.length-e.length)!==-1}function Os(t,e,r){const i={};for(const o in t)i[o]=e.call(r||this,t[o],o,t);return i}function le(t,e,r){const i={};for(const o in t)e.call(r||this,t[o],o,t)&&(i[o]=t[o]);return i}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t?Os(t,z):t}const P={};function F(t){P[t]||(typeof console<"u"&&console.warn(t),P[t]=!0)}function te(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function ie(t){let e=0;for(let r,i,o=0,s=t.length,n=s-1;o<s;n=o++)r=t[o],i=t[n],e+=(i.x-r.x)*(r.y+i.y);return e}function ve([t,e,r]){const i=$e(e+90),o=$e(r);return{x:t*Math.cos(i)*Math.sin(o),y:t*Math.sin(i)*Math.sin(o),z:t*Math.cos(o),azimuthal:e,polar:r}}function Ce(t,e,r){const i=Math.sqrt(t*t+e*e+r*r),o=i>0?Math.acos(r/i)*ts:0;let s=t!==0||e!==0?Math.atan2(-e,-t)*ts+90:0;return s<0&&(s+=360),[i,s,o]}function oe(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function ze(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,i,o,s)=>{const n=o||s;return e[i]=!n||n.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}let Ge=null;function Ve(){return!!$.document.fullscreenElement||!!$.document.webkitFullscreenElement}function kt(t){try{const e=$[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function $t(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function wr(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3]}function Ht(t,e){return[Math.pow(t[0],2.2)*e,Math.pow(t[1],2.2)*e,Math.pow(t[2],2.2)*e]}function er(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]}const Lt="mapbox-tiles";let Ir=500,Rr=50,Lr,Mi;function Fs(){try{return $.caches}catch{}}function Gr(){Fs()&&!Lr&&(Lr=$.caches.open(Lt))}function ro(t){const e=t.indexOf("?");if(e<0)return t;const r=function(o){const s=o.indexOf("?");return s>0?o.slice(s+1).split("&"):[]}(t),i=r.filter(o=>{const s=o.split("=");return s[0]==="language"||s[0]==="worldview"});return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let To=1/0;function Ns(t){To++,To>Rr&&(t.getActor().send("enforceCacheSizeLimit",Ir),To=0)}const J={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};typeof Object.freeze=="function"&&Object.freeze(J);class Q extends Error{constructor(e,r,i){r===401&&Wt(i)&&(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=r,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ne=oe()?()=>self.worker&&self.worker.referrer:()=>($.location.protocol==="blob:"?$.parent:$).location.href,ce=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(ne())&&!/^\w+:/.test(r))){if($.fetch&&$.Request&&$.AbortController&&$.Request.prototype.hasOwnProperty("signal"))return function(i,o){const s=new $.AbortController,n=new $.Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:ne(),referrerPolicy:i.referrerPolicy,signal:s.signal});let a=!1,l=!1;const c=(u=n.url).indexOf("sku=")>0&&Wt(u);var u;i.type==="json"&&n.headers.set("Accept","application/json");const h=(p,f,m)=>{if(l)return;if(p&&p.message!=="SecurityError"&&F(p.toString()),f&&m)return d(f);const _=Date.now();$.fetch(n).then(g=>{if(g.ok){const y=c?g.clone():null;return d(g,y,_)}return o(new Q(g.statusText,g.status,i.url))}).catch(g=>{g.name!=="AbortError"&&o(new Error(`${g.message} ${i.url}`))})},d=(p,f,m)=>{(i.type==="arrayBuffer"?p.arrayBuffer():i.type==="json"?p.json():p.text()).then(_=>{l||(f&&m&&function(g,y,v){if(Gr(),!Lr)return;const b={status:y.status,statusText:y.statusText,headers:new $.Headers};y.headers.forEach((T,E)=>b.headers.set(E,T));const x=ze(y.headers.get("Cache-Control")||"");if(x["no-store"])return;x["max-age"]&&b.headers.set("Expires",new Date(v+1e3*x["max-age"]).toUTCString());const w=b.headers.get("Expires");w&&(new Date(w).getTime()-v<42e4||function(T,E){if(Mi===void 0)try{new Response(new ReadableStream),Mi=!0}catch{Mi=!1}Mi?E(T.body):T.blob().then(E)}(y,T=>{const E=new $.Response(T,b);Gr(),Lr&&Lr.then(M=>M.put(ro(g.url),E)).catch(M=>F(M.message))}))}(n,f,m),a=!0,o(null,_,p.headers.get("Cache-Control"),p.headers.get("Expires")))}).catch(_=>{l||o(new Error(_.message))})};return c?function(p,f){if(Gr(),!Lr)return f(null);const m=ro(p.url);Lr.then(_=>{_.match(m).then(g=>{const y=function(v){if(!v)return!1;const b=new Date(v.headers.get("Expires")||0),x=ze(v.headers.get("Cache-Control")||"");return b>Date.now()&&!x["no-cache"]}(g);_.delete(m),y&&_.put(m,g.clone()),f(null,g,y)}).catch(f)}).catch(f)}(n,h):h(null,null),{cancel:()=>{l=!0,a||s.abort()}}}(t,e);if(oe()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(i,o){const s=new $.XMLHttpRequest;s.open(i.method||"GET",i.url,!0),i.type==="arrayBuffer"&&(s.responseType="arraybuffer");for(const n in i.headers)s.setRequestHeader(n,i.headers[n]);return i.type==="json"&&(s.responseType="text",s.setRequestHeader("Accept","application/json")),s.withCredentials=i.credentials==="include",s.onerror=()=>{o(new Error(s.statusText))},s.onload=()=>{if((s.status>=200&&s.status<300||s.status===0)&&s.response!==null){let n=s.response;if(i.type==="json")try{n=JSON.parse(s.response)}catch(a){return o(a)}o(null,n,s.getResponseHeader("Cache-Control"),s.getResponseHeader("Expires"))}else o(new Q(s.statusText,s.status,i.url))},s.send(i.body),{cancel:()=>s.abort()}}(t,e)},ue=function(t,e){return ce(Te(t,{type:"json"}),e)},fe=function(t,e){return ce(Te(t,{type:"arrayBuffer"}),e)};function _e(t){const e=$.document.createElement("a");return e.href=t,e.protocol===$.document.location.protocol&&e.host===$.document.location.host}const he="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Me,me;Me=[],me=0;const Ye=function(t,e){if(Mr.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),me>=Ke.MAX_PARALLEL_IMAGE_REQUESTS){const s={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return Me.push(s),s}me++;let r=!1;const i=()=>{if(!r)for(r=!0,me--;Me.length&&me<Ke.MAX_PARALLEL_IMAGE_REQUESTS;){const s=Me.shift(),{requestParameters:n,callback:a,cancelled:l}=s;l||(s.cancel=Ye(n,a).cancel)}},o=fe(t,(s,n,a,l)=>{i(),s?e(s):n&&($.createImageBitmap?function(c,u){const h=new $.Blob([new Uint8Array(c)],{type:"image/png"});$.createImageBitmap(h).then(d=>{u(null,d)}).catch(d=>{u(new Error(`Could not load image because of ${d.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(n,(c,u)=>e(c,u,a,l)):function(c,u){const h=new $.Image,d=$.URL;h.onload=()=>{u(null,h),d.revokeObjectURL(h.src),h.onload=null,$.requestAnimationFrame(()=>{h.src=he})},h.onerror=()=>u(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 p=new $.Blob([new Uint8Array(c)],{type:"image/png"});h.src=c.byteLength?d.createObjectURL(p):he}(n,(c,u)=>e(c,u,a,l)))});return{cancel:()=>{o.cancel(),i()}}},At="NO_ACCESS_TOKEN";class Pe{constructor(e,r,i){this._transformRequestFn=e,this._customAccessToken=r,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let r="";for(let i=0;i<10;i++)r+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Pn,r].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,r){return this._transformRequestFn&&this._transformRequestFn(e,r)||{url:e}}normalizeStyleURL(e,r){if(!wt(e))return e;const i=fr(e);return i.params.push(`sdk=js-${Vr}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeGlyphsURL(e,r){if(!wt(e))return e;const i=fr(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeModelURL(e,r){if(!wt(e))return e;const i=fr(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeSourceURL(e,r,i,o){if(!wt(e))return e;const s=fr(e);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),i&&s.params.push(`language=${i}`),o&&s.params.push(`worldview=${o}`),this._makeAPIURL(s,this._customAccessToken||r)}normalizeSpriteURL(e,r,i,o){const s=fr(e);return wt(e)?(s.path=`/styles/v1${s.path}/sprite${r}${i}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${i}`,Br(s))}normalizeTileURL(e,r,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!wt(e))return e;const o=fr(e);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||i&&o.authority!=="raster"&&i===512?"@2x":""}${Mr.supported?".webp":"$1"}`),o.authority==="raster"?o.path=`/${Ke.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${Ke.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(n){for(const a of n){const l=a.match(/^access_token=(.*)$/);if(l)return l[1]}return null}(o.params)||Ke.ACCESS_TOKEN;return Ke.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(e,r){const i=fr(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let o="mapbox://";i.path.match(/^\/raster\/v1\//)?o+=`raster/${i.path.replace(`/${Ke.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${i.path.replace(`/${Ke.TILE_URL_VERSION}/`,"")}`;let s=i.params;return r&&(s=s.filter(n=>!n.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(e,r){const i=!!r&&wt(r),o=[];for(const s of e.tiles||[])Wt(s)?o.push(this.canonicalizeTileURL(s,i)):o.push(s);return o}_makeAPIURL(e,r){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",o=fr(Ke.API_URL);if(e.protocol=o.protocol,e.authority=o.authority,e.protocol==="http"){const s=e.params.indexOf("secure");s>=0&&e.params.splice(s,1)}if(o.path!=="/"&&(e.path=`${o.path}${e.path}`),!Ke.REQUIRE_ACCESS_TOKEN)return Br(e);if(r=r||Ke.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if(r[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(s=>s.indexOf("access_token")===-1),e.params.push(`access_token=${r||""}`),Br(e)}}function wt(t){return t.indexOf("mapbox:")===0}function Wt(t){return Ke.API_URL_REGEX.test(t)}function tr(t){return Ke.API_CDN_URL_REGEX.test(t)}function lr(t){return Ke.API_STYLE_REGEX.test(t)&&!Cr(t)}function Cr(t){return Ke.API_SPRITE_REGEX.test(t)}const ui=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function fr(t){const e=t.match(ui);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 Br(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const zr="mapbox.eventData";function Us(t){if(!t)return null;const e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent($.atob(e[1]).split("").map(r=>"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Eo{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const r=Us(Ke.ACCESS_TOKEN);let i="";return i=r&&r.u?$.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(o,s)=>String.fromCharCode(+("0x"+s)))):Ke.ACCESS_TOKEN||"",e?`${zr}.${e}:${i}`:`${zr}:${i}`}fetchEventData(){const e=kt("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const o=$.localStorage.getItem(r);o&&(this.eventData=JSON.parse(o));const s=$.localStorage.getItem(i);s&&(this.anonId=s)}catch{F("Unable to read from LocalStorage")}}saveEventData(){const e=kt("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{$.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&$.localStorage.setItem(r,JSON.stringify(this.eventData))}catch{F("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,r,i,o){if(!Ke.EVENTS_URL)return;const s=fr(Ke.EVENTS_URL);s.params.push(`access_token=${o||Ke.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(e).toISOString()},a=r?Te(n,r):n,l={url:Br(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(c,u){return ce(Te(c,{method:"POST"}),u)}(l,c=>{this.pendingRequest=null,i(c),this.saveEventData(),this.processRequests(o)})}queueRequest(e,r){this.queue.push(e),this.processRequests(r)}}const Vs=new class extends Eo{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){Ke.EVENTS_URL&&Ke.ACCESS_TOKEN&&Array.isArray(t)&&t.some(r=>wt(r)||Wt(r))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=Us(Ke.ACCESS_TOKEN),r=e?e.u:Ke.ACCESS_TOKEN;let i=r!==this.eventData.tokenU;Ha(this.anonId)||(this.anonId=Za(),i=!0);const o=this.queue.shift();if(this.eventData.lastSuccess){const s=new Date(this.eventData.lastSuccess),n=new Date(o),a=(o-this.eventData.lastSuccess)/864e5;i=i||a>=1||a<-1||s.getDate()!==n.getDate()}else i=!0;i?this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Vr,skuId:Pn,"enabled.telemetry":!1,userId:this.anonId},s=>{s||(this.eventData.lastSuccess=o,this.eventData.tokenU=r)},t):this.processRequests()}},du=Vs.postTurnstileEvent.bind(Vs),Qp=new class extends Eo{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,r,i){this.skuToken=e,this.errorCb=i,Ke.EVENTS_URL&&(r||Ke.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(At)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Ha(this.anonId)||(this.anonId=Za()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Vr,skuId:Pn,skuToken:this.skuToken,userId:this.anonId},i=>{i?this.errorCb(i):e&&(this.success[e]=!0)},t))}},sv=Qp.postMapLoadEvent.bind(Qp),ef=new class extends Eo{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){Ke.EVENTS_URL&&(t||Ke.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:r}=this.queue.shift(),i=function(o){const s=$.performance.getEntriesByType("resource"),n=$.performance.getEntriesByType("mark"),a=function(d){const p={};if(d){for(const f in d)if(f!=="other")for(const m of d[f]){const _=`${f}ResolveRangeMin`,g=`${f}ResolveRangeMax`,y=`${f}RequestCount`,v=`${f}RequestCachedCount`;p[_]=Math.min(p[_]||1/0,m.startTime),p[g]=Math.max(p[g]||-1/0,m.responseEnd);const b=x=>{p[x]===void 0&&(p[x]=0),++p[x]};m.transferSize!==void 0&&m.transferSize===0&&b(v),b(y)}}return p}(function(d,p){const f={};if(d)for(const m of d){const _=p(m);f[_]===void 0&&(f[_]=[]),f[_].push(m)}return f}(s,lv)),l=$.devicePixelRatio,c=$.navigator.connection||$.navigator.mozConnection||$.navigator.webkitConnection,u={counters:[],metadata:[],attributes:[]},h=(d,p,f)=>{f!=null&&d.push({name:p,value:f.toString()})};for(const d in a)h(u.counters,d,a[d]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(h(u.counters,"interactionRangeMin",o.interactionRange[0]),h(u.counters,"interactionRangeMax",o.interactionRange[1])),n)for(const d of Object.keys(Xa)){const p=Xa[d],f=n.find(m=>m.name===p);f&&h(u.counters,p,f.startTime)}return h(u.counters,"visibilityHidden",o.visibilityHidden),h(u.attributes,"style",function(d){if(d)for(const p of d){const f=p.name.split("?")[0];if(lr(f)){const m=f.split("/").slice(-2);if(m.length===2)return`mapbox://styles/${m[0]}/${m[1]}`}}}(s)),h(u.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),h(u.attributes,"fogEnabled",o.fogEnabled?"true":"false"),h(u.attributes,"projection",o.projection),h(u.attributes,"zoom",o.zoom),h(u.metadata,"devicePixelRatio",l),h(u.metadata,"connectionEffectiveType",c?c.effectiveType:void 0),h(u.metadata,"navigatorUserAgent",$.navigator.userAgent),h(u.metadata,"screenWidth",$.screen.width),h(u.metadata,"screenHeight",$.screen.height),h(u.metadata,"windowWidth",$.innerWidth),h(u.metadata,"windowHeight",$.innerHeight),h(u.metadata,"mapWidth",o.width/l),h(u.metadata,"mapHeight",o.height/l),h(u.metadata,"webglRenderer",o.renderer),h(u.metadata,"webglVendor",o.vendor),h(u.metadata,"sdkVersion",Vr),h(u.metadata,"sdkIdentifier","mapbox-gl-js"),u}(r);for(const o of i.metadata);for(const o of i.counters);for(const o of i.attributes);this.postEvent(e,i,()=>{},t)}},nv=ef.postPerformanceEvent.bind(ef),tf=new class extends Eo{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,r,i){if(!Ke.API_URL||!Ke.SESSION_PATH)return;const o=fr(Ke.API_URL+Ke.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${i||Ke.ACCESS_TOKEN||""}`);const s={url:Br(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(n,a){return ce(Te(n,{method:"GET"}),a)}(s,n=>{this.pendingRequest=null,r(n),this.saveEventData(),this.processRequests(i)})}getSessionAPI(t,e,r,i){this.skuToken=e,this.errorCb=i,Ke.SESSION_PATH&&Ke.API_URL&&(r||Ke.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(At)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,i=>{i?this.errorCb(i):e&&(this.success[e]=!0)},t)}},av=tf.getSessionAPI.bind(tf),Wa=new Set;function rf(t,e){e?Wa.add(t):Wa.delete(t)}const Xa={create:"create",load:"load",fullLoad:"fullLoad"},of={mark(t){$.performance.mark(t)},measure(t,e,r){$.performance.measure(t,e,r)}};function lv(t){const e=t.name.split("?")[0];return tr(e)&&e.includes("mapbox-gl.js")?"javascript":tr(e)&&e.includes("mapbox-gl.css")?"css":function(r){return Ke.API_FONTS_REGEX.test(r)}(e)?"fontRange":Cr(e)?"sprite":lr(e)?"style":function(r){return Ke.API_TILEJSON_REGEX.test(r)}(e)?"tilejson":"other"}const cv=$.performance;function sf(t){const e=t?t.url.toString():void 0;return cv.getEntriesByName(e)}var nf=pu;function pu(t){return!function(e){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var i,o,s=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(s);try{o=new Worker(n),i=!0}catch{i=!1}return o&&o.terminate(),URL.revokeObjectURL(n),i}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var i=document.createElement("canvas");i.width=i.height=1;var o=i.getContext("2d");if(!o)return!1;var s=o.getImageData(0,0,1,1);return s&&s.width===i.width}()?(fu[r=e&&e.failIfMajorPerformanceCaveat]===void 0&&(fu[r]=function(i){var o,s=function(n){var a=document.createElement("canvas"),l=Object.create(pu.webGLContextAttributes);return l.failIfMajorPerformanceCaveat=n,a.getContext("webgl",l)||a.getContext("experimental-webgl",l)}(i);if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch{return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),s.getShaderParameter(o,s.COMPILE_STATUS)===!0)}(r)),fu[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var r}(t)}var fu={};let mu,Ya,_u,Ja,ns;function af(){return mu==null&&(mu=$.OffscreenCanvas&&new $.OffscreenCanvas(1,1).getContext("2d")&&typeof $.createImageBitmap=="function"),mu}pu.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const je={now:()=>Ja!==void 0?Ja:$.performance.now(),setNow(t){Ja=t},restoreNow(){Ja=void 0},frame(t){const e=$.requestAnimationFrame(t);return{cancel:()=>$.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:i}=t;ns||(ns=$.document.createElement("canvas"));const o=ns.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>ns.width||i>ns.height)&&(ns.width=r,ns.height=i),o.clearRect(-e,-e,r+2*e,i+2*e),o.drawImage(t,0,0,r,i),o.getImageData(-e,-e,r+2*e,i+2*e)},resolveURL:t=>(Ya||(Ya=$.document.createElement("a")),Ya.href=t,Ya.href),get devicePixelRatio(){return $.devicePixelRatio},get prefersReducedMotion(){return!!$.matchMedia&&(_u==null&&(_u=$.matchMedia("(prefers-reduced-motion: reduce)")),_u.matches)},hasCanvasFingerprintNoise(){if(!af())return!1;const t=new $.OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let o=0;o<t.width;++o)e.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,e.fillRect(o,0,1,1);const i=e.getImageData(0,0,t.width,t.height);r=0;for(let o=0;o<i.data.length;++o)if(o%4!=3&&r++!==i.data[o])return!0;return!1}};function Dt(t,e,r){const i=$.document.createElement(t);return e!==void 0&&(i.className=e),r&&r.appendChild(i),i}function io(t,e,r){const i=$.document.createElementNS("http://www.w3.org/2000/svg",t);for(const o of Object.keys(e))i.setAttributeNS(null,o,e[o]);return r&&r.appendChild(i),i}const as=$.document&&$.document.documentElement.style,Rn=as&&as.userSelect!==void 0?"userSelect":"WebkitUserSelect";let lf;function cf(){as&&Rn&&(lf=as[Rn],as[Rn]="none")}function uf(){as&&Rn&&(as[Rn]=lf)}function gu(t){t.preventDefault(),t.stopPropagation(),$.removeEventListener("click",gu,!0)}function yu(){$.addEventListener("click",gu,!0),$.setTimeout(()=>{$.removeEventListener("click",gu,!0)},0)}function Ln(t,e){const r=t.getBoundingClientRect();return df(t,r,e)}function Ka(t,e){const r=t.getBoundingClientRect(),i=[];for(let o=0;o<e.length;o++)i.push(df(t,r,e[o]));return i}function hf(t){return $.InstallTrigger!==void 0&&t.button===2&&t.ctrlKey&&$.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function df(t,e,r){const i=t.offsetWidth===e.width?1:t.offsetWidth/e.width;return new N((r.clientX-e.left)*i,(r.clientY-e.top)*i)}function pf(t,e,r){r[t]&&r[t].indexOf(e)!==-1||(r[t]=r[t]||[],r[t].push(e))}function xu(t,e,r){if(r&&r[t]){const i=r[t].indexOf(e);i!==-1&&r[t].splice(i,1)}}class ae{constructor(e,r={}){Te(this,r),this.type=e}}class Ue extends ae{constructor(e,r={}){super("error",Te({error:e},r))}}class or{on(e,r){return this._listeners=this._listeners||{},pf(e,r,this._listeners),this}off(e,r){return xu(e,r,this._listeners),xu(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},pf(e,r,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,r){typeof e=="string"&&(e=new ae(e,r||{}));const i=e.type;if(this.listens(i)){e.target=this;const o=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const a of o)a.call(this,e);const s=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const a of s)xu(i,a,this._oneTimeListeners),a.call(this,e);const n=this._eventedParent;n&&(Te(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Ue&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var j=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":"*"},"*":{"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":{},"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_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_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,"minimum":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","default":[0,1],"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_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"}}}');class be{constructor(e,r,i,o){this.message=(e?`${e}: `:"")+i,o&&(this.identifier=o),r!=null&&r.__line__&&(this.line=r.__line__)}}class ls extends be{}function oo(t,...e){for(const r of e)for(const i in r)t[i]=r[i];return t}function cr(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function so(t){if(Array.isArray(t))return t.map(so);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=so(t[r]);return e}return cr(t)}class uv extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}var Ui=uv;class vu{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[i,o]of r)this.bindings[i]=o}concat(e){return new vu(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 hv=vu;const js={kind:"null"},ye={kind:"number"},ft={kind:"string"},yt={kind:"boolean"},hi={kind:"color"},Gs={kind:"object"},_t={kind:"value"},Qa={kind:"collator"},Bn={kind:"formatted"},On={kind:"resolvedImage"};function qr(t,e){return{kind:"array",itemType:t,N:e}}function sr(t){if(t.kind==="array"){const e=sr(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}const dv=[js,ye,ft,yt,hi,Bn,Gs,qr(_t),On];function Fn(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Fn(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(const r of dv)if(!Fn(r,e))return null}}return`Expected ${sr(t)} but found ${sr(e)} instead.`}function bu(t,e){return e.some(r=>r.kind===t.kind)}function Nn(t,e){return e.some(r=>r==="null"?t===null:r==="array"?Array.isArray(t):r==="object"?t&&!Array.isArray(t)&&typeof t=="object":r===typeof t)}var wu,ff={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 el(t){return(t=Math.round(t))<0?0:t>255?255:t}function Tu(t){return el(t[t.length-1]==="%"?parseFloat(t)/100*255:parseInt(t))}function tl(t){return(e=t[t.length-1]==="%"?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Eu(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{wu={}.parseCSSColor=function(t){var e,r=t.replace(/ /g,"").toLowerCase();if(r in ff)return ff[r].slice();if(r[0]==="#")return r.length===4?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:r.length===7&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var i=r.indexOf("("),o=r.indexOf(")");if(i!==-1&&o+1===r.length){var s=r.substr(0,i),n=r.substr(i+1,o-(i+1)).split(","),a=1;switch(s){case"rgba":if(n.length!==4)return null;a=tl(n.pop());case"rgb":return n.length!==3?null:[Tu(n[0]),Tu(n[1]),Tu(n[2]),a];case"hsla":if(n.length!==4)return null;a=tl(n.pop());case"hsl":if(n.length!==3)return null;var l=(parseFloat(n[0])%360+360)%360/360,c=tl(n[1]),u=tl(n[2]),h=u<=.5?u*(c+1):u+c-u*c,d=2*u-h;return[el(255*Eu(d,h,l+1/3)),el(255*Eu(d,h,l)),el(255*Eu(d,h,l-1/3)),a];default:return null}}return null}}catch{}class Zr{constructor(e,r,i,o=1){this.r=e,this.g=r,this.b=i,this.a=o}static parse(e){if(!e)return;if(e instanceof Zr)return e;if(typeof e!="string")return;const r=wu(e);return r?new Zr(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[e,r,i,o]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(i)},${o})`}toArray(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[255*e/o,255*r/o,255*i/o,o]}toArray01(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[e/o,r/o,i/o,o]}toArray01Scaled(e){const{r,g:i,b:o,a:s}=this;return s===0?[0,0,0]:[r/s*e,i/s*e,o/s*e]}toArray01PremultipliedAlpha(){const{r:e,g:r,b:i,a:o}=this;return[e,r,i,o]}toArray01Linear(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[Math.pow(e/o,2.2),Math.pow(r/o,2.2),Math.pow(i/o,2.2),o]}}Zr.black=new Zr(0,0,0,1),Zr.white=new Zr(1,1,1,1),Zr.transparent=new Zr(0,0,0,0),Zr.red=new Zr(1,0,0,1),Zr.blue=new Zr(0,0,1,1);var Qe=Zr;class Mu{constructor(e,r,i){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Su{constructor(e,r,i,o,s){this.text=e.normalize?e.normalize():e,this.image=r,this.scale=i,this.fontStack=o,this.textColor=s}}class $r{constructor(e){this.sections=e}static fromString(e){return new $r([new Su(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.namePrimary.length!==0)}static factory(e){return e instanceof $r?e:$r.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const r of this.sections){if(r.image){e.push(["image",r.image.namePrimary]);continue}e.push(r.text);const i={};r.fontStack&&(i["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(i["font-scale"]=r.scale),r.textColor&&(i["text-color"]=["rgba"].concat(r.textColor.toArray())),e.push(i)}return e}}class di{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,r){return e?new di({namePrimary:e,nameSecondary:r,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mf(t,e,r,i){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?i===void 0||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[t,e,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[t,e,r,i]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function qs(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof Qe||t instanceof Mu||t instanceof $r||t instanceof di)return!0;if(Array.isArray(t)){for(const e of t)if(!qs(e))return!1;return!0}if(typeof t=="object"){for(const e in t)if(!qs(t[e]))return!1;return!0}return!1}function mr(t){if(t===null)return js;if(typeof t=="string")return ft;if(typeof t=="boolean")return yt;if(typeof t=="number")return ye;if(t instanceof Qe)return hi;if(t instanceof Mu)return Qa;if(t instanceof $r)return Bn;if(t instanceof di)return On;if(Array.isArray(t)){const e=t.length;let r;for(const i of t){const o=mr(i);if(r){if(r===o)continue;r=_t;break}r=o}return qr(r||_t,e)}return Gs}function Un(t){const e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof Qe||t instanceof $r||t instanceof di?t.toString():JSON.stringify(t)}class Au{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!qs(e[1]))return r.error("invalid value");const i=e[1];let o=mr(i);const s=r.expectedType;return o.kind!=="array"||o.N!==0||!s||s.kind!=="array"||typeof s.N=="number"&&s.N!==0||(o=s),new Au(o,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Qe?["rgba"].concat(this.value.toArray()):this.value instanceof $r?this.value.serialize():this.value}}var Vn=Au,Tr=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Iu={string:ft,number:ye,boolean:yt,object:Gs};class Cu{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i,o=1;const s=e[0];if(s==="array"){let a,l;if(e.length>2){const c=e[1];if(typeof c!="string"||!(c in Iu)||c==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);a=Iu[c],o++}else a=_t;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=e[2],o++}i=qr(a,l)}else i=Iu[s];const n=[];for(;o<e.length;o++){const a=r.parse(e[o],o,_t);if(!a)return null;n.push(a)}return new Cu(i,n)}evaluate(e){for(let r=0;r<this.args.length;r++){const i=this.args[r].evaluate(e);if(!Fn(this.type,mr(i)))return i;if(r===this.args.length-1)throw new Tr(`Expected value to be of type ${sr(this.type)}, but found ${sr(mr(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,r=[e.kind];if(e.kind==="array"){const i=e.itemType;if(i.kind==="string"||i.kind==="number"||i.kind==="boolean"){r.push(i.kind);const o=e.N;(typeof o=="number"||this.args.length>1)&&r.push(o)}}return r.concat(this.args.map(i=>i.serialize()))}}var no=Cu;class jn{constructor(e){this.type=Bn,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&typeof i=="object")return r.error("First argument must be an image or text section.");const o=[];let s=!1;for(let n=1;n<=e.length-1;++n){const a=e[n];if(s&&typeof a=="object"&&!Array.isArray(a)){s=!1;let l=null;if(a["font-scale"]&&(l=r.parse(a["font-scale"],1,ye),!l))return null;let c=null;if(a["text-font"]&&(c=r.parse(a["text-font"],1,qr(ft)),!c))return null;let u=null;if(a["text-color"]&&(u=r.parse(a["text-color"],1,hi),!u))return null;const h=o[o.length-1];h.scale=l,h.font=c,h.textColor=u}else{const l=r.parse(e[n],1,_t);if(!l)return null;const c=l.type.kind;if(c!=="string"&&c!=="value"&&c!=="null"&&c!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,o.push({content:l,scale:null,font:null,textColor:null})}}return new jn(o)}evaluate(e){return new $r(this.sections.map(r=>{const i=r.content.evaluate(e);return mr(i)===On?new Su("",i,null,null,null):new Su(Un(i),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const r of this.sections){e.push(r.content.serialize());const i={};r.scale&&(i["font-scale"]=r.scale.serialize()),r.font&&(i["text-font"]=r.font.serialize()),r.textColor&&(i["text-color"]=r.textColor.serialize()),e.push(i)}return e}}class Gn{constructor(e,r){this.type=On,this.inputPrimary=e,this.inputSecondary=r}static parse(e,r){if(e.length<2)return r.error("Expected two or more arguments.");const i=r.parse(e[1],1,ft);if(!i)return r.error("No image name provided.");if(e.length===2)return new Gn(i);const o=r.parse(e[2],1,ft);return o?new Gn(i,o):r.error("Secondary image variant is not a string.")}evaluate(e){const r=di.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(r.namePrimary)>-1,r.nameSecondary&&r.available&&e.availableImages&&(r.available=e.availableImages.indexOf(r.nameSecondary)>-1)),r}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 Tt(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}const pv={"to-boolean":yt,"to-color":hi,"to-number":ye,"to-string":ft};class zu{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const i=e[0],o=[];let s=js;if(i==="to-array"){if(!Array.isArray(e[1]))return null;const n=e[1].length;if(r.expectedType){if(r.expectedType.kind!=="array")return r.error(`Expected ${r.expectedType.kind} but found array.`);s=qr(r.expectedType.itemType,n)}else{if(!(n>0&&qs(e[1][0])))return null;s=qr(mr(e[1][0]),n)}for(let a=0;a<n;a++){const l=e[1][a];let c;if(Tt(l)==="array")c=r.parse(l,void 0,s.itemType);else{const u=Tt(l);if(u!==s.itemType.kind)return r.error(`Expected ${s.itemType.kind} but found ${u}.`);c=r.registry.literal.parse(["literal",l===void 0?null:l],r)}if(!c)return null;o.push(c)}}else{if((i==="to-boolean"||i==="to-string")&&e.length!==2)return r.error("Expected one argument.");s=pv[i];for(let n=1;n<e.length;n++){const a=r.parse(e[n],n,_t);if(!a)return null;o.push(a)}}return new zu(s,o)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let r,i;for(const o of this.args){if(r=o.evaluate(e),i=null,r instanceof Qe)return r;if(typeof r=="string"){const s=e.parseColor(r);if(s)return s}else if(Array.isArray(r)&&(i=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:mf(r[0],r[1],r[2],r[3]),!i))return new Qe(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Tr(i||`Could not parse color from value '${typeof r=="string"?r:String(JSON.stringify(r))}'`)}if(this.type.kind==="number"){let r=null;for(const i of this.args){if(r=i.evaluate(e),r===null)return 0;const o=Number(r);if(!isNaN(o))return o}throw new Tr(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?$r.fromString(Un(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?di.fromString(Un(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(r=>r.evaluate(e)):Un(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new jn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Gn(this.args[0]).serialize();const e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(r=>{e.push(r.serialize())}),e}}var cs=zu;const fv=["Unknown","Point","LineString","Polygon"];var _f=class{constructor(t){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.options=t}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?fv[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:r,y:i}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(i*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Qe.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}};class us{constructor(e,r,i,o,s){this.name=e,this.type=r,this._evaluate=i,this.args=o,this._overloadIndex=s}evaluate(e){if(!this._evaluate){const r=us.definitions[this.name];this._evaluate=Array.isArray(r)?r[2]:r.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,r){const i=e[0],o=us.definitions[i];if(!o)return r.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(o)?o[0]:o.type,n=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,a=[];let l=null,c=-1;for(const[u,h]of n){if(Array.isArray(u)&&u.length!==e.length-1)continue;a.push(u),c++,l=new Pf(r.registry,r.path,null,r.scope,void 0,r.options);const d=[];let p=!1;for(let f=1;f<e.length;f++){const m=e[f],_=Array.isArray(u)?u[f-1]:u.type,g=l.parse(m,1+d.length,_);if(!g){p=!0;break}d.push(g)}if(!p)if(Array.isArray(u)&&u.length!==d.length)l.error(`Expected ${u.length} arguments, but found ${d.length} instead.`);else{for(let f=0;f<d.length;f++){const m=Array.isArray(u)?u[f]:u.type,_=d[f];l.concat(f+1).checkSubtype(m,_.type)}if(l.errors.length===0)return new us(i,s,h,d,c)}}if(a.length===1)r.errors.push(...l.errors);else{const u=(a.length?a:n.map(([d])=>d)).map(mv).join(" | "),h=[];for(let d=1;d<e.length;d++){const p=r.parse(e[d],1+h.length);if(!p)return null;h.push(sr(p.type))}r.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(e,r){us.definitions=r;for(const i in r)e[i]=us}}function mv(t){return Array.isArray(t)?`(${t.map(sr).join(", ")})`:`(${sr(t.type)}...)`}var Vi=us;class rl{constructor(e,r,i){this.type=Qa,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const i=e[1];if(typeof i!="object"||Array.isArray(i))return r.error("Collator options argument must be an object.");const o=r.parse(i["case-sensitive"]!==void 0&&i["case-sensitive"],1,yt);if(!o)return null;const s=r.parse(i["diacritic-sensitive"]!==void 0&&i["diacritic-sensitive"],1,yt);if(!s)return null;let n=null;return i.locale&&(n=r.parse(i.locale,1,ft),!n)?null:new rl(o,s,n)}evaluate(e){return new Mu(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 gf={exports:{}};gf.exports=function(){function t(i,o,s,n,a){for(;n>s;){if(n-s>600){var l=n-s+1,c=o-s+1,u=Math.log(l),h=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1);t(i,o,Math.max(s,Math.floor(o-c*h/l+d)),Math.min(n,Math.floor(o+(l-c)*h/l+d)),a)}var p=i[o],f=s,m=n;for(e(i,s,o),a(i[n],p)>0&&e(i,s,n);f<m;){for(e(i,f,m),f++,m--;a(i[f],p)<0;)f++;for(;a(i[m],p)>0;)m--}a(i[s],p)===0?e(i,s,m):e(i,++m,n),m<=o&&(s=m+1),o<=m&&(n=m-1)}}function e(i,o,s){var n=i[o];i[o]=i[s],i[s]=n}function r(i,o){return i<o?-1:i>o?1:0}return function(i,o,s,n,a){t(i,o,s||0,n||i.length-1,a||r)}}();var _v=li(gf.exports);function gv(t){let e=0;for(let r,i,o=0,s=t.length,n=s-1;o<s;n=o++)r=t[o],i=t[n],e+=(i.x-r.x)*(r.y+i.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 Zn(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function yv(t,e,r){const i=t[0]-e[0],o=t[1]-e[1],s=t[0]-r[0],n=t[1]-r[1];return i*n-s*o==0&&i*s<=0&&o*n<=0}function Zs(t,e,r=!1){let i=!1;for(let a=0,l=e.length;a<l;a++){const c=e[a];for(let u=0,h=c.length,d=h-1;u<h;d=u++){const p=c[d],f=c[u];if(yv(t,p,f))return r;(s=p)[1]>(o=t)[1]!=(n=f)[1]>o[1]&&o[0]<(n[0]-s[0])*(o[1]-s[1])/(n[1]-s[1])+s[0]&&(i=!i)}}var o,s,n;return i}function yf(t,e,r,i){const o=i[0]-r[0],s=i[1]-r[1],n=(t[0]-r[0])*s-o*(t[1]-r[1]),a=(e[0]-r[0])*s-o*(e[1]-r[1]);return n>0&&a<0||n<0&&a>0}function il(t,e,r,i){return(o=[i[0]-r[0],i[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-o[1]*s[0]!=0&&!(!yf(t,e,r,i)||!yf(r,i,t,e));var o,s}const Mo=8192;function xv(t,e){const r=(180+t[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(r*o*Mo),Math.round(i*o*Mo)]}function vv(t,e){for(let r=0;r<e.length;r++)if(Zs(t,e[r]))return!0;return!1}function bv(t,e,r){for(const i of r)for(let o=0,s=i.length,n=s-1;o<s;n=o++)if(il(t,e,i[n],i[o]))return!0;return!1}function xf(t,e){for(let r=0;r<t.length;++r)if(!Zs(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(bv(t[r],t[r+1],e))return!1;return!0}function wv(t,e){for(let r=0;r<e.length;r++)if(xf(t,e[r]))return!0;return!1}function Du(t,e,r){const i=[];for(let o=0;o<t.length;o++){const s=[];for(let n=0;n<t[o].length;n++){const a=xv(t[o][n],r);qn(e,a),s.push(a)}i.push(s)}return i}function vf(t,e,r){const i=[];for(let o=0;o<t.length;o++){const s=Du(t[o],e,r);i.push(s)}return i}function bf(t,e,r,i){if(t[0]<r[0]||t[0]>r[2]){const o=.5*i;let s=t[0]-r[0]>o?-i:r[0]-t[0]>o?i:0;s===0&&(s=t[0]-r[2]>o?-i:r[2]-t[0]>o?i:0),t[0]+=s}qn(e,t)}function wf(t,e,r,i){const o=Math.pow(2,i.z)*Mo,s=[i.x*Mo,i.y*Mo],n=[];if(!t)return n;for(const a of t)for(const l of a){const c=[l.x+s[0],l.y+s[1]];bf(c,e,r,o),n.push(c)}return n}function Tf(t,e,r,i){const o=Math.pow(2,i.z)*Mo,s=[i.x*Mo,i.y*Mo],n=[];if(!t)return n;for(const l of t){const c=[];for(const u of l){const h=[u.x+s[0],u.y+s[1]];qn(e,h),c.push(h)}n.push(c)}if(e[2]-e[0]<=o/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const l of n)for(const c of l)bf(c,e,r,o)}var a;return n}class $n{constructor(e,r){this.type=yt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(qs(e[1])){const i=e[1];if(i.type==="FeatureCollection")for(let o=0;o<i.features.length;++o){const s=i.features[o].geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new $n(i,i.features[o].geometry)}else if(i.type==="Feature"){const o=i.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new $n(i,i.geometry)}else if(i.type==="Polygon"||i.type==="MultiPolygon")return new $n(i,i)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,i){const o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],n=r.canonicalID();if(!n)return!1;if(i.type==="Polygon"){const a=Du(i.coordinates,s,n),l=wf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!Zs(c,a))return!1}if(i.type==="MultiPolygon"){const a=vf(i.coordinates,s,n),l=wf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!vv(c,a))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,i){const o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],n=r.canonicalID();if(!n)return!1;if(i.type==="Polygon"){const a=Du(i.coordinates,s,n),l=Tf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!xf(c,a))return!1}if(i.type==="MultiPolygon"){const a=vf(i.coordinates,s,n),l=Tf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!wv(c,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var ku=$n,Ef={exports:{}};Ef.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,r=e*(2-e),i=Math.PI/180,o=function(c,u){if(c===void 0)throw new Error("No latitude given.");if(u&&!t[u])throw new Error("Unknown unit "+u+". Use one of: "+Object.keys(t).join(", "));var h=6378.137*i*(u?t[u]:1),d=Math.cos(c*i),p=1/(1-r*(1-d*d)),f=Math.sqrt(p);this.kx=h*f*d,this.ky=h*f*p*(1-r)},s={units:{configurable:!0}};function n(c,u){return c[0]===u[0]&&c[1]===u[1]}function a(c,u,h){var d=l(u[0]-c[0]);return[c[0]+d*h,c[1]+(u[1]-c[1])*h]}function l(c){for(;c<-180;)c+=360;for(;c>180;)c-=360;return c}return o.fromTile=function(c,u,h){var d=Math.PI*(1-2*(c+.5)/Math.pow(2,u)),p=Math.atan(.5*(Math.exp(d)-Math.exp(-d)))/i;return new o(p,h)},s.units.get=function(){return t},o.prototype.distance=function(c,u){var h=l(c[0]-u[0])*this.kx,d=(c[1]-u[1])*this.ky;return Math.sqrt(h*h+d*d)},o.prototype.bearing=function(c,u){var h=l(u[0]-c[0])*this.kx;return Math.atan2(h,(u[1]-c[1])*this.ky)/i},o.prototype.destination=function(c,u,h){var d=h*i;return this.offset(c,Math.sin(d)*u,Math.cos(d)*u)},o.prototype.offset=function(c,u,h){return[c[0]+u/this.kx,c[1]+h/this.ky]},o.prototype.lineDistance=function(c){for(var u=0,h=0;h<c.length-1;h++)u+=this.distance(c[h],c[h+1]);return u},o.prototype.area=function(c){for(var u=0,h=0;h<c.length;h++)for(var d=c[h],p=0,f=d.length,m=f-1;p<f;m=p++)u+=l(d[p][0]-d[m][0])*(d[p][1]+d[m][1])*(h?-1:1);return Math.abs(u)/2*this.kx*this.ky},o.prototype.along=function(c,u){var h=0;if(u<=0)return c[0];for(var d=0;d<c.length-1;d++){var p=c[d],f=c[d+1],m=this.distance(p,f);if((h+=m)>u)return a(p,f,(u-(h-m))/m)}return c[c.length-1]},o.prototype.pointToSegmentDistance=function(c,u,h){var d=u[0],p=u[1],f=l(h[0]-d)*this.kx,m=(h[1]-p)*this.ky,_=0;return f===0&&m===0||((_=(l(c[0]-d)*this.kx*f+(c[1]-p)*this.ky*m)/(f*f+m*m))>1?(d=h[0],p=h[1]):_>0&&(d+=f/this.kx*_,p+=m/this.ky*_)),f=l(c[0]-d)*this.kx,m=(c[1]-p)*this.ky,Math.sqrt(f*f+m*m)},o.prototype.pointOnLine=function(c,u){for(var h,d,p,f,m=1/0,_=0;_<c.length-1;_++){var g=c[_][0],y=c[_][1],v=l(c[_+1][0]-g)*this.kx,b=(c[_+1][1]-y)*this.ky,x=0;v===0&&b===0||((x=(l(u[0]-g)*this.kx*v+(u[1]-y)*this.ky*b)/(v*v+b*b))>1?(g=c[_+1][0],y=c[_+1][1]):x>0&&(g+=v/this.kx*x,y+=b/this.ky*x));var w=(v=l(u[0]-g)*this.kx)*v+(b=(u[1]-y)*this.ky)*b;w<m&&(m=w,h=g,d=y,p=_,f=x)}return{point:[h,d],index:p,t:Math.max(0,Math.min(1,f))}},o.prototype.lineSlice=function(c,u,h){var d=this.pointOnLine(h,c),p=this.pointOnLine(h,u);if(d.index>p.index||d.index===p.index&&d.t>p.t){var f=d;d=p,p=f}var m=[d.point],_=d.index+1,g=p.index;!n(h[_],m[0])&&_<=g&&m.push(h[_]);for(var y=_+1;y<=g;y++)m.push(h[y]);return n(h[g],p.point)||m.push(p.point),m},o.prototype.lineSliceAlong=function(c,u,h){for(var d=0,p=[],f=0;f<h.length-1;f++){var m=h[f],_=h[f+1],g=this.distance(m,_);if((d+=g)>c&&p.length===0&&p.push(a(m,_,(c-(d-g))/g)),d>=u)return p.push(a(m,_,(u-(d-g))/g)),p;d>c&&p.push(_)}return p},o.prototype.bufferPoint=function(c,u){var h=u/this.ky,d=u/this.kx;return[c[0]-d,c[1]-h,c[0]+d,c[1]+h]},o.prototype.bufferBBox=function(c,u){var h=u/this.ky,d=u/this.kx;return[c[0]-d,c[1]-h,c[2]+d,c[3]+h]},o.prototype.insideBBox=function(c,u){return l(c[0]-u[0])>=0&&l(c[0]-u[2])<=0&&c[1]>=u[1]&&c[1]<=u[3]},Object.defineProperties(o,s),o}();var Pu=li(Ef.exports),Mf={exports:{}};Mf.exports=function(){var t=function(r,i){if(r===void 0&&(r=[]),i===void 0&&(i=e),this.data=r,this.length=this.data.length,this.compare=i,this.length>0)for(var o=(this.length>>1)-1;o>=0;o--)this._down(o)};function e(r,i){return r<i?-1:r>i?1:0}return t.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},t.prototype.pop=function(){if(this.length!==0){var r=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),r}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(r){for(var i=this.data,o=this.compare,s=i[r];r>0;){var n=r-1>>1,a=i[n];if(o(s,a)>=0)break;i[r]=a,r=n}i[r]=s},t.prototype._down=function(r){for(var i=this.data,o=this.compare,s=this.length>>1,n=i[r];r<s;){var a=1+(r<<1),l=i[a],c=a+1;if(c<this.length&&o(i[c],l)<0&&(a=c,l=i[c]),o(l,n)>=0)break;i[r]=l,r=a}i[r]=n},t}();var Ru=li(Mf.exports),W=8192;function Sf(t,e){return e.dist-t.dist}const Lu=100,Bu=50;function Af(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function ol(t){return t[1]-t[0]+1}function ao(t,e){const r=t[1]>=t[0]&&t[1]<e;return r||console.warn("Distance Expression: Index is out of range"),r}function Ou(t,e){if(t[0]>t[1])return[null,null];const r=ol(t);if(e){if(r===2)return[t,null];const i=Math.floor(r/2);return[[t[0],t[0]+i],[t[0]+i,t[1]]]}{if(r===1)return[t,null];const i=Math.floor(r/2)-1;return[[t[0],t[0]+i],[t[0]+i+1,t[1]]]}}function hs(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!ao(e,t.length))return r;for(let i=e[0];i<=e[1];++i)qn(r,t[i]);return r}function sl(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let i=0;i<t[r].length;++i)qn(e,t[r][i]);return e}function $s(t,e,r){if(Af(t)||Af(e))return NaN;let i=0,o=0;return t[2]<e[0]&&(i=e[0]-t[2]),t[0]>e[2]&&(i=t[0]-e[2]),t[1]>e[3]&&(o=t[1]-e[3]),t[3]<e[1]&&(o=e[1]-t[3]),r.distance([0,0],[i,o])}function Fu(t,e){const r=Math.pow(2,e.z);return[(o=(t.x/W+e.x)/r,360*o-180),(i=(t.y/W+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90)];var i,o}function Tv(t,e){const r=[];for(let i=0;i<t.length;++i)r.push(Fu(t[i],e));return r}function If(t,e,r){const i=r.pointOnLine(e,t).point;return r.distance(t,i)}function Cf(t,e,r,i,o){const s=r.slice(i[0],i[1]+1);let n=1/0;for(let a=e[0];a<=e[1];++a)if((n=Math.min(n,If(t[a],s,o)))===0)return 0;return n}function Nu(t,e,r,i,o){const s=Math.min(o.pointToSegmentDistance(t,r,i),o.pointToSegmentDistance(e,r,i)),n=Math.min(o.pointToSegmentDistance(r,t,e),o.pointToSegmentDistance(i,t,e));return Math.min(s,n)}function Ev(t,e,r,i,o){if(!ao(e,t.length)||!ao(i,r.length))return NaN;let s=1/0;for(let n=e[0];n<e[1];++n)for(let a=i[0];a<i[1];++a){if(il(t[n],t[n+1],r[a],r[a+1]))return 0;s=Math.min(s,Nu(t[n],t[n+1],r[a],r[a+1],o))}return s}function Mv(t,e,r,i,o){if(!ao(e,t.length)||!ao(i,r.length))return NaN;let s=1/0;for(let n=e[0];n<=e[1];++n)for(let a=i[0];a<=i[1];++a)if((s=Math.min(s,o.distance(t[n],r[a])))===0)return s;return s}function Sv(t,e,r){if(Zs(t,e,!0))return 0;let i=1/0;for(const o of e){const s=o.length;if(s<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(o[0]!==o[s-1]&&(i=Math.min(i,r.pointToSegmentDistance(t,o[s-1],o[0])))===0||(i=Math.min(i,If(t,o,r)))===0)return i}return i}function Av(t,e,r,i){if(!ao(e,t.length))return NaN;for(let s=e[0];s<=e[1];++s)if(Zs(t[s],r,!0))return 0;let o=1/0;for(let s=e[0];s<e[1];++s)for(const n of r)for(let a=0,l=n.length,c=l-1;a<l;c=a++){if(il(t[s],t[s+1],n[c],n[a]))return 0;o=Math.min(o,Nu(t[s],t[s+1],n[c],n[a],i))}return o}function zf(t,e){for(const r of t)for(let i=0;i<=r.length-1;++i)if(Zs(r[i],e,!0))return!0;return!1}function Iv(t,e,r,i=1/0){const o=sl(t),s=sl(e);if(i!==1/0&&$s(o,s,r)>=i)return i;if(Zn(o,s)){if(zf(t,e))return 0}else if(zf(e,t))return 0;let n=i;for(const a of t)for(let l=0,c=a.length,u=c-1;l<c;u=l++)for(const h of e)for(let d=0,p=h.length,f=p-1;d<p;f=d++){if(il(a[u],a[l],h[f],h[d]))return 0;n=Math.min(n,Nu(a[u],a[l],h[f],h[d],r))}return n}function nl(t,e,r,i,o,s,n){if(s===null||n===null)return;const a=$s(hs(i,s),hs(o,n),r);a<e&&t.push({dist:a,range1:s,range2:n})}function Cv(t,e,r,i,o=1/0){let s=Math.min(i.distance(t[0],r[0][0]),o);if(s===0)return s;const n=new Ru([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Sf),a=e?Bu:Lu,l=sl(r);for(;n.length;){const c=n.pop();if(c.dist>=s)continue;const u=c.range1;if(ol(u)<=a){if(!ao(u,t.length))return NaN;if(e){const h=Av(t,u,r,i);if((s=Math.min(s,h))===0)return s}else for(let h=u[0];h<=u[1];++h){const d=Sv(t[h],r,i);if((s=Math.min(s,d))===0)return s}}else{const h=Ou(u,e);if(h[0]!==null){const d=$s(hs(t,h[0]),l,i);d<s&&n.push({dist:d,range1:h[0],range2:[0,0]})}if(h[1]!==null){const d=$s(hs(t,h[1]),l,i);d<s&&n.push({dist:d,range1:h[1],range2:[0,0]})}}}return s}function Df(t,e,r,i,o,s=1/0){let n=Math.min(s,o.distance(t[0],r[0]));if(n===0)return n;const a=new Ru([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],Sf),l=e?Bu:Lu,c=i?Bu:Lu;for(;a.length;){const u=a.pop();if(u.dist>=n)continue;const h=u.range1,d=u.range2;if(ol(h)<=l&&ol(d)<=c){if(!ao(h,t.length)||!ao(d,r.length))return NaN;if(e&&i?n=Math.min(n,Ev(t,h,r,d,o)):e||i?e&&!i?n=Math.min(n,Cf(r,d,t,h,o)):!e&&i&&(n=Math.min(n,Cf(t,h,r,d,o))):n=Math.min(n,Mv(t,h,r,d,o)),n===0)return n}else{const p=Ou(h,e),f=Ou(d,i);nl(a,n,o,t,r,p[0],f[0]),nl(a,n,o,t,r,p[0],f[1]),nl(a,n,o,t,r,p[1],f[0]),nl(a,n,o,t,r,p[1],f[1])}}return n}function Uu(t,e,r,i,o=1/0){let s=o;const n=hs(t,[0,t.length-1]);for(const a of r)if(!(s!==1/0&&$s(n,hs(a,[0,a.length-1]),i)>=s)&&(s=Math.min(s,Df(t,e,a,!0,i,s)),s===0))return s;return s}function al(t,e,r,i,o=1/0){let s=o;const n=hs(t,[0,t.length-1]);for(const a of r){if(s!==1/0&&$s(n,sl(a),i)>=s)continue;const l=Cv(t,e,a,i,s);if(isNaN(l))return l;if((s=Math.min(s,l))===0)return s}return s}function Vu(t){return t==="Point"||t==="MultiPoint"||t==="LineString"||t==="MultiLineString"||t==="Polygon"||t==="MultiPolygon"}class Hn{constructor(e,r){this.type=ye,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(qs(e[1])){const i=e[1];if(i.type==="FeatureCollection"){for(let o=0;o<i.features.length;++o)if(Vu(i.features[o].geometry.type))return new Hn(i,i.features[o].geometry)}else if(i.type==="Feature"){if(Vu(i.geometry.type))return new Hn(i,i.geometry)}else if(Vu(i.type))return new Hn(i,i)}return r.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const r=e.geometry(),i=e.canonicalID();if(r!=null&&i!=null){if(e.geometryType()==="Point")return function(o,s,n){const a=[];for(const c of o)for(const u of c)a.push(Fu(u,s));const l=new Pu(a[0][1],"meters");return n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString"?Df(a,!1,n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",l):n.type==="MultiLineString"?Uu(a,!1,n.coordinates,l):n.type==="Polygon"||n.type==="MultiPolygon"?al(a,!1,n.type==="Polygon"?[n.coordinates]:n.coordinates,l):null}(r,i,this.geometries);if(e.geometryType()==="LineString")return function(o,s,n){const a=[];for(const c of o){const u=[];for(const h of c)u.push(Fu(h,s));a.push(u)}const l=new Pu(a[0][0][1],"meters");if(n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString")return Uu(n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",a,l);if(n.type==="MultiLineString"){let c=1/0;for(let u=0;u<n.coordinates.length;u++){const h=Uu(n.coordinates[u],!0,a,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}if(n.type==="Polygon"||n.type==="MultiPolygon"){let c=1/0;for(let u=0;u<a.length;u++){const h=al(a[u],!0,n.type==="Polygon"?[n.coordinates]:n.coordinates,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}return null}(r,i,this.geometries);if(e.geometryType()==="Polygon")return function(o,s,n){const a=[];for(const c of function(u,h){const d=u.length;if(d<=1)return[u];const p=[];let f,m;for(let _=0;_<d;_++){const g=gv(u[_]);g!==0&&(u[_].area=Math.abs(g),m===void 0&&(m=g<0),m===g<0?(f&&p.push(f),f=[u[_]]):f.push(u[_]))}return f&&p.push(f),p}(o)){const u=[];for(let h=0;h<c.length;++h)u.push(Tv(c[h],s));a.push(u)}const l=new Pu(a[0][0][0][1],"meters");if(n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString")return al(n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",a,l);if(n.type==="MultiLineString"){let c=1/0;for(let u=0;u<n.coordinates.length;u++){const h=al(n.coordinates[u],!0,a,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}return n.type==="Polygon"||n.type==="MultiPolygon"?function(c,u,h){let d=1/0;for(const p of c)for(const f of u){const m=Iv(p,f,h,d);if(isNaN(m))return m;if((d=Math.min(d,m))===0)return d}return d}(n.type==="Polygon"?[n.coordinates]:n.coordinates,a,l):null}(r,i,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 ju=Hn;function Hs(t){if(t instanceof Vi&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof ku||t instanceof ju)return!1;let e=!0;return t.eachChild(r=>{e&&!Hs(r)&&(e=!1)}),e}function Wn(t){if(t instanceof Vi&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(r=>{e&&!Wn(r)&&(e=!1)}),e}function Gu(t){if(t instanceof Vi&&t.name==="config")return!1;let e=!0;return t.eachChild(r=>{e&&!Gu(r)&&(e=!1)}),e}function Ws(t,e){if(t instanceof Vi&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild(i=>{r&&!Ws(i,e)&&(r=!1)}),r}class qu{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const i=e[1];return r.scope.has(i)?new qu(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" 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 kf=qu;class Zu{constructor(e,r=[],i,o=new hv,s=[],n){this.registry=e,this.path=r,this.key=r.map(a=>`[${a}]`).join(""),this.scope=o,this.errors=s,this.expectedType=i,this.options=n}parse(e,r,i,o,s={}){return r||i?this.concat(r,i,o)._parse(e,s):this._parse(e,s)}_parse(e,r){function i(o,s,n){return n==="assert"?new no(s,[o]):n==="coerce"?new cs(s,[o]):o}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=typeof e[0]=="string"?this.registry[e[0]]:void 0;if(o){let s=o.parse(e,this);if(!s)return null;if(this.expectedType){const n=this.expectedType,a=s.type;if(n.kind!=="string"&&n.kind!=="number"&&n.kind!=="boolean"&&n.kind!=="object"&&n.kind!=="array"||a.kind!=="value")if(n.kind!=="color"&&n.kind!=="formatted"&&n.kind!=="resolvedImage"||a.kind!=="value"&&a.kind!=="string"){if(this.checkSubtype(n,a))return null}else s=i(s,n,r.typeAnnotation||"coerce");else s=i(s,n,r.typeAnnotation||"assert")}if(!(s instanceof Vn)&&s.type.kind!=="resolvedImage"&&$u(s)){const n=new _f(this.options);try{s=new Vn(s.type,s.evaluate(n))}catch(a){return this.error(a.message),null}}return s}return cs.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,i){const o=typeof e=="number"?this.path.concat(e):this.path,s=i?this.scope.concat(i):this.scope;return new Zu(this.registry,o,r||null,s,this.errors,this.options)}error(e,...r){const i=`${this.key}${r.map(o=>`[${o}]`).join("")}`;this.errors.push(new Ui(i,e))}checkSubtype(e,r){const i=Fn(e,r);return i&&this.error(i),i}}var Pf=Zu;function $u(t){if(t instanceof kf)return $u(t.boundExpression);if(t instanceof Vi&&t.name==="error"||t instanceof Vi&&t.name==="config"||t instanceof rl||t instanceof ku||t instanceof ju)return!1;const e=t instanceof cs||t instanceof no;let r=!0;return t.eachChild(i=>{r=e?r&&$u(i):r&&i instanceof Vn}),!!r&&Hs(t)&&Ws(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light"])}function ll(t,e){const r=t.length-1;let i,o,s=0,n=r,a=0;for(;s<=n;)if(a=Math.floor((s+n)/2),i=t[a],o=t[a+1],i<=e){if(a===r||e<o)return a;s=a+1}else{if(!(i>e))throw new Tr("Input is not a number.");n=a-1}return 0}class Hu{constructor(e,r,i){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[o,s]of i)this.labels.push(o),this.outputs.push(s)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const i=r.parse(e[1],1,ye);if(!i)return null;const o=[];let s=null;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);for(let n=1;n<e.length;n+=2){const a=n===1?-1/0:e[n],l=e[n+1],c=n,u=n+1;if(typeof a!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',c);if(o.length&&o[o.length-1][0]>=a)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',c);const h=r.parse(l,u,s);if(!h)return null;s=s||h.type,o.push([a,h])}return new Hu(s,i,o)}evaluate(e){const r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return i[0].evaluate(e);const s=r.length;return o>=r[s-1]?i[s-1].evaluate(e):i[ll(r,o)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let r=0;r<this.labels.length;r++)r>0&&e.push(this.labels[r]),e.push(this.outputs[r].serialize());return e}}var Wu=Hu;function Fe(t,e,r){return t*(1-r)+e*r}function Rf(t,e,r){return t.map((i,o)=>Fe(i,e[o],r))}var cl=Object.freeze({__proto__:null,array:Rf,color:function(t,e,r){return new Qe(Fe(t.r,e.r,r),Fe(t.g,e.g,r),Fe(t.b,e.b,r),Fe(t.a,e.a,r))},number:Fe});const Lf=.95047,Bf=1.08883,Of=4/29,Xs=6/29,Ff=3*Xs*Xs,zv=Xs*Xs*Xs,Dv=Math.PI/180,kv=180/Math.PI;function Xu(t){return t>zv?Math.pow(t,1/3):t/Ff+Of}function Yu(t){return t>Xs?t*t*t:Ff*(t-Of)}function Ju(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ku(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Nf(t){const e=Ku(t.r),r=Ku(t.g),i=Ku(t.b),o=Xu((.4124564*e+.3575761*r+.1804375*i)/Lf),s=Xu((.2126729*e+.7151522*r+.072175*i)/1);return{l:116*s-16,a:500*(o-s),b:200*(s-Xu((.0193339*e+.119192*r+.9503041*i)/Bf)),alpha:t.a}}function Uf(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,i=isNaN(t.b)?e:e-t.b/200;return e=1*Yu(e),r=Lf*Yu(r),i=Bf*Yu(i),new Qe(Ju(3.2404542*r-1.5371385*e-.4985314*i),Ju(-.969266*r+1.8760108*e+.041556*i),Ju(.0556434*r-.2040259*e+1.0572252*i),t.alpha)}function Pv(t,e,r){const i=e-t;return t+r*(i>180||i<-180?i-360*Math.round(i/360):i)}const Xn={forward:Nf,reverse:Uf,interpolate:function(t,e,r){return{l:Fe(t.l,e.l,r),a:Fe(t.a,e.a,r),b:Fe(t.b,e.b,r),alpha:Fe(t.alpha,e.alpha,r)}}},Yn={forward:function(t){const{l:e,a:r,b:i}=Nf(t),o=Math.atan2(i,r)*kv;return{h:o<0?o+360:o,c:Math.sqrt(r*r+i*i),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Dv,r=t.c;return Uf({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:Pv(t.h,e.h,r),c:Fe(t.c,e.c,r),l:Fe(t.l,e.l,r),alpha:Fe(t.alpha,e.alpha,r)}}};var Vf=Object.freeze({__proto__:null,hcl:Yn,lab:Xn});class ul{constructor(e,r,i,o,s){this.type=e,this.operator=r,this.interpolation=i,this.input=o,this.labels=[],this.outputs=[];for(const[n,a]of s)this.labels.push(n),this.outputs.push(a)}static interpolationFactor(e,r,i,o){let s=0;if(e.name==="exponential")s=Qu(r,e.base,i,o);else if(e.name==="linear")s=Qu(r,1,i,o);else if(e.name==="cubic-bezier"){const n=e.controlPoints;s=new qa(n[0],n[1],n[2],n[3]).solve(Qu(r,1,i,o))}return s}static parse(e,r){let[i,o,s,...n]=e;if(!Array.isArray(o)||o.length===0)return r.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const c=o[1];if(typeof c!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:c}}else{if(o[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const c=o.slice(1);if(c.length!==4||c.some(u=>typeof u!="number"||u<0||u>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:c}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(s=r.parse(s,2,ye),!s)return null;const a=[];let l=null;i==="interpolate-hcl"||i==="interpolate-lab"?l=hi:r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let c=0;c<n.length;c+=2){const u=n[c],h=n[c+1],d=c+3,p=c+4;if(typeof u!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(a.length&&a[a.length-1][0]>=u)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);const f=r.parse(h,p,l);if(!f)return null;l=l||f.type,a.push([u,f])}return l.kind==="number"||l.kind==="color"||l.kind==="array"&&l.itemType.kind==="number"&&typeof l.N=="number"?new ul(l,i,o,s,a):r.error(`Type ${sr(l)} is not interpolatable.`)}evaluate(e){const r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return i[0].evaluate(e);const s=r.length;if(o>=r[s-1])return i[s-1].evaluate(e);const n=ll(r,o),a=ul.interpolationFactor(this.interpolation,o,r[n],r[n+1]),l=i[n].evaluate(e),c=i[n+1].evaluate(e);return this.operator==="interpolate"?cl[this.type.kind.toLowerCase()](l,c,a):this.operator==="interpolate-hcl"?Yn.reverse(Yn.interpolate(Yn.forward(l),Yn.forward(c),a)):Xn.reverse(Xn.interpolate(Xn.forward(l),Xn.forward(c),a))}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const r=[this.operator,e,this.input.serialize()];for(let i=0;i<this.labels.length;i++)r.push(this.labels[i],this.outputs[i].serialize());return r}}function Qu(t,e,r,i){const o=i-r,s=t-r;return o===0?0:e===1?s/o:(Math.pow(e,s)-1)/(Math.pow(e,o)-1)}var ji=ul;class eh{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let i=null;const o=r.expectedType;o&&o.kind!=="value"&&(i=o);const s=[];for(const a of e.slice(1)){const l=r.parse(a,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!l)return null;i=i||l.type,s.push(l)}const n=o&&s.some(a=>Fn(o,a.type));return new eh(n?_t:i,s)}evaluate(e){let r,i=null,o=0;for(const s of this.args){if(o++,i=s.evaluate(e),i&&i instanceof di&&!i.available&&(r||(r=i),i=null,o===this.args.length))return r;if(i!==null)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var jf=eh;class th{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let s=1;s<e.length-1;s+=2){const n=e[s];if(typeof n!="string")return r.error(`Expected string, but found ${typeof n} instead.`,s);if(/[^a-zA-Z0-9_]/.test(n))return r.error("Variable names must contain only alphanumeric characters or '_'.",s);const a=r.parse(e[s+1],s+1);if(!a)return null;i.push([n,a])}const o=r.parse(e[e.length-1],e.length-1,r.expectedType,i);return o?new th(i,o):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[r,i]of this.bindings)e.push(r,i.serialize());return e.push(this.result.serialize()),e}}var Gf=th;class rh{constructor(e,r,i){this.type=e,this.index=r,this.input=i}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,ye),o=r.parse(e[2],2,qr(r.expectedType||_t));return i&&o?new rh(o.type.itemType,i,o):null}evaluate(e){const r=this.index.evaluate(e),i=this.input.evaluate(e);if(r<0)throw new Tr(`Array index out of bounds: ${r} < 0.`);if(r>=i.length)throw new Tr(`Array index out of bounds: ${r} > ${i.length-1}.`);if(r!==Math.floor(r))throw new Tr(`Array index must be an integer, but found ${r} instead.`);return i[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Rv=rh;class ih{constructor(e,r){this.type=yt,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,_t);return i&&o?bu(i.type,[yt,ft,ye,js,_t])?new ih(i,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(i==null)return!1;if(!Nn(r,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(mr(r))} instead.`);if(!Nn(i,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${sr(mr(i))} instead.`);return i.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Lv=ih;class hl{constructor(e,r,i){this.type=ye,this.needle=e,this.haystack=r,this.fromIndex=i}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,_t);if(!i||!o)return null;if(!bu(i.type,[yt,ft,ye,js,_t]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(e.length===4){const s=r.parse(e[3],3,ye);return s?new hl(i,o,s):null}return new hl(i,o)}evaluate(e){const r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Nn(r,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(mr(r))} instead.`);if(!Nn(i,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${sr(mr(i))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(e);return i.indexOf(r,o)}return i.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){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 Bv=hl;class oh{constructor(e,r,i,o,s,n){this.inputType=e,this.type=r,this.input=i,this.cases=o,this.outputs=s,this.otherwise=n}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let i,o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const s={},n=[];for(let c=2;c<e.length-1;c+=2){let u=e[c];const h=e[c+1];Array.isArray(u)||(u=[u]);const d=r.concat(c);if(u.length===0)return d.error("Expected at least one branch label.");for(const f of u){if(typeof f!="number"&&typeof f!="string")return d.error("Branch labels must be numbers or strings.");if(typeof f=="number"&&Math.abs(f)>Number.MAX_SAFE_INTEGER)return d.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof f=="number"&&Math.floor(f)!==f)return d.error("Numeric branch labels must be integer values.");if(i){if(d.checkSubtype(i,mr(f)))return null}else i=mr(f);if(s[String(f)]!==void 0)return d.error("Branch labels must be unique.");s[String(f)]=n.length}const p=r.parse(h,c,o);if(!p)return null;o=o||p.type,n.push(p)}const a=r.parse(e[1],1,_t);if(!a)return null;const l=r.parse(e[e.length-1],e.length-1,o);return l?a.type.kind!=="value"&&r.concat(1).checkSubtype(i,a.type)?null:new oh(i,o,a,s,n,l):null}evaluate(e){const r=this.input.evaluate(e);return(mr(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),i=[],o={};for(const n of r){const a=o[this.cases[n]];a===void 0?(o[this.cases[n]]=i.length,i.push([this.cases[n],[n]])):i[a][1].push(n)}const s=n=>this.inputType.kind==="number"?Number(n):n;for(const[n,a]of i)e.push(a.length===1?s(a[0]):a.map(s)),e.push(this.outputs[n].serialize());return e.push(this.otherwise.serialize()),e}}var Ov=oh;class sh{constructor(e,r,i){this.type=e,this.branches=r,this.otherwise=i}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let i;r.expectedType&&r.expectedType.kind!=="value"&&(i=r.expectedType);const o=[];for(let n=1;n<e.length-1;n+=2){const a=r.parse(e[n],n,yt);if(!a)return null;const l=r.parse(e[n+1],n+1,i);if(!l)return null;o.push([a,l]),i=i||l.type}const s=r.parse(e[e.length-1],e.length-1,i);return s?new sh(i,o,s):null}evaluate(e){for(const[r,i]of this.branches)if(r.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,i]of this.branches)e(r),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var Fv=sh;class dl{constructor(e,r,i,o){this.type=e,this.input=r,this.beginIndex=i,this.endIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,ye);if(!i||!o)return null;if(!bu(i.type,[qr(_t),ft,_t]))return r.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(e.length===4){const s=r.parse(e[3],3,ye);return s?new dl(i.type,i,o,s):null}return new dl(i.type,i,o)}evaluate(e){const r=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Nn(r,["string","array"]))throw new Tr(`Expected first argument to be of type array or string, but found ${sr(mr(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(e);return r.slice(i,o)}return r.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Nv=dl;function qf(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Zf(t,e,r,i){return i.compare(e,r)===0}function Ys(t,e,r){const i=t!=="=="&&t!=="!=";return class ov{constructor(s,n,a){this.type=yt,this.lhs=s,this.rhs=n,this.collator=a,this.hasUntypedArgument=s.type.kind==="value"||n.type.kind==="value"}static parse(s,n){if(s.length!==3&&s.length!==4)return n.error("Expected two or three arguments.");const a=s[0];let l=n.parse(s[1],1,_t);if(!l)return null;if(!qf(a,l.type))return n.concat(1).error(`"${a}" comparisons are not supported for type '${sr(l.type)}'.`);let c=n.parse(s[2],2,_t);if(!c)return null;if(!qf(a,c.type))return n.concat(2).error(`"${a}" comparisons are not supported for type '${sr(c.type)}'.`);if(l.type.kind!==c.type.kind&&l.type.kind!=="value"&&c.type.kind!=="value")return n.error(`Cannot compare types '${sr(l.type)}' and '${sr(c.type)}'.`);i&&(l.type.kind==="value"&&c.type.kind!=="value"?l=new no(c.type,[l]):l.type.kind!=="value"&&c.type.kind==="value"&&(c=new no(l.type,[c])));let u=null;if(s.length===4){if(l.type.kind!=="string"&&c.type.kind!=="string"&&l.type.kind!=="value"&&c.type.kind!=="value")return n.error("Cannot use collator to compare non-string types.");if(u=n.parse(s[3],3,Qa),!u)return null}return new ov(l,c,u)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(i&&this.hasUntypedArgument){const l=mr(n),c=mr(a);if(l.kind!==c.kind||l.kind!=="string"&&l.kind!=="number")throw new Tr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${l.kind}, ${c.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const l=mr(n),c=mr(a);if(l.kind!=="string"||c.kind!=="string")return e(s,n,a)}return this.collator?r(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(s){s(this.lhs),s(this.rhs),this.collator&&s(this.collator)}outputDefined(){return!0}serialize(){const s=[t];return this.eachChild(n=>{s.push(n.serialize())}),s}}}const Uv=Ys("==",function(t,e,r){return e===r},Zf),Vv=Ys("!=",function(t,e,r){return e!==r},function(t,e,r,i){return!Zf(0,e,r,i)}),jv=Ys("<",function(t,e,r){return e<r},function(t,e,r,i){return i.compare(e,r)<0}),Gv=Ys(">",function(t,e,r){return e>r},function(t,e,r,i){return i.compare(e,r)>0}),qv=Ys("<=",function(t,e,r){return e<=r},function(t,e,r,i){return i.compare(e,r)<=0}),Zv=Ys(">=",function(t,e,r){return e>=r},function(t,e,r,i){return i.compare(e,r)>=0});class nh{constructor(e,r,i,o,s,n){this.type=ft,this.number=e,this.locale=r,this.currency=i,this.unit=o,this.minFractionDigits=s,this.maxFractionDigits=n}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const i=r.parse(e[1],1,ye);if(!i)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let s=null;if(o.locale&&(s=r.parse(o.locale,1,ft),!s))return null;let n=null;if(o.currency&&(n=r.parse(o.currency,1,ft),!n))return null;let a=null;if(o.unit&&(a=r.parse(o.unit,1,ft),!a))return null;let l=null;if(o["min-fraction-digits"]&&(l=r.parse(o["min-fraction-digits"],1,ye),!l))return null;let c=null;return o["max-fraction-digits"]&&(c=r.parse(o["max-fraction-digits"],1,ye),!c)?null:new nh(i,s,n,a,l,c)}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 ah{constructor(e){this.type=ye,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=r.parse(e[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new ah(i):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Tr(`Expected value to be of type string or array, but found ${sr(mr(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(r=>{e.push(r.serialize())}),e}}function lh(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 $f={"==":Uv,"!=":Vv,">":Gv,"<":jv,">=":Zv,"<=":qv,array:no,at:Rv,boolean:no,case:Fv,coalesce:jf,collator:rl,format:jn,image:Gn,in:Lv,"index-of":Bv,interpolate:ji,"interpolate-hcl":ji,"interpolate-lab":ji,length:ah,let:Gf,literal:Vn,match:Ov,number:no,"number-format":nh,object:no,slice:Nv,step:Wu,string:no,"to-boolean":cs,"to-color":cs,"to-number":cs,"to-string":cs,var:kf,within:ku,distance:ju};function Hf(t,[e,r,i,o]){e=e.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);const s=o?o.evaluate(t):1,n=mf(e,r,i,s);if(n)throw new Tr(n);return new Qe(e/255*s,r/255*s,i/255*s,s)}function Wf(t,[e,r,i,o]){e=e.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);const s=o?o.evaluate(t):1,n=function(c,u,h,d){return typeof c=="number"&&c>=0&&c<=360?typeof u=="number"&&u>=0&&u<=100&&typeof h=="number"&&h>=0&&h<=100?d===void 0||typeof d=="number"&&d>=0&&d<=1?null:`Invalid hsla value [${[c,u,h,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof d=="number"?[c,u,h,d]:[c,u,h]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof d=="number"?[c,u,h,d]:[c,u,h]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,i,s);if(n)throw new Tr(n);const a=`hsla(${e}, ${r}%, ${i}%, ${s})`,l=Qe.parse(a);if(!l)throw new Tr(`Failed to parse HSLA color: ${a}`);return l}function Xf(t,e){return t in e}function ch(t,e){const r=e[t];return r===void 0?null:r}function Yf(t,e){switch(t){case"string":return String(e);case"number":return+e;case"boolean":return!!e;case"color":return Qe.parse(e)}return e}function Jf(t,e,r,i){return i!==void 0&&(t=i*Math.round(t/i)),e!==void 0&&t<e&&(t=e),r!==void 0&&t>r&&(t=r),t}function Kf(t,e,r){r.length&&(e+=`${r}`);const i=t.getConfig(e);if(!i)return null;const{type:o,value:s,values:n,minValue:a,maxValue:l,stepValue:c}=i,u=i.default.evaluate(t);let h=s?s.evaluate(t):u;return o&&(h=Yf(o,h)),s!==void 0&&h!==void 0&&n&&!n.includes(h)&&(h=u,o&&(h=Yf(o,h))),h===void 0||a===void 0&&l===void 0&&c===void 0||(typeof h=="number"?h=Jf(h,a,l,c):Array.isArray(h)&&(h=h.map(d=>typeof d=="number"?Jf(d,a,l,c):d))),h}function ds(t){return{type:t}}Vi.register($f,{error:[{kind:"error"},[ft],(t,[e])=>{throw new Tr(e.evaluate(t))}],typeof:[ft,[_t],(t,[e])=>sr(mr(e.evaluate(t)))],"to-rgba":[qr(ye,4),[hi],(t,[e])=>e.evaluate(t).toArray()],rgb:[hi,[ye,ye,ye],Hf],rgba:[hi,[ye,ye,ye,ye],Hf],hsl:[hi,[ye,ye,ye],Wf],hsla:[hi,[ye,ye,ye,ye],Wf],has:{type:yt,overloads:[[[ft],(t,[e])=>Xf(e.evaluate(t),t.properties())],[[ft,Gs],(t,[e,r])=>Xf(e.evaluate(t),r.evaluate(t))]]},get:{type:_t,overloads:[[[ft],(t,[e])=>ch(e.evaluate(t),t.properties())],[[ft,Gs],(t,[e,r])=>ch(e.evaluate(t),r.evaluate(t))]]},config:{type:_t,overloads:[[[ft],(t,[e])=>Kf(t,e.evaluate(t),"")],[[ft,ft],(t,[e,r])=>Kf(t,e.evaluate(t),r.evaluate(t))]]},"feature-state":[_t,[ft],(t,[e])=>ch(e.evaluate(t),t.featureState||{})],properties:[Gs,[],t=>t.properties()],"geometry-type":[ft,[],t=>t.geometryType()],id:[_t,[],t=>t.id()],zoom:[ye,[],t=>t.globals.zoom],pitch:[ye,[],t=>t.globals.pitch||0],"distance-from-center":[ye,[],t=>t.distanceFromCenter()],"measure-light":[ye,[ft],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ye,[],t=>t.globals.heatmapDensity||0],"line-progress":[ye,[],t=>t.globals.lineProgress||0],"raster-value":[ye,[],t=>t.globals.rasterValue||0],"sky-radial-progress":[ye,[],t=>t.globals.skyRadialProgress||0],accumulated:[_t,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[ye,ds(ye),(t,e)=>{let r=0;for(const i of e)r+=i.evaluate(t);return r}],"*":[ye,ds(ye),(t,e)=>{let r=1;for(const i of e)r*=i.evaluate(t);return r}],"-":{type:ye,overloads:[[[ye,ye],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[ye],(t,[e])=>-e.evaluate(t)]]},"/":[ye,[ye,ye],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[ye,[ye,ye],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[ye,[],()=>Math.LN2],pi:[ye,[],()=>Math.PI],e:[ye,[],()=>Math.E],"^":[ye,[ye,ye],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[ye,[ye],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))],log2:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ye,[ye],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ye,[ye],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ye,[ye],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ye,[ye],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ye,[ye],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ye,[ye],(t,[e])=>Math.atan(e.evaluate(t))],min:[ye,ds(ye),(t,e)=>Math.min(...e.map(r=>r.evaluate(t)))],max:[ye,ds(ye),(t,e)=>Math.max(...e.map(r=>r.evaluate(t)))],abs:[ye,[ye],(t,[e])=>Math.abs(e.evaluate(t))],round:[ye,[ye],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[ye,[ye],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ye,[ye],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[yt,[ft,_t],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[yt,[_t],(t,[e])=>t.id()===e.value],"filter-type-==":[yt,[ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i<o}],"filter-id-<":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r<i}],"filter->":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r>i}],"filter-<=":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r<=i}],"filter->=":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r>=i}],"filter-has":[yt,[_t],(t,[e])=>e.value in t.properties()],"filter-has-id":[yt,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[yt,[qr(ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[yt,[qr(_t)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[yt,[ft,qr(_t)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[yt,[ft,qr(_t)],(t,[e,r])=>function(i,o,s,n){for(;s<=n;){const a=s+n>>1;if(o[a]===i)return!0;o[a]>i?n=a-1:s=a+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:yt,overloads:[[[yt,yt],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[ds(yt),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:yt,overloads:[[[yt,yt],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[ds(yt),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[yt,[yt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[yt,[ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[ft,[ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ft,[ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ft,ds(_t),(t,e)=>e.map(r=>Un(r.evaluate(t))).join("")],"resolved-locale":[ft,[Qa],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ye,[ye,ye,_t],(t,e)=>{const[r,i,o]=e.map(n=>n.evaluate(t));if(r>i||r===i)return r;let s;if(typeof o=="string")s=function(n){let a=0;if(n.length===0)return a;for(let l=0;l<n.length;l++)a=(a<<5)-a+n.charCodeAt(l),a&=a;return a}(o);else{if(typeof o!="number")throw new Tr(`Invalid seed input: ${o}`);s=o}return r+lh(s)()*(i-r)}]});var Jn=$f;function Qf(t){return{result:"success",value:t}}function ps(t){return{result:"error",value:t}}function em(t,e){return!!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function fs(t){return t["property-type"]==="data-driven"}function tm(t){return em(t.expression,"measure-light")}function uh(t){return em(t.expression,"zoom")}function hh(t){return!!t.expression&&t.expression.interpolated}function pl(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $v(t){return t}function rm(t,e){const r=e.type==="color",i=t.stops&&typeof t.stops[0][0]=="object",o=i||!(i||t.property!==void 0),s=t.type||(hh(e)?"exponential":"interval");if(r&&((t=oo({},t)).stops&&(t.stops=t.stops.map(c=>[c[0],Qe.parse(c[1])])),t.default=Qe.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!Vf[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let n,a,l;if(s==="exponential")n=im;else if(s==="interval")n=Wv;else if(s==="categorical"){n=Hv,a=Object.create(null);for(const c of t.stops)a[c[0]]=c[1];l=typeof t.stops[0][0]}else{if(s!=="identity")throw new Error(`Unknown function type "${s}"`);n=Xv}if(i){const c={},u=[];for(let p=0;p<t.stops.length;p++){const f=t.stops[p],m=f[0].zoom;c[m]===void 0&&(c[m]={zoom:m,type:t.type,property:t.property,default:t.default,stops:[]},u.push(m)),c[m].stops.push([f[0].value,f[1]])}const h=[];for(const p of u)h.push([c[p].zoom,rm(c[p],e)]);const d={name:"linear"};return{kind:"composite",interpolationType:d,interpolationFactor:ji.interpolationFactor.bind(void 0,d),zoomStops:h.map(p=>p[0]),evaluate:({zoom:p},f)=>im({stops:h,base:t.base},e,p).evaluate(p,f)}}if(o){const c=s==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:c,interpolationFactor:ji.interpolationFactor.bind(void 0,c),zoomStops:t.stops.map(u=>u[0]),evaluate:({zoom:u})=>n(t,e,u,a,l)}}return{kind:"source",evaluate(c,u){const h=u&&u.properties?u.properties[t.property]:void 0;return h===void 0?Kn(t.default,e.default):n(t,e,h,a,l)}}}function Kn(t,e,r){return t!==void 0?t:e!==void 0?e:r!==void 0?r:void 0}function Hv(t,e,r,i,o){return Kn(typeof r===o?i[r]:void 0,t.default,e.default)}function Wv(t,e,r){if(Tt(r)!=="number")return Kn(t.default,e.default);const i=t.stops.length;if(i===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const o=ll(t.stops.map(s=>s[0]),r);return t.stops[o][1]}function im(t,e,r){const i=t.base!==void 0?t.base:1;if(Tt(r)!=="number")return Kn(t.default,e.default);const o=t.stops.length;if(o===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[o-1][0])return t.stops[o-1][1];const s=ll(t.stops.map(u=>u[0]),r),n=function(u,h,d,p){const f=p-d,m=u-d;return f===0?0:h===1?m/f:(Math.pow(h,m)-1)/(Math.pow(h,f)-1)}(r,i,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1];let c=cl[e.type]||$v;if(t.colorSpace&&t.colorSpace!=="rgb"){const u=Vf[t.colorSpace];c=(h,d)=>u.reverse(u.interpolate(u.forward(h),u.forward(d),n))}return typeof a.evaluate=="function"?{evaluate(...u){const h=a.evaluate.apply(void 0,u),d=l.evaluate.apply(void 0,u);if(h!==void 0&&d!==void 0)return c(h,d,n)}}:c(a,l,n)}function Xv(t,e,r){return e.type==="color"?r=Qe.parse(r):e.type==="formatted"?r=$r.fromString(r.toString()):e.type==="resolvedImage"?r=di.fromString(r.toString()):Tt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0),Kn(r,t.default,e.default)}class dh{constructor(e,r,i){this.expression=e,this._warningHistory={},this._evaluator=new _f(i),this._defaultValue=r?function(o){return o.type==="color"&&(pl(o.default)||Array.isArray(o.default))?new Qe(0,0,0,0):o.type==="color"?Qe.parse(o.default)||null:o.default===void 0?null:o.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,i,o,s,n,a,l){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=i,this._evaluator.canonical=o||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null,this.expression.evaluate(this._evaluator)}evaluate(e,r,i,o,s,n,a,l){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=i||null,this._evaluator.canonical=o||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null;try{const c=this.expression.evaluate(this._evaluator);if(c==null||typeof c=="number"&&c!=c)return this._defaultValue;if(this._enumValues&&!(c in this._enumValues))throw new Tr(`Expected value to be one of ${Object.keys(this._enumValues).map(u=>JSON.stringify(u)).join(", ")}, but found ${JSON.stringify(c)} instead.`);return c}catch(c){return this._warningHistory[c.message]||(this._warningHistory[c.message]=!0,typeof console<"u"&&console.warn(c.message)),this._defaultValue}}}function fl(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in Jn}function So(t,e,r){const i=new Pf(Jn,[],e?function(s){const n={color:hi,string:ft,number:ye,enum:ft,boolean:yt,formatted:Bn,resolvedImage:On};return s.type==="array"?qr(n[s.value]||_t,s.length):n[s.type]}(e):void 0,void 0,void 0,r),o=i.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?Qf(new dh(o,e,r)):ps(i.errors)}class ph{constructor(e,r,i){this.kind=e,this._styleExpression=r,this.isLightConstant=i,this.isStateDependent=e!=="constant"&&!Wn(r.expression),this.isConfigDependent=!Gu(r.expression)}evaluateWithoutErrorHandling(e,r,i,o,s,n){return this._styleExpression.evaluateWithoutErrorHandling(e,r,i,o,s,n)}evaluate(e,r,i,o,s,n){return this._styleExpression.evaluate(e,r,i,o,s,n)}}class Ao{constructor(e,r,i,o,s){this.kind=e,this.zoomStops=i,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!Wn(r.expression),this.isLightConstant=s,this.isConfigDependent=!Gu(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(e,r,i,o,s,n){return this._styleExpression.evaluateWithoutErrorHandling(e,r,i,o,s,n)}evaluate(e,r,i,o,s,n){return this._styleExpression.evaluate(e,r,i,o,s,n)}interpolationFactor(e,r,i){return this.interpolationType?ji.interpolationFactor(this.interpolationType,e,r,i):0}}function fh(t,e,r){if((t=So(t,e,r)).result==="error")return t;const i=t.value.expression,o=Hs(i);if(!o&&!fs(e))return ps([new Ui("","data expressions not supported")]);const s=Ws(i,["zoom","pitch","distance-from-center"]);if(!s&&!uh(e))return ps([new Ui("","zoom expressions not supported")]);const n=Ws(i,["measure-light"]);if(!n&&!tm(e))return ps([new Ui("","measure-light expression not supported")]);const a=e.expression&&e.expression.relaxZoomRestriction,l=_l(i);return l||s||a?l instanceof Ui?ps([l]):l instanceof ji&&!hh(e)?ps([new Ui("",'"interpolate" expressions cannot be used with this property')]):Qf(l?new Ao(o?"camera":"composite",t.value,l.labels,l instanceof ji?l.interpolation:void 0,n):new ph(o?"constant":"source",t.value,n)):ps([new Ui("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ml{constructor(e,r){this._parameters=e,this._specification=r,oo(this,rm(this._parameters,this._specification))}static deserialize(e){return new ml(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function _l(t){let e=null;if(t instanceof Gf)e=_l(t.result);else if(t instanceof jf){for(const r of t.args)if(e=_l(r),e)break}else(t instanceof Wu||t instanceof ji)&&t.input instanceof Vi&&t.input.name==="zoom"&&(e=t);return e instanceof Ui||t.eachChild(r=>{const i=_l(r);i instanceof Ui?e=i:e&&i&&e!==i&&(e=new Ui("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function pi(t){const e=t.key,r=t.value,i=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,n=t.styleSpec;let a=[];const l=Tt(r);if(l!=="object")return[new be(e,r,`object expected, ${l} found`)];for(const c in r){const u=c.split(".")[0];let h;o[u]?h=o[u]:i[u]?h=Sr:o["*"]?h=o["*"]:i["*"]&&(h=Sr),h?a=a.concat(h({key:(e&&`${e}.`)+c,value:r[c],valueSpec:i[u]||i["*"],style:s,styleSpec:n,object:r,objectKey:c},r)):a.push(new ls(e,r[c],`unknown property "${c}"`))}for(const c in i)o[c]||i[c].required&&i[c].default===void 0&&r[c]===void 0&&a.push(new be(e,r,`missing required property "${c}"`));return a}function om(t){const e=t.value,r=t.valueSpec,i=t.style,o=t.styleSpec,s=t.key,n=t.arrayElementValidator||Sr;if(Tt(e)!=="array")return[new be(s,e,`array expected, ${Tt(e)} found`)];if(r.length&&e.length!==r.length)return[new be(s,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new be(s,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let a={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};o.$version<7&&(a.function=r.function),Tt(r.value)==="object"&&(a=r.value);let l=[];for(let c=0;c<e.length;c++)l=l.concat(n({array:e,arrayIndex:c,value:e[c],valueSpec:a,style:i,styleSpec:o,key:`${s}[${c}]`},!0));return l}function sm(t){const e=t.key,r=t.value,i=t.valueSpec;let o=Tt(r);if(o==="number"&&r!=r&&(o="NaN"),o!=="number")return[new be(e,r,`number expected, ${o} found`)];if("minimum"in i){let s=i.minimum;if(Tt(i.minimum)==="array"&&(s=i.minimum[t.arrayIndex]),r<s)return[new be(e,r,`${r} is less than the minimum value ${s}`)]}if("maximum"in i){let s=i.maximum;if(Tt(i.maximum)==="array"&&(s=i.maximum[t.arrayIndex]),r>s)return[new be(e,r,`${r} is greater than the maximum value ${s}`)]}return[]}function nm(t){const e=t.valueSpec,r=cr(t.value.type);let i,o,s,n={};const a=r!=="categorical"&&t.value.property===void 0,l=!a,c=Tt(t.value.stops)==="array"&&Tt(t.value.stops[0])==="array"&&Tt(t.value.stops[0][0])==="object",u=pi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(p){if(r==="identity")return[new be(p.key,p.value,'identity function may not have a "stops" property')];let f=[];const m=p.value;return f=f.concat(om({key:p.key,value:m,valueSpec:p.valueSpec,style:p.style,styleSpec:p.styleSpec,arrayElementValidator:h})),Tt(m)==="array"&&m.length===0&&f.push(new be(p.key,m,"array must have at least one stop")),f},default:function(p){return Sr({key:p.key,value:p.value,valueSpec:e,style:p.style,styleSpec:p.styleSpec})}}});return r==="identity"&&a&&u.push(new be(t.key,t.value,'missing required property "property"')),r==="identity"||t.value.stops||u.push(new be(t.key,t.value,'missing required property "stops"')),r==="exponential"&&t.valueSpec.expression&&!hh(t.valueSpec)&&u.push(new be(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!fs(t.valueSpec)?u.push(new be(t.key,t.value,"property functions not supported")):a&&!uh(t.valueSpec)&&u.push(new be(t.key,t.value,"zoom functions not supported"))),r!=="categorical"&&!c||t.value.property!==void 0||u.push(new be(t.key,t.value,'"property" property is required')),u;function h(p){let f=[];const m=p.value,_=p.key;if(Tt(m)!=="array")return[new be(_,m,`array expected, ${Tt(m)} found`)];if(m.length!==2)return[new be(_,m,`array length 2 expected, length ${m.length} found`)];if(c){if(Tt(m[0])!=="object")return[new be(_,m,`object expected, ${Tt(m[0])} found`)];if(m[0].zoom===void 0)return[new be(_,m,"object stop key must have zoom")];if(m[0].value===void 0)return[new be(_,m,"object stop key must have value")];const g=cr(m[0].zoom);if(typeof g!="number")return[new be(_,m[0].zoom,"stop zoom values must be numbers")];if(s&&s>g)return[new be(_,m[0].zoom,"stop zoom values must appear in ascending order")];g!==s&&(s=g,o=void 0,n={}),f=f.concat(pi({key:`${_}[0]`,value:m[0],valueSpec:{zoom:{}},style:p.style,styleSpec:p.styleSpec,objectElementValidators:{zoom:sm,value:d}}))}else f=f.concat(d({key:`${_}[0]`,value:m[0],valueSpec:{},style:p.style,styleSpec:p.styleSpec},m));return fl(so(m[1]))?f.concat([new be(`${_}[1]`,m[1],"expressions are not allowed in function stops.")]):f.concat(Sr({key:`${_}[1]`,value:m[1],valueSpec:e,style:p.style,styleSpec:p.styleSpec}))}function d(p,f){const m=Tt(p.value),_=cr(p.value),g=p.value!==null?p.value:f;if(i){if(m!==i)return[new be(p.key,g,`${m} stop domain type must match previous stop domain type ${i}`)]}else i=m;if(m!=="number"&&m!=="string"&&m!=="boolean"&&typeof _!="number"&&typeof _!="string"&&typeof _!="boolean")return[new be(p.key,g,"stop domain value must be a number, string, or boolean")];if(m!=="number"&&r!=="categorical"){let y=`number expected, ${m} found`;return fs(e)&&r===void 0&&(y+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new be(p.key,g,y)]}return r!=="categorical"||m!=="number"||typeof _=="number"&&isFinite(_)&&Math.floor(_)===_?r!=="categorical"&&m==="number"&&typeof _=="number"&&typeof o=="number"&&o!==void 0&&_<o?[new be(p.key,g,"stop domain values must appear in ascending order")]:(o=_,r==="categorical"&&_ in n?[new be(p.key,g,"stop domain values must be unique")]:(n[_]=!0,[])):[new be(p.key,g,`integer expected, found ${String(_)}`)]}}function ms(t){const e=(t.expressionContext==="property"?fh:So)(so(t.value),t.valueSpec);if(e.result==="error")return e.value.map(i=>new be(`${t.key}${i.key}`,t.value,i.message));const r=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!r.outputDefined())return[new be(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Wn(r))return[new be(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return am(r,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!Ws(r,["zoom","feature-state"]))return[new be(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!Hs(r))return[new be(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function am(t,e){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const o of e.valueSpec.expression.parameters)r.delete(o);if(r.size===0)return[];const i=[];return t instanceof Vi&&r.has(t.name)?[new be(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild(o=>{i.push(...am(o,e))}),i)}function gl(t){const e=t.key,r=t.value,i=t.valueSpec,o=[];return Array.isArray(i.values)?i.values.indexOf(cr(r))===-1&&o.push(new be(e,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(i.values).indexOf(cr(r))===-1&&o.push(new be(e,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function mh(t){if(t===!0||t===!1)return!0;if(!Array.isArray(t)||t.length===0)return!1;switch(t[0]){case"has":return t.length>=2&&t[1]!=="$id"&&t[1]!=="$type";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!mh(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function yl(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};mh(t)||(t=xl(t));const r=t;let i=!0;try{i=function(c){if(!Js(c))return c;let u=so(c);return cm(u),u=lm(u),u}(r)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
1
+ import{q as ES,r as Jp,b as kn,i as MS,D as SS,o as Kp,c as ev,a as AS,t as IS,d as CS,y as zS,_ as DS,h as kS,e as PS,w as RS,j as LS,v as tv,p as BS}from"./_plugin-vue_export-helper.js";import{A as OS}from"./index.es.js";var rv={},FS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},iv={exports:{}};(function(Bi,Zt){(function(bi,Ur){Bi.exports=Ur()})(FS,function(){var bi,Ur,Qo;function to(we,$){if(!bi)bi=$;else if(!Ur)Ur=$;else{var Vr="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 = {}; ("+bi+")(sharedChunk); ("+Ur+")(sharedChunk); self.onerror = null;",Ti={};bi(Ti),Qo=$(Ti),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(Qo.workerUrl=window.URL.createObjectURL(new Blob([Vr],{type:"text/javascript"})))}}to(["exports"],function(we){var $=typeof self<"u"?self:{},Vr="3.1.2";let Ti;const Ke={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Ti==null){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Ti=rv.API_URL_REGEX!=null?new RegExp(rv.API_URL_REGEX):t}catch{Ti=t}}return Ti},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(!Ke.API_URL)return null;try{const t=new URL(Ke.API_URL);return t.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":t.hostname==="api.mapbox.com"?"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",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",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},Mr={supported:!1,testSupport:function(t){!Ei&&vr&&(ai?ja(t):kr=t)}};let kr,vr,Ei=!1,ai=!1;function ja(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,vr),t.isContextLost())return;Mr.supported=!0}catch{}t.deleteTexture(e),Ei=!0}$.document&&(vr=$.document.createElement("img"),vr.onload=function(){kr&&ja(kr),kr=null,ai=!0},vr.onerror=function(){Ei=!0,kr=null},vr.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Pn="01";function li(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ga=es;function es(t,e,r,i){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(i-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=i}es.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(e===void 0&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,i=0;i<8;i++){var o=this.sampleCurveX(r)-t;if(Math.abs(o)<e)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=o/s}var n=0,a=1;for(r=t,i=0;i<20&&(o=this.sampleCurveX(r),!(Math.abs(o-t)<e));i++)t>o?n=r:a=r,r=.5*(a-n)+n;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var qa=li(Ga),Ps=Oi;function Oi(t,e){this.x=t,this.y=e}Oi.prototype={clone:function(){return new Oi(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-i*(this.y-e.y),this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Oi.convert=function(t){return t instanceof Oi?t:Array.isArray(t)?new Oi(t[0],t[1]):t};var N=li(Ps);function dt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!dt(t[r],e[r]))return!1;return!0}if(typeof t=="object"&&t!==null&&e!==null){if(typeof e!="object"||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(!dt(t[r],e[r]))return!1;return!0}return t===e}const lu=Math.PI/180,ts=180/Math.PI;function $e(t){return t*lu}function br(t){return t*ts}const cu=[[0,0],[1,0],[1,1],[0,1]];function Rs(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function uu(t){let e=1/0,r=1/0,i=-1/0,o=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),i=Math.max(i,s.x),o=Math.max(o,s.y);return{min:new N(e,r),max:new N(i,o)}}function rs(t,e,r=0,i=!0){const o=new N(r,r),s=t.sub(o),n=e.add(o),a=[s,new N(n.x,s.y),n,new N(s.x,n.y)];return i&&a.push(s.clone()),a}function is(t,e,r,i){const o=new qa(t,e,r,i);return function(s){return o.solve(s)}}const ci=is(.25,.1,.25,1);function Se(t,e,r){return Math.min(r,Math.max(e,t))}function Fi(t,e,r){return(r=Se((r-t)/(e-t),0,1))*r*(3-2*r)}function Ni(t,e,r){const i=r-e,o=((t-e)%i+i)%i+e;return o===e?r:o}function os(t,e,r){if(!t.length)return r(null,[]);let i=t.length;const o=new Array(t.length);let s=null;t.forEach((n,a)=>{e(n,(l,c)=>{l&&(s=l),o[a]=c,--i==0&&r(s,o)})})}function ss(t){const e=[];for(const r in t)e.push(t[r]);return e}function Te(t,...e){for(const r of e)for(const i in r)t[i]=r[i];return t}function jr(t,e){const r={};for(let i=0;i<e.length;i++){const o=e[i];o in t&&(r[o]=t[o])}return r}let hu=1;function Ls(){return hu++}function Za(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function $a(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ha(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 pr(t,e){t.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function Bs(t,e){return t.indexOf(e,t.length-e.length)!==-1}function Os(t,e,r){const i={};for(const o in t)i[o]=e.call(this,t[o],o,t);return i}function le(t,e,r){const i={};for(const o in t)e.call(this,t[o],o,t)&&(i[o]=t[o]);return i}function z(t){return Array.isArray(t)?t.map(z):typeof t=="object"&&t?Os(t,z):t}const P={};function F(t){P[t]||(typeof console<"u"&&console.warn(t),P[t]=!0)}function te(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function ie(t){let e=0;for(let r,i,o=0,s=t.length,n=s-1;o<s;n=o++)r=t[o],i=t[n],e+=(i.x-r.x)*(r.y+i.y);return e}function ve([t,e,r]){const i=$e(e+90),o=$e(r);return{x:t*Math.cos(i)*Math.sin(o),y:t*Math.sin(i)*Math.sin(o),z:t*Math.cos(o),azimuthal:e,polar:r}}function Ce(t,e,r){const i=Math.sqrt(t*t+e*e+r*r),o=i>0?Math.acos(r/i)*ts:0;let s=t!==0||e!==0?Math.atan2(-e,-t)*ts+90:0;return s<0&&(s+=360),[i,s,o]}function oe(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function ze(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,i,o,s)=>{const n=o||s;return e[i]=!n||n.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}let Ge=null;function Ve(){return!!$.document.fullscreenElement||!!$.document.webkitFullscreenElement}function kt(t){try{const e=$[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function $t(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function wr(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3]}function Ht(t,e){return[Math.pow(t[0],2.2)*e,Math.pow(t[1],2.2)*e,Math.pow(t[2],2.2)*e]}function er(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]}const Lt="mapbox-tiles";let Ir=500,Rr=50,Lr,Mi;function Fs(){try{return $.caches}catch{}}function Gr(){Fs()&&!Lr&&(Lr=$.caches.open(Lt))}function ro(t){const e=t.indexOf("?");if(e<0)return t;const r=function(o){const s=o.indexOf("?");return s>0?o.slice(s+1).split("&"):[]}(t),i=r.filter(o=>{const s=o.split("=");return s[0]==="language"||s[0]==="worldview"});return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let To=1/0;function Ns(t){To++,To>Rr&&(t.getActor().send("enforceCacheSizeLimit",Ir),To=0)}const J={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};typeof Object.freeze=="function"&&Object.freeze(J);class Q extends Error{constructor(e,r,i){r===401&&Wt(i)&&(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=r,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ne=oe()?()=>self.worker&&self.worker.referrer:()=>($.location.protocol==="blob:"?$.parent:$).location.href,ce=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(ne())&&!/^\w+:/.test(r))){if($.fetch&&$.Request&&$.AbortController&&$.Request.prototype.hasOwnProperty("signal"))return function(i,o){const s=new $.AbortController,n=new $.Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:ne(),referrerPolicy:i.referrerPolicy,signal:s.signal});let a=!1,l=!1;const c=(u=n.url).indexOf("sku=")>0&&Wt(u);var u;i.type==="json"&&n.headers.set("Accept","application/json");const h=(p,f,m)=>{if(l)return;if(p&&p.message!=="SecurityError"&&F(p.toString()),f&&m)return d(f);const _=Date.now();$.fetch(n).then(g=>{if(g.ok){const y=c?g.clone():null;return d(g,y,_)}return o(new Q(g.statusText,g.status,i.url))}).catch(g=>{g.name!=="AbortError"&&o(new Error(`${g.message} ${i.url}`))})},d=(p,f,m)=>{(i.type==="arrayBuffer"?p.arrayBuffer():i.type==="json"?p.json():p.text()).then(_=>{l||(f&&m&&function(g,y,v){if(Gr(),!Lr)return;const b={status:y.status,statusText:y.statusText,headers:new $.Headers};y.headers.forEach((T,E)=>b.headers.set(E,T));const x=ze(y.headers.get("Cache-Control")||"");if(x["no-store"])return;x["max-age"]&&b.headers.set("Expires",new Date(v+1e3*x["max-age"]).toUTCString());const w=b.headers.get("Expires");w&&(new Date(w).getTime()-v<42e4||function(T,E){if(Mi===void 0)try{new Response(new ReadableStream),Mi=!0}catch{Mi=!1}Mi?E(T.body):T.blob().then(E)}(y,T=>{const E=new $.Response(T,b);Gr(),Lr&&Lr.then(M=>M.put(ro(g.url),E)).catch(M=>F(M.message))}))}(n,f,m),a=!0,o(null,_,p.headers.get("Cache-Control"),p.headers.get("Expires")))}).catch(_=>{l||o(new Error(_.message))})};return c?function(p,f){if(Gr(),!Lr)return f(null);const m=ro(p.url);Lr.then(_=>{_.match(m).then(g=>{const y=function(v){if(!v)return!1;const b=new Date(v.headers.get("Expires")||0),x=ze(v.headers.get("Cache-Control")||"");return b>Date.now()&&!x["no-cache"]}(g);_.delete(m),y&&_.put(m,g.clone()),f(null,g,y)}).catch(f)}).catch(f)}(n,h):h(null,null),{cancel:()=>{l=!0,a||s.abort()}}}(t,e);if(oe()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(i,o){const s=new $.XMLHttpRequest;s.open(i.method||"GET",i.url,!0),i.type==="arrayBuffer"&&(s.responseType="arraybuffer");for(const n in i.headers)s.setRequestHeader(n,i.headers[n]);return i.type==="json"&&(s.responseType="text",s.setRequestHeader("Accept","application/json")),s.withCredentials=i.credentials==="include",s.onerror=()=>{o(new Error(s.statusText))},s.onload=()=>{if((s.status>=200&&s.status<300||s.status===0)&&s.response!==null){let n=s.response;if(i.type==="json")try{n=JSON.parse(s.response)}catch(a){return o(a)}o(null,n,s.getResponseHeader("Cache-Control"),s.getResponseHeader("Expires"))}else o(new Q(s.statusText,s.status,i.url))},s.send(i.body),{cancel:()=>s.abort()}}(t,e)},ue=function(t,e){return ce(Te(t,{type:"json"}),e)},fe=function(t,e){return ce(Te(t,{type:"arrayBuffer"}),e)};function _e(t){const e=$.document.createElement("a");return e.href=t,e.protocol===$.document.location.protocol&&e.host===$.document.location.host}const he="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Me,me;Me=[],me=0;const Ye=function(t,e){if(Mr.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),me>=Ke.MAX_PARALLEL_IMAGE_REQUESTS){const s={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return Me.push(s),s}me++;let r=!1;const i=()=>{if(!r)for(r=!0,me--;Me.length&&me<Ke.MAX_PARALLEL_IMAGE_REQUESTS;){const s=Me.shift(),{requestParameters:n,callback:a,cancelled:l}=s;l||(s.cancel=Ye(n,a).cancel)}},o=fe(t,(s,n,a,l)=>{i(),s?e(s):n&&($.createImageBitmap?function(c,u){const h=new $.Blob([new Uint8Array(c)],{type:"image/png"});$.createImageBitmap(h).then(d=>{u(null,d)}).catch(d=>{u(new Error(`Could not load image because of ${d.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(n,(c,u)=>e(c,u,a,l)):function(c,u){const h=new $.Image,d=$.URL;h.onload=()=>{u(null,h),d.revokeObjectURL(h.src),h.onload=null,$.requestAnimationFrame(()=>{h.src=he})},h.onerror=()=>u(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 p=new $.Blob([new Uint8Array(c)],{type:"image/png"});h.src=c.byteLength?d.createObjectURL(p):he}(n,(c,u)=>e(c,u,a,l)))});return{cancel:()=>{o.cancel(),i()}}},At="NO_ACCESS_TOKEN";class Pe{constructor(e,r,i){this._transformRequestFn=e,this._customAccessToken=r,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let r="";for(let i=0;i<10;i++)r+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Pn,r].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,r){return this._transformRequestFn&&this._transformRequestFn(e,r)||{url:e}}normalizeStyleURL(e,r){if(!wt(e))return e;const i=fr(e);return i.params.push(`sdk=js-${Vr}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeGlyphsURL(e,r){if(!wt(e))return e;const i=fr(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeModelURL(e,r){if(!wt(e))return e;const i=fr(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeSourceURL(e,r,i,o){if(!wt(e))return e;const s=fr(e);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),i&&s.params.push(`language=${i}`),o&&s.params.push(`worldview=${o}`),this._makeAPIURL(s,this._customAccessToken||r)}normalizeSpriteURL(e,r,i,o){const s=fr(e);return wt(e)?(s.path=`/styles/v1${s.path}/sprite${r}${i}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${i}`,Br(s))}normalizeTileURL(e,r,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!wt(e))return e;const o=fr(e);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||i&&o.authority!=="raster"&&i===512?"@2x":""}${Mr.supported?".webp":"$1"}`),o.authority==="raster"?o.path=`/${Ke.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${Ke.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(n){for(const a of n){const l=a.match(/^access_token=(.*)$/);if(l)return l[1]}return null}(o.params)||Ke.ACCESS_TOKEN;return Ke.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(e,r){const i=fr(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let o="mapbox://";i.path.match(/^\/raster\/v1\//)?o+=`raster/${i.path.replace(`/${Ke.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${i.path.replace(`/${Ke.TILE_URL_VERSION}/`,"")}`;let s=i.params;return r&&(s=s.filter(n=>!n.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(e,r){const i=!!r&&wt(r),o=[];for(const s of e.tiles||[])Wt(s)?o.push(this.canonicalizeTileURL(s,i)):o.push(s);return o}_makeAPIURL(e,r){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",o=fr(Ke.API_URL);if(e.protocol=o.protocol,e.authority=o.authority,e.protocol==="http"){const s=e.params.indexOf("secure");s>=0&&e.params.splice(s,1)}if(o.path!=="/"&&(e.path=`${o.path}${e.path}`),!Ke.REQUIRE_ACCESS_TOKEN)return Br(e);if(r=r||Ke.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if(r[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(s=>s.indexOf("access_token")===-1),e.params.push(`access_token=${r||""}`),Br(e)}}function wt(t){return t.indexOf("mapbox:")===0}function Wt(t){return Ke.API_URL_REGEX.test(t)}function tr(t){return Ke.API_CDN_URL_REGEX.test(t)}function lr(t){return Ke.API_STYLE_REGEX.test(t)&&!Cr(t)}function Cr(t){return Ke.API_SPRITE_REGEX.test(t)}const ui=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function fr(t){const e=t.match(ui);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 Br(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const zr="mapbox.eventData";function Us(t){if(!t)return null;const e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent($.atob(e[1]).split("").map(r=>"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Eo{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const r=Us(Ke.ACCESS_TOKEN);let i="";return i=r&&r.u?$.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(o,s)=>String.fromCharCode(+("0x"+s)))):Ke.ACCESS_TOKEN||"",e?`${zr}.${e}:${i}`:`${zr}:${i}`}fetchEventData(){const e=kt("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const o=$.localStorage.getItem(r);o&&(this.eventData=JSON.parse(o));const s=$.localStorage.getItem(i);s&&(this.anonId=s)}catch{F("Unable to read from LocalStorage")}}saveEventData(){const e=kt("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{$.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&$.localStorage.setItem(r,JSON.stringify(this.eventData))}catch{F("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,r,i,o){if(!Ke.EVENTS_URL)return;const s=fr(Ke.EVENTS_URL);s.params.push(`access_token=${o||Ke.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(e).toISOString()},a=r?Te(n,r):n,l={url:Br(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(c,u){return ce(Te(c,{method:"POST"}),u)}(l,c=>{this.pendingRequest=null,i(c),this.saveEventData(),this.processRequests(o)})}queueRequest(e,r){this.queue.push(e),this.processRequests(r)}}const Vs=new class extends Eo{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){Ke.EVENTS_URL&&Ke.ACCESS_TOKEN&&Array.isArray(t)&&t.some(r=>wt(r)||Wt(r))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=Us(Ke.ACCESS_TOKEN),r=e?e.u:Ke.ACCESS_TOKEN;let i=r!==this.eventData.tokenU;Ha(this.anonId)||(this.anonId=Za(),i=!0);const o=this.queue.shift();if(this.eventData.lastSuccess){const s=new Date(this.eventData.lastSuccess),n=new Date(o),a=(o-this.eventData.lastSuccess)/864e5;i=i||a>=1||a<-1||s.getDate()!==n.getDate()}else i=!0;i?this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Vr,skuId:Pn,"enabled.telemetry":!1,userId:this.anonId},s=>{s||(this.eventData.lastSuccess=o,this.eventData.tokenU=r)},t):this.processRequests()}},du=Vs.postTurnstileEvent.bind(Vs),Qp=new class extends Eo{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,r,i){this.skuToken=e,this.errorCb=i,Ke.EVENTS_URL&&(r||Ke.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(At)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Ha(this.anonId)||(this.anonId=Za()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Vr,skuId:Pn,skuToken:this.skuToken,userId:this.anonId},i=>{i?this.errorCb(i):e&&(this.success[e]=!0)},t))}},sv=Qp.postMapLoadEvent.bind(Qp),ef=new class extends Eo{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){Ke.EVENTS_URL&&(t||Ke.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:r}=this.queue.shift(),i=function(o){const s=$.performance.getEntriesByType("resource"),n=$.performance.getEntriesByType("mark"),a=function(d){const p={};if(d){for(const f in d)if(f!=="other")for(const m of d[f]){const _=`${f}ResolveRangeMin`,g=`${f}ResolveRangeMax`,y=`${f}RequestCount`,v=`${f}RequestCachedCount`;p[_]=Math.min(p[_]||1/0,m.startTime),p[g]=Math.max(p[g]||-1/0,m.responseEnd);const b=x=>{p[x]===void 0&&(p[x]=0),++p[x]};m.transferSize!==void 0&&m.transferSize===0&&b(v),b(y)}}return p}(function(d,p){const f={};if(d)for(const m of d){const _=p(m);f[_]===void 0&&(f[_]=[]),f[_].push(m)}return f}(s,lv)),l=$.devicePixelRatio,c=$.navigator.connection||$.navigator.mozConnection||$.navigator.webkitConnection,u={counters:[],metadata:[],attributes:[]},h=(d,p,f)=>{f!=null&&d.push({name:p,value:f.toString()})};for(const d in a)h(u.counters,d,a[d]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(h(u.counters,"interactionRangeMin",o.interactionRange[0]),h(u.counters,"interactionRangeMax",o.interactionRange[1])),n)for(const d of Object.keys(Xa)){const p=Xa[d],f=n.find(m=>m.name===p);f&&h(u.counters,p,f.startTime)}return h(u.counters,"visibilityHidden",o.visibilityHidden),h(u.attributes,"style",function(d){if(d)for(const p of d){const f=p.name.split("?")[0];if(lr(f)){const m=f.split("/").slice(-2);if(m.length===2)return`mapbox://styles/${m[0]}/${m[1]}`}}}(s)),h(u.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),h(u.attributes,"fogEnabled",o.fogEnabled?"true":"false"),h(u.attributes,"projection",o.projection),h(u.attributes,"zoom",o.zoom),h(u.metadata,"devicePixelRatio",l),h(u.metadata,"connectionEffectiveType",c?c.effectiveType:void 0),h(u.metadata,"navigatorUserAgent",$.navigator.userAgent),h(u.metadata,"screenWidth",$.screen.width),h(u.metadata,"screenHeight",$.screen.height),h(u.metadata,"windowWidth",$.innerWidth),h(u.metadata,"windowHeight",$.innerHeight),h(u.metadata,"mapWidth",o.width/l),h(u.metadata,"mapHeight",o.height/l),h(u.metadata,"webglRenderer",o.renderer),h(u.metadata,"webglVendor",o.vendor),h(u.metadata,"sdkVersion",Vr),h(u.metadata,"sdkIdentifier","mapbox-gl-js"),u}(r);for(const o of i.metadata);for(const o of i.counters);for(const o of i.attributes);this.postEvent(e,i,()=>{},t)}},nv=ef.postPerformanceEvent.bind(ef),tf=new class extends Eo{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,r,i){if(!Ke.API_URL||!Ke.SESSION_PATH)return;const o=fr(Ke.API_URL+Ke.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${i||Ke.ACCESS_TOKEN||""}`);const s={url:Br(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(n,a){return ce(Te(n,{method:"GET"}),a)}(s,n=>{this.pendingRequest=null,r(n),this.saveEventData(),this.processRequests(i)})}getSessionAPI(t,e,r,i){this.skuToken=e,this.errorCb=i,Ke.SESSION_PATH&&Ke.API_URL&&(r||Ke.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(At)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,i=>{i?this.errorCb(i):e&&(this.success[e]=!0)},t)}},av=tf.getSessionAPI.bind(tf),Wa=new Set;function rf(t,e){e?Wa.add(t):Wa.delete(t)}const Xa={create:"create",load:"load",fullLoad:"fullLoad"},of={mark(t){$.performance.mark(t)},measure(t,e,r){$.performance.measure(t,e,r)}};function lv(t){const e=t.name.split("?")[0];return tr(e)&&e.includes("mapbox-gl.js")?"javascript":tr(e)&&e.includes("mapbox-gl.css")?"css":function(r){return Ke.API_FONTS_REGEX.test(r)}(e)?"fontRange":Cr(e)?"sprite":lr(e)?"style":function(r){return Ke.API_TILEJSON_REGEX.test(r)}(e)?"tilejson":"other"}const cv=$.performance;function sf(t){const e=t?t.url.toString():void 0;return cv.getEntriesByName(e)}var nf=pu;function pu(t){return!function(e){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var i,o,s=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(s);try{o=new Worker(n),i=!0}catch{i=!1}return o&&o.terminate(),URL.revokeObjectURL(n),i}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var i=document.createElement("canvas");i.width=i.height=1;var o=i.getContext("2d");if(!o)return!1;var s=o.getImageData(0,0,1,1);return s&&s.width===i.width}()?(fu[r=e&&e.failIfMajorPerformanceCaveat]===void 0&&(fu[r]=function(i){var o,s=function(n){var a=document.createElement("canvas"),l=Object.create(pu.webGLContextAttributes);return l.failIfMajorPerformanceCaveat=n,a.getContext("webgl",l)||a.getContext("experimental-webgl",l)}(i);if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch{return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),s.getShaderParameter(o,s.COMPILE_STATUS)===!0)}(r)),fu[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var r}(t)}var fu={};let mu,Ya,_u,Ja,ns;function af(){return mu==null&&(mu=$.OffscreenCanvas&&new $.OffscreenCanvas(1,1).getContext("2d")&&typeof $.createImageBitmap=="function"),mu}pu.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const je={now:()=>Ja!==void 0?Ja:$.performance.now(),setNow(t){Ja=t},restoreNow(){Ja=void 0},frame(t){const e=$.requestAnimationFrame(t);return{cancel:()=>$.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:i}=t;ns||(ns=$.document.createElement("canvas"));const o=ns.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>ns.width||i>ns.height)&&(ns.width=r,ns.height=i),o.clearRect(-e,-e,r+2*e,i+2*e),o.drawImage(t,0,0,r,i),o.getImageData(-e,-e,r+2*e,i+2*e)},resolveURL:t=>(Ya||(Ya=$.document.createElement("a")),Ya.href=t,Ya.href),get devicePixelRatio(){return $.devicePixelRatio},get prefersReducedMotion(){return!!$.matchMedia&&(_u==null&&(_u=$.matchMedia("(prefers-reduced-motion: reduce)")),_u.matches)},hasCanvasFingerprintNoise(){if(!af())return!1;const t=new $.OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let o=0;o<t.width;++o)e.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,e.fillRect(o,0,1,1);const i=e.getImageData(0,0,t.width,t.height);r=0;for(let o=0;o<i.data.length;++o)if(o%4!=3&&r++!==i.data[o])return!0;return!1}};function Dt(t,e,r){const i=$.document.createElement(t);return e!==void 0&&(i.className=e),r&&r.appendChild(i),i}function io(t,e,r){const i=$.document.createElementNS("http://www.w3.org/2000/svg",t);for(const o of Object.keys(e))i.setAttributeNS(null,o,e[o]);return r&&r.appendChild(i),i}const as=$.document&&$.document.documentElement.style,Rn=as&&as.userSelect!==void 0?"userSelect":"WebkitUserSelect";let lf;function cf(){as&&Rn&&(lf=as[Rn],as[Rn]="none")}function uf(){as&&Rn&&(as[Rn]=lf)}function gu(t){t.preventDefault(),t.stopPropagation(),$.removeEventListener("click",gu,!0)}function yu(){$.addEventListener("click",gu,!0),$.setTimeout(()=>{$.removeEventListener("click",gu,!0)},0)}function Ln(t,e){const r=t.getBoundingClientRect();return df(t,r,e)}function Ka(t,e){const r=t.getBoundingClientRect(),i=[];for(let o=0;o<e.length;o++)i.push(df(t,r,e[o]));return i}function hf(t){return $.InstallTrigger!==void 0&&t.button===2&&t.ctrlKey&&$.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function df(t,e,r){const i=t.offsetWidth===e.width?1:t.offsetWidth/e.width;return new N((r.clientX-e.left)*i,(r.clientY-e.top)*i)}function pf(t,e,r){r[t]&&r[t].indexOf(e)!==-1||(r[t]=r[t]||[],r[t].push(e))}function xu(t,e,r){if(r&&r[t]){const i=r[t].indexOf(e);i!==-1&&r[t].splice(i,1)}}class ae{constructor(e,r={}){Te(this,r),this.type=e}}class Ue extends ae{constructor(e,r={}){super("error",Te({error:e},r))}}class or{on(e,r){return this._listeners=this._listeners||{},pf(e,r,this._listeners),this}off(e,r){return xu(e,r,this._listeners),xu(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},pf(e,r,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,r){typeof e=="string"&&(e=new ae(e,r||{}));const i=e.type;if(this.listens(i)){e.target=this;const o=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const a of o)a.call(this,e);const s=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const a of s)xu(i,a,this._oneTimeListeners),a.call(this,e);const n=this._eventedParent;n&&(Te(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Ue&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var j=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":"*"},"*":{"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":{},"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_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_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,"minimum":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","default":[0,1],"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_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"}}}');class be{constructor(e,r,i,o){this.message=(e?`${e}: `:"")+i,o&&(this.identifier=o),r!=null&&r.__line__&&(this.line=r.__line__)}}class ls extends be{}function oo(t,...e){for(const r of e)for(const i in r)t[i]=r[i];return t}function cr(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function so(t){if(Array.isArray(t))return t.map(so);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=so(t[r]);return e}return cr(t)}class uv extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}var Ui=uv;class vu{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[i,o]of r)this.bindings[i]=o}concat(e){return new vu(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 hv=vu;const js={kind:"null"},ye={kind:"number"},ft={kind:"string"},yt={kind:"boolean"},hi={kind:"color"},Gs={kind:"object"},_t={kind:"value"},Qa={kind:"collator"},Bn={kind:"formatted"},On={kind:"resolvedImage"};function qr(t,e){return{kind:"array",itemType:t,N:e}}function sr(t){if(t.kind==="array"){const e=sr(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}const dv=[js,ye,ft,yt,hi,Bn,Gs,qr(_t),On];function Fn(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Fn(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(const r of dv)if(!Fn(r,e))return null}}return`Expected ${sr(t)} but found ${sr(e)} instead.`}function bu(t,e){return e.some(r=>r.kind===t.kind)}function Nn(t,e){return e.some(r=>r==="null"?t===null:r==="array"?Array.isArray(t):r==="object"?t&&!Array.isArray(t)&&typeof t=="object":r===typeof t)}var wu,ff={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 el(t){return(t=Math.round(t))<0?0:t>255?255:t}function Tu(t){return el(t[t.length-1]==="%"?parseFloat(t)/100*255:parseInt(t))}function tl(t){return(e=t[t.length-1]==="%"?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Eu(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{wu={}.parseCSSColor=function(t){var e,r=t.replace(/ /g,"").toLowerCase();if(r in ff)return ff[r].slice();if(r[0]==="#")return r.length===4?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:r.length===7&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var i=r.indexOf("("),o=r.indexOf(")");if(i!==-1&&o+1===r.length){var s=r.substr(0,i),n=r.substr(i+1,o-(i+1)).split(","),a=1;switch(s){case"rgba":if(n.length!==4)return null;a=tl(n.pop());case"rgb":return n.length!==3?null:[Tu(n[0]),Tu(n[1]),Tu(n[2]),a];case"hsla":if(n.length!==4)return null;a=tl(n.pop());case"hsl":if(n.length!==3)return null;var l=(parseFloat(n[0])%360+360)%360/360,c=tl(n[1]),u=tl(n[2]),h=u<=.5?u*(c+1):u+c-u*c,d=2*u-h;return[el(255*Eu(d,h,l+1/3)),el(255*Eu(d,h,l)),el(255*Eu(d,h,l-1/3)),a];default:return null}}return null}}catch{}class Zr{constructor(e,r,i,o=1){this.r=e,this.g=r,this.b=i,this.a=o}static parse(e){if(!e)return;if(e instanceof Zr)return e;if(typeof e!="string")return;const r=wu(e);return r?new Zr(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[e,r,i,o]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(i)},${o})`}toArray(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[255*e/o,255*r/o,255*i/o,o]}toArray01(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[e/o,r/o,i/o,o]}toArray01Scaled(e){const{r,g:i,b:o,a:s}=this;return s===0?[0,0,0]:[r/s*e,i/s*e,o/s*e]}toArray01PremultipliedAlpha(){const{r:e,g:r,b:i,a:o}=this;return[e,r,i,o]}toArray01Linear(){const{r:e,g:r,b:i,a:o}=this;return o===0?[0,0,0,0]:[Math.pow(e/o,2.2),Math.pow(r/o,2.2),Math.pow(i/o,2.2),o]}}Zr.black=new Zr(0,0,0,1),Zr.white=new Zr(1,1,1,1),Zr.transparent=new Zr(0,0,0,0),Zr.red=new Zr(1,0,0,1),Zr.blue=new Zr(0,0,1,1);var Qe=Zr;class Mu{constructor(e,r,i){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Su{constructor(e,r,i,o,s){this.text=e.normalize?e.normalize():e,this.image=r,this.scale=i,this.fontStack=o,this.textColor=s}}class $r{constructor(e){this.sections=e}static fromString(e){return new $r([new Su(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.namePrimary.length!==0)}static factory(e){return e instanceof $r?e:$r.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const r of this.sections){if(r.image){e.push(["image",r.image.namePrimary]);continue}e.push(r.text);const i={};r.fontStack&&(i["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(i["font-scale"]=r.scale),r.textColor&&(i["text-color"]=["rgba"].concat(r.textColor.toArray())),e.push(i)}return e}}class di{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,r){return e?new di({namePrimary:e,nameSecondary:r,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mf(t,e,r,i){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?i===void 0||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[t,e,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[t,e,r,i]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function qs(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof Qe||t instanceof Mu||t instanceof $r||t instanceof di)return!0;if(Array.isArray(t)){for(const e of t)if(!qs(e))return!1;return!0}if(typeof t=="object"){for(const e in t)if(!qs(t[e]))return!1;return!0}return!1}function mr(t){if(t===null)return js;if(typeof t=="string")return ft;if(typeof t=="boolean")return yt;if(typeof t=="number")return ye;if(t instanceof Qe)return hi;if(t instanceof Mu)return Qa;if(t instanceof $r)return Bn;if(t instanceof di)return On;if(Array.isArray(t)){const e=t.length;let r;for(const i of t){const o=mr(i);if(r){if(r===o)continue;r=_t;break}r=o}return qr(r||_t,e)}return Gs}function Un(t){const e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof Qe||t instanceof $r||t instanceof di?t.toString():JSON.stringify(t)}class Au{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!qs(e[1]))return r.error("invalid value");const i=e[1];let o=mr(i);const s=r.expectedType;return o.kind!=="array"||o.N!==0||!s||s.kind!=="array"||typeof s.N=="number"&&s.N!==0||(o=s),new Au(o,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Qe?["rgba"].concat(this.value.toArray()):this.value instanceof $r?this.value.serialize():this.value}}var Vn=Au,Tr=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Iu={string:ft,number:ye,boolean:yt,object:Gs};class Cu{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i,o=1;const s=e[0];if(s==="array"){let a,l;if(e.length>2){const c=e[1];if(typeof c!="string"||!(c in Iu)||c==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);a=Iu[c],o++}else a=_t;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=e[2],o++}i=qr(a,l)}else i=Iu[s];const n=[];for(;o<e.length;o++){const a=r.parse(e[o],o,_t);if(!a)return null;n.push(a)}return new Cu(i,n)}evaluate(e){for(let r=0;r<this.args.length;r++){const i=this.args[r].evaluate(e);if(!Fn(this.type,mr(i)))return i;if(r===this.args.length-1)throw new Tr(`Expected value to be of type ${sr(this.type)}, but found ${sr(mr(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,r=[e.kind];if(e.kind==="array"){const i=e.itemType;if(i.kind==="string"||i.kind==="number"||i.kind==="boolean"){r.push(i.kind);const o=e.N;(typeof o=="number"||this.args.length>1)&&r.push(o)}}return r.concat(this.args.map(i=>i.serialize()))}}var no=Cu;class jn{constructor(e){this.type=Bn,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&typeof i=="object")return r.error("First argument must be an image or text section.");const o=[];let s=!1;for(let n=1;n<=e.length-1;++n){const a=e[n];if(s&&typeof a=="object"&&!Array.isArray(a)){s=!1;let l=null;if(a["font-scale"]&&(l=r.parse(a["font-scale"],1,ye),!l))return null;let c=null;if(a["text-font"]&&(c=r.parse(a["text-font"],1,qr(ft)),!c))return null;let u=null;if(a["text-color"]&&(u=r.parse(a["text-color"],1,hi),!u))return null;const h=o[o.length-1];h.scale=l,h.font=c,h.textColor=u}else{const l=r.parse(e[n],1,_t);if(!l)return null;const c=l.type.kind;if(c!=="string"&&c!=="value"&&c!=="null"&&c!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,o.push({content:l,scale:null,font:null,textColor:null})}}return new jn(o)}evaluate(e){return new $r(this.sections.map(r=>{const i=r.content.evaluate(e);return mr(i)===On?new Su("",i,null,null,null):new Su(Un(i),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const r of this.sections){e.push(r.content.serialize());const i={};r.scale&&(i["font-scale"]=r.scale.serialize()),r.font&&(i["text-font"]=r.font.serialize()),r.textColor&&(i["text-color"]=r.textColor.serialize()),e.push(i)}return e}}class Gn{constructor(e,r){this.type=On,this.inputPrimary=e,this.inputSecondary=r}static parse(e,r){if(e.length<2)return r.error("Expected two or more arguments.");const i=r.parse(e[1],1,ft);if(!i)return r.error("No image name provided.");if(e.length===2)return new Gn(i);const o=r.parse(e[2],1,ft);return o?new Gn(i,o):r.error("Secondary image variant is not a string.")}evaluate(e){const r=di.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(r.namePrimary)>-1,r.nameSecondary&&r.available&&e.availableImages&&(r.available=e.availableImages.indexOf(r.nameSecondary)>-1)),r}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 Tt(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}const pv={"to-boolean":yt,"to-color":hi,"to-number":ye,"to-string":ft};class zu{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const i=e[0],o=[];let s=js;if(i==="to-array"){if(!Array.isArray(e[1]))return null;const n=e[1].length;if(r.expectedType){if(r.expectedType.kind!=="array")return r.error(`Expected ${r.expectedType.kind} but found array.`);s=qr(r.expectedType.itemType,n)}else{if(!(n>0&&qs(e[1][0])))return null;s=qr(mr(e[1][0]),n)}for(let a=0;a<n;a++){const l=e[1][a];let c;if(Tt(l)==="array")c=r.parse(l,void 0,s.itemType);else{const u=Tt(l);if(u!==s.itemType.kind)return r.error(`Expected ${s.itemType.kind} but found ${u}.`);c=r.registry.literal.parse(["literal",l===void 0?null:l],r)}if(!c)return null;o.push(c)}}else{if((i==="to-boolean"||i==="to-string")&&e.length!==2)return r.error("Expected one argument.");s=pv[i];for(let n=1;n<e.length;n++){const a=r.parse(e[n],n,_t);if(!a)return null;o.push(a)}}return new zu(s,o)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let r,i;for(const o of this.args){if(r=o.evaluate(e),i=null,r instanceof Qe)return r;if(typeof r=="string"){const s=e.parseColor(r);if(s)return s}else if(Array.isArray(r)&&(i=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:mf(r[0],r[1],r[2],r[3]),!i))return new Qe(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Tr(i||`Could not parse color from value '${typeof r=="string"?r:String(JSON.stringify(r))}'`)}if(this.type.kind==="number"){let r=null;for(const i of this.args){if(r=i.evaluate(e),r===null)return 0;const o=Number(r);if(!isNaN(o))return o}throw new Tr(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?$r.fromString(Un(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?di.fromString(Un(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(r=>r.evaluate(e)):Un(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new jn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Gn(this.args[0]).serialize();const e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(r=>{e.push(r.serialize())}),e}}var cs=zu;const fv=["Unknown","Point","LineString","Polygon"];var _f=class{constructor(t){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.options=t}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?fv[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:r,y:i}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(i*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Qe.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}};class us{constructor(e,r,i,o,s){this.name=e,this.type=r,this._evaluate=i,this.args=o,this._overloadIndex=s}evaluate(e){if(!this._evaluate){const r=us.definitions[this.name];this._evaluate=Array.isArray(r)?r[2]:r.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,r){const i=e[0],o=us.definitions[i];if(!o)return r.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(o)?o[0]:o.type,n=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,a=[];let l=null,c=-1;for(const[u,h]of n){if(Array.isArray(u)&&u.length!==e.length-1)continue;a.push(u),c++,l=new Pf(r.registry,r.path,null,r.scope,void 0,r.options);const d=[];let p=!1;for(let f=1;f<e.length;f++){const m=e[f],_=Array.isArray(u)?u[f-1]:u.type,g=l.parse(m,1+d.length,_);if(!g){p=!0;break}d.push(g)}if(!p)if(Array.isArray(u)&&u.length!==d.length)l.error(`Expected ${u.length} arguments, but found ${d.length} instead.`);else{for(let f=0;f<d.length;f++){const m=Array.isArray(u)?u[f]:u.type,_=d[f];l.concat(f+1).checkSubtype(m,_.type)}if(l.errors.length===0)return new us(i,s,h,d,c)}}if(a.length===1)r.errors.push(...l.errors);else{const u=(a.length?a:n.map(([d])=>d)).map(mv).join(" | "),h=[];for(let d=1;d<e.length;d++){const p=r.parse(e[d],1+h.length);if(!p)return null;h.push(sr(p.type))}r.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(e,r){us.definitions=r;for(const i in r)e[i]=us}}function mv(t){return Array.isArray(t)?`(${t.map(sr).join(", ")})`:`(${sr(t.type)}...)`}var Vi=us;class rl{constructor(e,r,i){this.type=Qa,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const i=e[1];if(typeof i!="object"||Array.isArray(i))return r.error("Collator options argument must be an object.");const o=r.parse(i["case-sensitive"]!==void 0&&i["case-sensitive"],1,yt);if(!o)return null;const s=r.parse(i["diacritic-sensitive"]!==void 0&&i["diacritic-sensitive"],1,yt);if(!s)return null;let n=null;return i.locale&&(n=r.parse(i.locale,1,ft),!n)?null:new rl(o,s,n)}evaluate(e){return new Mu(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 gf={exports:{}};gf.exports=function(){function t(i,o,s,n,a){for(;n>s;){if(n-s>600){var l=n-s+1,c=o-s+1,u=Math.log(l),h=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1);t(i,o,Math.max(s,Math.floor(o-c*h/l+d)),Math.min(n,Math.floor(o+(l-c)*h/l+d)),a)}var p=i[o],f=s,m=n;for(e(i,s,o),a(i[n],p)>0&&e(i,s,n);f<m;){for(e(i,f,m),f++,m--;a(i[f],p)<0;)f++;for(;a(i[m],p)>0;)m--}a(i[s],p)===0?e(i,s,m):e(i,++m,n),m<=o&&(s=m+1),o<=m&&(n=m-1)}}function e(i,o,s){var n=i[o];i[o]=i[s],i[s]=n}function r(i,o){return i<o?-1:i>o?1:0}return function(i,o,s,n,a){t(i,o,s||0,n||i.length-1,a||r)}}();var _v=li(gf.exports);function gv(t){let e=0;for(let r,i,o=0,s=t.length,n=s-1;o<s;n=o++)r=t[o],i=t[n],e+=(i.x-r.x)*(r.y+i.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 Zn(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function yv(t,e,r){const i=t[0]-e[0],o=t[1]-e[1],s=t[0]-r[0],n=t[1]-r[1];return i*n-s*o==0&&i*s<=0&&o*n<=0}function Zs(t,e,r=!1){let i=!1;for(let a=0,l=e.length;a<l;a++){const c=e[a];for(let u=0,h=c.length,d=h-1;u<h;d=u++){const p=c[d],f=c[u];if(yv(t,p,f))return r;(s=p)[1]>(o=t)[1]!=(n=f)[1]>o[1]&&o[0]<(n[0]-s[0])*(o[1]-s[1])/(n[1]-s[1])+s[0]&&(i=!i)}}var o,s,n;return i}function yf(t,e,r,i){const o=i[0]-r[0],s=i[1]-r[1],n=(t[0]-r[0])*s-o*(t[1]-r[1]),a=(e[0]-r[0])*s-o*(e[1]-r[1]);return n>0&&a<0||n<0&&a>0}function il(t,e,r,i){return(o=[i[0]-r[0],i[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-o[1]*s[0]!=0&&!(!yf(t,e,r,i)||!yf(r,i,t,e));var o,s}const Mo=8192;function xv(t,e){const r=(180+t[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(r*o*Mo),Math.round(i*o*Mo)]}function vv(t,e){for(let r=0;r<e.length;r++)if(Zs(t,e[r]))return!0;return!1}function bv(t,e,r){for(const i of r)for(let o=0,s=i.length,n=s-1;o<s;n=o++)if(il(t,e,i[n],i[o]))return!0;return!1}function xf(t,e){for(let r=0;r<t.length;++r)if(!Zs(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(bv(t[r],t[r+1],e))return!1;return!0}function wv(t,e){for(let r=0;r<e.length;r++)if(xf(t,e[r]))return!0;return!1}function Du(t,e,r){const i=[];for(let o=0;o<t.length;o++){const s=[];for(let n=0;n<t[o].length;n++){const a=xv(t[o][n],r);qn(e,a),s.push(a)}i.push(s)}return i}function vf(t,e,r){const i=[];for(let o=0;o<t.length;o++){const s=Du(t[o],e,r);i.push(s)}return i}function bf(t,e,r,i){if(t[0]<r[0]||t[0]>r[2]){const o=.5*i;let s=t[0]-r[0]>o?-i:r[0]-t[0]>o?i:0;s===0&&(s=t[0]-r[2]>o?-i:r[2]-t[0]>o?i:0),t[0]+=s}qn(e,t)}function wf(t,e,r,i){const o=Math.pow(2,i.z)*Mo,s=[i.x*Mo,i.y*Mo],n=[];if(!t)return n;for(const a of t)for(const l of a){const c=[l.x+s[0],l.y+s[1]];bf(c,e,r,o),n.push(c)}return n}function Tf(t,e,r,i){const o=Math.pow(2,i.z)*Mo,s=[i.x*Mo,i.y*Mo],n=[];if(!t)return n;for(const l of t){const c=[];for(const u of l){const h=[u.x+s[0],u.y+s[1]];qn(e,h),c.push(h)}n.push(c)}if(e[2]-e[0]<=o/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const l of n)for(const c of l)bf(c,e,r,o)}var a;return n}class $n{constructor(e,r){this.type=yt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(qs(e[1])){const i=e[1];if(i.type==="FeatureCollection")for(let o=0;o<i.features.length;++o){const s=i.features[o].geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new $n(i,i.features[o].geometry)}else if(i.type==="Feature"){const o=i.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new $n(i,i.geometry)}else if(i.type==="Polygon"||i.type==="MultiPolygon")return new $n(i,i)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,i){const o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],n=r.canonicalID();if(!n)return!1;if(i.type==="Polygon"){const a=Du(i.coordinates,s,n),l=wf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!Zs(c,a))return!1}if(i.type==="MultiPolygon"){const a=vf(i.coordinates,s,n),l=wf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!vv(c,a))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,i){const o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],n=r.canonicalID();if(!n)return!1;if(i.type==="Polygon"){const a=Du(i.coordinates,s,n),l=Tf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!xf(c,a))return!1}if(i.type==="MultiPolygon"){const a=vf(i.coordinates,s,n),l=Tf(r.geometry(),o,s,n);if(!Zn(o,s))return!1;for(const c of l)if(!wv(c,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var ku=$n,Ef={exports:{}};Ef.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,r=e*(2-e),i=Math.PI/180,o=function(c,u){if(c===void 0)throw new Error("No latitude given.");if(u&&!t[u])throw new Error("Unknown unit "+u+". Use one of: "+Object.keys(t).join(", "));var h=6378.137*i*(u?t[u]:1),d=Math.cos(c*i),p=1/(1-r*(1-d*d)),f=Math.sqrt(p);this.kx=h*f*d,this.ky=h*f*p*(1-r)},s={units:{configurable:!0}};function n(c,u){return c[0]===u[0]&&c[1]===u[1]}function a(c,u,h){var d=l(u[0]-c[0]);return[c[0]+d*h,c[1]+(u[1]-c[1])*h]}function l(c){for(;c<-180;)c+=360;for(;c>180;)c-=360;return c}return o.fromTile=function(c,u,h){var d=Math.PI*(1-2*(c+.5)/Math.pow(2,u)),p=Math.atan(.5*(Math.exp(d)-Math.exp(-d)))/i;return new o(p,h)},s.units.get=function(){return t},o.prototype.distance=function(c,u){var h=l(c[0]-u[0])*this.kx,d=(c[1]-u[1])*this.ky;return Math.sqrt(h*h+d*d)},o.prototype.bearing=function(c,u){var h=l(u[0]-c[0])*this.kx;return Math.atan2(h,(u[1]-c[1])*this.ky)/i},o.prototype.destination=function(c,u,h){var d=h*i;return this.offset(c,Math.sin(d)*u,Math.cos(d)*u)},o.prototype.offset=function(c,u,h){return[c[0]+u/this.kx,c[1]+h/this.ky]},o.prototype.lineDistance=function(c){for(var u=0,h=0;h<c.length-1;h++)u+=this.distance(c[h],c[h+1]);return u},o.prototype.area=function(c){for(var u=0,h=0;h<c.length;h++)for(var d=c[h],p=0,f=d.length,m=f-1;p<f;m=p++)u+=l(d[p][0]-d[m][0])*(d[p][1]+d[m][1])*(h?-1:1);return Math.abs(u)/2*this.kx*this.ky},o.prototype.along=function(c,u){var h=0;if(u<=0)return c[0];for(var d=0;d<c.length-1;d++){var p=c[d],f=c[d+1],m=this.distance(p,f);if((h+=m)>u)return a(p,f,(u-(h-m))/m)}return c[c.length-1]},o.prototype.pointToSegmentDistance=function(c,u,h){var d=u[0],p=u[1],f=l(h[0]-d)*this.kx,m=(h[1]-p)*this.ky,_=0;return f===0&&m===0||((_=(l(c[0]-d)*this.kx*f+(c[1]-p)*this.ky*m)/(f*f+m*m))>1?(d=h[0],p=h[1]):_>0&&(d+=f/this.kx*_,p+=m/this.ky*_)),f=l(c[0]-d)*this.kx,m=(c[1]-p)*this.ky,Math.sqrt(f*f+m*m)},o.prototype.pointOnLine=function(c,u){for(var h,d,p,f,m=1/0,_=0;_<c.length-1;_++){var g=c[_][0],y=c[_][1],v=l(c[_+1][0]-g)*this.kx,b=(c[_+1][1]-y)*this.ky,x=0;v===0&&b===0||((x=(l(u[0]-g)*this.kx*v+(u[1]-y)*this.ky*b)/(v*v+b*b))>1?(g=c[_+1][0],y=c[_+1][1]):x>0&&(g+=v/this.kx*x,y+=b/this.ky*x));var w=(v=l(u[0]-g)*this.kx)*v+(b=(u[1]-y)*this.ky)*b;w<m&&(m=w,h=g,d=y,p=_,f=x)}return{point:[h,d],index:p,t:Math.max(0,Math.min(1,f))}},o.prototype.lineSlice=function(c,u,h){var d=this.pointOnLine(h,c),p=this.pointOnLine(h,u);if(d.index>p.index||d.index===p.index&&d.t>p.t){var f=d;d=p,p=f}var m=[d.point],_=d.index+1,g=p.index;!n(h[_],m[0])&&_<=g&&m.push(h[_]);for(var y=_+1;y<=g;y++)m.push(h[y]);return n(h[g],p.point)||m.push(p.point),m},o.prototype.lineSliceAlong=function(c,u,h){for(var d=0,p=[],f=0;f<h.length-1;f++){var m=h[f],_=h[f+1],g=this.distance(m,_);if((d+=g)>c&&p.length===0&&p.push(a(m,_,(c-(d-g))/g)),d>=u)return p.push(a(m,_,(u-(d-g))/g)),p;d>c&&p.push(_)}return p},o.prototype.bufferPoint=function(c,u){var h=u/this.ky,d=u/this.kx;return[c[0]-d,c[1]-h,c[0]+d,c[1]+h]},o.prototype.bufferBBox=function(c,u){var h=u/this.ky,d=u/this.kx;return[c[0]-d,c[1]-h,c[2]+d,c[3]+h]},o.prototype.insideBBox=function(c,u){return l(c[0]-u[0])>=0&&l(c[0]-u[2])<=0&&c[1]>=u[1]&&c[1]<=u[3]},Object.defineProperties(o,s),o}();var Pu=li(Ef.exports),Mf={exports:{}};Mf.exports=function(){var t=function(r,i){if(r===void 0&&(r=[]),i===void 0&&(i=e),this.data=r,this.length=this.data.length,this.compare=i,this.length>0)for(var o=(this.length>>1)-1;o>=0;o--)this._down(o)};function e(r,i){return r<i?-1:r>i?1:0}return t.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},t.prototype.pop=function(){if(this.length!==0){var r=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),r}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(r){for(var i=this.data,o=this.compare,s=i[r];r>0;){var n=r-1>>1,a=i[n];if(o(s,a)>=0)break;i[r]=a,r=n}i[r]=s},t.prototype._down=function(r){for(var i=this.data,o=this.compare,s=this.length>>1,n=i[r];r<s;){var a=1+(r<<1),l=i[a],c=a+1;if(c<this.length&&o(i[c],l)<0&&(a=c,l=i[c]),o(l,n)>=0)break;i[r]=l,r=a}i[r]=n},t}();var Ru=li(Mf.exports),W=8192;function Sf(t,e){return e.dist-t.dist}const Lu=100,Bu=50;function Af(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function ol(t){return t[1]-t[0]+1}function ao(t,e){const r=t[1]>=t[0]&&t[1]<e;return r||console.warn("Distance Expression: Index is out of range"),r}function Ou(t,e){if(t[0]>t[1])return[null,null];const r=ol(t);if(e){if(r===2)return[t,null];const i=Math.floor(r/2);return[[t[0],t[0]+i],[t[0]+i,t[1]]]}{if(r===1)return[t,null];const i=Math.floor(r/2)-1;return[[t[0],t[0]+i],[t[0]+i+1,t[1]]]}}function hs(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!ao(e,t.length))return r;for(let i=e[0];i<=e[1];++i)qn(r,t[i]);return r}function sl(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let i=0;i<t[r].length;++i)qn(e,t[r][i]);return e}function $s(t,e,r){if(Af(t)||Af(e))return NaN;let i=0,o=0;return t[2]<e[0]&&(i=e[0]-t[2]),t[0]>e[2]&&(i=t[0]-e[2]),t[1]>e[3]&&(o=t[1]-e[3]),t[3]<e[1]&&(o=e[1]-t[3]),r.distance([0,0],[i,o])}function Fu(t,e){const r=Math.pow(2,e.z);return[(o=(t.x/W+e.x)/r,360*o-180),(i=(t.y/W+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90)];var i,o}function Tv(t,e){const r=[];for(let i=0;i<t.length;++i)r.push(Fu(t[i],e));return r}function If(t,e,r){const i=r.pointOnLine(e,t).point;return r.distance(t,i)}function Cf(t,e,r,i,o){const s=r.slice(i[0],i[1]+1);let n=1/0;for(let a=e[0];a<=e[1];++a)if((n=Math.min(n,If(t[a],s,o)))===0)return 0;return n}function Nu(t,e,r,i,o){const s=Math.min(o.pointToSegmentDistance(t,r,i),o.pointToSegmentDistance(e,r,i)),n=Math.min(o.pointToSegmentDistance(r,t,e),o.pointToSegmentDistance(i,t,e));return Math.min(s,n)}function Ev(t,e,r,i,o){if(!ao(e,t.length)||!ao(i,r.length))return NaN;let s=1/0;for(let n=e[0];n<e[1];++n)for(let a=i[0];a<i[1];++a){if(il(t[n],t[n+1],r[a],r[a+1]))return 0;s=Math.min(s,Nu(t[n],t[n+1],r[a],r[a+1],o))}return s}function Mv(t,e,r,i,o){if(!ao(e,t.length)||!ao(i,r.length))return NaN;let s=1/0;for(let n=e[0];n<=e[1];++n)for(let a=i[0];a<=i[1];++a)if((s=Math.min(s,o.distance(t[n],r[a])))===0)return s;return s}function Sv(t,e,r){if(Zs(t,e,!0))return 0;let i=1/0;for(const o of e){const s=o.length;if(s<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(o[0]!==o[s-1]&&(i=Math.min(i,r.pointToSegmentDistance(t,o[s-1],o[0])))===0||(i=Math.min(i,If(t,o,r)))===0)return i}return i}function Av(t,e,r,i){if(!ao(e,t.length))return NaN;for(let s=e[0];s<=e[1];++s)if(Zs(t[s],r,!0))return 0;let o=1/0;for(let s=e[0];s<e[1];++s)for(const n of r)for(let a=0,l=n.length,c=l-1;a<l;c=a++){if(il(t[s],t[s+1],n[c],n[a]))return 0;o=Math.min(o,Nu(t[s],t[s+1],n[c],n[a],i))}return o}function zf(t,e){for(const r of t)for(let i=0;i<=r.length-1;++i)if(Zs(r[i],e,!0))return!0;return!1}function Iv(t,e,r,i=1/0){const o=sl(t),s=sl(e);if(i!==1/0&&$s(o,s,r)>=i)return i;if(Zn(o,s)){if(zf(t,e))return 0}else if(zf(e,t))return 0;let n=i;for(const a of t)for(let l=0,c=a.length,u=c-1;l<c;u=l++)for(const h of e)for(let d=0,p=h.length,f=p-1;d<p;f=d++){if(il(a[u],a[l],h[f],h[d]))return 0;n=Math.min(n,Nu(a[u],a[l],h[f],h[d],r))}return n}function nl(t,e,r,i,o,s,n){if(s===null||n===null)return;const a=$s(hs(i,s),hs(o,n),r);a<e&&t.push({dist:a,range1:s,range2:n})}function Cv(t,e,r,i,o=1/0){let s=Math.min(i.distance(t[0],r[0][0]),o);if(s===0)return s;const n=new Ru([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Sf),a=e?Bu:Lu,l=sl(r);for(;n.length;){const c=n.pop();if(c.dist>=s)continue;const u=c.range1;if(ol(u)<=a){if(!ao(u,t.length))return NaN;if(e){const h=Av(t,u,r,i);if((s=Math.min(s,h))===0)return s}else for(let h=u[0];h<=u[1];++h){const d=Sv(t[h],r,i);if((s=Math.min(s,d))===0)return s}}else{const h=Ou(u,e);if(h[0]!==null){const d=$s(hs(t,h[0]),l,i);d<s&&n.push({dist:d,range1:h[0],range2:[0,0]})}if(h[1]!==null){const d=$s(hs(t,h[1]),l,i);d<s&&n.push({dist:d,range1:h[1],range2:[0,0]})}}}return s}function Df(t,e,r,i,o,s=1/0){let n=Math.min(s,o.distance(t[0],r[0]));if(n===0)return n;const a=new Ru([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],Sf),l=e?Bu:Lu,c=i?Bu:Lu;for(;a.length;){const u=a.pop();if(u.dist>=n)continue;const h=u.range1,d=u.range2;if(ol(h)<=l&&ol(d)<=c){if(!ao(h,t.length)||!ao(d,r.length))return NaN;if(e&&i?n=Math.min(n,Ev(t,h,r,d,o)):e||i?e&&!i?n=Math.min(n,Cf(r,d,t,h,o)):!e&&i&&(n=Math.min(n,Cf(t,h,r,d,o))):n=Math.min(n,Mv(t,h,r,d,o)),n===0)return n}else{const p=Ou(h,e),f=Ou(d,i);nl(a,n,o,t,r,p[0],f[0]),nl(a,n,o,t,r,p[0],f[1]),nl(a,n,o,t,r,p[1],f[0]),nl(a,n,o,t,r,p[1],f[1])}}return n}function Uu(t,e,r,i,o=1/0){let s=o;const n=hs(t,[0,t.length-1]);for(const a of r)if(!(s!==1/0&&$s(n,hs(a,[0,a.length-1]),i)>=s)&&(s=Math.min(s,Df(t,e,a,!0,i,s)),s===0))return s;return s}function al(t,e,r,i,o=1/0){let s=o;const n=hs(t,[0,t.length-1]);for(const a of r){if(s!==1/0&&$s(n,sl(a),i)>=s)continue;const l=Cv(t,e,a,i,s);if(isNaN(l))return l;if((s=Math.min(s,l))===0)return s}return s}function Vu(t){return t==="Point"||t==="MultiPoint"||t==="LineString"||t==="MultiLineString"||t==="Polygon"||t==="MultiPolygon"}class Hn{constructor(e,r){this.type=ye,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(qs(e[1])){const i=e[1];if(i.type==="FeatureCollection"){for(let o=0;o<i.features.length;++o)if(Vu(i.features[o].geometry.type))return new Hn(i,i.features[o].geometry)}else if(i.type==="Feature"){if(Vu(i.geometry.type))return new Hn(i,i.geometry)}else if(Vu(i.type))return new Hn(i,i)}return r.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const r=e.geometry(),i=e.canonicalID();if(r!=null&&i!=null){if(e.geometryType()==="Point")return function(o,s,n){const a=[];for(const c of o)for(const u of c)a.push(Fu(u,s));const l=new Pu(a[0][1],"meters");return n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString"?Df(a,!1,n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",l):n.type==="MultiLineString"?Uu(a,!1,n.coordinates,l):n.type==="Polygon"||n.type==="MultiPolygon"?al(a,!1,n.type==="Polygon"?[n.coordinates]:n.coordinates,l):null}(r,i,this.geometries);if(e.geometryType()==="LineString")return function(o,s,n){const a=[];for(const c of o){const u=[];for(const h of c)u.push(Fu(h,s));a.push(u)}const l=new Pu(a[0][0][1],"meters");if(n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString")return Uu(n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",a,l);if(n.type==="MultiLineString"){let c=1/0;for(let u=0;u<n.coordinates.length;u++){const h=Uu(n.coordinates[u],!0,a,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}if(n.type==="Polygon"||n.type==="MultiPolygon"){let c=1/0;for(let u=0;u<a.length;u++){const h=al(a[u],!0,n.type==="Polygon"?[n.coordinates]:n.coordinates,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}return null}(r,i,this.geometries);if(e.geometryType()==="Polygon")return function(o,s,n){const a=[];for(const c of function(u,h){const d=u.length;if(d<=1)return[u];const p=[];let f,m;for(let _=0;_<d;_++){const g=gv(u[_]);g!==0&&(u[_].area=Math.abs(g),m===void 0&&(m=g<0),m===g<0?(f&&p.push(f),f=[u[_]]):f.push(u[_]))}return f&&p.push(f),p}(o)){const u=[];for(let h=0;h<c.length;++h)u.push(Tv(c[h],s));a.push(u)}const l=new Pu(a[0][0][0][1],"meters");if(n.type==="Point"||n.type==="MultiPoint"||n.type==="LineString")return al(n.type==="Point"?[n.coordinates]:n.coordinates,n.type==="LineString",a,l);if(n.type==="MultiLineString"){let c=1/0;for(let u=0;u<n.coordinates.length;u++){const h=al(n.coordinates[u],!0,a,l,c);if(isNaN(h))return h;if((c=Math.min(c,h))===0)return c}return c}return n.type==="Polygon"||n.type==="MultiPolygon"?function(c,u,h){let d=1/0;for(const p of c)for(const f of u){const m=Iv(p,f,h,d);if(isNaN(m))return m;if((d=Math.min(d,m))===0)return d}return d}(n.type==="Polygon"?[n.coordinates]:n.coordinates,a,l):null}(r,i,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 ju=Hn;function Hs(t){if(t instanceof Vi&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof ku||t instanceof ju)return!1;let e=!0;return t.eachChild(r=>{e&&!Hs(r)&&(e=!1)}),e}function Wn(t){if(t instanceof Vi&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(r=>{e&&!Wn(r)&&(e=!1)}),e}function Gu(t){if(t instanceof Vi&&t.name==="config")return!1;let e=!0;return t.eachChild(r=>{e&&!Gu(r)&&(e=!1)}),e}function Ws(t,e){if(t instanceof Vi&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild(i=>{r&&!Ws(i,e)&&(r=!1)}),r}class qu{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const i=e[1];return r.scope.has(i)?new qu(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" 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 kf=qu;class Zu{constructor(e,r=[],i,o=new hv,s=[],n){this.registry=e,this.path=r,this.key=r.map(a=>`[${a}]`).join(""),this.scope=o,this.errors=s,this.expectedType=i,this.options=n}parse(e,r,i,o,s={}){return r||i?this.concat(r,i,o)._parse(e,s):this._parse(e,s)}_parse(e,r){function i(o,s,n){return n==="assert"?new no(s,[o]):n==="coerce"?new cs(s,[o]):o}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=typeof e[0]=="string"?this.registry[e[0]]:void 0;if(o){let s=o.parse(e,this);if(!s)return null;if(this.expectedType){const n=this.expectedType,a=s.type;if(n.kind!=="string"&&n.kind!=="number"&&n.kind!=="boolean"&&n.kind!=="object"&&n.kind!=="array"||a.kind!=="value")if(n.kind!=="color"&&n.kind!=="formatted"&&n.kind!=="resolvedImage"||a.kind!=="value"&&a.kind!=="string"){if(this.checkSubtype(n,a))return null}else s=i(s,n,r.typeAnnotation||"coerce");else s=i(s,n,r.typeAnnotation||"assert")}if(!(s instanceof Vn)&&s.type.kind!=="resolvedImage"&&$u(s)){const n=new _f(this.options);try{s=new Vn(s.type,s.evaluate(n))}catch(a){return this.error(a.message),null}}return s}return cs.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,i){const o=typeof e=="number"?this.path.concat(e):this.path,s=i?this.scope.concat(i):this.scope;return new Zu(this.registry,o,r||null,s,this.errors,this.options)}error(e,...r){const i=`${this.key}${r.map(o=>`[${o}]`).join("")}`;this.errors.push(new Ui(i,e))}checkSubtype(e,r){const i=Fn(e,r);return i&&this.error(i),i}}var Pf=Zu;function $u(t){if(t instanceof kf)return $u(t.boundExpression);if(t instanceof Vi&&t.name==="error"||t instanceof Vi&&t.name==="config"||t instanceof rl||t instanceof ku||t instanceof ju)return!1;const e=t instanceof cs||t instanceof no;let r=!0;return t.eachChild(i=>{r=e?r&&$u(i):r&&i instanceof Vn}),!!r&&Hs(t)&&Ws(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light"])}function ll(t,e){const r=t.length-1;let i,o,s=0,n=r,a=0;for(;s<=n;)if(a=Math.floor((s+n)/2),i=t[a],o=t[a+1],i<=e){if(a===r||e<o)return a;s=a+1}else{if(!(i>e))throw new Tr("Input is not a number.");n=a-1}return 0}class Hu{constructor(e,r,i){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[o,s]of i)this.labels.push(o),this.outputs.push(s)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const i=r.parse(e[1],1,ye);if(!i)return null;const o=[];let s=null;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);for(let n=1;n<e.length;n+=2){const a=n===1?-1/0:e[n],l=e[n+1],c=n,u=n+1;if(typeof a!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',c);if(o.length&&o[o.length-1][0]>=a)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',c);const h=r.parse(l,u,s);if(!h)return null;s=s||h.type,o.push([a,h])}return new Hu(s,i,o)}evaluate(e){const r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return i[0].evaluate(e);const s=r.length;return o>=r[s-1]?i[s-1].evaluate(e):i[ll(r,o)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let r=0;r<this.labels.length;r++)r>0&&e.push(this.labels[r]),e.push(this.outputs[r].serialize());return e}}var Wu=Hu;function Fe(t,e,r){return t*(1-r)+e*r}function Rf(t,e,r){return t.map((i,o)=>Fe(i,e[o],r))}var cl=Object.freeze({__proto__:null,array:Rf,color:function(t,e,r){return new Qe(Fe(t.r,e.r,r),Fe(t.g,e.g,r),Fe(t.b,e.b,r),Fe(t.a,e.a,r))},number:Fe});const Lf=.95047,Bf=1.08883,Of=4/29,Xs=6/29,Ff=3*Xs*Xs,zv=Xs*Xs*Xs,Dv=Math.PI/180,kv=180/Math.PI;function Xu(t){return t>zv?Math.pow(t,1/3):t/Ff+Of}function Yu(t){return t>Xs?t*t*t:Ff*(t-Of)}function Ju(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ku(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Nf(t){const e=Ku(t.r),r=Ku(t.g),i=Ku(t.b),o=Xu((.4124564*e+.3575761*r+.1804375*i)/Lf),s=Xu((.2126729*e+.7151522*r+.072175*i)/1);return{l:116*s-16,a:500*(o-s),b:200*(s-Xu((.0193339*e+.119192*r+.9503041*i)/Bf)),alpha:t.a}}function Uf(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,i=isNaN(t.b)?e:e-t.b/200;return e=1*Yu(e),r=Lf*Yu(r),i=Bf*Yu(i),new Qe(Ju(3.2404542*r-1.5371385*e-.4985314*i),Ju(-.969266*r+1.8760108*e+.041556*i),Ju(.0556434*r-.2040259*e+1.0572252*i),t.alpha)}function Pv(t,e,r){const i=e-t;return t+r*(i>180||i<-180?i-360*Math.round(i/360):i)}const Xn={forward:Nf,reverse:Uf,interpolate:function(t,e,r){return{l:Fe(t.l,e.l,r),a:Fe(t.a,e.a,r),b:Fe(t.b,e.b,r),alpha:Fe(t.alpha,e.alpha,r)}}},Yn={forward:function(t){const{l:e,a:r,b:i}=Nf(t),o=Math.atan2(i,r)*kv;return{h:o<0?o+360:o,c:Math.sqrt(r*r+i*i),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Dv,r=t.c;return Uf({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:Pv(t.h,e.h,r),c:Fe(t.c,e.c,r),l:Fe(t.l,e.l,r),alpha:Fe(t.alpha,e.alpha,r)}}};var Vf=Object.freeze({__proto__:null,hcl:Yn,lab:Xn});class ul{constructor(e,r,i,o,s){this.type=e,this.operator=r,this.interpolation=i,this.input=o,this.labels=[],this.outputs=[];for(const[n,a]of s)this.labels.push(n),this.outputs.push(a)}static interpolationFactor(e,r,i,o){let s=0;if(e.name==="exponential")s=Qu(r,e.base,i,o);else if(e.name==="linear")s=Qu(r,1,i,o);else if(e.name==="cubic-bezier"){const n=e.controlPoints;s=new qa(n[0],n[1],n[2],n[3]).solve(Qu(r,1,i,o))}return s}static parse(e,r){let[i,o,s,...n]=e;if(!Array.isArray(o)||o.length===0)return r.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const c=o[1];if(typeof c!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:c}}else{if(o[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const c=o.slice(1);if(c.length!==4||c.some(u=>typeof u!="number"||u<0||u>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:c}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(s=r.parse(s,2,ye),!s)return null;const a=[];let l=null;i==="interpolate-hcl"||i==="interpolate-lab"?l=hi:r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let c=0;c<n.length;c+=2){const u=n[c],h=n[c+1],d=c+3,p=c+4;if(typeof u!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(a.length&&a[a.length-1][0]>=u)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);const f=r.parse(h,p,l);if(!f)return null;l=l||f.type,a.push([u,f])}return l.kind==="number"||l.kind==="color"||l.kind==="array"&&l.itemType.kind==="number"&&typeof l.N=="number"?new ul(l,i,o,s,a):r.error(`Type ${sr(l)} is not interpolatable.`)}evaluate(e){const r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return i[0].evaluate(e);const s=r.length;if(o>=r[s-1])return i[s-1].evaluate(e);const n=ll(r,o),a=ul.interpolationFactor(this.interpolation,o,r[n],r[n+1]),l=i[n].evaluate(e),c=i[n+1].evaluate(e);return this.operator==="interpolate"?cl[this.type.kind.toLowerCase()](l,c,a):this.operator==="interpolate-hcl"?Yn.reverse(Yn.interpolate(Yn.forward(l),Yn.forward(c),a)):Xn.reverse(Xn.interpolate(Xn.forward(l),Xn.forward(c),a))}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const r=[this.operator,e,this.input.serialize()];for(let i=0;i<this.labels.length;i++)r.push(this.labels[i],this.outputs[i].serialize());return r}}function Qu(t,e,r,i){const o=i-r,s=t-r;return o===0?0:e===1?s/o:(Math.pow(e,s)-1)/(Math.pow(e,o)-1)}var ji=ul;class eh{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let i=null;const o=r.expectedType;o&&o.kind!=="value"&&(i=o);const s=[];for(const a of e.slice(1)){const l=r.parse(a,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!l)return null;i=i||l.type,s.push(l)}const n=o&&s.some(a=>Fn(o,a.type));return new eh(n?_t:i,s)}evaluate(e){let r,i=null,o=0;for(const s of this.args){if(o++,i=s.evaluate(e),i&&i instanceof di&&!i.available&&(r||(r=i),i=null,o===this.args.length))return r;if(i!==null)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var jf=eh;class th{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let s=1;s<e.length-1;s+=2){const n=e[s];if(typeof n!="string")return r.error(`Expected string, but found ${typeof n} instead.`,s);if(/[^a-zA-Z0-9_]/.test(n))return r.error("Variable names must contain only alphanumeric characters or '_'.",s);const a=r.parse(e[s+1],s+1);if(!a)return null;i.push([n,a])}const o=r.parse(e[e.length-1],e.length-1,r.expectedType,i);return o?new th(i,o):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[r,i]of this.bindings)e.push(r,i.serialize());return e.push(this.result.serialize()),e}}var Gf=th;class rh{constructor(e,r,i){this.type=e,this.index=r,this.input=i}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,ye),o=r.parse(e[2],2,qr(r.expectedType||_t));return i&&o?new rh(o.type.itemType,i,o):null}evaluate(e){const r=this.index.evaluate(e),i=this.input.evaluate(e);if(r<0)throw new Tr(`Array index out of bounds: ${r} < 0.`);if(r>=i.length)throw new Tr(`Array index out of bounds: ${r} > ${i.length-1}.`);if(r!==Math.floor(r))throw new Tr(`Array index must be an integer, but found ${r} instead.`);return i[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Rv=rh;class ih{constructor(e,r){this.type=yt,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,_t);return i&&o?bu(i.type,[yt,ft,ye,js,_t])?new ih(i,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(i==null)return!1;if(!Nn(r,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(mr(r))} instead.`);if(!Nn(i,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${sr(mr(i))} instead.`);return i.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Lv=ih;class hl{constructor(e,r,i){this.type=ye,this.needle=e,this.haystack=r,this.fromIndex=i}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,_t);if(!i||!o)return null;if(!bu(i.type,[yt,ft,ye,js,_t]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(e.length===4){const s=r.parse(e[3],3,ye);return s?new hl(i,o,s):null}return new hl(i,o)}evaluate(e){const r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Nn(r,["boolean","string","number","null"]))throw new Tr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(mr(r))} instead.`);if(!Nn(i,["string","array"]))throw new Tr(`Expected second argument to be of type array or string, but found ${sr(mr(i))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(e);return i.indexOf(r,o)}return i.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){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 Bv=hl;class oh{constructor(e,r,i,o,s,n){this.inputType=e,this.type=r,this.input=i,this.cases=o,this.outputs=s,this.otherwise=n}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let i,o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const s={},n=[];for(let c=2;c<e.length-1;c+=2){let u=e[c];const h=e[c+1];Array.isArray(u)||(u=[u]);const d=r.concat(c);if(u.length===0)return d.error("Expected at least one branch label.");for(const f of u){if(typeof f!="number"&&typeof f!="string")return d.error("Branch labels must be numbers or strings.");if(typeof f=="number"&&Math.abs(f)>Number.MAX_SAFE_INTEGER)return d.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof f=="number"&&Math.floor(f)!==f)return d.error("Numeric branch labels must be integer values.");if(i){if(d.checkSubtype(i,mr(f)))return null}else i=mr(f);if(s[String(f)]!==void 0)return d.error("Branch labels must be unique.");s[String(f)]=n.length}const p=r.parse(h,c,o);if(!p)return null;o=o||p.type,n.push(p)}const a=r.parse(e[1],1,_t);if(!a)return null;const l=r.parse(e[e.length-1],e.length-1,o);return l?a.type.kind!=="value"&&r.concat(1).checkSubtype(i,a.type)?null:new oh(i,o,a,s,n,l):null}evaluate(e){const r=this.input.evaluate(e);return(mr(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),i=[],o={};for(const n of r){const a=o[this.cases[n]];a===void 0?(o[this.cases[n]]=i.length,i.push([this.cases[n],[n]])):i[a][1].push(n)}const s=n=>this.inputType.kind==="number"?Number(n):n;for(const[n,a]of i)e.push(a.length===1?s(a[0]):a.map(s)),e.push(this.outputs[n].serialize());return e.push(this.otherwise.serialize()),e}}var Ov=oh;class sh{constructor(e,r,i){this.type=e,this.branches=r,this.otherwise=i}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let i;r.expectedType&&r.expectedType.kind!=="value"&&(i=r.expectedType);const o=[];for(let n=1;n<e.length-1;n+=2){const a=r.parse(e[n],n,yt);if(!a)return null;const l=r.parse(e[n+1],n+1,i);if(!l)return null;o.push([a,l]),i=i||l.type}const s=r.parse(e[e.length-1],e.length-1,i);return s?new sh(i,o,s):null}evaluate(e){for(const[r,i]of this.branches)if(r.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,i]of this.branches)e(r),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var Fv=sh;class dl{constructor(e,r,i,o){this.type=e,this.input=r,this.beginIndex=i,this.endIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=r.parse(e[1],1,_t),o=r.parse(e[2],2,ye);if(!i||!o)return null;if(!bu(i.type,[qr(_t),ft,_t]))return r.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(e.length===4){const s=r.parse(e[3],3,ye);return s?new dl(i.type,i,o,s):null}return new dl(i.type,i,o)}evaluate(e){const r=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Nn(r,["string","array"]))throw new Tr(`Expected first argument to be of type array or string, but found ${sr(mr(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(e);return r.slice(i,o)}return r.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Nv=dl;function qf(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Zf(t,e,r,i){return i.compare(e,r)===0}function Ys(t,e,r){const i=t!=="=="&&t!=="!=";return class ov{constructor(s,n,a){this.type=yt,this.lhs=s,this.rhs=n,this.collator=a,this.hasUntypedArgument=s.type.kind==="value"||n.type.kind==="value"}static parse(s,n){if(s.length!==3&&s.length!==4)return n.error("Expected two or three arguments.");const a=s[0];let l=n.parse(s[1],1,_t);if(!l)return null;if(!qf(a,l.type))return n.concat(1).error(`"${a}" comparisons are not supported for type '${sr(l.type)}'.`);let c=n.parse(s[2],2,_t);if(!c)return null;if(!qf(a,c.type))return n.concat(2).error(`"${a}" comparisons are not supported for type '${sr(c.type)}'.`);if(l.type.kind!==c.type.kind&&l.type.kind!=="value"&&c.type.kind!=="value")return n.error(`Cannot compare types '${sr(l.type)}' and '${sr(c.type)}'.`);i&&(l.type.kind==="value"&&c.type.kind!=="value"?l=new no(c.type,[l]):l.type.kind!=="value"&&c.type.kind==="value"&&(c=new no(l.type,[c])));let u=null;if(s.length===4){if(l.type.kind!=="string"&&c.type.kind!=="string"&&l.type.kind!=="value"&&c.type.kind!=="value")return n.error("Cannot use collator to compare non-string types.");if(u=n.parse(s[3],3,Qa),!u)return null}return new ov(l,c,u)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(i&&this.hasUntypedArgument){const l=mr(n),c=mr(a);if(l.kind!==c.kind||l.kind!=="string"&&l.kind!=="number")throw new Tr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${l.kind}, ${c.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const l=mr(n),c=mr(a);if(l.kind!=="string"||c.kind!=="string")return e(s,n,a)}return this.collator?r(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(s){s(this.lhs),s(this.rhs),this.collator&&s(this.collator)}outputDefined(){return!0}serialize(){const s=[t];return this.eachChild(n=>{s.push(n.serialize())}),s}}}const Uv=Ys("==",function(t,e,r){return e===r},Zf),Vv=Ys("!=",function(t,e,r){return e!==r},function(t,e,r,i){return!Zf(0,e,r,i)}),jv=Ys("<",function(t,e,r){return e<r},function(t,e,r,i){return i.compare(e,r)<0}),Gv=Ys(">",function(t,e,r){return e>r},function(t,e,r,i){return i.compare(e,r)>0}),qv=Ys("<=",function(t,e,r){return e<=r},function(t,e,r,i){return i.compare(e,r)<=0}),Zv=Ys(">=",function(t,e,r){return e>=r},function(t,e,r,i){return i.compare(e,r)>=0});class nh{constructor(e,r,i,o,s,n){this.type=ft,this.number=e,this.locale=r,this.currency=i,this.unit=o,this.minFractionDigits=s,this.maxFractionDigits=n}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const i=r.parse(e[1],1,ye);if(!i)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let s=null;if(o.locale&&(s=r.parse(o.locale,1,ft),!s))return null;let n=null;if(o.currency&&(n=r.parse(o.currency,1,ft),!n))return null;let a=null;if(o.unit&&(a=r.parse(o.unit,1,ft),!a))return null;let l=null;if(o["min-fraction-digits"]&&(l=r.parse(o["min-fraction-digits"],1,ye),!l))return null;let c=null;return o["max-fraction-digits"]&&(c=r.parse(o["max-fraction-digits"],1,ye),!c)?null:new nh(i,s,n,a,l,c)}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 ah{constructor(e){this.type=ye,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=r.parse(e[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new ah(i):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Tr(`Expected value to be of type string or array, but found ${sr(mr(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(r=>{e.push(r.serialize())}),e}}function lh(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 $f={"==":Uv,"!=":Vv,">":Gv,"<":jv,">=":Zv,"<=":qv,array:no,at:Rv,boolean:no,case:Fv,coalesce:jf,collator:rl,format:jn,image:Gn,in:Lv,"index-of":Bv,interpolate:ji,"interpolate-hcl":ji,"interpolate-lab":ji,length:ah,let:Gf,literal:Vn,match:Ov,number:no,"number-format":nh,object:no,slice:Nv,step:Wu,string:no,"to-boolean":cs,"to-color":cs,"to-number":cs,"to-string":cs,var:kf,within:ku,distance:ju};function Hf(t,[e,r,i,o]){e=e.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);const s=o?o.evaluate(t):1,n=mf(e,r,i,s);if(n)throw new Tr(n);return new Qe(e/255*s,r/255*s,i/255*s,s)}function Wf(t,[e,r,i,o]){e=e.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);const s=o?o.evaluate(t):1,n=function(c,u,h,d){return typeof c=="number"&&c>=0&&c<=360?typeof u=="number"&&u>=0&&u<=100&&typeof h=="number"&&h>=0&&h<=100?d===void 0||typeof d=="number"&&d>=0&&d<=1?null:`Invalid hsla value [${[c,u,h,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof d=="number"?[c,u,h,d]:[c,u,h]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof d=="number"?[c,u,h,d]:[c,u,h]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,i,s);if(n)throw new Tr(n);const a=`hsla(${e}, ${r}%, ${i}%, ${s})`,l=Qe.parse(a);if(!l)throw new Tr(`Failed to parse HSLA color: ${a}`);return l}function Xf(t,e){return t in e}function ch(t,e){const r=e[t];return r===void 0?null:r}function Yf(t,e){switch(t){case"string":return String(e);case"number":return+e;case"boolean":return!!e;case"color":return Qe.parse(e)}return e}function Jf(t,e,r,i){return i!==void 0&&(t=i*Math.round(t/i)),e!==void 0&&t<e&&(t=e),r!==void 0&&t>r&&(t=r),t}function Kf(t,e,r){r.length&&(e+=`${r}`);const i=t.getConfig(e);if(!i)return null;const{type:o,value:s,values:n,minValue:a,maxValue:l,stepValue:c}=i,u=i.default.evaluate(t);let h=s?s.evaluate(t):u;return o&&(h=Yf(o,h)),s!==void 0&&h!==void 0&&n&&!n.includes(h)&&(h=u,o&&(h=Yf(o,h))),h===void 0||a===void 0&&l===void 0&&c===void 0||(typeof h=="number"?h=Jf(h,a,l,c):Array.isArray(h)&&(h=h.map(d=>typeof d=="number"?Jf(d,a,l,c):d))),h}function ds(t){return{type:t}}Vi.register($f,{error:[{kind:"error"},[ft],(t,[e])=>{throw new Tr(e.evaluate(t))}],typeof:[ft,[_t],(t,[e])=>sr(mr(e.evaluate(t)))],"to-rgba":[qr(ye,4),[hi],(t,[e])=>e.evaluate(t).toArray()],rgb:[hi,[ye,ye,ye],Hf],rgba:[hi,[ye,ye,ye,ye],Hf],hsl:[hi,[ye,ye,ye],Wf],hsla:[hi,[ye,ye,ye,ye],Wf],has:{type:yt,overloads:[[[ft],(t,[e])=>Xf(e.evaluate(t),t.properties())],[[ft,Gs],(t,[e,r])=>Xf(e.evaluate(t),r.evaluate(t))]]},get:{type:_t,overloads:[[[ft],(t,[e])=>ch(e.evaluate(t),t.properties())],[[ft,Gs],(t,[e,r])=>ch(e.evaluate(t),r.evaluate(t))]]},config:{type:_t,overloads:[[[ft],(t,[e])=>Kf(t,e.evaluate(t),"")],[[ft,ft],(t,[e,r])=>Kf(t,e.evaluate(t),r.evaluate(t))]]},"feature-state":[_t,[ft],(t,[e])=>ch(e.evaluate(t),t.featureState||{})],properties:[Gs,[],t=>t.properties()],"geometry-type":[ft,[],t=>t.geometryType()],id:[_t,[],t=>t.id()],zoom:[ye,[],t=>t.globals.zoom],pitch:[ye,[],t=>t.globals.pitch||0],"distance-from-center":[ye,[],t=>t.distanceFromCenter()],"measure-light":[ye,[ft],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ye,[],t=>t.globals.heatmapDensity||0],"line-progress":[ye,[],t=>t.globals.lineProgress||0],"raster-value":[ye,[],t=>t.globals.rasterValue||0],"sky-radial-progress":[ye,[],t=>t.globals.skyRadialProgress||0],accumulated:[_t,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[ye,ds(ye),(t,e)=>{let r=0;for(const i of e)r+=i.evaluate(t);return r}],"*":[ye,ds(ye),(t,e)=>{let r=1;for(const i of e)r*=i.evaluate(t);return r}],"-":{type:ye,overloads:[[[ye,ye],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[ye],(t,[e])=>-e.evaluate(t)]]},"/":[ye,[ye,ye],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[ye,[ye,ye],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[ye,[],()=>Math.LN2],pi:[ye,[],()=>Math.PI],e:[ye,[],()=>Math.E],"^":[ye,[ye,ye],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[ye,[ye],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))],log2:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ye,[ye],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ye,[ye],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ye,[ye],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ye,[ye],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ye,[ye],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ye,[ye],(t,[e])=>Math.atan(e.evaluate(t))],min:[ye,ds(ye),(t,e)=>Math.min(...e.map(r=>r.evaluate(t)))],max:[ye,ds(ye),(t,e)=>Math.max(...e.map(r=>r.evaluate(t)))],abs:[ye,[ye],(t,[e])=>Math.abs(e.evaluate(t))],round:[ye,[ye],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[ye,[ye],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ye,[ye],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[yt,[ft,_t],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[yt,[_t],(t,[e])=>t.id()===e.value],"filter-type-==":[yt,[ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i<o}],"filter-id-<":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r<i}],"filter->":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r>i}],"filter-<=":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r<=i}],"filter->=":[yt,[ft,_t],(t,[e,r])=>{const i=t.properties()[e.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[yt,[_t],(t,[e])=>{const r=t.id(),i=e.value;return typeof r==typeof i&&r>=i}],"filter-has":[yt,[_t],(t,[e])=>e.value in t.properties()],"filter-has-id":[yt,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[yt,[qr(ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[yt,[qr(_t)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[yt,[ft,qr(_t)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[yt,[ft,qr(_t)],(t,[e,r])=>function(i,o,s,n){for(;s<=n;){const a=s+n>>1;if(o[a]===i)return!0;o[a]>i?n=a-1:s=a+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:yt,overloads:[[[yt,yt],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[ds(yt),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:yt,overloads:[[[yt,yt],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[ds(yt),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[yt,[yt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[yt,[ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[ft,[ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ft,[ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ft,ds(_t),(t,e)=>e.map(r=>Un(r.evaluate(t))).join("")],"resolved-locale":[ft,[Qa],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ye,[ye,ye,_t],(t,e)=>{const[r,i,o]=e.map(n=>n.evaluate(t));if(r>i||r===i)return r;let s;if(typeof o=="string")s=function(n){let a=0;if(n.length===0)return a;for(let l=0;l<n.length;l++)a=(a<<5)-a+n.charCodeAt(l),a&=a;return a}(o);else{if(typeof o!="number")throw new Tr(`Invalid seed input: ${o}`);s=o}return r+lh(s)()*(i-r)}]});var Jn=$f;function Qf(t){return{result:"success",value:t}}function ps(t){return{result:"error",value:t}}function em(t,e){return!!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function fs(t){return t["property-type"]==="data-driven"}function tm(t){return em(t.expression,"measure-light")}function uh(t){return em(t.expression,"zoom")}function hh(t){return!!t.expression&&t.expression.interpolated}function pl(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $v(t){return t}function rm(t,e){const r=e.type==="color",i=t.stops&&typeof t.stops[0][0]=="object",o=i||!(i||t.property!==void 0),s=t.type||(hh(e)?"exponential":"interval");if(r&&((t=oo({},t)).stops&&(t.stops=t.stops.map(c=>[c[0],Qe.parse(c[1])])),t.default=Qe.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!Vf[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let n,a,l;if(s==="exponential")n=im;else if(s==="interval")n=Wv;else if(s==="categorical"){n=Hv,a=Object.create(null);for(const c of t.stops)a[c[0]]=c[1];l=typeof t.stops[0][0]}else{if(s!=="identity")throw new Error(`Unknown function type "${s}"`);n=Xv}if(i){const c={},u=[];for(let p=0;p<t.stops.length;p++){const f=t.stops[p],m=f[0].zoom;c[m]===void 0&&(c[m]={zoom:m,type:t.type,property:t.property,default:t.default,stops:[]},u.push(m)),c[m].stops.push([f[0].value,f[1]])}const h=[];for(const p of u)h.push([c[p].zoom,rm(c[p],e)]);const d={name:"linear"};return{kind:"composite",interpolationType:d,interpolationFactor:ji.interpolationFactor.bind(void 0,d),zoomStops:h.map(p=>p[0]),evaluate:({zoom:p},f)=>im({stops:h,base:t.base},e,p).evaluate(p,f)}}if(o){const c=s==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:c,interpolationFactor:ji.interpolationFactor.bind(void 0,c),zoomStops:t.stops.map(u=>u[0]),evaluate:({zoom:u})=>n(t,e,u,a,l)}}return{kind:"source",evaluate(c,u){const h=u&&u.properties?u.properties[t.property]:void 0;return h===void 0?Kn(t.default,e.default):n(t,e,h,a,l)}}}function Kn(t,e,r){return t!==void 0?t:e!==void 0?e:r!==void 0?r:void 0}function Hv(t,e,r,i,o){return Kn(typeof r===o?i[r]:void 0,t.default,e.default)}function Wv(t,e,r){if(Tt(r)!=="number")return Kn(t.default,e.default);const i=t.stops.length;if(i===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const o=ll(t.stops.map(s=>s[0]),r);return t.stops[o][1]}function im(t,e,r){const i=t.base!==void 0?t.base:1;if(Tt(r)!=="number")return Kn(t.default,e.default);const o=t.stops.length;if(o===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[o-1][0])return t.stops[o-1][1];const s=ll(t.stops.map(u=>u[0]),r),n=function(u,h,d,p){const f=p-d,m=u-d;return f===0?0:h===1?m/f:(Math.pow(h,m)-1)/(Math.pow(h,f)-1)}(r,i,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1];let c=cl[e.type]||$v;if(t.colorSpace&&t.colorSpace!=="rgb"){const u=Vf[t.colorSpace];c=(h,d)=>u.reverse(u.interpolate(u.forward(h),u.forward(d),n))}return typeof a.evaluate=="function"?{evaluate(...u){const h=a.evaluate.apply(void 0,u),d=l.evaluate.apply(void 0,u);if(h!==void 0&&d!==void 0)return c(h,d,n)}}:c(a,l,n)}function Xv(t,e,r){return e.type==="color"?r=Qe.parse(r):e.type==="formatted"?r=$r.fromString(r.toString()):e.type==="resolvedImage"?r=di.fromString(r.toString()):Tt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0),Kn(r,t.default,e.default)}class dh{constructor(e,r,i){this.expression=e,this._warningHistory={},this._evaluator=new _f(i),this._defaultValue=r?function(o){return o.type==="color"&&(pl(o.default)||Array.isArray(o.default))?new Qe(0,0,0,0):o.type==="color"?Qe.parse(o.default)||null:o.default===void 0?null:o.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,i,o,s,n,a,l){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=i,this._evaluator.canonical=o||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null,this.expression.evaluate(this._evaluator)}evaluate(e,r,i,o,s,n,a,l){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=i||null,this._evaluator.canonical=o||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null;try{const c=this.expression.evaluate(this._evaluator);if(c==null||typeof c=="number"&&c!=c)return this._defaultValue;if(this._enumValues&&!(c in this._enumValues))throw new Tr(`Expected value to be one of ${Object.keys(this._enumValues).map(u=>JSON.stringify(u)).join(", ")}, but found ${JSON.stringify(c)} instead.`);return c}catch(c){return this._warningHistory[c.message]||(this._warningHistory[c.message]=!0,typeof console<"u"&&console.warn(c.message)),this._defaultValue}}}function fl(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in Jn}function So(t,e,r){const i=new Pf(Jn,[],e?function(s){const n={color:hi,string:ft,number:ye,enum:ft,boolean:yt,formatted:Bn,resolvedImage:On};return s.type==="array"?qr(n[s.value]||_t,s.length):n[s.type]}(e):void 0,void 0,void 0,r),o=i.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?Qf(new dh(o,e,r)):ps(i.errors)}class ph{constructor(e,r,i){this.kind=e,this._styleExpression=r,this.isLightConstant=i,this.isStateDependent=e!=="constant"&&!Wn(r.expression),this.isConfigDependent=!Gu(r.expression)}evaluateWithoutErrorHandling(e,r,i,o,s,n){return this._styleExpression.evaluateWithoutErrorHandling(e,r,i,o,s,n)}evaluate(e,r,i,o,s,n){return this._styleExpression.evaluate(e,r,i,o,s,n)}}class Ao{constructor(e,r,i,o,s){this.kind=e,this.zoomStops=i,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!Wn(r.expression),this.isLightConstant=s,this.isConfigDependent=!Gu(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(e,r,i,o,s,n){return this._styleExpression.evaluateWithoutErrorHandling(e,r,i,o,s,n)}evaluate(e,r,i,o,s,n){return this._styleExpression.evaluate(e,r,i,o,s,n)}interpolationFactor(e,r,i){return this.interpolationType?ji.interpolationFactor(this.interpolationType,e,r,i):0}}function fh(t,e,r){if((t=So(t,e,r)).result==="error")return t;const i=t.value.expression,o=Hs(i);if(!o&&!fs(e))return ps([new Ui("","data expressions not supported")]);const s=Ws(i,["zoom","pitch","distance-from-center"]);if(!s&&!uh(e))return ps([new Ui("","zoom expressions not supported")]);const n=Ws(i,["measure-light"]);if(!n&&!tm(e))return ps([new Ui("","measure-light expression not supported")]);const a=e.expression&&e.expression.relaxZoomRestriction,l=_l(i);return l||s||a?l instanceof Ui?ps([l]):l instanceof ji&&!hh(e)?ps([new Ui("",'"interpolate" expressions cannot be used with this property')]):Qf(l?new Ao(o?"camera":"composite",t.value,l.labels,l instanceof ji?l.interpolation:void 0,n):new ph(o?"constant":"source",t.value,n)):ps([new Ui("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ml{constructor(e,r){this._parameters=e,this._specification=r,oo(this,rm(this._parameters,this._specification))}static deserialize(e){return new ml(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function _l(t){let e=null;if(t instanceof Gf)e=_l(t.result);else if(t instanceof jf){for(const r of t.args)if(e=_l(r),e)break}else(t instanceof Wu||t instanceof ji)&&t.input instanceof Vi&&t.input.name==="zoom"&&(e=t);return e instanceof Ui||t.eachChild(r=>{const i=_l(r);i instanceof Ui?e=i:e&&i&&e!==i&&(e=new Ui("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function pi(t){const e=t.key,r=t.value,i=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,n=t.styleSpec;let a=[];const l=Tt(r);if(l!=="object")return[new be(e,r,`object expected, ${l} found`)];for(const c in r){const u=c.split(".")[0];let h;o[u]?h=o[u]:i[u]?h=Sr:o["*"]?h=o["*"]:i["*"]&&(h=Sr),h?a=a.concat(h({key:(e&&`${e}.`)+c,value:r[c],valueSpec:i[u]||i["*"],style:s,styleSpec:n,object:r,objectKey:c},r)):a.push(new ls(e,r[c],`unknown property "${c}"`))}for(const c in i)o[c]||i[c].required&&i[c].default===void 0&&r[c]===void 0&&a.push(new be(e,r,`missing required property "${c}"`));return a}function om(t){const e=t.value,r=t.valueSpec,i=t.style,o=t.styleSpec,s=t.key,n=t.arrayElementValidator||Sr;if(Tt(e)!=="array")return[new be(s,e,`array expected, ${Tt(e)} found`)];if(r.length&&e.length!==r.length)return[new be(s,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new be(s,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let a={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};o.$version<7&&(a.function=r.function),Tt(r.value)==="object"&&(a=r.value);let l=[];for(let c=0;c<e.length;c++)l=l.concat(n({array:e,arrayIndex:c,value:e[c],valueSpec:a,style:i,styleSpec:o,key:`${s}[${c}]`},!0));return l}function sm(t){const e=t.key,r=t.value,i=t.valueSpec;let o=Tt(r);if(o==="number"&&r!=r&&(o="NaN"),o!=="number")return[new be(e,r,`number expected, ${o} found`)];if("minimum"in i){let s=i.minimum;if(Tt(i.minimum)==="array"&&(s=i.minimum[t.arrayIndex]),r<s)return[new be(e,r,`${r} is less than the minimum value ${s}`)]}if("maximum"in i){let s=i.maximum;if(Tt(i.maximum)==="array"&&(s=i.maximum[t.arrayIndex]),r>s)return[new be(e,r,`${r} is greater than the maximum value ${s}`)]}return[]}function nm(t){const e=t.valueSpec,r=cr(t.value.type);let i,o,s,n={};const a=r!=="categorical"&&t.value.property===void 0,l=!a,c=Tt(t.value.stops)==="array"&&Tt(t.value.stops[0])==="array"&&Tt(t.value.stops[0][0])==="object",u=pi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(p){if(r==="identity")return[new be(p.key,p.value,'identity function may not have a "stops" property')];let f=[];const m=p.value;return f=f.concat(om({key:p.key,value:m,valueSpec:p.valueSpec,style:p.style,styleSpec:p.styleSpec,arrayElementValidator:h})),Tt(m)==="array"&&m.length===0&&f.push(new be(p.key,m,"array must have at least one stop")),f},default:function(p){return Sr({key:p.key,value:p.value,valueSpec:e,style:p.style,styleSpec:p.styleSpec})}}});return r==="identity"&&a&&u.push(new be(t.key,t.value,'missing required property "property"')),r==="identity"||t.value.stops||u.push(new be(t.key,t.value,'missing required property "stops"')),r==="exponential"&&t.valueSpec.expression&&!hh(t.valueSpec)&&u.push(new be(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!fs(t.valueSpec)?u.push(new be(t.key,t.value,"property functions not supported")):a&&!uh(t.valueSpec)&&u.push(new be(t.key,t.value,"zoom functions not supported"))),r!=="categorical"&&!c||t.value.property!==void 0||u.push(new be(t.key,t.value,'"property" property is required')),u;function h(p){let f=[];const m=p.value,_=p.key;if(Tt(m)!=="array")return[new be(_,m,`array expected, ${Tt(m)} found`)];if(m.length!==2)return[new be(_,m,`array length 2 expected, length ${m.length} found`)];if(c){if(Tt(m[0])!=="object")return[new be(_,m,`object expected, ${Tt(m[0])} found`)];if(m[0].zoom===void 0)return[new be(_,m,"object stop key must have zoom")];if(m[0].value===void 0)return[new be(_,m,"object stop key must have value")];const g=cr(m[0].zoom);if(typeof g!="number")return[new be(_,m[0].zoom,"stop zoom values must be numbers")];if(s&&s>g)return[new be(_,m[0].zoom,"stop zoom values must appear in ascending order")];g!==s&&(s=g,o=void 0,n={}),f=f.concat(pi({key:`${_}[0]`,value:m[0],valueSpec:{zoom:{}},style:p.style,styleSpec:p.styleSpec,objectElementValidators:{zoom:sm,value:d}}))}else f=f.concat(d({key:`${_}[0]`,value:m[0],valueSpec:{},style:p.style,styleSpec:p.styleSpec},m));return fl(so(m[1]))?f.concat([new be(`${_}[1]`,m[1],"expressions are not allowed in function stops.")]):f.concat(Sr({key:`${_}[1]`,value:m[1],valueSpec:e,style:p.style,styleSpec:p.styleSpec}))}function d(p,f){const m=Tt(p.value),_=cr(p.value),g=p.value!==null?p.value:f;if(i){if(m!==i)return[new be(p.key,g,`${m} stop domain type must match previous stop domain type ${i}`)]}else i=m;if(m!=="number"&&m!=="string"&&m!=="boolean"&&typeof _!="number"&&typeof _!="string"&&typeof _!="boolean")return[new be(p.key,g,"stop domain value must be a number, string, or boolean")];if(m!=="number"&&r!=="categorical"){let y=`number expected, ${m} found`;return fs(e)&&r===void 0&&(y+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new be(p.key,g,y)]}return r!=="categorical"||m!=="number"||typeof _=="number"&&isFinite(_)&&Math.floor(_)===_?r!=="categorical"&&m==="number"&&typeof _=="number"&&typeof o=="number"&&o!==void 0&&_<o?[new be(p.key,g,"stop domain values must appear in ascending order")]:(o=_,r==="categorical"&&_ in n?[new be(p.key,g,"stop domain values must be unique")]:(n[_]=!0,[])):[new be(p.key,g,`integer expected, found ${String(_)}`)]}}function ms(t){const e=(t.expressionContext==="property"?fh:So)(so(t.value),t.valueSpec);if(e.result==="error")return e.value.map(i=>new be(`${t.key}${i.key}`,t.value,i.message));const r=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!r.outputDefined())return[new be(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Wn(r))return[new be(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return am(r,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!Ws(r,["zoom","feature-state"]))return[new be(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!Hs(r))return[new be(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function am(t,e){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const o of e.valueSpec.expression.parameters)r.delete(o);if(r.size===0)return[];const i=[];return t instanceof Vi&&r.has(t.name)?[new be(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild(o=>{i.push(...am(o,e))}),i)}function gl(t){const e=t.key,r=t.value,i=t.valueSpec,o=[];return Array.isArray(i.values)?i.values.indexOf(cr(r))===-1&&o.push(new be(e,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(i.values).indexOf(cr(r))===-1&&o.push(new be(e,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function mh(t){if(t===!0||t===!1)return!0;if(!Array.isArray(t)||t.length===0)return!1;switch(t[0]){case"has":return t.length>=2&&t[1]!=="$id"&&t[1]!=="$type";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!mh(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function yl(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};mh(t)||(t=xl(t));const r=t;let i=!0;try{i=function(c){if(!Js(c))return c;let u=so(c);return cm(u),u=lm(u),u}(r)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
2
2
  This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
3
3
  and paste the contents of this message in the report.
4
4
  Thank you!
5
5
  Filter Expression:
6
6
  ${JSON.stringify(r,null,2)}
7
7
  `)}const o=j[`filter_${e}`],s=So(i,o);let n=null;if(s.result==="error")throw new Error(s.value.map(c=>`${c.key}: ${c.message}`).join(", "));n=(c,u,h)=>s.value.evaluate(c,u,{},h);let a=null,l=null;if(i!==r){const c=So(r,o);if(c.result==="error")throw new Error(c.value.map(u=>`${u.key}: ${u.message}`).join(", "));a=(u,h,d,p,f)=>c.value.evaluate(u,h,{},d,void 0,void 0,p,f),l=!Hs(c.value.expression)}return{filter:n,dynamicFilter:a||void 0,needGeometry:um(i),needFeature:!!l}}function lm(t){if(!Array.isArray(t))return t;const e=function(r){if(Yv.has(r[0])){for(let i=1;i<r.length;i++)if(Js(r[i]))return!0}return r}(t);return e===!0?e:e.map(r=>lm(r))}function cm(t){let e=!1;const r=[];if(t[0]==="case"){for(let i=1;i<t.length-1;i+=2)e=e||Js(t[i]),r.push(t[i+1]);r.push(t[t.length-1])}else if(t[0]==="match"){e=e||Js(t[1]);for(let i=2;i<t.length-1;i+=2)r.push(t[i+1]);r.push(t[t.length-1])}else if(t[0]==="step"){e=e||Js(t[1]);for(let i=1;i<t.length-1;i+=2)r.push(t[i+1])}e&&(t.length=0,t.push("any",...r));for(let i=1;i<t.length;i++)cm(t[i])}function Js(t){if(!Array.isArray(t))return!1;if((e=t[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let r=1;r<t.length;r++)if(Js(t[r]))return!0;return!1}const Yv=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Jv(t,e){return t<e?-1:t>e?1:0}function um(t){if(!Array.isArray(t))return!1;if(t[0]==="within"||t[0]==="distance")return!0;for(let e=1;e<t.length;e++)if(um(t[e]))return!0;return!1}function xl(t){if(!t)return!0;const e=t[0];return t.length<=1?e!=="any":e==="=="?_h(t[1],t[2],"=="):e==="!="?vl(_h(t[1],t[2],"==")):e==="<"||e===">"||e==="<="||e===">="?_h(t[1],t[2],e):e==="any"?(r=t.slice(1),["any"].concat(r.map(xl))):e==="all"?["all"].concat(t.slice(1).map(xl)):e==="none"?["all"].concat(t.slice(1).map(xl).map(vl)):e==="in"?hm(t[1],t.slice(2)):e==="!in"?vl(hm(t[1],t.slice(2))):e==="has"?dm(t[1]):e!=="!has"||vl(dm(t[1]));var r}function _h(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function hm(t,e){if(e.length===0)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",t,["literal",e.sort(Jv)]]:["filter-in-small",t,["literal",e]]}}function dm(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function vl(t){return["!",t]}function gh(t){return mh(so(t.value))?ms(oo({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):pm(t)}function pm(t){const e=t.value,r=t.key;if(Tt(e)!=="array")return[new be(r,e,`array expected, ${Tt(e)} found`)];const i=t.styleSpec;let o,s=[];if(e.length<1)return[new be(r,e,"filter array must have at least 1 element")];switch(s=s.concat(gl({key:`${r}[0]`,value:e[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),cr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&cr(e[1])==="$type"&&s.push(new be(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&s.push(new be(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Tt(e[1]),o!=="string"&&s.push(new be(`${r}[1]`,e[1],`string expected, ${o} found`)));for(let n=2;n<e.length;n++)o=Tt(e[n]),cr(e[1])==="$type"?s=s.concat(gl({key:`${r}[${n}]`,value:e[n],valueSpec:i.geometry_type,style:t.style,styleSpec:t.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&s.push(new be(`${r}[${n}]`,e[n],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let n=1;n<e.length;n++)s=s.concat(pm({key:`${r}[${n}]`,value:e[n],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=Tt(e[1]),e.length!==2?s.push(new be(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):o!=="string"&&s.push(new be(`${r}[1]`,e[1],`string expected, ${o} found`))}return s}function fm(t,e){const r=t.key,i=t.style,o=t.layer,s=t.styleSpec,n=t.value,a=t.objectKey,l=s[`${e}_${t.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if(e==="paint"&&c&&l[c[1]]&&l[c[1]].transition)return Sr({key:r,value:n,valueSpec:s.transition,style:i,styleSpec:s});const u=t.valueSpec||l[a];if(!u)return[new ls(r,n,`unknown property "${a}"`)];let h;if(Tt(n)==="string"&&fs(u)&&!u.tokens&&(h=/^{([^}]+)}$/.exec(n))){const p=`\`{ "type": "identity", "property": ${h?JSON.stringify(h[1]):'"_"'} }\``;return[new be(r,n,`"${a}" does not support interpolation syntax
8
- Use an identity property function instead: ${p}.`)]}const d=[];if(t.layerType==="symbol")a!=="text-field"||!i||i.glyphs||i.imports||d.push(new be(r,n,'use of "text-field" requires a style "glyphs" property')),a==="text-font"&&pl(so(n))&&cr(n.type)==="identity"&&d.push(new be(r,n,'"text-font" does not support identity functions'));else if(t.layerType==="model"&&e==="paint"&&o&&o.layout&&o.layout.hasOwnProperty("model-id")&&fs(u)&&(tm(u)||uh(u))){const p=fh(so(n),u),f=p.value.expression||p.value._styleExpression.expression;f&&!Ws(f,["measure-light"])&&(a==="model-emissive-strength"&&Hs(f)&&Wn(f)||d.push(new be(r,n,`${a} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return d.concat(Sr({key:t.key,value:n,valueSpec:u,style:i,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function mm(t){return fm(t,"paint")}function _m(t){return fm(t,"layout")}function gm(t){let e=[];const r=t.value,i=t.key,o=t.style,s=t.styleSpec;r.type||r.ref||e.push(new be(i,r,'either "type" or "ref" is required'));let n=cr(r.type);const a=cr(r.ref);if(r.id){const l=cr(r.id);for(let c=0;c<t.arrayIndex;c++){const u=o.layers[c];cr(u.id)===l&&e.push(new be(i,r.id,`duplicate layer id "${r.id}", previously used at line ${u.id.__line__}`))}}if("ref"in r){let l;["type","source","source-layer","filter","layout"].forEach(c=>{c in r&&e.push(new be(i,r[c],`"${c}" is prohibited for ref layers`))}),o.layers.forEach(c=>{cr(c.id)===a&&(l=c)}),l?l.ref?e.push(new be(i,r.ref,"ref cannot reference another ref layer")):n=cr(l.type):typeof a=="string"&&e.push(new be(i,r.ref,`ref layer "${a}" not found`))}else if(n!=="background"&&n!=="sky"&&n!=="slot")if(r.source){const l=o.sources&&o.sources[r.source],c=l&&cr(l.type);l?c==="vector"&&n==="raster"?e.push(new be(i,r.source,`layer "${r.id}" requires a raster source`)):c==="raster"&&n!=="raster"?e.push(new be(i,r.source,`layer "${r.id}" requires a vector source`)):c!=="vector"||r["source-layer"]?c==="raster-dem"&&n!=="hillshade"?e.push(new be(i,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):n!=="line"||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||c==="geojson"&&l.lineMetrics||e.push(new be(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new be(i,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new be(i,r.source,`source "${r.source}" not found`))}else e.push(new be(i,r,'missing required property "source"'));return e=e.concat(pi({key:i,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Sr({key:`${i}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:l=>gh(oo({layerType:n},l)),layout:l=>pi({layer:r,key:l.key,value:l.value,valueSpec:{},style:l.style,styleSpec:l.styleSpec,objectElementValidators:{"*":c=>_m(oo({layerType:n},c))}}),paint:l=>pi({layer:r,key:l.key,value:l.value,valueSpec:{},style:l.style,styleSpec:l.styleSpec,objectElementValidators:{"*":c=>mm(oo({layerType:n,layer:r},c))}})}})),e}function Ks(t){const e=t.value,r=t.key,i=Tt(e);return i!=="string"?[new be(r,e,`string expected, ${i} found`)]:[]}const ym={promoteId:function({key:t,value:e}){if(Tt(e)==="string")return Ks({key:t,value:e});{const r=[];for(const i in e)r.push(...Ks({key:`${t}.${i}`,value:e[i]}));return r}}};function xm(t){const e=t.value,r=t.key,i=t.styleSpec,o=t.style;if(!e.type)return[new be(r,e,'"type" is required')];const s=cr(e.type);let n=[];switch(["vector","raster","raster-dem"].includes(s)&&(e.url||e.tiles||n.push(new be(r,e,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":return n=n.concat(pi({key:r,value:e,valueSpec:i[`source_${s.replace("-","_")}`],style:t.style,styleSpec:i,objectElementValidators:ym})),n;case"geojson":if(n=pi({key:r,value:e,valueSpec:i.source_geojson,style:o,styleSpec:i,objectElementValidators:ym}),e.cluster)for(const a in e.clusterProperties){const[l,c]=e.clusterProperties[a],u=typeof l=="string"?[l,["accumulated"],["get",a]]:l;n.push(...ms({key:`${r}.${a}.map`,value:c,expressionContext:"cluster-map"})),n.push(...ms({key:`${r}.${a}.reduce`,value:u,expressionContext:"cluster-reduce"}))}return n;case"video":return pi({key:r,value:e,valueSpec:i.source_video,style:o,styleSpec:i});case"image":return pi({key:r,value:e,valueSpec:i.source_image,style:o,styleSpec:i});case"canvas":return[new be(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gl({key:`${r}.type`,value:e.type,valueSpec:{values:Kv(i)},style:o,styleSpec:i})}}function Kv(t){return t.source.reduce((e,r)=>{const i=t[r];return i.type.type==="enum"&&(e=e.concat(Object.keys(i.type.values))),e},[])}function vm(t){const e=t.value;let r=[];if(!e)return r;const i=Tt(e);return i!=="string"?(r=r.concat([new be(t.key,e,`string expected, "${i}" found`)]),r):(function(o){const s=o.indexOf("://")===-1;try{return new URL(o,s?"http://example.com":void 0),!0}catch{return!1}}(e)||(r=r.concat([new be(t.key,e,`invalid url "${e}"`)])),r)}function bm(t){const e=t.value,r=t.styleSpec,i=r.light,o=t.style;let s=[];const n=Tt(e);if(e===void 0)return s;if(n!=="object")return s=s.concat([new be("light",e,`object expected, ${n} found`)]),s;for(const a in e){const l=a.match(/^(.*)-transition$/);s=s.concat(l&&i[l[1]]&&i[l[1]].transition?Sr({key:a,value:e[a],valueSpec:r.transition,style:o,styleSpec:r}):i[a]?Sr({key:a,value:e[a],valueSpec:i[a],style:o,styleSpec:r}):[new be(a,e[a],`unknown property "${a}"`)])}return s}function wm(t){const e=t.value;let r=[];if(!e)return r;const i=Tt(e);if(i!=="object")return r=r.concat([new be("light-3d",e,`object expected, ${i} found`)]),r;const o=t.styleSpec,s=o["light-3d"],n=t.key,a=t.style,l=t.style.lights;for(const h of["type","id"])if(!(h in e))return r=r.concat([new be("light-3d",e,`missing property ${h} on light`)]),r;if(e.type&&l)for(let h=0;h<t.arrayIndex;h++){const d=cr(e.type),p=l[h];cr(p.type)===d&&r.push(new be(n,e.id,`duplicate light type "${e.type}", previously defined at line ${p.id.__line__}`))}const c=`properties_light_${e.type}`;if(!(c in o))return r=r.concat([new be("light-3d",e,`Invalid light type ${e.type}`)]),r;const u=o[c];for(const h in e)if(h==="properties"){const d=e[h],p=Tt(d);if(p!=="object")return r=r.concat([new be("properties",d,`object expected, ${p} found`)]),r;for(const f in d)r=r.concat(u[f]?Sr({key:f,value:d[f],valueSpec:u[f],style:a,styleSpec:o}):[new ls(t.key,d[f],`unknown property "${f}"`)])}else{const d=h.match(/^(.*)-transition$/);r=r.concat(d&&s[d[1]]&&s[d[1]].transition?Sr({key:h,value:e[h],valueSpec:o.transition,style:a,styleSpec:o}):s[h]?Sr({key:h,value:e[h],valueSpec:s[h],style:a,styleSpec:o}):[new ls(h,e[h],`unknown property "${h}"`)])}return r}function Tm(t){const e=t.value,r=t.key,i=t.style,o=t.styleSpec,s=o.terrain;let n=[];const a=Tt(e);if(e===void 0||a==="null")return n;if(a!=="object")return n=n.concat([new be("terrain",e,`object expected, ${a} found`)]),n;for(const l in e){const c=l.match(/^(.*)-transition$/);n=n.concat(c&&s[c[1]]&&s[c[1]].transition?Sr({key:l,value:e[l],valueSpec:o.transition,style:i,styleSpec:o}):s[l]?Sr({key:l,value:e[l],valueSpec:s[l],style:i,styleSpec:o}):[new ls(l,e[l],`unknown property "${l}"`)])}if(e.source){const l=i.sources&&i.sources[e.source],c=l&&cr(l.type);l?c!=="raster-dem"&&n.push(new be(r,e.source,`terrain cannot be used with a source of type ${String(c)}, it only be used with a "raster-dem" source type`)):n.push(new be(r,e.source,`source "${e.source}" not found`))}else n.push(new be(r,e,'terrain is missing required property "source"'));return n}function Em(t){const e=t.value,r=t.style,i=t.styleSpec,o=i.fog;let s=[];const n=Tt(e);if(e===void 0)return s;if(n!=="object")return s=s.concat([new be("fog",e,`object expected, ${n} found`)]),s;for(const a in e){const l=a.match(/^(.*)-transition$/);s=s.concat(l&&o[l[1]]&&o[l[1]].transition?Sr({key:a,value:e[a],valueSpec:i.transition,style:r,styleSpec:i}):o[a]?Sr({key:a,value:e[a],valueSpec:o[a],style:r,styleSpec:i}):[new ls(a,e[a],`unknown property "${a}"`)])}return s}const Mm={"*":()=>[],array:om,boolean:function(t){const e=t.value,r=t.key,i=Tt(e);return i!=="boolean"?[new be(r,e,`boolean expected, ${i} found`)]:[]},number:sm,color:function(t){const e=t.key,r=t.value,i=Tt(r);return i!=="string"?[new be(e,r,`color expected, ${i} found`)]:wu(r)===null?[new be(e,r,`color expected, "${r}" found`)]:[]},enum:gl,filter:gh,function:nm,layer:gm,object:pi,source:xm,model:vm,light:bm,"light-3d":wm,terrain:Tm,fog:Em,string:Ks,formatted:function(t){return Ks(t).length===0?[]:ms(t)},resolvedImage:function(t){return Ks(t).length===0?[]:ms(t)},projection:function(t){const e=t.value,r=t.styleSpec,i=r.projection,o=t.style;let s=[];const n=Tt(e);if(n==="object")for(const a in e)s=s.concat(Sr({key:a,value:e[a],valueSpec:i[a],style:o,styleSpec:r}));else n!=="string"&&(s=s.concat([new be("projection",e,`object or string expected, ${n} found`)]));return s},import:function(t){const{value:e,styleSpec:r}=t,{data:i,...o}=e;Object.defineProperty(o,"__line__",{value:e.__line__,enumerable:!1});let s=pi(oo({},t,{value:o,valueSpec:r.import}));return cr(o.id)===""&&s.push(new be(`${t.key}.id`,o,"import id can't be an empty string")),i&&(s=s.concat(Sm(i,r,{key:`${t.key}.data`}))),s}};function Sr(t,e=!1){const r=t.value,i=t.valueSpec,o=t.styleSpec;if(i.expression&&pl(cr(r)))return nm(t);if(i.expression&&fl(so(r)))return ms(t);if(i.type&&Mm[i.type]){const s=Mm[i.type](t);return e===!0&&s.length>0&&Tt(t.value)==="array"?ms(t):s}return pi(oo({},t,{valueSpec:i.type?o[i.type]:i}))}function Qv(t){const e=t.value,r=t.key,i=Ks(t);return i.length||(e.indexOf("{fontstack}")===-1&&i.push(new be(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&i.push(new be(r,e,'"glyphs" url must include a "{range}" token'))),i}function Sm(t,e=j,r={}){return Sr({key:r.key||"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Qv,"*":()=>[]}})}function Qs(t,e=j){return Si(Sm(t,e))}const eb=t=>Si(xm(t)),tb=t=>Si(bm(t)),rb=t=>Si(wm(t)),ib=t=>Si(Tm(t)),ob=t=>Si(Em(t)),sb=t=>Si(gm(t)),yh=t=>Si(gh(t)),nb=t=>Si(mm(t)),ab=t=>Si(_m(t)),lb=t=>Si(vm(t));function Si(t){return t.slice().sort((e,r)=>e.line&&r.line?e.line-r.line:0)}function bl(t,e){let r=!1;if(e&&e.length)for(const i of e)i instanceof ls?F(i.message):(t.fire(new Ue(new Error(i.message))),r=!0);return r}var cb=Gi,Io=3;function Gi(t,e,r){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(e=o[1])+2*(r=o[2]);for(var s=0;s<this.d*this.d;s++){var n=o[Io+s],a=o[Io+s+1];i.push(n===a?null:o.subarray(n,a))}var l=o[Io+i.length+1];this.keys=o.subarray(o[Io+i.length],l),this.bboxes=o.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=r,this.scale=e/t,this.uid=0;var u=r/e*t;this.min=-u,this.max=t+u}Gi.prototype.insert=function(t,e,r,i,o){this._forEachCell(e,r,i,o,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(o)},Gi.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Gi.prototype._insertCell=function(t,e,r,i,o,s){this.cells[o].push(s)},Gi.prototype.query=function(t,e,r,i,o){var s=this.min,n=this.max;if(t<=s&&e<=s&&n<=r&&n<=i&&!o)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,r,i,this._queryCell,a,{},o),a},Gi.prototype._queryCell=function(t,e,r,i,o,s,n,a){var l=this.cells[o];if(l!==null)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var d=l[h];if(n[d]===void 0){var p=4*d;(a?a(u[p+0],u[p+1],u[p+2],u[p+3]):t<=u[p+2]&&e<=u[p+3]&&r>=u[p+0]&&i>=u[p+1])?(n[d]=!0,s.push(c[d])):n[d]=!1}}},Gi.prototype._forEachCell=function(t,e,r,i,o,s,n,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(r),h=this._convertToCellCoord(i),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&o.call(this,t,e,r,i,f,s,n,a))return}},Gi.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Gi.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Gi.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Io+this.cells.length+1+1,r=0,i=0;i<this.cells.length;i++)r+=this.cells[i].length;var o=new Int32Array(e+r+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;for(var s=e,n=0;n<t.length;n++){var a=t[n];o[Io+n]=s,o.set(a,s),s+=a.length}return o[Io+t.length]=s,o.set(this.keys,s),o[Io+t.length+1]=s+=this.keys.length,o.set(this.bboxes,s),s+=this.bboxes.length,o.buffer};var en=li(cb);const wl={};function Ee(t,e,r={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),wl[e]={klass:t,omit:r.omit||[]}}Ee(Object,"Object"),en.serialize=function(t,e){const r=t.toArrayBuffer();return e&&e.add(r),{buffer:r}},en.deserialize=function(t){return new en(t.buffer)},Object.defineProperty(en,"name",{value:"Grid"}),Ee(en,"Grid"),Ee(Qe,"Color"),Ee(Error,"Error"),Ee(Q,"AJAXError"),Ee(di,"ResolvedImage"),Ee(ml,"StylePropertyFunction"),Ee(dh,"StyleExpression",{omit:["_evaluator"]}),Ee(Ao,"ZoomDependentExpression"),Ee(ph,"ZoomConstantExpression"),Ee(Vi,"CompoundExpression",{omit:["_evaluate"]});for(const t in Jn)wl[Jn[t]._classRegistryKey]||Ee(Jn[t],`Expression${t}`);function Am(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&t.constructor.name==="ArrayBuffer")}function Im(t){return $.ImageBitmap&&t instanceof $.ImageBitmap}function tn(t,e){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Am(t)||Im(t))return e&&e.add(t),t;if(ArrayBuffer.isView(t)){const r=t;return e&&e.add(r.buffer),r}if(t instanceof $.ImageData)return e&&e.add(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const i of t)r.push(tn(i,e));return r}if(t instanceof Map){const r={$name:"Map"};for(const[i,o]of t.entries())r[i]=tn(o);return r}if(typeof t=="object"){const r=t.constructor,i=r._classRegistryKey;if(!i)throw new Error(`can't serialize object of unregistered class ${i}`);const o=r.serialize?r.serialize(t,e):{};if(!r.serialize){for(const s in t)t.hasOwnProperty(s)&&(wl[i].omit.indexOf(s)>=0||(o[s]=tn(t[s],e)));t instanceof Error&&(o.message=t.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(o.$name=i),o}throw new Error("can't serialize object of type "+typeof t)}function rn(t){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Am(t)||Im(t)||ArrayBuffer.isView(t)||t instanceof $.ImageData)return t;if(Array.isArray(t))return t.map(rn);if(typeof t=="object"){const e=t.$name||"Object";if(e==="Map"){const o=new Map;for(const s of Object.keys(t))s!=="$name"&&o.set(s,rn(t[s]));return o}const{klass:r}=wl[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const i=Object.create(r.prototype);for(const o of Object.keys(t))o!=="$name"&&(i[o]=rn(t[o]));return i}throw new Error("can't deserialize object of type "+typeof t)}const Ae={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function xh(t){for(const e of t)if(vh(e.charCodeAt(0)))return!0;return!1}function ub(t){for(const e of t)if(!hb(e.charCodeAt(0)))return!1;return!0}function hb(t){return!(Ae.Arabic(t)||Ae["Arabic Supplement"](t)||Ae["Arabic Extended-A"](t)||Ae["Arabic Presentation Forms-A"](t)||Ae["Arabic Presentation Forms-B"](t))}function vh(t){return!(t!==746&&t!==747&&(t<4352||!(Ae["Bopomofo Extended"](t)||Ae.Bopomofo(t)||Ae["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Ae["CJK Compatibility Ideographs"](t)||Ae["CJK Compatibility"](t)||Ae["CJK Radicals Supplement"](t)||Ae["CJK Strokes"](t)||!(!Ae["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||Ae["CJK Unified Ideographs Extension A"](t)||Ae["CJK Unified Ideographs"](t)||Ae["Enclosed CJK Letters and Months"](t)||Ae["Hangul Compatibility Jamo"](t)||Ae["Hangul Jamo Extended-A"](t)||Ae["Hangul Jamo Extended-B"](t)||Ae["Hangul Jamo"](t)||Ae["Hangul Syllables"](t)||Ae.Hiragana(t)||Ae["Ideographic Description Characters"](t)||Ae.Kanbun(t)||Ae["Kangxi Radicals"](t)||Ae["Katakana Phonetic Extensions"](t)||Ae.Katakana(t)&&t!==12540||!(!Ae["Halfwidth and Fullwidth Forms"](t)||t===65288||t===65289||t===65293||t>=65306&&t<=65310||t===65339||t===65341||t===65343||t>=65371&&t<=65503||t===65507||t>=65512&&t<=65519)||!(!Ae["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Ae["Unified Canadian Aboriginal Syllabics"](t)||Ae["Unified Canadian Aboriginal Syllabics Extended"](t)||Ae["Vertical Forms"](t)||Ae["Yijing Hexagram Symbols"](t)||Ae["Yi Syllables"](t)||Ae["Yi Radicals"](t))))}function Cm(t){return!(vh(t)||function(e){return!!(Ae["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ae["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ae["Letterlike Symbols"](e)||Ae["Number Forms"](e)||Ae["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ae["Control Pictures"](e)&&e!==9251||Ae["Optical Character Recognition"](e)||Ae["Enclosed Alphanumerics"](e)||Ae["Geometric Shapes"](e)||Ae["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ae["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ae["CJK Symbols and Punctuation"](e)||Ae.Katakana(e)||Ae["Private Use Area"](e)||Ae["CJK Compatibility Forms"](e)||Ae["Small Form Variants"](e)||Ae["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(t))}function zm(t){return t>=1424&&t<=2303||Ae["Arabic Presentation Forms-A"](t)||Ae["Arabic Presentation Forms-B"](t)}function db(t,e){return!(!e&&zm(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Ae.Khmer(t))}function pb(t){for(const e of t)if(zm(e.charCodeAt(0)))return!0;return!1}const bh="deferred",wh="loading",Th="loaded";let Eh=null,Hr="unavailable",Co=null;const Dm=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(Hr="error"),Eh&&Eh(t)};function Mh(){Sh.fire(new ae("pluginStateChange",{pluginStatus:Hr,pluginURL:Co}))}const Sh=new or,Ah=function(){return Hr},km=function(){if(Hr!==bh||!Co)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Hr=wh,Mh(),Co&&fe({url:Co},t=>{t?Dm(t):(Hr=Th,Mh())})},fi={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Hr===Th||fi.applyArabicShaping!=null,isLoading:()=>Hr===wh,setState(t){Hr=t.pluginStatus,Co=t.pluginURL},isParsed:()=>fi.applyArabicShaping!=null&&fi.processBidirectionalText!=null&&fi.processStyledBidirectionalText!=null,getPluginURL:()=>Co};class Ut{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.transition=r.transition,this.pitch=r.pitch,this.brightness=r.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(r,i){for(const o of r)if(!db(o.charCodeAt(0),i))return!1;return!0}(e,fi.isLoaded())}}class Tl{constructor(e,r,i){this.property=e,this.value=r,this.expression=function(o,s,n){if(pl(o))return new ml(o,s);if(fl(o)||Array.isArray(o)&&o.length>0){const a=fh(o,s,n);if(a.result==="error")throw new Error(a.value.map(l=>`${l.key}: ${l.message}`).join(", "));return a.value}{let a=o;return typeof o=="string"&&s.type==="color"&&(a=Qe.parse(o)),{kind:"constant",isConfigDependent:!1,evaluate:()=>a}}}(r===void 0?e.specification.default:r,e.specification,i)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,i){return this.property.possiblyEvaluate(this,e,r,i)}}class Ih{constructor(e,r){this.property=e,this.value=new Tl(e,void 0,r)}transitioned(e,r){return new Pm(this.property,this.value,r,Te({},e.transition,this.transition),e.now)}untransitioned(){return new Pm(this.property,this.value,null,{},0)}}class Qn{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._options=r,this.isConfigDependent=!1}getValue(e){return z(this._values[e].value.value)}setValue(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Ih(this._values[e].property,this._options)),this._values[e].value=new Tl(this._values[e].property,r===null?void 0:z(r),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,r){r&&(this._options=r);const i=this._properties.properties;if(e)for(const o in e){const s=e[o];if(Bs(o,"-transition")){const n=o.slice(0,-11);i[n]&&this.setTransition(n,s)}else i[o]&&this.setValue(o,s)}}getTransition(e){return z(this._values[e].transition)}setTransition(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Ih(this._values[e].property)),this._values[e].transition=z(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const i=this.getValue(r);i!==void 0&&(e[r]=i);const o=this.getTransition(r);o!==void 0&&(e[`${r}-transition`]=o)}return e}transitioned(e,r){const i=new Rm(this._properties);for(const o of Object.keys(this._values))i._values[o]=this._values[o].transitioned(e,r._values[o]);return i}untransitioned(){const e=new Rm(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Pm{constructor(e,r,i,o,s){const n=o.delay||0,a=o.duration||0;s=s||0,this.property=e,this.value=r,this.begin=s+n,this.end=this.begin+a,e.specification.transition&&(o.delay||o.duration)&&(this.prior=i)}possiblyEvaluate(e,r,i){const o=e.now||0,s=this.value.possiblyEvaluate(e,r,i),n=this.prior;if(n){if(o>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(o<this.begin)return n.possiblyEvaluate(e,r,i);{const a=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,r,i),s,Rs(a))}}return s}}class Rm{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,i){const o=new ea(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(e,r,i);return o}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class fb{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._options=r,this.isConfigDependent=!1}getValue(e){return z(this._values[e].value)}setValue(e,r){this._values[e]=new Tl(this._values[e].property,r===null?void 0:z(r),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].expression.isConfigDependent}serialize(){const e={};for(const r of Object.keys(this._values)){const i=this.getValue(r);i!==void 0&&(e[r]=i)}return e}possiblyEvaluate(e,r,i){const o=new ea(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(e,r,i);return o}}class on{constructor(e,r,i){this.property=e,this.value=r,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,i,o){return this.property.evaluate(this.value,this.parameters,e,r,i,o)}}class ea{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class se{constructor(e){this.specification=e}possiblyEvaluate(e,r){return e.expression.evaluate(r)}interpolate(e,r,i){const o=cl[this.specification.type];return o?o(e,r,i):e}}class ke{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,i,o){return new on(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},i,o)}:e.expression,r)}interpolate(e,r,i){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new on(this,{kind:"constant",value:void 0},e.parameters);const o=cl[this.specification.type];return o?new on(this,{kind:"constant",value:o(e.value.value,r.value.value,i)},e.parameters):e}evaluate(e,r,i,o,s,n){return e.kind==="constant"?e.value:e.evaluate(r,i,o,s,n)}}class ta{constructor(e){this.specification=e}possiblyEvaluate(e,r,i,o){return!!e.expression.evaluate(r,null,{},i,o)}interpolate(){return!1}}class Xt{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const r=new Ut(0,{});for(const i in e){const o=e[i];o.specification.overridable&&this.overridableProperties.push(i);const s=this.defaultPropertyValues[i]=new Tl(o,void 0),n=this.defaultTransitionablePropertyValues[i]=new Ih(o);this.defaultTransitioningPropertyValues[i]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=s.possiblyEvaluate(r)}}}Ee(ke,"DataDrivenProperty"),Ee(se,"DataConstantProperty"),Ee(ta,"ColorRampProperty");const El="";function Lm(t){return t.indexOf(El)>=0}function Dr(t,e){return e?`${t}${El}${e}`:t}function Ml(t){const e=t.indexOf(El);return e>=0?t.slice(0,e):t}const Bm="-transition";class ri extends or{constructor(e,r,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this.options=i,e.slot&&(this.slot=e.slot),r.layout&&(this._unevaluatedLayout=new fb(r.layout,i),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),r.paint)){this._transitionablePaint=new Qn(r.paint,i);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ea(r.paint)}}setScope(e){this.scope=e,this.fqid=Dr(this.id,e)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,i={}){if(r!=null&&this._validate(ab,`layers.${this.id}.layout.${e}`,e,r,i))return;if(this.type==="custom"&&e==="visibility")return void(this.visibility=r);const o=this._unevaluatedLayout;o._properties.properties[e]&&(o.setValue(e,r),this.isConfigDependent=this.isConfigDependent||o.isConfigDependent,e==="visibility"&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return Bs(e,Bm)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,i={}){if(r!=null&&this._validate(nb,`layers.${this.id}.paint.${e}`,e,r,i))return!1;const o=this._transitionablePaint,s=o._properties.properties;if(Bs(e,Bm)){const d=e.slice(0,-11);return s[d]&&o.setTransition(d,r||void 0),!1}if(!s[e])return!1;const n=o._values[e],a=n.value.isDataDriven(),l=n.value;o.setValue(e,r),this.isConfigDependent=this.isConfigDependent||o.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const c=o._values[e].value,u=c.isDataDriven(),h=Bs(e,"pattern")||e==="line-dasharray";return u||a||h||this._handleOverridablePaintPropertyUpdate(e,l,c)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,r){return null}_handleOverridablePaintPropertyUpdate(e,r,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){return le({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,r)=>!(e===void 0||r==="layout"&&!Object.keys(e).length||r==="paint"&&!Object.keys(e).length))}_validate(e,r,i,o,s={}){return(!s||s.validate!==!1)&&bl(this,e.call(Qs,{key:r,layerType:this.type,objectKey:i,value:o,styleSpec:j,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof on&&fs(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=yl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(){this._stats&&(this._stats.numRenderedVerticesInShadowPass=0,this._stats.numRenderedVerticesInTransparentPass=0)}}class mb{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(e,r){this._updatedSourceCaches[e]=r,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const r=e.scope;this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._updatedLayers[r].add(e.id),this.setDirty()}removeLayer(e){const r=e.scope;this._removedLayers[r]=this._removedLayers[r]||{},this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._removedLayers[r][e.id]=e,this._updatedLayers[r].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const r in this._updatedLayers)e[r]=e[r]||{},e[r].updatedIds=Array.from(this._updatedLayers[r].values());for(const r in this._removedLayers)e[r]=e[r]||{},e[r].removedIds=Object.keys(this._removedLayers[r]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}const _b={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Sl{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Vt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function xt(t,e=1){let r=0,i=0;return{members:t.map(o=>{const s=_b[o.type].BYTES_PER_ELEMENT,n=r=Om(r,Math.max(e,s)),a=o.components||1;return i=Math.max(i,s),r+=s*a,{name:o.name,type:o.type,components:a,offset:n}}),size:Om(r,Math.max(i,e)),alignment:e}}function Om(t,e){return Math.ceil(t/e)*e}class Wr extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.int16[o+0]=r,this.int16[o+1]=i,e}}Wr.prototype.bytesPerElement=4,Ee(Wr,"StructArrayLayout2i4");class Al extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.int16[s+0]=r,this.int16[s+1]=i,this.int16[s+2]=o,e}}Al.prototype.bytesPerElement=6,Ee(Al,"StructArrayLayout3i6");class _s extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.int16[n+0]=r,this.int16[n+1]=i,this.int16[n+2]=o,this.int16[n+3]=s,e}}_s.prototype.bytesPerElement=8,Ee(_s,"StructArrayLayout4i8");class Ch extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=5*e;return this.int16[a+0]=r,this.int16[a+1]=i,this.int16[a+2]=o,this.int16[a+3]=s,this.int16[a+4]=n,e}}Ch.prototype.bytesPerElement=10,Ee(Ch,"StructArrayLayout5i10");class zh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=6*e,u=12*e,h=3*e;return this.int16[c+0]=r,this.int16[c+1]=i,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=n,this.uint8[u+7]=a,this.float32[h+2]=l,e}}zh.prototype.bytesPerElement=12,Ee(zh,"StructArrayLayout2i4ub1f12");class lo extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.float32[n+0]=r,this.float32[n+1]=i,this.float32[n+2]=o,this.float32[n+3]=s,e}}lo.prototype.bytesPerElement=16,Ee(lo,"StructArrayLayout4f16");class zo extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=6*e,l=3*e;return this.uint16[a+0]=r,this.uint16[a+1]=i,this.uint16[a+2]=o,this.uint16[a+3]=s,this.float32[l+2]=n,e}}zo.prototype.bytesPerElement=12,Ee(zo,"StructArrayLayout4ui1f12");class Il extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.uint16[n+0]=r,this.uint16[n+1]=i,this.uint16[n+2]=o,this.uint16[n+3]=s,e}}Il.prototype.bytesPerElement=8,Ee(Il,"StructArrayLayout4ui8");class Cl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,i,o,s,n)}emplace(e,r,i,o,s,n,a){const l=6*e;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=o,this.int16[l+3]=s,this.int16[l+4]=n,this.int16[l+5]=a,e}}Cl.prototype.bytesPerElement=12,Ee(Cl,"StructArrayLayout6i12");class Dh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,i,o,s,n,a,l,c,u,h,d)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p){const f=12*e;return this.int16[f+0]=r,this.int16[f+1]=i,this.int16[f+2]=o,this.int16[f+3]=s,this.uint16[f+4]=n,this.uint16[f+5]=a,this.uint16[f+6]=l,this.uint16[f+7]=c,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=d,this.int16[f+11]=p,e}}Dh.prototype.bytesPerElement=24,Ee(Dh,"StructArrayLayout4i4ui4i24");class kh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,i,o,s,n)}emplace(e,r,i,o,s,n,a){const l=10*e,c=5*e;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=o,this.float32[c+2]=s,this.float32[c+3]=n,this.float32[c+4]=a,e}}kh.prototype.bytesPerElement=20,Ee(kh,"StructArrayLayout3i3f20");class Ph extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Ph.prototype.bytesPerElement=4,Ee(Ph,"StructArrayLayout1ul4");class Do extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.uint16[o+0]=r,this.uint16[o+1]=i,e}}Do.prototype.bytesPerElement=4,Ee(Do,"StructArrayLayout2ui4");class Rh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,i,o,s,n,a,l,c,u,h,d,p)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f){const m=20*e,_=10*e;return this.int16[m+0]=r,this.int16[m+1]=i,this.int16[m+2]=o,this.int16[m+3]=s,this.int16[m+4]=n,this.float32[_+3]=a,this.float32[_+4]=l,this.float32[_+5]=c,this.float32[_+6]=u,this.int16[m+14]=h,this.uint32[_+8]=d,this.uint16[m+18]=p,this.uint16[m+19]=f,e}}Rh.prototype.bytesPerElement=40,Ee(Rh,"StructArrayLayout5i4f1i1ul2ui40");class zl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=8*e;return this.int16[c+0]=r,this.int16[c+1]=i,this.int16[c+2]=o,this.int16[c+4]=s,this.int16[c+5]=n,this.int16[c+6]=a,this.int16[c+7]=l,e}}zl.prototype.bytesPerElement=16,Ee(zl,"StructArrayLayout3i2i2i16");class Lh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=4*e,l=8*e;return this.float32[a+0]=r,this.float32[a+1]=i,this.float32[a+2]=o,this.int16[l+6]=s,this.int16[l+7]=n,e}}Lh.prototype.bytesPerElement=16,Ee(Lh,"StructArrayLayout2f1f2i16");class Bh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=12*e,a=3*e;return this.uint8[n+0]=r,this.uint8[n+1]=i,this.float32[a+1]=o,this.float32[a+2]=s,e}}Bh.prototype.bytesPerElement=12,Ee(Bh,"StructArrayLayout2ub2f12");class nr extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.uint16[s+0]=r,this.uint16[s+1]=i,this.uint16[s+2]=o,e}}nr.prototype.bytesPerElement=6,Ee(nr,"StructArrayLayout3ui6");class Oh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w){const T=30*e,E=15*e,M=60*e;return this.int16[T+0]=r,this.int16[T+1]=i,this.int16[T+2]=o,this.float32[E+2]=s,this.float32[E+3]=n,this.uint16[T+8]=a,this.uint16[T+9]=l,this.uint32[E+5]=c,this.uint32[E+6]=u,this.uint32[E+7]=h,this.uint16[T+16]=d,this.uint16[T+17]=p,this.uint16[T+18]=f,this.float32[E+10]=m,this.float32[E+11]=_,this.uint8[M+48]=g,this.uint8[M+49]=y,this.uint8[M+50]=v,this.uint32[E+13]=b,this.int16[T+28]=x,this.uint8[M+58]=w,e}}Oh.prototype.bytesPerElement=60,Ee(Oh,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Fh extends Vt{_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,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O){const U=this.length;return this.resize(U+1),this.emplace(U,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O,U){const R=20*e,B=40*e,G=80*e;return this.float32[R+0]=r,this.float32[R+1]=i,this.int16[B+4]=o,this.int16[B+5]=s,this.int16[B+6]=n,this.int16[B+7]=a,this.int16[B+8]=l,this.int16[B+9]=c,this.int16[B+10]=u,this.int16[B+11]=h,this.int16[B+12]=d,this.uint16[B+13]=p,this.uint16[B+14]=f,this.uint16[B+15]=m,this.uint16[B+16]=_,this.uint16[B+17]=g,this.uint16[B+18]=y,this.uint16[B+19]=v,this.uint16[B+20]=b,this.uint16[B+21]=x,this.uint16[B+22]=w,this.uint16[B+23]=T,this.uint16[B+24]=E,this.uint16[B+25]=M,this.uint16[B+26]=S,this.uint16[B+27]=I,this.uint32[R+14]=C,this.float32[R+15]=k,this.float32[R+16]=A,this.float32[R+17]=L,this.float32[R+18]=O,this.uint8[G+76]=U,e}}Fh.prototype.bytesPerElement=80,Ee(Fh,"StructArrayLayout2f9i15ui1ul4f1ub80");class ra extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}ra.prototype.bytesPerElement=4,Ee(ra,"StructArrayLayout1f4");class gs extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=5*e;return this.float32[a+0]=r,this.float32[a+1]=i,this.float32[a+2]=o,this.float32[a+3]=s,this.float32[a+4]=n,e}}gs.prototype.bytesPerElement=20,Ee(gs,"StructArrayLayout5f20");class Nh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=7*e;return this.float32[c+0]=r,this.float32[c+1]=i,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=n,this.float32[c+5]=a,this.float32[c+6]=l,e}}Nh.prototype.bytesPerElement=28,Ee(Nh,"StructArrayLayout7f28");class Uh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=6*e;return this.uint32[3*e+0]=r,this.uint16[n+2]=i,this.uint16[n+3]=o,this.uint16[n+4]=s,e}}Uh.prototype.bytesPerElement=12,Ee(Uh,"StructArrayLayout1ul3ui12");class ia extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}ia.prototype.bytesPerElement=2,Ee(ia,"StructArrayLayout1ui2");class ys extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.float32[s+0]=r,this.float32[s+1]=i,this.float32[s+2]=o,e}}ys.prototype.bytesPerElement=12,Ee(ys,"StructArrayLayout3f12");class oa extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.float32[o+0]=r,this.float32[o+1]=i,e}}oa.prototype.bytesPerElement=8,Ee(oa,"StructArrayLayout2f8");class Vh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=16*e;return this.float32[y+0]=r,this.float32[y+1]=i,this.float32[y+2]=o,this.float32[y+3]=s,this.float32[y+4]=n,this.float32[y+5]=a,this.float32[y+6]=l,this.float32[y+7]=c,this.float32[y+8]=u,this.float32[y+9]=h,this.float32[y+10]=d,this.float32[y+11]=p,this.float32[y+12]=f,this.float32[y+13]=m,this.float32[y+14]=_,this.float32[y+15]=g,e}}Vh.prototype.bytesPerElement=64,Ee(Vh,"StructArrayLayout16f64");class Dl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=10*e,u=5*e;return this.uint16[c+0]=r,this.uint16[c+1]=i,this.uint16[c+2]=o,this.uint16[c+3]=s,this.float32[u+2]=n,this.float32[u+3]=a,this.float32[u+4]=l,e}}Dl.prototype.bytesPerElement=20,Ee(Dl,"StructArrayLayout4ui3f20");class jh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint8[1*e+0]=r,e}}jh.prototype.bytesPerElement=1,Ee(jh,"StructArrayLayout1ub1");class Fm extends Sl{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]}}Fm.prototype.size=40;class Gh extends Rh{get(e){return new Fm(this,e)}}Ee(Gh,"CollisionBoxArray");class Nm extends Sl{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}}Nm.prototype.size=60;class Um extends Oh{get(e){return new Nm(this,e)}}Ee(Um,"PlacedSymbolArray");class Vm extends Sl{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]}}Vm.prototype.size=80;class jm extends Fh{get(e){return new Vm(this,e)}}Ee(jm,"SymbolInstanceArray");class Gm extends ra{getoffsetX(e){return this.float32[1*e+0]}}Ee(Gm,"GlyphOffsetArray");class qm extends Wr{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ee(qm,"SymbolLineVertexArray");class Zm extends Sl{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]}}Zm.prototype.size=12;class $m extends Uh{get(e){return new Zm(this,e)}}Ee($m,"FeatureIndexArray");class Hm extends Do{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ee(Hm,"FillExtrusionCentroidArray");const gb=xt([{name:"a_pos",components:2,type:"Int16"}],4),yb=xt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Et{constructor(e=[]){this.segments=e}_prepareSegment(e,r,i,o){let s=this.segments[this.segments.length-1];return e>Et.MAX_VERTEX_ARRAY_LENGTH&&F(`Max vertices per segment is ${Et.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>Et.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r,primitiveOffset:i,vertexLength:0,primitiveLength:0},o!==void 0&&(s.sortKey=o),this.segments.push(s)),s}prepareSegment(e,r,i,o){return this._prepareSegment(e,r.length,i.length,o)}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,i,o){return new Et([{vertexOffset:e,primitiveOffset:r,vertexLength:i,primitiveLength:o,vaos:{},sortKey:0}])}}function Wm(t,e){return 256*(t=Se(Math.floor(t),0,255))+Se(Math.floor(e),0,255)}Et.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ee(Et,"SegmentVector");const xb=xt([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),vb=xt([{name:"a_dash",components:4,type:"Uint16"}]);var kl={exports:{}},Xm={exports:{}};(function(t){t.exports=function(e,r){var i,o,s,n,a,l,c,u;for(o=e.length-(i=3&e.length),s=r,a=3432918353,l=461845907,u=0;u<o;)c=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,s=27492+(65535&(n=5*(65535&(s=(s^=c=(65535&(c=(c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295)<<15|c>>>17))*l+(((c>>>16)*l&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(c=0,i){case 3:c^=(255&e.charCodeAt(u+2))<<16;case 2:c^=(255&e.charCodeAt(u+1))<<8;case 1:s^=c=(65535&(c=(c=(65535&(c^=255&e.charCodeAt(u)))*a+(((c>>>16)*a&65535)<<16)&4294967295)<<15|c>>>17))*l+(((c>>>16)*l&65535)<<16)&4294967295}return s^=e.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}})(Xm);var bb=Xm.exports,Ym={exports:{}};(function(t){t.exports=function(e,r){for(var i,o=e.length,s=r^o,n=0;o>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),o-=4,++n;switch(o){case 3:s^=(255&e.charCodeAt(n+2))<<16;case 2:s^=(255&e.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&e.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}})(Ym);var Jm=bb,wb=Ym.exports;kl.exports=Jm,kl.exports.murmur3=Jm,kl.exports.murmur2=wb;var qh=li(kl.exports);class sa{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,r,i,o){this.ids.push(Km(e)),this.positions.push(r,i,o)}eachPosition(e,r){const i=Km(e);let o=0,s=this.ids.length-1;for(;o<s;){const n=o+s>>1;this.ids[n]>=i?s=n:o=n+1}for(;this.ids[o]===i;)r(this.positions[3*o],this.positions[3*o+1],this.positions[3*o+2]),o++}static serialize(e,r){const i=new Float64Array(e.ids),o=new Uint32Array(e.positions);return Zh(i,o,0,i.length-1),r&&(r.add(i.buffer),r.add(o.buffer)),{ids:i,positions:o}}static deserialize(e){const r=new sa;let i;r.ids=e.ids,r.positions=e.positions;for(const o of r.ids)o!==i&&r.uniqueIds.push(o),i=o;return r.indexed=!0,r}}function Km(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:qh(String(t))}function Zh(t,e,r,i){for(;r<i;){const o=t[r+i>>1];let s=r-1,n=i+1;for(;;){do s++;while(t[s]<o);do n--;while(t[n]>o);if(s>=n)break;Pl(t,s,n),Pl(e,3*s,3*n),Pl(e,3*s+1,3*n+1),Pl(e,3*s+2,3*n+2)}n-r<i-n?(Zh(t,e,r,n),r=n+1):(Zh(t,e,n+1,i),i=n)}}function Pl(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}Ee(sa,"FeaturePositionMap");class co{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,r){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,r),this.initialized=!0),!!this.location}}class it extends co{constructor(e){super(e),this.current=0}set(e,r,i){this.fetchUniformLocation(e,r)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class re extends co{constructor(e){super(e),this.current=0}set(e,r,i){this.fetchUniformLocation(e,r)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class ot extends co{constructor(e){super(e),this.current=[0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class He extends co{constructor(e){super(e),this.current=[0,0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class Xr extends co{constructor(e){super(e),this.current=[0,0,0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class sn extends co{constructor(e){super(e),this.current=Qe.transparent}set(e,r,i){this.fetchUniformLocation(e,r)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const Tb=new Float32Array(16);class qe extends co{constructor(e){super(e),this.current=Tb}set(e,r,i){if(this.fetchUniformLocation(e,r)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let o=1;o<16;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const Eb=new Float32Array(9);class $h extends co{constructor(e){super(e),this.current=Eb}set(e,r,i){if(this.fetchUniformLocation(e,r)){for(let o=0;o<9;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}}const Mb=new Float32Array(4);class Hh extends co{constructor(e){super(e),this.current=Mb}set(e,r,i){if(this.fetchUniformLocation(e,r)){for(let o=0;o<4;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}}function Wh(t){return[Wm(255*t.r,255*t.g),Wm(255*t.b,255*t.a)]}class na{constructor(e,r,i){this.value=e,this.uniformNames=r.map(o=>`u_${o}`),this.type=i}setUniform(e,r,i,o,s){r.set(e,s,o.constantOr(this.value))}getBinding(e,r){return this.type==="color"?new sn(e):new re(e)}}class nn{constructor(e,r){this.uniformNames=r.map(i=>`u_${i}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,r,i,o,s){const n=s==="u_pattern"||s==="u_dash"?this.pattern:s==="u_pixel_ratio"?this.pixelRatio:null;n&&r.set(e,s,n)}getBinding(e,r){return r==="u_pattern"||r==="u_dash"?new Xr(e):new re(e)}}class uo{constructor(e,r,i,o){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=r.map(s=>({name:`a_${s}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,r,i,o,s,n,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new Ut(0,{brightness:n}),r,{},s,o,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c)}updatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate({zoom:0,brightness:a},i,o,void 0,s);this._setPaintValue(e,r,l)}_setPaintValue(e,r,i){if(this.type==="color"){const o=Wh(i);for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,o[0],o[1])}else{for(let o=e;o<r;o++)this.paintVertexArray.emplace(o,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}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 Ai{constructor(e,r,i,o,s,n){this.expression=e,this.uniformNames=r.map(a=>`u_${a}_t`),this.type=i,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(a=>({name:`a_${a}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate(new Ut(this.zoom,{brightness:n}),r,{},s,o,a),c=this.expression.evaluate(new Ut(this.zoom+1,{brightness:n}),r,{},s,o,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(u,e,l,c)}updatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate({zoom:this.zoom,brightness:a},i,o,void 0,s),c=this.expression.evaluate({zoom:this.zoom+1,brightness:a},i,o,void 0,s);this._setPaintValue(e,r,l,c)}_setPaintValue(e,r,i,o){if(this.type==="color"){const s=Wh(i),n=Wh(o);for(let a=e;a<r;a++)this.paintVertexArray.emplace(a,s[0],s[1],n[0],n[1])}else{for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,i,o);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(o))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r,i,o,s){const n=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=Se(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);r.set(e,s,a)}getBinding(e,r){return new re(e)}}class ko{constructor(e,r,i,o,s){this.expression=e,this.layerId=s,this.paintVertexAttributes=(i==="array"?vb:xb).members;for(let n=0;n<r.length;++n);this.paintVertexArray=new o}populatePaintArray(e,r,i){const o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(o,e,r.patterns&&r.patterns[this.layerId],i)}updatePaintArray(e,r,i,o,s,n,a){this._setPaintValues(e,r,i.patterns&&i.patterns[this.layerId],n)}_setPaintValues(e,r,i,o){if(!o||!i)return;const s=o[i];if(!s)return;const{tl:n,br:a,pixelRatio:l}=s;for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,n[0],n[1],a[0],a[1],l)}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 xs{constructor(e,r,i=()=>!0){this.binders={},this._buffers=[];const o=[];for(const s in e.paint._values){const n=e.paint.get(s);if(!i(s)||!(n instanceof on&&fs(n.property.specification)))continue;const a=Ab(s,e.type),l=n.value,c=n.property.specification.type,u=!!n.property.useIntegerZoom,h=s==="line-dasharray"||s.endsWith("pattern"),d=s==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(l.kind!=="constant"||d)if(l.kind==="source"||d||h){const p=Qm(s,c,"source");this.binders[s]=h?new ko(l,a,c,p,e.id):new uo(l,a,c,p),o.push(`/a_${s}`)}else{const p=Qm(s,c,"composite");this.binders[s]=new Ai(l,a,c,u,r,p),o.push(`/z_${s}`)}else this.binders[s]=h?new nn(l.value,a):new na(l.value,a,c),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof uo||r instanceof Ai?r.maxValue:0}populatePaintArrays(e,r,i,o,s,n,a){for(const l in this.binders){const c=this.binders[l];(c instanceof uo||c instanceof Ai||c instanceof ko)&&c.populatePaintArray(e,r,i,o,s,n,a)}}setConstantPatternPositions(e){for(const r in this.binders){const i=this.binders[r];i instanceof nn&&i.setConstantPatternPositions(e)}}updatePaintArrays(e,r,i,o,s,n,a,l){let c=!1;const u=Object.keys(e),h=u.length!==0,d=h?u:r.uniqueIds;for(const p in this.binders){const f=this.binders[p];if((f instanceof uo||f instanceof Ai||f instanceof ko)&&(f.expression.isStateDependent===!0||f.expression.isLightConstant===!1)){const m=s.paint.get(p);f.expression=m.value;for(const _ of d){const g=e[_.toString()];r.eachPosition(_,(y,v,b)=>{const x=o.feature(y);f.updatePaintArray(v,b,x,g,n,a,l)})}if(!h)for(const _ of i.uniqueIds){const g=e[_.toString()];i.eachPosition(_,(y,v,b)=>{const x=o.feature(y);f.updatePaintArray(v,b,x,g,n,a,l)})}c=!0}}return c}defines(){const e=[];for(const r in this.binders){const i=this.binders[r];(i instanceof na||i instanceof nn)&&e.push(...i.uniformNames.map(o=>`#define HAS_UNIFORM_${o}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const i=this.binders[r];if(i instanceof uo||i instanceof Ai||i instanceof ko)for(let o=0;o<i.paintVertexAttributes.length;o++)e.push(i.paintVertexAttributes[o].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const i=this.binders[r];if(i instanceof na||i instanceof nn||i instanceof Ai)for(const o of i.uniformNames)e.push(o)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const r=[];for(const i in this.binders){const o=this.binders[i];if(o instanceof na||o instanceof nn||o instanceof Ai)for(const s of o.uniformNames)r.push({name:s,property:i,binding:o.getBinding(e,s)})}return r}setUniforms(e,r,i,o,s){for(const{name:n,property:a,binding:l}of i)this.binders[a].setUniform(e,l,s,o.get(a),n)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const r=this.binders[e];(r instanceof uo||r instanceof Ai||r instanceof ko)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(e){for(const r in this.binders){const i=this.binders[r];(i instanceof uo||i instanceof Ai||i instanceof ko)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof uo||r instanceof Ai||r instanceof ko)&&r.destroy()}}}class Po{constructor(e,r,i=()=>!0){this.programConfigurations={};for(const o of e)this.programConfigurations[o.id]=new xs(o,r,i);this.needsUpload=!1,this._featureMap=new sa,this._featureMapWithoutIds=new sa,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,r,i,o,s,n,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(e,r,o,s,n,a,l);r.id!==void 0?this._featureMap.add(r.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,i,o,s,n){for(const a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,r,a,o,s,n||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Sb={"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 Ab(t,e){return Sb[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Ib={"line-pattern":{source:zo,composite:zo},"fill-pattern":{source:zo,composite:zo},"fill-extrusion-pattern":{source:zo,composite:zo},"line-dasharray":{source:Il,composite:Il}},Cb={color:{source:oa,composite:lo},number:{source:ra,composite:oa}};function Qm(t,e,r){const i=Ib[t];return i&&i[r]||Cb[e][r]}Ee(na,"ConstantBinder"),Ee(nn,"PatternConstantBinder"),Ee(uo,"SourceExpressionBinder"),Ee(ko,"PatternCompositeBinder"),Ee(Ai,"CompositeExpressionBinder"),Ee(xs,"ProgramConfiguration",{omit:["_buffers"]}),Ee(Po,"ProgramConfigurationSet");class Yr{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof 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 r=this._sw,i=this._ne;let o,s;if(e instanceof Ne)o=e,s=e;else{if(!(e instanceof Yr))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Yr.convert(e)):this.extend(Ne.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Ne.convert(e)):this;if(o=e._sw,s=e._ne,!o||!s)return this}return r||i?(r.lng=Math.min(o.lng,r.lng),r.lat=Math.min(o.lat,r.lat),i.lng=Math.max(s.lng,i.lng),i.lat=Math.max(s.lat,i.lat)):(this._sw=new Ne(o.lng,o.lat),this._ne=new Ne(s.lng,s.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:r,lat:i}=Ne.convert(e);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&o}static convert(e){return!e||e instanceof Yr?e:new Yr(e)}}var _r={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.setMatrixArrayType=function(t){gr.ARRAY_TYPE=t_=t},gr.toRadian=function(t){return t*Db},gr.equals=function(t,e){return Math.abs(t-e)<=e_*Math.max(1,Math.abs(t),Math.abs(e))},gr.RANDOM=gr.ARRAY_TYPE=gr.EPSILON=void 0;var e_=1e-6;gr.EPSILON=e_;var t_=typeof Float32Array<"u"?Float32Array:Array;gr.ARRAY_TYPE=t_;var zb=Math.random;gr.RANDOM=zb;var Db=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 jt={};function Xh(t){return Xh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xh(t)}Object.defineProperty(jt,"__esModule",{value:!0}),jt.create=function(){var t=new Ro.ARRAY_TYPE(4);return Ro.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},jt.clone=function(t){var e=new Ro.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},jt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},jt.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},jt.fromValues=function(t,e,r,i){var o=new Ro.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o},jt.set=function(t,e,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t},jt.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},jt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r*s-o*i;return n?(t[0]=s*(n=1/n),t[1]=-i*n,t[2]=-o*n,t[3]=r*n,t):null},jt.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},jt.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},jt.multiply=i_,jt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+s*a,t[1]=o*l+n*a,t[2]=i*-a+s*l,t[3]=o*-a+n*l,t},jt.scale=function(t,e,r){var i=e[1],o=e[2],s=e[3],n=r[0],a=r[1];return t[0]=e[0]*n,t[1]=i*n,t[2]=o*a,t[3]=s*a,t},jt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=-r,t[3]=i,t},jt.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},jt.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},jt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},jt.LDU=function(t,e,r,i){return t[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-t[2]*r[1],[t,e,r]},jt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},jt.subtract=o_,jt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},jt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(r-n)<=Ro.EPSILON*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=Ro.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=Ro.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(s-c)<=Ro.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},jt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},jt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},jt.sub=jt.mul=void 0;var Ro=function(t,e){if(t&&t.__esModule)return t;if(t===null||Xh(t)!=="object"&&typeof t!="function")return{default:t};var r=r_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function r_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(r_=function(i){return i?r:e})(t)}function i_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*a+s*l,t[1]=o*a+n*l,t[2]=i*c+s*u,t[3]=o*c+n*u,t}function o_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}jt.mul=i_,jt.sub=o_;var qt={};function Yh(t){return Yh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yh(t)}Object.defineProperty(qt,"__esModule",{value:!0}),qt.create=function(){var t=new qi.ARRAY_TYPE(6);return qi.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},qt.clone=function(t){var e=new qi.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},qt.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},qt.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},qt.fromValues=function(t,e,r,i,o,s){var n=new qi.ARRAY_TYPE(6);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n[4]=o,n[5]=s,n},qt.set=function(t,e,r,i,o,s,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t},qt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=r*s-i*o;return l?(t[0]=s*(l=1/l),t[1]=-i*l,t[2]=-o*l,t[3]=r*l,t[4]=(o*a-s*n)*l,t[5]=(i*n-r*a)*l,t):null},qt.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},qt.multiply=n_,qt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=Math.sin(r),u=Math.cos(r);return t[0]=i*u+s*c,t[1]=o*u+n*c,t[2]=i*-c+s*u,t[3]=o*-c+n*u,t[4]=a,t[5]=l,t},qt.scale=function(t,e,r){var i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=r[0],c=r[1];return t[0]=e[0]*l,t[1]=i*l,t[2]=o*c,t[3]=s*c,t[4]=n,t[5]=a,t},qt.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=r[0],u=r[1];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=i*c+s*u+a,t[5]=o*c+n*u+l,t},qt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=-r,t[3]=i,t[4]=0,t[5]=0,t},qt.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},qt.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},qt.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},qt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},qt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},qt.subtract=a_,qt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},qt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t},qt.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]},qt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=e[0],c=e[1],u=e[2],h=e[3],d=e[4],p=e[5];return Math.abs(r-l)<=qi.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(i-c)<=qi.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(o-u)<=qi.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(s-h)<=qi.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(n-d)<=qi.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(a-p)<=qi.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))},qt.sub=qt.mul=void 0;var qi=function(t,e){if(t&&t.__esModule)return t;if(t===null||Yh(t)!=="object"&&typeof t!="function")return{default:t};var r=s_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function s_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(s_=function(i){return i?r:e})(t)}function n_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=r[0],u=r[1],h=r[2],d=r[3],p=r[4],f=r[5];return t[0]=i*c+s*u,t[1]=o*c+n*u,t[2]=i*h+s*d,t[3]=o*h+n*d,t[4]=i*p+s*f+a,t[5]=o*p+n*f+l,t}function a_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}qt.mul=n_,qt.sub=a_;var zt={};function Jh(t){return Jh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jh(t)}Object.defineProperty(zt,"__esModule",{value:!0}),zt.create=function(){var t=new ii.ARRAY_TYPE(9);return ii.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},zt.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},zt.clone=function(t){var e=new ii.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},zt.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},zt.fromValues=function(t,e,r,i,o,s,n,a,l){var c=new ii.ARRAY_TYPE(9);return c[0]=t,c[1]=e,c[2]=r,c[3]=i,c[4]=o,c[5]=s,c[6]=n,c[7]=a,c[8]=l,c},zt.set=function(t,e,r,i,o,s,n,a,l,c){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t[8]=c,t},zt.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},zt.transpose=function(t,e){if(t===e){var r=e[1],i=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=i,t[7]=o}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},zt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*n-a*c,d=-u*s+a*l,p=c*s-n*l,f=r*h+i*d+o*p;return f?(t[0]=h*(f=1/f),t[1]=(-u*i+o*c)*f,t[2]=(a*i-o*n)*f,t[3]=d*f,t[4]=(u*r-o*l)*f,t[5]=(-a*r+o*s)*f,t[6]=p*f,t[7]=(-c*r+i*l)*f,t[8]=(n*r-i*s)*f,t):null},zt.adjoint=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=n*u-a*c,t[1]=o*c-i*u,t[2]=i*a-o*n,t[3]=a*l-s*u,t[4]=r*u-o*l,t[5]=o*s-r*a,t[6]=s*c-n*l,t[7]=i*l-r*c,t[8]=r*n-i*s,t},zt.determinant=function(t){var e=t[3],r=t[4],i=t[5],o=t[6],s=t[7],n=t[8];return t[0]*(n*r-i*s)+t[1]*(-n*e+i*o)+t[2]*(s*e-r*o)},zt.multiply=c_,zt.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=r[0],p=r[1];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=a,t[5]=l,t[6]=d*i+p*n+c,t[7]=d*o+p*a+u,t[8]=d*s+p*l+h,t},zt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=Math.sin(r),p=Math.cos(r);return t[0]=p*i+d*n,t[1]=p*o+d*a,t[2]=p*s+d*l,t[3]=p*n-d*i,t[4]=p*a-d*o,t[5]=p*l-d*s,t[6]=c,t[7]=u,t[8]=h,t},zt.scale=function(t,e,r){var i=r[0],o=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},zt.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},zt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=-r,t[4]=i,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},zt.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},zt.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},zt.fromQuat=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r+r,a=i+i,l=o+o,c=r*n,u=i*n,h=i*a,d=o*n,p=o*a,f=o*l,m=s*n,_=s*a,g=s*l;return t[0]=1-h-f,t[3]=u-g,t[6]=d+_,t[1]=u+g,t[4]=1-c-f,t[7]=p-m,t[2]=d-_,t[5]=p+m,t[8]=1-c-h,t},zt.normalFromMat4=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=r*a-i*n,v=r*l-o*n,b=r*c-s*n,x=i*l-o*a,w=i*c-s*a,T=o*c-s*l,E=u*m-h*f,M=u*_-d*f,S=u*g-p*f,I=h*_-d*m,C=h*g-p*m,k=d*g-p*_,A=y*k-v*C+b*I+x*S-w*M+T*E;return A?(t[0]=(a*k-l*C+c*I)*(A=1/A),t[1]=(l*S-n*k-c*M)*A,t[2]=(n*C-a*S+c*E)*A,t[3]=(o*C-i*k-s*I)*A,t[4]=(r*k-o*S+s*M)*A,t[5]=(i*S-r*C-s*E)*A,t[6]=(m*T-_*w+g*x)*A,t[7]=(_*b-f*T-g*v)*A,t[8]=(f*w-m*b+g*y)*A,t):null},zt.projection=function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},zt.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},zt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},zt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},zt.subtract=u_,zt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},zt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t},zt.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]},zt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=e[0],d=e[1],p=e[2],f=e[3],m=e[4],_=e[5],g=e[6],y=e[7],v=e[8];return Math.abs(r-h)<=ii.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-d)<=ii.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(o-p)<=ii.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=ii.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(n-m)<=ii.EPSILON*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(a-_)<=ii.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(l-g)<=ii.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-y)<=ii.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(u-v)<=ii.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))},zt.sub=zt.mul=void 0;var ii=function(t,e){if(t&&t.__esModule)return t;if(t===null||Jh(t)!=="object"&&typeof t!="function")return{default:t};var r=l_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function l_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(l_=function(i){return i?r:e})(t)}function c_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=r[0],p=r[1],f=r[2],m=r[3],_=r[4],g=r[5],y=r[6],v=r[7],b=r[8];return t[0]=d*i+p*n+f*c,t[1]=d*o+p*a+f*u,t[2]=d*s+p*l+f*h,t[3]=m*i+_*n+g*c,t[4]=m*o+_*a+g*u,t[5]=m*s+_*l+g*h,t[6]=y*i+v*n+b*c,t[7]=y*o+v*a+b*u,t[8]=y*s+v*l+b*h,t}function u_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}zt.mul=c_,zt.sub=u_;var Xe={};function Kh(t){return Kh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kh(t)}Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.create=function(){var t=new Yt.ARRAY_TYPE(16);return Yt.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},Xe.clone=function(t){var e=new Yt.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},Xe.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},Xe.fromValues=function(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){var _=new Yt.ARRAY_TYPE(16);return _[0]=t,_[1]=e,_[2]=r,_[3]=i,_[4]=o,_[5]=s,_[6]=n,_[7]=a,_[8]=l,_[9]=c,_[10]=u,_[11]=h,_[12]=d,_[13]=p,_[14]=f,_[15]=m,_},Xe.set=function(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t[8]=c,t[9]=u,t[10]=h,t[11]=d,t[12]=p,t[13]=f,t[14]=m,t[15]=_,t},Xe.identity=d_,Xe.transpose=function(t,e){if(t===e){var r=e[1],i=e[2],o=e[3],s=e[6],n=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=s,t[11]=e[14],t[12]=o,t[13]=n,t[14]=a}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},Xe.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=r*a-i*n,v=r*l-o*n,b=r*c-s*n,x=i*l-o*a,w=i*c-s*a,T=o*c-s*l,E=u*m-h*f,M=u*_-d*f,S=u*g-p*f,I=h*_-d*m,C=h*g-p*m,k=d*g-p*_,A=y*k-v*C+b*I+x*S-w*M+T*E;return A?(t[0]=(a*k-l*C+c*I)*(A=1/A),t[1]=(o*C-i*k-s*I)*A,t[2]=(m*T-_*w+g*x)*A,t[3]=(d*w-h*T-p*x)*A,t[4]=(l*S-n*k-c*M)*A,t[5]=(r*k-o*S+s*M)*A,t[6]=(_*b-f*T-g*v)*A,t[7]=(u*T-d*b+p*v)*A,t[8]=(n*C-a*S+c*E)*A,t[9]=(i*S-r*C-s*E)*A,t[10]=(f*w-m*b+g*y)*A,t[11]=(h*b-u*w-p*y)*A,t[12]=(a*M-n*I-l*E)*A,t[13]=(r*I-i*M+o*E)*A,t[14]=(m*v-f*x-_*y)*A,t[15]=(u*x-h*v+d*y)*A,t):null},Xe.adjoint=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15];return t[0]=a*(d*g-p*_)-h*(l*g-c*_)+m*(l*p-c*d),t[1]=-(i*(d*g-p*_)-h*(o*g-s*_)+m*(o*p-s*d)),t[2]=i*(l*g-c*_)-a*(o*g-s*_)+m*(o*c-s*l),t[3]=-(i*(l*p-c*d)-a*(o*p-s*d)+h*(o*c-s*l)),t[4]=-(n*(d*g-p*_)-u*(l*g-c*_)+f*(l*p-c*d)),t[5]=r*(d*g-p*_)-u*(o*g-s*_)+f*(o*p-s*d),t[6]=-(r*(l*g-c*_)-n*(o*g-s*_)+f*(o*c-s*l)),t[7]=r*(l*p-c*d)-n*(o*p-s*d)+u*(o*c-s*l),t[8]=n*(h*g-p*m)-u*(a*g-c*m)+f*(a*p-c*h),t[9]=-(r*(h*g-p*m)-u*(i*g-s*m)+f*(i*p-s*h)),t[10]=r*(a*g-c*m)-n*(i*g-s*m)+f*(i*c-s*a),t[11]=-(r*(a*p-c*h)-n*(i*p-s*h)+u*(i*c-s*a)),t[12]=-(n*(h*_-d*m)-u*(a*_-l*m)+f*(a*d-l*h)),t[13]=r*(h*_-d*m)-u*(i*_-o*m)+f*(i*d-o*h),t[14]=-(r*(a*_-l*m)-n*(i*_-o*m)+f*(i*l-o*a)),t[15]=r*(a*d-l*h)-n*(i*d-o*h)+u*(i*l-o*a),t},Xe.determinant=function(t){var e=t[0],r=t[1],i=t[2],o=t[3],s=t[4],n=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],f=t[13],m=t[14],_=t[15];return(e*n-r*s)*(h*_-d*m)-(e*a-i*s)*(u*_-d*f)+(e*l-o*s)*(u*m-h*f)+(r*a-i*n)*(c*_-d*p)-(r*l-o*n)*(c*m-h*p)+(i*l-o*a)*(c*f-u*p)},Xe.multiply=p_,Xe.translate=function(t,e,r){var i,o,s,n,a,l,c,u,h,d,p,f,m=r[0],_=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],t[0]=i=e[0],t[1]=o,t[2]=s,t[3]=n,t[4]=a,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=d,t[10]=p,t[11]=f,t[12]=i*m+a*_+h*g+e[12],t[13]=o*m+l*_+d*g+e[13],t[14]=s*m+c*_+p*g+e[14],t[15]=n*m+u*_+f*g+e[15]),t},Xe.scale=function(t,e,r){var i=r[0],o=r[1],s=r[2];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]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Xe.rotate=function(t,e,r,i){var o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C=i[0],k=i[1],A=i[2],L=Math.hypot(C,k,A);return L<Yt.EPSILON?null:(C*=L=1/L,k*=L,A*=L,o=Math.sin(r),s=Math.cos(r),l=e[1],c=e[2],u=e[3],d=e[5],p=e[6],f=e[7],_=e[9],g=e[10],y=e[11],w=C*k*(n=1-s)-A*o,T=k*k*n+s,E=A*k*n+C*o,M=C*A*n+k*o,S=k*A*n-C*o,I=A*A*n+s,t[0]=(a=e[0])*(v=C*C*n+s)+(h=e[4])*(b=k*C*n+A*o)+(m=e[8])*(x=A*C*n-k*o),t[1]=l*v+d*b+_*x,t[2]=c*v+p*b+g*x,t[3]=u*v+f*b+y*x,t[4]=a*w+h*T+m*E,t[5]=l*w+d*T+_*E,t[6]=c*w+p*T+g*E,t[7]=u*w+f*T+y*E,t[8]=a*M+h*S+m*I,t[9]=l*M+d*S+_*I,t[10]=c*M+p*S+g*I,t[11]=u*M+f*S+y*I,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},Xe.rotateX=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[4],n=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+c*i,t[5]=n*o+u*i,t[6]=a*o+h*i,t[7]=l*o+d*i,t[8]=c*o-s*i,t[9]=u*o-n*i,t[10]=h*o-a*i,t[11]=d*o-l*i,t},Xe.rotateY=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[0],n=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-c*i,t[1]=n*o-u*i,t[2]=a*o-h*i,t[3]=l*o-d*i,t[8]=s*i+c*o,t[9]=n*i+u*o,t[10]=a*i+h*o,t[11]=l*i+d*o,t},Xe.rotateZ=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[0],n=e[1],a=e[2],l=e[3],c=e[4],u=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+c*i,t[1]=n*o+u*i,t[2]=a*o+h*i,t[3]=l*o+d*i,t[4]=c*o-s*i,t[5]=u*o-n*i,t[6]=h*o-a*i,t[7]=d*o-l*i,t},Xe.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},Xe.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},Xe.fromRotation=function(t,e,r){var i,o,s,n=r[0],a=r[1],l=r[2],c=Math.hypot(n,a,l);return c<Yt.EPSILON?null:(n*=c=1/c,a*=c,l*=c,i=Math.sin(e),o=Math.cos(e),t[0]=n*n*(s=1-o)+o,t[1]=a*n*s+l*i,t[2]=l*n*s-a*i,t[3]=0,t[4]=n*a*s-l*i,t[5]=a*a*s+o,t[6]=l*a*s+n*i,t[7]=0,t[8]=n*l*s+a*i,t[9]=a*l*s-n*i,t[10]=l*l*s+o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},Xe.fromXRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.fromYRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.fromZRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,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},Xe.fromRotationTranslation=f_,Xe.fromQuat2=function(t,e){var r=new Yt.ARRAY_TYPE(3),i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=i*i+o*o+s*s+n*n;return h>0?(r[0]=2*(a*n+u*i+l*s-c*o)/h,r[1]=2*(l*n+u*o+c*i-a*s)/h,r[2]=2*(c*n+u*s+a*o-l*i)/h):(r[0]=2*(a*n+u*i+l*s-c*o),r[1]=2*(l*n+u*o+c*i-a*s),r[2]=2*(c*n+u*s+a*o-l*i)),f_(t,e,r),t},Xe.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},Xe.getScaling=m_,Xe.getRotation=function(t,e){var r=new Yt.ARRAY_TYPE(3);m_(r,e);var i=1/r[0],o=1/r[1],s=1/r[2],n=e[0]*i,a=e[1]*o,l=e[2]*s,c=e[4]*i,u=e[5]*o,h=e[6]*s,d=e[8]*i,p=e[9]*o,f=e[10]*s,m=n+u+f,_=0;return m>0?(_=2*Math.sqrt(m+1),t[3]=.25*_,t[0]=(h-p)/_,t[1]=(d-l)/_,t[2]=(a-c)/_):n>u&&n>f?(_=2*Math.sqrt(1+n-u-f),t[3]=(h-p)/_,t[0]=.25*_,t[1]=(a+c)/_,t[2]=(d+l)/_):u>f?(_=2*Math.sqrt(1+u-n-f),t[3]=(d-l)/_,t[0]=(a+c)/_,t[1]=.25*_,t[2]=(h+p)/_):(_=2*Math.sqrt(1+f-n-u),t[3]=(a-c)/_,t[0]=(d+l)/_,t[1]=(h+p)/_,t[2]=.25*_),t},Xe.fromRotationTranslationScale=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=e[3],l=o+o,c=s+s,u=n+n,h=o*l,d=o*c,p=o*u,f=s*c,m=s*u,_=n*u,g=a*l,y=a*c,v=a*u,b=i[0],x=i[1],w=i[2];return t[0]=(1-(f+_))*b,t[1]=(d+v)*b,t[2]=(p-y)*b,t[3]=0,t[4]=(d-v)*x,t[5]=(1-(h+_))*x,t[6]=(m+g)*x,t[7]=0,t[8]=(p+y)*w,t[9]=(m-g)*w,t[10]=(1-(h+f))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},Xe.fromRotationTranslationScaleOrigin=function(t,e,r,i,o){var s=e[0],n=e[1],a=e[2],l=e[3],c=s+s,u=n+n,h=a+a,d=s*c,p=s*u,f=s*h,m=n*u,_=n*h,g=a*h,y=l*c,v=l*u,b=l*h,x=i[0],w=i[1],T=i[2],E=o[0],M=o[1],S=o[2],I=(1-(m+g))*x,C=(p+b)*x,k=(f-v)*x,A=(p-b)*w,L=(1-(d+g))*w,O=(_+y)*w,U=(f+v)*T,R=(_-y)*T,B=(1-(d+m))*T;return t[0]=I,t[1]=C,t[2]=k,t[3]=0,t[4]=A,t[5]=L,t[6]=O,t[7]=0,t[8]=U,t[9]=R,t[10]=B,t[11]=0,t[12]=r[0]+E-(I*E+A*M+U*S),t[13]=r[1]+M-(C*E+L*M+R*S),t[14]=r[2]+S-(k*E+O*M+B*S),t[15]=1,t},Xe.fromQuat=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r+r,a=i+i,l=o+o,c=r*n,u=i*n,h=i*a,d=o*n,p=o*a,f=o*l,m=s*n,_=s*a,g=s*l;return t[0]=1-h-f,t[1]=u+g,t[2]=d-_,t[3]=0,t[4]=u-g,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+_,t[9]=p-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.frustum=function(t,e,r,i,o,s,n){var a=1/(r-e),l=1/(o-i),c=1/(s-n);return t[0]=2*s*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*s*l,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+i)*l,t[10]=(n+s)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=n*s*2*c,t[15]=0,t},Xe.perspectiveNO=__,Xe.perspectiveZO=function(t,e,r,i,o){var s,n=1/Math.tan(e/2);return t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0?(t[10]=o*(s=1/(i-o)),t[14]=o*i*s):(t[10]=-1,t[14]=-i),t},Xe.perspectiveFromFieldOfView=function(t,e,r,i){var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),n=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),l=2/(n+a),c=2/(o+s);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(n-a)*l*.5,t[9]=(o-s)*c*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t},Xe.orthoNO=g_,Xe.orthoZO=function(t,e,r,i,o,s,n){var a=1/(e-r),l=1/(i-o),c=1/(s-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*l,t[14]=s*c,t[15]=1,t},Xe.lookAt=function(t,e,r,i){var o,s,n,a,l,c,u,h,d,p,f=e[0],m=e[1],_=e[2],g=i[0],y=i[1],v=i[2],b=r[0],x=r[1],w=r[2];return Math.abs(f-b)<Yt.EPSILON&&Math.abs(m-x)<Yt.EPSILON&&Math.abs(_-w)<Yt.EPSILON?d_(t):(u=f-b,h=m-x,d=_-w,o=y*(d*=p=1/Math.hypot(u,h,d))-v*(h*=p),s=v*(u*=p)-g*d,n=g*h-y*u,(p=Math.hypot(o,s,n))?(o*=p=1/p,s*=p,n*=p):(o=0,s=0,n=0),a=h*n-d*s,l=d*o-u*n,c=u*s-h*o,(p=Math.hypot(a,l,c))?(a*=p=1/p,l*=p,c*=p):(a=0,l=0,c=0),t[0]=o,t[1]=a,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=h,t[7]=0,t[8]=n,t[9]=c,t[10]=d,t[11]=0,t[12]=-(o*f+s*m+n*_),t[13]=-(a*f+l*m+c*_),t[14]=-(u*f+h*m+d*_),t[15]=1,t)},Xe.targetTo=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=i[0],l=i[1],c=i[2],u=o-r[0],h=s-r[1],d=n-r[2],p=u*u+h*h+d*d;p>0&&(u*=p=1/Math.sqrt(p),h*=p,d*=p);var f=l*d-c*h,m=c*u-a*d,_=a*h-l*u;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),t[0]=f,t[1]=m,t[2]=_,t[3]=0,t[4]=h*_-d*m,t[5]=d*f-u*_,t[6]=u*m-h*f,t[7]=0,t[8]=u,t[9]=h,t[10]=d,t[11]=0,t[12]=o,t[13]=s,t[14]=n,t[15]=1,t},Xe.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]+")"},Xe.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])},Xe.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},Xe.subtract=y_,Xe.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},Xe.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t},Xe.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]},Xe.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=e[0],v=e[1],b=e[2],x=e[3],w=e[4],T=e[5],E=e[6],M=e[7],S=e[8],I=e[9],C=e[10],k=e[11],A=e[12],L=e[13],O=e[14],U=e[15];return Math.abs(r-y)<=Yt.EPSILON*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-v)<=Yt.EPSILON*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(o-b)<=Yt.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-x)<=Yt.EPSILON*Math.max(1,Math.abs(s),Math.abs(x))&&Math.abs(n-w)<=Yt.EPSILON*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(a-T)<=Yt.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=Yt.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-M)<=Yt.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(u-S)<=Yt.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-I)<=Yt.EPSILON*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(d-C)<=Yt.EPSILON*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(p-k)<=Yt.EPSILON*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(f-A)<=Yt.EPSILON*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(m-L)<=Yt.EPSILON*Math.max(1,Math.abs(m),Math.abs(L))&&Math.abs(_-O)<=Yt.EPSILON*Math.max(1,Math.abs(_),Math.abs(O))&&Math.abs(g-U)<=Yt.EPSILON*Math.max(1,Math.abs(g),Math.abs(U))},Xe.sub=Xe.mul=Xe.ortho=Xe.perspective=void 0;var Yt=function(t,e){if(t&&t.__esModule)return t;if(t===null||Kh(t)!=="object"&&typeof t!="function")return{default:t};var r=h_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function h_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(h_=function(i){return i?r:e})(t)}function d_(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 p_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=r[0],b=r[1],x=r[2],w=r[3];return t[0]=v*i+b*a+x*h+w*m,t[1]=v*o+b*l+x*d+w*_,t[2]=v*s+b*c+x*p+w*g,t[3]=v*n+b*u+x*f+w*y,t[4]=(v=r[4])*i+(b=r[5])*a+(x=r[6])*h+(w=r[7])*m,t[5]=v*o+b*l+x*d+w*_,t[6]=v*s+b*c+x*p+w*g,t[7]=v*n+b*u+x*f+w*y,t[8]=(v=r[8])*i+(b=r[9])*a+(x=r[10])*h+(w=r[11])*m,t[9]=v*o+b*l+x*d+w*_,t[10]=v*s+b*c+x*p+w*g,t[11]=v*n+b*u+x*f+w*y,t[12]=(v=r[12])*i+(b=r[13])*a+(x=r[14])*h+(w=r[15])*m,t[13]=v*o+b*l+x*d+w*_,t[14]=v*s+b*c+x*p+w*g,t[15]=v*n+b*u+x*f+w*y,t}function f_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=i+i,l=o+o,c=s+s,u=i*a,h=i*l,d=i*c,p=o*l,f=o*c,m=s*c,_=n*a,g=n*l,y=n*c;return t[0]=1-(p+m),t[1]=h+y,t[2]=d-g,t[3]=0,t[4]=h-y,t[5]=1-(u+m),t[6]=f+_,t[7]=0,t[8]=d+g,t[9]=f-_,t[10]=1-(u+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function m_(t,e){var r=e[4],i=e[5],o=e[6],s=e[8],n=e[9],a=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,i,o),t[2]=Math.hypot(s,n,a),t}function __(t,e,r,i,o){var s,n=1/Math.tan(e/2);return t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0?(t[10]=(o+i)*(s=1/(i-o)),t[14]=2*o*i*s):(t[10]=-1,t[14]=-2*i),t}function g_(t,e,r,i,o,s,n){var a=1/(e-r),l=1/(i-o),c=1/(s-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*l,t[14]=(n+s)*c,t[15]=1,t}function y_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}Xe.perspective=__,Xe.ortho=g_,Xe.mul=p_,Xe.sub=y_;var Ze={},We={};function Qh(t){return Qh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qh(t)}Object.defineProperty(We,"__esModule",{value:!0}),We.create=v_,We.clone=function(t){var e=new ho.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},We.length=b_,We.fromValues=function(t,e,r){var i=new ho.ARRAY_TYPE(3);return i[0]=t,i[1]=e,i[2]=r,i},We.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},We.set=function(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t},We.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},We.subtract=w_,We.multiply=T_,We.divide=E_,We.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},We.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},We.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},We.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},We.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},We.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},We.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t},We.distance=M_,We.squaredDistance=S_,We.squaredLength=A_,We.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},We.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},We.normalize=function(t,e){var r=e[0],i=e[1],o=e[2],s=r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},We.dot=I_,We.cross=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[0],a=r[1],l=r[2];return t[0]=o*l-s*a,t[1]=s*n-i*l,t[2]=i*a-o*n,t},We.lerp=function(t,e,r,i){var o=e[0],s=e[1],n=e[2];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t[2]=n+i*(r[2]-n),t},We.hermite=function(t,e,r,i,o,s){var n=s*s,a=n*(2*s-3)+1,l=n*(s-2)+s,c=n*(s-1),u=n*(3-2*s);return t[0]=e[0]*a+r[0]*l+i[0]*c+o[0]*u,t[1]=e[1]*a+r[1]*l+i[1]*c+o[1]*u,t[2]=e[2]*a+r[2]*l+i[2]*c+o[2]*u,t},We.bezier=function(t,e,r,i,o,s){var n=1-s,a=n*n,l=s*s,c=a*n,u=3*s*a,h=3*l*n,d=l*s;return t[0]=e[0]*c+r[0]*u+i[0]*h+o[0]*d,t[1]=e[1]*c+r[1]*u+i[1]*h+o[1]*d,t[2]=e[2]*c+r[2]*u+i[2]*h+o[2]*d,t},We.random=function(t,e){e=e||1;var r=2*ho.RANDOM()*Math.PI,i=2*ho.RANDOM()-1,o=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=i*e,t},We.transformMat4=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[3]*i+r[7]*o+r[11]*s+r[15];return t[0]=(r[0]*i+r[4]*o+r[8]*s+r[12])/(n=n||1),t[1]=(r[1]*i+r[5]*o+r[9]*s+r[13])/n,t[2]=(r[2]*i+r[6]*o+r[10]*s+r[14])/n,t},We.transformMat3=function(t,e,r){var i=e[0],o=e[1],s=e[2];return t[0]=i*r[0]+o*r[3]+s*r[6],t[1]=i*r[1]+o*r[4]+s*r[7],t[2]=i*r[2]+o*r[5]+s*r[8],t},We.transformQuat=function(t,e,r){var i=r[0],o=r[1],s=r[2],n=e[0],a=e[1],l=e[2],c=o*l-s*a,u=s*n-i*l,h=i*a-o*n,d=o*h-s*u,p=s*c-i*h,f=i*u-o*c,m=2*r[3];return u*=m,h*=m,p*=2,f*=2,t[0]=n+(c*=m)+(d*=2),t[1]=a+u+p,t[2]=l+h+f,t},We.rotateX=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(i)-o[2]*Math.sin(i),s[2]=o[1]*Math.sin(i)+o[2]*Math.cos(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.rotateY=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(i)+o[0]*Math.cos(i),s[1]=o[1],s[2]=o[2]*Math.cos(i)-o[0]*Math.sin(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.rotateZ=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(i)-o[1]*Math.sin(i),s[1]=o[0]*Math.sin(i)+o[1]*Math.cos(i),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.angle=function(t,e){var r=t[0],i=t[1],o=t[2],s=e[0],n=e[1],a=e[2],l=Math.sqrt(r*r+i*i+o*o)*Math.sqrt(s*s+n*n+a*a),c=l&&I_(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))},We.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},We.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},We.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},We.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=e[0],n=e[1],a=e[2];return Math.abs(r-s)<=ho.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-n)<=ho.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(o-a)<=ho.EPSILON*Math.max(1,Math.abs(o),Math.abs(a))},We.forEach=We.sqrLen=We.len=We.sqrDist=We.dist=We.div=We.mul=We.sub=void 0;var ho=function(t,e){if(t&&t.__esModule)return t;if(t===null||Qh(t)!=="object"&&typeof t!="function")return{default:t};var r=x_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function x_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(x_=function(i){return i?r:e})(t)}function v_(){var t=new ho.ARRAY_TYPE(3);return ho.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function b_(t){return Math.hypot(t[0],t[1],t[2])}function w_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function T_(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function E_(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function M_(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function S_(t,e){var r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return r*r+i*i+o*o}function A_(t){var e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function I_(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}We.sub=w_,We.mul=T_,We.div=E_,We.dist=M_,We.sqrDist=S_,We.len=b_,We.sqrLen=A_;var po,kb=(po=v_(),function(t,e,r,i,o,s){var n,a;for(e||(e=3),r||(r=0),a=i?Math.min(i*e+r,t.length):t.length,n=r;n<a;n+=e)po[0]=t[n],po[1]=t[n+1],po[2]=t[n+2],o(po,po,s),t[n]=po[0],t[n+1]=po[1],t[n+2]=po[2];return t});We.forEach=kb;var nt={};function ed(t){return ed=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ed(t)}Object.defineProperty(nt,"__esModule",{value:!0}),nt.create=z_,nt.clone=function(t){var e=new mi.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,r,i){var o=new mi.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o},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,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t},nt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},nt.subtract=D_,nt.multiply=k_,nt.divide=P_,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,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},nt.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[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,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},nt.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},nt.distance=R_,nt.squaredDistance=L_,nt.length=B_,nt.squaredLength=O_,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 r=e[0],i=e[1],o=e[2],s=e[3],n=r*r+i*i+o*o+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=r*n,t[1]=i*n,t[2]=o*n,t[3]=s*n,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,r,i){var o=r[0]*i[1]-r[1]*i[0],s=r[0]*i[2]-r[2]*i[0],n=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],l=r[1]*i[3]-r[3]*i[1],c=r[2]*i[3]-r[3]*i[2],u=e[0],h=e[1],d=e[2],p=e[3];return t[0]=h*c-d*l+p*a,t[1]=-u*c+d*n-p*s,t[2]=u*l-h*n+p*o,t[3]=-u*a+h*s-d*o,t},nt.lerp=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=e[3];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t[2]=n+i*(r[2]-n),t[3]=a+i*(r[3]-a),t},nt.random=function(t,e){var r,i,o,s,n,a;e=e||1;do n=(r=2*mi.RANDOM()-1)*r+(i=2*mi.RANDOM()-1)*i;while(n>=1);do a=(o=2*mi.RANDOM()-1)*o+(s=2*mi.RANDOM()-1)*s;while(a>=1);var l=Math.sqrt((1-n)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*o*l,t[3]=e*s*l,t},nt.transformMat4=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3];return t[0]=r[0]*i+r[4]*o+r[8]*s+r[12]*n,t[1]=r[1]*i+r[5]*o+r[9]*s+r[13]*n,t[2]=r[2]*i+r[6]*o+r[10]*s+r[14]*n,t[3]=r[3]*i+r[7]*o+r[11]*s+r[15]*n,t},nt.transformQuat=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[0],a=r[1],l=r[2],c=r[3],u=c*i+a*s-l*o,h=c*o+l*i-n*s,d=c*s+n*o-a*i,p=-n*i-a*o-l*s;return t[0]=u*c+p*-n+h*-l-d*-a,t[1]=h*c+p*-a+d*-n-u*-l,t[2]=d*c+p*-l+u*-a-h*-n,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 r=t[0],i=t[1],o=t[2],s=t[3],n=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(r-n)<=mi.EPSILON*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=mi.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=mi.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(s-c)<=mi.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},nt.forEach=nt.sqrLen=nt.len=nt.sqrDist=nt.dist=nt.div=nt.mul=nt.sub=void 0;var mi=function(t,e){if(t&&t.__esModule)return t;if(t===null||ed(t)!=="object"&&typeof t!="function")return{default:t};var r=C_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function C_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(C_=function(i){return i?r:e})(t)}function z_(){var t=new mi.ARRAY_TYPE(4);return mi.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function D_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function k_(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function P_(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function R_(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function L_(t,e){var r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],s=e[3]-t[3];return r*r+i*i+o*o+s*s}function B_(t){return Math.hypot(t[0],t[1],t[2],t[3])}function O_(t){var e=t[0],r=t[1],i=t[2],o=t[3];return e*e+r*r+i*i+o*o}nt.sub=D_,nt.mul=k_,nt.div=P_,nt.dist=R_,nt.sqrDist=L_,nt.len=B_,nt.sqrLen=O_;var Pb=function(){var t=z_();return function(e,r,i,o,s,n){var a,l;for(r||(r=4),i||(i=0),l=o?Math.min(o*r+i,e.length):e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function td(t){return td=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},td(t)}nt.forEach=Pb,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.create=rd,Ze.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},Ze.setAxisAngle=N_,Ze.getAxisAngle=function(t,e){var r=2*Math.acos(e[3]),i=Math.sin(r/2);return i>vs.EPSILON?(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i):(t[0]=1,t[1]=0,t[2]=0),r},Ze.getAngle=function(t,e){var r=Z_(t,e);return Math.acos(2*r*r-1)},Ze.multiply=U_,Ze.rotateX=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+n*a,t[1]=o*l+s*a,t[2]=s*l-o*a,t[3]=n*l-i*a,t},Ze.rotateY=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l-s*a,t[1]=o*l+n*a,t[2]=s*l+i*a,t[3]=n*l-o*a,t},Ze.rotateZ=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*a,t[1]=o*l-i*a,t[2]=s*l+n*a,t[3]=n*l-s*a,t},Ze.calculateW=function(t,e){var r=e[0],i=e[1],o=e[2];return t[0]=r,t[1]=i,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-o*o)),t},Ze.exp=V_,Ze.ln=j_,Ze.pow=function(t,e,r){return j_(t,e),q_(t,t,r),V_(t,t),t},Ze.slerp=Ll,Ze.random=function(t){var e=vs.RANDOM(),r=vs.RANDOM(),i=vs.RANDOM(),o=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*i),t[3]=s*Math.cos(2*Math.PI*i),t},Ze.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r*r+i*i+o*o+s*s,a=n?1/n:0;return t[0]=-r*a,t[1]=-i*a,t[2]=-o*a,t[3]=s*a,t},Ze.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Ze.fromMat3=G_,Ze.fromEuler=function(t,e,r,i){var o=.5*Math.PI/180;e*=o,r*=o,i*=o;var s=Math.sin(e),n=Math.cos(e),a=Math.sin(r),l=Math.cos(r),c=Math.sin(i),u=Math.cos(i);return t[0]=s*l*u-n*a*c,t[1]=n*a*u+s*l*c,t[2]=n*l*c-s*a*u,t[3]=n*l*u+s*a*c,t},Ze.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Ze.setAxes=Ze.sqlerp=Ze.rotationTo=Ze.equals=Ze.exactEquals=Ze.normalize=Ze.sqrLen=Ze.squaredLength=Ze.len=Ze.length=Ze.lerp=Ze.dot=Ze.scale=Ze.mul=Ze.add=Ze.set=Ze.copy=Ze.fromValues=Ze.clone=void 0;var vs=Rl(gr),Rb=Rl(zt),fo=Rl(We),oi=Rl(nt);function F_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(F_=function(i){return i?r:e})(t)}function Rl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||td(t)!=="object"&&typeof t!="function")return{default:t};var r=F_(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}function rd(){var t=new vs.ARRAY_TYPE(4);return vs.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function N_(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t}function U_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*u+n*a+o*c-s*l,t[1]=o*u+n*l+s*a-i*c,t[2]=s*u+n*c+i*l-o*a,t[3]=n*u-i*a-o*l-s*c,t}function V_(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=Math.sqrt(r*r+i*i+o*o),a=Math.exp(s),l=n>0?a*Math.sin(n)/n:0;return t[0]=r*l,t[1]=i*l,t[2]=o*l,t[3]=a*Math.cos(n),t}function j_(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=Math.sqrt(r*r+i*i+o*o),a=n>0?Math.atan2(n,s)/n:0;return t[0]=r*a,t[1]=i*a,t[2]=o*a,t[3]=.5*Math.log(r*r+i*i+o*o+s*s),t}function Ll(t,e,r,i){var o,s,n,a,l,c=e[0],u=e[1],h=e[2],d=e[3],p=r[0],f=r[1],m=r[2],_=r[3];return(s=c*p+u*f+h*m+d*_)<0&&(s=-s,p=-p,f=-f,m=-m,_=-_),1-s>vs.EPSILON?(o=Math.acos(s),n=Math.sin(o),a=Math.sin((1-i)*o)/n,l=Math.sin(i*o)/n):(a=1-i,l=i),t[0]=a*c+l*p,t[1]=a*u+l*f,t[2]=a*h+l*m,t[3]=a*d+l*_,t}function G_(t,e){var r,i=e[0]+e[4]+e[8];if(i>0)r=Math.sqrt(i+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[3*o+o]&&(o=2);var s=(o+1)%3,n=(o+2)%3;r=Math.sqrt(e[3*o+o]-e[3*s+s]-e[3*n+n]+1),t[o]=.5*r,t[3]=(e[3*s+n]-e[3*n+s])*(r=.5/r),t[s]=(e[3*s+o]+e[3*o+s])*r,t[n]=(e[3*n+o]+e[3*o+n])*r}return t}Ze.clone=oi.clone,Ze.fromValues=oi.fromValues,Ze.copy=oi.copy,Ze.set=oi.set,Ze.add=oi.add,Ze.mul=U_;var q_=oi.scale;Ze.scale=q_;var Z_=oi.dot;Ze.dot=Z_,Ze.lerp=oi.lerp;var $_=oi.length;Ze.length=$_,Ze.len=$_;var H_=oi.squaredLength;Ze.squaredLength=H_,Ze.sqrLen=H_;var id=oi.normalize;Ze.normalize=id,Ze.exactEquals=oi.exactEquals,Ze.equals=oi.equals;var Ii,W_,X_,Lb=(Ii=fo.create(),W_=fo.fromValues(1,0,0),X_=fo.fromValues(0,1,0),function(t,e,r){var i=fo.dot(e,r);return i<-.999999?(fo.cross(Ii,W_,e),fo.len(Ii)<1e-6&&fo.cross(Ii,X_,e),fo.normalize(Ii,Ii),N_(t,Ii,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(fo.cross(Ii,e,r),t[0]=Ii[0],t[1]=Ii[1],t[2]=Ii[2],t[3]=1+i,id(t,t))});Ze.rotationTo=Lb;var od,sd,Bb=(od=rd(),sd=rd(),function(t,e,r,i,o,s){return Ll(od,e,o,s),Ll(sd,r,i,s),Ll(t,od,sd,2*s*(1-s)),t});Ze.sqlerp=Bb;var Ci,Ob=(Ci=Rb.create(),function(t,e,r,i){return Ci[0]=r[0],Ci[3]=r[1],Ci[6]=r[2],Ci[1]=i[0],Ci[4]=i[1],Ci[7]=i[2],Ci[2]=-e[0],Ci[5]=-e[1],Ci[8]=-e[2],id(t,G_(t,Ci))});Ze.setAxes=Ob;var ct={};function nd(t){return nd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nd(t)}Object.defineProperty(ct,"__esModule",{value:!0}),ct.create=function(){var t=new Or.ARRAY_TYPE(8);return Or.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},ct.clone=function(t){var e=new Or.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},ct.fromValues=function(t,e,r,i,o,s,n,a){var l=new Or.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=r,l[3]=i,l[4]=o,l[5]=s,l[6]=n,l[7]=a,l},ct.fromRotationTranslationValues=function(t,e,r,i,o,s,n){var a=new Or.ARRAY_TYPE(8);a[0]=t,a[1]=e,a[2]=r,a[3]=i;var l=.5*o,c=.5*s,u=.5*n;return a[4]=l*i+c*r-u*e,a[5]=c*i+u*t-l*r,a[6]=u*i+l*e-c*t,a[7]=-l*t-c*e-u*r,a},ct.fromRotationTranslation=K_,ct.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},ct.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},ct.fromMat4=function(t,e){var r=mo.create();Y_.getRotation(r,e);var i=new Or.ARRAY_TYPE(3);return Y_.getTranslation(i,e),K_(t,r,i),t},ct.copy=Q_,ct.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},ct.set=function(t,e,r,i,o,s,n,a,l){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t},ct.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},ct.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},ct.getTranslation=function(t,e){var r=e[4],i=e[5],o=e[6],s=e[7],n=-e[0],a=-e[1],l=-e[2],c=e[3];return t[0]=2*(r*c+s*n+i*l-o*a),t[1]=2*(i*c+s*a+o*n-r*l),t[2]=2*(o*c+s*l+r*a-i*n),t},ct.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=.5*r[0],l=.5*r[1],c=.5*r[2],u=e[4],h=e[5],d=e[6],p=e[7];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=n*a+o*c-s*l+u,t[5]=n*l+s*a-i*c+h,t[6]=n*c+i*l-o*a+d,t[7]=-i*a-o*l-s*c+p,t},ct.rotateX=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateX(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateY=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateY(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateZ=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateZ(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateByQuatAppend=function(t,e,r){var i=r[0],o=r[1],s=r[2],n=r[3],a=e[0],l=e[1],c=e[2],u=e[3];return t[0]=a*n+u*i+l*s-c*o,t[1]=l*n+u*o+c*i-a*s,t[2]=c*n+u*s+a*o-l*i,t[3]=u*n-a*i-l*o-c*s,t[4]=(a=e[4])*n+(u=e[7])*i+(l=e[5])*s-(c=e[6])*o,t[5]=l*n+u*o+c*i-a*s,t[6]=c*n+u*s+a*o-l*i,t[7]=u*n-a*i-l*o-c*s,t},ct.rotateByQuatPrepend=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*u+n*a+o*c-s*l,t[1]=o*u+n*l+s*a-i*c,t[2]=s*u+n*c+i*l-o*a,t[3]=n*u-i*a-o*l-s*c,t[4]=i*(u=r[7])+n*(a=r[4])+o*(c=r[6])-s*(l=r[5]),t[5]=o*u+n*l+s*a-i*c,t[6]=s*u+n*c+i*l-o*a,t[7]=n*u-i*a-o*l-s*c,t},ct.rotateAroundAxis=function(t,e,r,i){if(Math.abs(i)<Or.EPSILON)return Q_(t,e);var o=Math.hypot(r[0],r[1],r[2]);i*=.5;var s=Math.sin(i),n=s*r[0]/o,a=s*r[1]/o,l=s*r[2]/o,c=Math.cos(i),u=e[0],h=e[1],d=e[2],p=e[3];t[0]=u*c+p*n+h*l-d*a,t[1]=h*c+p*a+d*n-u*l,t[2]=d*c+p*l+u*a-h*n,t[3]=p*c-u*n-h*a-d*l;var f=e[4],m=e[5],_=e[6],g=e[7];return t[4]=f*c+g*n+m*l-_*a,t[5]=m*c+g*a+_*n-f*l,t[6]=_*c+g*l+f*a-m*n,t[7]=g*c-f*n-m*a-_*l,t},ct.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t},ct.multiply=eg,ct.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t},ct.lerp=function(t,e,r,i){var o=1-i;return tg(e,r)<0&&(i=-i),t[0]=e[0]*o+r[0]*i,t[1]=e[1]*o+r[1]*i,t[2]=e[2]*o+r[2]*i,t[3]=e[3]*o+r[3]*i,t[4]=e[4]*o+r[4]*i,t[5]=e[5]*o+r[5]*i,t[6]=e[6]*o+r[6]*i,t[7]=e[7]*o+r[7]*i,t},ct.invert=function(t,e){var r=Bl(e);return t[0]=-e[0]/r,t[1]=-e[1]/r,t[2]=-e[2]/r,t[3]=e[3]/r,t[4]=-e[4]/r,t[5]=-e[5]/r,t[6]=-e[6]/r,t[7]=e[7]/r,t},ct.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},ct.normalize=function(t,e){var r=Bl(e);if(r>0){r=Math.sqrt(r);var i=e[0]/r,o=e[1]/r,s=e[2]/r,n=e[3]/r,a=e[4],l=e[5],c=e[6],u=e[7],h=i*a+o*l+s*c+n*u;t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=(a-i*h)/r,t[5]=(l-o*h)/r,t[6]=(c-s*h)/r,t[7]=(u-n*h)/r}return t},ct.str=function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},ct.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]},ct.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=e[0],h=e[1],d=e[2],p=e[3],f=e[4],m=e[5],_=e[6],g=e[7];return Math.abs(r-u)<=Or.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-h)<=Or.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=Or.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(s-p)<=Or.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(n-f)<=Or.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(a-m)<=Or.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Or.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Or.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},ct.sqrLen=ct.squaredLength=ct.len=ct.length=ct.dot=ct.mul=ct.setReal=ct.getReal=void 0;var Or=ad(gr),mo=ad(Ze),Y_=ad(Xe);function J_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(J_=function(i){return i?r:e})(t)}function ad(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||nd(t)!=="object"&&typeof t!="function")return{default:t};var r=J_(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}function K_(t,e,r){var i=.5*r[0],o=.5*r[1],s=.5*r[2],n=e[0],a=e[1],l=e[2],c=e[3];return t[0]=n,t[1]=a,t[2]=l,t[3]=c,t[4]=i*c+o*l-s*a,t[5]=o*c+s*n-i*l,t[6]=s*c+i*a-o*n,t[7]=-i*n-o*a-s*l,t}function Q_(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 eg(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[4],l=r[5],c=r[6],u=r[7],h=e[4],d=e[5],p=e[6],f=e[7],m=r[0],_=r[1],g=r[2],y=r[3];return t[0]=i*y+n*m+o*g-s*_,t[1]=o*y+n*_+s*m-i*g,t[2]=s*y+n*g+i*_-o*m,t[3]=n*y-i*m-o*_-s*g,t[4]=i*u+n*a+o*c-s*l+h*y+f*m+d*g-p*_,t[5]=o*u+n*l+s*a-i*c+d*y+f*_+p*m-h*g,t[6]=s*u+n*c+i*l-o*a+p*y+f*g+h*_-d*m,t[7]=n*u-i*a-o*l-s*c+f*y-h*m-d*_-p*g,t}ct.getReal=mo.copy,ct.setReal=mo.copy,ct.mul=eg;var tg=mo.dot;ct.dot=tg;var rg=mo.length;ct.length=rg,ct.len=rg;var Bl=mo.squaredLength;ct.squaredLength=Bl,ct.sqrLen=Bl;var tt={};function ld(t){return ld=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ld(t)}Object.defineProperty(tt,"__esModule",{value:!0}),tt.create=og,tt.clone=function(t){var e=new bs.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},tt.fromValues=function(t,e){var r=new bs.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r},tt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},tt.set=function(t,e,r){return t[0]=e,t[1]=r,t},tt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},tt.subtract=sg,tt.multiply=ng,tt.divide=ag,tt.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},tt.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},tt.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},tt.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},tt.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},tt.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},tt.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},tt.distance=lg,tt.squaredDistance=cg,tt.length=ug,tt.squaredLength=hg,tt.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},tt.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},tt.normalize=function(t,e){var r=e[0],i=e[1],o=r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t},tt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},tt.cross=function(t,e,r){var i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t},tt.lerp=function(t,e,r,i){var o=e[0],s=e[1];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t},tt.random=function(t,e){e=e||1;var r=2*bs.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},tt.transformMat2=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t},tt.transformMat2d=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o+r[4],t[1]=r[1]*i+r[3]*o+r[5],t},tt.transformMat3=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[3]*o+r[6],t[1]=r[1]*i+r[4]*o+r[7],t},tt.transformMat4=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t},tt.rotate=function(t,e,r,i){var o=e[0]-r[0],s=e[1]-r[1],n=Math.sin(i),a=Math.cos(i);return t[0]=o*a-s*n+r[0],t[1]=o*n+s*a+r[1],t},tt.angle=function(t,e){var r=t[0],i=t[1],o=e[0],s=e[1],n=Math.sqrt(r*r+i*i)*Math.sqrt(o*o+s*s);return Math.acos(Math.min(Math.max(n&&(r*o+i*s)/n,-1),1))},tt.zero=function(t){return t[0]=0,t[1]=0,t},tt.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},tt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},tt.equals=function(t,e){var r=t[0],i=t[1],o=e[0],s=e[1];return Math.abs(r-o)<=bs.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=bs.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))},tt.forEach=tt.sqrLen=tt.sqrDist=tt.dist=tt.div=tt.mul=tt.sub=tt.len=void 0;var bs=function(t,e){if(t&&t.__esModule)return t;if(t===null||ld(t)!=="object"&&typeof t!="function")return{default:t};var r=ig(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function ig(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ig=function(i){return i?r:e})(t)}function og(){var t=new bs.ARRAY_TYPE(2);return bs.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function sg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function ng(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function ag(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function lg(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function cg(t,e){var r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function ug(t){return Math.hypot(t[0],t[1])}function hg(t){var e=t[0],r=t[1];return e*e+r*r}tt.len=ug,tt.sub=sg,tt.mul=ng,tt.div=ag,tt.dist=lg,tt.sqrDist=cg,tt.sqrLen=hg;var Fb=function(){var t=og();return function(e,r,i,o,s,n){var a,l;for(r||(r=2),i||(i=0),l=o?Math.min(o*r+i,e.length):e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}}();function cd(t){return cd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cd(t)}tt.forEach=Fb,Object.defineProperty(_r,"__esModule",{value:!0});var Mt=_r.vec4=D=_r.vec3=_r.vec2=_r.quat2=Ar=_r.quat=V=_r.mat4=Fr=_r.mat3=_r.mat2d=an=_r.mat2=_r.glMatrix=void 0,Nb=Zi(gr);_r.glMatrix=Nb;var Ub=Zi(jt),an=_r.mat2=Ub,Vb=Zi(qt);_r.mat2d=Vb;var jb=Zi(zt),Fr=_r.mat3=jb,Gb=Zi(Xe),V=_r.mat4=Gb,qb=Zi(Ze),Ar=_r.quat=qb,Zb=Zi(ct);_r.quat2=Zb;var $b=Zi(tt);_r.vec2=$b;var Hb=Zi(We),D=_r.vec3=Hb,Wb=Zi(nt);function dg(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(dg=function(i){return i?r:e})(t)}function Zi(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||cd(t)!=="object"&&typeof t!="function")return{default:t};var r=dg(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}Mt=_r.vec4=Wb;const Xb=xt([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ol}=Xb,pg=xt([{name:"a_pos_3",components:3,type:"Int16"}]);var Lo=xt([{name:"a_pos",type:"Int16",components:2}]),fg={};(function(t,e){(function(r){function i(s,n,a){var l=o(256*s,256*(n=Math.pow(2,a)-n-1),a),c=o(256*(s+1),256*(n+1),a);return l[0]+","+l[1]+","+c[0]+","+c[1]}function o(s,n,a){var l=2*Math.PI*6378137/256/Math.pow(2,a);return[s*l-2*Math.PI*6378137/2,n*l-2*Math.PI*6378137/2]}r.getURL=function(s,n,a,l,c,u){return u=u||{},s+"?"+["bbox="+i(a,l,c),"format="+(u.format||"image/png"),"service="+(u.service||"WMS"),"version="+(u.version||"1.1.1"),"request="+(u.request||"GetMap"),"srs="+(u.srs||"EPSG:3857"),"width="+(u.width||256),"height="+(u.height||256),"layers="+n].join("&")},r.getTileBBox=i,r.getMercCoords=o,Object.defineProperty(r,"__esModule",{value:!0})})(e)})(0,fg);var Yb=fg;class _i{constructor(e,r,i){this.z=e,this.x=r,this.y=i,this.key=aa(0,e,e,r,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r){const i=Yb.getTileBBox(this.x,this.y,this.z),o=function(s,n,a){let l,c="";for(let u=s;u>0;u--)l=1<<u-1,c+=(n&l?1:0)+(a&l?2:0);return c}(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(r==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",o).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ud{constructor(e,r){this.wrap=e,this.canonical=r,this.key=aa(e,r.z,r.z,r.x,r.y)}}class mt{constructor(e,r,i,o,s){this.overscaledZ=e,this.wrap=r,this.canonical=new _i(i,+o,+s),this.key=r===0&&e===i?this.canonical.key:aa(r,e,i,o,s)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const r=this.canonical.z-e;return e>this.canonical.z?new mt(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new mt(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r=!0){if(this.overscaledZ===e&&r)return this.key;if(e>this.canonical.z)return aa(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return aa(this.wrap*+r,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new mt(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,i=2*this.canonical.x,o=2*this.canonical.y;return[new mt(r,this.wrap,r,i,o),new mt(r,this.wrap,r,i+1,o),new mt(r,this.wrap,r,i,o+1),new mt(r,this.wrap,r,i+1,o+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new mt(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new mt(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 ud(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function aa(t,e,r,i,o){const s=1<<Math.min(r,22);let n=s*(o%s)+i%s;return t&&r<22&&(n+=s*s*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*n+r)+(e-r)}const mg=[t=>{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,r--),new mt(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,r=t.wrap;return e===1<<t.canonical.z&&(e=0,r++),new mt(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>new mt(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(t.canonical.y===0?1<<t.canonical.z:t.canonical.y)-1),t=>new mt(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)];Ee(_i,"CanonicalTileID"),Ee(mt,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});class Fl{constructor(e,r){this.pos=e,this.dir=r}intersectsPlane(e,r,i){const o=D.dot(r,this.dir);if(Math.abs(o)<1e-6)return!1;const s=((e[0]-this.pos[0])*r[0]+(e[1]-this.pos[1])*r[1]+(e[2]-this.pos[2])*r[2])/o;return i[0]=this.pos[0]+this.dir[0]*s,i[1]=this.pos[1]+this.dir[1]*s,i[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(e,r,i){if(D.equals(this.pos,e)||r===0)return i[0]=i[1]=i[2]=0,!1;const[o,s,n]=this.dir,a=this.pos[0]-e[0],l=this.pos[1]-e[1],c=this.pos[2]-e[2],u=o*o+s*s+n*n,h=2*(a*o+l*s+c*n),d=h*h-4*u*(a*a+l*l+c*c-r*r);if(d<0){const p=Math.max(-h/2,0),f=a+o*p,m=l+s*p,_=c+n*p,g=Math.hypot(f,m,_);return i[0]=f*r/g,i[1]=m*r/g,i[2]=_*r/g,!1}{const p=(-h-Math.sqrt(d))/(2*u);if(p<0){const f=Math.hypot(a,l,c);return i[0]=a*r/f,i[1]=l*r/f,i[2]=c*r/f,!1}return i[0]=a+o*p,i[1]=l+s*p,i[2]=c+n*p,!0}}}class hd{constructor(e,r,i,o,s){this.TL=e,this.TR=r,this.BR=i,this.BL=o,this.horizon=s}static fromInvProjectionMatrix(e,r,i){const o=[-1,1,1],s=[1,1,1],n=[1,-1,1],a=[-1,-1,1],l=D.transformMat4(o,o,e),c=D.transformMat4(s,s,e),u=D.transformMat4(n,n,e),h=D.transformMat4(a,a,e);return new hd(l,c,u,h,r/i)}}function la(t,e,r){let i=1/0,o=-1/0;const s=[];for(const n of t){D.sub(s,n,e);const a=D.dot(s,r);i=Math.min(i,a),o=Math.max(o,a)}return[i,o]}function _g(t,e){let r=!0;for(let i=0;i<t.planes.length;i++){const o=t.planes[i];let s=0;for(let n=0;n<e.length;n++)s+=D.dot(o,e[n])+o[3]>=0;if(s===0)return 0;s!==e.length&&(r=!1)}return r?2:1}function gg(t,e){for(const r of t.projections){const i=la(e,t.points[0],r.axis);if(r.projection[1]<i[0]||r.projection[0]>i[1])return 0}return 1}function yg(t,e){let r=0;const i=[0,0,0,0];for(let o=0;o<t.length;o++)i[0]=t[o][0],i[1]=t[o][1],i[2]=t[o][2],i[3]=1,Mt.dot(i,e)>=0&&r++;return r}class _o{constructor(e,r){this.points=e||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=Pt.fromPoints(this.points),this.projections=[],this.frustumEdges=[D.sub([],this.points[2],this.points[3]),D.sub([],this.points[0],this.points[3]),D.sub([],this.points[4],this.points[0]),D.sub([],this.points[5],this.points[1]),D.sub([],this.points[6],this.points[2]),D.sub([],this.points[7],this.points[3])];for(const i of this.frustumEdges){const o=[0,-i[2],i[1]],s=[i[2],0,-i[0]];this.projections.push({axis:o,projection:la(this.points,this.points[0],o)}),this.projections.push({axis:s,projection:la(this.points,this.points[0],s)})}}static fromInvProjectionMatrix(e,r,i,o){const s=Math.pow(2,i),n=[[-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(c=>{const u=Mt.transformMat4([],c,e),h=1/u[3]/r*s;return Mt.mul(u,u,[h,h,o?1/u[3]:h,h])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(c=>{const u=D.sub([],n[c[0]],n[c[1]]),h=D.sub([],n[c[2]],n[c[1]]),d=D.normalize([],D.cross([],u,h)),p=-D.dot(d,n[c[1]]);return d.concat(p)}),l=[];for(let c=0;c<n.length;c++)l.push([n[c][0],n[c][1],n[c][2]]);return new _o(l,a)}intersectsPrecise(e,r,i){for(let o=0;o<r.length;o++)if(!yg(e,r[o]))return 0;for(let o=0;o<this.planes.length;o++)if(!yg(e,this.planes[o]))return 0;for(const o of i)for(const s of this.frustumEdges){const n=D.cross([],o,s),a=D.length(n);if(a===0)continue;D.scale(n,n,1/a);const l=la(this.points,this.points[0],n),c=la(e,this.points[0],n);if(l[0]>c[1]||c[0]>l[1])return 0}return 1}}class Pt{static fromPoints(e){const r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const o of e)D.min(r,r,o),D.max(i,i,o);return new Pt(r,i)}static fromTileIdAndHeight(e,r,i){const o=1<<e.canonical.z,s=e.canonical.x,n=e.canonical.y;return new Pt([s/o,n/o,r],[(s+1)/o,(n+1)/o,i])}static applyTransform(e,r){const i=e.getCorners();for(let o=0;o<i.length;++o)D.transformMat4(i[o],i[o],r);return Pt.fromPoints(i)}static projectAabbCorners(e,r){const i=e.getCorners();for(let o=0;o<i.length;++o)D.transformMat4(i[o],i[o],r);return i}constructor(e,r){this.min=e,this.max=r,this.center=D.scale([],D.add([],this.min,this.max),.5)}quadrant(e){const r=[e%2==0,e<2],i=D.clone(this.min),o=D.clone(this.max);for(let s=0;s<r.length;s++)i[s]=r[s]?this.min[s]:this.center[s],o[s]=r[s]?this.center[s]:this.max[s];return o[2]=this.max[2],new Pt(i,o)}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,r=this.max;return[[e[0],e[1],e[2]],[r[0],e[1],e[2]],[r[0],r[1],e[2]],[e[0],r[1],e[2]],[e[0],e[1],r[2]],[r[0],e[1],r[2]],[r[0],r[1],r[2]],[e[0],r[1],r[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?_g(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?_g(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,r){return r||this.intersects(e)?gg(e,this.getCorners()):0}intersectsPreciseFlat(e,r){return r||this.intersectsFlat(e)?gg(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 r=0;r<3;++r)if(this.min[r]>e.max[r]||e.min[r]>this.max[r])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 r=0;r<3;r++)this.min[r]=Math.min(this.min[r],e.min[r]),this.max[r]=Math.max(this.max[r],e.max[r])}encapsulatePoint(e){for(let r=0;r<3;r++)this.min[r]=Math.min(this.min[r],e[r]),this.max[r]=Math.max(this.max[r],e[r])}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])]}}Ee(Pt,"Aabb");const ca=5,Bo=6,Pr=W/Math.PI/2,Jb=16383,ln=64,dd=[ln,32,16],gi=-Pr,yi=Pr,Kb=[new Pt([gi,gi,gi],[yi,yi,yi]),new Pt([gi,gi,gi],[0,0,yi]),new Pt([0,gi,gi],[yi,0,yi]),new Pt([gi,0,gi],[0,yi,yi]),new Pt([0,0,gi],[yi,yi,yi])];function Nl(t){return t*Pr/un}function xg(t,e,r,i=!0){const o=D.scale([],t._camera.position,t.worldSize),s=[e,r,1,1];Mt.transformMat4(s,s,t.pixelMatrixInverse),Mt.scale(s,s,1/s[3]);const n=D.sub([],s,o),a=D.normalize([],n),l=t.globeMatrix,c=[l[12],l[13],l[14]],u=D.sub([],c,o),h=D.length(u),d=D.normalize([],u),p=t.worldSize/(2*Math.PI),f=D.dot(d,a),m=Math.asin(p/h);if(m<Math.acos(f)){if(!i)return null;const I=[],C=[];D.scale(I,a,h/f),D.normalize(C,D.sub(C,I,u)),D.normalize(a,D.add(a,u,D.scale(a,C,Math.tan(m)*h)))}const _=[];new Fl(o,a).closestPointOnSphere(c,p,_);const g=D.normalize([],$t(l,0)),y=D.normalize([],$t(l,1)),v=D.normalize([],$t(l,2)),b=D.dot(g,_),x=D.dot(y,_),w=D.dot(v,_),T=br(Math.asin(-x/p));let E=br(Math.atan2(b,w));E=t.center.lng+function(I,C){const k=(C-I+180)%360-180;return k<-180?k+360:k}(t.center.lng,E);const M=ur(E),S=Se(dr(T),0,1);return new lt(M,S)}class Qb{constructor(e,r,i){this.a=D.sub([],e,i),this.b=D.sub([],r,i),this.center=i;const o=D.normalize([],this.a),s=D.normalize([],this.b);this.angle=Math.acos(D.dot(o,s))}}function pd(t,e){if(t.angle===0)return null;let r;return r=t.a[e]===0?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)),r<0||r>1?null:function(i,o,s,n){const a=Math.sin(s);return i*(Math.sin((1-n)*s)/a)+o*(Math.sin(n*s)/a)}(t.a[e],t.b[e],t.angle,Se(r,0,1))+t.center[e]}function si(t){if(t.z<=1)return Kb[t.z+2*t.y+t.x];const e=md(Ul(t));return Pt.fromPoints(e)}function go(t,e,r){return D.scale(t,t,1-r),D.scaleAndAdd(t,t,e,r)}function vg(t,e){const r=yr(e.zoom);if(r===0)return si(t);const i=Ul(t),o=md(i),s=ur(i.getWest())*e.worldSize,n=ur(i.getEast())*e.worldSize,a=dr(i.getNorth())*e.worldSize,l=dr(i.getSouth())*e.worldSize,c=[s,a,0],u=[n,a,0],h=[s,l,0],d=[n,l,0],p=V.invert([],e.globeMatrix);return D.transformMat4(c,c,p),D.transformMat4(u,u,p),D.transformMat4(h,h,p),D.transformMat4(d,d,p),o[0]=go(o[0],h,r),o[1]=go(o[1],d,r),o[2]=go(o[2],u,r),o[3]=go(o[3],c,r),Pt.fromPoints(o)}function bg(t,e,r){for(const i of t)D.transformMat4(i,i,e),D.scale(i,i,r)}function fd(t,e,r,i){const o=e/t.worldSize,s=t.globeMatrix;if(r.z<=1){const M=si(r).getCorners();return bg(M,s,o),Pt.fromPoints(M)}const n=Ul(r,i),a=md(n);bg(a,s,o);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(n.contains(t.center)){for(const I of a)D.min(u,u,I),D.max(c,c,I);c[2]=0;const M=t.point,S=[M.x*o,M.y*o,0];return D.min(u,u,S),D.max(c,c,S),new Pt(u,c)}const h=[s[12]*o,s[13]*o,s[14]*o],d=n.getCenter(),p=Se(t.center.lat,-Jt,Jt),f=Se(d.lat,-Jt,Jt),m=ur(t.center.lng),_=dr(p);let g=m-ur(d.lng);const y=_-dr(f);g>.5?g-=1:g<-.5&&(g+=1);let v=0;if(Math.abs(g)>Math.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const M=[s[4]*o,s[5]*o,s[6]*o],S=-Math.sin($e(y>=0?n.getSouth():n.getNorth()))*Pr;D.scaleAndAdd(h,h,M,S)}const b=a[v],x=a[(v+1)%4],w=new Qb(b,x,h),T=[pd(w,0)||b[0],pd(w,1)||b[1],pd(w,2)||b[2]],E=yr(t.zoom);if(E>0){const M=function({x:I,y:C,z:k},A,L,O,U){const R=1/(1<<k);let B=I*R,G=B+R,Z=C*R,q=Z+R,X=0;const Y=(B+G)/2-O;return Y>.5?X=-1:Y<-.5&&(X=1),B=((B+X)*A-(O*=A))*L+O,G=((G+X)*A-O)*L+O,Z=(Z*A-(U*=A))*L+U,q=(q*A-U)*L+U,[[B,q,0],[G,q,0],[G,Z,0],[B,Z,0]]}(r,e,t._pixelsPerMercatorPixel,m,_);for(let I=0;I<a.length;I++)go(a[I],M[I],E);const S=D.add([],M[v],M[(v+1)%4]);D.scale(S,S,.5),go(T,S,E)}for(const M of a)D.min(u,u,M),D.max(c,c,M);return u[2]=Math.min(b[2],x[2]),D.min(u,u,T),D.max(c,c,T),new Pt(u,c)}function Ul({x:t,y:e,z:r},i=!1){const o=1/(1<<r),s=new Ne(Jr(t*o),e===(1<<r)-1&&i?-90:ar((e+1)*o)),n=new Ne(Jr((t+1)*o),e===0&&i?90:ar(e*o));return new Yr(s,n)}function md(t){const e=$e(t.getNorth()),r=$e(t.getSouth()),i=Math.cos(e),o=Math.cos(r),s=Math.sin(e),n=Math.sin(r),a=t.getWest(),l=t.getEast();return[cn(o,n,a),cn(o,n,l),cn(i,s,l),cn(i,s,a)]}function cn(t,e,r,i=Pr){return r=$e(r),[t*Math.sin(r)*i,-e*i,t*Math.cos(r)*i]}function Nr(t,e,r){return cn(Math.cos($e(t)),Math.sin($e(t)),e,r)}function ua(t,e,r,i){const o=1<<r.z,s=(t/W+r.x)/o;return Nr(ar((e/W+r.y)/o),Jr(s),i)}function Vl({min:t,max:e}){return Jb/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const wg=new Float64Array(16);function Oo(t){const e=Vl(t),r=V.fromScaling(wg,[e,e,e]);return V.translate(r,r,D.negate([],t.min))}function _d(t){const e=V.fromTranslation(wg,t.min),r=1/Vl(t);return V.scale(e,e,[r,r,r])}function gd(t){const e=W/(2*Math.PI);return t/(2*Math.PI)/e}function Tg(t,e){return W/(512*Math.pow(2,t))*Vl(si(e))}function Eg(t,e,r,i,o){const s=gd(r),n=[t,e,-r/(2*Math.PI)],a=V.identity(new Float64Array(16));return V.translate(a,a,n),V.scale(a,a,[s,s,s]),V.rotateX(a,a,$e(-o)),V.rotateY(a,a,$e(-i)),a}function Mg(t){const e=t.pixelsPerMeter,r=e/It(1,t.center.lat),i=V.identity(new Float64Array(16));return V.translate(i,i,[t.point.x,t.point.y,0]),V.scale(i,i,[r,r,e]),Float32Array.from(i)}function yr(t){return Fi(ca,Bo,t)}function Sg(t,e,r){const i=V.identity(new Float64Array(16)),o=(e/(1<<t)-.5)*Math.PI*2;return V.rotateY(i,r.globeMatrix,o),Float32Array.from(i)}function Ag(t,e,r){const i=yr(r.zoom),o=t.style.map._antialias,s=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return i===0&&!o&&!s}function Ig(t,e,r,i){const o=e.getNorth(),s=e.getSouth(),n=e.getWest(),a=e.getEast(),l=1<<t.z,c=a-n,u=o-s,h=c/ln,d=-u/dd[r],p=[0,h,0,d,0,0,o,n,0];if(t.z>0){const f=180/i;Fr.multiply(p,p,[f/c+1,0,0,0,f/u+1,0,-.5*f/h,.5*f/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p}function ew(t){const e=Jt-5;t=Se(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin($e(t))),3);return Math.round(r*(dd.length-1))}function Cg(t){const e=[0,0,0],r=V.identity(new Float64Array(16));return V.multiply(r,t.pixelMatrix,t.globeMatrix),D.transformMat4(e,e,r),new N(e[0],e[1])}function zg(t,e){const r=Nr(e.lat,e.lng),i=function(s){const n=Nr(s._center.lat,s._center.lng),a=D.fromValues(0,1,0);let l=D.cross([],a,n);const c=V.fromRotation([],-s.angle,n);l=D.transformMat4(l,l,c),V.fromRotation(c,-s._pitch,l);const u=D.normalize([],n);return D.scale(u,u,Nl(s.cameraToCenterDistance/s.pixelsPerMeter)),D.transformMat4(u,u,c),D.add([],n,u)}(t),o=D.subtract([],i,r);return D.angle(o,r)}function jl(t,e){return zg(t,e)>Math.PI/2*1.01}const Dg=$e(85),tw=Math.cos(Dg),rw=Math.sin(Dg);class iw{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,r){const i=new Wr,o=new nr,s=[],n=e+1+2,a=r[0]+1,l=r[0]+1+(1+r.length),c=(u,h,d)=>{let p=u===n-1?u-2:u===0?u:u-1;return p+=d?24575:0,[p,h]};for(let u=0;u<n;++u)i.emplaceBack(...c(u,0,!0));for(let u=0;u<a;++u)for(let h=0;h<n;++h)i.emplaceBack(...c(h,u,(h===0||h===n-1)&&!0));for(let u=0;u<r.length;++u){const h=r[u];for(let d=0;d<n;++d)i.emplaceBack(...c(d,h,!0))}for(let u=0;u<r.length;++u){const h=o.length,d=r[u]+1+2,p=new nr;for(let _=0;_<d-1;_++){const g=_===d-2,y=g?n*(l-r.length+u-_):n;for(let v=0;v<n-1;v++){const b=_*n+v;_===0||g||v===0||v===n-2?(p.emplaceBack(b+1,b,b+y),p.emplaceBack(b+y,b+y+1,b+1)):(o.emplaceBack(b+1,b,b+y),o.emplaceBack(b+y,b+y+1,b+1))}}const f=Et.simpleSegment(0,h,i.length,o.length-h);for(let _=0;_<p.uint16.length;_+=3)o.emplaceBack(p.uint16[_],p.uint16[_+1],p.uint16[_+2]);const m=Et.simpleSegment(0,h,i.length,o.length-h);s.push({withoutSkirts:f,withSkirts:m})}return{vertices:i,indices:o,segments:s}}_createGrid(e){const r=this._fillGridMeshWithLods(ln,dd);this._gridSegments=r.segments,this._gridBuffer=e.createVertexBuffer(r.vertices,Lo.members),this._gridIndexBuffer=e.createIndexBuffer(r.indices,!0)}_createPoles(e){const r=new nr;for(let a=0;a<=ln;a++)r.emplaceBack(0,a+1,a+2);this._poleIndexBuffer=e.createIndexBuffer(r,!0);const i=new gs,o=new gs,s=new gs,n=new gs;this._poleSegments=[];for(let a=0,l=0;a<ca;a++){const c=360/(1<<a);i.emplaceBack(0,-Pr,0,.5,0),o.emplaceBack(0,-Pr,0,.5,1),s.emplaceBack(0,-Pr,0,.5,.5),n.emplaceBack(0,-Pr,0,.5,.5);for(let u=0;u<=ln;u++){let h=u/ln,d=0;const p=Fe(0,c,h),[f,m,_]=cn(tw,rw,p,Pr);i.emplaceBack(f,m,_,h,d),o.emplaceBack(f,m,_,h,1-d);const g=$e(p);h=.5+.5*Math.sin(g),d=.5+.5*Math.cos(g),s.emplaceBack(f,m,_,h,d),n.emplaceBack(f,m,_,h,1-d)}this._poleSegments.push(Et.simpleSegment(l,0,66,64)),l+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Ol,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(o,Ol,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(s,Ol,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(n,Ol,!1)}getGridBuffers(e,r){return[this._gridBuffer,this._gridIndexBuffer,r?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,r){return[r?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,r?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}}const un=63710088e-1,yd=2*Math.PI*un;class Fo{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fo(Ni(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,i=this.lat*r,o=e.lat*r,s=Math.sin(i)*Math.sin(o)+Math.cos(i)*Math.cos(o)*Math.cos((e.lng-this.lng)*r);return un*Math.acos(Math.min(s,1))}toBounds(e=0){const r=360*e/40075017,i=r/Math.cos(Math.PI/180*this.lat);return new Yr(new Fo(this.lng-i,this.lat-r),new Fo(this.lng+i,this.lat+r))}toEcef(e){const r=Nl(e);return Nr(this.lat,this.lng,Pr+r)}static convert(e){if(e instanceof Fo)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Fo(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Fo(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>]")}}var Ne=Fo;const ow=0,sw=25.5;function Gl(t){return yd*Math.cos(t*Math.PI/180)}function ur(t){return(180+t)/360}function dr(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function It(t,e){return t/Gl(e)}function Jr(t){return 360*t-180}function ar(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function kg(t,e){return t*Gl(ar(e))}const Jt=85.051129;function Pg(t){return Math.cos($e(Se(t,-Jt,Jt)))}function No(t,e){const r=Se(e,ow,sw),i=Math.pow(2,r);return Pg(t)*yd/(512*i)}function xd(t){return 1/Math.cos(t*Math.PI/180)}function ha(t,e=0){const r=Math.exp(Math.PI*(1-(t.y+e/W)/(1<<t.z)*2));return 80150034*r/(r*r+1)/W/(1<<t.z)}class lt{constructor(e,r,i=0){this.x=+e,this.y=+r,this.z=+i}static fromLngLat(e,r=0){const i=Ne.convert(e);return new lt(ur(i.lng),dr(i.lat),It(r,i.lat))}toLngLat(){return new Ne(Jr(this.x),ar(this.y))}toAltitude(){return kg(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/yd*xd(ar(this.y))}}function vd(t,e,r,i,o,s,n,a,l){const c=(e+i)/2,u=(r+o)/2,h=new N(c,u);a(h),function(d,p,f,m,_,g){const y=f-_,v=m-g;return Math.abs((m-p)*y-(f-d)*v)/Math.hypot(y,v)}(h.x,h.y,s.x,s.y,n.x,n.y)>=l?(vd(t,e,r,c,u,s,h,a,l),vd(t,c,u,i,o,h,n,a,l)):t.push(n)}function Rg(t,e,r){let i=t[0],o=i.x,s=i.y;e(i);const n=[i];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:u}=l;e(l),vd(n,o,s,c,u,i,l,e,r),o=c,s=u,i=l}return n}function bd(t,e,r,i){if(i(e,r)){const o=e.add(r)._mult(.5);bd(t,e,o,i),bd(t,o,r,i)}else t.push(r)}function nw(t,e){let r=t[0];const i=[r];for(let o=1;o<t.length;o++){const s=t[o];bd(i,r,s,e),r=s}return i}const wd=Math.pow(2,14)-1,Lg=-wd-1;function aw(t,e){const r=Math.round(t.x*e),i=Math.round(t.y*e);return t.x=Se(r,Lg,wd),t.y=Se(i,Lg,wd),(r<t.x||r>t.x+1||i<t.y||i>t.y+1)&&F("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function $i(t,e,r){const i=t.loadGeometry(),o=t.extent,s=W/o;if(e&&r&&r.projection.isReprojectedInTileSpace){const n=1<<e.z,{scale:a,x:l,y:c,projection:u}=r,h=d=>{const p=Jr((e.x+d.x/o)/n),f=ar((e.y+d.y/o)/n),m=u.project(p,f);d.x=(m.x*a-l)*o,d.y=(m.y*a-c)*o};for(let d=0;d<i.length;d++)if(t.type!==1)i[d]=Rg(i[d],h,1);else{const p=[];for(const f of i[d])f.x<0||f.x>=o||f.y<0||f.y>=o||(h(f),p.push(f));i[d]=p}}for(const n of i)for(const a of n)aw(a,s);return i}function Uo(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?$i(t):[]}}function ql(t,e,r,i,o){t.emplaceBack(2*e+(i+1)/2,2*r+(o+1)/2)}function Zl(t,e,r){t.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class Td{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Wr,this.indexArray=new nr,this.segments=new Et,this.programConfigurations=new Po(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,i,o){const s=this.layers[0],n=[];let a=null;s.type==="circle"&&(a=s.layout.get("circle-sort-key"));for(const{feature:c,id:u,index:h,sourceLayerIndex:d}of e){const p=this.layers[0]._featureFilter.needGeometry,f=Uo(c,p);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),f,i))continue;const m=a?a.evaluate(f,{},i):void 0,_={id:u,properties:c.properties,type:c.type,sourceLayerIndex:d,index:h,geometry:p?f.geometry:$i(c,i,o),patterns:{},sortKey:m};n.push(_)}a&&n.sort((c,u)=>c.sortKey-u.sortKey);let l=null;o.projection.name==="globe"&&(this.globeExtVertexArray=new Cl,l=o.projection);for(const c of n){const{geometry:u,index:h,sourceLayerIndex:d}=c,p=e[h].feature;this.addFeature(c,u,h,r.availableImages,i,l,r.brightness),r.featureIndex.insert(p,u,h,d,this.index)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gb.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,yb.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,r,i,o,s,n,a){for(const l of r)for(const c of l){const u=c.x,h=c.y;if(u<0||u>=W||h<0||h>=W)continue;if(n){const f=n.projectTilePoint(u,h,s),m=n.upVector(s,u,h),_=this.globeExtVertexArray;Zl(_,f,m),Zl(_,f,m),Zl(_,f,m),Zl(_,f,m)}const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),p=d.vertexLength;ql(this.layoutVertexArray,u,h,-1,-1),ql(this.layoutVertexArray,u,h,1,-1),ql(this.layoutVertexArray,u,h,1,1),ql(this.layoutVertexArray,u,h,-1,1),this.indexArray.emplaceBack(p,p+1,p+2),this.indexArray.emplaceBack(p,p+2,p+3),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},o,s,a)}}function Bg(t,e){for(let r=0;r<t.length;r++)if(Vo(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(Vo(t,e[r]))return!0;return!!Ed(t,e)}function lw(t,e,r){return!!Vo(t,e)||!!Md(e,t,r)}function Og(t,e){if(t.length===1)return Ng(e,t[0]);for(let r=0;r<e.length;r++){const i=e[r];for(let o=0;o<i.length;o++)if(Vo(t,i[o]))return!0}for(let r=0;r<t.length;r++)if(Ng(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(Ed(t,e[r]))return!0;return!1}function cw(t,e,r){if(t.length>1){if(Ed(t,e))return!0;for(let i=0;i<e.length;i++)if(Md(e[i],t,r))return!0}for(let i=0;i<t.length;i++)if(Md(t[i],e,r))return!0;return!1}function Ed(t,e){if(t.length===0||e.length===0)return!1;for(let r=0;r<t.length-1;r++){const i=t[r],o=t[r+1];for(let s=0;s<e.length-1;s++)if(uw(i,o,e[s],e[s+1]))return!0}return!1}function uw(t,e,r,i){return te(t,r,i)!==te(e,r,i)&&te(t,e,r)!==te(t,e,i)}function Md(t,e,r){const i=r*r;if(e.length===1)return t.distSqr(e[0])<i;for(let o=1;o<e.length;o++)if(Fg(t,e[o-1],e[o])<i)return!0;return!1}function Fg(t,e,r){const i=e.distSqr(r);if(i===0)return t.distSqr(e);const o=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/i;return t.distSqr(o<0?e:o>1?r:r.sub(e)._mult(o)._add(e))}function Ng(t,e){let r,i,o,s=!1;for(let n=0;n<t.length;n++){r=t[n];for(let a=0,l=r.length-1;a<r.length;l=a++)i=r[a],o=r[l],i.y>e.y!=o.y>e.y&&e.x<(o.x-i.x)*(e.y-i.y)/(o.y-i.y)+i.x&&(s=!s)}return s}function Vo(t,e){let r=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const s=t[i],n=t[o];s.y>e.y!=n.y>e.y&&e.x<(n.x-s.x)*(e.y-s.y)/(n.y-s.y)+s.x&&(r=!r)}return r}function Ug(t,e,r,i,o){for(const n of t)if(e<=n.x&&r<=n.y&&i>=n.x&&o>=n.y)return!0;const s=[new N(e,r),new N(e,o),new N(i,o),new N(i,r)];if(t.length>2){for(const n of s)if(Vo(t,n))return!0}for(let n=0;n<t.length-1;n++)if(hw(t[n],t[n+1],s))return!0;return!1}function hw(t,e,r){const i=r[0],o=r[2];if(t.x<i.x&&e.x<i.x||t.x>o.x&&e.x>o.x||t.y<i.y&&e.y<i.y||t.y>o.y&&e.y>o.y)return!1;const s=te(t,e,r[0]);return s!==te(t,e,r[1])||s!==te(t,e,r[2])||s!==te(t,e,r[3])}function hn(t,e,r,i,o,s){let n=e.y-t.y,a=t.x-e.x;if(s=s||0){const l=n*n+a*a;if(l===0)return!0;const c=Math.sqrt(l);n/=c,a/=c}return!((r.x-t.x)*n+(r.y-t.y)*a-s<0||(i.x-t.x)*n+(i.y-t.y)*a-s<0||(o.x-t.x)*n+(o.y-t.y)*a-s<0)}function Sd(t,e,r,i,o,s,n){return!(hn(t,e,i,o,s,n)||hn(e,r,i,o,s,n)||hn(r,t,i,o,s,n)||hn(i,o,t,e,r,n)||hn(o,s,t,e,r,n)||hn(s,i,t,e,r,n))}function dn(t,e,r){const i=e.paint.get(t).value;return i.kind==="constant"?i.value:r.programConfigurations.get(e.id).getMaxValue(t)}function $l(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Vg(t,e,r,i,o){if(!e[0]&&!e[1])return t;const s=N.convert(e)._mult(o);r==="viewport"&&s._rotate(-i);const n=[];for(let a=0;a<t.length;a++)n.push(t[a].sub(s));return n}function jg(t,e,r,i){const o=N.convert(t)._mult(i);return e==="viewport"&&o._rotate(-r),o}Ee(Td,"CircleBucket",{omit:["layers"]});const dw=new Xt({"circle-sort-key":new ke(j.layout_circle["circle-sort-key"]),visibility:new se(j.layout_circle.visibility)});var pw={paint:new Xt({"circle-radius":new ke(j.paint_circle["circle-radius"]),"circle-color":new ke(j.paint_circle["circle-color"]),"circle-blur":new ke(j.paint_circle["circle-blur"]),"circle-opacity":new ke(j.paint_circle["circle-opacity"]),"circle-translate":new se(j.paint_circle["circle-translate"]),"circle-translate-anchor":new se(j.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new se(j.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new se(j.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ke(j.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ke(j.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ke(j.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new se(j.paint_circle["circle-emissive-strength"])}),layout:dw};const fw=V.create(),mw=(t,e,r,i,o,s)=>{const n=t.transform,a=n.projection.name==="globe";let l;if(s.paint.get("circle-pitch-alignment")==="map")if(a){const u=Tg(n.zoom,e.canonical)*n._pixelsPerMercatorPixel;l=Float32Array.from([u,0,0,u])}else l=n.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([n.pixelsToGLUnits[0],0,0,n.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(n.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:je.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:fw,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],c.u_zoom_transition=yr(n.zoom);const u=o[0]*W,h=o[1]*W;c.u_up_dir=n.projection.upVector(new _i(0,0,0),u,h)}return c},Gg=t=>{const e=[];return t.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),t.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function qg(t,e,r,i,o,s,n,a,l){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=r.projection.upVectorScale(c,r.center.lat,r.worldSize).metersToTile;for(const h of e)for(const d of h){const p=d.add(a),f=o&&r.elevation?r.elevation.exaggeration()*o.getElevationAt(p.x,p.y,!0):0,m=r.projection.projectTilePoint(p.x,p.y,c);if(f>0){const v=r.projection.upVector(c,p.x,p.y);m.x+=v[0]*u*f,m.y+=v[1]*u*f,m.z+=v[2]*u*f}const _=s?p:_w(m.x,m.y,m.z,i),g=s?t.tilespaceRays.map(v=>yw(v,f)):t.queryGeometry.screenGeometry,y=Mt.transformMat4([],[m.x,m.y,m.z,1],i);if(!n&&s?l*=y[3]/r.cameraToCenterDistance:n&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const v=ar((d.y/W+c.y)/(1<<c.z));l/=r.projection.pixelsPerMeter(v,1)/It(1,v)}if(lw(g,_,l))return!0}return!1}function _w(t,e,r,i){const o=Mt.transformMat4([],[t,e,r,1],i);return new N(o[0]/o[3],o[1]/o[3])}const Zg=D.fromValues(0,0,0),gw=D.fromValues(0,0,1);function yw(t,e){const r=D.create();return Zg[2]=e,t.intersectsPlane(Zg,gw,r),new N(r[0],r[1])}class $g extends Td{}function Hg(t,{width:e,height:r},i,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==e*r*i)throw new RangeError("mismatched image size")}else o=new Uint8Array(e*r*i);return t.width=e,t.height=r,t.data=o,t}function Wg(t,e,r){const{width:i,height:o}=e;i===t.width&&o===t.height||(Ad(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,i),height:Math.min(t.height,o)},r),t.width=i,t.height=o,t.data=e.data)}function Ad(t,e,r,i,o,s){if(o.width===0||o.height===0)return e;if(o.width>t.width||o.height>t.height||r.x>t.width-o.width||r.y>t.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||i.x>e.width-o.width||i.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const n=t.data,a=e.data;for(let l=0;l<o.height;l++){const c=((r.y+l)*t.width+r.x)*s,u=((i.y+l)*e.width+i.x)*s;for(let h=0;h<o.width*s;h++)a[u+h]=n[c+h]}return e}Ee($g,"HeatmapBucket",{omit:["layers"]});class yo{constructor(e,r){Hg(this,e,1,r)}resize(e){Wg(this,new yo(e),1)}clone(){return new yo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,o,s){Ad(e,r,i,o,s,1)}}class ir{constructor(e,r){Hg(this,e,4,r)}resize(e){Wg(this,new ir(e),4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new ir({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,o,s){Ad(e,r,i,o,s,4)}}class Xg{constructor(e,r){this.width=e.width,this.height=e.height,this.data=r instanceof Uint8Array?new Float32Array(r.buffer):r}}Ee(yo,"AlphaImage"),Ee(ir,"RGBAImage");const xw=new Xt({visibility:new se(j.layout_heatmap.visibility)});var vw={paint:new Xt({"heatmap-radius":new ke(j.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ke(j.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new se(j.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ta(j.paint_heatmap["heatmap-color"]),"heatmap-opacity":new se(j.paint_heatmap["heatmap-opacity"])}),layout:xw};function Hl(t){const e={},r=t.resolution||256,i=t.clips?t.clips.length:1,o=t.image||new ir({width:r,height:i}),s=(n,a,l)=>{e[t.evaluationKey]=l;const c=t.expression.evaluate(e);c&&(o.data[n+a+0]=Math.floor(255*c.r/c.a),o.data[n+a+1]=Math.floor(255*c.g/c.a),o.data[n+a+2]=Math.floor(255*c.b/c.a),o.data[n+a+3]=Math.floor(255*c.a))};if(t.clips)for(let n=0,a=0;n<i;++n,a+=4*r)for(let l=0,c=0;l<r;l++,c+=4){const u=l/(r-1),{start:h,end:d}=t.clips[n];s(a,c,h*(1-u)+d*u)}else for(let n=0,a=0;n<r;n++,a+=4)s(0,a,n/(r-1));return o}const bw=new Xt({visibility:new se(j.layout_hillshade.visibility)});var ww={paint:new Xt({"hillshade-illumination-direction":new se(j.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new se(j.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new se(j.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new se(j.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new se(j.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new se(j.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new se(j.paint_hillshade["hillshade-emissive-strength"])}),layout:bw};const Tw=xt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ew}=Tw;var Id={exports:{}};function Wl(t,e,r){r=r||2;var i,o,s,n,a,l,c,u=e&&e.length,h=u?e[0]*r:t.length,d=Yg(t,0,h,r,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(m,_,g,y){var v,b,x,w=[];for(v=0,b=_.length;v<b;v++)(x=Yg(m,_[v]*y,v<b-1?_[v+1]*y:m.length,y,!1))===x.next&&(x.steiner=!0),w.push(kw(x));for(w.sort(Cw),v=0;v<w.length;v++)g=zw(w[v],g);return g}(t,e,d,r)),t.length>80*r){i=s=t[0],o=n=t[1];for(var f=r;f<h;f+=r)(a=t[f])<i&&(i=a),(l=t[f+1])<o&&(o=l),a>s&&(s=a),l>n&&(n=l);c=(c=Math.max(s-i,n-o))!==0?32767/c:0}return da(d,p,r,i,o,c,0),p}function Yg(t,e,r,i,o){var s,n;if(o===Dd(t,e,r,i)>0)for(s=e;s<r;s+=i)n=Qg(s,t[s],t[s+1],n);else for(s=r-i;s>=e;s-=i)n=Qg(s,t[s],t[s+1],n);return n&&Xl(n,n.next)&&(fa(n),n=n.next),n}function ws(t,e){if(!t)return t;e||(e=t);var r,i=t;do if(r=!1,i.steiner||!Xl(i,i.next)&&hr(i.prev,i,i.next)!==0)i=i.next;else{if(fa(i),(i=e=i.prev)===i.next)break;r=!0}while(r||i!==e);return e}function da(t,e,r,i,o,s,n){if(t){!n&&s&&function(u,h,d,p){var f=u;do f.z===0&&(f.z=Cd(f.x,f.y,h,d,p)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==u);f.prevZ.nextZ=null,f.prevZ=null,function(m){var _,g,y,v,b,x,w,T,E=1;do{for(g=m,m=null,b=null,x=0;g;){for(x++,y=g,w=0,_=0;_<E&&(w++,y=y.nextZ);_++);for(T=E;w>0||T>0&&y;)w!==0&&(T===0||!y||g.z<=y.z)?(v=g,g=g.nextZ,w--):(v=y,y=y.nextZ,T--),b?b.nextZ=v:m=v,v.prevZ=b,b=v;g=y}b.nextZ=null,E*=2}while(x>1)}(f)}(t,i,o,s);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?Sw(t,i,o,s):Mw(t))e.push(a.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),fa(t),t=l.next,c=l.next;else if((t=l)===c){n?n===1?da(t=Aw(ws(t),e,r),e,r,i,o,s,2):n===2&&Iw(t,e,r,i,o,s):da(ws(t),e,r,i,o,s,1);break}}}function Mw(t){var e=t.prev,r=t,i=t.next;if(hr(e,r,i)>=0)return!1;for(var o=e.x,s=r.x,n=i.x,a=e.y,l=r.y,c=i.y,u=o<s?o<n?o:n:s<n?s:n,h=a<l?a<c?a:c:l<c?l:c,d=o>s?o>n?o:n:s>n?s:n,p=a>l?a>c?a:c:l>c?l:c,f=i.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&pn(o,a,s,l,n,c,f.x,f.y)&&hr(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Sw(t,e,r,i){var o=t.prev,s=t,n=t.next;if(hr(o,s,n)>=0)return!1;for(var a=o.x,l=s.x,c=n.x,u=o.y,h=s.y,d=n.y,p=a<l?a<c?a:c:l<c?l:c,f=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,_=u>h?u>d?u:d:h>d?h:d,g=Cd(p,f,e,r,i),y=Cd(m,_,e,r,i),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==o&&v!==n&&pn(a,u,l,h,c,d,v.x,v.y)&&hr(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=_&&b!==o&&b!==n&&pn(a,u,l,h,c,d,b.x,b.y)&&hr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==o&&v!==n&&pn(a,u,l,h,c,d,v.x,v.y)&&hr(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=_&&b!==o&&b!==n&&pn(a,u,l,h,c,d,b.x,b.y)&&hr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Aw(t,e,r){var i=t;do{var o=i.prev,s=i.next.next;!Xl(o,s)&&Jg(o,i,i.next,s)&&pa(o,s)&&pa(s,o)&&(e.push(o.i/r|0),e.push(i.i/r|0),e.push(s.i/r|0),fa(i),fa(i.next),i=t=s),i=i.next}while(i!==t);return ws(i)}function Iw(t,e,r,i,o,s){var n=t;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&Pw(n,a)){var l=Kg(n,a);return n=ws(n,n.next),l=ws(l,l.next),da(n,e,r,i,o,s,0),void da(l,e,r,i,o,s,0)}a=a.next}n=n.next}while(n!==t)}function Cw(t,e){return t.x-e.x}function zw(t,e){var r=function(o,s){var n,a=s,l=o.x,c=o.y,u=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var h=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(h<=l&&h>u&&(u=h,n=a.x<a.next.x?a:a.next,h===l))return n}a=a.next}while(a!==s);if(!n)return null;var d,p=n,f=n.x,m=n.y,_=1/0;a=n;do l>=a.x&&a.x>=f&&l!==a.x&&pn(c<m?l:u,c,f,m,c<m?u:l,c,a.x,a.y)&&(d=Math.abs(c-a.y)/(l-a.x),pa(a,o)&&(d<_||d===_&&(a.x>n.x||a.x===n.x&&Dw(n,a)))&&(n=a,_=d)),a=a.next;while(a!==p);return n}(t,e);if(!r)return e;var i=Kg(r,t);return ws(i,i.next),ws(r,r.next)}function Dw(t,e){return hr(t.prev,t,e.prev)<0&&hr(e.next,t,t.next)<0}function Cd(t,e,r,i,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function kw(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function pn(t,e,r,i,o,s,n,a){return(o-n)*(e-a)>=(t-n)*(s-a)&&(t-n)*(i-a)>=(r-n)*(e-a)&&(r-n)*(s-a)>=(o-n)*(i-a)}function Pw(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(r,i){var o=r;do{if(o.i!==r.i&&o.next.i!==r.i&&o.i!==i.i&&o.next.i!==i.i&&Jg(o,o.next,r,i))return!0;o=o.next}while(o!==r);return!1}(t,e)&&(pa(t,e)&&pa(e,t)&&function(r,i){var o=r,s=!1,n=(r.x+i.x)/2,a=(r.y+i.y)/2;do o.y>a!=o.next.y>a&&o.next.y!==o.y&&n<(o.next.x-o.x)*(a-o.y)/(o.next.y-o.y)+o.x&&(s=!s),o=o.next;while(o!==r);return s}(t,e)&&(hr(t.prev,t,e.prev)||hr(t,e.prev,e))||Xl(t,e)&&hr(t.prev,t,t.next)>0&&hr(e.prev,e,e.next)>0)}function hr(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Xl(t,e){return t.x===e.x&&t.y===e.y}function Jg(t,e,r,i){var o=Jl(hr(t,e,r)),s=Jl(hr(t,e,i)),n=Jl(hr(r,i,t)),a=Jl(hr(r,i,e));return o!==s&&n!==a||!(o!==0||!Yl(t,r,e))||!(s!==0||!Yl(t,i,e))||!(n!==0||!Yl(r,t,i))||!(a!==0||!Yl(r,e,i))}function Yl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Jl(t){return t>0?1:t<0?-1:0}function pa(t,e){return hr(t.prev,t,t.next)<0?hr(t,e,t.next)>=0&&hr(t,t.prev,e)>=0:hr(t,e,t.prev)<0||hr(t,t.next,e)<0}function Kg(t,e){var r=new zd(t.i,t.x,t.y),i=new zd(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=o,o.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function Qg(t,e,r,i){var o=new zd(t,e,r);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function fa(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 zd(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Dd(t,e,r,i){for(var o=0,s=e,n=r-i;s<r;s+=i)o+=(t[n]-t[s])*(t[s+1]+t[n+1]),n=s;return o}Id.exports=Wl,Id.exports.default=Wl,Wl.deviation=function(t,e,r,i){var o=e&&e.length,s=Math.abs(Dd(t,0,o?e[0]*r:t.length,r));if(o)for(var n=0,a=e.length;n<a;n++)s-=Math.abs(Dd(t,e[n]*r,n<a-1?e[n+1]*r:t.length,r));var l=0;for(n=0;n<i.length;n+=3){var c=i[n]*r,u=i[n+1]*r,h=i[n+2]*r;l+=Math.abs((t[c]-t[h])*(t[u+1]-t[c+1])-(t[c]-t[u])*(t[h+1]-t[c+1]))}return s===0&&l===0?0:Math.abs((l-s)/s)},Wl.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},i=0,o=0;o<t.length;o++){for(var s=0;s<t[o].length;s++)for(var n=0;n<e;n++)r.vertices.push(t[o][s][n]);o>0&&r.holes.push(i+=t[o-1].length)}return r};var Kl=li(Id.exports);function kd(t,e){const r=t.length;if(r<=1)return[t];const i=[];let o,s;for(let n=0;n<r;n++){const a=ie(t[n]);a!==0&&(t[n].area=Math.abs(a),s===void 0&&(s=a<0),s===a<0?(o&&i.push(o),o=[t[n]]):o.push(t[n]))}if(o&&i.push(o),e>1)for(let n=0;n<i.length;n++)i[n].length<=e||(_v(i[n],e,1,i[n].length-1,Rw),i[n]=i[n].slice(0,e));return i}function Rw(t,e){return e.area-t.area}function Pd(t,e,r){const i=r.patternDependencies;let o=!1;for(const s of e){const n=s.paint.get(`${t}-pattern`);n.isConstant()||(o=!0);const a=n.constantOr(null);a&&(o=!0,i[a]=!0)}return o}function Rd(t,e,r,i,o){const s=o.patternDependencies;for(const n of e){const a=n.paint.get(`${t}-pattern`).value;if(a.kind!=="constant"){let l=a.evaluate({zoom:i},r,{},o.availableImages);l=l&&l.name?l.name:l,s[l]=!0,r.patterns[n.id]=l}}return r}class Ql{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Wr,this.indexArray=new nr,this.indexArray2=new Do,this.programConfigurations=new Po(e.layers,e.zoom),this.segments=new Et,this.segments2=new Et,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.projection=e.projection}populate(e,r,i,o){this.hasPattern=Pd("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),n=[];for(const{feature:a,id:l,index:c,sourceLayerIndex:u}of e){const h=this.layers[0]._featureFilter.needGeometry,d=Uo(a,h);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),d,i))continue;const p=s?s.evaluate(d,{},i,r.availableImages):void 0,f={id:l,properties:a.properties,type:a.type,sourceLayerIndex:u,index:c,geometry:h?d.geometry:$i(a,i,o),patterns:{},sortKey:p};n.push(f)}s&&n.sort((a,l)=>a.sortKey-l.sortKey);for(const a of n){const{geometry:l,index:c,sourceLayerIndex:u}=a;if(this.hasPattern){const h=Rd("fill",this.layers,a,this.zoom,r);this.patternFeatures.push(h)}else this.addFeature(a,l,c,i,{},r.availableImages,r.brightness);r.featureIndex.insert(e[c].feature,l,c,u,this.index)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}addFeatures(e,r,i,o,s,n){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,r,i,o,n)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ew),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,i,o,s,n=[],a){for(const l of kd(r,500)){let c=0;for(const m of l)c+=m.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),h=u.vertexLength,d=[],p=[];for(const m of l){if(m.length===0)continue;m!==l[0]&&p.push(d.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),d.push(m[0].x),d.push(m[0].y);for(let y=1;y<m.length;y++)this.layoutVertexArray.emplaceBack(m[y].x,m[y].y),this.indexArray2.emplaceBack(g+y-1,g+y),d.push(m[y].x),d.push(m[y].y);_.vertexLength+=m.length,_.primitiveLength+=m.length}const f=Kl(d,p);for(let m=0;m<f.length;m+=3)this.indexArray.emplaceBack(h+f[m],h+f[m+1],h+f[m+2]);u.vertexLength+=c,u.primitiveLength+=f.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,a)}}Ee(Ql,"FillBucket",{omit:["layers","patternFeatures"]});const Lw=new Xt({"fill-sort-key":new ke(j.layout_fill["fill-sort-key"]),visibility:new se(j.layout_fill.visibility)});var Bw={paint:new Xt({"fill-antialias":new se(j.paint_fill["fill-antialias"]),"fill-opacity":new ke(j.paint_fill["fill-opacity"]),"fill-color":new ke(j.paint_fill["fill-color"]),"fill-outline-color":new ke(j.paint_fill["fill-outline-color"]),"fill-translate":new se(j.paint_fill["fill-translate"]),"fill-translate-anchor":new se(j.paint_fill["fill-translate-anchor"]),"fill-pattern":new ke(j.paint_fill["fill-pattern"]),"fill-emissive-strength":new se(j.paint_fill["fill-emissive-strength"])}),layout:Lw};const Ow=xt([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Fw=xt([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Nw=xt([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Uw=xt([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Vw=xt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:jw}=Ow;var ec={},Gw=Ps,ey=fn;function fn(t,e,r,i,o){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,t.readFields(qw,this,e)}function qw(t,e,r){t==1?e.id=r.readVarint():t==2?function(i,o){for(var s=i.readVarint()+i.pos;i.pos<s;){var n=o._keys[i.readVarint()],a=o._values[i.readVarint()];o.properties[n]=a}}(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Zw(t){for(var e,r,i=0,o=0,s=t.length,n=s-1;o<s;n=o++)i+=((r=t[n]).x-(e=t[o]).x)*(e.y+r.y);return i}fn.types=["Unknown","Point","LineString","Polygon"],fn.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,r=t.readVarint()+t.pos,i=1,o=0,s=0,n=0,a=[];t.pos<r;){if(o<=0){var l=t.readVarint();i=7&l,o=l>>3}if(o--,i===1||i===2)s+=t.readSVarint(),n+=t.readSVarint(),i===1&&(e&&a.push(e),e=[]),e.push(new Gw(s,n));else{if(i!==7)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&a.push(e),a},fn.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,n=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(i<=0){var u=t.readVarint();r=7&u,i=u>>3}if(i--,r===1||r===2)(o+=t.readSVarint())<n&&(n=o),o>a&&(a=o),(s+=t.readSVarint())<l&&(l=s),s>c&&(c=s);else if(r!==7)throw new Error("unknown command "+r)}return[n,l,a,c]},fn.prototype.toGeoJSON=function(t,e,r){var i,o,s=this.extent*Math.pow(2,r),n=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=fn.types[this.type];function u(p){for(var f=0;f<p.length;f++){var m=p[f];p[f]=[360*(m.x+n)/s-180,360/Math.PI*Math.atan(Math.exp((180-360*(m.y+a)/s)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(i=0;i<l.length;i++)h[i]=l[i][0];u(l=h);break;case 2:for(i=0;i<l.length;i++)u(l[i]);break;case 3:for(l=function(p){var f=p.length;if(f<=1)return[p];for(var m,_,g=[],y=0;y<f;y++){var v=Zw(p[y]);v!==0&&(_===void 0&&(_=v<0),_===v<0?(m&&g.push(m),m=[p[y]]):m.push(p[y]))}return m&&g.push(m),g}(l),i=0;i<l.length;i++)for(o=0;o<l[i].length;o++)u(l[i][o])}l.length===1?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d};var $w=ey,ty=ry;function ry(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(Hw,this,e),this.length=this._features.length}function Hw(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(function(i){for(var o=null,s=i.readVarint()+i.pos;i.pos<s;){var n=i.readVarint()>>3;o=n===1?i.readString():n===2?i.readFloat():n===3?i.readDouble():n===4?i.readVarint64():n===5?i.readVarint():n===6?i.readSVarint():n===7?i.readBoolean():null}return o}(r))}ry.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 $w(this._pbf,e,this.extent,this._keys,this._values)};var Ww=ty;function Xw(t,e,r){if(t===3){var i=new Ww(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}var Ld=ec.VectorTile=function(t,e){this.layers=t.readFields(Xw,{},e)},tc=ec.VectorTileFeature=ey;function rc(t,e,r,i){const o=[],s=i===0?(n,a,l,c,u,h)=>{n.push(new N(h,l+(h-a)/(c-a)*(u-l)))}:(n,a,l,c,u,h)=>{n.push(new N(a+(h-l)/(u-l)*(c-a),h))};for(const n of t){const a=[];for(const l of n){if(l.length<=2)continue;const c=[];for(let d=0;d<l.length-1;d++){const p=l[d].x,f=l[d].y,m=l[d+1].x,_=l[d+1].y,g=i===0?p:f,y=i===0?m:_;g<e?y>e&&s(c,p,f,m,_,e):g>r?y<r&&s(c,p,f,m,_,r):c.push(l[d]),y<e&&g>=e&&s(c,p,f,m,_,e),y>r&&g<=r&&s(c,p,f,m,_,r)}let u=l[l.length-1];const h=i===0?u.x:u.y;h>=e&&h<=r&&c.push(u),c.length&&(u=c[c.length-1],c[0].x===u.x&&c[0].y===u.y||c.push(c[0]),a.push(c))}a.length&&o.push(a)}return o}ec.VectorTileLayer=ty;class iy{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const i=e[r];this._stringToNumber[i]=r,this._numberToString[r]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}var Yw={read:function(t,e,r,i,o){var s,n,a=8*o-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?o-1:0,d=r?-1:1,p=t[e+h];for(h+=d,s=p&(1<<-u)-1,p>>=-u,u+=a;u>0;s=256*s+t[e+h],h+=d,u-=8);for(n=s&(1<<-u)-1,s>>=-u,u+=i;u>0;n=256*n+t[e+h],h+=d,u-=8);if(s===0)s=1-c;else{if(s===l)return n?NaN:1/0*(p?-1:1);n+=Math.pow(2,i),s-=c}return(p?-1:1)*n*Math.pow(2,s-i)},write:function(t,e,r,i,o,s){var n,a,l,c=8*s-o-1,u=(1<<c)-1,h=u>>1,d=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:s-1,f=i?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,n=u):(n=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-n))<1&&(n--,l*=2),(e+=n+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(n++,l/=2),n+h>=u?(a=0,n=u):n+h>=1?(a=(e*l-1)*Math.pow(2,o),n+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),n=0));o>=8;t[r+p]=255&a,p+=f,a/=256,o-=8);for(n=n<<o|a,c+=o;c>0;t[r+p]=255&n,p+=f,n/=256,c-=8);t[r+p-f]|=128*m}},oy=Ft,ic=Yw;function Ft(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ft.Varint=0,Ft.Fixed64=1,Ft.Bytes=2,Ft.Fixed32=5;var Bd=4294967296,sy=1/Bd,ny=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function xo(t){return t.type===Ft.Bytes?t.readVarint()+t.pos:t.pos+1}function Jw(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function ay(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(i);for(var o=r.pos-1;o>=t;o--)r.buf[o+i]=r.buf[o]}function Kw(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Qw(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function e2(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function t2(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function r2(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function i2(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function o2(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function s2(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function n2(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function oc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function mn(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function ly(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Ft.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),o=i>>3,s=this.pos;this.type=7&i,t(o,e,this),this.pos===s&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=oc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=ly(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=oc(this.buf,this.pos)+oc(this.buf,this.pos+4)*Bd;return this.pos+=8,t},readSFixed64:function(){var t=oc(this.buf,this.pos)+ly(this.buf,this.pos+4)*Bd;return this.pos+=8,t},readFloat:function(){var t=ic.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ic.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,i=this.buf;return e=127&(r=i[this.pos++]),r<128?e:(e|=(127&(r=i[this.pos++]))<<7,r<128?e:(e|=(127&(r=i[this.pos++]))<<14,r<128?e:(e|=(127&(r=i[this.pos++]))<<21,r<128?e:function(o,s,n){var a,l,c=n.buf;if(a=(112&(l=c[n.pos++]))>>4,l<128||(a|=(127&(l=c[n.pos++]))<<3,l<128)||(a|=(127&(l=c[n.pos++]))<<10,l<128)||(a|=(127&(l=c[n.pos++]))<<17,l<128)||(a|=(127&(l=c[n.pos++]))<<24,l<128)||(a|=(1&(l=c[n.pos++]))<<31,l<128))return Jw(o,a,s);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=i[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&&ny?function(r,i,o){return ny.decode(r.subarray(i,o))}(this.buf,e,t):function(r,i,o){for(var s="",n=i;n<o;){var a,l,c,u=r[n],h=null,d=u>239?4:u>223?3:u>191?2:1;if(n+d>o)break;d===1?u<128&&(h=u):d===2?(192&(a=r[n+1]))==128&&(h=(31&u)<<6|63&a)<=127&&(h=null):d===3?(l=r[n+2],(192&(a=r[n+1]))==128&&(192&l)==128&&((h=(15&u)<<12|(63&a)<<6|63&l)<=2047||h>=55296&&h<=57343)&&(h=null)):d===4&&(l=r[n+2],c=r[n+3],(192&(a=r[n+1]))==128&&(192&l)==128&&(192&c)==128&&((h=(15&u)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||h>=1114112)&&(h=null)),h===null?(h=65533,d=1):h>65535&&(h-=65536,s+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),s+=String.fromCharCode(h),n+=d}return s}(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!==Ft.Bytes)return t.push(this.readVarint(e));var r=xo(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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===Ft.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ft.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ft.Fixed32)this.pos+=4;else{if(e!==Ft.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),mn(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),mn(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),mn(this.buf,-1&t,this.pos),mn(this.buf,Math.floor(t*sy),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),mn(this.buf,-1&t,this.pos),mn(this.buf,Math.floor(t*sy),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,r){var i,o;if(e>=0?(i=e%4294967296|0,o=e/4294967296|0):(o=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,o=o+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(s,n,a){a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7)}(i,0,r),function(s,n){var a=(7&s)<<4;n.buf[n.pos++]|=a|((s>>>=3)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s)))))}(o,r)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(i,o,s){for(var n,a,l=0;l<o.length;l++){if((n=o.charCodeAt(l))>55295&&n<57344){if(!a){n>56319||l+1===o.length?(i[s++]=239,i[s++]=191,i[s++]=189):a=n;continue}if(n<56320){i[s++]=239,i[s++]=191,i[s++]=189,a=n;continue}n=a-55296<<10|n-56320|65536,a=null}else a&&(i[s++]=239,i[s++]=191,i[s++]=189,a=null);n<128?i[s++]=n:(n<2048?i[s++]=n>>6|192:(n<65536?i[s++]=n>>12|224:(i[s++]=n>>18|240,i[s++]=n>>12&63|128),i[s++]=n>>6&63|128),i[s++]=63&n|128)}return s}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&ay(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),ic.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ic.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 r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&ay(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Ft.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Kw,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Qw,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,r2,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,e2,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,t2,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,i2,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,o2,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,s2,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,n2,e)},writeBytesField:function(t,e){this.writeTag(t,Ft.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ft.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ft.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ft.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var sc=li(oy);const a2=["tile","layer","source","sourceLayer","state"];class cy{constructor(e,r,i,o,s){this.type="Feature",this._vectorTileFeature=e,this._z=r,this._x=i,this._y=o,this.properties=e.properties,this.id=s}get geometry(){return this._geometry===void 0&&(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};this.id!==void 0&&(e.id=this.id);for(const r of a2)this[r]!==void 0&&(e[r]=this[r]);return e}}class l2{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,i){const o=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},Te(this.stateChanges[e][o],i),this.deletedStates[e]===null){this.deletedStates[e]={};for(const s in this.state[e])s!==o&&(this.deletedStates[e][s]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(const s in this.state[e][o])i[s]||(this.deletedStates[e][o][s]=null)}else for(const s in i)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][s]===null&&delete this.deletedStates[e][o][s]}removeFeatureState(e,r,i){if(this.deletedStates[e]===null)return;const o=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&r!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(r!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,r){const i=String(r),o=Te({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const s=this.deletedStates[e][r];if(s===null)return{};for(const n in s)delete o[n]}return o}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){const i={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const s={};for(const n in this.stateChanges[o])this.state[o][n]||(this.state[o][n]={}),Te(this.state[o][n],this.stateChanges[o][n]),s[n]=this.state[o][n];i[o]=s}for(const o in this.deletedStates){this.state[o]=this.state[o]||{};const s={};if(this.deletedStates[o]===null)for(const n in this.state[o])s[n]={},this.state[o][n]={};else for(const n in this.deletedStates[o]){if(this.deletedStates[o][n]===null)this.state[o][n]={};else if(this.state[o][n])for(const a of Object.keys(this.deletedStates[o][n]))delete this.state[o][n][a];s[n]=this.state[o][n]}i[o]=i[o]||{},Te(i[o],s)}if(this.stateChanges={},this.deletedStates={},Object.keys(i).length!==0)for(const o in e)e[o].setFeatureState(i,r)}}class uy{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,r){const i=this.toIdx(e,r);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,r){return this.leaves[this.toIdx(e,r)]}toIdx(e,r){return r*this.size+e}}function hy(t,e,r,i){let o=0,s=Number.MAX_VALUE;for(let n=0;n<3;n++)if(Math.abs(i[n])<1e-15){if(r[n]<t[n]||r[n]>e[n])return null}else{const a=1/i[n];let l=(t[n]-r[n])*a,c=(e[n]-r[n])*a;if(l>c){const u=l;l=c,c=u}if(l>o&&(o=l),c<s&&(s=c),o>s)return null}return o}function dy(t,e,r,i,o,s,n,a,l,c,u){const h=i-t,d=o-e,p=s-r,f=n-t,m=a-e,_=l-r,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,v=u[0]*m-u[1]*f,b=h*g+d*y+p*v;if(Math.abs(b)<1e-15)return null;const x=1/b,w=c[0]-t,T=c[1]-e,E=c[2]-r,M=(w*g+T*y+E*v)*x;if(M<0||M>1)return null;const S=T*p-E*d,I=E*h-w*p,C=w*d-T*h,k=(u[0]*S+u[1]*I+u[2]*C)*x;return k<0||M+k>1?null:(f*S+m*I+_*C)*x}function py(t,e,r){return(t-e)/(r-e)}function fy(t,e,r,i,o,s,n,a,l){const c=1<<r,u=s-i,h=n-o,d=(t+1)/c*u+i,p=(e+0)/c*h+o,f=(e+1)/c*h+o;a[0]=(t+0)/c*u+i,a[1]=p,l[0]=d,l[1]=f}class my{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 r=function(s){const n=Math.ceil(Math.log2(s.dim/8)),a=[];let l=Math.ceil(Math.pow(2,n));const c=1/l,u=(p,f,m,_,g)=>{const y=_?1:0,v=(p+1)*m-y,b=f*m,x=(f+1)*m-y;g[0]=p*m,g[1]=b,g[2]=v,g[3]=x};let h=new uy(l);const d=[];for(let p=0;p<l*l;p++){u(p%l,Math.floor(p/l),c,!1,d);const f=jo(d[0],d[1],s),m=jo(d[2],d[1],s),_=jo(d[2],d[3],s),g=jo(d[0],d[3],s);h.minimums.push(Math.min(f,m,_,g)),h.maximums.push(Math.max(f,m,_,g)),h.leaves.push(1)}for(a.push(h),l/=2;l>=1;l/=2){const p=a[a.length-1];h=new uy(l);for(let f=0;f<l*l;f++){u(f%l,Math.floor(f/l),2,!0,d);const m=p.getElevation(d[0],d[1]),_=p.getElevation(d[2],d[1]),g=p.getElevation(d[2],d[3]),y=p.getElevation(d[0],d[3]),v=p.isLeaf(d[0],d[1]),b=p.isLeaf(d[2],d[1]),x=p.isLeaf(d[2],d[3]),w=p.isLeaf(d[0],d[3]),T=Math.min(m.min,_.min,g.min,y.min),E=Math.max(m.max,_.max,g.max,y.max),M=v&&b&&x&&w;h.maximums.push(E),h.minimums.push(T),h.leaves.push(E-T<=5&&M?1:0)}a.push(h)}return a}(this.dem),i=r.length-1,o=r[i];this._addNode(o.minimums[0],o.maximums[0],o.leaves[0]),this._construct(r,0,0,i,0)}raycastRoot(e,r,i,o,s,n,a=1){return hy([e,r,-100],[i,o,this.maximums[0]*a],s,n)}raycast(e,r,i,o,s,n,a=1){if(!this.nodeCount)return null;const l=this.raycastRoot(e,r,i,o,s,n,a);if(l==null)return null;const c=[],u=[],h=[],d=[],p=[{idx:0,t:l,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:f,t:m,nodex:_,nodey:g,depth:y}=p.pop();if(this.leaves[f]){fy(_,g,y,e,r,i,o,h,d);const b=1<<y,x=(_+0)/b,w=(_+1)/b,T=(g+0)/b,E=(g+1)/b,M=jo(x,T,this.dem)*a,S=jo(w,T,this.dem)*a,I=jo(w,E,this.dem)*a,C=jo(x,E,this.dem)*a,k=dy(h[0],h[1],M,d[0],h[1],S,d[0],d[1],I,s,n),A=dy(d[0],d[1],I,h[0],d[1],C,h[0],h[1],M,s,n),L=Math.min(k!==null?k:Number.MAX_VALUE,A!==null?A:Number.MAX_VALUE);if(L!==Number.MAX_VALUE)return L;{const O=D.scaleAndAdd([],s,n,m);if(_y(M,S,C,I,py(O[0],h[0],d[0]),py(O[1],h[1],d[1]))>=O[2])return m}continue}let v=0;for(let b=0;b<this._siblingOffset.length;b++){fy((_<<1)+this._siblingOffset[b][0],(g<<1)+this._siblingOffset[b][1],y+1,e,r,i,o,h,d),h[2]=-100,d[2]=this.maximums[this.childOffsets[f]+b]*a;const x=hy(h,d,s,n);if(x!=null){const w=x;c[b]=w;let T=!1;for(let E=0;E<v&&!T;E++)w>=c[u[E]]&&(u.splice(E,0,b),T=!0);T||(u[v]=b),v++}}for(let b=0;b<v;b++){const x=u[b];p.push({idx:this.childOffsets[f]+x,t:c[x],nodex:(_<<1)+this._siblingOffset[x][0],nodey:(g<<1)+this._siblingOffset[x][1],depth:y+1})}}return null}_addNode(e,r,i){return this.minimums.push(e),this.maximums.push(r),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,r,i,o,s){if(e[o].isLeaf(r,i)===1)return;this.childOffsets[s]||(this.childOffsets[s]=this.nodeCount);const n=o-1,a=e[n];let l=0,c=0;for(let u=0;u<this._siblingOffset.length;u++){const h=2*r+this._siblingOffset[u][0],d=2*i+this._siblingOffset[u][1],p=a.getElevation(h,d),f=a.isLeaf(h,d),m=this._addNode(p.min,p.max,f);f&&(l|=1<<u),c||(c=m)}for(let u=0;u<this._siblingOffset.length;u++)l&1<<u||this._construct(e,2*r+this._siblingOffset[u][0],2*i+this._siblingOffset[u][1],n,c+u)}}function _y(t,e,r,i,o,s){return Fe(Fe(t,r,s),Fe(e,i,s),o)}function jo(t,e,r){const i=r.dim,o=Se(t*i-.5,0,i-1),s=Se(e*i-.5,0,i-1),n=Math.floor(o),a=Math.floor(s),l=Math.min(n+1,i-1),c=Math.min(a+1,i-1);return _y(r.get(n,a),r.get(l,a),r.get(n,c),r.get(l,c),o-n,s-a)}const c2={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function u2(t,e,r){return(256*t*256+256*e+r)/10-1e4}function h2(t,e,r){return 256*t+e+r/256-32768}class nc{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,r,i,o=!1){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(i&&i!=="mapbox"&&i!=="terrarium")return F(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;const s=this.dim=r.height-2,n=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.floatView=new Float32Array(r.data.buffer),this.borderReady=o,this._modifiedForSources={},!o){for(let l=0;l<s;l++)n[this._idx(-1,l)]=n[this._idx(0,l)],n[this._idx(s,l)]=n[this._idx(s-1,l)],n[this._idx(l,-1)]=n[this._idx(l,0)],n[this._idx(l,s)]=n[this._idx(l,s-1)];n[this._idx(-1,-1)]=n[this._idx(0,0)],n[this._idx(s,-1)]=n[this._idx(s-1,0)],n[this._idx(-1,s)]=n[this._idx(0,s-1)],n[this._idx(s,s)]=n[this._idx(s-1,s-1)]}const a=i==="terrarium"?h2:u2;for(let l=0;l<n.length;++l){const c=4*l;this.floatView[l]=a(this.pixels[c],this.pixels[c+1],this.pixels[c+2])}this._timestamp=je.now()}_buildQuadTree(){this._tree=new my(this)}get(e,r,i=!1){i&&(e=Se(e,-1,this.dim),r=Se(r,-1,this.dim));const o=this._idx(e,r);return this.floatView[o]}set(e,r,i){const o=this._idx(e,r),s=this.floatView[o];return this.floatView[o]=i,i-s}static getUnpackVector(e){return c2[e]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}static pack(e,r){const i=[0,0,0,0],o=nc.getUnpackVector(r);let s=Math.floor((e+o[3])/o[2]);return i[2]=s%256,s=Math.floor(s/256),i[1]=s%256,s=Math.floor(s/256),i[0]=s,i}getPixels(){return new Xg({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,r,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(r){case-1:o=s-1;break;case 1:s=o+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const l=-r*this.dim,c=-i*this.dim;for(let u=n;u<a;u++)for(let h=o;h<s;h++){const d=4*this._idx(h,u),p=4*this._idx(h+l,u+c);this.pixels[d+0]=e.pixels[p+0],this.pixels[d+1]=e.pixels[p+1],this.pixels[d+2]=e.pixels[p+2],this.pixels[d+3]=e.pixels[p+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Ee(nc,"DEMData"),Ee(my,"DemMinMaxQuadTree",{omit:["dem"]});class d2{isDataAvailableAtPoint(e){const r=this._source();if(this.isUsingMockSource()||!r||e.y<0||e.y>1)return!1;const i=r.getSource().maxzoom,o=1<<i,s=Math.floor(e.x),n=Math.floor((e.x-s)*o),a=Math.floor(e.y*o),l=this.findDEMTileFor(new mt(i,s,i,n,a));return!(!l||!l.dem)}getAtPointOrZero(e,r=0){return this.getAtPoint(e,r)||0}getAtPoint(e,r,i=!0){if(this.isUsingMockSource())return null;r==null&&(r=null);const o=this._source();if(!o||e.y<0||e.y>1)return r;const s=o.getSource().maxzoom,n=1<<s,a=Math.floor(e.x),l=e.x-a,c=new mt(s,a,s,Math.floor(l*n),Math.floor(e.y*n)),u=this.findDEMTileFor(c);if(!u||!u.dem)return r;const h=u.dem,d=1<<u.tileID.canonical.z,p=(l*d-u.tileID.canonical.x)*h.dim,f=(e.y*d-u.tileID.canonical.y)*h.dim,m=Math.floor(p),_=Math.floor(f);return(i?this.exaggeration():1)*Fe(Fe(h.get(m,_),h.get(m,_+1),f-_),Fe(h.get(m+1,_),h.get(m+1,_+1),f-_),p-m)}getAtTileOffset(e,r,i){const o=1<<e.canonical.z;return this.getAtPointOrZero(new lt(e.wrap+(e.canonical.x+r/W)/o,(e.canonical.y+i/W)/o))}getAtTileOffsetFunc(e,r,i,o){return s=>{const n=this.getAtTileOffset(e,s.x,s.y),a=o.upVector(e.canonical,s.x,s.y),l=o.upVectorScale(e.canonical,r,i).metersToTile;return D.scale(a,a,n*l),a}}getForTilePoints(e,r,i,o){if(this.isUsingMockSource())return!1;const s=_n.create(this,e,o);return!!s&&(r.forEach(n=>{n[2]=this.exaggeration()*s.getElevationAt(n[0],n[1],i)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const r=this.findDEMTileFor(e);if(!r||!r.dem)return null;const i=r.dem.tree,o=r.tileID,s=1<<e.canonical.z-o.canonical.z;let n=e.canonical.x/s-o.canonical.x,a=e.canonical.y/s-o.canonical.y,l=0;for(let c=0;c<e.canonical.z-o.canonical.z&&!i.leaves[l];c++){n*=2,a*=2;const u=2*Math.floor(a)+Math.floor(n);l=i.childOffsets[l]+u,n%=1,a%=1}return{min:this.exaggeration()*i.minimums[l],max:this.exaggeration()*i.maximums[l]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,r,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){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(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(e.length===0)return null;let r=!1,i=Number.MAX_VALUE,o=Number.MIN_VALUE;for(const s of e){const n=this.getMinMaxForTile(s.tileID);n&&(i=Math.min(i,n.min),o=Math.max(o,n.max),r=!0)}return r?{min:i,max:o}:null}}class _n{constructor(e,r,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=r,this._offset=i}static create(e,r,i){const o=i||e.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,n=o.tileID,a=1<<r.canonical.z-n.canonical.z;return new _n(o,s.dim/W/a,[(r.canonical.x/a-n.canonical.x)*s.dim,(r.canonical.y/a-n.canonical.y)*s.dim])}tileCoordToPixel(e,r){const i=r*this._scale+this._offset[1],o=Math.floor(e*this._scale+this._offset[0]),s=Math.floor(i);return new N(o,s)}getElevationAt(e,r,i,o){const s=e*this._scale+this._offset[0],n=r*this._scale+this._offset[1],a=Math.floor(s),l=Math.floor(n),c=this._dem;return o=!!o,i?Fe(Fe(c.get(a,l,o),c.get(a,l+1,o),n-l),Fe(c.get(a+1,l,o),c.get(a+1,l+1,o),n-l),s-a):c.get(a,l,o)}getElevationAtPixel(e,r,i){return this._dem.get(e,r,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*It(1,e)*this._dem.stride}}class Od{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new en(W,16,0),this.featureIndexArray=new $m,this.promoteId=r}insert(e,r,i,o,s,n=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,o,s,n);const l=this.grid;for(let c=0;c<r.length;c++){const u=r[c],h=[1/0,1/0,-1/0,-1/0];for(let d=0;d<u.length;d++){const p=u[d];h[0]=Math.min(h[0],p.x),h[1]=Math.min(h[1],p.y),h[2]=Math.max(h[2],p.x),h[3]=Math.max(h[3],p.y)}h[0]<W&&h[1]<W&&h[2]>=0&&h[3]>=0&&l.insert(a,h[0],h[1],h[2],h[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Ld(new sc(this.rawTileData)).layers,this.sourceLayerCoder=new iy(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,r,i,o){this.loadVTLayers();const s=e.params||{},n=yl(s.filter),a=e.tileResult,l=e.transform,c=a.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(f,m,_,g)=>Ug(a.bufferedTilespaceGeometry,f,m,_,g));u.sort(p2);let h=null;l.elevation&&u.length>0&&(h=_n.create(l.elevation,this.tileID));const d={};let p;for(let f=0;f<u.length;f++){const m=u[f];if(m===p)continue;p=m;const _=this.featureIndexArray.get(m);let g=null;this.loadMatchingFeature(d,_,n,s.layers,s.availableImages,r,i,o,(y,v,b,x=0)=>(g||(g=$i(y,this.tileID.canonical,e.tileTransform)),v.queryIntersectsFeature(a,y,b,g,this.z,e.transform,e.pixelPosMatrix,h,x)))}return d}loadMatchingFeature(e,r,i,o,s,n,a,l,c){const{featureIndex:u,bucketIndex:h,sourceLayerIndex:d,layoutVertexArrayOffset:p}=r,f=this.bucketLayerIDs[h];if(o&&!function(y,v){for(let b=0;b<y.length;b++)if(v.indexOf(y[b])>=0)return!0;return!1}(o,f))return;const m=this.sourceLayerCoder.decode(d),_=this.vtLayers[m].feature(u);if(i.needGeometry){const y=Uo(_,!0);if(!i.filter(new Ut(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!i.filter(new Ut(this.tileID.overscaledZ),_))return;const g=this.getId(_,m);for(let y=0;y<f.length;y++){const v=f[y];if(o&&o.indexOf(v)<0)continue;const b=n[v];if(!b)continue;let x={};g!==void 0&&l&&(x=l.getState(b.sourceLayer||"_geojsonTileLayer",g));const w=Te({},a[v]);w.paint=gy(w.paint,b.paint,_,x,s),w.layout=gy(w.layout,b.layout,_,x,s);const T=!c||c(_,b,x,p);if(!T)continue;const E=new cy(_,this.z,this.x,this.y,g);E.layer=w;let M=e[v];M===void 0&&(M=e[v]=[]),M.push({featureIndex:u,feature:E,intersectionZ:T})}}lookupSymbolFeatures(e,r,i,o,s,n,a,l){const c={};this.loadVTLayers();const u=yl(s);for(const h of e)this.loadMatchingFeature(c,{bucketIndex:i,sourceLayerIndex:o,featureIndex:h,layoutVertexArrayOffset:0},u,n,a,l,r);return c}loadFeature(e){const{featureIndex:r,sourceLayerIndex:i}=e;this.loadVTLayers();const o=this.sourceLayerCoder.decode(i),s=this.vtFeatures[o];if(s[r])return s[r];const n=this.vtLayers[o].feature(r);return s[r]=n,n}hasLayer(e){for(const r of this.bucketLayerIDs)for(const i of r)if(e===i)return!0;return!1}getId(e,r){let i=e.id;if(this.promoteId){const o=typeof this.promoteId=="string"?this.promoteId:this.promoteId[r];o!=null&&(i=e.properties[o]),typeof i=="boolean"&&(i=Number(i))}return i}}function gy(t,e,r,i,o){return Os(t,(s,n)=>{const a=e instanceof ea?e.get(n):null;return a&&a.evaluate?a.evaluate(r,i,o):a})}function p2(t,e){return e-t}Ee(Od,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const f2=xt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),m2=xt([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),_2=xt([{name:"a_projected_pos",components:4,type:"Float32"}],4);xt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const g2=xt([{name:"a_z_offset",components:1,type:"Float32"}],4),y2=xt([{name:"a_texb",components:2,type:"Uint16"}]),x2=xt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),v2=xt([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);xt([{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 yy=xt([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),b2=xt([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);xt([{name:"triangle",components:3,type:"Uint16"}]),xt([{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"}]),xt([{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"}]),xt([{type:"Float32",name:"offsetX"}]),xt([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var xr=24;const zi=128;function Fd(t,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Ut(t+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:i,interpolationType:o}=r;let s=0;for(;s<i.length&&i[s]<=t;)s++;s=Math.max(0,s-1);let n=s;for(;n<i.length&&i[n]<t+1;)n++;n=Math.min(i.length-1,n);const a=i[s],l=i[n];return r.kind==="composite"?{kind:"composite",minZoom:a,maxZoom:l,interpolationType:o}:{kind:"camera",minZoom:a,maxZoom:l,minSize:r.evaluate(new Ut(a)),maxSize:r.evaluate(new Ut(l)),interpolationType:o}}}function ma(t,{uSize:e,uSizeT:r},{lowerSize:i,upperSize:o}){return t.kind==="source"?i/zi:t.kind==="composite"?Fe(i/zi,o/zi,r):e}function Hi(t,e){let r=0,i=0;if(t.kind==="constant")i=t.layoutSize;else if(t.kind!=="source"){const{interpolationType:o,minZoom:s,maxZoom:n}=t,a=o?Se(ji.interpolationFactor(o,e,s,n),0,1):0;t.kind==="camera"?i=Fe(t.minSize,t.maxSize,a):r=a}return{uSizeT:r,uSize:i}}var w2=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:zi,evaluateSizeForFeature:ma,evaluateSizeForZoom:Hi,getSizeData:Fd});function T2(t,e,r){return t.sections.forEach(i=>{i.text=function(o,s,n){const a=s.layout.get("text-transform").evaluate(n,{});return a==="uppercase"?o=o.toLocaleUpperCase():a==="lowercase"&&(o=o.toLocaleLowerCase()),fi.applyArabicShaping&&(o=fi.applyArabicShaping(o)),o}(i.text,e,r)}),t}const _a={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function E2(t){return t==="︶"||t==="﹈"||t==="︸"||t==="﹄"||t==="﹂"||t==="︾"||t==="︼"||t==="︺"||t==="︘"||t==="﹀"||t==="︐"||t==="︓"||t==="︔"||t==="`"||t===" ̄"||t==="︑"||t==="︒"}function M2(t){return t==="︵"||t==="﹇"||t==="︷"||t==="﹃"||t==="﹁"||t==="︽"||t==="︻"||t==="︹"||t==="︗"||t==="︿"}const Nd=3;function S2(t,e,r){e.glyphs=[],t===1&&r.readMessage(A2,e)}function A2(t,e,r){if(t===3){const{id:i,bitmap:o,width:s,height:n,left:a,top:l,advance:c}=r.readMessage(I2,{});e.glyphs.push({id:i,bitmap:new yo({width:s+2*Nd,height:n+2*Nd},o),metrics:{width:s,height:n,left:a,top:l,advance:c}})}else t===4?e.ascender=r.readSVarint():t===5&&(e.descender=r.readSVarint())}function I2(t,e,r){t===1?e.id=r.readVarint():t===2?e.bitmap=r.readBytes():t===3?e.width=r.readVarint():t===4?e.height=r.readVarint():t===5?e.left=r.readSVarint():t===6?e.top=r.readSVarint():t===7&&(e.advance=r.readVarint())}const xy=Nd,Nt={horizontal:1,vertical:2,horizontalOnly:3},vy=-17;class ga{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const i=new ga;return i.scale=e||1,i.fontStack=r,i}static forImage(e){const r=new ga;return r.imageName=e,r}}class gn{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const i=new gn;for(let o=0;o<e.sections.length;o++){const s=e.sections[o];s.image?i.addImageSection(s):i.addTextSection(s,r)}return i}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(r,i){let o="";for(let s=0;s<r.length;s++){const n=r.charCodeAt(s+1)||null,a=r.charCodeAt(s-1)||null;o+=!i&&(n&&Cm(n)&&!_a[r[s+1]]||a&&Cm(a)&&!_a[r[s-1]])||!_a[r[s]]?r[s]:_a[r[s]]}return o}(this.text,e)}trim(){let e=0;for(let i=0;i<this.text.length&&ac[this.text.charCodeAt(i)];i++)e++;let r=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&ac[this.text.charCodeAt(i)];i--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const i=new gn;return i.text=this.text.substring(e,r),i.sectionIndex=this.sectionIndex.slice(e,r),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(ga.forText(e.scale,e.fontStack||r));const i=this.sections.length-1;for(let o=0;o<e.text.length;++o)this.sectionIndex.push(i)}addImageSection(e){const r=e.image?e.image.namePrimary:"";if(r.length===0)return void F("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCodePoint(i),this.sections.push(ga.forImage(r)),this.sectionIndex.push(this.sections.length-1)):F("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ud(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f){const m=gn.fromFeature(t,o);h===Nt.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(w,T,E,M,S,I){if(!w)return[];const C=[],k=function(U,R,B,G,Z,q){let X=0;for(let Y=0;Y<U.length();Y++){const K=U.getSection(Y);X+=by(U.getCodePoint(Y),K,G,Z,R,q)}return X/Math.max(1,Math.ceil(X/B))}(w,T,E,M,S,I),A=w.text.indexOf("​")>=0;let L=0;for(let U=0;U<w.length();U++){const R=w.getSection(U),B=w.getCodePoint(U);if(ac[B]||(L+=by(B,R,M,S,T,I)),U<w.length()-1){const G=!((O=B)<11904||!(Ae["Bopomofo Extended"](O)||Ae.Bopomofo(O)||Ae["CJK Compatibility Forms"](O)||Ae["CJK Compatibility Ideographs"](O)||Ae["CJK Compatibility"](O)||Ae["CJK Radicals Supplement"](O)||Ae["CJK Strokes"](O)||Ae["CJK Symbols and Punctuation"](O)||Ae["CJK Unified Ideographs Extension A"](O)||Ae["CJK Unified Ideographs"](O)||Ae["Enclosed CJK Letters and Months"](O)||Ae["Halfwidth and Fullwidth Forms"](O)||Ae.Hiragana(O)||Ae["Ideographic Description Characters"](O)||Ae["Kangxi Radicals"](O)||Ae["Katakana Phonetic Extensions"](O)||Ae.Katakana(O)||Ae["Vertical Forms"](O)||Ae["Yi Radicals"](O)||Ae["Yi Syllables"](O)));(C2[B]||G||R.imageName)&&C.push(Ty(U+1,L,k,C,z2(B,w.getCodePoint(U+1),G&&A),!1))}}var O;return Ey(Ty(w.length(),L,k,C,0,!0))}(m,c,s,e,i,p),{processBidirectionalText:y,processStyledBidirectionalText:v}=fi;if(y&&m.sections.length===1){const w=y(m.toString(),g);for(const T of w){const E=new gn;E.text=T,E.sections=m.sections;for(let M=0;M<T.length;M++)E.sectionIndex.push(0);_.push(E)}}else if(v){const w=v(m.text,m.sectionIndex,g);for(const T of w){const E=new gn;E.text=T[0],E.sectionIndex=T[1],E.sections=m.sections,_.push(E)}}else _=function(w,T){const E=[],M=w.text;let S=0;for(const I of T)E.push(w.substring(S,I)),S=I;return S<M.length&&E.push(w.substring(S,M.length)),E}(m,g);const b=[],x={positionedLines:b,text:m.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(w,T,E,M,S,I,C,k,A,L,O,U){let R=0,B=0,G=0;const Z=k==="right"?1:k==="left"?0:.5;let q=!1;for(const de of S){const pe=de.getSections();for(const ge of pe){if(ge.imageName)continue;const xe=T[ge.fontStack];if(xe&&(q=xe.ascender!==void 0&&xe.descender!==void 0,!q))break}if(!q)break}let X=0;for(const de of S){de.trim();const pe=de.getMaxScale(),ge=(pe-1)*xr,xe={positionedGlyphs:[],lineOffset:0};w.positionedLines[X]=xe;const Oe=xe.positionedGlyphs;let Ie=0;if(!de.length()){B+=I,++X;continue}let ht=0,st=0;for(let Re=0;Re<de.length();Re++){const De=de.getSection(Re),at=de.getSectionIndex(Re),ut=de.getCodePoint(Re);let Je=De.scale,Ct=null,Kt=null,St=null,Rt=xr,rr=0;const Qt=!(A===Nt.horizontal||!O&&!vh(ut)||O&&(ac[ut]||(Y=ut,Ae.Arabic(Y)||Ae["Arabic Supplement"](Y)||Ae["Arabic Extended-A"](Y)||Ae["Arabic Presentation Forms-A"](Y)||Ae["Arabic Presentation Forms-B"](Y))));if(De.imageName){const Ot=M[De.imageName];if(!Ot)continue;St=De.imageName,w.iconsInText=w.iconsInText||!0,Kt=Ot.paddedRect;const bt=Ot.displaySize;Je=Je*xr/U,Ct={width:bt[0],height:bt[1],left:0,top:-xy,advance:Qt?bt[1]:bt[0],localGlyph:!1},rr=q?-Ct.height*Je:vy+pe*xr-bt[1]*Je,Rt=Ct.advance;const Er=(Qt?bt[0]:bt[1])*Je-xr*pe;Er>0&&Er>Ie&&(Ie=Er)}else{const Ot=E[De.fontStack];if(!Ot)continue;Ot[ut]&&(Kt=Ot[ut]);const bt=T[De.fontStack];if(!bt)continue;const Er=bt.glyphs[ut];if(!Er)continue;if(Ct=Er.metrics,Rt=ut!==8203?xr:0,q){const Qi=bt.ascender!==void 0?Math.abs(bt.ascender):0,bo=bt.descender!==void 0?Math.abs(bt.descender):0,wo=(Qi+bo)*Je;ht<wo&&(ht=wo,st=(Qi-bo)/2*Je),rr=-Qi*Je}else rr=vy+(pe-Je)*xr}Qt?(w.verticalizable=!0,Oe.push({glyph:ut,imageName:St,x:R,y:B+rr,vertical:Qt,scale:Je,localGlyph:Ct.localGlyph,fontStack:De.fontStack,sectionIndex:at,metrics:Ct,rect:Kt}),R+=Rt*Je+L):(Oe.push({glyph:ut,imageName:St,x:R,y:B+rr,vertical:Qt,scale:Je,localGlyph:Ct.localGlyph,fontStack:De.fontStack,sectionIndex:at,metrics:Ct,rect:Kt}),R+=Ct.advance*Je+L)}Oe.length!==0&&(G=Math.max(R-L,G),q?My(Oe,Z,Ie,st,I*pe/2):My(Oe,Z,Ie,0,I/2)),R=0;const Be=I*pe+Ie;xe.lineOffset=Math.max(Ie,ge),B+=Be,++X}var Y;const K=B,{horizontalAlign:H,verticalAlign:ee}=lc(C);(function(de,pe,ge,xe,Oe,Ie){const ht=(pe-ge)*Oe,st=-Ie*xe;for(const Be of de)for(const Re of Be.positionedGlyphs)Re.x+=ht,Re.y+=st})(w.positionedLines,Z,H,ee,G,K),w.top+=-ee*K,w.bottom=w.top+K,w.left+=-H*G,w.right=w.left+G,w.hasBaseline=q}(x,e,r,i,_,n,a,l,h,c,d,f),!function(w){for(const T of w)if(T.positionedGlyphs.length!==0)return!1;return!0}(b)&&x}const ac={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},C2={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 by(t,e,r,i,o,s){if(e.imageName){const n=i[e.imageName];return n?n.displaySize[0]*e.scale*xr/s+o:0}{const n=r[e.fontStack],a=n&&n.glyphs[t];return a?a.metrics.advance*e.scale+o:0}}function wy(t,e,r,i){const o=Math.pow(t-e,2);return i?t<e?o/2:2*o:o+Math.abs(r)*r}function z2(t,e,r){let i=0;return t===10&&(i-=1e4),r&&(i+=150),t!==40&&t!==65288||(i+=50),e!==41&&e!==65289||(i+=50),i}function Ty(t,e,r,i,o,s){let n=null,a=wy(e,r,o,s);for(const l of i){const c=wy(e-l.x,r,o,s)+l.badness;c<=a&&(n=l,a=c)}return{index:t,x:e,priorBreak:n,badness:a}}function Ey(t){return t?Ey(t.priorBreak).concat(t.index):[]}function lc(t){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function My(t,e,r,i,o){if(!(e||r||i||o))return;const s=t.length-1,n=t[s],a=(n.x+n.metrics.advance*n.scale)*e;for(let l=0;l<=s;l++)t[l].x-=a,t[l].y+=r+i+o}function D2(t,e,r,i){const{horizontalAlign:o,verticalAlign:s}=lc(i),n=r[0]-t.displaySize[0]*o,a=r[1]-t.displaySize[1]*s;return{imagePrimary:t,imageSecondary:e,top:a,bottom:a+t.displaySize[1],left:n,right:n+t.displaySize[0]}}function Sy(t,e,r,i,o,s){const n=t.imagePrimary;let a;if(n.content){const _=n.content,g=n.pixelRatio||1;a=[_[0]/g,_[1]/g,n.displaySize[0]-_[2]/g,n.displaySize[1]-_[3]/g]}const l=e.left*s,c=e.right*s;let u,h,d,p;r==="width"||r==="both"?(p=o[0]+l-i[3],h=o[0]+c+i[1]):(p=o[0]+(l+c-n.displaySize[0])/2,h=p+n.displaySize[0]);const f=e.top*s,m=e.bottom*s;return r==="height"||r==="both"?(u=o[1]+f-i[0],d=o[1]+m+i[2]):(u=o[1]+(f+m-n.displaySize[1])/2,d=u+n.displaySize[1]),{imagePrimary:n,imageSecondary:void 0,top:u,right:h,bottom:d,left:p,collisionPadding:a}}class vo extends N{constructor(e,r,i,o,s){super(e,r),this.angle=o,this.z=i,s!==void 0&&(this.segment=s)}clone(){return new vo(this.x,this.y,this.z,this.angle,this.segment)}}function Ay(t,e,r,i,o){if(e.segment===void 0)return!0;let s=e,n=e.segment+1,a=0;for(;a>-r/2;){if(n--,n<0)return!1;a-=t[n].dist(s),s=t[n]}a+=t[n].dist(t[n+1]),n++;const l=[];let c=0;for(;a<r/2;){const u=t[n],h=t[n+1];if(!h)return!1;let d=t[n-1].angleTo(u)-u.angleTo(h);for(d=Math.abs((d+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:d}),c+=d;a-l[0].distance>i;)c-=l.shift().angleDelta;if(c>o)return!1;n++,a+=u.dist(h)}return!0}function Iy(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function Cy(t,e,r){return t?.6*e*r:0}function zy(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function k2(t,e,r,i,o,s){const n=Cy(r,o,s),a=zy(r,i)*s;let l=0;const c=Iy(t)/2;for(let u=0;u<t.length-1;u++){const h=t[u],d=t[u+1],p=h.dist(d);if(l+p>c){const f=(c-l)/p,m=Fe(h.x,d.x,f),_=Fe(h.y,d.y,f),g=new vo(m,_,0,d.angleTo(h),u);return!n||Ay(t,g,a,n,e)?g:void 0}l+=p}}function P2(t,e,r,i,o,s,n,a,l){const c=Cy(i,s,n),u=zy(i,o),h=u*n,d=t[0].x===0||t[0].x===l||t[0].y===0||t[0].y===l;return e-h<e/4&&(e=h+e/4),Dy(t,d?e/2*a%e:(u/2+2*s)*n*a%e,e,c,r,h,d,!1,l)}function Dy(t,e,r,i,o,s,n,a,l){const c=s/2,u=Iy(t);let h=0,d=e-r,p=[];for(let f=0;f<t.length-1;f++){const m=t[f],_=t[f+1],g=m.dist(_),y=_.angleTo(m);for(;d+r<h+g;){d+=r;const v=(d-h)/g,b=Fe(m.x,_.x,v),x=Fe(m.y,_.y,v);if(b>=0&&b<l&&x>=0&&x<l&&d-c>=0&&d+c<=u){const w=new vo(b,x,0,y,f);i&&!Ay(t,w,s,i,o)||p.push(w)}}h+=g}return a||p.length||n||(p=Dy(t,h/2,r,i,o,s,n,!0,l)),p}function ky(t,e,r,i,o){const s=[];for(let n=0;n<t.length;n++){const a=t[n];let l;for(let c=0;c<a.length-1;c++){let u=a[c],h=a[c+1];u.x<e&&h.x<e||(u.x<e?u=new N(e,u.y+(e-u.x)/(h.x-u.x)*(h.y-u.y))._round():h.x<e&&(h=new N(e,u.y+(e-u.x)/(h.x-u.x)*(h.y-u.y))._round()),u.y<r&&h.y<r||(u.y<r?u=new N(u.x+(r-u.y)/(h.y-u.y)*(h.x-u.x),r)._round():h.y<r&&(h=new N(u.x+(r-u.y)/(h.y-u.y)*(h.x-u.x),r)._round()),u.x>=i&&h.x>=i||(u.x>=i?u=new N(i,u.y+(i-u.x)/(h.x-u.x)*(h.y-u.y))._round():h.x>=i&&(h=new N(i,u.y+(i-u.x)/(h.x-u.x)*(h.y-u.y))._round()),u.y>=o&&h.y>=o||(u.y>=o?u=new N(u.x+(o-u.y)/(h.y-u.y)*(h.x-u.x),o)._round():h.y>=o&&(h=new N(u.x+(o-u.y)/(h.y-u.y)*(h.x-u.x),o)._round()),l&&u.equals(l[l.length-1])||(l=[u],s.push(l)),l.push(h)))))}}return s}function Vd(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort((n,a)=>a.h-n.h);const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let o=0,s=0;for(const n of t)for(let a=i.length-1;a>=0;a--){const l=i[a];if(!(n.w>l.w||n.h>l.h)){if(n.x=l.x,n.y=l.y,s=Math.max(s,n.y+n.h),o=Math.max(o,n.x+n.w),n.w===l.w&&n.h===l.h){const c=i.pop();a<i.length&&(i[a]=c)}else n.h===l.h?(l.x+=n.w,l.w-=n.w):n.w===l.w?(l.y+=n.h,l.h-=n.h):(i.push({x:l.x+n.w,y:l.y,w:l.w-n.w,h:n.h}),l.y+=n.h,l.h-=n.h);break}}return{w:o,h:s,fill:e/(o*s)||0}}Ee(vo,"Anchor");const Kr=1;class jd{constructor(e,{pixelRatio:r,version:i,stretchX:o,stretchY:s,content:n}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+Kr,this.paddedRect.y+Kr]}get br(){return[this.paddedRect.x+this.paddedRect.w-Kr,this.paddedRect.y+this.paddedRect.h-Kr]}get displaySize(){return[(this.paddedRect.w-2*Kr)/this.pixelRatio,(this.paddedRect.h-2*Kr)/this.pixelRatio]}}class Py{constructor(e,r){const i={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(e,i,s),this.addImages(r,o,s);const{w:n,h:a}=Vd(s),l=new ir({width:n||1,height:a||1});for(const c in e){const u=e[c],h=i[c].paddedRect;ir.copy(u.data,l,{x:0,y:0},{x:h.x+Kr,y:h.y+Kr},u.data)}for(const c in r){const u=r[c],h=o[c].paddedRect,d=h.x+Kr,p=h.y+Kr,f=u.data.width,m=u.data.height;ir.copy(u.data,l,{x:0,y:0},{x:d,y:p},u.data),ir.copy(u.data,l,{x:0,y:m-1},{x:d,y:p-1},{width:f,height:1}),ir.copy(u.data,l,{x:0,y:0},{x:d,y:p+m},{width:f,height:1}),ir.copy(u.data,l,{x:f-1,y:0},{x:d-1,y:p},{width:1,height:m}),ir.copy(u.data,l,{x:0,y:0},{x:d+f,y:p},{width:1,height:m})}this.image=l,this.iconPositions=i,this.patternPositions=o}addImages(e,r,i){for(const o in e){const s=e[o],n={x:0,y:0,w:s.data.width+2*Kr,h:s.data.height+2*Kr};i.push(n),r[o]=new jd(n,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(e,r,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(o=>e.hasImage(o,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const o in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[o],e.getImage(o,i),r),this.patchUpdatedImage(this.patternPositions[o],e.getImage(o,i),r)}patchUpdatedImage(e,r,i){if(!e||!r||e.version===r.version)return;e.version=r.version;const[o,s]=e.tl;i.update(r.data,void 0,{x:o,y:s})}}Ee(jd,"ImagePosition"),Ee(Py,"ImageAtlas");const ya=1e20;function Ry(t,e,r,i,o,s,n,a,l){for(let c=e;c<e+i;c++)Ly(t,r*s+c,s,o,n,a,l);for(let c=r;c<r+o;c++)Ly(t,c*s+e,1,i,n,a,l)}function Ly(t,e,r,i,o,s,n){s[0]=0,n[0]=-ya,n[1]=ya,o[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){o[a]=t[e+a*r];const u=a*a;do{const h=s[l];c=(o[a]-o[h]+u-h*h)/(a-h)/2}while(c<=n[l]&&--l>-1);l++,s[l]=a,n[l]=c,n[l+1]=ya}for(let a=0,l=0;a<i;a++){for(;n[l+1]<a;)l++;const c=s[l],u=a-c;t[e+a*r]=o[c]+u*u}}const Di=2;class yn{constructor(e,r,i){this.requestManager=e,this.localGlyphMode=r,this.localFontFamily=i,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e,r){this.urls[r]=e}getGlyphs(e,r,i){const o=[],s=this.urls[r]||Ke.GLYPHS_URL;for(const n in e)for(const a of e[n])o.push({stack:n,id:a});os(o,({stack:n,id:a},l)=>{let c=this.entries[n];c||(c=this.entries[n]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let u=c.glyphs[a];if(u!==void 0)return void l(null,{stack:n,id:a,glyph:u});if(u=this._tinySDF(c,n,a),u)return c.glyphs[a]=u,void l(null,{stack:n,id:a,glyph:u});const h=Math.floor(a/256);if(256*h>65535)return void l(new Error("glyphs > 65535 not supported"));if(c.ranges[h])return void l(null,{stack:n,id:a,glyph:u});let d=c.requests[h];d||(d=c.requests[h]=[],yn.loadGlyphRange(n,h,s,this.requestManager,(p,f)=>{if(f){c.ascender=f.ascender,c.descender=f.descender;for(const m in f.glyphs)this._doesCharSupportLocalGlyph(+m)||(c.glyphs[+m]=f.glyphs[+m]);c.ranges[h]=!0}for(const m of d)m(p,f);delete c.requests[h]})),d.push((p,f)=>{p?l(p):f&&l(null,{stack:n,id:a,glyph:f.glyphs[a]||null})})},(n,a)=>{if(n)i(n);else if(a){const l={};for(const{stack:c,id:u,glyph:h}of a)l[c]===void 0&&(l[c]={}),l[c].glyphs===void 0&&(l[c].glyphs={}),l[c].glyphs[u]=h&&{id:h.id,bitmap:h.bitmap.clone(),metrics:h.metrics},l[c].ascender=this.entries[c].ascender,l[c].descender=this.entries[c].descender;i(null,l)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==0&&(this.localGlyphMode===2?!!this.localFontFamily:!!this.localFontFamily&&(Ae["CJK Unified Ideographs"](e)||Ae["Hangul Syllables"](e)||Ae.Hiragana(e)||Ae.Katakana(e)||Ae["CJK Symbols and Punctuation"](e)||Ae["CJK Unified Ideographs Extension A"](e)||Ae["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,r,i){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(i))return;let s=e.tinySDF;if(!s){let m="400";/bold/i.test(r)?m="900":/medium/i.test(r)?m="500":/light/i.test(r)&&(m="200"),s=e.tinySDF=new yn.TinySDF({fontFamily:o,fontWeight:m,fontSize:24*Di,buffer:3*Di,radius:8*Di}),s.fontWeight=m}if(this.localGlyphs[s.fontWeight][i])return this.localGlyphs[s.fontWeight][i];const n=String.fromCodePoint(i),{data:a,width:l,height:c,glyphWidth:u,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=s.draw(n);return this.localGlyphs[s.fontWeight][i]={id:i,bitmap:new yo({width:l,height:c},a),metrics:{width:u/Di,height:h/Di,left:d/Di,top:p/Di-27,advance:f/Di,localGlyph:!0}}}}yn.loadGlyphRange=function(t,e,r,i,o){const s=256*e,n=s+255,a=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${s}-${n}`),J.Glyphs);fe(a,(l,c)=>{if(l)o(l);else if(c){const u={},h=function(d){return new sc(d).readFields(S2,{})}(c);for(const d of h.glyphs)u[d.id]=d;o(null,{glyphs:u,ascender:h.ascender,descender:h.descender})}})},yn.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:i=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:n="normal"}={}){this.buffer=e,this.cutoff=i,this.radius=r;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${n} ${s} ${t}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(t),n=Math.ceil(r),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,n+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:n,glyphLeft:0,glyphAdvance:e};if(a===0||l===0)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+n);const y=f.getImageData(m,m,a,l);g.fill(ya,0,h),_.fill(0,0,h);for(let v=0;v<l;v++)for(let b=0;b<a;b++){const x=y.data[4*(v*a+b)+3]/255;if(x===0)continue;const w=(v+m)*c+b+m;if(x===1)g[w]=0,_[w]=ya;else{const T=.5-x;g[w]=T>0?T*T:0,_[w]=T<0?T*T:0}}Ry(g,0,0,c,u,c,this.f,this.v,this.z),Ry(_,m,m,a,l,c,this.f,this.v,this.z);for(let v=0;v<h;v++){const b=Math.sqrt(g[v])-Math.sqrt(_[v]);d[v]=Math.round(255-255*(b/this.radius+this.cutoff))}return p}};const Go=Kr;function By(t,e,r,i){const o=[],s=t.imagePrimary,n=s.pixelRatio,a=s.paddedRect.w-2*Go,l=s.paddedRect.h-2*Go,c=t.right-t.left,u=t.bottom-t.top,h=s.stretchX||[[0,a]],d=s.stretchY||[[0,l]],p=(I,C)=>I+C[1]-C[0],f=h.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,b=0,x=m,w=0,T=_,E=0,M=g;if(s.content&&i){const I=s.content;y=cc(h,0,I[0]),b=cc(d,0,I[1]),v=cc(h,I[0],I[2]),x=cc(d,I[1],I[3]),w=I[0]-y,E=I[1]-b,T=I[2]-I[0]-v,M=I[3]-I[1]-x}const S=(I,C,k,A)=>{const L=uc(I.stretch-y,v,c,t.left),O=hc(I.fixed-w,T,I.stretch,f),U=uc(C.stretch-b,x,u,t.top),R=hc(C.fixed-E,M,C.stretch,m),B=uc(k.stretch-y,v,c,t.left),G=hc(k.fixed-w,T,k.stretch,f),Z=uc(A.stretch-b,x,u,t.top),q=hc(A.fixed-E,M,A.stretch,m),X=new N(L,U),Y=new N(B,U),K=new N(B,Z),H=new N(L,Z),ee=new N(O/n,R/n),de=new N(G/n,q/n),pe=e*Math.PI/180;if(pe){const st=Math.sin(pe),Be=Math.cos(pe),Re=[Be,-st,st,Be];X._matMult(Re),Y._matMult(Re),H._matMult(Re),K._matMult(Re)}const ge=I.stretch+I.fixed,xe=k.stretch+k.fixed,Oe=C.stretch+C.fixed,Ie=A.stretch+A.fixed,ht=t.imageSecondary;return{tl:X,tr:Y,bl:H,br:K,texPrimary:{x:s.paddedRect.x+Go+ge,y:s.paddedRect.y+Go+Oe,w:xe-ge,h:Ie-Oe},texSecondary:ht?{x:ht.paddedRect.x+Go+ge,y:ht.paddedRect.y+Go+Oe,w:xe-ge,h:Ie-Oe}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ee,pixelOffsetBR:de,minFontScaleX:T/n/c,minFontScaleY:M/n/u,isSDF:r}};if(i&&(s.stretchX||s.stretchY)){const I=Oy(h,_,f),C=Oy(d,g,m);for(let k=0;k<I.length-1;k++){const A=I[k],L=I[k+1];for(let O=0;O<C.length-1;O++)o.push(S(A,C[O],L,C[O+1]))}}else o.push(S({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:l+1}));return o}function cc(t,e,r){let i=0;for(const o of t)i+=Math.max(e,Math.min(r,o[1]))-Math.max(e,Math.min(r,o[0]));return i}function Oy(t,e,r){const i=[{fixed:-Go,stretch:0}];for(const[o,s]of t){const n=i[i.length-1];i.push({fixed:o-n.stretch,stretch:n.stretch}),i.push({fixed:o-n.stretch,stretch:n.stretch+(s-o)})}return i.push({fixed:e+Go,stretch:r}),i}function uc(t,e,r,i){return t/e*r+i}function hc(t,e,r,i){return t-e*r/i}function R2(t,e,r,i){const o=e+t.positionedLines[i].lineOffset;return i===0?r+o/2:r+(o+(e+t.positionedLines[i-1].lineOffset))/2}function L2(t,e=1,r=!1){let i=1/0,o=1/0,s=-1/0,n=-1/0;const a=t[0];for(let p=0;p<a.length;p++){const f=a[p];(!p||f.x<i)&&(i=f.x),(!p||f.y<o)&&(o=f.y),(!p||f.x>s)&&(s=f.x),(!p||f.y>n)&&(n=f.y)}const l=Math.min(s-i,n-o);let c=l/2;const u=new Ru([],B2);if(l===0)return new N(i,o);for(let p=i;p<s;p+=l)for(let f=o;f<n;f+=l)u.push(new xn(p+c,f+c,c,t));let h=function(p){let f=0,m=0,_=0;const g=p[0];for(let y=0,v=g.length,b=v-1;y<v;b=y++){const x=g[y],w=g[b],T=x.x*w.y-w.x*x.y;m+=(x.x+w.x)*T,_+=(x.y+w.y)*T,f+=3*T}return new xn(m/f,_/f,0,p)}(t),d=u.length;for(;u.length;){const p=u.pop();(p.d>h.d||!h.d)&&(h=p,r&&console.log("found best %d after %d probes",Math.round(1e4*p.d)/1e4,d)),p.max-h.d<=e||(c=p.h/2,u.push(new xn(p.p.x-c,p.p.y-c,c,t)),u.push(new xn(p.p.x+c,p.p.y-c,c,t)),u.push(new xn(p.p.x-c,p.p.y+c,c,t)),u.push(new xn(p.p.x+c,p.p.y+c,c,t)),d+=4)}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function B2(t,e){return e.max-t.max}class xn{constructor(e,r,i,o){this.p=new N(e,r),this.h=i,this.d=function(s,n){let a=!1,l=1/0;for(let c=0;c<n.length;c++){const u=n[c];for(let h=0,d=u.length,p=d-1;h<d;p=h++){const f=u[h],m=u[p];f.y>s.y!=m.y>s.y&&s.x<(m.x-f.x)*(s.y-f.y)/(m.y-f.y)+f.x&&(a=!a),l=Math.min(l,Fg(s,f,m))}}return(a?1:-1)*Math.sqrt(l)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}}const vn=7,Gd=Number.POSITIVE_INFINITY,O2=Math.sqrt(2);function qd(t,[e,r]){let i=0,o=0;if(r===Gd){e<0&&(e=0);const s=e/O2;switch(t){case"top-right":case"top-left":o=s-vn;break;case"bottom-right":case"bottom-left":o=-s+vn;break;case"bottom":o=-e+vn;break;case"top":o=e-vn}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}}else{switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":o=r-vn;break;case"bottom-right":case"bottom-left":case"bottom":o=-r+vn}switch(t){case"top-right":case"bottom-right":case"right":i=-e;break;case"top-left":case"bottom-left":case"left":i=e}}return[i,o]}function F2(t,e,r,i,o,s,n,a,l,c,u){t.createArrays(),t.tilePixelRatio=W/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const h=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if(t.textSizeData.kind==="composite"){const{minZoom:g,maxZoom:y}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ut(g),a),d["text-size"].possiblyEvaluate(new Ut(y),a)]}if(t.iconSizeData.kind==="composite"){const{minZoom:g,maxZoom:y}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ut(g),a),d["icon-size"].possiblyEvaluate(new Ut(y),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ut(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ut(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ut(18),a);const f=h.get("text-rotation-alignment")==="map"&&h.get("symbol-placement")!=="point",m=h.get("text-size");let _=!1;for(const g of t.features)if(g.icon&&g.icon.nameSecondary){_=!0;break}for(const g of t.features){const y=h.get("text-font").evaluate(g,{},a).join(","),v=m.evaluate(g,{},a),b=p.layoutTextSize.evaluate(g,{},a),x=(p.layoutIconSize.evaluate(g,{},a),{horizontal:{},vertical:void 0}),w=g.text;let T,E=[0,0];if(w){const I=w.toString(),C=h.get("text-letter-spacing").evaluate(g,{},a)*xr,k=h.get("text-line-height").evaluate(g,{},a)*xr,A=ub(I)?C:0,L=h.get("text-anchor").evaluate(g,{},a),O=h.get("text-variable-anchor");if(!O){const Z=h.get("text-radial-offset").evaluate(g,{},a);E=Z?qd(L,[Z*xr,Gd]):h.get("text-offset").evaluate(g,{},a).map(q=>q*xr)}let U=f?"center":h.get("text-justify").evaluate(g,{},a);const R=h.get("symbol-placement")==="point",B=R?h.get("text-max-width").evaluate(g,{},a)*xr:1/0,G=Z=>{t.allowVerticalPlacement&&xh(I)&&(x.vertical=Ud(w,e,r,o,y,B,k,L,Z,A,E,Nt.vertical,!0,b,v))};if(!f&&O){const Z=U==="auto"?O.map(X=>Zd(X)):[U];let q=!1;for(let X=0;X<Z.length;X++){const Y=Z[X];if(!x.horizontal[Y])if(q)x.horizontal[Y]=x.horizontal[0];else{const K=Ud(w,e,r,o,y,B,k,"center",Y,A,E,Nt.horizontal,!1,b,v);K&&(x.horizontal[Y]=K,q=K.positionedLines.length===1)}}G("left")}else{if(U==="auto"&&(U=Zd(L)),R||h.get("text-writing-mode").indexOf("horizontal")>=0||!xh(I)){const Z=Ud(w,e,r,o,y,B,k,L,U,A,E,Nt.horizontal,!1,b,v);Z&&(x.horizontal[U]=Z)}G(R?"left":U)}}let M=!1;if(g.icon&&g.icon.namePrimary){const I=i[g.icon.namePrimary];I&&(T=D2(o[g.icon.namePrimary],g.icon.nameSecondary?o[g.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(g,{},a),h.get("icon-anchor").evaluate(g,{},a)),M=I.sdf,t.sdfIcons===void 0?t.sdfIcons=I.sdf:t.sdfIcons!==I.sdf&&F("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(I.pixelRatio!==t.pixelRatio||h.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}const S=Ny(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!S&&S.iconsInText),(S||T)&&N2(t,g,x,T,i,p,b,0,E,M,n,a,c,u,_)}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Zd(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 N2(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f){let m=s.textMaxSize.evaluate(e,{},h);m===void 0&&(m=n);const _=t.layers[0].layout,g=_.get("icon-offset").evaluate(e,{},h),y=Ny(r.horizontal)||r.vertical,v=d.name==="globe",b=xr,x=n/b,w=t.tilePixelRatio*m/b,T=(L=t.overscaling,t.zoom>18&&L>2&&(L>>=1),Math.max(W/(512*L),1)*_.get("symbol-spacing")),E=_.get("text-padding")*t.tilePixelRatio,M=_.get("icon-padding")*t.tilePixelRatio,S=$e(_.get("text-max-angle")),I=_.get("text-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point",C=_.get("icon-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point",k=_.get("symbol-placement"),A=T/2;var L;const O=_.get("icon-text-fit").evaluate(e,{},h),U=_.get("icon-text-fit-padding").evaluate(e,{},h),R=O!=="none";let B;t.hasAnyIconTextFit===!1&&R&&(t.hasAnyIconTextFit=!0),i&&R&&(t.allowVerticalPlacement&&r.vertical&&(B=Sy(i,r.vertical,O,U,g,x)),y&&(i=Sy(i,y,O,U,g,x)));const G=(Z,q,X)=>{if(q.x<0||q.x>=W||q.y<0||q.y>=W)return;let Y=null;if(v){const{x:K,y:H,z:ee}=d.projectTilePoint(q.x,q.y,X);Y={anchor:new vo(K,H,ee,0,void 0),up:d.upVector(X,q.x,q.y)}}(function(K,H,ee,de,pe,ge,xe,Oe,Ie,ht,st,Be,Re,De,at,ut,Je,Ct,Kt,St,Rt,rr,Qt,Ot,bt,Er,Qi){const bo=K.addToLineVertexArray(H,de);let wo,Ua,Va,nu,Z1,$1,H1,W1=0,X1=0,Y1=0,J1=0,Zp=-1,$p=-1;const eo={};let K1=qh("");const Ds=ee?ee.anchor:H,Hp=Ie.layout.get("icon-text-fit").evaluate(Rt,{},bt)!=="none";let Wp=0,Xp=0;if(Ie._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Wp,Xp]=Ie.layout.get("text-offset").evaluate(Rt,{},bt).map(ei=>ei*xr):(Wp=Ie.layout.get("text-radial-offset").evaluate(Rt,{},bt)*xr,Xp=Gd),K.allowVerticalPlacement&&pe.vertical){const ei=pe.vertical;if(at)$1=$d(ei),Oe&&(H1=$d(Oe));else{const ti=Ie.layout.get("text-rotate").evaluate(Rt,{},bt)+90;Va=dc(ht,Ds,H,st,Be,Re,ei,De,ti,ut),Oe&&(nu=dc(ht,Ds,H,st,Be,Re,Oe,Ct,ti))}}if(ge){const ei=Ie.layout.get("icon-rotate").evaluate(Rt,{},bt),ti=By(ge,ei,Qt,Hp),Dn=Oe?By(Oe,ei,Qt,Hp):void 0;Ua=dc(ht,Ds,H,st,Be,Re,ge,Ct,ei),W1=4*ti.length;const Q1=K.iconSizeData;let ks=null;Q1.kind==="source"?(ks=[zi*Ie.layout.get("icon-size").evaluate(Rt,{},bt)],ks[0]>qo&&F(`${K.layerIds[0]}: Value for "icon-size" is >= ${xa}. Reduce your "icon-size".`)):Q1.kind==="composite"&&(ks=[zi*rr.compositeIconSizes[0].evaluate(Rt,{},bt),zi*rr.compositeIconSizes[1].evaluate(Rt,{},bt)],(ks[0]>qo||ks[1]>qo)&&F(`${K.layerIds[0]}: Value for "icon-size" is >= ${xa}. Reduce your "icon-size".`)),K.addSymbols(K.icon,ti,ks,St,Kt,Rt,!1,ee,H,bo.lineStartIndex,bo.lineLength,-1,Ot,bt,Er,Qi),Zp=K.icon.placedSymbolArray.length-1,Dn&&(X1=4*Dn.length,K.addSymbols(K.icon,Dn,ks,St,Kt,Rt,Nt.vertical,ee,H,bo.lineStartIndex,bo.lineLength,-1,Ot,bt,Er,Qi),$p=K.icon.placedSymbolArray.length-1)}for(const ei in pe.horizontal){const ti=pe.horizontal[ei];wo||(K1=qh(ti.text),at?Z1=$d(ti):wo=dc(ht,Ds,H,st,Be,Re,ti,De,Ie.layout.get("text-rotate").evaluate(Rt,{},bt),ut));const Dn=ti.positionedLines.length===1;if(Y1+=Fy(K,ee,H,ti,xe,Ie,at,Rt,ut,bo,pe.vertical?Nt.horizontal:Nt.horizontalOnly,Dn?Object.keys(pe.horizontal):[ei],eo,Zp,rr,Ot,bt,Er),Dn)break}pe.vertical&&(J1+=Fy(K,ee,H,pe.vertical,xe,Ie,at,Rt,ut,bo,Nt.vertical,["vertical"],eo,$p,rr,Ot,bt,Er));let Ko=-1;const Yp=(ei,ti)=>ei?Math.max(ei,ti):ti;Ko=Yp(Z1,Ko),Ko=Yp($1,Ko),Ko=Yp(H1,Ko);const TS=Ko>-1?1:0;K.glyphOffsetArray.length>=Ea.MAX_GLYPHS&&F("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Rt.sortKey!==void 0&&K.addToSortKeyRanges(K.symbolInstances.length,Rt.sortKey),K.symbolInstances.emplaceBack(H.x,H.y,Ds.x,Ds.y,Ds.z,eo.right>=0?eo.right:-1,eo.center>=0?eo.center:-1,eo.left>=0?eo.left:-1,eo.vertical>=0?eo.vertical:-1,Zp,$p,K1,wo!==void 0?wo:K.collisionBoxArray.length,wo!==void 0?wo+1:K.collisionBoxArray.length,Va!==void 0?Va:K.collisionBoxArray.length,Va!==void 0?Va+1:K.collisionBoxArray.length,Ua!==void 0?Ua:K.collisionBoxArray.length,Ua!==void 0?Ua+1:K.collisionBoxArray.length,nu||K.collisionBoxArray.length,nu?nu+1:K.collisionBoxArray.length,st,Y1,J1,W1,X1,TS,0,Wp,Xp,Ko,0,Hp?1:0)})(t,q,Y,Z,r,i,o,B,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,E,I,l,0,M,C,g,e,s,c,u,h,p,f)};if(k==="line")for(const Z of ky(e.geometry,0,0,W,W)){const q=P2(Z,T,S,r.vertical||y,i,b,w,t.overscaling,W);for(const X of q)y&&U2(t,y.text,A,X)||G(Z,X,h)}else if(k==="line-center"){for(const Z of e.geometry)if(Z.length>1){const q=k2(Z,S,r.vertical||y,i,b,w);q&&G(Z,q,h)}}else if(e.type==="Polygon")for(const Z of kd(e.geometry,0)){const q=L2(Z,16);G(Z[0],new vo(q.x,q.y,0,0,void 0),h)}else if(e.type==="LineString")for(const Z of e.geometry)G(Z,new vo(Z[0].x,Z[0].y,0,0,void 0),h);else if(e.type==="Point")for(const Z of e.geometry)for(const q of Z)G([q],new vo(q.x,q.y,0,0,void 0),h)}const xa=255,qo=xa*zi;function Fy(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=function(x,w,T,E,M,S,I,C){const k=[];if(w.positionedLines.length===0)return k;const A=E.layout.get("text-rotate").evaluate(S,{})*Math.PI/180,L=function(G){const Z=G[0],q=G[1],X=Z*q;return X>0?[Z,-q]:X<0?[-Z,q]:Z===0?[q,Z]:[q,-Z]}(T);let O=Math.abs(w.top-w.bottom);for(const G of w.positionedLines)O-=G.lineOffset;const U=w.positionedLines.length,R=O/U;let B=w.top-T[1];for(let G=0;G<U;++G){const Z=w.positionedLines[G];B=R2(w,R,B,G);for(const q of Z.positionedGlyphs){if(!q.rect)continue;const X=q.rect||{};let Y=xy+1,K=!0,H=1,ee=0;if(q.imageName){const St=I[q.imageName];if(!St)continue;if(St.sdf){F("SDF images are not supported in formatted text and will be ignored.");continue}K=!1,H=St.pixelRatio,Y=Kr/H}const de=(M||C)&&q.vertical,pe=q.metrics.advance*q.scale/2,ge=q.metrics,xe=q.rect;if(xe===null)continue;C&&w.verticalizable&&(ee=q.imageName?pe-q.metrics.width*q.scale/2:0);const Oe=M?[q.x+pe,q.y]:[0,0];let Ie=[0,0],ht=[0,0],st=!1;M||(de?(ht=[q.x+pe+L[0],q.y+L[1]-ee],st=!0):Ie=[q.x+pe+T[0],q.y+T[1]-ee]);const Be=xe.w*q.scale/(H*(q.localGlyph?Di:1)),Re=xe.h*q.scale/(H*(q.localGlyph?Di:1));let De,at,ut,Je;if(de){const St=q.y-B,Rt=new N(-pe,pe-St),rr=-Math.PI/2,Qt=new N(...ht);De=new N(-pe+Ie[0],Ie[1]),De._rotateAround(rr,Rt)._add(Qt),De.x+=-St+pe,De.y-=(ge.left-Y)*q.scale;const Ot=q.imageName?ge.advance*q.scale:xr*q.scale,bt=String.fromCodePoint(q.glyph);E2(bt)?De.x+=(1-Y)*q.scale:M2(bt)?De.x+=Ot-ge.height*q.scale+(-Y-1)*q.scale:De.x+=q.imageName||ge.width+2*Y===xe.w&&ge.height+2*Y===xe.h?(Ot-Re)/2:(Ot-(ge.height+2*Y)*q.scale)/2,at=new N(De.x,De.y-Be),ut=new N(De.x+Re,De.y),Je=new N(De.x+Re,De.y-Be)}else{const St=(ge.left-Y)*q.scale-pe+Ie[0],Rt=(-ge.top-Y)*q.scale+Ie[1],rr=St+Be,Qt=Rt+Re;De=new N(St,Rt),at=new N(rr,Rt),ut=new N(St,Qt),Je=new N(rr,Qt)}if(A){let St;St=M?new N(0,0):st?new N(L[0],L[1]):new N(T[0],T[1]),De._rotateAround(A,St),at._rotateAround(A,St),ut._rotateAround(A,St),Je._rotateAround(A,St)}const Ct=new N(0,0),Kt=new N(0,0);k.push({tl:De,tr:at,bl:ut,br:Je,texPrimary:X,texSecondary:void 0,writingMode:w.writingMode,glyphOffset:Oe,sectionIndex:q.sectionIndex,isSDF:K,pixelOffsetTL:Ct,pixelOffsetBR:Kt,minFontScaleX:0,minFontScaleY:0})}}return k}(0,i,l,s,n,a,o,t.allowVerticalPlacement),v=t.textSizeData;let b=null;v.kind==="source"?(b=[zi*s.layout.get("text-size").evaluate(a,{},_)],b[0]>qo&&F(`${t.layerIds[0]}: Value for "text-size" is >= ${xa}. Reduce your "text-size".`)):v.kind==="composite"&&(b=[zi*f.compositeTextSizes[0].evaluate(a,{},_),zi*f.compositeTextSizes[1].evaluate(a,{},_)],(b[0]>qo||b[1]>qo)&&F(`${t.layerIds[0]}: Value for "text-size" is >= ${xa}. Reduce your "text-size".`)),t.addSymbols(t.text,y,b,l,n,a,u,e,r,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const x of h)d[x]=t.text.placedSymbolArray.length-1;return 4*y.length}function Ny(t){for(const e in t)return t[e];return null}function dc(t,e,r,i,o,s,n,a,l,c){let u=n.top,h=n.bottom,d=n.left,p=n.right;const f=n.collisionPadding;if(f&&(d-=f[0],u-=f[1],p+=f[2],h+=f[3]),l){const m=new N(d,u),_=new N(p,u),g=new N(d,h),y=new N(p,h),v=$e(l);let b=new N(0,0);c&&(b=new N(c[0],c[1])),m._rotateAround(v,b),_._rotateAround(v,b),g._rotateAround(v,b),y._rotateAround(v,b),d=Math.min(m.x,_.x,g.x,y.x),p=Math.max(m.x,_.x,g.x,y.x),u=Math.min(m.y,_.y,g.y,y.y),h=Math.max(m.y,_.y,g.y,y.y)}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,d,u,p,h,a,i,o,s),t.length-1}function $d(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 U2(t,e,r,i){const o=t.compareText;if(e in o){const s=o[e];for(let n=s.length-1;n>=0;n--)if(i.dist(s[n])<r)return!0}else o[e]=[];return o[e].push(i),!1}function Uy(t,e){const r=t.fovAboveCenter,i=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,o=(t._camera.position[2]*t.worldSize-i)/Math.cos(t._pitch),s=Math.sin(r)*o/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01)),n=Math.sin(t._pitch)*s+o;return Math.min(1.01*n,o*(1/t._horizonShift))}function Ts(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 r=Math.pow(2,-t.z),i=t.x*r,o=(t.x+1)*r,s=t.y*r,n=(t.y+1)*r,a=Jr(i),l=Jr(o),c=ar(s),u=ar(n),h=e.project(a,c),d=e.project(l,c),p=e.project(l,u),f=e.project(a,u);let m=Math.min(h.x,d.x,p.x,f.x),_=Math.min(h.y,d.y,p.y,f.y),g=Math.max(h.x,d.x,p.x,f.x),y=Math.max(h.y,d.y,p.y,f.y);const v=r/16;function b(w,T,E,M,S,I){const C=(E+S)/2,k=(M+I)/2,A=e.project(Jr(C),ar(k)),L=Math.max(0,m-A.x,_-A.y,A.x-g,A.y-y);m=Math.min(m,A.x),g=Math.max(g,A.x),_=Math.min(_,A.y),y=Math.max(y,A.y),L>v&&(b(w,A,E,M,C,k),b(A,T,C,k,S,I))}b(h,d,i,s,o,s),b(d,p,o,s,o,n),b(p,f,o,n,i,n),b(f,h,i,n,i,s),m-=v,_-=v,g+=v,y+=v;const x=1/Math.max(g-m,y-_);return{scale:x,x:m*x,y:_*x,x2:g*x,y2:y*x,projection:e}}function Vy(t,e,r,i,o,s,n,a,l){if(l.name==="globe")return fd(t,e,new _i(r,i,o),!1);const c=Ts({z:r,x:i,y:o},l);return new Pt([(s+c.x/c.scale)*e,e*(c.y/c.scale),n],[(s+c.x2/c.scale)*e,e*(c.y2/c.scale),a])}function jy(t,{x:e,y:r},i=0){return new N(((e-i)*t.scale-t.x)*W,(r*t.scale-t.y)*W)}function Gy(t,e,r=0){return D.fromValues(((e.x-r)*t.scale-t.x)*W,(e.y*t.scale-t.y)*W,kg(e.z,e.y))}const V2=V.identity(new Float32Array(16));class Zo{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,r){return{x:0,y:0,z:0}}unproject(e,r){return new Ne(0,0)}projectTilePoint(e,r,i){return{x:e,y:r,z:0}}locationPoint(e,r,i=!0){return e._coordinatePoint(e.locationCoordinate(r),i)}pixelsPerMeter(e,r){return It(1,e)*r}pixelSpaceConversion(e,r,i){return 1}farthestPixelDistance(e){return Uy(e,e.pixelsPerMeter)}pointCoordinate(e,r,i,o){const s=e.horizonLineFromTop(!1),n=new N(r,Math.max(s,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(n,o))}pointCoordinate3D(e,r,i){const o=new N(r,i);if(e.elevation)return e.elevation.pointCoordinate(o);{const s=this.pointCoordinate(e,o.x,o.y,0);return[s.x,s.y,s.z]}}isPointAboveHorizon(e,r){if(e.elevation)return!this.pointCoordinate3D(e,r.x,r.y);const i=e.horizonLineFromTop();return r.y<i}createInversionMatrix(e,r){return V2}createTileMatrix(e,r,i){let o,s,n;const a=i.canonical,l=V.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const c=Ts(a,this);o=1,s=c.x+i.wrap*c.scale,n=c.y,V.scale(l,l,[o/c.scale,o/c.scale,e.pixelsPerMeter/r])}else o=r/e.zoomScale(a.z),s=(a.x+Math.pow(2,a.z)*i.wrap)*o,n=a.y*o;return V.translate(l,l,[s,n,0]),V.scale(l,l,[o/W,o/W,1]),l}upVector(e,r,i){return[0,0,1]}upVectorScale(e,r,i){return{metersToTile:1}}}class j2 extends Zo{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[r,i]=this.parallels=e.parallels||[29.5,45.5],o=Math.sin($e(r));this.n=(o+Math.sin($e(i)))/2,this.c=1+o*(2*this.n-o),this.r0=Math.sqrt(this.c)/this.n}project(e,r){const{n:i,c:o,r0:s}=this,n=$e(e-this.center[0]),a=$e(r),l=Math.sqrt(o-2*i*Math.sin(a))/i;return{x:l*Math.sin(n*i),y:l*Math.cos(n*i)-s,z:0}}unproject(e,r){const{n:i,c:o,r0:s}=this,n=s+r;let a=Math.atan2(e,Math.abs(n))*Math.sign(n);n*i<0&&(a-=Math.PI*Math.sign(e)*Math.sign(n));const l=$e(this.center[0])*i;a=Ni(a,-Math.PI-l,Math.PI-l);const c=Se(br(a/i)+this.center[0],-180,180),u=Math.asin(Se((o-(e*e+n*n)*i*i)/(2*i),-1,1)),h=Se(br(u),-Jt,Jt);return new Ne(c,h)}}const va=1.340264,ba=-.081106,wa=893e-6,Ta=.003796,pc=Math.sqrt(3)/2;class G2 extends Zo{project(e,r){r=r/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(pc*Math.sin(r)),o=i*i,s=o*o*o;return{x:.5*(e*Math.cos(i)/(pc*(va+3*ba*o+s*(7*wa+9*Ta*o)))/Math.PI+.5),y:1-.5*(i*(va+ba*o+s*(wa+Ta*o))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let i=r=(2*(1-r)-1)*Math.PI,o=i*i,s=o*o*o;for(let u,h,d,p=0;p<12&&(h=i*(va+ba*o+s*(wa+Ta*o))-r,d=va+3*ba*o+s*(7*wa+9*Ta*o),u=h/d,i=Se(i-u,-Math.PI/3,Math.PI/3),o=i*i,s=o*o*o,!(Math.abs(u)<1e-12));++p);const n=pc*e*(va+3*ba*o+s*(7*wa+9*Ta*o))/Math.cos(i),a=Math.asin(Math.sin(i)/pc),l=Se(180*n/Math.PI,-180,180),c=Se(180*a/Math.PI,-Jt,Jt);return new Ne(l,c)}}class q2 extends Zo{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){return{x:.5+e/360,y:.5-r/360,z:0}}unproject(e,r){const i=360*(e-.5),o=Se(360*(.5-r),-Jt,Jt);return new Ne(i,o)}}const bn=Math.PI/2;function fc(t){return Math.tan((bn+t)/2)}class Z2 extends Zo{constructor(e){super(e),this.center=e.center||[0,30];const[r,i]=this.parallels=e.parallels||[30,30];let o=$e(r),s=$e(i);this.southernCenter=o+s<0,this.southernCenter&&(o=-o,s=-s);const n=Math.cos(o),a=fc(o);this.n=o===s?Math.sin(o):Math.log(n/Math.cos(s))/Math.log(fc(s)/a),this.f=n*Math.pow(fc(o),this.n)/this.n}project(e,r){r=$e(r),this.southernCenter&&(r=-r),e=$e(e-this.center[0]);const i=1e-6,{n:o,f:s}=this;s>0?r<-bn+i&&(r=-bn+i):r>bn-i&&(r=bn-i);const n=s/Math.pow(fc(r),o);let a=n*Math.sin(o*e),l=s-n*Math.cos(o*e);return a=.5*(a/Math.PI+.5),l=.5*(l/Math.PI+.5),{x:a,y:this.southernCenter?l:1-l,z:0}}unproject(e,r){e=(2*e-.5)*Math.PI,this.southernCenter&&(r=1-r),r=(2*(1-r)-.5)*Math.PI;const{n:i,f:o}=this,s=o-r,n=Math.sign(s),a=Math.sign(i)*Math.sqrt(e*e+s*s);let l=Math.atan2(e,Math.abs(s))*n;s*i<0&&(l-=Math.PI*Math.sign(e)*n);const c=Se(br(l/i)+this.center[0],-180,180),u=Se(br(2*Math.atan(Math.pow(o/a,1/i))-bn),-Jt,Jt);return new Ne(c,this.southernCenter?-u:u)}}class qy extends Zo{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,r){return{x:ur(e),y:dr(r),z:0}}unproject(e,r){const i=Jr(e),o=ar(r);return new Ne(i,o)}}const Zy=$e(Jt);class $2 extends Zo{project(e,r){const i=(r=$e(r))*r,o=i*i;return{x:.5*((e=$e(e))*(.8707-.131979*i+o*(o*(.003971*i-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+i*(.015085+o*(.028874*i-.044475-.005916*o)))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let i=r=(2*(1-r)-1)*Math.PI,o=25,s=0,n=i*i;do{n=i*i;const c=n*n;s=(i*(1.007226+n*(.015085+c*(.028874*n-.044475-.005916*c)))-r)/(1.007226+n*(.045255+c*(.259866*n-.311325-.005916*11*c))),i=Se(i-s,-Zy,Zy)}while(Math.abs(s)>1e-6&&--o>0);n=i*i;const a=Se(br(e/(.8707+n*(n*(n*n*n*(.003971-.001529*n)-.013791)-.131979))),-180,180),l=br(i);return new Ne(a,l)}}const $y=$e(Jt);class H2 extends Zo{project(e,r){r=$e(r),e=$e(e);const i=Math.cos(r),o=2/Math.PI,s=Math.acos(i*Math.cos(e/2)),n=Math.sin(s)/s,a=.5*(e*o+2*i*Math.sin(e/2)/n)||0,l=.5*(r+Math.sin(r)/n)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+1),z:0}}unproject(e,r){let i=e=(2*e-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25;const n=1e-6;let a=0,l=0;do{const c=Math.cos(o),u=Math.sin(o),h=2*u*c,d=u*u,p=c*c,f=Math.cos(i/2),m=Math.sin(i/2),_=2*f*m,g=m*m,y=1-p*f*f,v=y?1/y:0,b=y?Math.acos(c*f)*Math.sqrt(1/y):0,x=.5*(2*b*c*m+2*i/Math.PI)-e,w=.5*(b*u+o)-r,T=.5*v*(p*g+b*c*f*d)+1/Math.PI,E=v*(_*h/4-b*u*m),M=.125*v*(h*m-b*u*p*_),S=.5*v*(d*f+b*g*c)+.5,I=E*M-S*T;a=(w*E-x*S)/I,l=(x*M-w*T)/I,i=Se(i-a,-Math.PI,Math.PI),o=Se(o-l,-$y,$y)}while((Math.abs(a)>n||Math.abs(l)>n)&&--s>0);return new Ne(br(i),br(o))}}class Hy extends Zo{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos($e(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){const{scale:i,cosPhi:o}=this;return{x:$e(e)*o*i+.5,y:-Math.sin($e(r))/o*i+.5,z:0}}unproject(e,r){const{scale:i,cosPhi:o}=this,s=-(r-.5)/i,n=Se(br((e-.5)/i)/o,-180,180),a=Math.asin(Se(s*o,-1,1)),l=Se(br(a),-Jt,Jt);return new Ne(n,l)}}class W2 extends qy{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,r,i){const o=ua(e,r,i),s=Oo(si(i));return D.transformMat4(o,o,s),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,r){const i=Nr(r.lat,r.lng),o=D.normalize([],i),s=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude,n=It(1,0)*W*s;D.scaleAndAdd(i,i,o,n);const a=V.identity(new Float64Array(16));return V.multiply(a,e.pixelMatrix,e.globeMatrix),D.transformMat4(i,i,a),new N(i[0],i[1])}pixelsPerMeter(e,r){return It(1,0)*r}pixelSpaceConversion(e,r,i){const o=It(1,e)*r,s=Fe(It(1,45)*r,o,i);return this.pixelsPerMeter(e,r)/s}createTileMatrix(e,r,i){const o=_d(si(i.canonical));return V.multiply(new Float64Array(16),e.globeMatrix,o)}createInversionMatrix(e,r){const{center:i}=e,o=Oo(si(r));return V.rotateY(o,o,$e(i.lng)),V.rotateX(o,o,$e(i.lat)),V.scale(o,o,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(o)}pointCoordinate(e,r,i,o){return xg(e,r,i,!0)||new lt(0,0)}pointCoordinate3D(e,r,i){const o=this.pointCoordinate(e,r,i,0);return[o.x,o.y,o.z]}isPointAboveHorizon(e,r){return!xg(e,r.x,r.y,!1)}farthestPixelDistance(e){const r=function(o,s){const n=o.cameraToCenterDistance,a=o._centerAltitude*s,l=o._camera,c=o._camera.forward(),u=D.add([],D.scale([],c,-n),[0,0,a]),h=o.worldSize/(2*Math.PI),d=[0,0,-h],p=o.width/o.height,f=Math.tan(o.fovAboveCenter),m=D.scale([],l.up(),f),_=D.scale([],l.right(),f*p),g=D.normalize([],D.add([],D.add([],c,m),_)),y=[];let v;if(new Fl(u,g).closestPointOnSphere(d,h,y)){const b=D.add([],y,d),x=D.sub([],b,u);v=Math.cos(o.fovAboveCenter)*D.length(x)}else{const b=D.sub([],u,d),x=D.sub([],d,u);D.normalize(x,x);const w=D.length(b)-h;v=Math.sqrt(w*(w+2*h));const T=Math.acos(v/(h+w))-Math.acos(D.dot(c,x));v*=Math.cos(T)}return 1.01*v}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=yr(e.zoom);if(i>0){const o=Uy(e,It(1,e.center.lat)*e.worldSize),s=e.worldSize/(2*Math.PI),n=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Fe(r,o+s*(1-Math.cos(n)),Math.pow(i,10))}return r}upVector(e,r,i){return ua(r,i,e,1)}upVectorScale(e){return{metersToTile:Nl(Vl(si(e)))}}}function mc(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new qy(t);case"equirectangular":return new q2(t);case"naturalEarth":return new $2(t);case"equalEarth":return new G2(t);case"winkelTripel":return new H2(t);case"albers":return r?new Hy(t):new j2(t);case"lambertConformalConic":return r?new Hy(t):new Z2(t);case"globe":return new W2(t)}throw new Error(`Invalid projection name: ${t.name}`)}const X2=new Xt({"symbol-placement":new se(j.layout_symbol["symbol-placement"]),"symbol-spacing":new se(j.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new se(j.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ke(j.layout_symbol["symbol-sort-key"]),"symbol-z-order":new se(j.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new se(j.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new se(j.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new se(j.layout_symbol["icon-ignore-placement"]),"icon-optional":new se(j.layout_symbol["icon-optional"]),"icon-rotation-alignment":new se(j.layout_symbol["icon-rotation-alignment"]),"icon-size":new ke(j.layout_symbol["icon-size"]),"icon-text-fit":new ke(j.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ke(j.layout_symbol["icon-text-fit-padding"]),"icon-image":new ke(j.layout_symbol["icon-image"]),"icon-rotate":new ke(j.layout_symbol["icon-rotate"]),"icon-padding":new se(j.layout_symbol["icon-padding"]),"icon-keep-upright":new se(j.layout_symbol["icon-keep-upright"]),"icon-offset":new ke(j.layout_symbol["icon-offset"]),"icon-anchor":new ke(j.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new se(j.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new se(j.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new se(j.layout_symbol["text-rotation-alignment"]),"text-field":new ke(j.layout_symbol["text-field"]),"text-font":new ke(j.layout_symbol["text-font"]),"text-size":new ke(j.layout_symbol["text-size"]),"text-max-width":new ke(j.layout_symbol["text-max-width"]),"text-line-height":new ke(j.layout_symbol["text-line-height"]),"text-letter-spacing":new ke(j.layout_symbol["text-letter-spacing"]),"text-justify":new ke(j.layout_symbol["text-justify"]),"text-radial-offset":new ke(j.layout_symbol["text-radial-offset"]),"text-variable-anchor":new se(j.layout_symbol["text-variable-anchor"]),"text-anchor":new ke(j.layout_symbol["text-anchor"]),"text-max-angle":new se(j.layout_symbol["text-max-angle"]),"text-writing-mode":new se(j.layout_symbol["text-writing-mode"]),"text-rotate":new ke(j.layout_symbol["text-rotate"]),"text-padding":new se(j.layout_symbol["text-padding"]),"text-keep-upright":new se(j.layout_symbol["text-keep-upright"]),"text-transform":new ke(j.layout_symbol["text-transform"]),"text-offset":new ke(j.layout_symbol["text-offset"]),"text-allow-overlap":new se(j.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new se(j.layout_symbol["text-ignore-placement"]),"text-optional":new se(j.layout_symbol["text-optional"]),visibility:new se(j.layout_symbol.visibility)});var Hd={paint:new Xt({"icon-opacity":new ke(j.paint_symbol["icon-opacity"]),"icon-emissive-strength":new ke(j.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ke(j.paint_symbol["text-emissive-strength"]),"icon-color":new ke(j.paint_symbol["icon-color"]),"icon-halo-color":new ke(j.paint_symbol["icon-halo-color"]),"icon-halo-width":new ke(j.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ke(j.paint_symbol["icon-halo-blur"]),"icon-translate":new se(j.paint_symbol["icon-translate"]),"icon-translate-anchor":new se(j.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ke(j.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ke(j.paint_symbol["text-opacity"]),"text-color":new ke(j.paint_symbol["text-color"],{runtimeType:hi,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ke(j.paint_symbol["text-halo-color"]),"text-halo-width":new ke(j.paint_symbol["text-halo-width"]),"text-halo-blur":new ke(j.paint_symbol["text-halo-blur"]),"text-translate":new se(j.paint_symbol["text-translate"]),"text-translate-anchor":new se(j.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new se(j.paint_symbol["icon-color-saturation"])}),layout:X2};class Wy{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:js,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ee(Wy,"FormatSectionOverride",{omit:["defaultValue"]});class _c extends ri{constructor(e,r){super(e,Hd,r)}recalculate(e,r){super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const o=[];for(const s of i)o.indexOf(s)<0&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,r,i,o){const s=this.layout.get(e).evaluate(r,{},i,o),n=this._unevaluatedLayout._values[e];return n.isDataDriven()||fl(n.value)||!s?s:function(a,l){return l.replace(/{([^{}]+)}/g,(c,u)=>u in a?String(a[u]):"")}(r.properties,s)}createBucket(e){return new Ea(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Hd.paint.overridableProperties){if(!_c.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),i=new Wy(r),o=new dh(i,r.property.specification);let s=null;s=r.value.kind==="constant"||r.value.kind==="source"?new ph("source",o):new Ao("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[e]=new on(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,i){return!(!this.layout||r.isDataDriven()||i.isDataDriven())&&_c.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const i=e.get("text-field"),o=Hd.paint.properties[r];let s=!1;const n=a=>{for(const l of a)if(o.overrides&&o.overrides.hasOverride(l))return void(s=!0)};if(i.value.kind==="constant"&&i.value.value instanceof $r)n(i.value.value.sections);else if(i.value.kind==="source"){const a=c=>{s||(c instanceof Vn&&mr(c.value)===Bn?n(c.value.sections):c instanceof jn?n(c.sections):c.eachChild(a))},l=i.value;l._styleExpression&&a(l._styleExpression.expression)}return s}getProgramIds(){const e=this.paint.get("icon-opacity").constantOr(1)!==0,r=this.paint.get("text-opacity").constantOr(1)!==0,i=[];return e&&i.push("symbolIcon"),r&&i.push("symbolSDF"),i}getDefaultProgramParams(e,r){return{config:new xs(this,r),overrideFog:!1}}}const Y2=tc.types,J2=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function gc(t,e,r,i,o,s,n,a,l,c,u,h,d){const p=a?Math.min(qo,Math.round(a[0])):0,f=a?Math.min(qo,Math.round(a[1])):0;t.emplaceBack(e,r,Math.round(32*i),Math.round(32*o),s,n,(p<<1)+(l?1:0),f,16*c,16*u,256*h,256*d)}function yc(t,e,r){t.emplaceBack(e,r)}function xc(t,e,r,i,o,s,n){t.emplaceBack(e,r,i,o,s,n)}function vc(t,e,r,i,o){const s=5*e+2;t.float32[s+0]=r,t.float32[s+1]=i,t.float32[s+2]=o}function wn(t,e,r,i,o){t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o)}function K2(t){for(const e of t.sections)if(pb(e.text))return!0;return!1}class Wd{constructor(e){this.layoutVertexArray=new Dh,this.indexArray=new nr,this.programConfigurations=e,this.segments=new Et,this.dynamicLayoutVertexArray=new lo,this.opacityVertexArray=new Ph,this.placedSymbolArray=new Um,this.iconTransitioningVertexArray=new Do,this.globeExtVertexArray=new kh,this.zOffsetVertexArray=new ra}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}upload(e,r,i,o,s){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,f2.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,_2.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,J2,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,y2.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,m2.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||s)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,g2.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||o)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}Ee(Wd,"SymbolBuffers");class Xd{constructor(e,r,i){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new i,this.segments=new Et,this.collisionVertexArray=new Bh,this.collisionVertexArrayExt=new lo}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,x2.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,v2.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ee(Xd,"CollisionBuffers");class bc{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(n=>n.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=V.identity([]),this.placementViewportMatrix=V.identity([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fd(this.zoom,r["text-size"]),this.iconSizeData=Fd(this.zoom,r["icon-size"]);const i=this.layers[0].layout,o=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey=s!=="viewport-y"&&o.constantOr(1)!==void 0,this.sortFeaturesByY=(s==="viewport-y"||s==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(n=>Nt[n]),this.stateDependentLayerIds=this.layers.filter(n=>n.isStateDependent()).map(n=>n.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate")}createArrays(){this.text=new Wd(new Po(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Wd(new Po(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Gm,this.lineVertexArray=new qm,this.symbolInstances=new jm}calculateGlyphDependencies(e,r,i,o,s){for(let n=0;n<e.length;n++){const a=e.codePointAt(n);if(a===void 0)break;if(r[a]=!0,o&&s&&a<=65535){const l=_a[e.charAt(n)];l&&(r[l.charCodeAt(0)]=!0)}}}populate(e,r,i,o){const s=this.layers[0],n=s.layout,a=this.projection.name==="globe",l=n.get("text-font"),c=n.get("text-field"),u=n.get("icon-image"),h=(c.value.kind!=="constant"||c.value.value instanceof $r&&!c.value.value.isEmpty()||c.value.value.toString().length>0)&&(l.value.kind!=="constant"||l.value.value.length>0),d=u.value.kind!=="constant"||!!u.value.value||Object.keys(u.parameters).length>0,p=n.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new Ut(this.zoom);for(const{feature:y,id:v,index:b,sourceLayerIndex:x}of e){const w=s._featureFilter.needGeometry,T=Uo(y,w);if(!s._featureFilter.filter(g,T,i))continue;if(w||(T.geometry=$i(y,i,o)),a&&y.type!==1&&i.z<=5){const I=T.geometry,C=.98078528056,k=(A,L)=>{const O=ua(A.x,A.y,i,1),U=ua(L.x,L.y,i,1);return D.dot(O,U)<C};for(let A=0;A<I.length;A++)I[A]=nw(I[A],k)}let E,M;if(h){const I=s.getValueAndResolveTokens("text-field",T,i,_),C=$r.factory(I);K2(C)&&(this.hasRTLText=!0),(!this.hasRTLText||Ah()==="unavailable"||this.hasRTLText&&fi.isParsed())&&(E=T2(C,s,T))}if(d){const I=s.getValueAndResolveTokens("icon-image",T,i,_);M=I instanceof di?I:di.fromString(I)}if(!E&&!M)continue;const S=this.sortFeaturesByKey?p.evaluate(T,{},i):void 0;if(this.features.push({id:v,text:E,icon:M,index:b,sourceLayerIndex:x,geometry:T.geometry,properties:y.properties,type:Y2[y.type],sortKey:S}),M&&(f[M.namePrimary]=!0,M.nameSecondary&&(f[M.nameSecondary]=!0)),E){const I=l.evaluate(T,{},i).join(","),C=n.get("text-rotation-alignment")==="map"&&n.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Nt.vertical)>=0;for(const k of E.sections)if(k.image)f[k.image.namePrimary]=!0;else{const A=xh(E.toString()),L=k.fontStack||I,O=m[L]=m[L]||{};this.calculateGlyphDependencies(k.text,O,C,this.allowVerticalPlacement,A)}}}n.get("symbol-placement")==="line"&&(this.features=function(y){const v={},b={},x=[];let w=0;function T(I){x.push(y[I]),w++}function E(I,C,k){const A=b[I];return delete b[I],b[C]=A,x[A].geometry[0].pop(),x[A].geometry[0]=x[A].geometry[0].concat(k[0]),A}function M(I,C,k){const A=v[C];return delete v[C],v[I]=A,x[A].geometry[0].shift(),x[A].geometry[0]=k[0].concat(x[A].geometry[0]),A}function S(I,C,k){const A=k?C[0][C[0].length-1]:C[0][0];return`${I}:${A.x}:${A.y}`}for(let I=0;I<y.length;I++){const C=y[I],k=C.geometry,A=C.text?C.text.toString():null;if(!A){T(I);continue}const L=S(A,k),O=S(A,k,!0);if(L in b&&O in v&&b[L]!==v[O]){const U=M(L,O,k),R=E(L,O,x[U].geometry);delete v[L],delete b[O],b[S(A,x[R].geometry,!0)]=R,x[U].geometry=null}else L in b?E(L,O,k):O in v?M(L,O,k):(T(I),v[L]=w-1,b[O]=w-1)}return x.filter(I=>I.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((y,v)=>y.sortKey-v.sortKey)}update(e,r,i,o,s){const n=Object.keys(e).length!==0;if(n&&!this.stateDependentLayers.length)return;const a=n?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,r,a,i,o,s),this.icon.programConfigurations.updatePaintArrays(e,r,a,i,o,s)}updateZOffset(){const e=(s,n,a)=>{i+=n,i>s.length&&s.resize(i);for(let l=-n;l<0;l++)s.emplace(l+i,a)},r=(s,n,a)=>{o+=n,o>s.length&&s.resize(o);for(let l=-n;l<0;l++)s.emplace(l+o,a)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,o=0;for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,numIconVertices:c}=n,u=n.zOffset,h=c>0;if((a>0||l>0)&&(e(this.text.zOffsetVertexArray,a,u),e(this.text.zOffsetVertexArray,l,u)),h){const{placedIconSymbolIndex:d,verticalPlacedIconSymbolIndex:p}=n;d>=0&&r(this.icon.zOffsetVertexArray,c,u),p>=0&&r(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,u)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.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=mc(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const i=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:o,y:s}of r)this.lineVertexArray.emplaceBack(o,s);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){const g=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,b=e.segments.prepareSegment(4*r.length,y,g,this.canOverlap?n.sortKey:void 0),x=this.glyphOffsetArray.length,w=b.vertexLength,T=this.allowVerticalPlacement&&a===Nt.vertical?Math.PI/2:0,E=n.text&&n.text.sections;for(let S=0;S<r.length;S++){const{tl:I,tr:C,bl:k,br:A,texPrimary:L,texSecondary:O,pixelOffsetTL:U,pixelOffsetBR:R,minFontScaleX:B,minFontScaleY:G,glyphOffset:Z,isSDF:q,sectionIndex:X}=r[S],Y=b.vertexLength,K=Z[1];if(gc(y,c.x,c.y,I.x,K+I.y,L.x,L.y,i,q,U.x,U.y,B,G),gc(y,c.x,c.y,C.x,K+C.y,L.x+L.w,L.y,i,q,R.x,U.y,B,G),gc(y,c.x,c.y,k.x,K+k.y,L.x,L.y+L.h,i,q,U.x,R.y,B,G),gc(y,c.x,c.y,A.x,K+A.y,L.x+L.w,L.y+L.h,i,q,R.x,R.y,B,G),l){const{x:H,y:ee,z:de}=l.anchor,[pe,ge,xe]=l.up;xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),wn(e.dynamicLayoutVertexArray,H,ee,de,T)}else wn(e.dynamicLayoutVertexArray,c.x,c.y,c.z,T);if(_){const H=O||L;yc(e.iconTransitioningVertexArray,H.x,H.y),yc(e.iconTransitioningVertexArray,H.x+H.w,H.y),yc(e.iconTransitioningVertexArray,H.x,H.y+H.h),yc(e.iconTransitioningVertexArray,H.x+H.w,H.y+H.h)}g.emplaceBack(Y,Y+1,Y+2),g.emplaceBack(Y+1,Y+2,Y+3),b.vertexLength+=4,b.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Z[0]),S!==r.length-1&&X===r[S+1].sectionIndex||e.programConfigurations.populatePaintArrays(y.length,n,n.index,{},p,f,m,E&&E[X])}const M=l?l.anchor:c;e.placedSymbolArray.emplaceBack(M.x,M.y,M.z,c.x,c.y,x,this.glyphOffsetArray.length-x,w,u,h,c.segment,i?i[0]:0,i?i[1]:0,o[0],o[1],a,0,!1,0,d,0)}_commitLayoutVertex(e,r,i,o,s,n,a){e.emplaceBack(r,i,o,s,n,Math.round(a.x),Math.round(a.y))}_addCollisionDebugVertices(e,r,i,o,s,n,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=a.tileAnchorX,h=a.tileAnchorY;for(let p=0;p<4;p++)i.collisionVertexArray.emplaceBack(0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,r,e.padding,a.zOffset),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x1,e.y2)),l.vertexLength+=4;const d=i.indexArray;d.emplaceBack(c,c+1),d.emplaceBack(c+1,c+2),d.emplaceBack(c+2,c+3),d.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceTextSize(e,n,r,a);this._addCollisionDebugVertices(l,c,this.textCollisionBox,l.projectedAnchorX,l.projectedAnchorY,l.projectedAnchorZ,n)}}_addIconDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceIconSize(e,r,n.placedIconSymbolIndex);this._addCollisionDebugVertices(l,c,this.iconCollisionBox,l.projectedAnchorX,l.projectedAnchorY,l.projectedAnchorZ,n)}}generateCollisionDebugBuffers(e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Xd(zl,yy.members,Do),this.iconCollisionBox=new Xd(zl,yy.members,Do);const i=Hi(this.iconSizeData,e),o=Hi(this.textSizeData,e);for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s);this._addTextDebugCollisionBoxes(o,e,r,n.textBoxStartIndex,n.textBoxEndIndex,n),this._addTextDebugCollisionBoxes(o,e,r,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n),this._addIconDebugCollisionBoxes(i,e,r,n.iconBoxStartIndex,n.iconBoxEndIndex,n),this._addIconDebugCollisionBoxes(i,e,r,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex,n)}}getSymbolInstanceTextSize(e,r,i,o){const s=this.text.placedSymbolArray.get(r.rightJustifiedTextSymbolIndex>=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),n=ma(this.textSizeData,e,s)/xr;return this.tilePixelRatio*n}getSymbolInstanceIconSize(e,r,i){const o=this.icon.placedSymbolArray.get(i),s=ma(this.iconSizeData,e,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(e,r,i,o){e.emplaceBack(r,-i,-i,o),e.emplaceBack(r,i,-i,o),e.emplaceBack(r,i,i,o),e.emplaceBack(r,-i,i,o)}_updateTextDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceTextSize(e,n,r,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,c,l.padding,n.zOffset)}}_updateIconDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceIconSize(e,r,n.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,c,l.padding,n.zOffset)}}updateCollisionDebugBuffers(e,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Hi(this.iconSizeData,e),o=Hi(this.textSizeData,e);for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,e,r,n.textBoxStartIndex,n.textBoxEndIndex,n),this._updateTextDebugCollisionBoxes(o,e,r,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n),this._updateIconDebugCollisionBoxes(i,e,r,n.iconBoxStartIndex,n.iconBoxEndIndex,n),this._updateIconDebugCollisionBoxes(i,e,r,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex,n)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,r,i,o,s,n,a,l,c){const u={};if(r<i){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(r);u.textBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.textFeatureIndex=x}if(o<s){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(o);u.verticalTextBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.verticalTextFeatureIndex=x}if(n<a){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(n);u.iconBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.iconFeatureIndex=x}if(l<c){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(l);u.verticalIconBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.verticalIconFeatureIndex=x}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const i=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,r){const i=e.placedSymbolArray.get(r),o=i.vertexStartIndex+4*i.numGlyphs;for(let s=i.vertexStartIndex;s<o;s+=4)e.indexArray.emplaceBack(s,s+1,s+2),e.indexArray.emplaceBack(s+1,s+2,s+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),i=Math.cos(e),o=[],s=[],n=[];for(let a=0;a<this.symbolInstances.length;++a){n.push(a);const l=this.symbolInstances.get(a);o.push(0|Math.round(r*l.tileAnchorX+i*l.tileAnchorY)),s.push(l.featureIndex)}return n.sort((a,l)=>o[a]-o[l]||s[l]-s[a]),n}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,r)=>this.symbolInstances.get(r).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,r){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===r?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const i=this.symbolInstances.get(r);this.featureSortOrder.push(i.featureIndex);const{rightJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:a,placedIconSymbolIndex:l,verticalPlacedIconSymbolIndex:c}=i;o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&s!==o&&this.addIndicesForPlacedSymbol(this.text,s),n>=0&&n!==s&&n!==o&&this.addIndicesForPlacedSymbol(this.text,n),a>=0&&this.addIndicesForPlacedSymbol(this.text,a),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l),c>=0&&this.addIndicesForPlacedSymbol(this.icon,c)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ee(bc,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),bc.MAX_GLYPHS=65535,bc.addDynamicAttributes=wn;var Ea=bc;const Q2=xt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:eT}=Q2,tT=xt([{name:"a_packed",components:4,type:"Float32"}]),{members:rT}=tT,iT=tc.types,oT=Math.cos(Math.PI/180*37.5);class wc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new zh,this.layoutVertexArray2=new lo,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom),this.segments=new Et,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,i,o){this.hasPattern=Pd("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),n=[];for(const{feature:u,id:h,index:d,sourceLayerIndex:p}of e){const f=this.layers[0]._featureFilter.needGeometry,m=Uo(u,f);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),m,i))continue;const _=s?s.evaluate(m,{},i):void 0,g={id:h,properties:u.properties,type:u.type,sourceLayerIndex:p,index:d,geometry:f?m.geometry:$i(u,i,o),patterns:{},sortKey:_};n.push(g)}s&&n.sort((u,h)=>u.sortKey-h.sortKey);const{lineAtlas:a,featureIndex:l}=r,c=this.addConstantDashes(a);for(const u of n){const{geometry:h,index:d,sourceLayerIndex:p}=u;if(c&&this.addFeatureDashes(u,a),this.hasPattern){const f=Rd("line",this.layers,u,this.zoom,r);this.patternFeatures.push(f)}else this.addFeature(u,h,d,i,a.positions,r.availableImages,r.brightness);l.insert(e[d].feature,h,d,p,this.index)}}addConstantDashes(e){let r=!1;for(const i of this.layers){const o=i.paint.get("line-dasharray").value,s=i.layout.get("line-cap").value;if(o.kind!=="constant"||s.kind!=="constant")r=!0;else{const n=s.value,a=o.value;if(!a)continue;e.addDash(a,n)}}return r}addFeatureDashes(e,r){const i=this.zoom;for(const o of this.layers){const s=o.paint.get("line-dasharray").value,n=o.layout.get("line-cap").value;if(s.kind==="constant"&&n.kind==="constant")continue;let a,l;if(s.kind==="constant"){if(a=s.value,!a)continue}else a=s.evaluate({zoom:i},e);l=n.kind==="constant"?n.value:n.evaluate({zoom:i},e),r.addDash(a,l),e.patterns[o.id]=r.getKey(a,l)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}addFeatures(e,r,i,o,s,n){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,r,i,o,n)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,rT)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,eT),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,i,o,s,n,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const p of r)this.addLine(p,e,c,u,h,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,a)}addLine(e,r,i,o,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let g=0;g<e.length-1;g++)this.totalDistance+=e[g].dist(e[g+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a=iT[r.type]==="Polygon";let l=e.length;for(;l>=2&&e[l-1].equals(e[l-2]);)l--;let c=0;for(;c<l-1&&e[c].equals(e[c+1]);)c++;if(l<(a?3:2))return;i==="bevel"&&(s=1.05);const u=this.overscaling<=16?15*W/(512*this.overscaling):0,h=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray);let d,p,f,m,_;this.e1=this.e2=-1,a&&(d=e[l-2],_=e[c].sub(d)._unit()._perp());for(let g=c;g<l;g++){if(f=g===l-1?a?e[c+1]:void 0:e[g+1],f&&e[g].equals(f))continue;_&&(m=_),d&&(p=d),d=e[g],_=f?f.sub(d)._unit()._perp():m,m=m||_;let y=m.add(_);y.x===0&&y.y===0||y._unit();const v=m.x*_.x+m.y*_.y,b=y.x*_.x+y.y*_.y,x=b!==0?1/b:1/0,w=2*Math.sqrt(2-2*b),T=b<oT&&p&&f,E=m.x*_.y-m.y*_.x>0;if(T&&g>c){const I=d.dist(p);if(I>2*u){const C=d.sub(d.sub(p)._mult(u/I)._round());this.updateDistance(p,C),this.addCurrentVertex(C,m,0,0,h),p=C}}const M=p&&f;let S=M?i:a?"butt":o;if(M&&S==="round"&&(x<n?S="miter":x<=2&&(S="fakeround")),S==="miter"&&x>s&&(S="bevel"),S==="bevel"&&(x>2&&(S="flipbevel"),x<s&&(S="miter")),p&&this.updateDistance(p,d),S==="miter")y._mult(x),this.addCurrentVertex(d,y,0,0,h);else if(S==="flipbevel"){if(x>100)y=_.mult(-1);else{const I=x*m.add(_).mag()/m.sub(_).mag();y._perp()._mult(I*(E?-1:1))}this.addCurrentVertex(d,y,0,0,h),this.addCurrentVertex(d,y.mult(-1),0,0,h)}else if(S==="bevel"||S==="fakeround"){const I=-Math.sqrt(x*x-1),C=E?I:0,k=E?0:I;if(p&&this.addCurrentVertex(d,m,C,k,h),S==="fakeround"){const A=Math.round(180*w/Math.PI/20);for(let L=1;L<A;L++){let O=L/A;if(O!==.5){const R=O-.5;O+=O*R*(O-1)*((1.0904+v*(v*(3.55645-1.43519*v)-3.2452))*R*R+(.848013+v*(.215638*v-1.06021)))}const U=_.sub(m)._mult(O)._add(m)._unit()._mult(E?-1:1);this.addHalfVertex(d,U.x,U.y,!1,E,0,h)}}f&&this.addCurrentVertex(d,_,-C,-k,h)}else if(S==="butt")this.addCurrentVertex(d,y,0,0,h);else if(S==="square"){const I=p?1:-1;p||this.addCurrentVertex(d,y,I,I,h),this.addCurrentVertex(d,y,0,0,h),p&&this.addCurrentVertex(d,y,I,I,h)}else S==="round"&&(p&&(this.addCurrentVertex(d,m,0,0,h),this.addCurrentVertex(d,m,1,1,h,!0)),f&&(this.addCurrentVertex(d,_,-1,-1,h,!0),this.addCurrentVertex(d,_,0,0,h)));if(T&&g<l-1){const I=d.dist(f);if(I>2*u){const C=d.add(f.sub(d)._mult(u/I)._round());this.updateDistance(d,C),this.addCurrentVertex(C,_,0,0,h),d=C}}}}addCurrentVertex(e,r,i,o,s,n=!1){const a=r.y*o-r.x,l=-r.y-r.x*o;this.addHalfVertex(e,r.x+r.y*i,r.y-r.x*i,n,!1,i,s),this.addHalfVertex(e,a,l,n,!0,-o,s)}addHalfVertex({x:e,y:r},i,o,s,n,a,l){this.layoutVertexArray.emplaceBack((e<<1)+(s?1:0),(r<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*o)+128,1+(a===0?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const c=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),l.primitiveLength++),n?this.e2=c:this.e1=c}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,r){this.distance+=e.dist(r),this.updateScaledDistance()}}Ee(wc,"LineBucket",{omit:["layers","patternFeatures"]});class Gt{constructor(e,r,i,o){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(r,o)}update(e,r,i){const{width:o,height:s}=e,{context:n}=this,{gl:a}=n,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:d}=$;if(a.bindTexture(a.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!r||r.premultiply!==!1)),i||this.size&&this.size[0]===o&&this.size[1]===s){const{x:p,y:f}=i||{x:0,y:0};if(e instanceof l||e instanceof c||e instanceof u||e instanceof h||d&&e instanceof d)a.texSubImage2D(a.TEXTURE_2D,0,p,f,a.RGBA,a.UNSIGNED_BYTE,e);else{let m=this.format,_=a.UNSIGNED_BYTE;this.format===a.R32F&&(m=a.RED,_=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,p,f,o,s,m,_,e.data)}}else if(this.size=[o,s],e instanceof l||e instanceof c||e instanceof u||e instanceof h||d&&e instanceof d){let p=this.format;this.format===a.R8&&(p=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,p,a.UNSIGNED_BYTE,e)}else{let p=this.format,f=this.format,m=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(p=a.DEPTH_COMPONENT16,m=a.UNSIGNED_SHORT),this.format===a.R32F&&(m=a.FLOAT,f=a.RED),a.texImage2D(a.TEXTURE_2D,0,p,o,s,0,f,m,e.data)}this.useMipmap=!!(r&&r.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(e,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),r!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapS=r)}bindExtraParam(e,r,i,o){const{context:s}=this,{gl:n}=s;n.bindTexture(n.TEXTURE_2D,this.texture),r!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,r),this.magFilter=r),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),i!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,i),this.wrapS=i),o!==this.wrapT&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,o),this.wrapT=o)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Tc{constructor(e,r){this.context=e,this.texture=r}bind(e,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,e),this.minFilter=e),r!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapS=r)}}const xi=32,Wi=33,$o=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,r=0,i=0,o=0,s=0,n=0,a=0;for(1&e?o=s=n=xi:r=i=a=xi;(e>>=1)>1;){const c=r+o>>1,u=i+s>>1;1&e?(o=r,s=i,r=n,i=a):(r=o,i=s,o=n,s=a),n=c,a=u}const l=4*t;$o[l+0]=r,$o[l+1]=i,$o[l+2]=o,$o[l+3]=s}const Xi=new Uint16Array(2178),Ho=new Uint8Array(1089),Ec=new Uint16Array(1089);function Xy(t){return t===0?-.03125:t===32?.03125:0}var Yd=xt([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Yy={type:2,extent:W,loadGeometry:()=>[[new N(0,0),new N(W+1,0),new N(W+1,W+1),new N(0,W+1),new N(0,0)]]};class Ma{constructor(e,r,i,o,s){this.tileID=e,this.uid=Ls(),this.uses=0,this.tileSize=r,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,o&&o.style&&(this._lastUpdatedBrightness=o.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(e){const r=e+this.timeAdded;r<je.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Ts(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,r,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(o,s){const n={};if(!s)return n;for(const a of o){const l=a.layerIds.map(c=>s.getLayer(c)).filter(Boolean);if(l.length!==0){a.layers=l,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(c=>l.filter(u=>u.id===c)[0]));for(const c of l)n[c.fqid]=a}}return n}(e.buckets,r.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const s=this.buckets[o];if(s instanceof Ea){if(this.hasSymbolBuckets=!0,!i)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const o in this.buckets){const s=this.buckets[o];if(s instanceof Ea&&s.hasRTLText){this.hasRTLText=!0,fi.isLoading()||fi.isLoaded()||Ah()!=="deferred"||km();break}}this.queryPadding=0;for(const o in this.buckets){const s=this.buckets[o],n=r.style.getOwnLayer(o);if(!n)continue;const a=n.queryRadius(s);this.queryPadding=Math.max(this.queryPadding,a)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new Gh}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._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(e){return this.buckets[e.fqid]}upload(e){for(const i in this.buckets){const o=this.buckets[i];o.uploadPending()&&o.upload(e)}const r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Gt(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Gt(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Gt(e,this.lineAtlas.image,r.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e,r,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!r||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=r.style.getBrightness();(this._lastUpdatedBrightness||o)&&(this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this._lastUpdatedBrightness=o,this.updateBuckets(void 0,r)))}queryRenderedFeatures(e,r,i,o,s,n,a,l){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:a,transform:n,params:s,tileTransform:this.tileTransform},e,r,i):{}}querySourceFeatures(e,r){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const o=i.loadVTLayers(),s=r?r.sourceLayer:"",n=o._geojsonTileLayer||o[s];if(!n)return;const a=yl(r&&r.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let d=0;d<n.length;d++){const p=n.feature(d);if(a.needGeometry){const _=Uo(p,!0);if(!a.filter(new Ut(this.tileID.overscaledZ),_,this.tileID.canonical))continue}else if(!a.filter(new Ut(this.tileID.overscaledZ),p))continue;const f=i.getId(p,s),m=new cy(p,l,c,u,f);m.tile=h,e.push(m)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}bucketsLoaded(){for(const e in this.buckets)if(this.buckets[e].uploadPending())return!1;return!0}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const r=this.expirationTime;if(e.cacheControl){const i=ze(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const i=Date.now();let o=!1;if(this.expirationTime>i)o=!1;else if(r)if(this.expirationTime<r)o=!0;else{const s=this.expirationTime-r;s?this.expirationTime=i+Math.max(s,3e4):o=!0}else o=!0;o?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,r){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&Object.keys(e).length!==0&&r&&this.updateBuckets(e,r)}updateBuckets(e,r){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),o=r.style.listImages(),s=r.style.getBrightness();for(const n in this.buckets){if(!r.style.hasLayer(n))continue;const a=this.buckets[n],l=a.layers[0].sourceLayer||"_geojsonTileLayer",c=i[l];let u={};if(e&&(u=e[l],!c||!u||Object.keys(u).length===0))continue;if(a.update(u,c,o,this.imageAtlas&&this.imageAtlas.patternPositions||{},s),a instanceof wc||a instanceof Ql){const d=r.style.getOwnSourceCache(a.layers[0].source);r._terrain&&r._terrain.enabled&&d&&a.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(d.id,this.tileID)}const h=r&&r.style&&r.style.getOwnLayer(n);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(a)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<je.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=je.now()+e}setTexture(e,r){const i=r.context,o=i.gl;this.texture=this.texture||r.getTileTexture(e.width),this.texture&&this.texture instanceof Gt?this.texture.update(e,{useMipmap:!0}):(this.texture=new Gt(i,e,o.RGBA,{useMipmap:!0}),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE))}setDependencies(e,r){const i={};for(const o of r)i[o]=!0;this.dependencies[e]=i}hasDependency(e,r){for(const i of e){const o=this.dependencies[i];if(o){for(const s of r)if(o[s])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,r){if(!r||r.name==="mercator"||this._tileDebugBuffer)return;const i=$i(Yy,this.tileID.canonical,this.tileTransform)[0],o=new Wr,s=new ia;for(let n=0;n<i.length;n++){const{x:a,y:l}=i[n];o.emplaceBack(a,l),s.emplaceBack(n)}s.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(s),this._tileDebugBuffer=e.createVertexBuffer(o,Lo.members),this._tileDebugSegments=Et.simpleSegment(0,0,o.length,s.length)}_makeTileBoundsBuffers(e,r){if(this._tileBoundsBuffer||!r||r.name==="mercator")return;const i=$i(Yy,this.tileID.canonical,this.tileTransform)[0];let o,s;if(this.isRaster){const n=function(a,l){const c=Ts(a,l),u=Math.pow(2,a.z);for(let _=0;_<Wi;_++)for(let g=0;g<Wi;g++){const y=Jr((a.x+(g+Xy(g))/xi)/u),v=ar((a.y+(_+Xy(_))/xi)/u),b=l.project(y,v),x=_*Wi+g;Xi[2*x+0]=Math.round((b.x*c.scale-c.x)*W),Xi[2*x+1]=Math.round((b.y*c.scale-c.y)*W)}Ho.fill(0),Ec.fill(0);for(let _=2045;_>=0;_--){const g=4*_,y=$o[g+0],v=$o[g+1],b=$o[g+2],x=$o[g+3],w=y+b>>1,T=v+x>>1,E=w+T-v,M=T+y-w,S=v*Wi+y,I=x*Wi+b,C=T*Wi+w,k=Math.hypot((Xi[2*S+0]+Xi[2*I+0])/2-Xi[2*C+0],(Xi[2*S+1]+Xi[2*I+1])/2-Xi[2*C+1])>=16;Ho[C]=Ho[C]||(k?1:0),_<1022&&(Ho[C]=Ho[C]||Ho[(v+M>>1)*Wi+(y+E>>1)]||Ho[(x+M>>1)*Wi+(b+E>>1)])}const h=new _s,d=new nr;let p=0;function f(_,g){const y=g*Wi+_;return Ec[y]===0&&(h.emplaceBack(Xi[2*y+0],Xi[2*y+1],_*W/xi,g*W/xi),Ec[y]=++p),Ec[y]-1}function m(_,g,y,v,b,x){const w=_+y>>1,T=g+v>>1;if(Math.abs(_-b)+Math.abs(g-x)>1&&Ho[T*Wi+w])m(b,x,_,g,w,T),m(y,v,b,x,w,T);else{const E=f(_,g),M=f(y,v),S=f(b,x);d.emplaceBack(E,M,S)}}return m(0,0,xi,xi,xi,0),m(xi,xi,0,0,0,xi),{vertices:h,indices:d}}(this.tileID.canonical,r);o=n.vertices,s=n.indices}else{o=new _s,s=new nr;for(const{x:a,y:l}of i)o.emplaceBack(a,l,0,0);const n=Kl(o.int16,void 0,4);for(let a=0;a<n.length;a+=3)s.emplaceBack(n[a],n[a+1],n[a+2])}this._tileBoundsBuffer=e.createVertexBuffer(o,Yd.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(s),this._tileBoundsSegments=Et.simpleSegment(0,0,o.length,s.length)}_makeGlobeTileDebugBuffers(e,r){const i=r.projection;if(!i||i.name!=="globe"||r.freezeTileCoverage)return;const o=this.tileID.canonical,s=Oo(vg(o,r)),n=yr(r.zoom);let a;n>0&&(a=V.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,o,r,s,a,n),this._makeGlobeTileDebugTextBuffer(e,o,r,s,a,n)}_globePoint(e,r,i,o,s,n,a){let l=ua(e,r,i);if(n){const c=1<<i.z,u=ur(o.center.lng),h=dr(o.center.lat),d=(i.x+.5)/c-u;let p=0;d>.5?p=-1:d<-.5&&(p=1);let f=(e/W+i.x)/c+p,m=(r/W+i.y)/c;f=(f-u)*o._pixelsPerMercatorPixel+u,m=(m-h)*o._pixelsPerMercatorPixel+h;const _=[f*o.worldSize,m*o.worldSize,0];D.transformMat4(_,_,n),l=go(l,_,a)}return D.transformMat4(l,l,s)}_makeGlobeTileDebugBorderBuffer(e,r,i,o,s,n){const a=new Wr,l=new ia,c=new Al,u=(d,p,f,m,_)=>{const g=(f-d)/(_-1),y=(m-p)/(_-1),v=a.length;for(let b=0;b<_;b++){const x=d+b*g,w=p+b*y;a.emplaceBack(x,w);const T=this._globePoint(x,w,r,i,o,s,n);c.emplaceBack(T[0],T[1],T[2]),l.emplaceBack(v+b)}},h=W;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(l),this._tileDebugBuffer=e.createVertexBuffer(a,Lo.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(c,pg.members),this._tileDebugSegments=Et.simpleSegment(0,0,a.length,l.length)}_makeGlobeTileDebugTextBuffer(e,r,i,o,s,n){const a=W/4,l=new Wr,c=new nr,u=new Al,h=25;c.reserve(32),l.reserve(h),u.reserve(h);const d=(p,f)=>h*p+f;for(let p=0;p<h;p++){const f=p*a;for(let m=0;m<h;m++){const _=m*a;l.emplaceBack(_,f);const g=this._globePoint(_,f,r,i,o,s,n);u.emplaceBack(g[0],g[1],g[2])}}for(let p=0;p<4;p++)for(let f=0;f<4;f++){const m=d(p,f),_=d(p,f+1),g=d(p+1,f),y=d(p+1,f+1);c.emplaceBack(m,_,g),c.emplaceBack(g,_,y)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(c),this._tileDebugTextBuffer=e.createVertexBuffer(l,Lo.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(u,pg.members),this._tileDebugTextSegments=Et.simpleSegment(0,0,h,32)}destroy(e=!1){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(),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),!e&&this.texture&&this.texture instanceof Gt&&(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.latestFeatureIndex=null,this.state="unloaded"}}class sT{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(const e in this.data)for(const r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,i){const o=e.wrapped().key;this.data[o]===void 0&&(this.data[o]=[]);const s={value:r,timeout:void 0};if(i!==void 0&&(s.timeout=setTimeout(()=>{this.remove(e,s)},i)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){const r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;const i=e.wrapped().key,o=r===void 0?0:this.data[i].indexOf(r),s=this.data[i][o];return this.data[i].splice(o,1),s.timeout&&clearTimeout(s.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(e){const r=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||r.push(o);for(const i of r)this.remove(i.value.tileID,i)}}class Wo{constructor(e,r,i,o){this.id=Wo.uniqueIdxCounter,Wo.uniqueIdxCounter++,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||o||r.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=Wo.uniqueIdxCounter,Wo.uniqueIdxCounter++;const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Wo.uniqueIdxCounter=0;const nT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class aT{constructor(e,r,i,o,s,n){this.length=r.length,this.attributes=i,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.instanceCount=n,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||s||r.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,r){for(let i=0;i<this.attributes.length;i++){const o=r.attributes[this.attributes[i].name];o!==void 0&&e.enableVertexAttribArray(o)}}setVertexAttribPointers(e,r,i){for(let o=0;o<this.attributes.length;o++){const s=this.attributes[o],n=r.attributes[s.name];n!==void 0&&e.vertexAttribPointer(n,s.components,e[nT[s.type]],!1,this.itemSize,s.offset+this.itemSize*(i||0))}}setVertexAttribDivisor(e,r,i){for(let o=0;o<this.attributes.length;o++){const s=r.attributes[this.attributes[o].name];s!==void 0&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(s,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Bt{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class lT extends Bt{getDefault(){return Qe.transparent}set(e){const r=this.current;(e.r!==r.r||e.g!==r.g||e.b!==r.b||e.a!==r.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class cT extends Bt{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class uT extends Bt{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class hT extends Bt{getDefault(){return[!0,!0,!0,!0]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class dT extends Bt{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class pT extends Bt{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class fT extends Bt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const r=this.current;(e.func!==r.func||e.ref!==r.ref||e.mask!==r.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class mT extends Bt{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class _T extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.STENCIL_TEST):r.disable(r.STENCIL_TEST),this.current=e,this.dirty=!1}}class gT extends Bt{getDefault(){return[0,1]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class yT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),this.current=e,this.dirty=!1}}class xT extends Bt{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class vT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.BLEND):r.disable(r.BLEND),this.current=e,this.dirty=!1}}class bT extends Bt{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class wT extends Bt{getDefault(){return Qe.transparent}set(e){const r=this.current;(e.r!==r.r||e.g!==r.g||e.b!==r.b||e.a!==r.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class TT extends Bt{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class ET extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),this.current=e,this.dirty=!1}}class MT extends Bt{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class ST extends Bt{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let AT=class extends Bt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}};class IT extends Bt{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class CT extends Bt{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class zT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindFramebuffer(r.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class DT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindRenderbuffer(r.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class kT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindTexture(r.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class PT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindBuffer(r.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class RT extends Bt{getDefault(){return null}set(e){const r=this.gl;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class LT extends Bt{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class BT extends Bt{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class OT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class FT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Jd extends Bt{constructor(e,r){super(e),this.context=e,this.parent=r}getDefault(){return null}}class NT extends Jd{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Jy extends Jd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferRenderbuffer(r.FRAMEBUFFER,this.attachment(),r.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class UT extends Jd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,this.attachment(),r.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class VT extends Jy{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class jT{constructor(e,r,i,o,s){this.context=e,this.width=r,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new NT(e,n)),s&&(this.depthAttachmentType=s,this.depthAttachment=s==="renderbuffer"?new Jy(e,n):new UT(e,n))}destroy(){const e=this.context.gl;if(this.colorAttachment){const r=this.colorAttachment.get();r&&e.deleteTexture(r)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}else{const r=this.depthAttachment.get();r&&e.deleteTexture(r)}e.deleteFramebuffer(this.framebuffer)}}class Le{constructor(e,r,i){this.func=e,this.mask=r,this.range=i}}Le.ReadOnly=!1,Le.ReadWrite=!0,Le.disabled=new Le(519,Le.ReadOnly,[0,1]);const Kd=7680;class et{constructor(e,r,i,o,s,n){this.test=e,this.ref=r,this.mask=i,this.fail=o,this.depthFail=s,this.pass=n}}et.disabled=new et({func:519,mask:0},0,0,Kd,Kd,Kd);const Mc=771;class pt{constructor(e,r,i,o){this.blendFunction=e,this.blendColor=r,this.mask=i,this.blendEquation=o}}pt.Replace=[1,0,1,0],pt.disabled=new pt(pt.Replace,Qe.transparent,[!1,!1,!1,!1]),pt.unblended=new pt(pt.Replace,Qe.transparent,[!0,!0,!0,!0]),pt.alphaBlended=new pt([1,Mc,1,Mc],Qe.transparent,[!0,!0,!0,!0]),pt.multiply=new pt([774,0,774,0],Qe.transparent,[!0,!0,!0,!0]);const Qd=1029,ep=2305;class rt{constructor(e,r,i){this.enable=e,this.mode=r,this.frontFace=i}}rt.disabled=new rt(!1,Qd,ep),rt.backCCW=new rt(!0,Qd,ep),rt.backCW=new rt(!0,Qd,2304),rt.frontCW=new rt(!0,1028,2304),rt.frontCCW=new rt(!0,1028,ep);class GT{constructor(e,r){this.gl=e,this.clearColor=new lT(this),this.clearDepth=new cT(this),this.clearStencil=new uT(this),this.colorMask=new hT(this),this.depthMask=new dT(this),this.stencilMask=new pT(this),this.stencilFunc=new fT(this),this.stencilOp=new mT(this),this.stencilTest=new _T(this),this.depthRange=new gT(this),this.depthTest=new yT(this),this.depthFunc=new xT(this),this.blend=new vT(this),this.blendFunc=new bT(this),this.blendColor=new wT(this),this.blendEquation=new TT(this),this.cullFace=new ET(this),this.cullFaceSide=new MT(this),this.frontFace=new ST(this),this.program=new AT(this),this.activeTexture=new IT(this),this.viewport=new CT(this),this.bindFramebuffer=new zT(this),this.bindRenderbuffer=new DT(this),this.bindTexture=new kT(this),this.bindVertexBuffer=new PT(this),this.bindElementBuffer=new RT(this),this.bindVertexArrayOES=new LT(this),this.pixelStoreUnpack=new BT(this),this.pixelStoreUnpackPremultiplyAlpha=new OT(this),this.pixelStoreUnpackFlipY=new FT(this),this.options=r?{...r}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,r,i){return new Wo(this,e,r,i)}createVertexBuffer(e,r,i,o,s){return new aT(this,e,r,i,o,s)}createRenderbuffer(e,r,i){const o=this.gl,s=o.createRenderbuffer();return this.bindRenderbuffer.set(s),o.renderbufferStorage(o.RENDERBUFFER,e,r,i),this.bindRenderbuffer.set(null),s}createFramebuffer(e,r,i,o){return new jT(this,e,r,i,o)}clear({color:e,depth:r,stencil:i,colorMask:o}){const s=this.gl;let n=0;e&&(n|=s.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(o||[!0,!0,!0,!0])),r!==void 0&&(n|=s.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(r),this.depthMask.set(!0)),i!==void 0&&(n|=s.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),s.clear(n)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){dt(e.blendFunction,pt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}class ki extends or{constructor(e,r,i){super(),this.id=e,this._onlySymbols=i,r.on("data",o=>{o.dataType==="source"&&o.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&o.dataType==="source"&&o.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new sT(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new l2,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(e){this.map=e,this._minTileCacheSize=this._minTileCacheSize===void 0&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const e in this._tiles){const r=this._tiles[e];if(r.state!=="errored"&&(r.state!=="loaded"||!r.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,r){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,r)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const r in this._tiles){const i=this._tiles[r];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ss(this._tiles).map(e=>e.tileID).sort(Ky).map(e=>e.key)}getRenderableIds(e,r){const i=[];for(const o in this._tiles)this._isIdRenderable(+o,e,r)&&i.push(this._tiles[o]);return e?i.sort((o,s)=>{const n=o.tileID,a=s.tileID,l=new N(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),c=new N(a.canonical.x,a.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-a.overscaledZ||c.y-l.y||c.x-l.x}).map(o=>o.tileID.key):i.map(o=>o.tileID).sort(Ky).map(o=>o.key)}hasRenderableParent(e){const r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,r){const i=this._tiles[e];i&&(i.state!=="loading"&&(i.state=r),this._loadTile(i,this._tileLoaded.bind(this,i,e,r)))}_tileLoaded(e,r,i,o){if(o)if(e.state="errored",o.status!==404)this._source.fire(new Ue(o,{tile:e}));else{if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new ae("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else e.timeAdded=je.now(),i==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new ae("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const r=this.getRenderableIds();for(let o=0;o<r.length;o++){const s=r[o];if(e.neighboringTiles&&e.neighboringTiles[s]){const n=this.getTileByID(s);i(e,n),i(n,e)}}function i(o,s){if(!o.dem||o.dem.borderReady)return;o.needsHillshadePrepare=!0,o.needsDEMTextureUpload=!0;let n=s.tileID.canonical.x-o.tileID.canonical.x;const a=s.tileID.canonical.y-o.tileID.canonical.y,l=Math.pow(2,o.tileID.canonical.z),c=s.tileID.key;n===0&&a===0||Math.abs(a)>1||(Math.abs(n)>1&&(Math.abs(n+l)===1?n+=l:Math.abs(n-l)===1&&(n-=l)),s.dem&&o.dem&&(o.dem.backfillBorder(s.dem,n,a),o.neighboringTiles&&o.neighboringTiles[c]&&(o.neighboringTiles[c].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,i,o){for(const s in this._tiles){let n=this._tiles[s];if(o[s]||!n.hasData()||n.tileID.overscaledZ<=r||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>r+1;){const c=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[c.key],n&&n.hasData()&&(a=c)}let l=a;for(;l.overscaledZ>r;)if(l=l.scaledTo(l.overscaledZ-1),e[l.key]){o[a.key]=a;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=r?i:null}for(let i=e.overscaledZ-1;i>=r;i--){const o=e.scaledTo(i),s=this._getLoadedTile(o);if(s)return s}}_getLoadedTile(e){const r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,r){r=r||this._source.tileSize;const i=Math.ceil(e.width/r)+1,o=Math.ceil(e.height/r)+1,s=Math.floor(i*o*5),n=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,s):s,a=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(a)}handleWrapJump(e){const r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,r){const i={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),i[s.tileID.key]=s}this._tiles=i;for(const o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(const o in this._tiles)this._setTileReloadTimer(+o,this._tiles[o])}}update(e,r,i,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!i)return;let s;if(this.updateCacheSize(e,r),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new mt(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(s=e.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter(l=>this._source.hasTile(l)))):s=[],s.length>0&&this.castsShadows&&o&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!tp(this._source.type)){const l=e.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),c=Math.min(l,this._source.maxzoom),u=e.extendTileCoverForShadows(s,o,c);for(const h of u)this._shadowCasterTiles[h.key]=!0,s.push(h)}const n=this._updateRetainedTiles(s);if(tp(this._source.type)&&s.length!==0){const l={},c={},u=Object.keys(n);for(const d of u){const p=n[d],f=this._tiles[d];if(!f||f.fadeEndTime&&f.fadeEndTime<=je.now())continue;const m=this.findLoadedParent(p,Math.max(p.overscaledZ-ki.maxOverzooming,this._source.minzoom));m&&(this._addTile(m.tileID),l[m.tileID.key]=m.tileID),c[d]=p}const h=s[s.length-1].overscaledZ;for(const d in this._tiles){const p=this._tiles[d];if(n[d]||!p.hasData())continue;let f=p.tileID;for(;f.overscaledZ>h;){f=f.scaledTo(f.overscaledZ-1);const m=this._tiles[f.key];if(m&&m.hasData()&&c[f.key]){n[d]=p.tileID;break}}}for(const d in l)n[d]||(this._coveredTiles[d]=!0,n[d]=l[d])}for(const l in n)this._tiles[l].clearFadeHold();const a=function(l,c){const u=[];for(const h in l)h in c||u.push(h);return u}(this._tiles,n);for(const l of a){const c=this._tiles[l];c.hasSymbolBuckets&&!c.holdingForFade()?c.setHoldDuration(this.map._fadeDuration):c.hasSymbolBuckets&&!c.symbolFadeFinished()||this._removeTile(+l)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const r={};if(e.length===0)return r;const i={},o=e.reduce((c,u)=>Math.min(c,u.overscaledZ),1/0),s=e[0].overscaledZ,n=Math.max(s-ki.maxOverzooming,this._source.minzoom),a=Math.max(s+ki.maxUnderzooming,this._source.minzoom),l={};for(const c of e){const u=this._addTile(c);r[c.key]=c,u.hasData()||o<this._source.maxzoom&&(l[c.key]=c)}this._retainLoadedChildren(l,o,a,r);for(const c of e){let u=this._tiles[c.key];if(u.hasData())continue;if(c.canonical.z>=this._source.maxzoom){const d=c.children(this._source.maxzoom)[0],p=this.getTile(d);if(p&&p.hasData()){r[d.key]=d;continue}}else{const d=c.children(this._source.maxzoom);if(r[d[0].key]&&r[d[1].key]&&r[d[2].key]&&r[d[3].key])continue}let h=u.wasRequested();for(let d=c.overscaledZ-1;d>=n;--d){const p=c.scaledTo(d);if(i[p.key]||(i[p.key]=!0,u=this.getTile(p),!u&&h&&(u=this._addTile(p)),u&&(r[p.key]=p,h=u.wasRequested(),u.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const r=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(s),i)break;o=s}for(const s of r)this._loadedParentTiles[s]=i}}_addTile(e){let r=this._tiles[e.key];if(r)return r.isExtraShadowCaster!==!0||this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));const i=!!r;if(!i){const o=this.map?this.map.painter:null;r=new Ma(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,o,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))}return r?(r.uses++,this._tiles[e.key]=r,i||this._source.fire(new ae("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=r.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_removeTile(e){const r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&r.state!=="reloading"?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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(e,r,i){const o=[],s=this.transform;if(!s)return o;const n=s.projection.name==="globe",a=ur(s.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(i&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(n){const h=c.tileID.canonical;if(h.z===0){const d=[Math.abs(Se(a,...Sa(h,-1))-a),Math.abs(Se(a,...Sa(h,1))-a)];u=[0,2*d.indexOf(Math.min(...d))-1]}else{const d=[Math.abs(Se(a,...Sa(h,-1))-a),Math.abs(Se(a,...Sa(h,0))-a),Math.abs(Se(a,...Sa(h,1))-a)];u=[d.indexOf(Math.min(...d))-1]}}else u=[0];for(const h of u){const d=e.containsTile(c,s,r,h);d&&o.push(d)}}return o}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,r){const i=this.getRenderableIds(e,r).map(s=>this._tiles[s].tileID),o=this.transform.projection.name==="globe";for(const s of i)s.projMatrix=this.transform.calculateProjMatrix(s.toUnwrapped()),s.expandedProjMatrix=o?this.transform.calculateProjMatrix(s.toUnwrapped(),!1,!0):s.projMatrix;return i}sortCoordinatesByDistance(e){const r=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),s={};for(const n of r){const a=1/(1<<n.canonical.z);s[n.key]=((n.canonical.x+.5)*a+n.wrap-i[0])*o[0]+((n.canonical.y+.5)*a-i[1])*o[1]-i[2]*o[2]}return r.sort((n,a)=>s[n.key]-s[a.key]),r}hasTransition(){if(this._source.hasTransition())return!0;if(tp(this._source.type))for(const e in this._tiles){const r=this._tiles[e];if(r.fadeEndTime!==void 0&&r.fadeEndTime>=je.now())return!0}return!1}setFeatureState(e,r,i){this._state.updateState(e=e||"_geojsonTileLayer",r,i)}removeFeatureState(e,r,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,i)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,i){const o=this._tiles[e];o&&o.setDependencies(r,i)}reloadTilesForDependencies(e,r){for(const i in this._tiles)this._tiles[i].hasDependency(e,r)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,r))}_preloadTiles(e,r){if(!this._sourceLoaded){const a=()=>{this._sourceLoaded&&(this._source.off("data",a),this._preloadTiles(e,r))};return void this._source.on("data",a)}const i=new Map,o=Array.isArray(e)?e:[e],s=this.map.painter.terrain,n=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const a of o){const l=a.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const c of l)i.set(c.key,c);this.usedForTerrain&&a.updateElevation(!1)}os(Array.from(i.values()),(a,l)=>{const c=new Ma(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(c,u=>{this._source.type==="raster-dem"&&c.dem&&this._backfillDEM(c),l(u,c)})},r)}}function Ky(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),i=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||i-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function tp(t){return t==="raster"||t==="image"||t==="video"||t==="custom"}function Sa(t,e){const r=1<<t.z;return[t.x/r+e,(t.x+1)/r+e]}ki.maxOverzooming=10,ki.maxUnderzooming=3;const qT=xt([{name:"a_pos_3f",components:3,type:"Float32"}]),ZT=xt([{name:"a_color_3f",components:3,type:"Float32"}]),$T=xt([{name:"a_color_4f",components:4,type:"Float32"}]),HT=xt([{name:"a_uv_2f",components:2,type:"Float32"}]),WT=xt([{name:"a_normal_3f",components:3,type:"Float32"}]),XT=xt([{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"}]),YT=xt([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class rp{constructor(e=0,r=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(r)||r<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=r,this.left=i,this.right=o}interpolate(e,r,i){return r.top!=null&&e.top!=null&&(this.top=Fe(e.top,r.top,i)),r.bottom!=null&&e.bottom!=null&&(this.bottom=Fe(e.bottom,r.bottom,i)),r.left!=null&&e.left!=null&&(this.left=Fe(e.left,r.left,i)),r.right!=null&&e.right!=null&&(this.right=Fe(e.right,r.right,i)),this}getCenter(e,r){const i=Se((this.left+e-this.right)/2,0,e),o=Se((this.top+r-this.bottom)/2,0,r);return new N(i,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new rp(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qy(t,e){const r=$t(t,3);V.fromQuat(t,e),wr(t,3,r)}function ip(t,e){const r=Ar.identity([]);return Ar.rotateZ(r,r,-e),Ar.rotateX(r,r,-t),r}function e0(t,e){const r=[t[0],t[1],0],i=[e[0],e[1],0];if(D.length(r)>=1e-15){const n=D.normalize([],r);D.scale(i,n,D.dot(i,n)),e[0]=i[0],e[1]=i[1]}const o=D.cross([],e,t);if(D.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return ip(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class t0{constructor(e,r){this.position=e,this.orientation=r}get position(){return this._position}set position(e){if(e){const r=e instanceof lt?e:new lt(e[0],e[1],e[2]);this._renderWorldCopies&&(r.x=Ni(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(e,r){if(this.orientation=null,!this.position)return;const i=this.position,o=this._elevation?this._elevation.getAtPointOrZero(lt.fromLngLat(e)):0,s=lt.fromLngLat(e,o),n=[s.x-i.x,s.y-i.y,s.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=e0(n,r)}setPitchBearing(e,r){this.orientation=ip($e(e),$e(-r))}}class Sc{constructor(e,r){this._transform=V.identity([]),this.orientation=r,this.position=e}get mercatorPosition(){const e=this.position;return new lt(e[0],e[1],e[2])}get position(){const e=$t(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var r;e&&wr(this._transform,3,[(r=e)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||Ar.identity([]),e&&Qy(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),r=this.right();return{bearing:Math.atan2(-r[1],r[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,r){this._orientation=ip(e,r),Qy(this._transform,this._orientation)}forward(){const e=$t(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=$t(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=$t(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,r){const i=new Float64Array(16);return V.invert(i,this.getWorldToCamera(e,r)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,r,i){const o=this.position;D.scale(o,o,-e);const s=new Float64Array(16);return V.fromScaling(s,[i,i,i]),V.translate(s,s,o),s[10]*=r,s}getWorldToCamera(e,r){const i=new Float64Array(16),o=new Float64Array(4),s=this.position;return Ar.conjugate(o,this._orientation),D.scale(s,s,-e),V.fromQuat(i,o),V.translate(i,i,s),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}getCameraToClipPerspective(e,r,i,o){const s=new Float64Array(16);return V.perspective(s,e,r,i,o),s}getCameraToClipOrthographic(e,r,i,o,s,n){const a=new Float64Array(16);return V.ortho(a,e,r,i,o,s,n),a}getDistanceToElevation(e,r=!1){const i=e===0?0:It(e,r?ar(this.position[1]):this.position[1]),o=this.forward();return(i-this.position[2])/o[2]}clone(){return new Sc([...this.position],[...this.orientation])}}function r0(t,e){const r=Aa(t.projection,t.zoom,t.width,t.height),i=function(s,n,a,l,c){const u=new Ne(a.lng-180*Xo,a.lat),h=new Ne(a.lng+180*Xo,a.lat),d=s.project(u.lng,u.lat),p=s.project(h.lng,h.lat),f=-Math.atan2(p.y-d.y,p.x-d.x),m=lt.fromLngLat(a);m.y=Se(m.y,-1+Xo,1-Xo);const _=m.toLngLat(),g=s.project(_.lng,_.lat),y=lt.fromLngLat(_);y.x+=Xo;const v=y.toLngLat(),b=s.project(v.lng,v.lat),x=s0(b.x-g.x,b.y-g.y,f),w=lt.fromLngLat(_);w.y+=Xo;const T=w.toLngLat(),E=s.project(T.lng,T.lat),M=s0(E.x-g.x,E.y-g.y,f),S=Math.abs(x.x)/Math.abs(M.y),I=V.identity([]);V.rotateZ(I,I,-f*(1-(c?0:l)));const C=V.identity([]);return V.scale(C,C,[1,1-(1-S)*l,1]),C[4]=-M.x/M.y*l,V.rotateZ(C,C,f),V.multiply(C,I,C),C}(t.projection,0,t.center,r,e),o=i0(t);return V.scale(i,i,[o,o,1]),i}function i0(t){const e=t.projection,r=Aa(t.projection,t.zoom,t.width,t.height),i=o0(e,t.center),o=o0(e,Ne.convert(e.center));return Math.pow(2,i*r+(1-r)*o)}function Aa(t,e,r,i,o=1/0){const s=t.range;if(!s)return 0;const n=Math.min(o,Math.max(r,i)),a=Math.log(n/1024)/Math.LN2;return Fi(s[0]+a,s[1]+a,e)}const Xo=1/4e4;function o0(t,e){const r=Se(e.lat,-Jt,Jt),i=new Ne(e.lng-180*Xo,r),o=new Ne(e.lng+180*Xo,r),s=t.project(i.lng,r),n=t.project(o.lng,r),a=lt.fromLngLat(i),l=lt.fromLngLat(o),c=n.x-s.x,u=n.y-s.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log(p)/Math.LN2}function s0(t,e,r){const i=Math.cos(r),o=Math.sin(r);return{x:t*i-e*o,y:t*o+e*i}}function Es(t,e,r){return e*(W/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}const Tn={unknown:0,flipRequired:1,flipNotRequired:2},JT=Math.tan(85*Math.PI/180);function Ac(t,e,r,i,o,s,n){const a=V.create();if(r)if(s.name==="globe"){const l=function(c,u){const{x:h,y:d}=c.point,p=Eg(h,d,c.worldSize/c._pixelsPerMercatorPixel,0,0);return V.multiply(p,p,_d(si(u)))}(o,e);V.multiply(a,a,l)}else{const l=an.invert([],n);a[0]=l[0],a[1]=l[1],a[4]=l[2],a[5]=l[3],i||V.rotateZ(a,a,o.angle)}else V.multiply(a,o.labelPlaneMatrix,t);return a}function n0(t,e,r,i,o,s,n){const a=Ac(t,e,r,i,o,s,n);return s.name==="globe"&&r||(a[2]=a[6]=a[10]=a[14]=0),a}function a0(t,e,r,i,o,s,n){if(r){if(s.name==="globe"){const a=Ac(t,e,r,i,o,s,n);return V.invert(a,a),V.multiply(a,t,a),a}{const a=V.clone(t),l=V.identity([]);return l[0]=n[0],l[1]=n[1],l[4]=n[2],l[5]=n[3],V.multiply(a,a,l),i||V.rotateZ(a,a,-o.angle),a}}return o.glCoordMatrix}function Pi(t,e,r,i){const o=[t,e,r,1];r?Mt.transformMat4(o,o,i):f0(o,o,i);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function l0(t,e){return Math.min(.5+t/e*.5,1.5)}function KT(t,e){const r=t[0]/t[3],i=t[1]/t[3];return r>=-e[0]&&r<=e[0]&&i>=-e[1]&&i<=e[1]}function QT(t,e,r,i,o,s,n,a,l,c){const u=r.transform,h=i?t.textSizeData:t.iconSizeData,d=Hi(h,r.transform.zoom),p=u.projection.name==="globe",f=[256/r.width*2+1,256/r.height*2+1],m=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let _=null;p&&(_=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const g=t.lineVertexArray,y=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b,x=!1;for(let w=0;w<y.length;w++){const T=y.get(w),{numGlyphs:E,writingMode:M}=T;if(M!==Nt.vertical||x||b===Nt.horizontal||(x=!0),b=M,(T.hidden||M===Nt.vertical)&&!x){En(E,m);continue}x=!1;const S=new N(T.tileAnchorX,T.tileAnchorY);let{x:I,y:C,z:k}=u.projection.projectTilePoint(S.x,S.y,c.canonical);if(l){const[X,Y,K]=l(S);I+=X,C+=Y,k+=K}const A=[I,C,k,1];if(Mt.transformMat4(A,A,e),!KT(A,f)){En(E,m);continue}const L=A[3],O=l0(r.transform.getCameraToCenterDistance(u.projection),L),U=ma(h,d,T),R=n?U/O:U*O,B=Pi(I,C,k,o);if(B[3]<=0){En(E,m);continue}let G={};const Z=n?null:l,q=h0(T,R,!1,a,e,o,s,t.glyphOffsetArray,g,m,_,B,S,G,v,Z,u.projection,c,n);x=q.useVertical,Z&&q.needsFlipping&&(G={}),(q.notEnoughRoom||x||q.needsFlipping&&h0(T,R,!0,a,e,o,s,t.glyphOffsetArray,g,m,_,B,S,G,v,Z,u.projection,c,n).notEnoughRoom)&&En(E,m)}i?(t.text.dynamicLayoutVertexBuffer.updateData(m),_&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(_)):(t.icon.dynamicLayoutVertexBuffer.updateData(m),_&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(_))}function c0(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){const{lineStartIndex:_,glyphStartIndex:g,segment:y}=a,v=g+a.numGlyphs,b=_+a.lineLength,x=e.getoffsetX(g),w=e.getoffsetX(v-1),T=Ic(t*x,r,i,o,s,n,y,_,b,l,c,u,h,d,!0,p,f,m);if(!T)return null;const E=Ic(t*w,r,i,o,s,n,y,_,b,l,c,u,h,d,!0,p,f,m);return E?{first:T,last:E}:null}function u0(t,e,r,i){return t===Nt.horizontal&&Math.abs(i)>Math.abs(r)?{useVertical:!0}:t===Nt.vertical?i>0?{needsFlipping:!0}:null:e!==Tn.unknown&&function(o,s){return o===0||Math.abs(s/o)>JT}(r,i)?e===Tn.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function h0(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y){const v=e/24,b=t.lineOffsetX*v,x=t.lineOffsetY*v,{lineStartIndex:w,glyphStartIndex:T,numGlyphs:E,segment:M,writingMode:S,flipState:I}=t,C=w+t.lineLength,k=A=>{if(u){const[R,B,G]=A.up,Z=c.length;vc(u,Z+0,R,B,G),vc(u,Z+1,R,B,G),vc(u,Z+2,R,B,G),vc(u,Z+3,R,B,G)}const[L,O,U]=A.point;wn(c,L,O,U,A.angle)};if(E>1){const A=c0(v,a,b,x,r,h,d,t,l,s,p,m,!1,_,g,y);if(!A)return{notEnoughRoom:!0};if(i&&!r){let[L,O,U]=A.first.point,[R,B,G]=A.last.point;[L,O]=Pi(L,O,U,n),[R,B]=Pi(R,B,G,n);const Z=u0(S,I,(R-L)*f,B-O);if(t.flipState=Z&&Z.needsFlipping?Tn.flipRequired:Tn.flipNotRequired,Z)return Z}k(A.first);for(let L=T+1;L<T+E-1;L++){const O=Ic(v*a.getoffsetX(L),b,x,r,h,d,M,w,C,l,s,p,m,!1,!1,_,g,y);if(!O)return c.length-=4*(L-T),{notEnoughRoom:!0};k(O)}k(A.last)}else{if(i&&!r){const L=Pi(d.x,d.y,0,o),O=w+M+1,U=new N(l.getx(O),l.gety(O)),R=Pi(U.x,U.y,0,o),B=R[3]>0?R:p0(d,U,L,1,o,void 0,_,g.canonical),G=u0(S,I,(B[0]-L[0])*f,B[1]-L[1]);if(t.flipState=G&&G.needsFlipping?Tn.flipRequired:Tn.flipNotRequired,G)return G}const A=Ic(v*a.getoffsetX(T),b,x,r,h,d,M,w,C,l,s,p,m,!1,!1,_,g,y);if(!A)return{notEnoughRoom:!0};k(A)}return{}}function d0(t,e,r,i,o){const{x:s,y:n,z:a}=i.projectTilePoint(t.x,t.y,e);if(!o)return Pi(s,n,a,r);const[l,c,u]=o(t);return Pi(s+l,n+c,a+u,r)}function p0(t,e,r,i,o,s,n,a){const l=d0(t.sub(e)._unit()._add(t),a,o,n,s);return D.sub(l,r,l),D.normalize(l,l),D.scaleAndAdd(l,r,l,i)}function Ic(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=i?t-e:t+e;let v=y>0?1:-1,b=0;i&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let x=a+n+(v>0?0:1)|0,w=o,T=o,E=0,M=0;const S=Math.abs(y),I=[],C=[];let k=s,A=k;const L=()=>p0(A,k,T,S-E+1,u,d,m,_.canonical);for(;E+M<=S;){if(x+=v,x<a||x>=l)return null;if(T=w,A=k,I.push(T),p&&C.push(A),k=new N(c.getx(x),c.gety(x)),w=h[x],!w){const Y=d0(k,_.canonical,u,m,d);w=Y[3]>0?h[x]=Y:L()}E+=M,M=D.distance(T,w)}f&&d&&(h[x]&&(w=L(),M=D.distance(T,w)),h[x]=w);const O=(S-E)/M,U=k.sub(A)._mult(O)._add(A),R=D.sub([],w,T),B=D.scaleAndAdd([],T,R,O);let G=[0,0,1],Z=R[0],q=R[1];if(g&&(G=m.upVector(_.canonical,U.x,U.y),G[0]!==0||G[1]!==0||G[2]!==1)){const Y=[G[2],0,-G[0]],K=D.cross([],G,Y);D.normalize(Y,Y),D.normalize(K,K),Z=D.dot(R,Y),q=D.dot(R,K)}if(r){const Y=D.cross([],G,R);D.normalize(Y,Y),D.scaleAndAdd(B,B,Y,r*v)}const X=b+Math.atan2(q,Z);return I.push(B),p&&C.push(U),{point:B,angle:X,path:I,tilePath:C,up:G}}function En(t,e){const r=e.length,i=r+4*t;e.resize(i),e.float32.fill(-1/0,4*r,4*i)}function f0(t,e,r){const i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t[3]=r[3]*i+r[7]*o+r[15],t}const m0=(t,e,r)=>(1-r)*t+r*e,_0=t=>t*t*t*t*t;class op{constructor(e,r,i,o,s,n,a){this.tileSize=512,this._renderWorldCopies=s===void 0||s,this._minZoom=e||0,this._maxZoom=r||22,this._minPitch=i??0,this._maxPitch=o??60,this.setProjection(n),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new Ne(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 rp,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Sc,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new op(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(e,r=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(r),this._calcMatrices()}getProjection(){return jr(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=mc(this.projectionOptions);const i=!dt(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=mc({name:"mercator"});const r=e!==this.projection.name;return r&&this._calcMatrices(),r}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return It(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new N(this.width,this.height)}get bearing(){return Ni(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const r=-e*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=an.create(),an.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const r=Se(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,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 e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=$e(e),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const r=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==r&&(this._unmodified=!1,this._setZoom(r),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,r=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!r||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;r||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let o=0,s=0;for(let n=0;n<r.length;n++){const a=new N(r[n][0]*this.width,i+r[n][1]*(this.height-i)),l=e.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);o+=l[3]*c,s+=c}return s===0?NaN:o/s}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const e=this._seaLevelZoom,r=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*r,o=this._mercatorZfromZoom(e),s=this._mercatorZfromZoom(this._maxZoom),n=Math.max(o-i,s);this._setZoom(this._zoomFromMercatorZ(n))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(e){const r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[r.x,r.y,r.z]:[e.x,e.y,e.z];const o=D.length(D.sub([],this._camera.position,i));return Se(this._zoomFromMercatorZ(o),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height||!e.position&&!e.orientation)return;this._updateCameraState();let r=!1;if(e.orientation&&!Ar.exactEquals(e.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];D.exactEquals(i,this._camera.position)||(this._setCameraPosition(i),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,r=new t0;return r.position=new lt(e[0],e[1],e[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(e){if(!Ar.length(e))return!1;Ar.normalize(e,e);const r=D.transformQuat([],[0,0,-1],e),i=D.transformQuat([],[0,-1,0],e);if(i[2]<0)return!1;const o=e0(r,i);return!!o&&(this._camera.orientation=o,!0)}_setCameraPosition(e){const r=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,o=this.cameraToCenterDistance;e[2]=Se(e[2],o/i,o/r),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,r,i){this._unmodified=!1,this._edgeInsets.interpolate(e,r,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const r=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,r)}getVisibleUnwrappedCoordinates(e){const r=[new ud(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new N(0,0)),o=this.pointCoordinate(new N(this.width,0)),s=this.pointCoordinate(new N(this.width,this.height)),n=this.pointCoordinate(new N(0,this.height)),a=Math.floor(Math.min(i.x,o.x,s.x,n.x)),l=Math.floor(Math.max(i.x,o.x,s.x,n.x)),c=1;for(let u=a-c;u<=l+c;u++)u!==0&&r.push(new ud(u,e))}return r}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(e,r,i){let o=[];if(r[0]===0&&r[1]===0)return o;for(const n of e){const a=n.canonical,l=n.overscaledZ,c=n.wrap,u=1<<a.z,h=a.x+1<u,d=a.x>0,p=a.y+1<u,f=a.y>0,m=n.wrap-(d?0:1),_=n.wrap+(h?0:1),g=d?a.x-1:u-1,y=h?a.x+1:0;r[0]<0?(o.push(new mt(l,_,a.z,y,a.y)),r[1]<0&&p&&(o.push(new mt(l,c,a.z,a.x,a.y+1)),o.push(new mt(l,_,a.z,y,a.y+1))),r[1]>0&&f&&(o.push(new mt(l,c,a.z,a.x,a.y-1)),o.push(new mt(l,_,a.z,y,a.y-1)))):r[0]>0?(o.push(new mt(l,m,a.z,g,a.y)),r[1]<0&&p&&(o.push(new mt(l,c,a.z,a.x,a.y+1)),o.push(new mt(l,m,a.z,g,a.y+1))),r[1]>0&&f&&(o.push(new mt(l,c,a.z,a.x,a.y-1)),o.push(new mt(l,m,a.z,g,a.y-1)))):r[1]<0&&p?o.push(new mt(l,c,a.z,a.x,a.y+1)):f&&o.push(new mt(l,c,a.z,a.x,a.y-1))}if(o.length>1){o.sort((l,c)=>l.overscaledZ-c.overscaledZ||l.wrap-c.wrap||l.canonical.z-c.canonical.z||l.canonical.x-c.canonical.x||l.canonical.y-c.canonical.y);let n=0,a=0;for(;a<o.length;)o[a].equals(o[n])?++a:o[++n]=o[a++];o.length=n+1}const s=[];for(const n of o)o.some(a=>n.isChildOf(a))||s.push(n);return o=s.filter(n=>!e.some(a=>!!(n.overscaledZ<i&&a.isChildOf(n))||n.equals(a)||n.isChildOf(a))),o}coveringTiles(e){let r=this.coveringZoomLevel(e);const i=r,o=this.elevation&&this.elevation.exaggeration(),s=o&&!e.isTerrainDEM,n=this.projection.name==="mercator";if(e.minzoom!==void 0&&r<e.minzoom)return[];e.maxzoom!==void 0&&r>e.maxzoom&&(r=e.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<r,u=[c*a.x,c*a.y,0],h=this.projection.name==="globe",d=!h,p=_o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,d),f=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*It(1,this.center.lat),_=this._camera.position[2]/It(1,this.center.lat),g=[c*f.x,c*f.y,_*(d?1:m)],y=h||o,v=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),b=this.isLODDisabled(!0)?r:0;let x;if(this._elevation&&e.isTerrainDEM)x=1e4*this._elevation.exaggeration();else if(this._elevation){const R=this._elevation.getMinMaxForVisibleTiles();x=R?R.max:this._centerAltitude}else x=this._centerAltitude;const w=e.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?i0(this):1,E=R=>{const B=new lt(R.x+25e-6,R.y,R.z),G=new lt(R.x,R.y+25e-6,R.z),Z=R.toLngLat(),q=B.toLngLat(),X=G.toLngLat(),Y=this.locationCoordinate(Z),K=this.locationCoordinate(q),H=this.locationCoordinate(X),ee=Math.hypot(K.x-Y.x,K.y-Y.y),de=Math.hypot(H.x-Y.x,H.y-Y.y);return Math.sqrt(ee*de)*T/25e-6},M=R=>{const B=x,G=w;return{aabb:Vy(this,c,0,0,0,R,G,B,this.projection),zoom:0,x:0,y:0,minZ:G,maxZ:B,wrap:R,fullyVisible:!1}},S=[];let I=[];const C=r,k=e.reparseOverscaled?i:r,A=R=>R*R,L=A((_-this._centerAltitude)*m),O=R=>{if(!this._elevation||!R.tileID||!n)return;const B=this._elevation.getMinMaxForTile(R.tileID),G=R.aabb;B?(G.min[2]=B.min,G.max[2]=B.max,G.center[2]=(G.min[2]+G.max[2])/2):(R.shouldSplit=U(R),R.shouldSplit||(G.min[2]=G.max[2]=G.center[2]=this._centerAltitude))},U=R=>{if(R.zoom<b)return!0;if(R.zoom===C)return!1;if(R.shouldSplit!=null)return R.shouldSplit;const B=R.aabb.distanceX(g),G=R.aabb.distanceY(g);let Z=L,q=1;if(h){Z=A(R.aabb.distanceZ(g));const K=Math.pow(2,R.zoom),H=ar((R.y+1)/K),ee=ar(R.y/K),de=Math.min(Math.max(l,H),ee),pe=Gl(de)/Gl(l);if(q=de===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,pe/this._mercatorScaleRatio),this.zoom<=ca&&R.zoom===C-1&&pe>=.9)return!0}else if(s&&(Z=A(R.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&i<=5){const K=Math.pow(2,R.zoom),H=E(new lt((R.x+.5)/K,(R.y+.5)/K));q=H>.85?1:H}const X=B*B+G*G+Z,Y=A((1<<C-R.zoom)*v*q*((K,H)=>{if(H*A(.707)<K)return 1;const ee=Math.sqrt(H/K);return ee/(1.4144271570014144+(Math.pow(1.1,ee-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Z,L),X));return X<Y};if(this.renderWorldCopies)for(let R=1;R<=3;R++)S.push(M(-R)),S.push(M(R));for(S.push(M(0));S.length>0;){const R=S.pop(),B=R.x,G=R.y;let Z=R.fullyVisible;const q=()=>this.projection.name==="globe"&&(R.y===0||R.y===(1<<R.zoom)-1);if(!Z){let X=y?R.aabb.intersects(p):R.aabb.intersectsFlat(p);if(X===0&&q()){const Y=new _i(R.zoom,B,G);X=fd(this,c,Y,!0).intersects(p)}if(X===0)continue;Z=X===2}if(R.zoom!==C&&U(R))for(let X=0;X<4;X++){const Y=(B<<1)+X%2,K=(G<<1)+(X>>1),H={aabb:n?R.aabb.quadrant(X):Vy(this,c,R.zoom+1,Y,K,R.wrap,R.minZ,R.maxZ,this.projection),zoom:R.zoom+1,x:Y,y:K,wrap:R.wrap,fullyVisible:Z,tileID:void 0,shouldSplit:void 0,minZ:R.minZ,maxZ:R.maxZ};s&&!h&&(H.tileID=new mt(R.zoom+1===C?k:R.zoom+1,R.wrap,R.zoom+1,Y,K),O(H)),S.push(H)}else{const X=R.zoom===C?k:R.zoom;if(e.minzoom&&e.minzoom>X)continue;if(!Z){let ee=y?R.aabb.intersectsPrecise(p):R.aabb.intersectsPreciseFlat(p);if(ee===0&&q()){const de=new _i(R.zoom,B,G);ee=fd(this,c,de,!0).intersectsPrecise(p)}if(ee===0)continue}const Y=u[0]-(.5+B+(R.wrap<<R.zoom))*(1<<r-R.zoom),K=u[1]-.5-G,H=R.tileID?R.tileID:new mt(X,R.wrap,R.zoom,B,G);I.push({tileID:H,distanceSq:Y*Y+K*K})}}if(this.fogCullDistSq){const R=this.fogCullDistSq,B=this.horizonLineFromTop();I=I.filter(G=>{const Z=[0,0,0,1],q=[W,W,0,1],X=this.calculateFogTileMatrix(G.tileID.toUnwrapped());Mt.transformMat4(Z,Z,X),Mt.transformMat4(q,q,X);const Y=function(ee,de,pe){let ge=0;for(let xe=0;xe<2;++xe)ee[xe]>0&&(ge+=(ee[xe]-0)*(ee[xe]-0)),de[xe]<0&&(ge+=(0-de[xe])*(0-de[xe]));return ge}(Mt.min([],Z,q),Mt.max([],Z,q));if(Y===0)return!0;let K=!1;const H=this._elevation;if(H&&Y>R&&B!==0){const ee=this.calculateProjMatrix(G.tileID.toUnwrapped());let de;e.isTerrainDEM||(de=H.getMinMaxForTile(G.tileID)),de||(de={min:w,max:x});const pe=function(xe){const Oe=Math.round((xe+45+360)%360/90)%4;return cu[Oe]}(this.rotation),ge=[pe[0]*W,pe[1]*W,de.max];D.transformMat4(ge,ge,ee),K=(1-ge[1])*this.height*.5<B}return Y<R||K})}return I.sort((R,B)=>R.distanceSq-B.distanceSq).map(R=>R.tileID)}resize(e,r){this.width=e,this.height=r,this.pixelsToGLUnits=[2/e,-2/r],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const r=Se(e.lat,-Jt,Jt),i=this.projection.project(e.lng,r);return new N(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/It(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,r){let i,o;const s=this.centerPoint;if(this.projection.name==="globe"){const a=this.worldSize;i=(r.x-s.x)/a,o=(r.y-s.y)/a}else{const a=this.pointCoordinate(r),l=this.pointCoordinate(s);i=a.x-l.x,o=a.y-l.y}const n=this.locationCoordinate(e);this.setLocation(new lt(n.x-i,n.y-o))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,r){const i=r?It(r,e.lat):void 0,o=this.projection.project(e.lng,e.lat);return new lt(o.x,o.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,r){const i=r??this._centerAltitude,o=[e.x,e.y,0,1],s=[e.x,e.y,1,1];Mt.transformMat4(o,o,this.pixelMatrixInverse),Mt.transformMat4(s,s,this.pixelMatrixInverse);const n=s[3];Mt.scale(o,o,1/o[3]),Mt.scale(s,s,1/n);const a=o[2],l=s[2];return{p0:o,p1:s,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(e){const r=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return Mt.transformMat4(r,r,this.pixelMatrixInverse),Mt.transformMat4(i,i,this.pixelMatrixInverse),Mt.scale(r,r,1/r[3]),Mt.scale(i,i,1/i[3]),r[2]=It(r[2],this._center.lat)*this.worldSize,i[2]=It(i[2],this._center.lat)*this.worldSize,Mt.scale(r,r,1/this.worldSize),Mt.scale(i,i,1/this.worldSize),new Fl([r[0],r[1],r[2]],D.normalize([],D.sub([],i,r)))}rayIntersectionCoordinate(e){const{p0:r,p1:i,t:o}=e,s=It(r[2],this._center.lat),n=It(i[2],this._center.lat);return new lt(Fe(r[0],i[0],o)/this.worldSize,Fe(r[1],i[1],o)/this.worldSize,Fe(s,n,o))}pointCoordinate(e,r=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,r)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let r=this.projection.pointCoordinate3D(this,e.x,e.y);if(r)return new lt(r[0],r[1],r[2]);let i=0,o=this.horizonLineFromTop();if(e.y>o)return this.pointCoordinate(e);const s=.02*o,n=e.clone();for(let a=0;a<10&&o-i>s;a++){n.y=Fe(i,o,.66);const l=this.projection.pointCoordinate3D(this,n.x,n.y);l?(o=n.y,r=l):i=n.y}return r?new lt(r[0],r[1],r[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=Bo)return!this.isPointAboveHorizon(e);const r=this.pointCoordinate(e);return r.y>=0&&r.y<=1}_coordinatePoint(e,r){const i=r&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,o=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return Mt.transformMat4(o,o,this.pixelMatrix),o[3]>0?new N(o[0]/o[3],o[1]/o[3]):new N(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=this.pointLocation3D(new N(r,e)),n=this.pointLocation3D(new N(o,e)),a=this.pointLocation3D(new N(o,i)),l=this.pointLocation3D(new N(r,i));let c=Math.min(s.lng,n.lng,a.lng,l.lng),u=Math.max(s.lng,n.lng,a.lng,l.lng),h=Math.min(s.lat,n.lat,a.lat,l.lat),d=Math.max(s.lat,n.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f=this.projection.name==="globe"?1:4,m=(_,g,y,v,b)=>{const x=(_+y)/2,w=(g+v)/2,T=new N(x,w),{lng:E,lat:M}=this.pointLocation3D(T),S=Math.max(0,c-E,h-M,E-u,M-d);c=Math.min(c,E),u=Math.max(u,E),h=Math.min(h,M),d=Math.max(d,M),(b<f||S>p)&&(m(_,g,x,w,b+1),m(x,w,y,v,b+1))};if(m(r,e,o,e,1),m(o,e,o,i,1),m(o,i,r,i,1),m(r,i,r,e,1),this.projection.name==="globe"){const[_,g]=function(y){const v=V.identity(new Float64Array(16));V.multiply(v,y.pixelMatrix,y.globeMatrix);const b=[0,gi,0],x=[0,yi,0];return D.transformMat4(b,b,v),D.transformMat4(x,x,v),[b[0]>0&&b[0]<=y.width&&b[1]>0&&b[1]<=y.height&&!jl(y,new Ne(y.center.lat,90)),x[0]>0&&x[0]<=y.width&&x[1]>0&&x[1]<=y.height&&!jl(y,new Ne(y.center.lat,-90))]}(this);_?(d=90,u=180,c=-180):g&&(h=-90,u=180,c=-180)}return new Yr(new Ne(c,h),new Ne(u,d))}_getBoundsRectangular(e,r){const{top:i,left:o}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,a=new N(o,i),l=new N(n,i),c=new N(n,s),u=new N(o,s);let h=this.pointCoordinate(a,e),d=this.pointCoordinate(l,e);const p=this.pointCoordinate(c,r),f=this.pointCoordinate(u,r),m=(_,g)=>(g.y-_.y)/(g.x-_.x);return h.y>1&&d.y>=0?h=new lt((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new lt(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new lt((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new lt(-p.y/m(p,d)+p.x,0)),new Yr().extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const r=e.visibleDemTiles.reduce((i,o)=>{if(o.dem){const s=o.dem.tree;i.min=Math.min(i.min,s.minimums[0]),i.max=Math.max(i.max,s.maximums[0])}return i},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(r.min*e.exaggeration(),r.max*e.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const r=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-r*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-Jt,this.maxLat=Jt,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=ur(this.minLng)*this.tileSize,this.worldMaxX=ur(this.maxLng)*this.tileSize,this.worldMinY=dr(this.maxLat)*this.tileSize,this.worldMaxY=dr(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,r){return this.projection.createTileMatrix(this,r,e)}calculateDistanceTileData(e){const r=e.key,i=this._distanceTileDataCache;if(i[r])return i[r];const o=e.canonical,s=1/this.height,n=this.cameraWorldSize,a=n/this.zoomScale(o.z),l=(o.x+Math.pow(2,o.z)*e.wrap)*a,c=o.y*a,u=this.point;u.x*=n/this.worldSize,u.y*=n/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return i[r]={bearing:[d,p],center:[(u.x-l)*s,(u.y-c)*s],scale:a/W*s},i[r]}calculateFogTileMatrix(e){const r=e.key,i=this._fogTileMatrixCache;if(i[r])return i[r];const o=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return V.multiply(o,this.worldToFogMatrix,o),i[r]=new Float32Array(o),i[r]}calculateProjMatrix(e,r=!1,i=!1){const o=e.key;let s;if(s=i?this._expandedProjMatrixCache:r?this._alignedProjMatrixCache:this._projMatrixCache,s[o])return s[o];const n=this.calculatePosMatrix(e,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:r?this.alignedProjMatrix:this.projMatrix,V.multiply(n,a,n),s[o]=new Float32Array(n),s[o]}calculatePixelsToTileUnitsMatrix(e){const r=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];const o=function(s,n){const{scale:a}=s.tileTransform,l=a*W/(s.tileSize*Math.pow(2,n.zoom-s.tileID.overscaledZ+s.tileID.canonical.z));return an.scale(new Float32Array(4),n.inverseAdjustmentMatrix,[l,l])}(e,this);return i[r]=o,i[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const e=1/this.worldSize,r=V.fromScaling([],[e,e,e]);return V.multiply(r,r,this.globeMatrix),r}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const e=this._elevation;this._updateCameraState();const r=It(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),o=this._camera.forward(),s=It(1,this._center.lat);i[2]/=s,o[2]/=s,D.normalize(o,o);const n=e.raycast(i,o,e.exaggeration());if(n){const a=D.scaleAndAdd([],i,o,n),l=new lt(a[0],a[1],It(a[2],ar(a[1]))),c=(l.z+D.length([l.x-i[0],l.y-i[1],l.z-i[2]*s]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(c),this._centerAltitude=l.toAltitude(),this._center=this.coordinateLocation(l),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(e=!1){if(!this._elevation)return;const r=this._elevation,i=It(1,this._center.lat)*this.worldSize,o=this._computeCameraPosition(i),s=r.getAtPointOrZero(new lt(...o)),n=this.pixelsPerMeter/this.worldSize*s,a=this._minimumHeightOverTerrain(),l=o[2]-n;if(l<=a)if(l<0||e){const c=this.locationCoordinate(this._center,this._centerAltitude),u=[o[0],o[1],c.z-o[2]],h=D.length(u);u[2]-=(a-l)/this._pixelsPerMercatorPixel;const d=D.length(u);if(d===0)return;D.scale(u,u,h/d*this._pixelsPerMercatorPixel),this._camera.position=[o[0],o[1],c.z*this._pixelsPerMercatorPixel-u[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const d=this.center;return d.lat=Se(d.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(d.lng=Se(d.lng,this.minLng,this.maxLng)),this.center=d,void(this._constraining=!1)}const r=this._unmodified,{x:i,y:o}=this.point;let s=0,n=i,a=o;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(o-c<u&&(a=u+c),o+c>h&&(a=h-c),h-u<this.height&&(s=Math.max(s,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const d=this.worldMinX*this.scale,p=this.worldMaxX*this.scale,f=this.worldSize/2-(d+p)/2;n=(i+f+this.worldSize)%this.worldSize-f,n-l<d&&(n=d+l),n+l>p&&(n=p-l),p-d<this.width&&(s=Math.max(s,this.width/(p-d)),n=(p+d)/2)}n===i&&a===o||(this.center=this.unproject(new N(n,a))),s&&(this.zoom+=this.scaleZoom(s)),this._constrainCamera(),this._unmodified=r,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,r=this.projection.name==="globe",i=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=It(1,this.center.lat)/It(1,45));const o=Aa(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,o),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 s=this.projection.zAxisUnit==="meters"?i:1,n=this._camera.getWorldToCamera(this.worldSize,s);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-e.x/this.width,l[9]=2*e.y/this.height,this.isOrthographic){let M=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),S=M*this.aspect,I=-S,C=-M;S-=e.x,I-=e.x,M+=e.y,C+=e.y,a=this._camera.getCameraToClipOrthographic(I,S,C,M,this._nearZ,this._farZ),((k,A,L,O)=>{for(let U=0;U<16;U++)k[U]=m0(A[U],L[U],O)})(a,a,l,_0(this.pitch>=15?1:this.pitch/15))}else a=l;const c=V.mul([],l,n);let u=V.mul([],a,n);if(this.projection.isReprojectedInTileSpace){const M=this.locationCoordinate(this.center),S=V.identity([]);V.translate(S,S,[M.x*this.worldSize,M.y*this.worldSize,0]),V.multiply(S,S,r0(this)),V.translate(S,S,[-M.x*this.worldSize,-M.y*this.worldSize,0]),V.multiply(u,u,S),V.multiply(c,c,S),this.inverseAdjustmentMatrix=function(I){const C=r0(I,!0);return an.invert([],[C[0],C[1],C[4],C[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=V.scale([],u,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=u,this.invProjMatrix=V.invert(new Float64Array(16),this.projMatrix),r){const M=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);M[8]=2*-e.x/this.width,M[9]=2*e.y/this.height,this.expandedFarZProjMatrix=V.mul([],M,n)}else this.expandedFarZProjMatrix=this.projMatrix;const h=V.invert([],a);this.frustumCorners=hd.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=_o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);const d=new Float32Array(16);V.identity(d),V.scale(d,d,[1,-1,1]),V.rotateX(d,d,this._pitch),V.rotateZ(d,d,this.angle);const p=V.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=V.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-e.x/this.width,p[9]=2*(e.y+f)/this.height,this.skyboxMatrix=V.multiply(d,p,d);const m=this.point,_=m.x,g=m.y,y=this.width%2/2,v=this.height%2/2,b=Math.cos(this.angle),x=Math.sin(this.angle),w=_-Math.round(_)+b*y+x*v,T=g-Math.round(g)+b*v+x*y,E=new Float64Array(u);if(V.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,u=V.create(),V.scale(u,u,[this.width/2,-this.height/2,1]),V.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=V.create(),V.scale(u,u,[1,-1,1]),V.translate(u,u,[-1,-1,0]),V.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=V.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=V.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=function(S){const{x:I,y:C}=S.point,{lng:k,lat:A}=S._center;return Eg(I,C,S.worldSize,k,A)}(this);const M=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=D.transformMat4(M,M,n),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,o=1/this.height/this._pixelsPerMercatorPixel,s=[e,e,r];D.scale(s,s,o),D.scale(i,i,-1),D.multiply(i,i,s);const n=V.create();V.translate(n,n,i),V.scale(n,n,s),this.mercatorFogMatrix=n,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,r,o)}_computeCameraPosition(e){const r=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,s=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*r-e/this.worldSize*this._centerAltitude;return[o.x/this.worldSize-i[0]*s,o.y/this.worldSize-i[1]*s,e/this.worldSize*this._centerAltitude-i[2]*s]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],o=e[2];let s=1;this.projection.wrap&&(this.center=this.center.wrap()),o>0&&(s=Math.min((r-i)/o,1)),this._camera.position=D.scaleAndAdd([],this._camera.position,e,s),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,r=this._camera.forward(),{pitch:i,bearing:o}=this._camera.getPitchBearing(),s=It(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,n=this._mercatorZfromZoom(this._maxZoom)*Math.cos($e(this._maxPitch)),a=Math.max((e[2]-s)/Math.cos(i),n),l=this._zoomFromMercatorZ(a);D.scaleAndAdd(e,e,r,a),this._pitch=Se(i,$e(this.minPitch),$e(this.maxPitch)),this.angle=Ni(o,-Math.PI,Math.PI),this._setZoom(Se(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new lt(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){let r=0,i=Bo,o=0,s=1/0;for(;i-r>1e-6&&i>r;){const n=r+.5*(i-r),a=this.tileSize*Math.pow(2,n),l=this.getCameraToCenterDistance(this.projection,n,a),c=this.scaleZoom(l/(e*this.tileSize)),u=Math.abs(n-c);u<s&&(s=u,o=n),n<c?r=n:i=n}return o}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(F("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,r){const i=Math.min(e.x,r.x),o=Math.max(e.x,r.x),s=Math.min(e.y,r.y),n=Math.max(e.y,r.y);if(s<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const a=[new N(i,s),new N(o,n),new N(i,n),new N(o,s)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const u of a){const h=this.pointRayIntersection(u);if(h.t<0)return!0;const d=this.rayIntersectionCoordinate(h);if(d.x<l||d.y<0||d.x>c||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+br(this.fovAboveCenter)>88||this.anyCornerOffEdge(new N(0,0),new N(this.width,this.height))}zoomDeltaToMovement(e,r){const i=D.length(D.sub([],this._camera.position,e)),o=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(o)}getCameraPoint(){if(this.projection.name==="globe"){const e=function([r,i,o],s){const n=[r,i,o,1];Mt.transformMat4(n,n,s);const a=n[3]=Math.max(n[3],1e-6);return n[0]/=a,n[1]/=a,n[2]/=a,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new N(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new N(0,e))}}getCameraToCenterDistance(e,r=this.zoom,i=this.worldSize){const o=Aa(e,r,this.width,this.height,1024),s=e.pixelSpaceConversion(this.center.lat,i,o);let n=.5/Math.tan(.5*this._fov)*this.height*s;return this.isOrthographic&&(n=m0(1,n,_0(this.pitch>=15?1:this.pitch/15))),n}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&V.multiply(e,e,this.globeMatrix),e}getFrustum(e){return _o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,this.projection.zAxisUnit==="meters")}}function g0(t,e,r){V.identity(t),V.rotateZ(t,t,$e(e[2])),V.rotateX(t,t,$e(e[0])),V.rotateY(t,t,$e(e[1])),V.scale(t,t,r),V.multiply(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Cc(t,e,r,i,o,s,n,a){const l=[r[0]-e[0],r[1]-e[1],0],c=[i[0]-e[0],i[1]-e[1],0];if(D.length(l)<1e-12||D.length(c)<1e-12)return Ar.identity(t);const u=D.cross([],l,c);D.normalize(u,u),D.subtract(c,i,e),l[2]=(s-o)*a,c[2]=(n-o)*a;const h=l;return D.cross(h,l,c),D.normalize(h,h),Ar.rotationTo(t,u,h)}function y0(t,e,r=!1){const i=yr(e.zoom),o=function(s,n,a){const l=n.worldSize,c=[s[12],s[13],s[14]],u=ar(c[1]/l),h=Jr(c[0]/l),d=V.identity([]),p=It(1,u)*l,f=It(1,0)*l*No(u,n.zoom),m=1/gd(l);let _=f*m;if(a){const b=Aa(n.projection,n.zoom,n.width,n.height,1024);_=m*n.projection.pixelSpaceConversion(n.center.lat,l,b)}const g=Nr(u,h);D.add(g,g,D.scale([],D.normalize([],g),p*_*c[2]));const y=function(b){const x=[b[0],b[1],b[2]];let w=[0,1,0];const T=D.cross([],w,x);return D.cross(w,x,T),D.squaredLength(w)===0&&(w=[0,1,0],D.cross(T,x,w)),D.normalize(T,T),D.normalize(w,w),D.normalize(x,x),[T[0],T[1],T[2],0,w[0],w[1],w[2],0,x[0],x[1],x[2],0,b[0],b[1],b[2],1]}(g);V.scale(d,d,[_,_,_*p]),V.translate(d,d,[-c[0],-c[1],-c[2]]);const v=V.multiply([],n.globeMatrix,y);return V.multiply(v,v,d),V.multiply(v,v,s),v}(t,e,r);if(i>0){const s=function(n,a){const l=a.worldSize,c=It(1,0)*l*No(a.center.lat,a.zoom)/gd(l),u=It(1,a.center.lat)*l,h=V.identity([]);return V.rotateY(h,h,$e(a.center.lng)),V.rotateX(h,h,$e(a.center.lat)),V.translate(h,h,[0,0,Pr]),V.scale(h,h,[c,c,c*u]),V.translate(h,h,[a.point.x-.5*l,a.point.y-.5*l,0]),V.multiply(h,h,n),V.multiply(h,a.globeMatrix,h)}(t,e);return function(n,a,l){const c=(f,m,_)=>{const g=D.length(f),y=D.length(m),v=go(f,m,_);return D.scale(v,v,1/D.length(v)*Fe(g,y,_))},u=c([n[0],n[1],n[2]],[a[0],a[1],a[2]],l),h=c([n[4],n[5],n[6]],[a[4],a[5],a[6]],l),d=c([n[8],n[9],n[10]],[a[8],a[9],a[10]],l),p=go([n[12],n[13],n[14]],[a[12],a[13],a[14]],l);return[u[0],u[1],u[2],0,h[0],h[1],h[2],0,d[0],d[1],d[2],0,p[0],p[1],p[2],1]}(o,s,i)}return o}const Ms=64,e3=[1,1,1];class x0{constructor(e,r,i,o){this.id=e,this.position=r!=null?new Ne(r[0],r[1]):new Ne(0,0),this.orientation=i??[0,0,0],this.nodes=o,this.uploaded=!1,this.aabb=new Pt([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,r){if(V.multiply(e.matrix,r,e.matrix),e.meshes)for(const i of e.meshes){const o=Pt.applyTransform(i.aabb,e.matrix);this.aabb.encapsulate(o)}if(e.children)for(const i of e.children)this._applyTransformations(i,e.matrix)}computeBoundsAndApplyParent(){const e=V.identity([]);for(const r of this.nodes)this._applyTransformations(r,e)}_positionModelOnTerrain(e,r){const i=e.elevation;if(!i)return 0;const o=Pt.projectAabbCorners(this.aabb,this.matrix),s=It(1,this.position.lat)*e.worldSize,n=function(g,y){const v=[0,0,1],b=[{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 x of b){const w=g[x.corners[0]],T=g[x.corners[1]],E=g[x.corners[2]],M=[T[0]-w[0],T[1]-w[1],y*(T[2]-w[2])],S=D.cross(M,M,[E[0]-w[0],E[1]-w[1],y*(E[2]-w[2])]);D.normalize(S,S),x.dotProductWithUp=D.dot(S,v)}return b.sort((x,w)=>x.dotProductWithUp-w.dotProductWithUp),b[0].corners}(o,s),a=o[n[0]],l=o[n[1]],c=o[n[2]],u=o[n[3]],h=i.getAtPointOrZero(new lt(a[0]/e.worldSize,a[1]/e.worldSize),0),d=i.getAtPointOrZero(new lt(l[0]/e.worldSize,l[1]/e.worldSize),0),p=i.getAtPointOrZero(new lt(c[0]/e.worldSize,c[1]/e.worldSize),0),f=i.getAtPointOrZero(new lt(u[0]/e.worldSize,u[1]/e.worldSize),0),m=(h+f)/2,_=(d+p)/2;return m>_?d<p?Cc(r,l,u,a,d,f,h,s):Cc(r,c,a,u,p,h,f,s):h<f?Cc(r,a,l,c,h,d,p,s):Cc(r,u,c,l,f,p,d,s),Math.max(m,_)}computeModelMatrix(e,r,i,o,s,n,a=!1){const l=e.transform,c=l.zoom,u=l.project(this.position),h=No(this.position.lat,c),d=1/h;V.identity(this.matrix),V.translate(this.matrix,this.matrix,[u.x+o[0]*d,u.y+o[1]*d,o[2]]);let p=1,f=1;const m=l.worldSize;if(a){if(l.projection.name==="mercator"){let v=0;l.elevation&&(v=l.elevation.getAtPointOrZero(new lt(u.x/m,u.y/m),0));const b=Mt.transformMat4([],[u.x,u.y,v,1],l.projMatrix)[3]/l.cameraToCenterDistance;p=b,f=b*No(l.center.lat,c)}else if(l.projection.name==="globe"){const v=y0(this.matrix,l),b=V.multiply([],l.projMatrix,v),x=[0,0,0,1];Mt.transformMat4(x,x,b);const w=x[3]/l.cameraToCenterDistance,T=yr(c),E=l.projection.pixelsPerMeter(this.position.lat,m)*No(this.position.lat,c),M=l.projection.pixelsPerMeter(l.center.lat,m)*No(l.center.lat,c);p=w/Fe(E,Pg(l.center.lat),T),f=w*h/E,p*=M,f*=M}}else p=d;V.scale(this.matrix,this.matrix,[p,p,f]);const _=[...this.matrix],g=this.orientation,y=[];if(g0(y,[g[0]+r[0],g[1]+r[1],g[2]+r[2]],i),V.multiply(this.matrix,_,y),s&&l.elevation){let v=0;const b=[];if(n&&l.elevation){v=this._positionModelOnTerrain(l,b);const x=V.fromQuat([],b),w=V.multiply([],x,y);V.multiply(this.matrix,_,w)}else v=l.elevation.getAtPointOrZero(new lt(u.x/m,u.y/m),0);v!==0&&(this.matrix[14]+=v)}}upload(e){if(!this.uploaded){for(const r of this.nodes)sp(r,e);for(const r of this.nodes)zc(r);this.uploaded=!0}}destroy(){for(const e of this.nodes)Dc(e)}}function Ia(t,e,r=!1){t.uploaded||(t.gfxTexture=new Gt(e,t.image,r?e.gl.R8:e.gl.RGBA,{useMipmap:t.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function t3(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,qT.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,WT.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,HT.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(t.colorArray.bytesPerElement===12?ZT:$T).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,YT.members,!0)),t.segments=Et.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const i=t.material;i.pbrMetallicRoughness.baseColorTexture&&Ia(i.pbrMetallicRoughness.baseColorTexture,e),i.pbrMetallicRoughness.metallicRoughnessTexture&&Ia(i.pbrMetallicRoughness.metallicRoughnessTexture,e),i.normalTexture&&Ia(i.normalTexture,e),i.occlusionTexture&&Ia(i.occlusionTexture,e,r),i.emissionTexture&&Ia(i.emissionTexture,e)}function sp(t,e,r){if(t.meshes)for(const i of t.meshes)t3(i,e,r);if(t.children)for(const i of t.children)sp(i,e,r)}function zc(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)zc(e)}function Dc(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.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 r of t.children)Dc(r)}class v0{constructor(e,r){this.feature=e,this.instancedDataOffset=r,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class b0{constructor(){this.instancedDataArray=new Vh,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class w0{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.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,r,i,o){this.tileToMeter=ha(i);const s=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:n,id:a,index:l,sourceLayerIndex:c}of e){const u=Uo(n,s);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),u,i))continue;const h={id:a,sourceLayerIndex:c,index:l,geometry:s?u.geometry:$i(n,i,o),properties:n.properties,type:n.type,patterns:{}},d=this.addFeature(h,h.geometry,u);d&&r.featureIndex.insert(n,h.geometry,l,c,this.index,this.instancesPerModel[d].instancedDataArray.length)}this.lookup=null}update(e,r,i,o){for(const s in this.instancesPerModel){const n=this.instancesPerModel[s];for(const a in e)n.idToFeaturesIndex.hasOwnProperty(a)&&this.evaluate(n.features[n.idToFeaturesIndex[a]],e[a],n,!0)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const r in this.instancesPerModel){const i=this.instancesPerModel[r];for(const o of i.features){const s=this.layers[0],n=o.feature,a=this.canonical,l=s.paint.get("model-rotation").evaluate(n,{},a),c=s.paint.get("model-scale").evaluate(n,{},a),u=s.paint.get("model-translation").evaluate(n,{},a);D.exactEquals(o.rotation,l)&&D.exactEquals(o.scale,c)&&D.exactEquals(o.translation,u)||(this.evaluate(o,o.featureStates,i,!0),e=!0)}}return e}isEmpty(){for(const e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const r in this.instancesPerModel){const i=this.instancesPerModel[r];i.instancedDataArray.length<0||i.instancedDataArray.length===0||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,XT.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length!==0&&r.instancedDataBuffer&&r.instancedDataBuffer.destroy()}}addFeature(e,r,i){const o=this.layers[0],s=o.layout.get("model-id").evaluate(i,{},this.canonical);if(!s)return F(`modelId is not evaluated for layer ${o.id} and it is not going to get rendered.`),s;this.instancesPerModel[s]||(this.instancesPerModel[s]=new b0);const n=this.instancesPerModel[s],a=n.instancedDataArray,l=new v0(i,a.length);for(const c of r)for(const u of c){if(u.x<0||u.x>=W||u.y<0||u.y>=W)continue;const h=(this.lookupDim-1)/W,d=this.lookupDim*(u.y*h|0)+u.x*h|0;if(this.lookup){if(this.lookup[d]!==0)continue;this.lookup[d]=1}this.instanceCount++;const p=a.length;a.resize(p+1),n.instancesEvaluatedElevation.push(0),a.float32[16*p]=u.x,a.float32[16*p+1]=u.y}return l.instancedDataCount=n.instancedDataArray.length-l.instancedDataOffset,l.instancedDataCount>0&&(e.id&&(n.idToFeaturesIndex[e.id]=n.features.length),n.features.push(l),this.evaluate(l,{},n,!1)),s}evaluate(e,r,i,o){const s=this.layers[0],n=e.feature,a=this.canonical,l=e.rotation=s.paint.get("model-rotation").evaluate(n,r,a),c=e.scale=s.paint.get("model-scale").evaluate(n,r,a),u=e.translation=s.paint.get("model-translation").evaluate(n,r,a),h=s.paint.get("model-color").evaluate(n,r,a);h.a=s.paint.get("model-color-mix-intensity").evaluate(n,r,a);const d=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]),this.maxScale=Math.max(Math.max(this.maxScale,c[0]),Math.max(c[1],c[2])),g0(d,l,c);const p=Math.round(100*h.a)+h.b/1.05;for(let f=0;f<e.instancedDataCount;++f){const m=e.instancedDataOffset+f,_=16*m,g=i.instancedDataArray.float32;let y=0;o&&(y=g[_+6]-i.instancesEvaluatedElevation[m]);const v=0|g[_+1];g[_]=(0|g[_])+h.r/1.05,g[_+1]=v+h.g/1.05,g[_+2]=p,g[_+3]=1/(a.z>10?this.tileToMeter:ha(a,v)),g[_+4]=u[0],g[_+5]=u[1],g[_+6]=u[2]+y,g[_+7]=d[0],g[_+8]=d[1],g[_+9]=d[2],g[_+10]=d[4],g[_+11]=d[5],g[_+12]=d[6],g[_+13]=d[8],g[_+14]=d[9],g[_+15]=d[10],i.instancesEvaluatedElevation[m]=u[2]}}}Ee(w0,"ModelBucket",{omit:["layers"]}),Ee(b0,"PerModelAttributes"),Ee(v0,"ModelFeature");const r3=new Xt({visibility:new se(j.layout_model.visibility),"model-id":new ke(j.layout_model["model-id"])});var i3={paint:new Xt({"model-opacity":new se(j.paint_model["model-opacity"]),"model-rotation":new ke(j.paint_model["model-rotation"]),"model-scale":new ke(j.paint_model["model-scale"]),"model-translation":new ke(j.paint_model["model-translation"]),"model-color":new ke(j.paint_model["model-color"]),"model-color-mix-intensity":new ke(j.paint_model["model-color-mix-intensity"]),"model-type":new se(j.paint_model["model-type"]),"model-cast-shadows":new se(j.paint_model["model-cast-shadows"]),"model-receive-shadows":new se(j.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new se(j.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ke(j.paint_model["model-emissive-strength"]),"model-roughness":new ke(j.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ke(j.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new se(j.paint_model["model-cutoff-fade-range"])}),layout:r3};const np=new Float32Array(262144),Ss=new Uint8Array(262144);function T0(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,T0(r));return e}const E0=["","wall","door","roof","window","lamp","logo"];class M0{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:T0(e)}}}}class S0{constructor(e,r,i,o){this.nodes=e,this.id=r,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.dirty=!0,this.needsUpload=!1}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 r=this.getNodesInfo();for(const i of r){const o=i.node;this.uploaded?this.updatePbrBuffer(o):sp(o,e,!0)}for(const i of r)zc(i.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let r=!1;if(!e.meshes)return r;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),r=!0);return r}needsReEvaluation(e,r,i){const o=e.transform.projectionOptions,s=e.style.getBrightness(),n=this.brightness!==s;return!!(!this.uploaded||this.dirty||o.name!==this.projection.name||Ca(i.paint.get("model-color").value,n)||Ca(i.paint.get("model-color-mix-intensity").value,n)||Ca(i.paint.get("model-roughness").value,n)||Ca(i.paint.get("model-emissive-strength").value,n)||Ca(i.paint.get("model-height-based-emissive-strength-multiplier").value,n))&&(this.projection=o,this.brightness=s,!0)}evaluateScale(e,r){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),o=this.id.canonical;for(const s of i){const n=s.feature;s.evaluatedScale=r.paint.get("model-scale").evaluate(n,{},o)}}evaluate(e){const r=this.getNodesInfo();for(const i of r){if(!i.node.meshes)continue;const o=i.feature,s=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],a=i.evaluatedRMEA[2],l=this.id.canonical;if(i.hasTranslucentParts=!1,s){for(let c=0;c<E0.length;c++){const u=E0[c];u.length&&(o.properties.part=u);const h=e.paint.get("model-color").evaluate(o,{},l),d=e.paint.get("model-color-mix-intensity").evaluate(o,{},l);i.evaluatedColor[c]=[h.r,h.g,h.b,d],i.evaluatedRMEA[c][0]=e.paint.get("model-roughness").evaluate(o,{},l),i.evaluatedRMEA[c][2]=e.paint.get("model-emissive-strength").evaluate(o,{},l),i.evaluatedRMEA[c][3]=h.a,i.emissionHeightBasedParams[c]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(o,{},l),!i.hasTranslucentParts&&h.a<1&&(i.hasTranslucentParts=!0)}delete o.properties.part,s3(i,n!==i.evaluatedColor[2]||a!==i.evaluatedRMEA[2])}i.evaluatedScale=e.paint.get("model-scale").evaluate(o,{},l),this.updatePbrBuffer(i.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,r,i,o){const s=e.findDEMTileFor(i);if(s&&(s.tileID.canonical!==this.terrainTile||r!==this.terrainExaggeration)){if(s.dem&&s.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=s.tileID.overscaledZ;const n=_n.create(e,i,s);if(!n)return;4&this.modelTraits&&this.updateDEM(e,n,i,o);for(const a of this.getNodesInfo()){const l=a.node;if(!l.footprint||!l.footprint.vertices||!l.footprint.vertices.length)continue;const c=l.footprint.vertices;let u=n.getElevationAt(c[0].x,c[0].y,!0,!0);for(let h=1;h<c.length;h++)u=Math.min(u,n.getElevationAt(c[h].x,c[h].y,!0,!0));l.elevation=u}}this.terrainTile=s.tileID.canonical,this.terrainExaggeration=r}}updateDEM(e,r,i,o){let s=r._dem._modifiedForSources[o];if(s===void 0&&(r._dem._modifiedForSources[o]=[],s=r._dem._modifiedForSources[o]),s.includes(i.canonical))return;const n=r._dem.dim;s.push(i.canonical);let a=!1;for(const l of this.getNodesInfo()){const c=l.node;if(!c.footprint||!c.footprint.grid)continue;const u=c.footprint.grid,h=r.tileCoordToPixel(u.min.x,u.min.y),d=r.tileCoordToPixel(u.max.x,u.max.y),p=Math.min(Math.min(n-d.y,h.x),Math.min(h.y,n-d.x));if(p<0)continue;const f=Se(p,2,5);let m=Math.max(0,h.x-f),_=Math.max(0,h.y-f),g=Math.min(d.x+f,n-1),y=Math.min(d.y+f,n-1);for(let w=_;w<=y;++w)for(let T=m;T<=g;++T)Ss[w*n+T]=255;let v=0,b=0;for(let w=0;w<u.cellsY;++w)for(let T=0;T<u.cellsX;++T){if(!u.cells[w*u.cellsX+T])continue;const E=r.tileCoordToPixel(u.min.x+T/u.xScale,u.min.y+w/u.yScale),M=r.tileCoordToPixel(u.min.x+(T+1)/u.xScale,u.min.y+(w+1)/u.yScale);for(let S=E.y;S<=Math.min(M.y+1,n-1);++S)for(let I=E.x;I<=Math.min(M.x+1,n-1);++I)Ss[S*n+I]===255&&(Ss[S*n+I]=0,v+=r.getElevationAtPixel(I,S),b++)}const x=v/b;m=Math.max(1,h.x-f),_=Math.max(1,h.y-f),g=Math.min(d.x+f,n-2),y=Math.min(d.y+f,n-2),a=!0;for(let w=_;w<=y;++w)for(let T=m;T<=g;++T)Ss[w*n+T]===0&&(np[w*n+T]=r._dem.set(T,w,x));for(let w=1;w<f;++w){m=Math.max(1,h.x-w),_=Math.max(1,h.y-w),g=Math.min(d.x+w,n-2),y=Math.min(d.y+w,n-2);for(let T=_;T<=y;++T)for(let E=m;E<=g;++E){const M=T*n+E;if(Ss[M]===255){let S=0,I=0,C=-1,k=-1;for(let A=-1;A<=1;++A)for(let L=-1;L<=1;++L){const O=(T+A)*n+E+L;if(Ss[O]>=w)continue;const U=np[O],R=Math.abs(U);R>I&&(S=U,I=R,C=L,k=A)}if(I>.1){const A=1-(w+.5*Math.abs(C*k))/f;let L=r._dem.get(E,T)+S*A;const O=r._dem.get(E+C,T+k),U=r._dem.get(E-C,T-k,!0);(L-O)*(L-U)>0&&(L=(O+U)/2),np[M]=r._dem.set(E,T,L),Ss[M]=w}}}}}a&&(r._demTile.needsDEMTextureUpload=!0,r._dem._timestamp=je.now())}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new M0(e));this.freeNodes()}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Dc(e);this.nodes.splice(0,this.nodes.length)}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const r of e)zc(r.node),Dc(r.node)}isEmpty(){return!this.nodes.length}updateReplacement(e,r){if(r.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=r.updateTime;const i=r.getReplacementRegionsForTile(e.toUnwrapped()),o=this.getNodesInfo();for(let s=0;s<this.nodesInfo.length;s++){const n=o[s].node;o[s].hiddenByReplacement=!!n.footprint&&!i.find(a=>a.footprint===n.footprint)}}getHeightAtTileCoord(e,r){const i=this.getNodesInfo(),o=[];for(let s=0;s<this.nodesInfo.length;s++){const n=i[s],a=n.node.meshes[0];if(e<a.aabb.min[0]||r<a.aabb.min[1]||e>a.aabb.max[0]||r>a.aabb.max[1])continue;const l=(e-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*Ms|0,c=Math.min(63,(r-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*Ms|0)*Ms+Math.min(63,l);if(!(a.heightmap[c]<0&&n.node.footprint))return n.hiddenByReplacement?void 0:{height:a.heightmap[c],maxHeight:n.feature.properties.height,hidden:!1,verticalScale:n.evaluatedScale[2]};if(n.node.footprint.grid.query(new N(e,r),new N(e,r),o),o.length>0)return{height:void 0,maxHeight:n.feature.properties.height,hidden:n.hiddenByReplacement,verticalScale:n.evaluatedScale[2]}}}}function Ca(t,e){return!t.isLightConstant&&e}function o3(t,e,r,i,o,s,n,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,u=240&e|(240&e)>>4;r[3]>0&&(l=Fe(l,255*r[0],r[3]),c=Fe(c,255*r[1],r[3]),u=Fe(u,255*r[2],r[3]));const h=l<<8|c,d=u<<8|Math.floor(255*i[3]),p=function(w){const T=Se(w,0,2);return Math.min(Math.round(.5*T*255),255)}(i[2])<<8|15*i[0]<<4|15*i[1],f=Se(o[0],0,1),m=Se(o[1],0,1),_=Se(o[2],0,1),g=Se(o[3],0,1);let y,v,b,x;if(f!==m&&n!==s&&m!==f){const w=n-s;v=1/(w*(m-f)),b=-(s+w*f)/(w*(m-f));const T=Se(o[4],-1,1);x=Math.pow(10,T),y=255*_<<8|255*g}else y=65535,v=0,b=1,x=1;if(t.emplaceBack(h,d,p,y,v,b,x),a){const w=a.length;a.clear();for(let T=0;T<w;T++)a.emplaceBack(h,d,p,y,v,b,x)}}function s3(t,e){const r=t.node;let i=0;for(const o of r.meshes){if(r.lights&&r.lightMeshIndex===i||!o.featureData)continue;o.featureArray=new Dl,o.featureArray.reserve(o.featureData.length);let s=e;for(const n of o.featureData){let a;const l=65535&n,c=(15&l)<8?15&l:0,u=n>>16&65535,h=t.evaluatedRMEA[c],d=t.evaluatedColor[c],p=t.emissionHeightBasedParams[c];if(s&&c===2&&r.lights&&(a=new Dl,a.resize(10*r.lights.length)),o3(o.featureArray,u,d,h,p,o.aabb.min[2],o.aabb.max[2],a),a&&s){s=!1;const f=r.meshes[r.lightMeshIndex];f.featureArray=a,f.featureArray._trim()}}o.featureArray._trim(),i++}}Ee(S0,"Tiled3dModelBucket",{omit:["layers"]}),Ee(M0,"Tiled3dModelFeature");class n3{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(e){const r=C0(new N(0,0),new N(W,W),e),i=[];for(const o of this._activeRegions){if(o.hiddenByOverlap||!I0(r,o))continue;const s=a3(o.min,o.max,e);i.push({min:s.min,max:s.max,sourceId:this._sourceIds[o.priority],footprint:o.footprint,footprintTileId:o.tileId})}return i}setSources(e){this._setSources(e.map(r=>({getSourceId:()=>r.cache.id,getFootprints:()=>{const i=[];for(const o of r.cache.getVisibleCoordinates()){const s=r.cache.getTile(o).buckets[r.layer];if(s)for(const n of s.getNodesInfo()){const a=n.node;a.footprint&&i.push({footprint:a.footprint,id:o.toUnwrapped()})}}return i}})))}_addSource(e){const r=e.getFootprints();if(r.length!==0){for(const i of r){if(!i.footprint)continue;const o=C0(i.footprint.min,i.footprint.max,i.id);this._activeRegions.push({min:o.min,max:o.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:i.id,footprint:i.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort((r,i)=>r.priority-i.priority||kc(r.min,i.min)||kc(r.max,i.max));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let r=0,i=0;for(;!e&&r!==this._activeRegions.length;){const o=this._activeRegions[r],s=this._prevRegions[i];e=o.priority!==s.priority||!A0(o,s),++r,++i}}if(e){++this._updateTime;const r=i=>{const o=this._activeRegions;if(i>=o.length)return i;const s=o[i].priority;for(;i<o.length&&o[i].priority===s;)++i;return i};if(this._sourceIds.length>1){let i=0,o=r(i);for(;i!==o;){let s=i;const n=i;for(;s!==o;){const a=this._activeRegions[s];a.hiddenByOverlap=!1;for(let l=0;l<n;l++){const c=this._activeRegions[l];if(!c.hiddenByOverlap&&I0(a,c)&&(a.hiddenByOverlap=D0(a.footprint,a.tileId,c.footprint,c.tileId),a.hiddenByOverlap))break}++s}i=o,o=r(i)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let r=e.length-1;r>=0;r--)this._addSource(e[r]);this._computeReplacement()}}function kc(t,e){return t.x-e.x||t.y-e.y}function A0(t,e){return kc(t.min,e.min)===0&&kc(t.max,e.max)===0}function I0(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 C0(t,e,r){const i=1/W,o=1/(1<<r.canonical.z),s=(e.x*i+r.canonical.x)*o+r.wrap,n=(e.y*i+r.canonical.y)*o;return{min:new N((t.x*i+r.canonical.x)*o+r.wrap,(t.y*i+r.canonical.y)*o),max:new N(s,n)}}function a3(t,e,r){const i=1<<r.canonical.z,o=((e.x-r.wrap)*i-r.canonical.x)*W,s=(e.y*i-r.canonical.y)*W;return{min:new N(((t.x-r.wrap)*i-r.canonical.x)*W,(t.y*i-r.canonical.y)*W),max:new N(o,s)}}function z0(t,e,r,i,o,s,n){const a=t.indices,l=t.vertices,c=[];for(let u=i;u<i+o;u+=3){const h=e[r[u+0]+s],d=e[r[u+1]+s],p=e[r[u+2]+s],f=Math.min(h.x,d.x,p.x),m=Math.max(h.x,d.x,p.x),_=Math.min(h.y,d.y,p.y),g=Math.max(h.y,d.y,p.y);c.length=0,t.grid.query(new N(f,_),new N(m,g),c);for(let y=0;y<c.length;y++){const v=c[y];if(Sd(l[a[3*v+0]],l[a[3*v+1]],l[a[3*v+2]],h,d,p,n))return!0}}return!1}function D0(t,e,r,i){if(!t||!r)return!1;let o=t.vertices;if(!e.canonical.equals(i.canonical)||e.wrap!==i.wrap){if(r.vertices.length<t.vertices.length)return D0(r,i,t,e);const s=e.canonical,n=i.canonical,a=Math.pow(2,n.z-s.z);o=t.vertices.map(l=>new N(l.x*s.x*W*a-n.x*W,l.y*s.y*W*a-n.y*W))}return z0(r,o,t.indices,0,t.indices.length,0,0)}const l3=tc.types,c3=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],u3=["fill-extrusion-flood-light-ground-radius"],h3=Math.pow(2,13),d3=Math.pow(2,15)-1,k0=new N(0,1),Yi=2147483648;function za(t,e,r,i,o,s,n,a){t.emplaceBack((e<<1)+n,(r<<1)+s,(Math.floor(i*h3)<<1)+o,Math.round(a))}function Pc(t,e,r,i,o,s){t.emplaceBack(e.x,e.y,(r.x<<1)+i,(r.y<<1)+o,s)}function Da(t,e,r){t.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class P0{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class R0{constructor(){this.centroidXY=new N(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 N(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new N(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new N(this.max.x-this.min.x,this.max.y-this.min.y)}}class L0{constructor(){this.acc=new N(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,r){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=r.x,e.min.y=e.max.y=r.y)}appendEdge(e,r,i){this.accCount++,this.acc._add(r);let o=!!this.borders;r.x<e.min.x?(e.min.x=r.x,o=!0):r.x>e.max.x&&(e.max.x=r.x,o=!0),r.y<e.min.y?(e.min.y=r.y,o=!0):r.y>e.max.y&&(e.max.y=r.y,o=!0),((r.x===0||r.x===W)&&r.x===i.x)!=((r.y===0||r.y===W)&&r.y===i.y)&&this.processBorderOverlap(r,i),o&&this.checkBorderIntersection(r,i)}checkBorderIntersection(e,r){r.x<0!=e.x<0&&this.addBorderIntersection(0,Fe(r.y,e.y,(0-r.x)/(e.x-r.x))),r.x>W!=e.x>W&&this.addBorderIntersection(1,Fe(r.y,e.y,(W-r.x)/(e.x-r.x))),r.y<0!=e.y<0&&this.addBorderIntersection(2,Fe(r.x,e.x,(0-r.y)/(e.y-r.y))),r.y>W!=e.y>W&&this.addBorderIntersection(3,Fe(r.x,e.x,(W-r.y)/(e.y-r.y)))}addBorderIntersection(e,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];r<i[0]&&(i[0]=r),r>i[1]&&(i[1]=r)}processBorderOverlap(e,r){if(e.x===r.x){if(e.y===r.y)return;const i=e.x===0?0:1;this.addBorderIntersection(i,r.y),this.addBorderIntersection(i,e.y)}else{const i=e.y===0?2:3;this.addBorderIntersection(i,r.x),this.addBorderIntersection(i,e.x)}}centroid(){return this.accCount===0?new N(0,0):new N(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,r)=>e+ +(r[0]!==Number.MAX_VALUE),0):0}}function B0(t,e){const r=t.add(e)._unit(),i=Se(t.x*r.x+t.y*r.y,-1,1);var o,s,n;return o=Math.acos(i),Math.min(4,Math.max(-4,Math.tan(o)))/4*d3*((s=t).x*(n=e).y-s.y*n.x<0?-1:1)}const p3=[t=>t.x<0,t=>t.x>W,t=>t.y<0,t=>t.y>W];function f3(t,e,r,i){const o=[4];if(i===0)return o;r._mult(i);const s=t.sub(r),n=e.sub(r),a=[t,e,s,n];for(let l=0;l<4;l++)for(const c of a)if(p3[l](c)){o.push(l);break}return o}class O0{constructor(e){this.vertexArray=new Ch,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom,r=>u3.includes(r)),this._segments=new Et,this.hiddenByLandmarkVertexArray=new jh,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Et}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,r,i,o=!1){const s=e.length;if(s>2){let n=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*s,this.vertexArray.length,2*this._segmentToGroundQuads[n].length);let l;n!==this._segments.get().length-1&&(n++,this._segmentToGroundQuads[n]=[],this._segmentToRegionTriCounts[n]=[0,0,0,0,0]);{const c=e[0],u=e[1];l=B0(c.sub(e[s-1])._perp()._unit(),u.sub(c)._perp()._unit())}for(let c=0;c<s;c++){const u=c===s-1?0:c+1,h=e[c],d=e[u],p=e[u===s-1?0:u+1],f=d.sub(h)._perp()._unit(),m=B0(f,p.sub(d)._perp()._unit()),_=l,g=m;if(ap(h,d,r)||o&&U0(h,r)&&U0(d,r)){l=m;continue}const y=a.vertexLength;Pc(this.vertexArray,h,d,1,1,_),Pc(this.vertexArray,h,d,1,0,_),Pc(this.vertexArray,h,d,0,1,g),Pc(this.vertexArray,h,d,0,0,g),a.vertexLength+=4;const v=f3(h,d,f,i);for(const b of v)this._segmentToGroundQuads[n].push({id:y,region:b}),this._segmentToRegionTriCounts[n][b]+=2,a.primitiveLength+=2;l=m}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),r=e.length;for(let i=0;i<r;i++)this._segmentToGroundQuads[i].sort((o,s)=>o.region-s.region);for(let i=0;i<r;i++){const o=this._segmentToGroundQuads[i],s=e[i],n=this._segmentToRegionTriCounts[i];n.reduce((l,c)=>l+c,0);let a=0;for(let l=0;l<=4;l++){const c=n[l];if(c!==0){let u=this.regionSegments[l];u||(u=this.regionSegments[l]=new Et);const h={vertexOffset:s.vertexOffset,primitiveOffset:s.primitiveOffset+a,vertexLength:s.vertexLength,primitiveLength:c};u.get().push(h)}a+=c}for(let l=0;l<o.length;l++){const c=o[l].id;this.indexArray.emplaceBack(c,c+1,c+3),this.indexArray.emplaceBack(c,c+3,c+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,r,i,o,s,n){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,r,i,o,s,n)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Fw.members),this.indexBuffer=e.createIndexBuffer(this.indexArray))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,r,i,o,s,n){this.hasData()&&this.programConfigurations.updatePaintArrays(e,r,i,o,s,n)}updateHiddenByLandmark(e){if(!this.hasData())return;const r=e.groundVertexCount+e.groundVertexArrayOffset;if(e.groundVertexCount===0)return;const i=e.flags&Yi?1:0;for(let o=e.groundVertexArrayOffset;o<r;++o)this.hiddenByLandmarkVertexArray.emplace(o,i);this._needsHiddenByLandmarkUpdate=!0}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Uw.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 r=this.regionSegments[e];r&&r.destroy()}}}}class ka{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.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 nr,this.footprintVertices=new Wr,this.footprintSegments=[],this.layoutVertexArray=new _s,this.centroidVertexArray=new Hm,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom,r=>c3.includes(r)),this.segments=new Et,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.groundEffect=new O0(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,r,i,o){this.features=[],this.hasPattern=Pd("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ha(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:s,id:n,index:a,sourceLayerIndex:l}of e){const c=this.layers[0]._featureFilter.needGeometry,u=Uo(s,c);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),u,i))continue;const h={id:n,sourceLayerIndex:l,index:a,geometry:c?u.geometry:$i(s,i,o),properties:s.properties,type:s.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Rd("fill-extrusion",this.layers,h,this.zoom,r)):this.addFeature(h,h.geometry,a,i,{},r.availableImages,o,r.brightness),r.featureIndex.insert(s,h.geometry,a,l,this.index,d)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,r,i,o,s,n){for(const a of this.features){const{geometry:l}=a;this.addFeature(a,l,a.index,r,i,o,s,n)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,r,i,o,s){const n=Object.keys(e).length!==0;if(n&&!this.stateDependentLayers.length)return;const a=n?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,r,a,i,o,s),this.groundEffect.update(e,r,a,i,o,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jw),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Vw.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,Nw.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,r,i,o,s,n,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new N(0,0),new N(W,W)],h=a.projection,d=h.name==="globe",p=l3[e.type]==="Polygon",f=new L0;f.centroidDataIndex=this.centroidData.length;const m=new R0,_=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},o)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},o);m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Cl);const y=kd(r,500);for(let E=y.length-1;E>=0;E--){const M=y[E];(M.length===0||(v=M[0]).every(S=>S.x<=0)||v.every(S=>S.x>=W)||v.every(S=>S.y<=0)||v.every(S=>S.y>=W))&&y.splice(E,1)}var v;let b;if(d)b=q0(y,u,o);else{b=[];for(const E of y)b.push({polygon:E,bounds:u})}const x=p?this.edgeRadius:0,w=x>0&&this.zoom<17,T=(E,M)=>{if(E.length===0)return!1;const S=E[E.length-1];return M.x===S.x&&M.y===S.y};for(const{polygon:E,bounds:M}of b){let S=0,I=0;for(const L of E)p&&!L[0].equals(L[L.length-1])&&L.push(L[0]),I+=p?L.length-1:L.length;const C=this.segments.prepareSegment((p?5:4)*I,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const k={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},A=new P0;if(A.vertexOffset=this.footprintVertices.length,A.indexOffset=3*this.footprintIndices.length,A.ringIndices=[],p){const L=[],O=[];S=C.vertexLength;for(let R=0;R<E.length;R++){const B=E[R];B.length&&R!==0&&O.push(L.length/2);const G=[];let Z,q;Z=B[1].sub(B[0])._perp()._unit(),A.ringIndices.push(B.length-1);for(let X=1;X<B.length;X++){const Y=B[X],K=B[X===B.length-1?1:X+1],H=Y.clone();if(x){q=K.sub(Y)._perp()._unit();const ee=Z.add(q)._unit(),de=x*Math.min(4,1/(Z.x*ee.x+Z.y*ee.y));H.x+=de*ee.x,H.y+=de*ee.y,H.x=Math.round(H.x),H.y=Math.round(H.y),Z=q}!_||x!==0&&!w||T(G,H)||G.push(H),za(this.layoutVertexArray,H.x,H.y,0,0,1,1,0),C.vertexLength++,this.footprintVertices.emplaceBack(Y.x,Y.y),L.push(Y.x,Y.y),d&&Da(this.layoutVertexExtArray,h.projectTilePoint(H.x,H.y,o),h.upVector(o,H.x,H.y))}_&&(x===0||w)&&(G.length!==0&&T(G,G[0])&&G.pop(),this.groundEffect.addData(G,M,c))}const U=Kl(L,O);for(let R=0;R<U.length;R+=3)this.footprintIndices.emplaceBack(A.vertexOffset+U[R+0],A.vertexOffset+U[R+1],A.vertexOffset+U[R+2]),this.indexArray.emplaceBack(S+U[R],S+U[R+2],S+U[R+1]),C.primitiveLength++;A.indexCount+=U.length,A.vertexCount+=this.footprintVertices.length-A.vertexOffset}for(let L=0;L<E.length;L++){const O=E[L];f.startRing(m,O[0]);let U=O.length>4&&V0(O[O.length-2],O[0],O[1]),R=x?m3(O[O.length-2],O[0],O[1],x):0;const B=[];let G,Z,q;Z=O[1].sub(O[0])._perp()._unit();let X=!0;for(let Y=1,K=0;Y<O.length;Y++){let H=O[Y-1],ee=O[Y];const de=O[Y===O.length-1?1:Y+1];if(f.appendEdge(m,ee,H),ap(ee,H,M)){x&&(Z=de.sub(ee)._perp()._unit(),X=!X);continue}const pe=ee.sub(H)._perp(),ge=pe.x/(Math.abs(pe.x)+Math.abs(pe.y)),xe=pe.y>0?1:0,Oe=H.dist(ee);if(K+Oe>32768&&(K=0),x){q=de.sub(ee)._perp()._unit();let Be=N0(H,ee,de,F0(Z,q),x);isNaN(Be)&&(Be=0);const Re=ee.sub(H)._unit();H=H.add(Re.mult(R))._round(),ee=ee.add(Re.mult(-Be))._round(),R=Be,Z=q,_&&this.zoom>=17&&(T(B,H)||B.push(H),T(B,ee)||B.push(ee))}const Ie=C.vertexLength,ht=O.length>4&&V0(H,ee,de);let st=j0(K,U,X);if(za(this.layoutVertexArray,H.x,H.y,ge,xe,0,0,st),za(this.layoutVertexArray,H.x,H.y,ge,xe,0,1,st),K+=Oe,st=j0(K,ht,!X),U=ht,za(this.layoutVertexArray,ee.x,ee.y,ge,xe,0,0,st),za(this.layoutVertexArray,ee.x,ee.y,ge,xe,0,1,st),C.vertexLength+=4,this.indexArray.emplaceBack(Ie+0,Ie+1,Ie+2),this.indexArray.emplaceBack(Ie+1,Ie+3,Ie+2),C.primitiveLength+=2,x){const Be=S+(Y===1?O.length-2:Y-2),Re=Y===1?S:Be+1;if(this.indexArray.emplaceBack(Ie+1,Be,Ie+3),this.indexArray.emplaceBack(Be,Re,Ie+3),C.primitiveLength+=2,G===void 0&&(G=Ie),!ap(de,O[Y],M)){const De=Y===O.length-1?G:C.vertexLength;this.indexArray.emplaceBack(Ie+2,Ie+3,De),this.indexArray.emplaceBack(Ie+3,De+1,De),this.indexArray.emplaceBack(Ie+3,Re,De+1),C.primitiveLength+=3}X=!X}if(d){const Be=this.layoutVertexExtArray,Re=h.projectTilePoint(H.x,H.y,o),De=h.projectTilePoint(ee.x,ee.y,o),at=h.upVector(o,H.x,H.y),ut=h.upVector(o,ee.x,ee.y);Da(Be,Re,at),Da(Be,Re,at),Da(Be,De,ut),Da(Be,De,ut)}}p&&(S+=O.length-1),_&&x&&this.zoom>=17&&(B.length!==0&&T(B,B[0])&&B.pop(),this.groundEffect.addData(B,M,c,x>0))}this.footprintSegments.push(A),k.triangleCount=this.indexArray.length-k.triangleArrayOffset,this.polygonSegments.push(k),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,m.vertexCount!==0){if(m.centroidXY=f.borders?k0:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const E=this.featuresOnBorder.length-1;for(let M=0;M<f.borders.length;M++)f.borders[M][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[M].push(E)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,l),this.groundEffect.addPaintPropertiesData(e,i,s,n,o,l),this.maxHeight=Math.max(this.maxHeight,g)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((r,i)=>this.featuresOnBorder[r].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let a=0;a<this.centroidData.length;a++){const l=this.centroidData[a],c=+(l.min.y+l.max.y>W),u=2*c+(+(l.min.x+l.max.x>W)^c);for(let h=0;h<l.polygonSegLen;h++){const d=l.polygonSegIdx+h;e.push({centroidIdx:a,subtile:u,polygonSegmentIdx:d,triangleSegmentIdx:this.polygonSegments[d].triangleSegIdx})}}const r=new nr;e.sort((a,l)=>a.triangleSegmentIdx===l.triangleSegmentIdx?a.subtile-l.subtile:a.triangleSegmentIdx-l.triangleSegmentIdx);let i=0,o=0,s=0;for(const a of e){if(a.triangleSegmentIdx!==i)break;s++}const n=e.length;for(;o!==e.length;){i=e[o].triangleSegmentIdx;let a=0,l=o,c=o;for(let u=l;u<s&&e[u].subtile===a;u++)c++;for(;l!==s;){const u=e[l];a=u.subtile;const h=this.centroidData[u.centroidIdx].min.clone(),d=this.centroidData[u.centroidIdx].max.clone(),p={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:r.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let f=l;f<c;f++){const m=e[f],_=this.polygonSegments[m.polygonSegmentIdx],g=this.centroidData[m.centroidIdx].min,y=this.centroidData[m.centroidIdx].max,v=this.indexArray.uint16;for(let b=_.triangleArrayOffset;b<_.triangleArrayOffset+_.triangleCount;b++)r.emplaceBack(v[3*b],v[3*b+1],v[3*b+2]);p.primitiveLength+=_.triangleCount,h.x=Math.min(h.x,g.x),h.y=Math.min(h.y,g.y),d.x=Math.max(d.x,y.x),d.y=Math.max(d.y,y.y)}p.primitiveLength>0&&this.triangleSubSegments.push({segment:p,min:h,max:d}),l=c;for(let f=l;f<s&&e[f].subtile===e[l].subtile;f++)c++}o=s;for(let u=o;u<n&&e[u].triangleSegmentIdx===e[o].triangleSegmentIdx;u++)s++}r._trim(),this.indexArray=r}getVisibleSegments(e,r,i){let o=0,s=0;const n=1<<e.canonical.z;if(r){const m=r.getMinMaxForTile(e);m&&(o=m.min,s=m.max)}s+=this.maxHeight;const a=e.toUnwrapped();let l;const c=[a.canonical.x/n+a.wrap,a.canonical.y/n],u=[(a.canonical.x+1)/n+a.wrap,(a.canonical.y+1)/n],h=new Et,d=(m,_,g)=>[m[0]*(1-g[0])+_[0]*g[0],m[1]*(1-g[1])+_[1]*g[1]],p=[],f=[];for(const m of this.triangleSubSegments){p[0]=m.min.x/W,p[1]=m.min.y/W,f[0]=m.max.x/W,f[1]=m.max.y/W;const _=d(c,u,p),g=d(c,u,f);if(new Pt([_[0],_[1],o],[g[0],g[1],s]).intersectsPrecise(i)===0){l&&(h.segments.push(l),l=void 0);continue}const y=m.segment;l&&l.vertexOffset!==y.vertexOffset&&(h.segments.push(l),l=void 0),l?(l.vertexLength+=y.vertexLength,l.primitiveLength+=y.primitiveLength):l={vertexOffset:y.vertexOffset,primitiveLength:y.primitiveLength,vertexLength:y.vertexLength,primitiveOffset:y.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&h.segments.push(l),h}encodeCentroid(e,r){const i=e.centroid(),o=r.span(),s=Math.min(7,Math.round(o.x*this.tileToMeter/10)),n=Math.min(7,Math.round(o.y*this.tileToMeter/10));return new N(Se(i.x,1,W-1)<<3|s,Se(i.y,1,W-1)<<3|n)}showCentroid(e){const r=this.centroidData[e.centroidDataIndex];r.flags&=Yi,r.centroidXY.x=0,r.centroidXY.y=0,this.writeCentroidToBuffer(r)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const r=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,o=e.flags&Yi?k0:e.centroidXY,s=this.centroidVertexArray.geta_centroid_pos0(r);if(this.centroidVertexArray.geta_centroid_pos1(r)!==o.y||s!==o.x){for(let n=r;n<i;++n)this.centroidVertexArray.emplace(n,o.x,o.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,r){if(r.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=r.updateTime;const i=r.getReplacementRegionsForTile(e.toUnwrapped());if(function(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a].sourceId!==n[a].sourceId||!A0(s[a],n[a]))return!1;return!0}(this.activeReplacements,i))return;if(this.activeReplacements=i,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(const s of this.centroidData)s.flags&=2147483647;const o=[];for(const s of this.activeReplacements){const n=Math.pow(2,s.footprintTileId.canonical.z-e.canonical.z);for(const a of this.centroidData)if(!(a.flags&Yi||s.min.x>a.max.x||a.min.x>s.max.x||s.min.y>a.max.y||a.min.y>s.max.y))for(let l=0;l<a.footprintSegLen;l++){const c=this.footprintSegments[a.footprintSegIdx+l];if(o.length=0,_3(this.footprintVertices,c.vertexOffset,c.vertexCount,s.footprintTileId.canonical,e.canonical,o),z0(s.footprint,o,this.footprintIndices.uint16,c.indexOffset,c.indexCount,-c.vertexOffset,-n)){a.flags|=Yi;break}}}for(const s of this.centroidData)this.writeCentroidToBuffer(s);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,r,i){let o=!1;for(let s=0;s<i.footprintSegLen;s++){const n=this.footprintSegments[i.footprintSegIdx+s];let a=0;for(const l of n.ringIndices){for(let c=a,u=l+a-1;c<l+a;u=c++){const h=this.footprintVertices.int16[2*(c+n.vertexOffset)+0],d=this.footprintVertices.int16[2*(c+n.vertexOffset)+1],p=this.footprintVertices.int16[2*(u+n.vertexOffset)+1];d>r!=p>r&&e<(this.footprintVertices.int16[2*(u+n.vertexOffset)+0]-h)*(r-d)/(p-d)+h&&(o=!o)}a=l}}return o}getHeightAtTileCoord(e,r){let i=Number.NEGATIVE_INFINITY,o=!0;const s=4*(e+W)*W+(r+W);if(this.partLookup.hasOwnProperty(s)){const n=this.partLookup[s];return n?{height:n.height,hidden:!!(n.flags&Yi)}:void 0}for(const n of this.centroidData)e>n.max.x||n.min.x>e||r>n.max.y||n.min.y>r||this.footprintContainsPoint(e,r,n)&&n&&n.height>i&&(i=n.height,this.partLookup[s]=n,o=!!(n.flags&Yi));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:o};this.partLookup[s]=void 0}}function F0(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function m3(t,e,r,i){const o=e.sub(t)._perp()._unit(),s=r.sub(e)._perp()._unit();return N0(t,e,r,F0(o,s),i)}function N0(t,e,r,i,o){const s=Math.sqrt(1-i*i);return Math.min(t.dist(e)/3,e.dist(r)/3,o*s/i)}function ap(t,e,r){return t.x<r[0].x&&e.x<r[0].x||t.x>r[1].x&&e.x>r[1].x||t.y<r[0].y&&e.y<r[0].y||t.y>r[1].y&&e.y>r[1].y}function U0(t,e){return t.x<e[0].x||t.x>e[1].x||t.y<e[0].y||t.y>e[1].y}function V0(t,e,r){if(t.x<0||t.x>=W||e.x<0||e.x>=W||r.x<0||r.x>=W)return!1;const i=r.sub(e),o=i.perp(),s=t.sub(e);return(i.x*s.x+i.y*s.y)/Math.sqrt((i.x*i.x+i.y*i.y)*(s.x*s.x+s.y*s.y))>-.866&&o.x*s.x+o.y*s.y<0}function j0(t,e,r){const i=e?2|t:-3&t;return r?1|i:-2&i}function G0(){const t=Math.PI/32,e=Math.tan(t),r=un;return r*Math.sqrt(1+2*e*e)-r}function q0(t,e,r){const i=1<<r.z,o=Jr(r.x/i),s=Jr((r.x+1)/i),n=ar(r.y/i),a=ar((r.y+1)/i);return function(l,c,u,h,d=0,p){const f=[];if(!l.length||!u||!h)return f;const m=(w,T)=>{for(const E of w)f.push({polygon:E,bounds:T})},_=Math.ceil(Math.log2(u)),g=Math.ceil(Math.log2(h)),y=_-g,v=[];for(let w=0;w<Math.abs(y);w++)v.push(y>0?0:1);for(let w=0;w<Math.min(_,g);w++)v.push(0),v.push(1);let b=l;if(b=rc(b,c[0].y-d,c[1].y+d,1),b=rc(b,c[0].x-d,c[1].x+d,0),!b.length)return f;const x=[];for(v.length?x.push({polygons:b,bounds:c,depth:0}):m(b,c);x.length;){const w=x.pop(),T=w.depth,E=v[T],M=w.bounds[0],S=w.bounds[1],I=E===0?M.x:M.y,C=E===0?S.x:S.y,k=p?p(E,I,C):.5*(I+C),A=rc(w.polygons,I-d,k+d,E),L=rc(w.polygons,k-d,C+d,E);if(A.length){const O=[M,new N(E===0?k:S.x,E===1?k:S.y)];v.length>T+1?x.push({polygons:A,bounds:O,depth:T+1}):m(A,O)}if(L.length){const O=[new N(E===0?k:M.x,E===1?k:M.y),S];v.length>T+1?x.push({polygons:L,bounds:O,depth:T+1}):m(L,O)}}return f}(t,e,Math.ceil((s-o)/11.25),Math.ceil((n-a)/11.25),1,(l,c,u)=>{if(l===0)return .5*(c+u);{const h=ar((r.y+c/W)/i);return(dr(.5*(ar((r.y+u/W)/i)+h))*i-r.y)*W}})}function _3(t,e,r,i,o,s){const n=Math.pow(2,i.z-o.z);for(let a=0;a<r;a++){let l=t.int16[2*(a+e)+0],c=t.int16[2*(a+e)+1];l=(l+o.x*W)*n-i.x*W,c=(c+o.y*W)*n-i.y*W,s.push(new N(l,c))}}Ee(ka,"FillExtrusionBucket",{omit:["layers","features"]}),Ee(R0,"PartData"),Ee(P0,"FootprintSegment"),Ee(L0,"BorderCentroidData"),Ee(O0,"GroundEffect");const g3=new Xt({visibility:new se(j["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new se(j["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var y3={paint:new Xt({"fill-extrusion-opacity":new se(j["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ke(j["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new se(j["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new se(j["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ke(j["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ke(j["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ke(j["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new se(j["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ke(j["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ke(j["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new se(j["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new se(j["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new se(j["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new se(j["paint_fill-extrusion"]["fill-extrusion-emissive-strength"])}),layout:g3};class Mn extends N{constructor(e,r,i){super(e,r),this.z=i}}function Pa(t,e){return t.x*e.x+t.y*e.y}function Z0(t,e){if(t.length===1){let r=0;const i=e[r++];let o;for(;!o||i.equals(o);)if(o=e[r++],!o)return 1/0;for(;r<e.length;r++){const s=e[r],n=t[0],a=o.sub(i),l=s.sub(i),c=n.sub(i),u=Pa(a,a),h=Pa(a,l),d=Pa(l,l),p=Pa(c,a),f=Pa(c,l),m=u*d-h*h,_=(d*p-h*f)/m,g=(u*f-h*p)/m,y=i.z*(1-_-g)+o.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let r=1/0;for(const i of e)r=Math.min(r,i.z);return r}}function $0(t,e,r,i,o,s,n,a){const l=n*o.getElevationAt(t,e,!0,!0),c=s[0]!==0,u=c?s[1]===0?n*(s[0]/7-450):n*function(h,d,p){const f=Math.floor(d[0]/8),m=Math.floor(d[1]/8),_=10*(d[0]-8*f),g=10*(d[1]-8*m),y=h.getElevationAt(f,m,!0,!0),v=h.getMeterToDEM(p),b=Math.floor(.5*(_*v-1)),x=Math.floor(.5*(g*v-1)),w=h.tileCoordToPixel(f,m),T=2*b+1,E=2*x+1,M=function(L,O,U,R,B){return[L.getElevationAtPixel(O,U,!0),L.getElevationAtPixel(O+B,U,!0),L.getElevationAtPixel(O,U+B,!0),L.getElevationAtPixel(O+R,U+B,!0)]}(h,w.x-b,w.y-x,T,E),S=Math.abs(M[0]-M[1]),I=Math.abs(M[2]-M[3]),C=Math.abs(M[0]-M[2])+Math.abs(M[1]-M[3]),k=Math.min(.25,.5*v*(S+I)/T),A=Math.min(.25,.5*v*C/E);return y+Math.max(k*_,A*g)}(o,s,a):l;return{base:l+(r===0)?-1:r,top:c?Math.max(u+i,l+r+2):l+i}}const x3=new Xt({"line-cap":new ke(j.layout_line["line-cap"]),"line-join":new ke(j.layout_line["line-join"]),"line-miter-limit":new se(j.layout_line["line-miter-limit"]),"line-round-limit":new se(j.layout_line["line-round-limit"]),"line-sort-key":new ke(j.layout_line["line-sort-key"]),visibility:new se(j.layout_line.visibility)});var H0={paint:new Xt({"line-opacity":new ke(j.paint_line["line-opacity"]),"line-color":new ke(j.paint_line["line-color"]),"line-translate":new se(j.paint_line["line-translate"]),"line-translate-anchor":new se(j.paint_line["line-translate-anchor"]),"line-width":new ke(j.paint_line["line-width"]),"line-gap-width":new ke(j.paint_line["line-gap-width"]),"line-offset":new ke(j.paint_line["line-offset"]),"line-blur":new ke(j.paint_line["line-blur"]),"line-dasharray":new ke(j.paint_line["line-dasharray"]),"line-pattern":new ke(j.paint_line["line-pattern"]),"line-gradient":new ta(j.paint_line["line-gradient"]),"line-trim-offset":new se(j.paint_line["line-trim-offset"]),"line-emissive-strength":new se(j.paint_line["line-emissive-strength"]),"line-border-width":new ke(j.paint_line["line-border-width"]),"line-border-color":new ke(j.paint_line["line-border-color"])}),layout:x3};const v3=(t,e,r,i,o,s,n)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:X0(t,e,r,i),u_pixels_to_tile_units:l,u_device_pixel_ratio:s,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:J0(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:W0(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:n,u_emissive_strength:r.paint.get("line-emissive-strength")}},b3=(t,e,r,i,o)=>{const s=t.transform;return{u_matrix:X0(t,e,r,i),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:o,u_image:0,u_tile_units_to_pixels:W0(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function W0(t,e){return 1/Es(t,1,e.tileZoom)}function X0(t,e,r,i){return t.translatePosMatrix(i||e.tileID.projMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Y0=t=>{const e=[];J0(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");return r[0]===0&&r[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),t.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER"),e};function J0(t){const e=t.paint.get("line-dasharray").value;return e.value||e.kind!=="constant"}const K0=new class extends ke{possiblyEvaluate(t,e){return e=new Ut(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,i){return e=Te({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,i)}}(H0.paint.properties["line-width"].specification);function Q0(t,e){return e>0?e+2*t:t}K0.useIntegerZoom=!0;const w3=new Xt({visibility:new se(j.layout_background.visibility)});var T3={paint:new Xt({"background-color":new se(j.paint_background["background-color"]),"background-pattern":new se(j.paint_background["background-pattern"]),"background-opacity":new se(j.paint_background["background-opacity"]),"background-emissive-strength":new se(j.paint_background["background-emissive-strength"])}),layout:w3};const E3=new Xt({visibility:new se(j.layout_raster.visibility)});var M3={paint:new Xt({"raster-opacity":new se(j.paint_raster["raster-opacity"]),"raster-color":new ta(j.paint_raster["raster-color"]),"raster-color-mix":new se(j.paint_raster["raster-color-mix"]),"raster-color-range":new se(j.paint_raster["raster-color-range"]),"raster-hue-rotate":new se(j.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new se(j.paint_raster["raster-brightness-min"]),"raster-brightness-max":new se(j.paint_raster["raster-brightness-max"]),"raster-saturation":new se(j.paint_raster["raster-saturation"]),"raster-contrast":new se(j.paint_raster["raster-contrast"]),"raster-resampling":new se(j.paint_raster["raster-resampling"]),"raster-fade-duration":new se(j.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new se(j.paint_raster["raster-emissive-strength"]),"raster-array-band":new se(j.paint_raster["raster-array-band"]),"raster-elevation":new se(j.paint_raster["raster-elevation"])}),layout:E3};function ex(t,e,r,i,o,s,n,a){const l=[t,r,o,e,i,s,1,1,1],c=[n,a,1],u=Fr.adjoint([],l),[h,d,p]=D.transformMat3(c,c,Fr.transpose(u,u));return Fr.multiply(l,[h,0,0,0,d,0,0,0,p],l)}class vi extends or{constructor(e,r,i,o){super(),this.id=e,this.dispatcher=i,this.coordinates=r.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(o),this.options=r,this._dirty=!1}load(e,r){if(this._loaded=r||!1,this.fire(new ae("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ye(this.map._requestManager.transformRequest(this.url,J.Image),(i,o)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new Ue(i));else if(o){const{HTMLImageElement:s}=$;this.image=o instanceof s?je.getImageData(o):o,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 Tc(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 ae("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 Tc||this.texture.destroy()}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let r=e[0][1],i=e[0][1];for(const s of e)s[1]>i&&(i=s[1]),s[1]<r&&(r=s[1]);const o=(i+r)/2;if(o>Jt?this.onNorthPole=!0:o<-Jt&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const s=e.map(lt.fromLngLat);this.tileID=function(n){let a=1/0,l=1/0,c=-1/0,u=-1/0;for(const f of n)a=Math.min(a,f.x),l=Math.min(l,f.y),c=Math.max(c,f.x),u=Math.max(u,f.y);const h=Math.max(c-a,u-l),d=Math.max(0,Math.floor(-Math.log(h)/Math.LN2)),p=Math.pow(2,d);return new _i(d,Math.floor((a+c)/2*p),Math.floor((l+u)/2*p))}(s),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ae("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const l in this.tiles){const c=this.tiles[l];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture)}if(this._boundsArray)return;const r=Ts(this.tileID,this.map.transform.projection),[i,o,s,n]=this.coordinates.map(l=>{const c=r.projection.project(l[0],l[1]);return jy(r,c)._round()});this.perspectiveTransform=function(l,c,u,h,d,p,f,m,_,g){const y=ex(0,0,l,0,0,c,l,c),v=ex(u,h,d,p,f,m,_,g);return Fr.multiply(v,Fr.adjoint(y,y),v),[v[6]/v[8]*l/W,v[7]/v[8]*c/W]}(this.width,this.height,i.x,i.y,o.x,o.y,n.x,n.y,s.x,s.y);const a=this._boundsArray=new _s;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(o.x,o.y,W,0),a.emplaceBack(n.x,n.y,0,W),a.emplaceBack(s.x,s.y,W,W),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Yd.members),this.boundsSegments=Et.simpleSegment(0,0,4,2)}prepare(){const e=Object.keys(this.tiles).length!==0;if(this.tileID&&!e)return;const r=this.map.painter.context,i=r.gl;!this._dirty||this.texture instanceof Tc||(this.texture?this.texture.update(this.image):(this.texture=new Gt(r,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(r)}loadTile(e,r){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},r(null)):(e.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class S3 extends ri{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(e){return this.implementation.renderToTile!==void 0}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 A3=new Xt({visibility:new se(j.layout_sky.visibility)});var I3={paint:new Xt({"sky-type":new se(j.paint_sky["sky-type"]),"sky-atmosphere-sun":new se(j.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new se(j.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new se(j.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new se(j.paint_sky["sky-gradient-radius"]),"sky-gradient":new ta(j.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new se(j.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new se(j.paint_sky["sky-atmosphere-color"]),"sky-opacity":new se(j.paint_sky["sky-opacity"])}),layout:A3};function lp(t,e,r){const i=[0,0,1],o=Ar.identity([]);return Ar.rotateY(o,o,r?-$e(t)+Math.PI:$e(t)),Ar.rotateX(o,o,-$e(e)),D.transformQuat(i,i,o),D.normalize(i,i)}var C3={paint:new Xt({})};const z3={circle:class extends ri{constructor(t,e){super(t,pw,e)}createBucket(t){return new Td(t)}queryRadius(t){const e=t;return dn("circle-radius",this,e)+dn("circle-stroke-width",this,e)+$l(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,i,o,s,n,a){const l=jg(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return qg(t,i,s,n,a,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",l,c)}getProgramIds(){return["circle"]}getDefaultProgramParams(t,e){const r=Gg(this);return{config:new xs(this,e),defines:r,overrideFog:!1}}},heatmap:class extends ri{createBucket(t){return new $g(t)}constructor(t,e){super(t,vw,e),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Hl({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 dn("heatmap-radius",this,t)}queryIntersectsFeature(t,e,r,i,o,s,n,a){const l=this.paint.get("heatmap-radius").evaluate(e,r);return qg(t,i,s,n,a,!0,!0,new N(0,0),l)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(t,e){return t==="heatmap"?{config:new xs(this,e),overrideFog:!1}:{}}},hillshade:class extends ri{constructor(t,e){super(t,ww,e)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},fill:class extends ri{constructor(t,e){super(t,Bw,e)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(t,e){return{config:new xs(this,e),overrideFog:!1}}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Ql(t)}queryRadius(){return $l(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,i,o,s){return!t.queryGeometry.isAboveHorizon&&Og(Vg(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),i)}isTileClipped(){return!0}},"fill-extrusion":class extends ri{constructor(t,e){super(t,y3,e),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new ka(t)}queryRadius(){return $l(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,r,i,o,s,n,a,l){const c=jg(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),d=[0,0],p=a&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=t.tile.getBucket(this);if(p&&m instanceof ka){const b=m.centroidVertexArray,x=l+1;x<b.length&&(d[0]=b.geta_centroid_pos0(x),d[1]=b.geta_centroid_pos1(x))}if(d[0]===0&&d[1]===1)return!1;s.projection.name==="globe"&&(i=q0([i],[new N(0,0),new N(W,W)],t.tileID.canonical).map(b=>b.polygon).flat());const _=p?a:null,[g,y]=function(b,x,w,T,E,M,S,I,C,k,A){return b.projection.name==="globe"?function(L,O,U,R,B,G,Z,q,X,Y,K){const H=[],ee=[],de=L.projection.upVectorScale(K,L.center.lat,L.worldSize).metersToTile,pe=[0,0,0,1],ge=[0,0,0,1],xe=(Ie,ht,st,Be)=>{Ie[0]=ht,Ie[1]=st,Ie[2]=Be,Ie[3]=1},Oe=G0();U>0&&(U+=Oe),R+=Oe;for(const Ie of O){const ht=[],st=[];for(const Be of Ie){const Re=Be.x+B.x,De=Be.y+B.y,at=L.projection.projectTilePoint(Re,De,K),ut=L.projection.upVector(K,Be.x,Be.y);let Je=U,Ct=R;if(Z){const Kt=$0(Re,De,U,R,Z,q,X,Y);Je+=Kt.base,Ct+=Kt.top}U!==0?xe(pe,at.x+ut[0]*de*Je,at.y+ut[1]*de*Je,at.z+ut[2]*de*Je):xe(pe,at.x,at.y,at.z),xe(ge,at.x+ut[0]*de*Ct,at.y+ut[1]*de*Ct,at.z+ut[2]*de*Ct),D.transformMat4(pe,pe,G),D.transformMat4(ge,ge,G),ht.push(new Mn(pe[0],pe[1],pe[2])),st.push(new Mn(ge[0],ge[1],ge[2]))}H.push(ht),ee.push(st)}return[H,ee]}(b,x,w,T,E,M,S,I,C,k,A):S?function(L,O,U,R,B,G,Z,q,X){const Y=[],K=[],H=[0,0,0,1];for(const ee of L){const de=[],pe=[];for(const ge of ee){const xe=ge.x+R.x,Oe=ge.y+R.y,Ie=$0(xe,Oe,O,U,G,Z,q,X);H[0]=xe,H[1]=Oe,H[2]=Ie.base,H[3]=1,Mt.transformMat4(H,H,B),H[3]=Math.max(H[3],1e-5);const ht=new Mn(H[0]/H[3],H[1]/H[3],H[2]/H[3]);H[0]=xe,H[1]=Oe,H[2]=Ie.top,H[3]=1,Mt.transformMat4(H,H,B),H[3]=Math.max(H[3],1e-5);const st=new Mn(H[0]/H[3],H[1]/H[3],H[2]/H[3]);de.push(ht),pe.push(st)}Y.push(de),K.push(pe)}return[Y,K]}(x,w,T,E,M,S,I,C,k):function(L,O,U,R,B){const G=[],Z=[],q=B[8]*O,X=B[9]*O,Y=B[10]*O,K=B[11]*O,H=B[8]*U,ee=B[9]*U,de=B[10]*U,pe=B[11]*U;for(const ge of L){const xe=[],Oe=[];for(const Ie of ge){const ht=Ie.x+R.x,st=Ie.y+R.y,Be=B[0]*ht+B[4]*st+B[12],Re=B[1]*ht+B[5]*st+B[13],De=B[2]*ht+B[6]*st+B[14],at=B[3]*ht+B[7]*st+B[15],ut=Be+q,Je=Re+X,Ct=De+Y,Kt=Math.max(at+K,1e-5),St=Be+H,Rt=Re+ee,rr=De+de,Qt=Math.max(at+pe,1e-5);xe.push(new Mn(ut/Kt,Je/Kt,Ct/Kt)),Oe.push(new Mn(St/Qt,Rt/Qt,rr/Qt))}G.push(xe),Z.push(Oe)}return[G,Z]}(x,w,T,E,M)}(s,i,h,u,c,n,_,d,f,s.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(b,x,w){let T=1/0;Og(w,x)&&(T=Z0(w,x[0]));for(let E=0;E<x.length;E++){const M=x[E],S=b[E];for(let I=0;I<M.length-1;I++){const C=M[I],k=[C,M[I+1],S[I+1],S[I],C];Bg(w,k)&&(T=Math.min(T,Z0(w,k)))}}return T!==1/0&&T}(g,y,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},line:class extends ri{constructor(t,e){super(t,H0,e),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Wu,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"]=K0.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new wc(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e){const r=Y0(this);return{config:new xs(this,e),defines:r,overrideFog:!1}}queryRadius(t){const e=t,r=Q0(dn("line-width",this,e),dn("line-gap-width",this,e)),i=dn("line-offset",this,e);return r/2+Math.abs(i)+$l(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,i,o,s){if(t.queryGeometry.isAboveHorizon)return!1;const n=Vg(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*Q0(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(i=function(c,u){const h=[],d=new N(0,0);for(let p=0;p<c.length;p++){const f=c[p],m=[];for(let _=0;_<f.length;_++){const g=f[_],y=f[_+1],v=_===0?d:g.sub(f[_-1])._unit()._perp(),b=_===f.length-1?d:y.sub(g)._unit()._perp(),x=v._add(b)._unit();x._mult(1/(x.x*b.x+x.y*b.y)),m.push(x._mult(u)._add(g))}h.push(m)}return h}(i,l*t.pixelToTileUnitsFactor)),function(c,u,h){for(let d=0;d<u.length;d++){const p=u[d];if(c.length>=3){for(let f=0;f<p.length;f++)if(Vo(c,p[f]))return!0}if(cw(c,p,h))return!0}return!1}(n,i,a)}isTileClipped(){return!0}},symbol:_c,background:class extends ri{constructor(t,e){super(t,T3,e)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},raster:class extends ri{constructor(t,e){super(t,M3,e),this._updateColorRamp()}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}isLayerDraped(t){return!(t&&t._source instanceof vi)||!t._source.onNorthPole&&!t._source.onSouthPole&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(t){t!=="raster-color"&&t!=="raster-color-range"||this._updateColorRamp()}_updateColorRamp(){if(!this.hasColorMap())return;const t=this._transitionablePaint._values["raster-color"].value.expression,[e,r]=this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0});this.colorRamp=Hl({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:e,end:r}],resolution:256}),this.colorRampTexture=null}},sky:class extends ri{constructor(t,e){super(t,I3,e),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="sky-gradient"?this._updateColorRamp():t!=="sky-atmosphere-sun"&&t!=="sky-atmosphere-halo-color"&&t!=="sky-atmosphere-color"&&t!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Hl({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(this.paint.get("sky-type")==="atmosphere"){const i=this.paint.get("sky-atmosphere-sun"),o=!i,s=t.style.light,n=s.properties.get("position");return o&&s.properties.get("anchor")==="viewport"&&F("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),o?lp(n.azimuthal,90-n.polar,e):lp(i[0],90-i[1],e)}const r=this.paint.get("sky-gradient-center");return lp(r[0],90-r[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 t==="atmosphere"?["skyboxCapture","skybox"]:t==="gradient"?["skyboxGradient"]:null}},slot:class extends ri{constructor(t,e){super(t,C3)}},model:class extends ri{constructor(t,e){super(t,i3,e)}createBucket(t){return new w0(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(){return 0}queryIntersectsFeature(){return!1}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven()||t!=="model-color"&&t!=="model-color-mix-intensity"&&t!=="model-rotation"&&t!=="model-scale"&&t!=="model-translation"&&t!=="model-emissive-strength")}_isPropertyZoomDependent(t){const e=this._transitionablePaint._values[t];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof Ao}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}}};function Rc(t,e){return t.type==="custom"?new S3(t):new z3[t.type](t,e)}function D3(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class k3 extends or{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(e){this.images[e]={},this.loaded[e]=!1,this.updatedImages[e]={},this.patterns[e]={},this.callbackDispatchedThisFrame[e]={},this.atlasImage[e]=new ir({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,r){if(this.loaded[r]!==e&&(this.loaded[r]=e,e)){for(const{ids:i,callback:o}of this.requestors)this._notify(i,r,o);this.requestors=[]}}hasImage(e,r){return!!this.getImage(e,r)}getImage(e,r){return this.images[r][e]}addImage(e,r,i){this._validate(e,i)&&(this.images[r][e]=i)}_validate(e,r){let i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,r){if(!e)return!0;let i=0;for(const o of e){if(o[0]<i||o[1]<o[0]||r<o[1])return!1;i=o[1]}return!0}_validateContent(e,r){return!(e&&(e.length!==4||e[0]<0||r.data.width<e[0]||e[1]<0||r.data.height<e[1]||e[2]<0||r.data.width<e[2]||e[3]<0||r.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,r,i){i.version=this.images[r][e].version+1,this.images[r][e]=i,this.updatedImages[r][e]=!0}removeImage(e,r){const i=this.images[r][e];delete this.images[r][e],delete this.patterns[r][e],i.userImage&&i.userImage.onRemove&&i.userImage.onRemove()}listImages(e){return Object.keys(this.images[e])}getImages(e,r,i){let o=!0;const s=!!this.loaded[r];if(!s)for(const n of e)this.images[r][n]||(o=!1);s||o?this._notify(e,r,i):this.requestors.push({ids:e,scope:r,callback:i})}getUpdatedImages(e){return this.updatedImages[e]}_notify(e,r,i){const o={};for(const s of e){this.images[r][s]||this.fire(new ae("styleimagemissing",{id:s}));const n=this.images[r][s];n?o[s]={data:n.data.clone(),pixelRatio:n.pixelRatio,sdf:n.sdf,version:n.version,stretchX:n.stretchX,stretchY:n.stretchY,content:n.content,hasRenderCallback:!!(n.userImage&&n.userImage.render)}:F(`Image "${s}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,o)}getPixelSize(e){const{width:r,height:i}=this.atlasImage[e];return{width:r,height:i}}getPattern(e,r){const i=this.patterns[r][e],o=this.getImage(e,r);if(!o)return null;if(i&&i.position.version===o.version)return i.position;if(i)i.position.version=o.version;else{const s={w:o.data.width+2,h:o.data.height+2,x:0,y:0},n=new jd(s,o);this.patterns[r][e]={bin:s,position:n}}return this._updatePatternAtlas(r),this.patterns[r][e].position}bind(e,r){const i=e.gl;let o=this.atlasTexture[r];o?this.dirty&&(o.update(this.atlasImage[r]),this.dirty=!1):(o=new Gt(e,this.atlasImage[r],i.RGBA),this.atlasTexture[r]=o),o.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(e){const r=[];for(const n in this.patterns[e])r.push(this.patterns[e][n].bin);const{w:i,h:o}=Vd(r),s=this.atlasImage[e];s.resize({width:i||1,height:o||1});for(const n in this.patterns[e]){const{bin:a}=this.patterns[e][n],l=a.x+1,c=a.y+1,u=this.images[e][n].data,h=u.width,d=u.height;ir.copy(u,s,{x:0,y:0},{x:l,y:c},{width:h,height:d}),ir.copy(u,s,{x:0,y:d-1},{x:l,y:c-1},{width:h,height:1}),ir.copy(u,s,{x:0,y:0},{x:l,y:c+d},{width:h,height:1}),ir.copy(u,s,{x:h-1,y:0},{x:l-1,y:c},{width:1,height:d}),ir.copy(u,s,{x:0,y:0},{x:l+h,y:c},{width:1,height:d})}this.dirty=!0}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={}}dispatchRenderCallbacks(e,r){for(const i of e){if(this.callbackDispatchedThisFrame[r][i])continue;this.callbackDispatchedThisFrame[r][i]=!0;const o=this.images[r][i];D3(o)&&this.updateImage(i,r,o)}}}const P3=new Xt({anchor:new se(j.light.anchor),position:new class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return ve(t.expression.evaluate(e))}interpolate(t,e,r){return{x:Fe(t.x,e.x,r),y:Fe(t.y,e.y,r),z:Fe(t.z,e.z,r),azimuthal:Fe(t.azimuthal,e.azimuthal,r),polar:Fe(t.polar,e.polar,r)}}}(j.light.position),color:new se(j.light.color),intensity:new se(j.light.intensity)});class tx extends or{constructor(e,r="flat"){super(),this._transitionable=new Qn(P3),this.setLight(e,r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,r,i={}){this._validate(tb,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=r)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,r,i){return(!i||i.validate!==!1)&&bl(this,e.call(Qs,Te({value:r,style:{glyphs:!0,sprite:!0},styleSpec:j})))}}const R3=new Xt({source:new se(j.terrain.source),exaggeration:new se(j.terrain.exaggeration)});let L3=class extends or{constructor(t,e,r,i){super(),this.scope=r,this._transitionable=new Qn(R3,i),this._transitionable.setTransitionOrValue(t,i),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=e}get(){return this._transitionable.serialize()}set(t,e){this._transitionable.setTransitionOrValue(t,e)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new Ut(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return t!=null&&t.value!=null&&t.value.expression!=null&&t.value.expression instanceof Ao}};const rx=45,ix=65,As=.05;function Lc(t,e,r,i){const o=Fi(rx,ix,r),[s,n]=ox(t,i);let a=1-Math.min(1,Math.exp((e-s)/(n-s)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*o*t.alpha}function ox(t,e){const r=.5/Math.tan(.5*e);return[t.range[0]+r,t.range[1]+r]}function sx(t,e,r,i,o){const s=D.transformMat4([],[e,r,i],o.mercatorFogMatrix);return Lc(t,D.length(s),o.pitch,o._fov)}function nx(t,e,r,i,o,s,n){const a=[[r,i,0],[o,i,0],[o,s,0],[r,s,0]];let l=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(const u of a){const h=D.transformMat4([],u,e),d=D.length(h);l=Math.min(l,d),c=Math.max(c,d)}return[Lc(t,l,n.pitch,n._fov),Lc(t,c,n.pitch,n._fov)]}const B3=new Xt({range:new se(j.fog.range),color:new se(j.fog.color),"high-color":new se(j.fog["high-color"]),"space-color":new se(j.fog["space-color"]),"horizon-blend":new se(j.fog["horizon-blend"]),"star-intensity":new se(j.fog["star-intensity"]),"vertical-range":new se(j.fog["vertical-range"])});class O3 extends or{constructor(e,r){super(),this._transitionable=new Qn(B3),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=r}get state(){const e=this._transform,r=e.projection.name==="globe",i=yr(e.zoom),o=this.properties.get("range"),s=[.5,3];return{range:r?[Fe(s[0],o[0],i),Fe(s[1],o[1],i)]:o,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,r={}){if(this._validate(ob,e,r))return;const i=Te({},e);for(const o of Object.keys(j.fog))i[o]===void 0&&(i[o]=j.fog[o].default);this._transitionable.setTransitionOrValue(i)}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const r=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:Fi(rx,ix,e))*r.a}getOpacityAtLatLng(e,r){return this._transform.projection.supportsFog?function(i,o,s){const n=lt.fromLngLat(o),a=s.elevation?s.elevation.getAtPointOrZero(n):0;return sx(i,n.x,n.y,a,s)}(this.state,e,r):0}getOpacityForTile(e){if(!this._transform.projection.supportsFog)return[1,1];const r=this._transform.calculateFogTileMatrix(e.toUnwrapped());return nx(this.state,r,0,0,W,W,this._transform)}getOpacityForBounds(e,r,i,o,s){return this._transform.projection.supportsFog?nx(this.state,e,r,i,o,s,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?ox(this.state,e):[0,1]}isVisibleOnFrustum(e){if(!this._transform.projection.supportsFog)return!1;const r=[4,5,6,7];for(const i of r){const o=e.points[i];let s;if(o[2]>=0)s=o;else{const n=e.points[i-4];s=Rf(n,o,n[2]/(n[2]-o[2]))}if(sx(this.state,s[0],s[1],0,this._transform)>=As)return!0}return!1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,r,i){return(!i||i.validate!==!1)&&bl(this,e.call(Qs,Te({value:r,style:{glyphs:!0,sprite:!0},styleSpec:j})))}}class F3{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 N3{constructor(){this.tasks={},this.taskQueue=[],pr(["process"],this),this.invoker=new F3(this.process),this.nextId=0}add(e,r){const i=this.nextId++,o=function({type:s,isSymbolTile:n,zoom:a}){return a=a||0,s==="message"?0:s!=="maybePrepare"||n?s!=="parseTile"||n?s==="parseTile"&&n?300-a:s==="maybePrepare"&&n?400-a:500:200-a:100-a}(r);if(o===0){oe();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:r,priority:o,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){oe();try{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}finally{}}pick(){let e=null,r=1/0;for(let o=0;o<this.taskQueue.length;o++){const s=this.tasks[this.taskQueue[o]];s.priority<r&&(r=s.priority,e=o)}if(e===null)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class ax{constructor(e,r,i){this.target=e,this.parent=r,this.mapId=i,this.callbacks={},this.cancelCallbacks={},pr(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new N3}send(e,r,i,o,s=!1,n){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=n,this.callbacks[a]=i);const l=new Set;return this.target.postMessage({id:a,type:e,hasCallback:!!i,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:tn(r,l)},l),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"<cancel>",targetMapId:o,sourceMapId:this.mapId})}}}receive(e){const r=e.data,i=r.id;if(i&&(!r.targetMapId||this.mapId===r.targetMapId))if(r.type==="<cancel>"){const o=this.cancelCallbacks[i];delete this.cancelCallbacks[i],o&&o.cancel()}else if(r.mustQueue||oe()){const o=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,r),o&&o.metadata||{type:"message"})}else this.processTask(i,r)}processTask(e,r){if(r.type==="<response>"){const i=this.callbacks[e];delete this.callbacks[e],i&&(r.error?i(rn(r.error)):i(null,rn(r.data)))}else{const i=new Set,o=r.hasCallback?(n,a)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:n?tn(n):null,data:tn(a,i)},i)}:n=>{},s=rn(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,s,o);else if(this.parent.getWorkerSource){const n=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,n[0],s.source,s.scope)[n[1]](s,o)}else o(new Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Is{constructor(e,r){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ls();const i=this.workerPool.acquire(this.id);for(let o=0;o<i.length;o++){const s=new Is.Actor(i[o],r,this.id);s.name=`Worker ${o}`,this.actors.push(s)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(e,r,i){os(this.actors,(o,s)=>{o.send(e,r,s)},i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}Is.Actor=ax;class lx extends or{constructor(e,r,i,o){super(),this.scope=i,this._options=e,this.properties=new ea(r),this._transitionable=new Qn(r,new Map(o)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,r){this._options=e,this._transitionable.setTransitionOrValue(e.properties,r)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const U3=new Xt({color:new se(j.properties_light_ambient.color),intensity:new se(j.properties_light_ambient.intensity)}),V3=new Xt({direction:new class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([r,i]){const o=ve([1,r,i]);return{x:o.x,y:o.y,z:o.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return{x:Fe(t.x,e.x,r),y:Fe(t.y,e.y,r),z:Fe(t.z,e.z,r)}}}(j.properties_light_directional.direction),color:new se(j.properties_light_directional.color),intensity:new se(j.properties_light_directional.intensity),"cast-shadows":new se(j.properties_light_directional["cast-shadows"]),"shadow-intensity":new se(j.properties_light_directional["shadow-intensity"])});class cp{constructor(e,r,i,o){this.screenBounds=e,this.cameraPoint=r,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o)}static createFromScreenPoints(e,r){let i,o;if(e instanceof N||typeof e[0]=="number"){const s=N.convert(e);i=[s],o=r.isPointAboveHorizon(s)}else{const s=N.convert(e[0]),n=N.convert(e[1]);i=[s,n],o=rs(s,n).every(a=>r.isPointAboveHorizon(a))}return new cp(i,r.getCameraPoint(),o,r)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(e){return rs(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const r=this.screenBounds[0],i=this.screenBounds.length===1?this.screenBounds[0].add(new N(1,1)):this.screenBounds[1],o=rs(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<i.x?o.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?o[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(o[3]=this.cameraPoint)),function(s,n){const a=[];for(let l=0;l<s.length;l++){const c=Ni(l-1,-1,s.length-1),u=Ni(l+1,-1,s.length-1),h=s[l],d=s[u],p=s[c].sub(h).unit(),f=d.sub(h).unit(),m=f.angleWithSep(p.x,p.y),_=p.add(f).unit().mult(-1*n/Math.sin(m/2));a.push(h.add(_))}return a}(o,e)}bufferedCameraGeometryGlobe(e){const r=this.screenBounds[0],i=this.screenBounds.length===1?this.screenBounds[0].add(new N(1,1)):this.screenBounds[1],o=rs(r,i,e),s=this.cameraPoint.clone();switch(3*((s.y>r.y)+(s.y>i.y))+((s.x>r.x)+(s.x>i.x))){case 0:o[0]=s,o[4]=s.clone();break;case 1:o.splice(1,0,s);break;case 2:o[1]=s;break;case 3:o.splice(4,0,s);break;case 5:o.splice(2,0,s);break;case 6:o[3]=s;break;case 7:o.splice(3,0,s);break;case 8:o[2]=s}return o}containsTile(e,r,i,o=0){const s=e.queryPadding/r._pixelsPerMercatorPixel+1,n=i?this._bufferedCameraMercator(s,r):this._bufferedScreenMercator(s,r);let a=e.tileID.wrap+(n.unwrapped?o:0);const l=n.polygon.map(_=>jy(e.tileTransform,_,a));if(!Ug(l,0,0,W,W))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?o:0);const c=this.screenGeometryMercator.polygon.map(_=>Gy(e.tileTransform,_,a)),u=c.map(_=>new N(_[0],_[1])),h=r.getFreeCameraOptions().position||new lt(0,0,0),d=Gy(e.tileTransform,h,a),p=c.map(_=>{const g=D.sub(_,_,d);return D.normalize(g,g),new Fl(d,g)}),f=Es(e,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=uu(l),m.min.x=Se(m.min.x,0,W),m.min.y=Se(m.min.y,0,W),m.max.x=Se(m.max.x,0,W),m.max.y=Se(m.max.y,0,W),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,r){const i=cx(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o=r.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(e),r):{polygon:this.bufferedScreenGeometry(e).map(s=>r.pointCoordinate3D(s)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,r){const i=cx(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o=r.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),r):{polygon:this.bufferedCameraGeometry(e).map(s=>r.pointCoordinate3D(s)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(e,r){const i=function(s,n){const a=V.multiply([],n.pixelMatrix,n.globeMatrix),l=[0,-Pr,0,1],c=[0,Pr,0,1],u=[0,0,0,1];Mt.transformMat4(l,l,a),Mt.transformMat4(c,c,a),Mt.transformMat4(u,u,a);const h=new N(l[0]/l[3],l[1]/l[3]),d=new N(c[0]/c[3],c[1]/c[3]),p=Vo(s,h)&&l[3]<u[3],f=Vo(s,d)&&c[3]<u[3];if(!p&&!f)return null;const m=function(T,E,M){for(let S=1;S<T.length;S++){const I=Ra(E.pointCoordinate3D(T[S-1]).x),C=Ra(E.pointCoordinate3D(T[S]).x);if(M<0){if(I<C)return{idx:S,t:-I/(C-1-I)}}else if(C<I)return{idx:S,t:(1-I)/(C+1-I)}}return null}(s,n,p?-1:1);if(!m)return null;const{idx:_,t:g}=m;let y=_>1?up(s.slice(0,_),n):[],v=_<s.length?up(s.slice(_),n):[];y=y.map(T=>new N(Ra(T.x),T.y)),v=v.map(T=>new N(Ra(T.x),T.y));const b=[...y];b.length===0&&b.push(v[v.length-1]);const x=Fe(b[b.length-1].y,(v.length===0?y[0]:v[0]).y,g);let w;return w=p?[new N(0,x),new N(0,0),new N(1,0),new N(1,x)]:[new N(1,x),new N(1,1),new N(0,1),new N(0,x)],b.push(...w),v.length===0?b.push(y[0]):b.push(...v),{polygon:b.map(T=>new lt(T.x,T.y)),unwrapped:!1}}(e,r);if(i)return i;const o=function(s,n){let a=!1,l=-1/0,c=0;for(let h=0;h<s.length-1;h++)s[h].x>l&&(l=s[h].x,c=h);for(let h=0;h<s.length-1;h++){const d=(c+h)%(s.length-1),p=s[d],f=s[d+1];Math.abs(p.x-f.x)>.5&&(p.x<f.x?(p.x+=1,d===0&&(s[s.length-1].x+=1)):(f.x+=1,d+1===s.length-1&&(s[0].x+=1)),a=!0)}const u=ur(n.center.lng);return a&&u<Math.abs(u-1)&&s.forEach(h=>{h.x-=1}),{polygon:s,unwrapped:a}}(up(e,r).map(s=>new N(Ra(s.x),s.y)),r);return{polygon:o.polygon.map(s=>new lt(s.x,s.y)),unwrapped:o.unwrapped}}}function up(t,e){return Rg(t,r=>{const i=e.pointCoordinate3D(r);r.x=i.x,r.y=i.y},1/256)}function Ra(t){return t<0?1+t%1:t%1}function cx(t){return 100*t|0}function hp(t,e,r,i,o){const s=function(n,a){if(n)return o(n);if(a){t.url&&a.tiles&&t.tiles&&delete t.tiles;const l=jr(Te(a,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(c=>c.id)),l.tiles=e.canonicalizeTileset(l,t.url),o(null,l)}};return t.url?ue(e.transformRequest(e.normalizeSourceURL(t.url,null,r,i),J.Source),s):je.frame(()=>s(null,t))}class Bc{constructor(e,r,i){this.bounds=Yr.convert(this.validateBounds(e)),this.minzoom=r||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const r=Math.pow(2,e.z),i=Math.floor(ur(this.bounds.getWest())*r),o=Math.floor(dr(this.bounds.getNorth())*r),s=Math.ceil(ur(this.bounds.getEast())*r),n=Math.ceil(dr(this.bounds.getSouth())*r);return e.x>=i&&e.x<s&&e.y>=o&&e.y<n}}class ux{constructor(e,r){this.width=e,this.height=r,this.nextRow=0,this.image=new yo({width:e,height:r}),this.positions={},this.uploaded=!1}getDash(e,r){const i=this.getKey(e,r);return this.positions[i]}trim(){const e=this.width,r=this.height=$a(this.nextRow);this.image.resize({width:e,height:r})}getKey(e,r){return e.join(",")+r}getDashRanges(e,r,i){const o=[];let s=e.length%2==1?-e[e.length-1]*i:0,n=e[0]*i,a=!0;o.push({left:s,right:n,isDash:a,zeroLength:e[0]===0});let l=e[0];for(let c=1;c<e.length;c++){a=!a;const u=e[c];s=l*i,l+=u,n=l*i,o.push({left:s,right:n,isDash:a,zeroLength:u===0})}return o}addRoundDash(e,r,i){const o=r/2;for(let s=-i;s<=i;s++){const n=this.width*(this.nextRow+i+s);let a=0,l=e[a];for(let c=0;c<this.width;c++){c/l.right>1&&(l=e[++a]);const u=Math.abs(c-l.left),h=Math.abs(c-l.right),d=Math.min(u,h);let p;const f=s/i*(o+1);if(l.isDash){const m=o-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=o-Math.sqrt(d*d+f*f);this.image.data[n+c]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e,r){for(let l=e.length-1;l>=0;--l){const c=e[l],u=e[l+1];c.zeroLength?e.splice(l,1):u&&u.isDash===c.isDash&&(u.left=c.left,e.splice(l,1))}const i=e[0],o=e[e.length-1];i.isDash===o.isDash&&(i.left=o.left-this.width,o.right=i.right+this.width);const s=this.width*this.nextRow;let n=0,a=e[n];for(let l=0;l<this.width;l++){l/a.right>1&&(a=e[++n]);const c=Math.abs(l-a.left),u=Math.abs(l-a.right),h=Math.min(c,u);this.image.data[s+l]=Math.max(0,Math.min(255,(a.isDash?h:-h)+r+128))}}addDash(e,r){const i=this.getKey(e,r);if(this.positions[i])return this.positions[i];const o=r==="round",s=o?7:0,n=2*s+1;if(this.nextRow+n>this.height)return F("LineAtlas out of space"),null;e.length===0&&e.push(1);let a=0;for(let u=0;u<e.length;u++)e[u]<0&&(F("Negative value is found in line dasharray, replacing values with 0"),e[u]=0),a+=e[u];if(a!==0){const u=this.width/a,h=this.getDashRanges(e,this.width,u);o?this.addRoundDash(h,u,s):this.addRegularDash(h,r==="square"?.5*u:0)}const l=this.nextRow+s;this.nextRow+=n;const c={tl:[l,s],br:[a,0]};return this.positions[i]=c,c}}Ee(ux,"LineAtlas");const hx=1*Di;class dx{constructor(e){const r={},i=[];for(const a in e){const l=e[a],c=r[a]={};for(const u in l.glyphs){const h=l.glyphs[+u];if(!h||h.bitmap.width===0||h.bitmap.height===0)continue;const d=h.metrics.localGlyph?hx:1,p={x:0,y:0,w:h.bitmap.width+2*d,h:h.bitmap.height+2*d};i.push(p),c[u]=p}}const{w:o,h:s}=Vd(i),n=new yo({width:o||1,height:s||1});for(const a in e){const l=e[a];for(const c in l.glyphs){const u=l.glyphs[+c];if(!u||u.bitmap.width===0||u.bitmap.height===0)continue;const h=r[a][c],d=u.metrics.localGlyph?hx:1;yo.copy(u.bitmap,n,{x:0,y:0},{x:h.x+d,y:h.y+d},u.bitmap)}}this.image=n,this.positions=r}}Ee(dx,"GlyphAtlas");class j3{constructor(e){this.tileID=new mt(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=Ts(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster}parse(e,r,i,o,s){this.status="parsing",this.data=e,this.collisionBoxArray=new Gh;const n=new iy(Object.keys(e.layers).sort()),a=new Od(this.tileID,this.promoteId);a.bucketLayerIDs=[];const l={},c=new ux(256,256),u={featureIndex:a,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:c,availableImages:i,brightness:this.brightness},h=r.familiesBySource[this.source];for(const y in h){const v=e.layers[y];if(!v)continue;let b=!1,x=!1,w=!1;for(const M of h[y])M[0].type==="symbol"?b=!0:x=!0,M[0].is3D()&&M[0].type!=="model"&&(w=!0);if(this.extraShadowCaster&&!w||this.isSymbolTile===!0&&!b||this.isSymbolTile===!1&&!x)continue;v.version===1&&F(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=n.encode(y),E=[];for(let M=0;M<v.length;M++){const S=v.feature(M),I=a.getId(S,y);E.push({feature:S,id:I,index:M,sourceLayerIndex:T})}for(const M of h[y]){const S=M[0];(!this.extraShadowCaster||S.is3D()&&S.type!=="model")&&(this.isSymbolTile!==void 0&&S.type==="symbol"!==this.isSymbolTile||S.minzoom&&this.zoom<Math.floor(S.minzoom)||S.maxzoom&&this.zoom>=S.maxzoom||S.visibility!=="none"&&(dp(M,this.zoom,u.brightness,i),(l[S.id]=S.createBucket({index:a.bucketLayerIDs.length,layers:M,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,projection:this.projection.spec})).populate(E,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(M.map(I=>I.id))))}}let d,p,f,m;c.trim();const _={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=()=>{if(d)return this.status="done",s(d);if(this.extraShadowCaster)this.status="done",s(null,{buckets:ss(l).filter(y=>!y.isEmpty()),featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:u.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(p&&f&&m){const y=new dx(p),v=new Py(f,m);for(const b in l){const x=l[b];x instanceof Ea?(dp(x.layers,this.zoom,u.brightness,i),F2(x,p,y.positions,f,v.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):x.hasPattern&&(x instanceof wc||x instanceof Ql||x instanceof ka)&&(dp(x.layers,this.zoom,u.brightness,i),x.addFeatures(u,this.tileID.canonical,v.patternPositions,i,this.tileTransform,this.brightness))}this.status="done",s(null,{buckets:ss(l).filter(b=>!b.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:y.image,lineAtlas:c,imageAtlas:v,brightness:u.brightness})}};if(!this.extraShadowCaster){const y=Os(u.glyphDependencies,x=>Object.keys(x).map(Number));Object.keys(y).length?o.send("getGlyphs",{uid:this.uid,stacks:y,scope:this.scope},(x,w)=>{d||(d=x,p=w,g())},void 0,!1,_):p={};const v=Object.keys(u.iconDependencies);v.length?o.send("getImages",{icons:v,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(x,w)=>{d||(d=x,f=w,g())},void 0,!1,_):f={};const b=Object.keys(u.patternDependencies);b.length?o.send("getImages",{icons:b,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(x,w)=>{d||(d=x,m=w,g())},void 0,!1,_):m={}}g()}}function dp(t,e,r,i){const o=new Ut(e,{brightness:r});for(const s of t)s.recalculate(o,i)}class px{constructor(e){this.entries={},this.scheduler=e}request(e,r,i,o){const s=this.entries[e]=this.entries[e]||{callbacks:[]};if(s.result){const[n,a]=s.result;return this.scheduler?this.scheduler.add(()=>{o(n,a)},r):o(n,a),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=i((n,a)=>{s.result=[n,a];for(const l of s.callbacks)this.scheduler?this.scheduler.add(()=>{l(n,a)},r):l(n,a);setTimeout(()=>delete this.entries[e],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(n=>n!==o),s.callbacks.length||(s.cancel(),delete this.entries[e]))}}}function fx(t,e,r){const i=JSON.stringify(t.request);return t.data&&(this.deduped.entries[i]={result:[null,t.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},o=>{const s=fe(t.request,(n,a,l,c)=>{n?o(n):a&&o(null,{vectorTile:r?void 0:new Ld(new sc(a)),rawData:a,cacheControl:l,expires:c})});return()=>{s.cancel(),o()}},e)}class mx extends or{constructor(e,r,i,o){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Te(this,jr(r,["url","scheme","tileSize","promoteId"])),this._options=Te({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o),this._tileWorkers={},this._deduped=new px}load(e){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=hp(this._options,this.map._requestManager,r,i,(o,s)=>{this._tileJSONRequest=null,this._loaded=!0,o?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&i.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new Ue(o))):s&&(Te(this,s),s.bounds&&(this.tileBounds=new Bc(s.bounds,this.minzoom,this.maxzoom)),du(s.tiles,this.map._requestManager._customAccessToken),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),e&&e(o)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=Dr(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return Te({},this._options)}loadTile(e,r){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),o={request:this.map._requestManager.transformRequest(i,J.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:je.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(o.request.collectResourceTiming=this._collectResourceTiming,e.actor&&e.state!=="expired")e.state==="loading"?e.reloadCallback=r:e.request=e.actor.send("reloadTile",o,s.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",o,s.bind(this),void 0,!0);else{const n=fx.call({deduped:this._deduped},o,(a,l)=>{a||!l?s.call(this,a):(o.data={cacheControl:l.cacheControl,expires:l.expires,rawData:l.rawData.slice(0)},e.actor&&e.actor.send("loadTile",o,s.bind(this),void 0,!0))},!0);e.request={cancel:n}}function s(n,a){return delete e.request,e.aborted?r(null):n&&n.status!==404?r(n):(a&&a.resourceTiming&&(e.resourceTiming=a.resourceTiming),this.map._refreshExpiredTiles&&a&&e.setExpiryData(a),e.loadVectorData(a,this.map.painter),Ns(this.dispatcher),r(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class pp extends or{constructor(e,r,i,o){super(),this.id=e,this.dispatcher=i,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Te({type:"raster"},r),Te(this,jr(r,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"})),this._tileJSONRequest=hp(this._options,this.map._requestManager,null,null,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new Ue(r)):i&&(Te(this,i),i.bounds&&(this.tileBounds=new Bc(i.bounds,this.minzoom,this.maxzoom)),du(i.tiles),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=Dr(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return Te({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,r){const i=je.devicePixelRatio>=2,o=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=Ye(this.map._requestManager.transformRequest(o,J.Tile),(s,n,a,l)=>(delete e.request,e.aborted?(e.state="unloaded",r(null)):s?(e.state="errored",r(s)):n?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:a,expires:l}),e.setTexture(n,this.map.painter),e.state="loaded",Ns(this.dispatcher),void r(null)):r(null)))}abortTile(e,r){e.request&&(e.request.cancel(),delete e.request),r()}unloadTile(e,r){e.texture&&e.texture instanceof Gt?(e.destroy(!0),e.texture&&e.texture instanceof Gt&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function G3(){return su.workerClass!=null?new su.workerClass:new $.Worker(su.workerUrl)}const fp="mapboxgl_preloaded_worker_pool";class Sn{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Sn.workerCount;)this.workers.push(new G3);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&this.numActive()===0&&(this.workers.forEach(r=>{r.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[fp]}numActive(){return Object.keys(this.active).length}}let La;function Ba(){return La||(La=new Sn),La}Sn.workerCount=2;let Oc,mp,Ri,_p=null;function _x(){return oe()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:mp||Ke.DRACO_URL}const gp=5123,yp=5126,xp={5120:Int8Array,5121:Uint8Array,5122:Int16Array,[gp]:Uint16Array,5125:Uint32Array,[yp]:Float32Array},q3={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",[gp]:"DT_UINT16",5125:"DT_UINT32",[yp]:"DT_FLOAT32"},vp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function gx(t,e,r){const i=r.json.bufferViews.length,o=r.buffers.length;e.bufferView=i,r.json.bufferViews[i]={buffer:o,byteLength:t.byteLength},r.buffers[o]=t}const bp="KHR_draco_mesh_compression";function Z3(t,e){const r=t.extensions&&t.extensions[bp];if(!r)return;const i=new Ri.Decoder,o=bx(e,r.bufferView),s=new Ri.Mesh;if(!i.DecodeArrayToMesh(o,o.byteLength,s))throw new Error("Failed to decode Draco mesh");const n=e.json.accessors[t.indices],a=xp[n.componentType],l=n.count*a.BYTES_PER_ELEMENT,c=Ri._malloc(l);a===Uint16Array?i.GetTrianglesUInt16Array(s,l,c):i.GetTrianglesUInt32Array(s,l,c),gx(Ri.memory.buffer.slice(c,c+l),n,e),Ri._free(c);for(const u of Object.keys(r.attributes)){const h=i.GetAttributeByUniqueId(s,r.attributes[u]),d=e.json.accessors[t.attributes[u]],p=q3[d.componentType],f=d.count*vp[d.type]*xp[d.componentType].BYTES_PER_ELEMENT,m=Ri._malloc(f);i.GetAttributeDataArrayForAllPoints(s,h,Ri[p],f,m),gx(Ri.memory.buffer.slice(m,m+f),d,e),Ri._free(m)}i.destroy(),s.destroy(),delete t.extensions[bp]}const yx=1179937895,xx=new TextDecoder("utf8");function vx(t,e){return new URL(t,e).href}function $3(t,e,r,i){return fetch(vx(t.uri,i)).then(o=>o.arrayBuffer()).then(o=>{e.buffers[r]=o})}function bx(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function H3(t,e,r,i){if(t.uri){const o=vx(t.uri,i);return fetch(o).then(s=>s.blob()).then(s=>$.createImageBitmap(s)).then(s=>{e.images[r]=s})}if(t.bufferView!==void 0){const o=bx(e,t.bufferView),s=new $.Blob([o],{type:t.mimeType});return $.createImageBitmap(s).then(n=>{e.images[r]=n})}}function wx(t,e=0,r){const i={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===yx){const c=new Uint32Array(t,e);let u=2;const h=(c[u++]>>2)-3,d=c[u++]>>2;if(u++,i.json=JSON.parse(xx.decode(c.subarray(u,u+d))),u+=d,u<h){const p=c[u++];u++;const f=e+(u<<2);i.buffers[0]=t.slice(f,f+p)}}else i.json=JSON.parse(xx.decode(new Uint8Array(t,e)));const{buffers:o,images:s,meshes:n,extensionsUsed:a}=i.json;let l=Promise.resolve();if(o){const c=[];for(let u=0;u<o.length;u++){const h=o[u];h.uri?c.push($3(h,i,u,r)):i.buffers[u]||(i.buffers[u]=null)}l=Promise.all(c)}return l.then(()=>{const c=[],u=a&&a.includes(bp);if(u&&c.push(function(){if(!Ri)return Oc||(Oc=function(h){let d,p=null;function f(){d=new Uint8Array(p.buffer)}function m(){throw new Error("Unexpected Draco error.")}const _={a:{a:m,d:function(g,y,v){return d.copyWithin(g,y,y+v)},c:function(g){const y=d.length,v=Math.max(g>>>0,Math.ceil(1.2*y)),b=Math.ceil((v-y)/65536);try{return p.grow(b),f(),!0}catch{return!1}},b:m}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,_):h.then(g=>g.arrayBuffer()).then(g=>WebAssembly.instantiate(g,_))).then(g=>{const{Rb:y,Qb:v,P:b,T:x,X:w,Ja:T,La:E,Qa:M,Va:S,Wa:I,eb:C,jb:k,f:A,e:L,yb:O,zb:U,Ab:R,Bb:B,Db:G,Gb:Z}=g.instance.exports;p=L;const q=(()=>{let X=0,Y=0,K=0,H=0;return ee=>{K&&(y(H),y(X),Y+=K,K=X=0),X||(Y+=128,X=v(Y));const de=ee.length+7&-8;let pe=X;de>=Y&&(K=de,pe=H=v(de));for(let ge=0;ge<ee.length;ge++)d[pe+ge]=ee[ge];return pe}})();return f(),A(),{memory:L,_free:y,_malloc:v,Mesh:class{constructor(){this.ptr=b()}destroy(){x(this.ptr)}},Decoder:class{constructor(){this.ptr=T()}destroy(){k(this.ptr)}DecodeArrayToMesh(X,Y,K){const H=q(X),ee=E(this.ptr,H,Y,K.ptr);return!!w(ee)}GetAttributeByUniqueId(X,Y){return{ptr:M(this.ptr,X.ptr,Y)}}GetTrianglesUInt16Array(X,Y,K){S(this.ptr,X.ptr,Y,K)}GetTrianglesUInt32Array(X,Y,K){I(this.ptr,X.ptr,Y,K)}GetAttributeDataArrayForAllPoints(X,Y,K,H,ee){C(this.ptr,X.ptr,Y.ptr,K,H,ee)}},DT_INT8:O(),DT_UINT8:U(),DT_INT16:R(),DT_UINT16:B(),DT_UINT32:G(),DT_FLOAT32:Z()}})}(fetch(_x())),Oc.then(h=>{Ri=h,Oc=void 0}))}()),s)for(let h=0;h<s.length;h++)c.push(H3(s[h],i,h,r));return(c.length?Promise.all(c):Promise.resolve()).then(()=>{if(u&&n)for(const{primitives:h}of n)for(const d of h)Z3(d,i);return i})})}function Tx(t){return fetch(t).then(e=>e.arrayBuffer()).then(e=>wx(e,0,t))}class Ex{constructor(e,r,i){if(this.triangleCount=r.length/3,this.min=new N(0,0),this.max=new N(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0||i===0)return;const o=e.map(u=>u.x),s=e.map(u=>u.y);this.min=new N(Math.min(...o),Math.min(...s)),this.max=new N(Math.max(...o),Math.max(...s));const n=this.max.sub(this.min);n.x=Math.max(n.x,1),n.y=Math.max(n.y,1);const a=Math.max(n.x,n.y)/i;this.cellsX=Math.max(1,Math.ceil(n.x/a)),this.cellsY=Math.max(1,Math.ceil(n.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let u=0;u<this.triangleCount;u++){const h=e[r[3*u+0]].sub(this.min),d=e[r[3*u+1]].sub(this.min),p=e[r[3*u+2]].sub(this.min),f=Yo(Math.floor(Math.min(h.x,d.x,p.x)),this.xScale,this.cellsX),m=Yo(Math.floor(Math.max(h.x,d.x,p.x)),this.xScale,this.cellsX),_=Yo(Math.floor(Math.min(h.y,d.y,p.y)),this.yScale,this.cellsY),g=Yo(Math.floor(Math.max(h.y,d.y,p.y)),this.yScale,this.cellsY),y=new N(0,0),v=new N(0,0),b=new N(0,0),x=new N(0,0);for(let w=_;w<=g;++w){y.y=v.y=w*a,b.y=x.y=(w+1)*a;for(let T=f;T<=m;++T)y.x=b.x=T*a,v.x=x.x=(T+1)*a,(Sd(h,d,p,y,v,x)||Sd(h,d,p,y,x,b))&&l.push({cellIdx:w*this.cellsX+T,triIdx:u})}}if(l.length===0)return;l.sort((u,h)=>u.cellIdx-h.cellIdx||u.triIdx-h.triIdx);let c=0;for(;c<l.length;){const u=l[c].cellIdx,h={start:this.payload.length,len:0};for(;c<l.length&&l[c].cellIdx===u;)++h.len,this.payload.push(l[c++].triIdx);this.cells[u]=h}}query(e,r,i){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>r.x||e.y>this.max.y||this.min.y>r.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let l=0;l<this.lookup.length;l++)this.lookup[l]=0;const o=Yo(e.x-this.min.x,this.xScale,this.cellsX),s=Yo(r.x-this.min.x,this.xScale,this.cellsX),n=Yo(e.y-this.min.y,this.yScale,this.cellsY),a=Yo(r.y-this.min.y,this.yScale,this.cellsY);for(let l=n;l<=a;l++)for(let c=o;c<=s;c++){const u=this.cells[l*this.cellsX+c];if(u)for(let h=0;h<u.len;h++){const d=this.payload[u.start+h],p=Math.floor(d/8),f=1<<d%8;if(!(this.lookup[p]&f)&&(this.lookup[p]|=f,i.push(d),i.length===this.triangleCount))return}}}}function Yo(t,e,r){return Math.max(0,Math.min(r-1,Math.floor(t*e)))}function Cs(t,e){const r=t.json.bufferViews[e.bufferView];return new xp[e.componentType](t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*vp[e.type])}function W3(t,e,r){const i=t.indices,o=t.attributes,s={};s.indexArray=new nr;const n=e.json.accessors[i],a=n.count/3;s.indexArray.reserve(a);const l=Cs(e,n);for(let d=0;d<a;d++)s.indexArray.emplaceBack(l[3*d],l[3*d+1],l[3*d+2]);s.indexArray._trim(),s.vertexArray=new ys;const c=e.json.accessors[o.POSITION];s.vertexArray.reserve(c.count);const u=Cs(e,c);for(let d=0;d<c.count;d++)s.vertexArray.emplaceBack(u[3*d],u[3*d+1],u[3*d+2]);if(s.vertexArray._trim(),s.aabb=new Pt(c.min,c.max),s.centroid=function(d,p){const f=[0,0,0],m=d.length;if(m>0){for(let _=0;_<m;_++){const g=3*d[_];f[0]+=p[g],f[1]+=p[g+1],f[2]+=p[g+2]}f[0]/=m,f[1]/=m,f[2]/=m}return f}(l,u),o.COLOR_0!==void 0){const d=e.json.accessors[o.COLOR_0],p=vp[d.type];if(d.componentType===yp){s.colorArray=p===3?new ys:new lo,s.colorArray.reserve(d.count);const f=Cs(e,d);if(p===3)for(let m=0;m<d.count;m++)s.colorArray.emplaceBack(f[3*m],f[3*m+1],f[3*m+2]);else for(let m=0;m<d.count;m++)s.colorArray.emplaceBack(f[4*m],f[4*m+1],f[4*m+2],f[4*m+3]);s.colorArray._trim()}else if(d.componentType===gp&&p===4){s.colorArray=new lo,s.colorArray.resize(d.count);const f=Cs(e,d),m=1/65535,_=s.colorArray.float32;for(let g=0;g<4*f.length;++g)_[g]=f[g]*m}else F(`glTF color buffer parsing for accessor ${JSON.stringify(d)} is not supported`)}if(o.NORMAL!==void 0){s.normalArray=new ys;const d=e.json.accessors[o.NORMAL];s.normalArray.reserve(d.count);const p=Cs(e,d);for(let f=0;f<d.count;f++)s.normalArray.emplaceBack(p[3*f],p[3*f+1],p[3*f+2]);s.normalArray._trim()}if(o.TEXCOORD_0!==void 0&&r.length>0){s.texcoordArray=new oa;const d=e.json.accessors[o.TEXCOORD_0];s.texcoordArray.reserve(d.count);const p=Cs(e,d);for(let f=0;f<d.count;f++)s.texcoordArray.emplaceBack(p[2*f],p[2*f+1]);s.texcoordArray._trim()}const h=t.material;return s.material=function(d,p){const{emissiveFactor:f=[0,0,0],alphaMode:m="OPAQUE",alphaCutoff:_=.5,normalTexture:g,occlusionTexture:y,emissiveTexture:v,doubleSided:b}=d,{baseColorFactor:x=[1,1,1,1],metallicFactor:w=1,roughnessFactor:T=1,baseColorTexture:E,metallicRoughnessTexture:M}=d.pbrMetallicRoughness||{};return{pbrMetallicRoughness:{baseColorFactor:new Qe(...x),metallicFactor:w,roughnessFactor:T,baseColorTexture:E?p[E.index]:void 0,metallicRoughnessTexture:M?p[M.index]:void 0},doubleSided:b,emissiveFactor:f,alphaMode:m,alphaCutoff:_,normalTexture:g?p[g.index]:void 0,occlusionTexture:y?p[y.index]:void 0,emissionTexture:v?p[v.index]:void 0,defined:d.defined===void 0}}(h!==void 0?e.json.materials[h]:{defined:!1},r),o._FEATURE_RGBA4444!==void 0&&(s.featureData=new Uint32Array(Cs(e,e.json.accessors[o._FEATURE_RGBA4444]).buffer)),s}function Mx(t,e,r){const{matrix:i,rotation:o,translation:s,scale:n,mesh:a,extras:l,children:c}=t,u={};if(u.matrix=i||V.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],n||[1,1,1]),a!==void 0){u.meshes=r[a];const h=u.anchor=[0,0];for(const d of u.meshes){const{min:p,max:f}=d.aabb;h[0]+=p[0]+f[0],h[1]+=p[1]+f[1]}h[0]=Math.floor(h[0]/u.meshes.length/2),h[1]=Math.floor(h[1]/u.meshes.length/2)}if(l&&(l.id&&(u.id=l.id),l.lights&&(u.lights=function(h){if(!h.length)return[];const d=function(g){const y=atob(g),v=new Uint8Array(y.length);for(let b=0;b<y.length;b++)v[b]=y.codePointAt(b);return v}(h),p=[],f=d.length/24,m=new Uint16Array(d.buffer),_=new Float32Array(d.buffer);for(let g=0;g<f;g++){const y=m[2*g*6]/30,v=m[2*g*6+1]/30,b=m[2*g*6+10]/100,x=_[6*g+1],w=_[6*g+2],T=_[6*g+3],E=_[6*g+4],M=T-x,S=E-w,I=Math.hypot(M,S);p.push({pos:[x+.5*M,w+.5*S,v],normal:[S/I,-M/I,0],width:I,height:y,depth:b,points:[x,w,T,E]})}return p}(l.lights))),c){const h=[];for(const d of c)h.push(Mx(e.json.nodes[d],e,r));u.children=h}return u}function X3(t){if(t.vertices.length===0||t.indices.length===0)return null;const[e,r]=[t.vertices[0].clone(),t.vertices[0].clone()];for(let n=1;n<t.vertices.length;++n){const a=t.vertices[n];e.x=Math.min(e.x,a.x),e.y=Math.min(e.y,a.y),r.x=Math.max(r.x,a.x),r.y=Math.max(r.y,a.y)}const i=Math.ceil(Math.max(r.x-e.x,r.y-e.y)/256),o=Math.max(8,i),s=new Ex(t.vertices,t.indices,o);return{vertices:t.vertices,indices:t.indices,grid:s,min:e,max:r}}function Y3(t){if(!t.extras||!t.extras.ground)return null;const e=t.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;const r=e[0];if(!r||!Array.isArray(r)||r.length===0)return null;const i=[];for(const n of r){if(!Array.isArray(n)||n.length!==2)continue;const a=n[0],l=n[1];typeof a=="number"&&typeof l=="number"&&i.push(new N(a,l))}if(i.length<3)return null;i.length>1&&i[i.length-1].equals(i[0])&&i.pop();let o=0;for(let n=0;n<i.length;n++){const a=i[n],l=i[(n+1)%i.length],c=i[(n+2)%i.length];o+=(a.x-l.x)*(c.y-l.y)-(c.x-l.x)*(a.y-l.y)}o>0&&i.reverse();const s=Kl(i.flatMap(n=>[n.x,n.y]),[]);return s.length===0?null:{vertices:i,indices:s}}function J3(t){const e=[],r=[];let i=0;for(const o of t){i=e.length;const s=o.vertexArray.float32,n=o.indexArray.uint16;for(let a=0;a<o.vertexArray.length;a++)e.push(new N(s[3*a+0],s[3*a+1]));for(let a=0;a<3*o.indexArray.length;a++)r.push(n[a]+i)}if(r.length%3!=0)return null;for(let o=0;o<r.length;o+=3){const s=e[r[o+0]],n=e[r[o+1]],a=e[r[o+2]];(s.x-n.x)*(a.y-n.y)-(a.x-n.x)*(s.y-n.y)>0&&([r[o+1],r[o+2]]=[r[o+2],r[o+1]])}return{vertices:e,indices:r}}function wp(t){const e=function(l,c){const u=[],h=$.WebGL2RenderingContext;if(l.json.textures)for(const d of l.json.textures){const p={magFilter:h.LINEAR,minFilter:h.NEAREST,wrapS:h.REPEAT,wrapT:h.REPEAT};d.sampler!==void 0&&Object.assign(p,l.json.samplers[d.sampler]),u.push({image:c[d.source],sampler:p,uploaded:!1})}return u}(t,t.images),r=function(l,c){const u=[];for(const h of l.json.meshes){const d=[];for(const p of h.primitives)d.push(W3(p,l,c));u.push(d)}return u}(t,e),{scenes:i,scene:o,nodes:s}=t.json,n=i?i[o||0].nodes:s,a=[];for(const l of n)a.push(Mx(s[l],t,r));return function(l,c,u){const h={},d=new Set;for(let p=0;p<l.length;p++){const f=u[c[p]];if(!f.extras)continue;const m=f.extras["mapbox:footprint:version"],_=f.extras["mapbox:footprint:id"];(m||_)&&d.add(p),m==="1.0.0"&&_&&(h[_]=p)}for(let p=0;p<l.length;p++){if(d.has(p))continue;const f=l[p],m=u[c[p]];if(!m.extras)continue;let _=null;f.id in h&&(_=J3(l[h[f.id]].meshes)),_||(_=Y3(m)),_&&(f.footprint=X3(_))}if(d.size>0){const p=Array.from(d.values()).sort((f,m)=>f-m);for(let f=p.length-1;f>=0;f--)l.splice(p[f],1)}}(a,n,t.json.nodes),a}function K3(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,i=t.aabb.min[1]-1,o=Ms/(t.aabb.max[0]-r+2),s=Ms/(t.aabb.max[1]-i+2);for(let n=0;n<e.length;n+=3){const a=e[n+2],l=(e[n+0]-r)*o|0,c=(e[n+1]-i)*s|0;a>t.heightmap[c*Ms+l]&&(t.heightmap[c*Ms+l]=a)}}function Q3(t,e){const r={};r.indexArray=new nr,r.indexArray.reserve(4*t.length),r.vertexArray=new ys,r.vertexArray.reserve(10*t.length),r.colorArray=new lo,r.vertexArray.reserve(10*t.length);let i=0;for(const n of t){const a=Math.min(10,Math.max(4,1.3*n.height))*e,l=[-n.normal[1],n.normal[0],0],c=Math.min(.29,.1*n.width/n.depth),u=n.width-2*n.depth*e*(c+.01),h=D.scaleAndAdd([],n.pos,l,u/2),d=D.scaleAndAdd([],n.pos,l,-u/2),p=[h[0],h[1],h[2]+n.height],f=[d[0],d[1],d[2]+n.height],m=D.scaleAndAdd([],n.normal,l,c);D.scale(m,m,a);const _=D.scaleAndAdd([],n.normal,l,-c);D.scale(_,_,a),D.add(m,h,m),D.add(_,d,_),h[2]+=.1,d[2]+=.1,r.vertexArray.emplaceBack(m[0],m[1],m[2]),r.vertexArray.emplaceBack(_[0],_[1],_[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(m[0],m[1],m[2]),r.vertexArray.emplaceBack(_[0],_[1],_[2]);const g=u/a/2;r.colorArray.emplaceBack(-g-c,-1,g,.8),r.colorArray.emplaceBack(g+c,-1,g,.8),r.colorArray.emplaceBack(-g,0,g,1.3),r.colorArray.emplaceBack(g,0,g,1.3),r.colorArray.emplaceBack(g+c,-.8,g,.7),r.colorArray.emplaceBack(g+c,-.8,g,.7),r.colorArray.emplaceBack(0,0,g,1.3),r.colorArray.emplaceBack(0,0,g,1.3),r.colorArray.emplaceBack(g+c,-1.2,g,.8),r.colorArray.emplaceBack(g+c,-1.2,g,.8),r.indexArray.emplaceBack(6+i,4+i,8+i),r.indexArray.emplaceBack(7+i,9+i,5+i),r.indexArray.emplaceBack(0+i,1+i,2+i),r.indexArray.emplaceBack(1+i,3+i,2+i),i+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Qe.white,o.pbrMetallicRoughness=s,r.material=o,r.aabb=new Pt([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}Ee(Ex,"TriangleGridIndex");const Tp={vector:mx,raster:pp,"raster-dem":class extends pp{constructor(t,e,r,i){super(t,e,r,i),this.type="raster-dem",this.maxzoom=22,this._options=Te({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}loadTile(t,e){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(o,s){o&&(t.state="errored",e(o)),s&&(t.dem=s,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",e(null))}t.request=Ye(this.map._requestManager.transformRequest(r,J.Tile),function(o,s,n,a){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(o)t.state="errored",e(o);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:a});const c=$.ImageBitmap&&s instanceof $.ImageBitmap&&af(),u=1-(s.width-((l=s.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;u<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const h=c?s:je.getImageData(s,u),d={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:h,encoding:this.encoding,padding:u};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",d,i.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(t){const e=t.canonical,r=Math.pow(2,e.z),i=(e.x-1+r)%r,o=e.x===0?t.wrap-1:t.wrap,s=(e.x+1+r)%r,n=e.x+1===r?t.wrap+1:t.wrap,a={};return a[new mt(t.overscaledZ,o,e.z,i,e.y).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new mt(t.overscaledZ,o,e.z,i,e.y-1).key]={backfilled:!1},a[new mt(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<r&&(a[new mt(t.overscaledZ,o,e.z,i,e.y+1).key]={backfilled:!1},a[new mt(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y+1).key]={backfilled:!1}),a}},geojson:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(i),this._data=e.data,this._options=Te({},e),this._collectResourceTiming=e.collectResourceTiming,e.maxzoom!==void 0&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const o=W/this.tileSize;this.workerOptions=Te({source:this.id,scope:this.scope,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(e.buffer!==void 0?e.buffer:128)*o,tolerance:(e.tolerance!==void 0?e.tolerance:.375)*o,extent:W,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:e.clusterMaxZoom!==void 0?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:W,radius:(e.clusterRadius!==void 0?e.clusterRadius:50)*o,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id,scope:this.scope},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id,scope:this.scope},e),this}getClusterLeaves(t,e,r,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:t,limit:e,offset:r},i),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new ae("dataloading",{dataType:"source"})),this._loaded=!1;const t=Te({},this.workerOptions);t.scope=this.scope;const e=this._data;typeof e=="string"?(t.request=this.map._requestManager.transformRequest(je.resolveURL(e),J.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(e),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,(r,i)=>{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new Ue(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(o.resourceTiming=i.resourceTiming[this.id]),this.fire(new ae("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,e){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:je.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(r,i,(o,s)=>(delete t.request,t.destroy(),t.aborted?e(null):o?e(o):(t.loadVectorData(s,this.map.painter,r==="reloadTile"),e(null))),void 0,r==="loadTile")}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Te({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends vi{constructor(t,e,r,i){super(t,e,r,i),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,J.Source).url);(function(e,r){const i=$.document.createElement("video");i.muted=!0,i.onloadstart=function(){r(null,i)};for(let o=0;o<e.length;o++){const s=$.document.createElement("source");_e(e[o])||(i.crossOrigin="Anonymous"),s.src=e[o],i.appendChild(s)}})(this.urls,(e,r)=>{this._loaded=!0,e?this.fire(new Ue(e)):r&&(this.video=r,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(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new Ue(new be(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new Gt(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:vi,model:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="model",this.models=[],this._loaded=!1,this._options=e}load(){const t=[];for(const e in this._options.models){const r=this._options.models[e],i=Tx(this.map._requestManager.transformRequest(r.uri,J.Model).url).then(o=>{if(!o)return;const s=wp(o),n=new x0(e,r.position,r.orientation,s);n.computeBoundsAndApplyParent(),this.models.push(n)}).catch(o=>{this.fire(new Ue(new Error(`Could not load model ${e} from ${r.uri}: ${o.message}`)))});t.push(i)}return Promise.allSettled(t).then(()=>{this._loaded=!0,this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this.fire(new Ue(new Error(`Could not load models: ${e.message}`)))})}onAdd(t){this.map=t,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(t,e){}serialize(){return{type:"model"}}},"batched-model":class extends or{constructor(t,e,r,i){super(),this.type="batched-model",this.id=t,this.tileSize=512,this._options=e,this.tiles=this._options.tiles,this.maxzoom=e.maxzoom||19,this.minzoom=e.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=r,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(i)}onAdd(t){this.map=t,this.load()}load(t){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"}));const e=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=hp(this._options,this.map._requestManager,e,r,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?(e&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${e}`),r&&r.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new Ue(i))):o&&(Te(this,o),o.bounds&&(this.tileBounds=new Bc(o.bounds,this.minzoom,this.maxzoom)),du(o.tiles,this.map._requestManager._customAccessToken),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}hasTransition(){return!1}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loaded(){return this._loaded}loadTile(t,e){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,J.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&t.state!=="expired")if(t.state==="loading")t.reloadCallback=e;else{if(t.buckets){const s=Object.values(t.buckets);for(const n of s)n.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",i,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);function o(s,n){return t.aborted?e(null):s&&s.status!==404?e(s):(n&&(n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(n),t.buckets={...t.buckets,...n.buckets}),t.state="loaded",void e(null))}}serialize(){return Te({},this._options)}},canvas:class extends vi{constructor(t,e,r,i){super(t,e,r,i),e.coordinates?Array.isArray(e.coordinates)&&e.coordinates.length===4&&!e.coordinates.some(o=>!Array.isArray(o)||o.length!==2||o.some(s=>typeof s!="number"))||this.fire(new Ue(new be(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Ue(new be(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&typeof e.animate!="boolean"&&this.fire(new Ue(new be(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?typeof e.canvas=="string"||e.canvas instanceof $.HTMLCanvasElement||this.fire(new Ue(new be(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new Ue(new be(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=e.animate===void 0||e.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 Ue(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const e=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof Tc||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Gt(e,this.canvas,e.gl.RGBA,{premultiply:!0}),this._prepareData(e)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=e,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new Ue(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new Ue(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Bc(this._implementation.bounds,this.minzoom,this.maxzoom)),e.update=this._update.bind(this),e.clearTiles=this._clearTiles.bind(this),e.coveringTiles=this._coveringTiles.bind(this),Te(this,jr(e,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return jr(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:r,z:i}=t.canonical;return this._implementation.hasTile({x:e,y:r,z:i})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const{x:r,y:i,z:o}=t.tileID.canonical,s=new $.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:s.signal})).then(function(n){return delete t.request,t.aborted?(t.state="unloaded",e(null)):n===void 0?(t.state="errored",e(null)):n===null?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",e(null)):function(a){return a instanceof $.ImageData||a instanceof $.HTMLCanvasElement||a instanceof $.ImageBitmap||a instanceof $.HTMLImageElement}(n)?(this.loadTileData(t,n),t.state="loaded",void e(null)):(t.state="errored",e(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(n=>{n.code!==20&&(t.state="errored",e(n))}),t.request.cancel=()=>s.abort()}loadTileData(t,e){t.setTexture(e,this._map.painter)}unloadTile(t,e){if(t.texture&&t.texture instanceof Gt?(t.destroy(!0),t.texture&&t.texture instanceof Gt&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:r,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:r,y:i,z:o})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z}))}_clearTiles(){const t=Dr(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))}}},Ep=function(t,e,r,i){const o=new Tp[e.type](t,e,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return pr(["load","abort","unload","serialize","prepare"],o),o};function eE(t,e){const r=V.identity([]);return V.scale(r,r,[.5*t.width,.5*-t.height,1]),V.translate(r,r,[1,-1,0]),V.multiply(r,r,t.calculateProjMatrix(e.toUnwrapped())),Float32Array.from(r)}function tE(t,e,r,i,o,s,n,a=!1){const l=t.tilesIn(i,n,a);l.sort(Sx);const c=[];for(const h of l)c.push({wrappedTileID:h.tile.tileID.wrapped().key,queryResults:h.tile.queryRenderedFeatures(e,r,t._state,h,o,s,eE(t.transform,h.tile.tileID),a)});const u=function(h){const d={},p={};for(const f of h){const m=f.queryResults,_=f.wrappedTileID,g=p[_]=p[_]||{};for(const y in m){const v=m[y],b=g[y]=g[y]||{},x=d[y]=d[y]||[];for(const w of v)b[w.featureIndex]||(b[w.featureIndex]=!0,x.push(w))}}return d}(c);for(const h in u)u[h].forEach(d=>{const p=d.feature,f=p.layer;f&&f.type!=="background"&&f.type!=="sky"&&f.type!=="slot"&&(p.source=f.source,f["source-layer"]&&(p.sourceLayer=f["source-layer"]),p.state=p.id!==void 0?t.getFeatureState(f["source-layer"],p.id):{})});return u}function rE(t,e){const r=t.getRenderableIds().map(s=>t.getTileByID(s)),i=[],o={};for(let s=0;s<r.length;s++){const n=r[s],a=n.tileID.canonical.key;o[a]||(o[a]=!0,n.querySourceFeatures(i,e))}return i}function Sx(t,e){const r=t.tileID,i=e.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}class iE{constructor(e){this.style=e}processLayersChanged(){this.layers=[];for(const e in this.style._mergedLayers){const r=this.style._mergedLayers[e];if(r.type==="fill-extrusion")this.layers.push(r);else if(r.type==="model"){const i=this.style.getLayerSource(r);i&&i.type==="batched-model"&&this.layers.push(r)}}}updateZOffset(e,r){this.currentBuildingBuckets=[];for(let o=0;o<this.layers.length;++o){const s=this.layers[o],n=this.style.getLayerSourceCache(s);let a=1;s.type==="fill-extrusion"&&(a=s.paint.get("fill-extrusion-opacity")>0?s.paint.get("fill-extrusion-vertical-scale"):0);let l=n?n.getTile(r):null;if(!l&&n&&r.canonical.z>n.getSource().minzoom){let c=r.scaledTo(Math.min(n.getSource().maxzoom,r.overscaledZ-1));for(;c.overscaledZ>=n.getSource().minzoom&&(l=n.getTile(c),!l&&c.overscaledZ!==0);)c=c.scaledTo(c.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:l?l.getBucket(s):null,tileID:l?l.tileID:r,verticalScale:a})}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o<e.symbolInstances.length;o++){const s=e.symbolInstances.get(o),n=s.zOffset,a=this._getHeightAtTileOffset(r,s.tileAnchorX,s.tileAnchorY);s.zOffset=a!==-1?a:n,i||n===s.zOffset||(i=!0),e.hasAnyZOffset||s.zOffset===0||(e.hasAnyZOffset=!0)}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(e,r,i,o){let s=r,n=i;if(e.canonical.z!==o.canonical.z){const a=o.canonical,l=1/(1<<e.canonical.z-a.z);s=(r+e.canonical.x*W)*l-a.x*W|0,n=(i+e.canonical.y*W)*l-a.y*W|0}return{tileX:s,tileY:n}}_getHeightAtTileOffset(e,r,i){let o;for(let s=0;s<this.layers.length;++s){if(this.layers[s].type!=="fill-extrusion")continue;const{bucket:n,tileID:a,verticalScale:l}=this.currentBuildingBuckets[s];if(!n)continue;const{tileX:c,tileY:u}=this._mapCoordToOverlappingTile(e,r,i,a),h=n.getHeightAtTileCoord(c,u);if(h&&h.height!==void 0){if(!h.hidden)return h.height*l;o=h.height}}for(let s=0;s<this.layers.length;++s){if(this.layers[s].type!=="model")continue;const{bucket:n,tileID:a}=this.currentBuildingBuckets[s];if(!n)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,r,i,a),u=n.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return u.height===void 0&&o!==void 0?Math.min(u.maxHeight,o)*u.verticalScale:(u.height||0)*u.verticalScale}return-1}}var Ax=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function oE(t,e){const r={};for(const i in t)i!=="ref"&&(r[i]=t[i]);return Ax.forEach(i=>{i in e&&(r[i]=e[i])}),r}function Ix(t){t=t.slice();const e=Object.create(null);for(let r=0;r<t.length;r++)e[t[r].id]=t[r];for(let r=0;r<t.length;r++)"ref"in t[r]&&(t[r]=oE(t[r],e[t[r].ref]));return t}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",setImportUrl:"setImportUrl",setImportData:"setImportData",setImportConfig:"setImportConfig"};function Cx(t,e,r){r.push({command:gt.addSource,args:[t,e[t]]})}function zx(t,e,r){e.push({command:gt.removeSource,args:[t]}),r[t]=!0}function sE(t,e,r,i){zx(t,r,i),Cx(t,e,r)}function nE(t,e,r){let i;for(i in t[r])if(t[r].hasOwnProperty(i)&&i!=="data"&&!dt(t[r][i],e[r][i]))return!1;for(i in e[r])if(e[r].hasOwnProperty(i)&&i!=="data"&&!dt(t[r][i],e[r][i]))return!1;return!0}function Fc(t,e,r,i,o,s){let n;for(n in e=e||{},t=t||{})t.hasOwnProperty(n)&&(dt(t[n],e[n])||r.push({command:s,args:[i,n,e[n],o]}));for(n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(dt(t[n],e[n])||r.push({command:s,args:[i,n,e[n],o]}))}function Nc(t){return t.id}function Uc(t,e){return t[e.id]=e,t}class aE{constructor(e,r){this.reset(e,r)}reset(e,r){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(r||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=Se(e,0,1);let r=1,i=this._distances[r];const o=e*this.paddedLength+this.padding;for(;i<o&&r<this._distances.length;)i=this._distances[++r];const s=r-1,n=this._distances[s],a=i-n,l=a>0?(o-n)/a:0;return this.points[s].mult(1-l).add(this.points[r].mult(l))}}class Dx{constructor(e,r,i){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(r/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)o.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=r,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/r,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,r,i,o,s){this._forEachCell(r,i,o,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(o),this.bboxes.push(s)}insertCircle(e,r,i,o){this._forEachCell(r-o,i-o,r+o,i+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(r),this.circles.push(i),this.circles.push(o)}_insertBoxCell(e,r,i,o,s,n){this.boxCells[s].push(n)}_insertCircleCell(e,r,i,o,s,n){this.circleCells[s].push(n)}_query(e,r,i,o,s,n){if(i<0||e>this.width||o<0||r>this.height)return!s&&[];const a=[];if(e<=0&&r<=0&&this.width<=i&&this.height<=o){if(s)return!0;for(let l=0;l<this.boxKeys.length;l++)a.push({key:this.boxKeys[l],x1:this.bboxes[4*l],y1:this.bboxes[4*l+1],x2:this.bboxes[4*l+2],y2:this.bboxes[4*l+3]});for(let l=0;l<this.circleKeys.length;l++){const c=this.circles[3*l],u=this.circles[3*l+1],h=this.circles[3*l+2];a.push({key:this.circleKeys[l],x1:c-h,y1:u-h,x2:c+h,y2:u+h})}return n?a.filter(n):a}return this._forEachCell(e,r,i,o,this._queryCell,a,{hitTest:s,seenUids:{box:{},circle:{}}},n),s?a.length>0:a}_queryCircle(e,r,i,o,s){const n=e-i,a=e+i,l=r-i,c=r+i;if(a<0||n>this.width||c<0||l>this.height)return!o&&[];const u=[];return this._forEachCell(n,l,a,c,this._queryCellCircle,u,{hitTest:o,circle:{x:e,y:r,radius:i},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(e,r,i,o,s){return this._query(e,r,i,o,!1,s)}hitTest(e,r,i,o,s){return this._query(e,r,i,o,!0,s)}hitTestCircle(e,r,i,o){return this._queryCircle(e,r,i,!0,o)}_queryCell(e,r,i,o,s,n,a,l){const c=a.seenUids,u=this.boxCells[s];if(u!==null){const d=this.bboxes;for(const p of u)if(!c.box[p]){c.box[p]=!0;const f=4*p;if(e<=d[f+2]&&r<=d[f+3]&&i>=d[f+0]&&o>=d[f+1]&&(!l||l(this.boxKeys[p]))){if(a.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const h=this.circleCells[s];if(h!==null){const d=this.circles;for(const p of h)if(!c.circle[p]){c.circle[p]=!0;const f=3*p;if(this._circleAndRectCollide(d[f],d[f+1],d[f+2],e,r,i,o)&&(!l||l(this.circleKeys[p]))){if(a.hitTest)return n.push(!0),!0;{const m=d[f],_=d[f+1],g=d[f+2];n.push({key:this.circleKeys[p],x1:m-g,y1:_-g,x2:m+g,y2:_+g})}}}}}_queryCellCircle(e,r,i,o,s,n,a,l){const c=a.circle,u=a.seenUids,h=this.boxCells[s];if(h!==null){const p=this.bboxes;for(const f of h)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(c.x,c.y,c.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!l||l(this.boxKeys[f])))return n.push(!0),!0}}const d=this.circleCells[s];if(d!==null){const p=this.circles;for(const f of d)if(!u.circle[f]){u.circle[f]=!0;const m=3*f;if(this._circlesCollide(p[m],p[m+1],p[m+2],c.x,c.y,c.radius)&&(!l||l(this.circleKeys[f])))return n.push(!0),!0}}}_forEachCell(e,r,i,o,s,n,a,l){const c=this._convertToXCellCoord(e),u=this._convertToYCellCoord(r),h=this._convertToXCellCoord(i),d=this._convertToYCellCoord(o);for(let p=c;p<=h;p++)for(let f=u;f<=d;f++)if(s.call(this,e,r,i,o,this.xCellCount*f+p,n,a,l))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,r,i,o,s,n){const a=o-e,l=s-r,c=i+n;return c*c>a*a+l*l}_circleAndRectCollide(e,r,i,o,s,n,a){const l=(n-o)/2,c=Math.abs(e-(o+l));if(c>l+i)return!1;const u=(a-s)/2,h=Math.abs(r-(s+u));if(h>u+i)return!1;if(c<=l||h<=u)return!0;const d=c-l,p=h-u;return d*d+p*p<=i*i}}const Ji=100;class lE{constructor(e,r,i=new Dx(e.width+200,e.height+200,25),o=new Dx(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Ji,this.screenBottomBoundary=e.height+Ji,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=r}placeCollisionBox(e,r,i,o,s,n,a,l){let c=i.projectedAnchorX,u=i.projectedAnchorY,h=i.projectedAnchorZ;const d=i.elevation,p=i.tileID,f=e.getProjection();if(d&&p){const[w,T,E]=f.upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),M=f.upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;c+=w*d*M,u+=T*d*M,h+=E*d*M}const m=this.projectAndGetPerspectiveRatio(a,c,u,h,i.tileID,f.name==="globe"||!!d||this.transform.pitch>0,f),_=n*m.perspectiveRatio,g=(i.x1*r+o.x-i.padding)*_+m.point.x,y=(i.y1*r+o.y-i.padding)*_+m.point.y,v=(i.x2*r+o.x+i.padding)*_+m.point.x,b=(i.y2*r+o.y+i.padding)*_+m.point.y,x=m.perspectiveRatio<=.55||m.occluded;return!this.isInsideGrid(g,y,v,b)||!s&&this.grid.hitTest(g,y,v,b,l)||x?{box:[],offscreen:!1,occluded:m.occluded}:{box:[g,y,v,b],offscreen:this.isOffscreen(g,y,v,b),occluded:!1}}placeCollisionCircles(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){const _=[],g=this.transform.elevation,y=e.getProjection(),v=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,b=new N(i.tileAnchorX,i.tileAnchorY);let{x,y:w,z:T}=y.projectTilePoint(b.x,b.y,m.canonical);if(v){const[U,R,B]=v(b);x+=U,w+=R,T+=B}const E=y.name==="globe",M=this.projectAndGetPerspectiveRatio(a,x,w,T,m,E||!!g||this.transform.pitch>0,y),{perspectiveRatio:S}=M,I=(h?n/S:n*S)/xr,C=Pi(x,w,T,l),k=M.signedDistanceFromCamera>0?c0(I,s,i.lineOffsetX*I,i.lineOffsetY*I,!1,C,b,i,o,l,{},g&&!h?v:null,h&&!!g,y,m,h):null;let A=!1,L=!1,O=!0;if(k&&!M.occluded){const U=.5*p*S+f,R=new N(-100,-100),B=new N(this.screenRightBoundary,this.screenBottomBoundary),G=new aE,{first:Z,last:q}=k,X=Z.path.length;let Y=[];for(let ee=X-1;ee>=1;ee--)Y.push(Z.path[ee]);for(let ee=1;ee<q.path.length;ee++)Y.push(q.path[ee]);const K=2.5*U;c&&(Y=Y.map(([ee,de,pe],ge)=>(v&&!E&&(pe=v(ge<X-1?Z.tilePath[X-1-ge]:q.tilePath[ge-X+2])[2]),Pi(ee,de,pe,c))),Y.some(ee=>ee[3]<=0)&&(Y=[]));let H=[];if(Y.length>0){let ee=1/0,de=-1/0,pe=1/0,ge=-1/0;for(const xe of Y)ee=Math.min(ee,xe[0]),pe=Math.min(pe,xe[1]),de=Math.max(de,xe[0]),ge=Math.max(ge,xe[1]);de>=R.x&&ee<=B.x&&ge>=R.y&&pe<=B.y&&(H=[Y.map(xe=>new N(xe[0],xe[1]))],(ee<R.x||de>B.x||pe<R.y||ge>B.y)&&(H=ky(H,R.x,R.y,B.x,B.y)))}for(const ee of H){G.reset(ee,.25*U);let de=0;de=G.length<=.5*U?1:Math.ceil(G.paddedLength/K)+1;for(let pe=0;pe<de;pe++){const ge=pe/Math.max(de-1,1),xe=G.lerp(ge),Oe=xe.x+Ji,Ie=xe.y+Ji;_.push(Oe,Ie,U,0);const ht=Oe-U,st=Ie-U,Be=Oe+U,Re=Ie+U;if(O=O&&this.isOffscreen(ht,st,Be,Re),L=L||this.isInsideGrid(ht,st,Be,Re),!r&&this.grid.hitTestCircle(Oe,Ie,U,d)&&(A=!0,!u))return{circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return{circles:!u&&A||!L?[]:_,offscreen:O,collisionDetected:A,occluded:M.occluded}}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const r=[];let i=1/0,o=1/0,s=-1/0,n=-1/0;for(const u of e){const h=new N(u.x+Ji,u.y+Ji);i=Math.min(i,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x),n=Math.max(n,h.y),r.push(h)}const a=this.grid.query(i,o,s,n).concat(this.ignoredGrid.query(i,o,s,n)),l={},c={};for(const u of a){const h=u.key;l[h.bucketInstanceId]===void 0&&(l[h.bucketInstanceId]={}),l[h.bucketInstanceId][h.featureIndex]||Bg(r,[new N(u.x1,u.y1),new N(u.x2,u.y1),new N(u.x2,u.y2),new N(u.x1,u.y2)])&&(l[h.bucketInstanceId][h.featureIndex]=!0,c[h.bucketInstanceId]===void 0&&(c[h.bucketInstanceId]=[]),c[h.bucketInstanceId].push(h.featureIndex))}return c}insertCollisionBox(e,r,i,o,s){(r?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:o,collisionGroupID:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,r,i,o,s){const n=r?this.ignoredGrid:this.grid,a={bucketInstanceId:i,featureIndex:o,collisionGroupID:s};for(let l=0;l<e.length;l+=4)n.insertCircle(a,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,r,i,o,s,n,a){const l=[r,i,o,1];let c=!1;o||this.transform.pitch>0?(Mt.transformMat4(l,l,e),this.fogState&&s&&a.name!=="globe"&&(c=function(h,d,p,f,m,_){const g=_.calculateFogTileMatrix(m),y=[d,p,f];return D.transformMat4(y,y,g),Lc(h,D.length(y),_.pitch,_._fov)}(this.fogState,r,i,o,s.toUnwrapped(),this.transform)>.9)):f0(l,l,e);const u=l[3];return{point:new N((l[0]/u+1)/2*this.transform.width+Ji,(-l[1]/u+1)/2*this.transform.height+Ji),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:n&&l[2]>u||c}}isOffscreen(e,r,i,o){return i<Ji||e>=this.screenRightBoundary||o<Ji||r>this.screenBottomBoundary}isInsideGrid(e,r,i,o){return i>=0&&e<this.gridRightBoundary&&o>=0&&r<this.gridBottomBoundary}getViewportMatrix(){const e=V.identity([]);return V.translate(e,e,[-100,-100,0]),e}}function Mp(t,e,r){const i=e.createTileMatrix(t,t.worldSize,r.toUnwrapped());return V.multiply(new Float32Array(16),t.projMatrix,i)}function cE(t,e,r){if(e.projection.name===r.projection.name)return t.projMatrix;const i=r.clone();return i.setProjection(e.projection),Mp(i,e.getProjection(),t)}function Sp(t,e,r){return e.name===r.projection.name?t.projMatrix:Mp(r,e,t)}class kx{constructor(e,r,i,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?r:-r))):o&&i?1:0,this.placed=i}isHidden(){return this.opacity===0&&!this.placed}}class Oa{constructor(e,r,i,o,s,n=!1){this.text=new kx(e?e.text:null,r,i,s),this.icon=new kx(e?e.icon:null,r,o,s),this.clipped=n}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ap{constructor(e,r,i,o=!1){this.text=e,this.icon=r,this.skipFade=i,this.clipped=o}}class uE{constructor(){this.invProjMatrix=V.create(),this.viewportMatrix=V.create(),this.circles=[]}}class hE{constructor(e,r,i,o,s){this.bucketInstanceId=e,this.featureIndex=r,this.sourceLayerIndex=i,this.bucketIndex=o,this.tileID=s}}class dE{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const r=++this.maxGroupID;this.collisionGroups[e]={ID:r,predicate:i=>i.collisionGroupID===r}}return this.collisionGroups[e]}}function Px(t,e,r,i,o){const{horizontalAlign:s,verticalAlign:n}=lc(t),a=-(s-.5)*e,l=-(n-.5)*r,c=qd(t,i);return new N(a+c[0]*o,l+c[1]*o)}function Ip(t,e,r,i,o){const s=new N(t,e);return r&&s._rotate(i?o:-o),s}class pE{constructor(e,r,i,o,s,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new lE(this.transform,s),this.buildingIndex=n,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new dE(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,r,i,o){const s=i.getBucket(r),n=i.latestFeatureIndex;if(!s||!n||r.fqid!==s.layerIds[0])return;const a=s.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/W,h=i.tileID.toUnwrapped();this.transform.setProjection(s.projection);const d=(p=i.tileID,f=s.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Mp(m,f,p));var p,f,m;const _=a.get("text-pitch-alignment")==="map",g=a.get("text-rotation-alignment")==="map";r.compileFilter();const y=r.dynamicFilter(),v=r.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(i),x=n0(d,i.tileID.canonical,_,g,this.transform,s.getProjection(),b);let w=null;if(_){const M=a0(d,i.tileID.canonical,_,g,this.transform,s.getProjection(),b);w=V.multiply([],this.transform.labelPlaneMatrix,M)}let T=null;y&&i.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[s.bucketInstanceId]=new hE(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);const E={bucket:s,layout:a,posMatrix:d,textLabelPlaneMatrix:x,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:Hi(s.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:Hi(s.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(o)for(const M of s.sortKeyRanges){const{sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C}=M;e.push({sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C,parameters:E})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y){const{textOffset0:v,textOffset1:b,crossTileID:x}=d,w=[v,b],T=Px(e,i,o,w,s),E=this.collisionIndex.placeCollisionBox(f,s,r,Ip(T.x,T.y,n,a,this.transform.angle),h,l,c,u.predicate);if(_){const M=f.getSymbolInstanceIconSize(y,this.transform.zoom,d.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(f,M,_,Ip(T.x,T.y,n,a,this.transform.angle),h,l,c,u.predicate).box.length===0)return}if(E.box.length>0){let M;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(M=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:w,width:i,height:o,anchor:e,textScale:s,prevAnchor:M},this.markUsedJustification(f,e,d,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,d),this.placedOrientations[x]=m),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(e,r,i,o){const{bucket:s,layout:n,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=n.get("text-optional"),y=n.get("icon-optional"),v=n.get("text-allow-overlap"),b=n.get("icon-allow-overlap"),x=n.get("text-rotation-alignment")==="map",w=n.get("text-pitch-alignment")==="map",T=n.get("symbol-z-order")==="viewport-y",E=n.get("symbol-z-elevate");this.transform.setProjection(s.projection);let M=v&&(b||!s.hasIconData()||y),S=b&&(v||!s.hasTextData()||g);!s.collisionArrays&&p&&s.deserializeCollisionBoxes(p),i&&o&&s.updateCollisionDebugBuffers(this.transform.zoom,p);const I=(C,k,A)=>{const{crossTileID:L,numVerticalGlyphVertices:O}=C;if(u){const Be={zoom:this.transform.zoom,pitch:this.transform.pitch};let Re=null;if(u.dynamicFilterNeedsFeature){const De=this.retainedQueryData[s.bucketInstanceId];Re=u.featureIndex.loadFeature({featureIndex:C.featureIndex,bucketIndex:De.bucketIndex,sourceLayerIndex:De.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(Be,Re,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new N(C.tileAnchorX,C.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[L]=new Ap(!1,!1,!1,!0),void r.add(L)}if(r.has(L))return;if(d)return void(this.placements[L]=new Ap(!1,!1,!1));let U=!1,R=!1,B=!0,G=!1,Z=!1,q=null,X={box:null,offscreen:null,occluded:null},Y={box:null,offscreen:null,occluded:null},K=null,H=null,ee=null,de=0,pe=0,ge=0;A.textFeatureIndex?de=A.textFeatureIndex:C.useRuntimeCollisionCircles&&(de=C.featureIndex),A.verticalTextFeatureIndex&&(pe=A.verticalTextFeatureIndex);const xe=Be=>{Be.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const Re=this.transform.elevation;Be.elevation=C.zOffset+(Re?Re.getAtTileOffset(Be.tileID,Be.tileAnchorX,Be.tileAnchorY):0)},Oe=A.textBox;if(Oe){xe(Oe);const Be=De=>{let at=Nt.horizontal;if(s.allowVerticalPlacement&&!De&&this.prevPlacement){const ut=this.prevPlacement.placedOrientations[L];ut&&(this.placedOrientations[L]=ut,at=ut,this.markUsedOrientation(s,at,C))}return at},Re=(De,at)=>{if(s.allowVerticalPlacement&&O>0&&A.verticalTextBox){for(const ut of s.writingModes)if(ut===Nt.vertical?(X=at(),Y=X):X=De(),X&&X.box&&X.box.length)break}else X=De()};if(n.get("text-variable-anchor")){let De=n.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[L]){const Je=this.prevPlacement.variableOffsets[L];De.indexOf(Je.anchor)>0&&(De=De.filter(Ct=>Ct!==Je.anchor),De.unshift(Je.anchor))}const at=(Je,Ct,Kt)=>{const St=s.getSymbolInstanceTextSize(f,C,this.transform.zoom,k),Rt=(Je.x2-Je.x1)*St+2*Je.padding,rr=(Je.y2-Je.y1)*St+2*Je.padding,Qt=C.hasIconTextFit&&!b?Ct:null;Qt&&xe(Qt);let Ot={box:[],offscreen:!1,occluded:!1};const bt=v?2*De.length:De.length;for(let Er=0;Er<bt;++Er){const Qi=this.attemptAnchorPlacement(De[Er%De.length],Je,Rt,rr,St,x,w,h,a,_,Er>=De.length,C,k,s,Kt,Qt,f,m);if(Qi&&(Ot=Qi.placedGlyphBoxes,Ot&&Ot.box&&Ot.box.length)){U=!0,q=Qi.shift;break}}return Ot};Re(()=>at(Oe,A.iconBox,Nt.horizontal),()=>{const Je=A.verticalTextBox;return Je&&xe(Je),s.allowVerticalPlacement&&!(X&&X.box&&X.box.length)&&O>0&&Je?at(Je,A.verticalIconBox,Nt.vertical):{box:null,offscreen:null,occluded:null}}),X&&(U=X.box,B=X.offscreen,G=X.occluded);const ut=Be(!(!X||!X.box));if(!U&&this.prevPlacement){const Je=this.prevPlacement.variableOffsets[L];Je&&(this.variableOffsets[L]=Je,this.markUsedJustification(s,Je.anchor,C,ut))}}else{const De=(at,ut)=>{const Je=s.getSymbolInstanceTextSize(f,C,this.transform.zoom,k),Ct=this.collisionIndex.placeCollisionBox(s,Je,at,new N(0,0),v,h,a,_.predicate);return Ct&&Ct.box&&Ct.box.length&&(this.markUsedOrientation(s,ut,C),this.placedOrientations[L]=ut),Ct};Re(()=>De(Oe,Nt.horizontal),()=>{const at=A.verticalTextBox;return s.allowVerticalPlacement&&O>0&&at?(xe(at),De(at,Nt.vertical)):{box:null,offscreen:null,occluded:null}}),Be(!!(X&&X.box&&X.box.length))}}if(K=X,U=K&&K.box&&K.box.length>0,B=K&&K.offscreen,G=K&&K.occluded,C.useRuntimeCollisionCircles){const Be=s.text.placedSymbolArray.get(C.centerJustifiedTextSymbolIndex>=0?C.centerJustifiedTextSymbolIndex:C.verticalPlacedTextSymbolIndex),Re=ma(s.textSizeData,f,Be),De=n.get("text-padding");H=this.collisionIndex.placeCollisionCircles(s,v,Be,s.lineVertexArray,s.glyphOffsetArray,Re,a,l,c,i,w,_.predicate,C.collisionCircleDiameter*Re/xr,De,this.retainedQueryData[s.bucketInstanceId].tileID),U=v||H.circles.length>0&&!H.collisionDetected,B=B&&H.offscreen,G=H.occluded}if(A.iconFeatureIndex&&(ge=A.iconFeatureIndex),A.iconBox){const Be=Re=>{xe(Re);const De=C.hasIconTextFit&&q?Ip(q.x,q.y,x,w,this.transform.angle):new N(0,0),at=s.getSymbolInstanceIconSize(m,this.transform.zoom,C.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,at,Re,De,b,h,a,_.predicate)};Y&&Y.box&&Y.box.length&&A.verticalIconBox?(ee=Be(A.verticalIconBox),R=ee.box.length>0):(ee=Be(A.iconBox),R=ee.box.length>0),B=B&&ee.offscreen,Z=ee.occluded}const Ie=g||C.numHorizontalGlyphVertices===0&&O===0,ht=y||C.numIconVertices===0;if(Ie||ht?ht?Ie||(R=R&&U):U=R&&U:R=U=R&&U,U&&K&&K.box&&this.collisionIndex.insertCollisionBox(K.box,n.get("text-ignore-placement"),s.bucketInstanceId,Y&&Y.box&&pe?pe:de,_.ID),R&&ee&&this.collisionIndex.insertCollisionBox(ee.box,n.get("icon-ignore-placement"),s.bucketInstanceId,ge,_.ID),H&&(U&&this.collisionIndex.insertCollisionCircles(H.circles,n.get("text-ignore-placement"),s.bucketInstanceId,de,_.ID),i)){const Be=s.bucketInstanceId;let Re=this.collisionCircleArrays[Be];Re===void 0&&(Re=this.collisionCircleArrays[Be]=new uE);for(let De=0;De<H.circles.length;De+=4)Re.circles.push(H.circles[De+0]),Re.circles.push(H.circles[De+1]),Re.circles.push(H.circles[De+2]),Re.circles.push(H.collisionDetected?1:0)}const st=s.projection.name!=="globe";M=M&&(st||!G),S=S&&(st||!Z),this.placements[L]=new Ap(U||M,R||S,B||s.justReloaded),r.add(L)};if(E&&this.buildingIndex&&(this.buildingIndex.updateZOffset(s,this.retainedQueryData[s.bucketInstanceId].tileID),s.updateZOffset()),T){const C=s.getSortedSymbolIndexes(this.transform.angle);for(let k=C.length-1;k>=0;--k){const A=C[k];I(s.symbolInstances.get(A),A,s.collisionArrays[A])}s.hasAnyZOffset&&F(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const C=s.getSortedIndexesByZOffset();for(let k=0;k<C.length;++k){const A=C[k];I(s.symbolInstances.get(A),A,s.collisionArrays[A])}}else for(let C=e.symbolInstanceStart;C<e.symbolInstanceEnd;C++)I(s.symbolInstances.get(C),C,s.collisionArrays[C]);if(i&&s.bucketInstanceId in this.collisionCircleArrays){const C=this.collisionCircleArrays[s.bucketInstanceId];V.invert(C.invProjMatrix,a),C.viewportMatrix=this.collisionIndex.getViewportMatrix()}s.justReloaded=!1}markUsedJustification(e,r,i,o){const{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=i,u=Zd(r),h=o===Nt.vertical?l:u==="left"?s:u==="center"?n:u==="right"?a:-1;s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),n>=0&&(e.text.placedSymbolArray.get(n).crossTileID=h>=0&&n!==h?0:c),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(e.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(e,r,i){const o=r===Nt.horizontal||r===Nt.horizontalOnly?r:0,s=r===Nt.vertical?r:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=i,u=e.text.placedSymbolArray;n>=0&&(u.get(n).placedOrientation=o),a>=0&&(u.get(a).placedOrientation=o),l>=0&&(u.get(l).placedOrientation=o),c>=0&&(u.get(c).placedOrientation=s)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let i=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(e):1,s=r?r.opacities:{},n=r?r.variableOffsets:{},a=r?r.placedOrientations:{};for(const l in this.placements){const c=this.placements[l],u=s[l];u?(this.opacities[l]=new Oa(u,o,c.text,c.icon,null,c.clipped),i=i||c.text!==u.text.placed||c.icon!==u.icon.placed):(this.opacities[l]=new Oa(null,o,c.text,c.icon,c.skipFade,c.clipped),i=i||c.text||c.icon)}for(const l in s){const c=s[l];if(!this.opacities[l]){const u=new Oa(c,o,!1,!1);u.isHidden()||(this.opacities[l]=u,i=i||c.text.placed||c.icon.placed)}}for(const l in n)this.variableOffsets[l]||!this.opacities[l]||this.opacities[l].isHidden()||(this.variableOffsets[l]=n[l]);for(const l in a)this.placedOrientations[l]||!this.opacities[l]||this.opacities[l].isHidden()||(this.placedOrientations[l]=a[l]);i?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:e)}updateLayerOpacities(e,r){const i=new Set;for(const o of r){const s=o.getBucket(e);s&&o.latestFeatureIndex&&e.fqid===s.layerIds[0]&&(this.updateBucketOpacities(s,i,o.collisionBoxArray),s.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(s,o.tileID),s.updateZOffset()))}}updateBucketOpacities(e,r,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0].layout,s=!!e.layers[0].dynamicFilter(),n=new Oa(null,0,!1,!1,!0),a=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),c=o.get("text-variable-anchor"),u=o.get("text-rotation-alignment")==="map",h=o.get("text-pitch-alignment")==="map",d=new Oa(null,0,a&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(a||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const p=(m,_,g)=>{for(let y=0;y<_/4;y++)m.opacityVertexArray.emplaceBack(g)};let f=0;for(let m=0;m<e.symbolInstances.length;m++){const _=e.symbolInstances.get(m),{numHorizontalGlyphVertices:g,numVerticalGlyphVertices:y,crossTileID:v,numIconVertices:b}=_,x=r.has(v);let w=this.opacities[v];x?w=n:w||(w=d,this.opacities[v]=w),r.add(v);const T=g>0||y>0,E=b>0,M=this.placedOrientations[v],S=M===Nt.vertical,I=M===Nt.horizontal||M===Nt.horizontalOnly;if(!T&&!E||w.isHidden()||f++,T){const C=Rx(w.text);p(e.text,g,S?jc:C),p(e.text,y,I?jc:C);const k=w.text.isHidden(),{leftJustifiedTextSymbolIndex:A,centerJustifiedTextSymbolIndex:L,rightJustifiedTextSymbolIndex:O,verticalPlacedTextSymbolIndex:U}=_,R=e.text.placedSymbolArray,B=k||S?1:0;A>=0&&(R.get(A).hidden=B),L>=0&&(R.get(L).hidden=B),O>=0&&(R.get(O).hidden=B),U>=0&&(R.get(U).hidden=k||I?1:0);const G=this.variableOffsets[v];G&&this.markUsedJustification(e,G.anchor,_,M);const Z=this.placedOrientations[v];Z&&(this.markUsedJustification(e,"left",_,Z),this.markUsedOrientation(e,Z,_))}if(E){const C=Rx(w.icon),{placedIconSymbolIndex:k,verticalPlacedIconSymbolIndex:A}=_,L=e.icon.placedSymbolArray,O=w.icon.isHidden()?1:0;k>=0&&(p(e.icon,b,S?jc:C),L.get(k).hidden=O),A>=0&&(p(e.icon,_.numVerticalIconVertices,I?jc:C),L.get(A).hidden=O)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const C=e.collisionArrays[m];if(C){let k=new N(0,0),A=!0;if(C.textBox||C.verticalTextBox){if(c){const O=this.variableOffsets[v];O?(k=Px(O.anchor,O.width,O.height,O.textOffset,O.textScale),u&&k._rotate(h?this.transform.angle:-this.transform.angle)):A=!1}s&&(A=!w.clipped),C.textBox&&Vc(e.textCollisionBox.collisionVertexArray,w.text.placed,!A||S,k.x,k.y),C.verticalTextBox&&Vc(e.textCollisionBox.collisionVertexArray,w.text.placed,!A||I,k.x,k.y)}const L=A&&!!(!I&&C.verticalIconBox);C.iconBox&&Vc(e.iconCollisionBox.collisionVertexArray,w.icon.placed,L,_.hasIconTextFit?k.x:0,_.hasIconTextFit?k.y:0),C.verticalIconBox&&Vc(e.iconCollisionBox.collisionVertexArray,w.icon.placed,!L,_.hasIconTextFit?k.x:0,_.hasIconTextFit?k.y:0)}}}if(e.fullyClipped=f===0,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const m=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=m.invProjMatrix,e.placementViewportMatrix=m.viewportMatrix,e.collisionCircleArray=m.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,r){const i=this.zoomAtLastRecencyCheck===r?1-this.zoomAdjustment(r):1;return this.zoomAtLastRecencyCheck=r,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function Vc(t,e,r,i,o){t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0)}const fE=Math.pow(2,25),mE=Math.pow(2,24),_E=Math.pow(2,17),gE=Math.pow(2,16),yE=Math.pow(2,9),xE=Math.pow(2,8),vE=Math.pow(2,1);function Rx(t){if(t.opacity===0&&!t.placed)return 0;if(t.opacity===1&&t.placed)return 4294967295;const e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*fE+e*mE+r*_E+e*gE+r*yE+e*xE+r*vE+e}const jc=0;class bE{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&e.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,r,i,o,s){const n=this._bucketParts;for(;this._currentTileIndex<e.length;)if(r.getBucketParts(n,o,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((a,l)=>a.sortKey-l.sortKey));this._currentPartIndex<n.length;){const a=n[this._currentPartIndex];if(r.placeLayerBucketPart(a,this._seenCrossTileIDs,i,a.symbolInstanceStart===0),this._currentPartIndex++,s())return!0}return!1}}class wE{constructor(e,r,i,o,s,n,a,l,c){this.placement=new pE(e,s,n,a,l,c),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=o,this._done=!1}isDone(){return this._done}continuePlacement(e,r,i,o){const s=je.now(),n=()=>{const a=je.now()-s;return!this._forceFullPlacement&&a>2};for(;this._currentPlacementIndex>=0;){const a=r[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if(a.type==="symbol"&&(!a.minzoom||a.minzoom<=l)&&(!a.maxzoom||a.maxzoom>l)){const c=a,u=c.layout.get("symbol-z-elevate"),h=this._inProgressLayer=this._inProgressLayer||new bE(c),d=Dr(a.source,a.scope);if(h.continuePlacement(u?o[d]:i[d],this.placement,this._showCollisionBoxes,a,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Lx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Gc{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,i]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=i>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const s=Lx[15&i];if(!s)throw new Error("Unrecognized array type.");const[n]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Gc(a,n,s,e)}constructor(e,r=64,i=Float64Array,o){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const s=Lx.indexOf(this.ArrayType),n=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${i}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+l,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+n+a+l),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=r,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Cp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,i,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:n,nodeSize:a}=this,l=[0,s.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let _=d;_<=h;_++){const g=n[2*_],y=n[2*_+1];g>=e&&g<=i&&y>=r&&y<=o&&c.push(s[_])}continue}const p=d+h>>1,f=n[2*p],m=n[2*p+1];f>=e&&f<=i&&m>=r&&m<=o&&c.push(s[p]),(u===0?e<=f:r<=m)&&(l.push(d),l.push(p-1),l.push(1-u)),(u===0?i>=f:o>=m)&&(l.push(p+1),l.push(h),l.push(1-u))}return c}within(e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:s,nodeSize:n}=this,a=[0,o.length-1,0],l=[],c=i*i;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=n){for(let _=d;_<=h;_++)Ox(s[2*_],s[2*_+1],e,r)<=c&&l.push(o[_]);continue}const p=d+h>>1,f=s[2*p],m=s[2*p+1];Ox(f,m,e,r)<=c&&l.push(o[p]),(u===0?e-i<=f:r-i<=m)&&(a.push(d),a.push(p-1),a.push(1-u)),(u===0?e+i>=f:r+i>=m)&&(a.push(p+1),a.push(h),a.push(1-u))}return l}}function Cp(t,e,r,i,o,s){if(o-i<=r)return;const n=i+o>>1;Bx(t,e,n,i,o,s),Cp(t,e,r,i,n-1,1-s),Cp(t,e,r,n+1,o,1-s)}function Bx(t,e,r,i,o,s){for(;o>i;){if(o-i>600){const c=o-i+1,u=r-i+1,h=Math.log(c),d=.5*Math.exp(2*h/3),p=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1);Bx(t,e,r,Math.max(i,Math.floor(r-u*d/c+p)),Math.min(o,Math.floor(r+(c-u)*d/c+p)),s)}const n=e[2*r+s];let a=i,l=o;for(Fa(t,e,i,r),e[2*o+s]>n&&Fa(t,e,i,o);a<l;){for(Fa(t,e,a,l),a++,l--;e[2*a+s]<n;)a++;for(;e[2*l+s]>n;)l--}e[2*i+s]===n?Fa(t,e,i,l):(l++,Fa(t,e,l,o)),l<=r&&(i=l+1),r<=l&&(o=l-1)}}function Fa(t,e,r,i){zp(t,r,i),zp(e,2*r,2*i),zp(e,2*r+1,2*i+1)}function zp(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function Ox(t,e,r,i){const o=t-r,s=e-i;return o*o+s*s}const Dp=512/W/2;class TE{constructor(e,r,i){this.tileID=e,this.bucketInstanceId=i,this.index=new Gc(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const o=e.canonical.x*W,s=e.canonical.y*W;for(let n=0;n<r.length;n++){const{key:a,crossTileID:l,tileAnchorX:c,tileAnchorY:u}=r.get(n),h=Math.floor((o+c)*Dp),d=Math.floor((s+u)*Dp);this.index.add(h,d),this.keys.push(a),this.crossTileIDs.push(l)}this.index.finish()}findMatches(e,r,i){const o=this.tileID.canonical.z<r.canonical.z?1:Math.pow(2,this.tileID.canonical.z-r.canonical.z),s=Dp/Math.pow(2,r.canonical.z-this.tileID.canonical.z),n=r.canonical.x*W,a=r.canonical.y*W;for(let l=0;l<e.length;l++){const c=e.get(l);if(c.crossTileID)continue;const{key:u,tileAnchorX:h,tileAnchorY:d}=c,p=Math.floor((n+h)*s),f=Math.floor((a+d)*s),m=this.index.range(p-o,f-o,p+o,f+o);for(const _ of m){const g=this.crossTileIDs[_];if(this.keys[_]===u&&!i.has(g)){i.add(g),c.crossTileID=g;break}}}}}class EE{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ME{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const r=Math.round((e-this.lng)/360);if(r!==0)for(const i in this.indexes){const o=this.indexes[i],s={};for(const n in o){const a=o[n];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+r),s[a.tileID.key]=a}this.indexes[i]=s}this.lng=e}addBucket(e,r,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===r.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let s=0;s<r.symbolInstances.length;s++)r.symbolInstances.get(s).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const o=this.usedCrossTileIDs[e.overscaledZ];for(const s in this.indexes){const n=this.indexes[s];if(Number(s)>e.overscaledZ)for(const a in n){const l=n[a];l.tileID.isChildOf(e)&&l.findMatches(r.symbolInstances,e,o)}else{const a=n[e.scaledTo(Number(s)).key];a&&a.findMatches(r.symbolInstances,e,o)}}for(let s=0;s<r.symbolInstances.length;s++){const n=r.symbolInstances.get(s);n.crossTileID||(n.crossTileID=i.generate(),o.add(n.crossTileID))}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new TE(e,r.symbolInstances,r.bucketInstanceId),!0}removeBucketCrossTileIDs(e,r){for(const i of r.crossTileIDs)this.usedCrossTileIDs[e].delete(i)}removeStaleBuckets(e){let r=!1;for(const i in this.indexes){const o=this.indexes[i];for(const s in o)e[o[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,o[s]),delete o[s],r=!0)}return r}}class SE{constructor(){this.layerIndexes={},this.crossTileIDs=new EE,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,r,i,o){let s=this.layerIndexes[e.fqid];s===void 0&&(s=this.layerIndexes[e.fqid]=new ME);let n=!1;const a={};o.name!=="globe"&&s.handleWrapJump(i);for(const l of r){const c=l.getBucket(e);c&&e.fqid===c.layerIds[0]&&(c.bucketInstanceId||(c.bucketInstanceId=++this.maxBucketInstanceId),s.addBucket(l.tileID,c,this.crossTileIDs)&&(n=!0),a[c.bucketInstanceId]=!0)}return s.removeStaleBuckets(a)&&(n=!0),n}pruneUnusedLayers(e){const r={};e.forEach(i=>{r[i]=!0});for(const i in this.layerIndexes)r[i]||delete this.layerIndexes[i]}}var Fx=`
8
+ Use an identity property function instead: ${p}.`)]}const d=[];if(t.layerType==="symbol")a!=="text-field"||!i||i.glyphs||i.imports||d.push(new be(r,n,'use of "text-field" requires a style "glyphs" property')),a==="text-font"&&pl(so(n))&&cr(n.type)==="identity"&&d.push(new be(r,n,'"text-font" does not support identity functions'));else if(t.layerType==="model"&&e==="paint"&&o&&o.layout&&o.layout.hasOwnProperty("model-id")&&fs(u)&&(tm(u)||uh(u))){const p=fh(so(n),u),f=p.value.expression||p.value._styleExpression.expression;f&&!Ws(f,["measure-light"])&&(a==="model-emissive-strength"&&Hs(f)&&Wn(f)||d.push(new be(r,n,`${a} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return d.concat(Sr({key:t.key,value:n,valueSpec:u,style:i,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function mm(t){return fm(t,"paint")}function _m(t){return fm(t,"layout")}function gm(t){let e=[];const r=t.value,i=t.key,o=t.style,s=t.styleSpec;r.type||r.ref||e.push(new be(i,r,'either "type" or "ref" is required'));let n=cr(r.type);const a=cr(r.ref);if(r.id){const l=cr(r.id);for(let c=0;c<t.arrayIndex;c++){const u=o.layers[c];cr(u.id)===l&&e.push(new be(i,r.id,`duplicate layer id "${r.id}", previously used at line ${u.id.__line__}`))}}if("ref"in r){let l;["type","source","source-layer","filter","layout"].forEach(c=>{c in r&&e.push(new be(i,r[c],`"${c}" is prohibited for ref layers`))}),o.layers.forEach(c=>{cr(c.id)===a&&(l=c)}),l?l.ref?e.push(new be(i,r.ref,"ref cannot reference another ref layer")):n=cr(l.type):typeof a=="string"&&e.push(new be(i,r.ref,`ref layer "${a}" not found`))}else if(n!=="background"&&n!=="sky"&&n!=="slot")if(r.source){const l=o.sources&&o.sources[r.source],c=l&&cr(l.type);l?c==="vector"&&n==="raster"?e.push(new be(i,r.source,`layer "${r.id}" requires a raster source`)):c==="raster"&&n!=="raster"?e.push(new be(i,r.source,`layer "${r.id}" requires a vector source`)):c!=="vector"||r["source-layer"]?c==="raster-dem"&&n!=="hillshade"?e.push(new be(i,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):n!=="line"||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||c==="geojson"&&l.lineMetrics||e.push(new be(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new be(i,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new be(i,r.source,`source "${r.source}" not found`))}else e.push(new be(i,r,'missing required property "source"'));return e=e.concat(pi({key:i,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Sr({key:`${i}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:l=>gh(oo({layerType:n},l)),layout:l=>pi({layer:r,key:l.key,value:l.value,valueSpec:{},style:l.style,styleSpec:l.styleSpec,objectElementValidators:{"*":c=>_m(oo({layerType:n},c))}}),paint:l=>pi({layer:r,key:l.key,value:l.value,valueSpec:{},style:l.style,styleSpec:l.styleSpec,objectElementValidators:{"*":c=>mm(oo({layerType:n,layer:r},c))}})}})),e}function Ks(t){const e=t.value,r=t.key,i=Tt(e);return i!=="string"?[new be(r,e,`string expected, ${i} found`)]:[]}const ym={promoteId:function({key:t,value:e}){if(Tt(e)==="string")return Ks({key:t,value:e});{const r=[];for(const i in e)r.push(...Ks({key:`${t}.${i}`,value:e[i]}));return r}}};function xm(t){const e=t.value,r=t.key,i=t.styleSpec,o=t.style;if(!e.type)return[new be(r,e,'"type" is required')];const s=cr(e.type);let n=[];switch(["vector","raster","raster-dem"].includes(s)&&(e.url||e.tiles||n.push(new be(r,e,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":return n=n.concat(pi({key:r,value:e,valueSpec:i[`source_${s.replace("-","_")}`],style:t.style,styleSpec:i,objectElementValidators:ym})),n;case"geojson":if(n=pi({key:r,value:e,valueSpec:i.source_geojson,style:o,styleSpec:i,objectElementValidators:ym}),e.cluster)for(const a in e.clusterProperties){const[l,c]=e.clusterProperties[a],u=typeof l=="string"?[l,["accumulated"],["get",a]]:l;n.push(...ms({key:`${r}.${a}.map`,value:c,expressionContext:"cluster-map"})),n.push(...ms({key:`${r}.${a}.reduce`,value:u,expressionContext:"cluster-reduce"}))}return n;case"video":return pi({key:r,value:e,valueSpec:i.source_video,style:o,styleSpec:i});case"image":return pi({key:r,value:e,valueSpec:i.source_image,style:o,styleSpec:i});case"canvas":return[new be(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gl({key:`${r}.type`,value:e.type,valueSpec:{values:Kv(i)},style:o,styleSpec:i})}}function Kv(t){return t.source.reduce((e,r)=>{const i=t[r];return i.type.type==="enum"&&(e=e.concat(Object.keys(i.type.values))),e},[])}function vm(t){const e=t.value;let r=[];if(!e)return r;const i=Tt(e);return i!=="string"?(r=r.concat([new be(t.key,e,`string expected, "${i}" found`)]),r):(function(o){const s=o.indexOf("://")===-1;try{return new URL(o,s?"http://example.com":void 0),!0}catch{return!1}}(e)||(r=r.concat([new be(t.key,e,`invalid url "${e}"`)])),r)}function bm(t){const e=t.value,r=t.styleSpec,i=r.light,o=t.style;let s=[];const n=Tt(e);if(e===void 0)return s;if(n!=="object")return s=s.concat([new be("light",e,`object expected, ${n} found`)]),s;for(const a in e){const l=a.match(/^(.*)-transition$/);s=s.concat(l&&i[l[1]]&&i[l[1]].transition?Sr({key:a,value:e[a],valueSpec:r.transition,style:o,styleSpec:r}):i[a]?Sr({key:a,value:e[a],valueSpec:i[a],style:o,styleSpec:r}):[new be(a,e[a],`unknown property "${a}"`)])}return s}function wm(t){const e=t.value;let r=[];if(!e)return r;const i=Tt(e);if(i!=="object")return r=r.concat([new be("light-3d",e,`object expected, ${i} found`)]),r;const o=t.styleSpec,s=o["light-3d"],n=t.key,a=t.style,l=t.style.lights;for(const h of["type","id"])if(!(h in e))return r=r.concat([new be("light-3d",e,`missing property ${h} on light`)]),r;if(e.type&&l)for(let h=0;h<t.arrayIndex;h++){const d=cr(e.type),p=l[h];cr(p.type)===d&&r.push(new be(n,e.id,`duplicate light type "${e.type}", previously defined at line ${p.id.__line__}`))}const c=`properties_light_${e.type}`;if(!(c in o))return r=r.concat([new be("light-3d",e,`Invalid light type ${e.type}`)]),r;const u=o[c];for(const h in e)if(h==="properties"){const d=e[h],p=Tt(d);if(p!=="object")return r=r.concat([new be("properties",d,`object expected, ${p} found`)]),r;for(const f in d)r=r.concat(u[f]?Sr({key:f,value:d[f],valueSpec:u[f],style:a,styleSpec:o}):[new ls(t.key,d[f],`unknown property "${f}"`)])}else{const d=h.match(/^(.*)-transition$/);r=r.concat(d&&s[d[1]]&&s[d[1]].transition?Sr({key:h,value:e[h],valueSpec:o.transition,style:a,styleSpec:o}):s[h]?Sr({key:h,value:e[h],valueSpec:s[h],style:a,styleSpec:o}):[new ls(h,e[h],`unknown property "${h}"`)])}return r}function Tm(t){const e=t.value,r=t.key,i=t.style,o=t.styleSpec,s=o.terrain;let n=[];const a=Tt(e);if(e===void 0||a==="null")return n;if(a!=="object")return n=n.concat([new be("terrain",e,`object expected, ${a} found`)]),n;for(const l in e){const c=l.match(/^(.*)-transition$/);n=n.concat(c&&s[c[1]]&&s[c[1]].transition?Sr({key:l,value:e[l],valueSpec:o.transition,style:i,styleSpec:o}):s[l]?Sr({key:l,value:e[l],valueSpec:s[l],style:i,styleSpec:o}):[new ls(l,e[l],`unknown property "${l}"`)])}if(e.source){const l=i.sources&&i.sources[e.source],c=l&&cr(l.type);l?c!=="raster-dem"&&n.push(new be(r,e.source,`terrain cannot be used with a source of type ${String(c)}, it only be used with a "raster-dem" source type`)):n.push(new be(r,e.source,`source "${e.source}" not found`))}else n.push(new be(r,e,'terrain is missing required property "source"'));return n}function Em(t){const e=t.value,r=t.style,i=t.styleSpec,o=i.fog;let s=[];const n=Tt(e);if(e===void 0)return s;if(n!=="object")return s=s.concat([new be("fog",e,`object expected, ${n} found`)]),s;for(const a in e){const l=a.match(/^(.*)-transition$/);s=s.concat(l&&o[l[1]]&&o[l[1]].transition?Sr({key:a,value:e[a],valueSpec:i.transition,style:r,styleSpec:i}):o[a]?Sr({key:a,value:e[a],valueSpec:o[a],style:r,styleSpec:i}):[new ls(a,e[a],`unknown property "${a}"`)])}return s}const Mm={"*":()=>[],array:om,boolean:function(t){const e=t.value,r=t.key,i=Tt(e);return i!=="boolean"?[new be(r,e,`boolean expected, ${i} found`)]:[]},number:sm,color:function(t){const e=t.key,r=t.value,i=Tt(r);return i!=="string"?[new be(e,r,`color expected, ${i} found`)]:wu(r)===null?[new be(e,r,`color expected, "${r}" found`)]:[]},enum:gl,filter:gh,function:nm,layer:gm,object:pi,source:xm,model:vm,light:bm,"light-3d":wm,terrain:Tm,fog:Em,string:Ks,formatted:function(t){return Ks(t).length===0?[]:ms(t)},resolvedImage:function(t){return Ks(t).length===0?[]:ms(t)},projection:function(t){const e=t.value,r=t.styleSpec,i=r.projection,o=t.style;let s=[];const n=Tt(e);if(n==="object")for(const a in e)s=s.concat(Sr({key:a,value:e[a],valueSpec:i[a],style:o,styleSpec:r}));else n!=="string"&&(s=s.concat([new be("projection",e,`object or string expected, ${n} found`)]));return s},import:function(t){const{value:e,styleSpec:r}=t,{data:i,...o}=e;Object.defineProperty(o,"__line__",{value:e.__line__,enumerable:!1});let s=pi(oo({},t,{value:o,valueSpec:r.import}));return cr(o.id)===""&&s.push(new be(`${t.key}.id`,o,"import id can't be an empty string")),i&&(s=s.concat(Sm(i,r,{key:`${t.key}.data`}))),s}};function Sr(t,e=!1){const r=t.value,i=t.valueSpec,o=t.styleSpec;if(i.expression&&pl(cr(r)))return nm(t);if(i.expression&&fl(so(r)))return ms(t);if(i.type&&Mm[i.type]){const s=Mm[i.type](t);return e===!0&&s.length>0&&Tt(t.value)==="array"?ms(t):s}return pi(oo({},t,{valueSpec:i.type?o[i.type]:i}))}function Qv(t){const e=t.value,r=t.key,i=Ks(t);return i.length||(e.indexOf("{fontstack}")===-1&&i.push(new be(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&i.push(new be(r,e,'"glyphs" url must include a "{range}" token'))),i}function Sm(t,e=j,r={}){return Sr({key:r.key||"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Qv,"*":()=>[]}})}function Qs(t,e=j){return Si(Sm(t,e))}const eb=t=>Si(xm(t)),tb=t=>Si(bm(t)),rb=t=>Si(wm(t)),ib=t=>Si(Tm(t)),ob=t=>Si(Em(t)),sb=t=>Si(gm(t)),yh=t=>Si(gh(t)),nb=t=>Si(mm(t)),ab=t=>Si(_m(t)),lb=t=>Si(vm(t));function Si(t){return t.slice().sort((e,r)=>e.line&&r.line?e.line-r.line:0)}function bl(t,e){let r=!1;if(e&&e.length)for(const i of e)i instanceof ls?F(i.message):(t.fire(new Ue(new Error(i.message))),r=!0);return r}var cb=Gi,Io=3;function Gi(t,e,r){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(e=o[1])+2*(r=o[2]);for(var s=0;s<this.d*this.d;s++){var n=o[Io+s],a=o[Io+s+1];i.push(n===a?null:o.subarray(n,a))}var l=o[Io+i.length+1];this.keys=o.subarray(o[Io+i.length],l),this.bboxes=o.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=r,this.scale=e/t,this.uid=0;var u=r/e*t;this.min=-u,this.max=t+u}Gi.prototype.insert=function(t,e,r,i,o){this._forEachCell(e,r,i,o,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(o)},Gi.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Gi.prototype._insertCell=function(t,e,r,i,o,s){this.cells[o].push(s)},Gi.prototype.query=function(t,e,r,i,o){var s=this.min,n=this.max;if(t<=s&&e<=s&&n<=r&&n<=i&&!o)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,r,i,this._queryCell,a,{},o),a},Gi.prototype._queryCell=function(t,e,r,i,o,s,n,a){var l=this.cells[o];if(l!==null)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var d=l[h];if(n[d]===void 0){var p=4*d;(a?a(u[p+0],u[p+1],u[p+2],u[p+3]):t<=u[p+2]&&e<=u[p+3]&&r>=u[p+0]&&i>=u[p+1])?(n[d]=!0,s.push(c[d])):n[d]=!1}}},Gi.prototype._forEachCell=function(t,e,r,i,o,s,n,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(r),h=this._convertToCellCoord(i),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&o.call(this,t,e,r,i,f,s,n,a))return}},Gi.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Gi.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Gi.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Io+this.cells.length+1+1,r=0,i=0;i<this.cells.length;i++)r+=this.cells[i].length;var o=new Int32Array(e+r+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;for(var s=e,n=0;n<t.length;n++){var a=t[n];o[Io+n]=s,o.set(a,s),s+=a.length}return o[Io+t.length]=s,o.set(this.keys,s),o[Io+t.length+1]=s+=this.keys.length,o.set(this.bboxes,s),s+=this.bboxes.length,o.buffer};var en=li(cb);const wl={};function Ee(t,e,r={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),wl[e]={klass:t,omit:r.omit||[]}}Ee(Object,"Object"),en.serialize=function(t,e){const r=t.toArrayBuffer();return e&&e.add(r),{buffer:r}},en.deserialize=function(t){return new en(t.buffer)},Object.defineProperty(en,"name",{value:"Grid"}),Ee(en,"Grid"),Ee(Qe,"Color"),Ee(Error,"Error"),Ee(Q,"AJAXError"),Ee(di,"ResolvedImage"),Ee(ml,"StylePropertyFunction"),Ee(dh,"StyleExpression",{omit:["_evaluator"]}),Ee(Ao,"ZoomDependentExpression"),Ee(ph,"ZoomConstantExpression"),Ee(Vi,"CompoundExpression",{omit:["_evaluate"]});for(const t in Jn)wl[Jn[t]._classRegistryKey]||Ee(Jn[t],`Expression${t}`);function Am(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&t.constructor.name==="ArrayBuffer")}function Im(t){return $.ImageBitmap&&t instanceof $.ImageBitmap}function tn(t,e){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Am(t)||Im(t))return e&&e.add(t),t;if(ArrayBuffer.isView(t)){const r=t;return e&&e.add(r.buffer),r}if(t instanceof $.ImageData)return e&&e.add(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const i of t)r.push(tn(i,e));return r}if(t instanceof Map){const r={$name:"Map"};for(const[i,o]of t.entries())r[i]=tn(o);return r}if(typeof t=="object"){const r=t.constructor,i=r._classRegistryKey;if(!i)throw new Error(`can't serialize object of unregistered class ${i}`);const o=r.serialize?r.serialize(t,e):{};if(!r.serialize){for(const s in t)t.hasOwnProperty(s)&&(wl[i].omit.indexOf(s)>=0||(o[s]=tn(t[s],e)));t instanceof Error&&(o.message=t.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(o.$name=i),o}throw new Error("can't serialize object of type "+typeof t)}function rn(t){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Am(t)||Im(t)||ArrayBuffer.isView(t)||t instanceof $.ImageData)return t;if(Array.isArray(t))return t.map(rn);if(typeof t=="object"){const e=t.$name||"Object";if(e==="Map"){const o=new Map;for(const s of Object.keys(t))s!=="$name"&&o.set(s,rn(t[s]));return o}const{klass:r}=wl[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const i=Object.create(r.prototype);for(const o of Object.keys(t))o!=="$name"&&(i[o]=rn(t[o]));return i}throw new Error("can't deserialize object of type "+typeof t)}const Ae={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function xh(t){for(const e of t)if(vh(e.charCodeAt(0)))return!0;return!1}function ub(t){for(const e of t)if(!hb(e.charCodeAt(0)))return!1;return!0}function hb(t){return!(Ae.Arabic(t)||Ae["Arabic Supplement"](t)||Ae["Arabic Extended-A"](t)||Ae["Arabic Presentation Forms-A"](t)||Ae["Arabic Presentation Forms-B"](t))}function vh(t){return!(t!==746&&t!==747&&(t<4352||!(Ae["Bopomofo Extended"](t)||Ae.Bopomofo(t)||Ae["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Ae["CJK Compatibility Ideographs"](t)||Ae["CJK Compatibility"](t)||Ae["CJK Radicals Supplement"](t)||Ae["CJK Strokes"](t)||!(!Ae["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||Ae["CJK Unified Ideographs Extension A"](t)||Ae["CJK Unified Ideographs"](t)||Ae["Enclosed CJK Letters and Months"](t)||Ae["Hangul Compatibility Jamo"](t)||Ae["Hangul Jamo Extended-A"](t)||Ae["Hangul Jamo Extended-B"](t)||Ae["Hangul Jamo"](t)||Ae["Hangul Syllables"](t)||Ae.Hiragana(t)||Ae["Ideographic Description Characters"](t)||Ae.Kanbun(t)||Ae["Kangxi Radicals"](t)||Ae["Katakana Phonetic Extensions"](t)||Ae.Katakana(t)&&t!==12540||!(!Ae["Halfwidth and Fullwidth Forms"](t)||t===65288||t===65289||t===65293||t>=65306&&t<=65310||t===65339||t===65341||t===65343||t>=65371&&t<=65503||t===65507||t>=65512&&t<=65519)||!(!Ae["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Ae["Unified Canadian Aboriginal Syllabics"](t)||Ae["Unified Canadian Aboriginal Syllabics Extended"](t)||Ae["Vertical Forms"](t)||Ae["Yijing Hexagram Symbols"](t)||Ae["Yi Syllables"](t)||Ae["Yi Radicals"](t))))}function Cm(t){return!(vh(t)||function(e){return!!(Ae["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ae["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ae["Letterlike Symbols"](e)||Ae["Number Forms"](e)||Ae["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ae["Control Pictures"](e)&&e!==9251||Ae["Optical Character Recognition"](e)||Ae["Enclosed Alphanumerics"](e)||Ae["Geometric Shapes"](e)||Ae["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ae["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ae["CJK Symbols and Punctuation"](e)||Ae.Katakana(e)||Ae["Private Use Area"](e)||Ae["CJK Compatibility Forms"](e)||Ae["Small Form Variants"](e)||Ae["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(t))}function zm(t){return t>=1424&&t<=2303||Ae["Arabic Presentation Forms-A"](t)||Ae["Arabic Presentation Forms-B"](t)}function db(t,e){return!(!e&&zm(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Ae.Khmer(t))}function pb(t){for(const e of t)if(zm(e.charCodeAt(0)))return!0;return!1}const bh="deferred",wh="loading",Th="loaded";let Eh=null,Hr="unavailable",Co=null;const Dm=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(Hr="error"),Eh&&Eh(t)};function Mh(){Sh.fire(new ae("pluginStateChange",{pluginStatus:Hr,pluginURL:Co}))}const Sh=new or,Ah=function(){return Hr},km=function(){if(Hr!==bh||!Co)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Hr=wh,Mh(),Co&&fe({url:Co},t=>{t?Dm(t):(Hr=Th,Mh())})},fi={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Hr===Th||fi.applyArabicShaping!=null,isLoading:()=>Hr===wh,setState(t){Hr=t.pluginStatus,Co=t.pluginURL},isParsed:()=>fi.applyArabicShaping!=null&&fi.processBidirectionalText!=null&&fi.processStyledBidirectionalText!=null,getPluginURL:()=>Co};class Ut{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.transition=r.transition,this.pitch=r.pitch,this.brightness=r.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(r,i){for(const o of r)if(!db(o.charCodeAt(0),i))return!1;return!0}(e,fi.isLoaded())}}class Tl{constructor(e,r,i){this.property=e,this.value=r,this.expression=function(o,s,n){if(pl(o))return new ml(o,s);if(fl(o)||Array.isArray(o)&&o.length>0){const a=fh(o,s,n);if(a.result==="error")throw new Error(a.value.map(l=>`${l.key}: ${l.message}`).join(", "));return a.value}{let a=o;return typeof o=="string"&&s.type==="color"&&(a=Qe.parse(o)),{kind:"constant",isConfigDependent:!1,evaluate:()=>a}}}(r===void 0?e.specification.default:r,e.specification,i)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,i){return this.property.possiblyEvaluate(this,e,r,i)}}class Ih{constructor(e,r){this.property=e,this.value=new Tl(e,void 0,r)}transitioned(e,r){return new Pm(this.property,this.value,r,Te({},e.transition,this.transition),e.now)}untransitioned(){return new Pm(this.property,this.value,null,{},0)}}class Qn{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._options=r,this.isConfigDependent=!1}getValue(e){return z(this._values[e].value.value)}setValue(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Ih(this._values[e].property,this._options)),this._values[e].value=new Tl(this._values[e].property,r===null?void 0:z(r),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,r){r&&(this._options=r);const i=this._properties.properties;if(e)for(const o in e){const s=e[o];if(Bs(o,"-transition")){const n=o.slice(0,-11);i[n]&&this.setTransition(n,s)}else i[o]&&this.setValue(o,s)}}getTransition(e){return z(this._values[e].transition)}setTransition(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Ih(this._values[e].property)),this._values[e].transition=z(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const i=this.getValue(r);i!==void 0&&(e[r]=i);const o=this.getTransition(r);o!==void 0&&(e[`${r}-transition`]=o)}return e}transitioned(e,r){const i=new Rm(this._properties);for(const o of Object.keys(this._values))i._values[o]=this._values[o].transitioned(e,r._values[o]);return i}untransitioned(){const e=new Rm(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Pm{constructor(e,r,i,o,s){const n=o.delay||0,a=o.duration||0;s=s||0,this.property=e,this.value=r,this.begin=s+n,this.end=this.begin+a,e.specification.transition&&(o.delay||o.duration)&&(this.prior=i)}possiblyEvaluate(e,r,i){const o=e.now||0,s=this.value.possiblyEvaluate(e,r,i),n=this.prior;if(n){if(o>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(o<this.begin)return n.possiblyEvaluate(e,r,i);{const a=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,r,i),s,Rs(a))}}return s}}class Rm{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,i){const o=new ea(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(e,r,i);return o}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class fb{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._options=r,this.isConfigDependent=!1}getValue(e){return z(this._values[e].value)}setValue(e,r){this._values[e]=new Tl(this._values[e].property,r===null?void 0:z(r),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].expression.isConfigDependent}serialize(){const e={};for(const r of Object.keys(this._values)){const i=this.getValue(r);i!==void 0&&(e[r]=i)}return e}possiblyEvaluate(e,r,i){const o=new ea(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(e,r,i);return o}}class on{constructor(e,r,i){this.property=e,this.value=r,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,i,o){return this.property.evaluate(this.value,this.parameters,e,r,i,o)}}class ea{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class se{constructor(e){this.specification=e}possiblyEvaluate(e,r){return e.expression.evaluate(r)}interpolate(e,r,i){const o=cl[this.specification.type];return o?o(e,r,i):e}}class ke{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,i,o){return new on(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},i,o)}:e.expression,r)}interpolate(e,r,i){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new on(this,{kind:"constant",value:void 0},e.parameters);const o=cl[this.specification.type];return o?new on(this,{kind:"constant",value:o(e.value.value,r.value.value,i)},e.parameters):e}evaluate(e,r,i,o,s,n){return e.kind==="constant"?e.value:e.evaluate(r,i,o,s,n)}}class ta{constructor(e){this.specification=e}possiblyEvaluate(e,r,i,o){return!!e.expression.evaluate(r,null,{},i,o)}interpolate(){return!1}}class Xt{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const r=new Ut(0,{});for(const i in e){const o=e[i];o.specification.overridable&&this.overridableProperties.push(i);const s=this.defaultPropertyValues[i]=new Tl(o,void 0),n=this.defaultTransitionablePropertyValues[i]=new Ih(o);this.defaultTransitioningPropertyValues[i]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=s.possiblyEvaluate(r)}}}Ee(ke,"DataDrivenProperty"),Ee(se,"DataConstantProperty"),Ee(ta,"ColorRampProperty");const El="";function Lm(t){return t.indexOf(El)>=0}function Dr(t,e){return e?`${t}${El}${e}`:t}function Ml(t){const e=t.indexOf(El);return e>=0?t.slice(0,e):t}const Bm="-transition";class ri extends or{constructor(e,r,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this.options=i,e.slot&&(this.slot=e.slot),r.layout&&(this._unevaluatedLayout=new fb(r.layout,i),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),r.paint)){this._transitionablePaint=new Qn(r.paint,i);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ea(r.paint)}}setScope(e){this.scope=e,this.fqid=Dr(this.id,e)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,i={}){if(r!=null&&this._validate(ab,`layers.${this.id}.layout.${e}`,e,r,i))return;if(this.type==="custom"&&e==="visibility")return void(this.visibility=r);const o=this._unevaluatedLayout;o._properties.properties[e]&&(o.setValue(e,r),this.isConfigDependent=this.isConfigDependent||o.isConfigDependent,e==="visibility"&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return Bs(e,Bm)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,i={}){if(r!=null&&this._validate(nb,`layers.${this.id}.paint.${e}`,e,r,i))return!1;const o=this._transitionablePaint,s=o._properties.properties;if(Bs(e,Bm)){const d=e.slice(0,-11);return s[d]&&o.setTransition(d,r||void 0),!1}if(!s[e])return!1;const n=o._values[e],a=n.value.isDataDriven(),l=n.value;o.setValue(e,r),this.isConfigDependent=this.isConfigDependent||o.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const c=o._values[e].value,u=c.isDataDriven(),h=Bs(e,"pattern")||e==="line-dasharray";return u||a||h||this._handleOverridablePaintPropertyUpdate(e,l,c)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,r){return null}_handleOverridablePaintPropertyUpdate(e,r,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){return le({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,r)=>!(e===void 0||r==="layout"&&!Object.keys(e).length||r==="paint"&&!Object.keys(e).length))}_validate(e,r,i,o,s={}){return(!s||s.validate!==!1)&&bl(this,e.call(Qs,{key:r,layerType:this.type,objectKey:i,value:o,styleSpec:j,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof on&&fs(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=yl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(){this._stats&&(this._stats.numRenderedVerticesInShadowPass=0,this._stats.numRenderedVerticesInTransparentPass=0)}}class mb{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(e,r){this._updatedSourceCaches[e]=r,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const r=e.scope;this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._updatedLayers[r].add(e.id),this.setDirty()}removeLayer(e){const r=e.scope;this._removedLayers[r]=this._removedLayers[r]||{},this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._removedLayers[r][e.id]=e,this._updatedLayers[r].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const r in this._updatedLayers)e[r]=e[r]||{},e[r].updatedIds=Array.from(this._updatedLayers[r].values());for(const r in this._removedLayers)e[r]=e[r]||{},e[r].removedIds=Object.keys(this._removedLayers[r]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}const _b={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Sl{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Vt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function xt(t,e=1){let r=0,i=0;return{members:t.map(o=>{const s=_b[o.type].BYTES_PER_ELEMENT,n=r=Om(r,Math.max(e,s)),a=o.components||1;return i=Math.max(i,s),r+=s*a,{name:o.name,type:o.type,components:a,offset:n}}),size:Om(r,Math.max(i,e)),alignment:e}}function Om(t,e){return Math.ceil(t/e)*e}class Wr extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.int16[o+0]=r,this.int16[o+1]=i,e}}Wr.prototype.bytesPerElement=4,Ee(Wr,"StructArrayLayout2i4");class Al extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.int16[s+0]=r,this.int16[s+1]=i,this.int16[s+2]=o,e}}Al.prototype.bytesPerElement=6,Ee(Al,"StructArrayLayout3i6");class _s extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.int16[n+0]=r,this.int16[n+1]=i,this.int16[n+2]=o,this.int16[n+3]=s,e}}_s.prototype.bytesPerElement=8,Ee(_s,"StructArrayLayout4i8");class Ch extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=5*e;return this.int16[a+0]=r,this.int16[a+1]=i,this.int16[a+2]=o,this.int16[a+3]=s,this.int16[a+4]=n,e}}Ch.prototype.bytesPerElement=10,Ee(Ch,"StructArrayLayout5i10");class zh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=6*e,u=12*e,h=3*e;return this.int16[c+0]=r,this.int16[c+1]=i,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=n,this.uint8[u+7]=a,this.float32[h+2]=l,e}}zh.prototype.bytesPerElement=12,Ee(zh,"StructArrayLayout2i4ub1f12");class lo extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.float32[n+0]=r,this.float32[n+1]=i,this.float32[n+2]=o,this.float32[n+3]=s,e}}lo.prototype.bytesPerElement=16,Ee(lo,"StructArrayLayout4f16");class zo extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=6*e,l=3*e;return this.uint16[a+0]=r,this.uint16[a+1]=i,this.uint16[a+2]=o,this.uint16[a+3]=s,this.float32[l+2]=n,e}}zo.prototype.bytesPerElement=12,Ee(zo,"StructArrayLayout4ui1f12");class Il extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=4*e;return this.uint16[n+0]=r,this.uint16[n+1]=i,this.uint16[n+2]=o,this.uint16[n+3]=s,e}}Il.prototype.bytesPerElement=8,Ee(Il,"StructArrayLayout4ui8");class Cl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,i,o,s,n)}emplace(e,r,i,o,s,n,a){const l=6*e;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=o,this.int16[l+3]=s,this.int16[l+4]=n,this.int16[l+5]=a,e}}Cl.prototype.bytesPerElement=12,Ee(Cl,"StructArrayLayout6i12");class Dh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,i,o,s,n,a,l,c,u,h,d)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p){const f=12*e;return this.int16[f+0]=r,this.int16[f+1]=i,this.int16[f+2]=o,this.int16[f+3]=s,this.uint16[f+4]=n,this.uint16[f+5]=a,this.uint16[f+6]=l,this.uint16[f+7]=c,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=d,this.int16[f+11]=p,e}}Dh.prototype.bytesPerElement=24,Ee(Dh,"StructArrayLayout4i4ui4i24");class kh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,i,o,s,n)}emplace(e,r,i,o,s,n,a){const l=10*e,c=5*e;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=o,this.float32[c+2]=s,this.float32[c+3]=n,this.float32[c+4]=a,e}}kh.prototype.bytesPerElement=20,Ee(kh,"StructArrayLayout3i3f20");class Ph extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Ph.prototype.bytesPerElement=4,Ee(Ph,"StructArrayLayout1ul4");class Do extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.uint16[o+0]=r,this.uint16[o+1]=i,e}}Do.prototype.bytesPerElement=4,Ee(Do,"StructArrayLayout2ui4");class Rh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,i,o,s,n,a,l,c,u,h,d,p)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f){const m=20*e,_=10*e;return this.int16[m+0]=r,this.int16[m+1]=i,this.int16[m+2]=o,this.int16[m+3]=s,this.int16[m+4]=n,this.float32[_+3]=a,this.float32[_+4]=l,this.float32[_+5]=c,this.float32[_+6]=u,this.int16[m+14]=h,this.uint32[_+8]=d,this.uint16[m+18]=p,this.uint16[m+19]=f,e}}Rh.prototype.bytesPerElement=40,Ee(Rh,"StructArrayLayout5i4f1i1ul2ui40");class zl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=8*e;return this.int16[c+0]=r,this.int16[c+1]=i,this.int16[c+2]=o,this.int16[c+4]=s,this.int16[c+5]=n,this.int16[c+6]=a,this.int16[c+7]=l,e}}zl.prototype.bytesPerElement=16,Ee(zl,"StructArrayLayout3i2i2i16");class Lh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=4*e,l=8*e;return this.float32[a+0]=r,this.float32[a+1]=i,this.float32[a+2]=o,this.int16[l+6]=s,this.int16[l+7]=n,e}}Lh.prototype.bytesPerElement=16,Ee(Lh,"StructArrayLayout2f1f2i16");class Bh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=12*e,a=3*e;return this.uint8[n+0]=r,this.uint8[n+1]=i,this.float32[a+1]=o,this.float32[a+2]=s,e}}Bh.prototype.bytesPerElement=12,Ee(Bh,"StructArrayLayout2ub2f12");class nr extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.uint16[s+0]=r,this.uint16[s+1]=i,this.uint16[s+2]=o,e}}nr.prototype.bytesPerElement=6,Ee(nr,"StructArrayLayout3ui6");class Oh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w){const T=30*e,E=15*e,M=60*e;return this.int16[T+0]=r,this.int16[T+1]=i,this.int16[T+2]=o,this.float32[E+2]=s,this.float32[E+3]=n,this.uint16[T+8]=a,this.uint16[T+9]=l,this.uint32[E+5]=c,this.uint32[E+6]=u,this.uint32[E+7]=h,this.uint16[T+16]=d,this.uint16[T+17]=p,this.uint16[T+18]=f,this.float32[E+10]=m,this.float32[E+11]=_,this.uint8[M+48]=g,this.uint8[M+49]=y,this.uint8[M+50]=v,this.uint32[E+13]=b,this.int16[T+28]=x,this.uint8[M+58]=w,e}}Oh.prototype.bytesPerElement=60,Ee(Oh,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Fh extends Vt{_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,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O){const U=this.length;return this.resize(U+1),this.emplace(U,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C,k,A,L,O,U){const R=20*e,B=40*e,G=80*e;return this.float32[R+0]=r,this.float32[R+1]=i,this.int16[B+4]=o,this.int16[B+5]=s,this.int16[B+6]=n,this.int16[B+7]=a,this.int16[B+8]=l,this.int16[B+9]=c,this.int16[B+10]=u,this.int16[B+11]=h,this.int16[B+12]=d,this.uint16[B+13]=p,this.uint16[B+14]=f,this.uint16[B+15]=m,this.uint16[B+16]=_,this.uint16[B+17]=g,this.uint16[B+18]=y,this.uint16[B+19]=v,this.uint16[B+20]=b,this.uint16[B+21]=x,this.uint16[B+22]=w,this.uint16[B+23]=T,this.uint16[B+24]=E,this.uint16[B+25]=M,this.uint16[B+26]=S,this.uint16[B+27]=I,this.uint32[R+14]=C,this.float32[R+15]=k,this.float32[R+16]=A,this.float32[R+17]=L,this.float32[R+18]=O,this.uint8[G+76]=U,e}}Fh.prototype.bytesPerElement=80,Ee(Fh,"StructArrayLayout2f9i15ui1ul4f1ub80");class ra extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}ra.prototype.bytesPerElement=4,Ee(ra,"StructArrayLayout1f4");class gs extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s){const n=this.length;return this.resize(n+1),this.emplace(n,e,r,i,o,s)}emplace(e,r,i,o,s,n){const a=5*e;return this.float32[a+0]=r,this.float32[a+1]=i,this.float32[a+2]=o,this.float32[a+3]=s,this.float32[a+4]=n,e}}gs.prototype.bytesPerElement=20,Ee(gs,"StructArrayLayout5f20");class Nh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=7*e;return this.float32[c+0]=r,this.float32[c+1]=i,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=n,this.float32[c+5]=a,this.float32[c+6]=l,e}}Nh.prototype.bytesPerElement=28,Ee(Nh,"StructArrayLayout7f28");class Uh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,r,i,o)}emplace(e,r,i,o,s){const n=6*e;return this.uint32[3*e+0]=r,this.uint16[n+2]=i,this.uint16[n+3]=o,this.uint16[n+4]=s,e}}Uh.prototype.bytesPerElement=12,Ee(Uh,"StructArrayLayout1ul3ui12");class ia extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}ia.prototype.bytesPerElement=2,Ee(ia,"StructArrayLayout1ui2");class ys extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,i)}emplace(e,r,i,o){const s=3*e;return this.float32[s+0]=r,this.float32[s+1]=i,this.float32[s+2]=o,e}}ys.prototype.bytesPerElement=12,Ee(ys,"StructArrayLayout3f12");class oa extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,r)}emplace(e,r,i){const o=2*e;return this.float32[o+0]=r,this.float32[o+1]=i,e}}oa.prototype.bytesPerElement=8,Ee(oa,"StructArrayLayout2f8");class Vh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_)}emplace(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=16*e;return this.float32[y+0]=r,this.float32[y+1]=i,this.float32[y+2]=o,this.float32[y+3]=s,this.float32[y+4]=n,this.float32[y+5]=a,this.float32[y+6]=l,this.float32[y+7]=c,this.float32[y+8]=u,this.float32[y+9]=h,this.float32[y+10]=d,this.float32[y+11]=p,this.float32[y+12]=f,this.float32[y+13]=m,this.float32[y+14]=_,this.float32[y+15]=g,e}}Vh.prototype.bytesPerElement=64,Ee(Vh,"StructArrayLayout16f64");class Dl extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,i,o,s,n,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,i,o,s,n,a)}emplace(e,r,i,o,s,n,a,l){const c=10*e,u=5*e;return this.uint16[c+0]=r,this.uint16[c+1]=i,this.uint16[c+2]=o,this.uint16[c+3]=s,this.float32[u+2]=n,this.float32[u+3]=a,this.float32[u+4]=l,e}}Dl.prototype.bytesPerElement=20,Ee(Dl,"StructArrayLayout4ui3f20");class jh extends Vt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint8[1*e+0]=r,e}}jh.prototype.bytesPerElement=1,Ee(jh,"StructArrayLayout1ub1");class Fm extends Sl{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]}}Fm.prototype.size=40;class Gh extends Rh{get(e){return new Fm(this,e)}}Ee(Gh,"CollisionBoxArray");class Nm extends Sl{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}}Nm.prototype.size=60;class Um extends Oh{get(e){return new Nm(this,e)}}Ee(Um,"PlacedSymbolArray");class Vm extends Sl{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]}}Vm.prototype.size=80;class jm extends Fh{get(e){return new Vm(this,e)}}Ee(jm,"SymbolInstanceArray");class Gm extends ra{getoffsetX(e){return this.float32[1*e+0]}}Ee(Gm,"GlyphOffsetArray");class qm extends Wr{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ee(qm,"SymbolLineVertexArray");class Zm extends Sl{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]}}Zm.prototype.size=12;class $m extends Uh{get(e){return new Zm(this,e)}}Ee($m,"FeatureIndexArray");class Hm extends Do{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ee(Hm,"FillExtrusionCentroidArray");const gb=xt([{name:"a_pos",components:2,type:"Int16"}],4),yb=xt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Et{constructor(e=[]){this.segments=e}_prepareSegment(e,r,i,o){let s=this.segments[this.segments.length-1];return e>Et.MAX_VERTEX_ARRAY_LENGTH&&F(`Max vertices per segment is ${Et.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>Et.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r,primitiveOffset:i,vertexLength:0,primitiveLength:0},o!==void 0&&(s.sortKey=o),this.segments.push(s)),s}prepareSegment(e,r,i,o){return this._prepareSegment(e,r.length,i.length,o)}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,i,o){return new Et([{vertexOffset:e,primitiveOffset:r,vertexLength:i,primitiveLength:o,vaos:{},sortKey:0}])}}function Wm(t,e){return 256*(t=Se(Math.floor(t),0,255))+Se(Math.floor(e),0,255)}Et.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ee(Et,"SegmentVector");const xb=xt([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),vb=xt([{name:"a_dash",components:4,type:"Uint16"}]);var kl={exports:{}},Xm={exports:{}};(function(t){t.exports=function(e,r){var i,o,s,n,a,l,c,u;for(o=e.length-(i=3&e.length),s=r,a=3432918353,l=461845907,u=0;u<o;)c=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,s=27492+(65535&(n=5*(65535&(s=(s^=c=(65535&(c=(c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295)<<15|c>>>17))*l+(((c>>>16)*l&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(c=0,i){case 3:c^=(255&e.charCodeAt(u+2))<<16;case 2:c^=(255&e.charCodeAt(u+1))<<8;case 1:s^=c=(65535&(c=(c=(65535&(c^=255&e.charCodeAt(u)))*a+(((c>>>16)*a&65535)<<16)&4294967295)<<15|c>>>17))*l+(((c>>>16)*l&65535)<<16)&4294967295}return s^=e.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}})(Xm);var bb=Xm.exports,Ym={exports:{}};(function(t){t.exports=function(e,r){for(var i,o=e.length,s=r^o,n=0;o>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),o-=4,++n;switch(o){case 3:s^=(255&e.charCodeAt(n+2))<<16;case 2:s^=(255&e.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&e.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}})(Ym);var Jm=bb,wb=Ym.exports;kl.exports=Jm,kl.exports.murmur3=Jm,kl.exports.murmur2=wb;var qh=li(kl.exports);class sa{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,r,i,o){this.ids.push(Km(e)),this.positions.push(r,i,o)}eachPosition(e,r){const i=Km(e);let o=0,s=this.ids.length-1;for(;o<s;){const n=o+s>>1;this.ids[n]>=i?s=n:o=n+1}for(;this.ids[o]===i;)r(this.positions[3*o],this.positions[3*o+1],this.positions[3*o+2]),o++}static serialize(e,r){const i=new Float64Array(e.ids),o=new Uint32Array(e.positions);return Zh(i,o,0,i.length-1),r&&(r.add(i.buffer),r.add(o.buffer)),{ids:i,positions:o}}static deserialize(e){const r=new sa;let i;r.ids=e.ids,r.positions=e.positions;for(const o of r.ids)o!==i&&r.uniqueIds.push(o),i=o;return r.indexed=!0,r}}function Km(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:qh(String(t))}function Zh(t,e,r,i){for(;r<i;){const o=t[r+i>>1];let s=r-1,n=i+1;for(;;){do s++;while(t[s]<o);do n--;while(t[n]>o);if(s>=n)break;Pl(t,s,n),Pl(e,3*s,3*n),Pl(e,3*s+1,3*n+1),Pl(e,3*s+2,3*n+2)}n-r<i-n?(Zh(t,e,r,n),r=n+1):(Zh(t,e,n+1,i),i=n)}}function Pl(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}Ee(sa,"FeaturePositionMap");class co{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,r){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,r),this.initialized=!0),!!this.location}}class it extends co{constructor(e){super(e),this.current=0}set(e,r,i){this.fetchUniformLocation(e,r)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class re extends co{constructor(e){super(e),this.current=0}set(e,r,i){this.fetchUniformLocation(e,r)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class ot extends co{constructor(e){super(e),this.current=[0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class He extends co{constructor(e){super(e),this.current=[0,0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class Xr extends co{constructor(e){super(e),this.current=[0,0,0,0]}set(e,r,i){this.fetchUniformLocation(e,r)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class sn extends co{constructor(e){super(e),this.current=Qe.transparent}set(e,r,i){this.fetchUniformLocation(e,r)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const Tb=new Float32Array(16);class qe extends co{constructor(e){super(e),this.current=Tb}set(e,r,i){if(this.fetchUniformLocation(e,r)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let o=1;o<16;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const Eb=new Float32Array(9);class $h extends co{constructor(e){super(e),this.current=Eb}set(e,r,i){if(this.fetchUniformLocation(e,r)){for(let o=0;o<9;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}}const Mb=new Float32Array(4);class Hh extends co{constructor(e){super(e),this.current=Mb}set(e,r,i){if(this.fetchUniformLocation(e,r)){for(let o=0;o<4;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}}function Wh(t){return[Wm(255*t.r,255*t.g),Wm(255*t.b,255*t.a)]}class na{constructor(e,r,i){this.value=e,this.uniformNames=r.map(o=>`u_${o}`),this.type=i}setUniform(e,r,i,o,s){r.set(e,s,o.constantOr(this.value))}getBinding(e,r){return this.type==="color"?new sn(e):new re(e)}}class nn{constructor(e,r){this.uniformNames=r.map(i=>`u_${i}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,r,i,o,s){const n=s==="u_pattern"||s==="u_dash"?this.pattern:s==="u_pixel_ratio"?this.pixelRatio:null;n&&r.set(e,s,n)}getBinding(e,r){return r==="u_pattern"||r==="u_dash"?new Xr(e):new re(e)}}class uo{constructor(e,r,i,o){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=r.map(s=>({name:`a_${s}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,r,i,o,s,n,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new Ut(0,{brightness:n}),r,{},s,o,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c)}updatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate({zoom:0,brightness:a},i,o,void 0,s);this._setPaintValue(e,r,l)}_setPaintValue(e,r,i){if(this.type==="color"){const o=Wh(i);for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,o[0],o[1])}else{for(let o=e;o<r;o++)this.paintVertexArray.emplace(o,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}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 Ai{constructor(e,r,i,o,s,n){this.expression=e,this.uniformNames=r.map(a=>`u_${a}_t`),this.type=i,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(a=>({name:`a_${a}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate(new Ut(this.zoom,{brightness:n}),r,{},s,o,a),c=this.expression.evaluate(new Ut(this.zoom+1,{brightness:n}),r,{},s,o,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(u,e,l,c)}updatePaintArray(e,r,i,o,s,n,a){const l=this.expression.evaluate({zoom:this.zoom,brightness:a},i,o,void 0,s),c=this.expression.evaluate({zoom:this.zoom+1,brightness:a},i,o,void 0,s);this._setPaintValue(e,r,l,c)}_setPaintValue(e,r,i,o){if(this.type==="color"){const s=Wh(i),n=Wh(o);for(let a=e;a<r;a++)this.paintVertexArray.emplace(a,s[0],s[1],n[0],n[1])}else{for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,i,o);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(o))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r,i,o,s){const n=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=Se(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);r.set(e,s,a)}getBinding(e,r){return new re(e)}}class ko{constructor(e,r,i,o,s){this.expression=e,this.layerId=s,this.paintVertexAttributes=(i==="array"?vb:xb).members;for(let n=0;n<r.length;++n);this.paintVertexArray=new o}populatePaintArray(e,r,i){const o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(o,e,r.patterns&&r.patterns[this.layerId],i)}updatePaintArray(e,r,i,o,s,n,a){this._setPaintValues(e,r,i.patterns&&i.patterns[this.layerId],n)}_setPaintValues(e,r,i,o){if(!o||!i)return;const s=o[i];if(!s)return;const{tl:n,br:a,pixelRatio:l}=s;for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,n[0],n[1],a[0],a[1],l)}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 xs{constructor(e,r,i=()=>!0){this.binders={},this._buffers=[];const o=[];for(const s in e.paint._values){const n=e.paint.get(s);if(!i(s)||!(n instanceof on&&fs(n.property.specification)))continue;const a=Ab(s,e.type),l=n.value,c=n.property.specification.type,u=!!n.property.useIntegerZoom,h=s==="line-dasharray"||s.endsWith("pattern"),d=s==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(l.kind!=="constant"||d)if(l.kind==="source"||d||h){const p=Qm(s,c,"source");this.binders[s]=h?new ko(l,a,c,p,e.id):new uo(l,a,c,p),o.push(`/a_${s}`)}else{const p=Qm(s,c,"composite");this.binders[s]=new Ai(l,a,c,u,r,p),o.push(`/z_${s}`)}else this.binders[s]=h?new nn(l.value,a):new na(l.value,a,c),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof uo||r instanceof Ai?r.maxValue:0}populatePaintArrays(e,r,i,o,s,n,a){for(const l in this.binders){const c=this.binders[l];(c instanceof uo||c instanceof Ai||c instanceof ko)&&c.populatePaintArray(e,r,i,o,s,n,a)}}setConstantPatternPositions(e){for(const r in this.binders){const i=this.binders[r];i instanceof nn&&i.setConstantPatternPositions(e)}}updatePaintArrays(e,r,i,o,s,n,a,l){let c=!1;const u=Object.keys(e),h=u.length!==0,d=h?u:r.uniqueIds;for(const p in this.binders){const f=this.binders[p];if((f instanceof uo||f instanceof Ai||f instanceof ko)&&(f.expression.isStateDependent===!0||f.expression.isLightConstant===!1)){const m=s.paint.get(p);f.expression=m.value;for(const _ of d){const g=e[_.toString()];r.eachPosition(_,(y,v,b)=>{const x=o.feature(y);f.updatePaintArray(v,b,x,g,n,a,l)})}if(!h)for(const _ of i.uniqueIds){const g=e[_.toString()];i.eachPosition(_,(y,v,b)=>{const x=o.feature(y);f.updatePaintArray(v,b,x,g,n,a,l)})}c=!0}}return c}defines(){const e=[];for(const r in this.binders){const i=this.binders[r];(i instanceof na||i instanceof nn)&&e.push(...i.uniformNames.map(o=>`#define HAS_UNIFORM_${o}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const i=this.binders[r];if(i instanceof uo||i instanceof Ai||i instanceof ko)for(let o=0;o<i.paintVertexAttributes.length;o++)e.push(i.paintVertexAttributes[o].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const i=this.binders[r];if(i instanceof na||i instanceof nn||i instanceof Ai)for(const o of i.uniformNames)e.push(o)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const r=[];for(const i in this.binders){const o=this.binders[i];if(o instanceof na||o instanceof nn||o instanceof Ai)for(const s of o.uniformNames)r.push({name:s,property:i,binding:o.getBinding(e,s)})}return r}setUniforms(e,r,i,o,s){for(const{name:n,property:a,binding:l}of i)this.binders[a].setUniform(e,l,s,o.get(a),n)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const r=this.binders[e];(r instanceof uo||r instanceof Ai||r instanceof ko)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(e){for(const r in this.binders){const i=this.binders[r];(i instanceof uo||i instanceof Ai||i instanceof ko)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof uo||r instanceof Ai||r instanceof ko)&&r.destroy()}}}class Po{constructor(e,r,i=()=>!0){this.programConfigurations={};for(const o of e)this.programConfigurations[o.id]=new xs(o,r,i);this.needsUpload=!1,this._featureMap=new sa,this._featureMapWithoutIds=new sa,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,r,i,o,s,n,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(e,r,o,s,n,a,l);r.id!==void 0?this._featureMap.add(r.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,i,o,s,n){for(const a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,r,a,o,s,n||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Sb={"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 Ab(t,e){return Sb[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Ib={"line-pattern":{source:zo,composite:zo},"fill-pattern":{source:zo,composite:zo},"fill-extrusion-pattern":{source:zo,composite:zo},"line-dasharray":{source:Il,composite:Il}},Cb={color:{source:oa,composite:lo},number:{source:ra,composite:oa}};function Qm(t,e,r){const i=Ib[t];return i&&i[r]||Cb[e][r]}Ee(na,"ConstantBinder"),Ee(nn,"PatternConstantBinder"),Ee(uo,"SourceExpressionBinder"),Ee(ko,"PatternCompositeBinder"),Ee(Ai,"CompositeExpressionBinder"),Ee(xs,"ProgramConfiguration",{omit:["_buffers"]}),Ee(Po,"ProgramConfigurationSet");class Yr{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof 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 r=this._sw,i=this._ne;let o,s;if(e instanceof Ne)o=e,s=e;else{if(!(e instanceof Yr))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Yr.convert(e)):this.extend(Ne.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Ne.convert(e)):this;if(o=e._sw,s=e._ne,!o||!s)return this}return r||i?(r.lng=Math.min(o.lng,r.lng),r.lat=Math.min(o.lat,r.lat),i.lng=Math.max(s.lng,i.lng),i.lat=Math.max(s.lat,i.lat)):(this._sw=new Ne(o.lng,o.lat),this._ne=new Ne(s.lng,s.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:r,lat:i}=Ne.convert(e);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&o}static convert(e){return!e||e instanceof Yr?e:new Yr(e)}}var _r={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.setMatrixArrayType=function(t){gr.ARRAY_TYPE=t_=t},gr.toRadian=function(t){return t*Db},gr.equals=function(t,e){return Math.abs(t-e)<=e_*Math.max(1,Math.abs(t),Math.abs(e))},gr.RANDOM=gr.ARRAY_TYPE=gr.EPSILON=void 0;var e_=1e-6;gr.EPSILON=e_;var t_=typeof Float32Array<"u"?Float32Array:Array;gr.ARRAY_TYPE=t_;var zb=Math.random;gr.RANDOM=zb;var Db=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 jt={};function Xh(t){return Xh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xh(t)}Object.defineProperty(jt,"__esModule",{value:!0}),jt.create=function(){var t=new Ro.ARRAY_TYPE(4);return Ro.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},jt.clone=function(t){var e=new Ro.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},jt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},jt.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},jt.fromValues=function(t,e,r,i){var o=new Ro.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o},jt.set=function(t,e,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t},jt.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},jt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r*s-o*i;return n?(t[0]=s*(n=1/n),t[1]=-i*n,t[2]=-o*n,t[3]=r*n,t):null},jt.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},jt.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},jt.multiply=i_,jt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+s*a,t[1]=o*l+n*a,t[2]=i*-a+s*l,t[3]=o*-a+n*l,t},jt.scale=function(t,e,r){var i=e[1],o=e[2],s=e[3],n=r[0],a=r[1];return t[0]=e[0]*n,t[1]=i*n,t[2]=o*a,t[3]=s*a,t},jt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=-r,t[3]=i,t},jt.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},jt.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},jt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},jt.LDU=function(t,e,r,i){return t[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-t[2]*r[1],[t,e,r]},jt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},jt.subtract=o_,jt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},jt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(r-n)<=Ro.EPSILON*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=Ro.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=Ro.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(s-c)<=Ro.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},jt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},jt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},jt.sub=jt.mul=void 0;var Ro=function(t,e){if(t&&t.__esModule)return t;if(t===null||Xh(t)!=="object"&&typeof t!="function")return{default:t};var r=r_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function r_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(r_=function(i){return i?r:e})(t)}function i_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*a+s*l,t[1]=o*a+n*l,t[2]=i*c+s*u,t[3]=o*c+n*u,t}function o_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}jt.mul=i_,jt.sub=o_;var qt={};function Yh(t){return Yh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yh(t)}Object.defineProperty(qt,"__esModule",{value:!0}),qt.create=function(){var t=new qi.ARRAY_TYPE(6);return qi.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},qt.clone=function(t){var e=new qi.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},qt.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},qt.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},qt.fromValues=function(t,e,r,i,o,s){var n=new qi.ARRAY_TYPE(6);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n[4]=o,n[5]=s,n},qt.set=function(t,e,r,i,o,s,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t},qt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=r*s-i*o;return l?(t[0]=s*(l=1/l),t[1]=-i*l,t[2]=-o*l,t[3]=r*l,t[4]=(o*a-s*n)*l,t[5]=(i*n-r*a)*l,t):null},qt.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},qt.multiply=n_,qt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=Math.sin(r),u=Math.cos(r);return t[0]=i*u+s*c,t[1]=o*u+n*c,t[2]=i*-c+s*u,t[3]=o*-c+n*u,t[4]=a,t[5]=l,t},qt.scale=function(t,e,r){var i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=r[0],c=r[1];return t[0]=e[0]*l,t[1]=i*l,t[2]=o*c,t[3]=s*c,t[4]=n,t[5]=a,t},qt.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=r[0],u=r[1];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=i*c+s*u+a,t[5]=o*c+n*u+l,t},qt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=-r,t[3]=i,t[4]=0,t[5]=0,t},qt.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},qt.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},qt.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},qt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},qt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},qt.subtract=a_,qt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},qt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t},qt.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]},qt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=e[0],c=e[1],u=e[2],h=e[3],d=e[4],p=e[5];return Math.abs(r-l)<=qi.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(i-c)<=qi.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(o-u)<=qi.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(s-h)<=qi.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(n-d)<=qi.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(a-p)<=qi.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))},qt.sub=qt.mul=void 0;var qi=function(t,e){if(t&&t.__esModule)return t;if(t===null||Yh(t)!=="object"&&typeof t!="function")return{default:t};var r=s_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function s_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(s_=function(i){return i?r:e})(t)}function n_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=r[0],u=r[1],h=r[2],d=r[3],p=r[4],f=r[5];return t[0]=i*c+s*u,t[1]=o*c+n*u,t[2]=i*h+s*d,t[3]=o*h+n*d,t[4]=i*p+s*f+a,t[5]=o*p+n*f+l,t}function a_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}qt.mul=n_,qt.sub=a_;var zt={};function Jh(t){return Jh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jh(t)}Object.defineProperty(zt,"__esModule",{value:!0}),zt.create=function(){var t=new ii.ARRAY_TYPE(9);return ii.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},zt.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},zt.clone=function(t){var e=new ii.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},zt.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},zt.fromValues=function(t,e,r,i,o,s,n,a,l){var c=new ii.ARRAY_TYPE(9);return c[0]=t,c[1]=e,c[2]=r,c[3]=i,c[4]=o,c[5]=s,c[6]=n,c[7]=a,c[8]=l,c},zt.set=function(t,e,r,i,o,s,n,a,l,c){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t[8]=c,t},zt.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},zt.transpose=function(t,e){if(t===e){var r=e[1],i=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=i,t[7]=o}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},zt.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*n-a*c,d=-u*s+a*l,p=c*s-n*l,f=r*h+i*d+o*p;return f?(t[0]=h*(f=1/f),t[1]=(-u*i+o*c)*f,t[2]=(a*i-o*n)*f,t[3]=d*f,t[4]=(u*r-o*l)*f,t[5]=(-a*r+o*s)*f,t[6]=p*f,t[7]=(-c*r+i*l)*f,t[8]=(n*r-i*s)*f,t):null},zt.adjoint=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=n*u-a*c,t[1]=o*c-i*u,t[2]=i*a-o*n,t[3]=a*l-s*u,t[4]=r*u-o*l,t[5]=o*s-r*a,t[6]=s*c-n*l,t[7]=i*l-r*c,t[8]=r*n-i*s,t},zt.determinant=function(t){var e=t[3],r=t[4],i=t[5],o=t[6],s=t[7],n=t[8];return t[0]*(n*r-i*s)+t[1]*(-n*e+i*o)+t[2]*(s*e-r*o)},zt.multiply=c_,zt.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=r[0],p=r[1];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=a,t[5]=l,t[6]=d*i+p*n+c,t[7]=d*o+p*a+u,t[8]=d*s+p*l+h,t},zt.rotate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=Math.sin(r),p=Math.cos(r);return t[0]=p*i+d*n,t[1]=p*o+d*a,t[2]=p*s+d*l,t[3]=p*n-d*i,t[4]=p*a-d*o,t[5]=p*l-d*s,t[6]=c,t[7]=u,t[8]=h,t},zt.scale=function(t,e,r){var i=r[0],o=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},zt.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},zt.fromRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=-r,t[4]=i,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},zt.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},zt.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},zt.fromQuat=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r+r,a=i+i,l=o+o,c=r*n,u=i*n,h=i*a,d=o*n,p=o*a,f=o*l,m=s*n,_=s*a,g=s*l;return t[0]=1-h-f,t[3]=u-g,t[6]=d+_,t[1]=u+g,t[4]=1-c-f,t[7]=p-m,t[2]=d-_,t[5]=p+m,t[8]=1-c-h,t},zt.normalFromMat4=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=r*a-i*n,v=r*l-o*n,b=r*c-s*n,x=i*l-o*a,w=i*c-s*a,T=o*c-s*l,E=u*m-h*f,M=u*_-d*f,S=u*g-p*f,I=h*_-d*m,C=h*g-p*m,k=d*g-p*_,A=y*k-v*C+b*I+x*S-w*M+T*E;return A?(t[0]=(a*k-l*C+c*I)*(A=1/A),t[1]=(l*S-n*k-c*M)*A,t[2]=(n*C-a*S+c*E)*A,t[3]=(o*C-i*k-s*I)*A,t[4]=(r*k-o*S+s*M)*A,t[5]=(i*S-r*C-s*E)*A,t[6]=(m*T-_*w+g*x)*A,t[7]=(_*b-f*T-g*v)*A,t[8]=(f*w-m*b+g*y)*A,t):null},zt.projection=function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},zt.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},zt.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},zt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},zt.subtract=u_,zt.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},zt.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t},zt.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]},zt.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=e[0],d=e[1],p=e[2],f=e[3],m=e[4],_=e[5],g=e[6],y=e[7],v=e[8];return Math.abs(r-h)<=ii.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-d)<=ii.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(o-p)<=ii.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=ii.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(n-m)<=ii.EPSILON*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(a-_)<=ii.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(l-g)<=ii.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-y)<=ii.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(u-v)<=ii.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))},zt.sub=zt.mul=void 0;var ii=function(t,e){if(t&&t.__esModule)return t;if(t===null||Jh(t)!=="object"&&typeof t!="function")return{default:t};var r=l_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function l_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(l_=function(i){return i?r:e})(t)}function c_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=r[0],p=r[1],f=r[2],m=r[3],_=r[4],g=r[5],y=r[6],v=r[7],b=r[8];return t[0]=d*i+p*n+f*c,t[1]=d*o+p*a+f*u,t[2]=d*s+p*l+f*h,t[3]=m*i+_*n+g*c,t[4]=m*o+_*a+g*u,t[5]=m*s+_*l+g*h,t[6]=y*i+v*n+b*c,t[7]=y*o+v*a+b*u,t[8]=y*s+v*l+b*h,t}function u_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}zt.mul=c_,zt.sub=u_;var Xe={};function Kh(t){return Kh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kh(t)}Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.create=function(){var t=new Yt.ARRAY_TYPE(16);return Yt.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},Xe.clone=function(t){var e=new Yt.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},Xe.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},Xe.fromValues=function(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){var _=new Yt.ARRAY_TYPE(16);return _[0]=t,_[1]=e,_[2]=r,_[3]=i,_[4]=o,_[5]=s,_[6]=n,_[7]=a,_[8]=l,_[9]=c,_[10]=u,_[11]=h,_[12]=d,_[13]=p,_[14]=f,_[15]=m,_},Xe.set=function(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t[8]=c,t[9]=u,t[10]=h,t[11]=d,t[12]=p,t[13]=f,t[14]=m,t[15]=_,t},Xe.identity=d_,Xe.transpose=function(t,e){if(t===e){var r=e[1],i=e[2],o=e[3],s=e[6],n=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=s,t[11]=e[14],t[12]=o,t[13]=n,t[14]=a}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},Xe.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=r*a-i*n,v=r*l-o*n,b=r*c-s*n,x=i*l-o*a,w=i*c-s*a,T=o*c-s*l,E=u*m-h*f,M=u*_-d*f,S=u*g-p*f,I=h*_-d*m,C=h*g-p*m,k=d*g-p*_,A=y*k-v*C+b*I+x*S-w*M+T*E;return A?(t[0]=(a*k-l*C+c*I)*(A=1/A),t[1]=(o*C-i*k-s*I)*A,t[2]=(m*T-_*w+g*x)*A,t[3]=(d*w-h*T-p*x)*A,t[4]=(l*S-n*k-c*M)*A,t[5]=(r*k-o*S+s*M)*A,t[6]=(_*b-f*T-g*v)*A,t[7]=(u*T-d*b+p*v)*A,t[8]=(n*C-a*S+c*E)*A,t[9]=(i*S-r*C-s*E)*A,t[10]=(f*w-m*b+g*y)*A,t[11]=(h*b-u*w-p*y)*A,t[12]=(a*M-n*I-l*E)*A,t[13]=(r*I-i*M+o*E)*A,t[14]=(m*v-f*x-_*y)*A,t[15]=(u*x-h*v+d*y)*A,t):null},Xe.adjoint=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15];return t[0]=a*(d*g-p*_)-h*(l*g-c*_)+m*(l*p-c*d),t[1]=-(i*(d*g-p*_)-h*(o*g-s*_)+m*(o*p-s*d)),t[2]=i*(l*g-c*_)-a*(o*g-s*_)+m*(o*c-s*l),t[3]=-(i*(l*p-c*d)-a*(o*p-s*d)+h*(o*c-s*l)),t[4]=-(n*(d*g-p*_)-u*(l*g-c*_)+f*(l*p-c*d)),t[5]=r*(d*g-p*_)-u*(o*g-s*_)+f*(o*p-s*d),t[6]=-(r*(l*g-c*_)-n*(o*g-s*_)+f*(o*c-s*l)),t[7]=r*(l*p-c*d)-n*(o*p-s*d)+u*(o*c-s*l),t[8]=n*(h*g-p*m)-u*(a*g-c*m)+f*(a*p-c*h),t[9]=-(r*(h*g-p*m)-u*(i*g-s*m)+f*(i*p-s*h)),t[10]=r*(a*g-c*m)-n*(i*g-s*m)+f*(i*c-s*a),t[11]=-(r*(a*p-c*h)-n*(i*p-s*h)+u*(i*c-s*a)),t[12]=-(n*(h*_-d*m)-u*(a*_-l*m)+f*(a*d-l*h)),t[13]=r*(h*_-d*m)-u*(i*_-o*m)+f*(i*d-o*h),t[14]=-(r*(a*_-l*m)-n*(i*_-o*m)+f*(i*l-o*a)),t[15]=r*(a*d-l*h)-n*(i*d-o*h)+u*(i*l-o*a),t},Xe.determinant=function(t){var e=t[0],r=t[1],i=t[2],o=t[3],s=t[4],n=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],f=t[13],m=t[14],_=t[15];return(e*n-r*s)*(h*_-d*m)-(e*a-i*s)*(u*_-d*f)+(e*l-o*s)*(u*m-h*f)+(r*a-i*n)*(c*_-d*p)-(r*l-o*n)*(c*m-h*p)+(i*l-o*a)*(c*f-u*p)},Xe.multiply=p_,Xe.translate=function(t,e,r){var i,o,s,n,a,l,c,u,h,d,p,f,m=r[0],_=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],t[0]=i=e[0],t[1]=o,t[2]=s,t[3]=n,t[4]=a,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=d,t[10]=p,t[11]=f,t[12]=i*m+a*_+h*g+e[12],t[13]=o*m+l*_+d*g+e[13],t[14]=s*m+c*_+p*g+e[14],t[15]=n*m+u*_+f*g+e[15]),t},Xe.scale=function(t,e,r){var i=r[0],o=r[1],s=r[2];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]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Xe.rotate=function(t,e,r,i){var o,s,n,a,l,c,u,h,d,p,f,m,_,g,y,v,b,x,w,T,E,M,S,I,C=i[0],k=i[1],A=i[2],L=Math.hypot(C,k,A);return L<Yt.EPSILON?null:(C*=L=1/L,k*=L,A*=L,o=Math.sin(r),s=Math.cos(r),l=e[1],c=e[2],u=e[3],d=e[5],p=e[6],f=e[7],_=e[9],g=e[10],y=e[11],w=C*k*(n=1-s)-A*o,T=k*k*n+s,E=A*k*n+C*o,M=C*A*n+k*o,S=k*A*n-C*o,I=A*A*n+s,t[0]=(a=e[0])*(v=C*C*n+s)+(h=e[4])*(b=k*C*n+A*o)+(m=e[8])*(x=A*C*n-k*o),t[1]=l*v+d*b+_*x,t[2]=c*v+p*b+g*x,t[3]=u*v+f*b+y*x,t[4]=a*w+h*T+m*E,t[5]=l*w+d*T+_*E,t[6]=c*w+p*T+g*E,t[7]=u*w+f*T+y*E,t[8]=a*M+h*S+m*I,t[9]=l*M+d*S+_*I,t[10]=c*M+p*S+g*I,t[11]=u*M+f*S+y*I,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},Xe.rotateX=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[4],n=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+c*i,t[5]=n*o+u*i,t[6]=a*o+h*i,t[7]=l*o+d*i,t[8]=c*o-s*i,t[9]=u*o-n*i,t[10]=h*o-a*i,t[11]=d*o-l*i,t},Xe.rotateY=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[0],n=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-c*i,t[1]=n*o-u*i,t[2]=a*o-h*i,t[3]=l*o-d*i,t[8]=s*i+c*o,t[9]=n*i+u*o,t[10]=a*i+h*o,t[11]=l*i+d*o,t},Xe.rotateZ=function(t,e,r){var i=Math.sin(r),o=Math.cos(r),s=e[0],n=e[1],a=e[2],l=e[3],c=e[4],u=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+c*i,t[1]=n*o+u*i,t[2]=a*o+h*i,t[3]=l*o+d*i,t[4]=c*o-s*i,t[5]=u*o-n*i,t[6]=h*o-a*i,t[7]=d*o-l*i,t},Xe.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},Xe.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},Xe.fromRotation=function(t,e,r){var i,o,s,n=r[0],a=r[1],l=r[2],c=Math.hypot(n,a,l);return c<Yt.EPSILON?null:(n*=c=1/c,a*=c,l*=c,i=Math.sin(e),o=Math.cos(e),t[0]=n*n*(s=1-o)+o,t[1]=a*n*s+l*i,t[2]=l*n*s-a*i,t[3]=0,t[4]=n*a*s-l*i,t[5]=a*a*s+o,t[6]=l*a*s+n*i,t[7]=0,t[8]=n*l*s+a*i,t[9]=a*l*s-n*i,t[10]=l*l*s+o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},Xe.fromXRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.fromYRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.fromZRotation=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,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},Xe.fromRotationTranslation=f_,Xe.fromQuat2=function(t,e){var r=new Yt.ARRAY_TYPE(3),i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=i*i+o*o+s*s+n*n;return h>0?(r[0]=2*(a*n+u*i+l*s-c*o)/h,r[1]=2*(l*n+u*o+c*i-a*s)/h,r[2]=2*(c*n+u*s+a*o-l*i)/h):(r[0]=2*(a*n+u*i+l*s-c*o),r[1]=2*(l*n+u*o+c*i-a*s),r[2]=2*(c*n+u*s+a*o-l*i)),f_(t,e,r),t},Xe.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},Xe.getScaling=m_,Xe.getRotation=function(t,e){var r=new Yt.ARRAY_TYPE(3);m_(r,e);var i=1/r[0],o=1/r[1],s=1/r[2],n=e[0]*i,a=e[1]*o,l=e[2]*s,c=e[4]*i,u=e[5]*o,h=e[6]*s,d=e[8]*i,p=e[9]*o,f=e[10]*s,m=n+u+f,_=0;return m>0?(_=2*Math.sqrt(m+1),t[3]=.25*_,t[0]=(h-p)/_,t[1]=(d-l)/_,t[2]=(a-c)/_):n>u&&n>f?(_=2*Math.sqrt(1+n-u-f),t[3]=(h-p)/_,t[0]=.25*_,t[1]=(a+c)/_,t[2]=(d+l)/_):u>f?(_=2*Math.sqrt(1+u-n-f),t[3]=(d-l)/_,t[0]=(a+c)/_,t[1]=.25*_,t[2]=(h+p)/_):(_=2*Math.sqrt(1+f-n-u),t[3]=(a-c)/_,t[0]=(d+l)/_,t[1]=(h+p)/_,t[2]=.25*_),t},Xe.fromRotationTranslationScale=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=e[3],l=o+o,c=s+s,u=n+n,h=o*l,d=o*c,p=o*u,f=s*c,m=s*u,_=n*u,g=a*l,y=a*c,v=a*u,b=i[0],x=i[1],w=i[2];return t[0]=(1-(f+_))*b,t[1]=(d+v)*b,t[2]=(p-y)*b,t[3]=0,t[4]=(d-v)*x,t[5]=(1-(h+_))*x,t[6]=(m+g)*x,t[7]=0,t[8]=(p+y)*w,t[9]=(m-g)*w,t[10]=(1-(h+f))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},Xe.fromRotationTranslationScaleOrigin=function(t,e,r,i,o){var s=e[0],n=e[1],a=e[2],l=e[3],c=s+s,u=n+n,h=a+a,d=s*c,p=s*u,f=s*h,m=n*u,_=n*h,g=a*h,y=l*c,v=l*u,b=l*h,x=i[0],w=i[1],T=i[2],E=o[0],M=o[1],S=o[2],I=(1-(m+g))*x,C=(p+b)*x,k=(f-v)*x,A=(p-b)*w,L=(1-(d+g))*w,O=(_+y)*w,U=(f+v)*T,R=(_-y)*T,B=(1-(d+m))*T;return t[0]=I,t[1]=C,t[2]=k,t[3]=0,t[4]=A,t[5]=L,t[6]=O,t[7]=0,t[8]=U,t[9]=R,t[10]=B,t[11]=0,t[12]=r[0]+E-(I*E+A*M+U*S),t[13]=r[1]+M-(C*E+L*M+R*S),t[14]=r[2]+S-(k*E+O*M+B*S),t[15]=1,t},Xe.fromQuat=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r+r,a=i+i,l=o+o,c=r*n,u=i*n,h=i*a,d=o*n,p=o*a,f=o*l,m=s*n,_=s*a,g=s*l;return t[0]=1-h-f,t[1]=u+g,t[2]=d-_,t[3]=0,t[4]=u-g,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+_,t[9]=p-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Xe.frustum=function(t,e,r,i,o,s,n){var a=1/(r-e),l=1/(o-i),c=1/(s-n);return t[0]=2*s*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*s*l,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+i)*l,t[10]=(n+s)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=n*s*2*c,t[15]=0,t},Xe.perspectiveNO=__,Xe.perspectiveZO=function(t,e,r,i,o){var s,n=1/Math.tan(e/2);return t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0?(t[10]=o*(s=1/(i-o)),t[14]=o*i*s):(t[10]=-1,t[14]=-i),t},Xe.perspectiveFromFieldOfView=function(t,e,r,i){var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),n=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),l=2/(n+a),c=2/(o+s);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(n-a)*l*.5,t[9]=(o-s)*c*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t},Xe.orthoNO=g_,Xe.orthoZO=function(t,e,r,i,o,s,n){var a=1/(e-r),l=1/(i-o),c=1/(s-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*l,t[14]=s*c,t[15]=1,t},Xe.lookAt=function(t,e,r,i){var o,s,n,a,l,c,u,h,d,p,f=e[0],m=e[1],_=e[2],g=i[0],y=i[1],v=i[2],b=r[0],x=r[1],w=r[2];return Math.abs(f-b)<Yt.EPSILON&&Math.abs(m-x)<Yt.EPSILON&&Math.abs(_-w)<Yt.EPSILON?d_(t):(u=f-b,h=m-x,d=_-w,o=y*(d*=p=1/Math.hypot(u,h,d))-v*(h*=p),s=v*(u*=p)-g*d,n=g*h-y*u,(p=Math.hypot(o,s,n))?(o*=p=1/p,s*=p,n*=p):(o=0,s=0,n=0),a=h*n-d*s,l=d*o-u*n,c=u*s-h*o,(p=Math.hypot(a,l,c))?(a*=p=1/p,l*=p,c*=p):(a=0,l=0,c=0),t[0]=o,t[1]=a,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=h,t[7]=0,t[8]=n,t[9]=c,t[10]=d,t[11]=0,t[12]=-(o*f+s*m+n*_),t[13]=-(a*f+l*m+c*_),t[14]=-(u*f+h*m+d*_),t[15]=1,t)},Xe.targetTo=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=i[0],l=i[1],c=i[2],u=o-r[0],h=s-r[1],d=n-r[2],p=u*u+h*h+d*d;p>0&&(u*=p=1/Math.sqrt(p),h*=p,d*=p);var f=l*d-c*h,m=c*u-a*d,_=a*h-l*u;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),t[0]=f,t[1]=m,t[2]=_,t[3]=0,t[4]=h*_-d*m,t[5]=d*f-u*_,t[6]=u*m-h*f,t[7]=0,t[8]=u,t[9]=h,t[10]=d,t[11]=0,t[12]=o,t[13]=s,t[14]=n,t[15]=1,t},Xe.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]+")"},Xe.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])},Xe.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},Xe.subtract=y_,Xe.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},Xe.multiplyScalarAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t},Xe.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]},Xe.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=e[0],v=e[1],b=e[2],x=e[3],w=e[4],T=e[5],E=e[6],M=e[7],S=e[8],I=e[9],C=e[10],k=e[11],A=e[12],L=e[13],O=e[14],U=e[15];return Math.abs(r-y)<=Yt.EPSILON*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-v)<=Yt.EPSILON*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(o-b)<=Yt.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-x)<=Yt.EPSILON*Math.max(1,Math.abs(s),Math.abs(x))&&Math.abs(n-w)<=Yt.EPSILON*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(a-T)<=Yt.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=Yt.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-M)<=Yt.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(u-S)<=Yt.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-I)<=Yt.EPSILON*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(d-C)<=Yt.EPSILON*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(p-k)<=Yt.EPSILON*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(f-A)<=Yt.EPSILON*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(m-L)<=Yt.EPSILON*Math.max(1,Math.abs(m),Math.abs(L))&&Math.abs(_-O)<=Yt.EPSILON*Math.max(1,Math.abs(_),Math.abs(O))&&Math.abs(g-U)<=Yt.EPSILON*Math.max(1,Math.abs(g),Math.abs(U))},Xe.sub=Xe.mul=Xe.ortho=Xe.perspective=void 0;var Yt=function(t,e){if(t&&t.__esModule)return t;if(t===null||Kh(t)!=="object"&&typeof t!="function")return{default:t};var r=h_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function h_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(h_=function(i){return i?r:e})(t)}function d_(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 p_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=r[0],b=r[1],x=r[2],w=r[3];return t[0]=v*i+b*a+x*h+w*m,t[1]=v*o+b*l+x*d+w*_,t[2]=v*s+b*c+x*p+w*g,t[3]=v*n+b*u+x*f+w*y,t[4]=(v=r[4])*i+(b=r[5])*a+(x=r[6])*h+(w=r[7])*m,t[5]=v*o+b*l+x*d+w*_,t[6]=v*s+b*c+x*p+w*g,t[7]=v*n+b*u+x*f+w*y,t[8]=(v=r[8])*i+(b=r[9])*a+(x=r[10])*h+(w=r[11])*m,t[9]=v*o+b*l+x*d+w*_,t[10]=v*s+b*c+x*p+w*g,t[11]=v*n+b*u+x*f+w*y,t[12]=(v=r[12])*i+(b=r[13])*a+(x=r[14])*h+(w=r[15])*m,t[13]=v*o+b*l+x*d+w*_,t[14]=v*s+b*c+x*p+w*g,t[15]=v*n+b*u+x*f+w*y,t}function f_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=i+i,l=o+o,c=s+s,u=i*a,h=i*l,d=i*c,p=o*l,f=o*c,m=s*c,_=n*a,g=n*l,y=n*c;return t[0]=1-(p+m),t[1]=h+y,t[2]=d-g,t[3]=0,t[4]=h-y,t[5]=1-(u+m),t[6]=f+_,t[7]=0,t[8]=d+g,t[9]=f-_,t[10]=1-(u+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function m_(t,e){var r=e[4],i=e[5],o=e[6],s=e[8],n=e[9],a=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,i,o),t[2]=Math.hypot(s,n,a),t}function __(t,e,r,i,o){var s,n=1/Math.tan(e/2);return t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0?(t[10]=(o+i)*(s=1/(i-o)),t[14]=2*o*i*s):(t[10]=-1,t[14]=-2*i),t}function g_(t,e,r,i,o,s,n){var a=1/(e-r),l=1/(i-o),c=1/(s-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*l,t[14]=(n+s)*c,t[15]=1,t}function y_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}Xe.perspective=__,Xe.ortho=g_,Xe.mul=p_,Xe.sub=y_;var Ze={},We={};function Qh(t){return Qh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qh(t)}Object.defineProperty(We,"__esModule",{value:!0}),We.create=v_,We.clone=function(t){var e=new ho.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},We.length=b_,We.fromValues=function(t,e,r){var i=new ho.ARRAY_TYPE(3);return i[0]=t,i[1]=e,i[2]=r,i},We.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},We.set=function(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t},We.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},We.subtract=w_,We.multiply=T_,We.divide=E_,We.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},We.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},We.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},We.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},We.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},We.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},We.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t},We.distance=M_,We.squaredDistance=S_,We.squaredLength=A_,We.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},We.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},We.normalize=function(t,e){var r=e[0],i=e[1],o=e[2],s=r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},We.dot=I_,We.cross=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[0],a=r[1],l=r[2];return t[0]=o*l-s*a,t[1]=s*n-i*l,t[2]=i*a-o*n,t},We.lerp=function(t,e,r,i){var o=e[0],s=e[1],n=e[2];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t[2]=n+i*(r[2]-n),t},We.hermite=function(t,e,r,i,o,s){var n=s*s,a=n*(2*s-3)+1,l=n*(s-2)+s,c=n*(s-1),u=n*(3-2*s);return t[0]=e[0]*a+r[0]*l+i[0]*c+o[0]*u,t[1]=e[1]*a+r[1]*l+i[1]*c+o[1]*u,t[2]=e[2]*a+r[2]*l+i[2]*c+o[2]*u,t},We.bezier=function(t,e,r,i,o,s){var n=1-s,a=n*n,l=s*s,c=a*n,u=3*s*a,h=3*l*n,d=l*s;return t[0]=e[0]*c+r[0]*u+i[0]*h+o[0]*d,t[1]=e[1]*c+r[1]*u+i[1]*h+o[1]*d,t[2]=e[2]*c+r[2]*u+i[2]*h+o[2]*d,t},We.random=function(t,e){e=e||1;var r=2*ho.RANDOM()*Math.PI,i=2*ho.RANDOM()-1,o=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=i*e,t},We.transformMat4=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[3]*i+r[7]*o+r[11]*s+r[15];return t[0]=(r[0]*i+r[4]*o+r[8]*s+r[12])/(n=n||1),t[1]=(r[1]*i+r[5]*o+r[9]*s+r[13])/n,t[2]=(r[2]*i+r[6]*o+r[10]*s+r[14])/n,t},We.transformMat3=function(t,e,r){var i=e[0],o=e[1],s=e[2];return t[0]=i*r[0]+o*r[3]+s*r[6],t[1]=i*r[1]+o*r[4]+s*r[7],t[2]=i*r[2]+o*r[5]+s*r[8],t},We.transformQuat=function(t,e,r){var i=r[0],o=r[1],s=r[2],n=e[0],a=e[1],l=e[2],c=o*l-s*a,u=s*n-i*l,h=i*a-o*n,d=o*h-s*u,p=s*c-i*h,f=i*u-o*c,m=2*r[3];return u*=m,h*=m,p*=2,f*=2,t[0]=n+(c*=m)+(d*=2),t[1]=a+u+p,t[2]=l+h+f,t},We.rotateX=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(i)-o[2]*Math.sin(i),s[2]=o[1]*Math.sin(i)+o[2]*Math.cos(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.rotateY=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(i)+o[0]*Math.cos(i),s[1]=o[1],s[2]=o[2]*Math.cos(i)-o[0]*Math.sin(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.rotateZ=function(t,e,r,i){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(i)-o[1]*Math.sin(i),s[1]=o[0]*Math.sin(i)+o[1]*Math.cos(i),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},We.angle=function(t,e){var r=t[0],i=t[1],o=t[2],s=e[0],n=e[1],a=e[2],l=Math.sqrt(r*r+i*i+o*o)*Math.sqrt(s*s+n*n+a*a),c=l&&I_(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))},We.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},We.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},We.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},We.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=e[0],n=e[1],a=e[2];return Math.abs(r-s)<=ho.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-n)<=ho.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(o-a)<=ho.EPSILON*Math.max(1,Math.abs(o),Math.abs(a))},We.forEach=We.sqrLen=We.len=We.sqrDist=We.dist=We.div=We.mul=We.sub=void 0;var ho=function(t,e){if(t&&t.__esModule)return t;if(t===null||Qh(t)!=="object"&&typeof t!="function")return{default:t};var r=x_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function x_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(x_=function(i){return i?r:e})(t)}function v_(){var t=new ho.ARRAY_TYPE(3);return ho.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function b_(t){return Math.hypot(t[0],t[1],t[2])}function w_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function T_(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function E_(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function M_(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function S_(t,e){var r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return r*r+i*i+o*o}function A_(t){var e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function I_(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}We.sub=w_,We.mul=T_,We.div=E_,We.dist=M_,We.sqrDist=S_,We.len=b_,We.sqrLen=A_;var po,kb=(po=v_(),function(t,e,r,i,o,s){var n,a;for(e||(e=3),r||(r=0),a=i?Math.min(i*e+r,t.length):t.length,n=r;n<a;n+=e)po[0]=t[n],po[1]=t[n+1],po[2]=t[n+2],o(po,po,s),t[n]=po[0],t[n+1]=po[1],t[n+2]=po[2];return t});We.forEach=kb;var nt={};function ed(t){return ed=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ed(t)}Object.defineProperty(nt,"__esModule",{value:!0}),nt.create=z_,nt.clone=function(t){var e=new mi.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,r,i){var o=new mi.ARRAY_TYPE(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o},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,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t},nt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},nt.subtract=D_,nt.multiply=k_,nt.divide=P_,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,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},nt.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[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,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},nt.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},nt.distance=R_,nt.squaredDistance=L_,nt.length=B_,nt.squaredLength=O_,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 r=e[0],i=e[1],o=e[2],s=e[3],n=r*r+i*i+o*o+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=r*n,t[1]=i*n,t[2]=o*n,t[3]=s*n,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,r,i){var o=r[0]*i[1]-r[1]*i[0],s=r[0]*i[2]-r[2]*i[0],n=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],l=r[1]*i[3]-r[3]*i[1],c=r[2]*i[3]-r[3]*i[2],u=e[0],h=e[1],d=e[2],p=e[3];return t[0]=h*c-d*l+p*a,t[1]=-u*c+d*n-p*s,t[2]=u*l-h*n+p*o,t[3]=-u*a+h*s-d*o,t},nt.lerp=function(t,e,r,i){var o=e[0],s=e[1],n=e[2],a=e[3];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t[2]=n+i*(r[2]-n),t[3]=a+i*(r[3]-a),t},nt.random=function(t,e){var r,i,o,s,n,a;e=e||1;do n=(r=2*mi.RANDOM()-1)*r+(i=2*mi.RANDOM()-1)*i;while(n>=1);do a=(o=2*mi.RANDOM()-1)*o+(s=2*mi.RANDOM()-1)*s;while(a>=1);var l=Math.sqrt((1-n)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*o*l,t[3]=e*s*l,t},nt.transformMat4=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3];return t[0]=r[0]*i+r[4]*o+r[8]*s+r[12]*n,t[1]=r[1]*i+r[5]*o+r[9]*s+r[13]*n,t[2]=r[2]*i+r[6]*o+r[10]*s+r[14]*n,t[3]=r[3]*i+r[7]*o+r[11]*s+r[15]*n,t},nt.transformQuat=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=r[0],a=r[1],l=r[2],c=r[3],u=c*i+a*s-l*o,h=c*o+l*i-n*s,d=c*s+n*o-a*i,p=-n*i-a*o-l*s;return t[0]=u*c+p*-n+h*-l-d*-a,t[1]=h*c+p*-a+d*-n-u*-l,t[2]=d*c+p*-l+u*-a-h*-n,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 r=t[0],i=t[1],o=t[2],s=t[3],n=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(r-n)<=mi.EPSILON*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=mi.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=mi.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(s-c)<=mi.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},nt.forEach=nt.sqrLen=nt.len=nt.sqrDist=nt.dist=nt.div=nt.mul=nt.sub=void 0;var mi=function(t,e){if(t&&t.__esModule)return t;if(t===null||ed(t)!=="object"&&typeof t!="function")return{default:t};var r=C_(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function C_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(C_=function(i){return i?r:e})(t)}function z_(){var t=new mi.ARRAY_TYPE(4);return mi.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function D_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function k_(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function P_(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function R_(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function L_(t,e){var r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],s=e[3]-t[3];return r*r+i*i+o*o+s*s}function B_(t){return Math.hypot(t[0],t[1],t[2],t[3])}function O_(t){var e=t[0],r=t[1],i=t[2],o=t[3];return e*e+r*r+i*i+o*o}nt.sub=D_,nt.mul=k_,nt.div=P_,nt.dist=R_,nt.sqrDist=L_,nt.len=B_,nt.sqrLen=O_;var Pb=function(){var t=z_();return function(e,r,i,o,s,n){var a,l;for(r||(r=4),i||(i=0),l=o?Math.min(o*r+i,e.length):e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function td(t){return td=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},td(t)}nt.forEach=Pb,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.create=rd,Ze.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},Ze.setAxisAngle=N_,Ze.getAxisAngle=function(t,e){var r=2*Math.acos(e[3]),i=Math.sin(r/2);return i>vs.EPSILON?(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i):(t[0]=1,t[1]=0,t[2]=0),r},Ze.getAngle=function(t,e){var r=Z_(t,e);return Math.acos(2*r*r-1)},Ze.multiply=U_,Ze.rotateX=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+n*a,t[1]=o*l+s*a,t[2]=s*l-o*a,t[3]=n*l-i*a,t},Ze.rotateY=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l-s*a,t[1]=o*l+n*a,t[2]=s*l+i*a,t[3]=n*l-o*a,t},Ze.rotateZ=function(t,e,r){r*=.5;var i=e[0],o=e[1],s=e[2],n=e[3],a=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*a,t[1]=o*l-i*a,t[2]=s*l+n*a,t[3]=n*l-s*a,t},Ze.calculateW=function(t,e){var r=e[0],i=e[1],o=e[2];return t[0]=r,t[1]=i,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-o*o)),t},Ze.exp=V_,Ze.ln=j_,Ze.pow=function(t,e,r){return j_(t,e),q_(t,t,r),V_(t,t),t},Ze.slerp=Ll,Ze.random=function(t){var e=vs.RANDOM(),r=vs.RANDOM(),i=vs.RANDOM(),o=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*i),t[3]=s*Math.cos(2*Math.PI*i),t},Ze.invert=function(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=r*r+i*i+o*o+s*s,a=n?1/n:0;return t[0]=-r*a,t[1]=-i*a,t[2]=-o*a,t[3]=s*a,t},Ze.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Ze.fromMat3=G_,Ze.fromEuler=function(t,e,r,i){var o=.5*Math.PI/180;e*=o,r*=o,i*=o;var s=Math.sin(e),n=Math.cos(e),a=Math.sin(r),l=Math.cos(r),c=Math.sin(i),u=Math.cos(i);return t[0]=s*l*u-n*a*c,t[1]=n*a*u+s*l*c,t[2]=n*l*c-s*a*u,t[3]=n*l*u+s*a*c,t},Ze.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Ze.setAxes=Ze.sqlerp=Ze.rotationTo=Ze.equals=Ze.exactEquals=Ze.normalize=Ze.sqrLen=Ze.squaredLength=Ze.len=Ze.length=Ze.lerp=Ze.dot=Ze.scale=Ze.mul=Ze.add=Ze.set=Ze.copy=Ze.fromValues=Ze.clone=void 0;var vs=Rl(gr),Rb=Rl(zt),fo=Rl(We),oi=Rl(nt);function F_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(F_=function(i){return i?r:e})(t)}function Rl(t,e){if(t&&t.__esModule)return t;if(t===null||td(t)!=="object"&&typeof t!="function")return{default:t};var r=F_(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}function rd(){var t=new vs.ARRAY_TYPE(4);return vs.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function N_(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t}function U_(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*u+n*a+o*c-s*l,t[1]=o*u+n*l+s*a-i*c,t[2]=s*u+n*c+i*l-o*a,t[3]=n*u-i*a-o*l-s*c,t}function V_(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=Math.sqrt(r*r+i*i+o*o),a=Math.exp(s),l=n>0?a*Math.sin(n)/n:0;return t[0]=r*l,t[1]=i*l,t[2]=o*l,t[3]=a*Math.cos(n),t}function j_(t,e){var r=e[0],i=e[1],o=e[2],s=e[3],n=Math.sqrt(r*r+i*i+o*o),a=n>0?Math.atan2(n,s)/n:0;return t[0]=r*a,t[1]=i*a,t[2]=o*a,t[3]=.5*Math.log(r*r+i*i+o*o+s*s),t}function Ll(t,e,r,i){var o,s,n,a,l,c=e[0],u=e[1],h=e[2],d=e[3],p=r[0],f=r[1],m=r[2],_=r[3];return(s=c*p+u*f+h*m+d*_)<0&&(s=-s,p=-p,f=-f,m=-m,_=-_),1-s>vs.EPSILON?(o=Math.acos(s),n=Math.sin(o),a=Math.sin((1-i)*o)/n,l=Math.sin(i*o)/n):(a=1-i,l=i),t[0]=a*c+l*p,t[1]=a*u+l*f,t[2]=a*h+l*m,t[3]=a*d+l*_,t}function G_(t,e){var r,i=e[0]+e[4]+e[8];if(i>0)r=Math.sqrt(i+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[3*o+o]&&(o=2);var s=(o+1)%3,n=(o+2)%3;r=Math.sqrt(e[3*o+o]-e[3*s+s]-e[3*n+n]+1),t[o]=.5*r,t[3]=(e[3*s+n]-e[3*n+s])*(r=.5/r),t[s]=(e[3*s+o]+e[3*o+s])*r,t[n]=(e[3*n+o]+e[3*o+n])*r}return t}Ze.clone=oi.clone,Ze.fromValues=oi.fromValues,Ze.copy=oi.copy,Ze.set=oi.set,Ze.add=oi.add,Ze.mul=U_;var q_=oi.scale;Ze.scale=q_;var Z_=oi.dot;Ze.dot=Z_,Ze.lerp=oi.lerp;var $_=oi.length;Ze.length=$_,Ze.len=$_;var H_=oi.squaredLength;Ze.squaredLength=H_,Ze.sqrLen=H_;var id=oi.normalize;Ze.normalize=id,Ze.exactEquals=oi.exactEquals,Ze.equals=oi.equals;var Ii,W_,X_,Lb=(Ii=fo.create(),W_=fo.fromValues(1,0,0),X_=fo.fromValues(0,1,0),function(t,e,r){var i=fo.dot(e,r);return i<-.999999?(fo.cross(Ii,W_,e),fo.len(Ii)<1e-6&&fo.cross(Ii,X_,e),fo.normalize(Ii,Ii),N_(t,Ii,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(fo.cross(Ii,e,r),t[0]=Ii[0],t[1]=Ii[1],t[2]=Ii[2],t[3]=1+i,id(t,t))});Ze.rotationTo=Lb;var od,sd,Bb=(od=rd(),sd=rd(),function(t,e,r,i,o,s){return Ll(od,e,o,s),Ll(sd,r,i,s),Ll(t,od,sd,2*s*(1-s)),t});Ze.sqlerp=Bb;var Ci,Ob=(Ci=Rb.create(),function(t,e,r,i){return Ci[0]=r[0],Ci[3]=r[1],Ci[6]=r[2],Ci[1]=i[0],Ci[4]=i[1],Ci[7]=i[2],Ci[2]=-e[0],Ci[5]=-e[1],Ci[8]=-e[2],id(t,G_(t,Ci))});Ze.setAxes=Ob;var ct={};function nd(t){return nd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nd(t)}Object.defineProperty(ct,"__esModule",{value:!0}),ct.create=function(){var t=new Or.ARRAY_TYPE(8);return Or.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},ct.clone=function(t){var e=new Or.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},ct.fromValues=function(t,e,r,i,o,s,n,a){var l=new Or.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=r,l[3]=i,l[4]=o,l[5]=s,l[6]=n,l[7]=a,l},ct.fromRotationTranslationValues=function(t,e,r,i,o,s,n){var a=new Or.ARRAY_TYPE(8);a[0]=t,a[1]=e,a[2]=r,a[3]=i;var l=.5*o,c=.5*s,u=.5*n;return a[4]=l*i+c*r-u*e,a[5]=c*i+u*t-l*r,a[6]=u*i+l*e-c*t,a[7]=-l*t-c*e-u*r,a},ct.fromRotationTranslation=K_,ct.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},ct.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},ct.fromMat4=function(t,e){var r=mo.create();Y_.getRotation(r,e);var i=new Or.ARRAY_TYPE(3);return Y_.getTranslation(i,e),K_(t,r,i),t},ct.copy=Q_,ct.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},ct.set=function(t,e,r,i,o,s,n,a,l){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l,t},ct.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},ct.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},ct.getTranslation=function(t,e){var r=e[4],i=e[5],o=e[6],s=e[7],n=-e[0],a=-e[1],l=-e[2],c=e[3];return t[0]=2*(r*c+s*n+i*l-o*a),t[1]=2*(i*c+s*a+o*n-r*l),t[2]=2*(o*c+s*l+r*a-i*n),t},ct.translate=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=.5*r[0],l=.5*r[1],c=.5*r[2],u=e[4],h=e[5],d=e[6],p=e[7];return t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=n*a+o*c-s*l+u,t[5]=n*l+s*a-i*c+h,t[6]=n*c+i*l-o*a+d,t[7]=-i*a-o*l-s*c+p,t},ct.rotateX=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateX(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateY=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateY(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateZ=function(t,e,r){var i=-e[0],o=-e[1],s=-e[2],n=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=a*n+u*i+l*s-c*o,d=l*n+u*o+c*i-a*s,p=c*n+u*s+a*o-l*i,f=u*n-a*i-l*o-c*s;return mo.rotateZ(t,e,r),t[4]=h*(n=t[3])+f*(i=t[0])+d*(s=t[2])-p*(o=t[1]),t[5]=d*n+f*o+p*i-h*s,t[6]=p*n+f*s+h*o-d*i,t[7]=f*n-h*i-d*o-p*s,t},ct.rotateByQuatAppend=function(t,e,r){var i=r[0],o=r[1],s=r[2],n=r[3],a=e[0],l=e[1],c=e[2],u=e[3];return t[0]=a*n+u*i+l*s-c*o,t[1]=l*n+u*o+c*i-a*s,t[2]=c*n+u*s+a*o-l*i,t[3]=u*n-a*i-l*o-c*s,t[4]=(a=e[4])*n+(u=e[7])*i+(l=e[5])*s-(c=e[6])*o,t[5]=l*n+u*o+c*i-a*s,t[6]=c*n+u*s+a*o-l*i,t[7]=u*n-a*i-l*o-c*s,t},ct.rotateByQuatPrepend=function(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[0],l=r[1],c=r[2],u=r[3];return t[0]=i*u+n*a+o*c-s*l,t[1]=o*u+n*l+s*a-i*c,t[2]=s*u+n*c+i*l-o*a,t[3]=n*u-i*a-o*l-s*c,t[4]=i*(u=r[7])+n*(a=r[4])+o*(c=r[6])-s*(l=r[5]),t[5]=o*u+n*l+s*a-i*c,t[6]=s*u+n*c+i*l-o*a,t[7]=n*u-i*a-o*l-s*c,t},ct.rotateAroundAxis=function(t,e,r,i){if(Math.abs(i)<Or.EPSILON)return Q_(t,e);var o=Math.hypot(r[0],r[1],r[2]);i*=.5;var s=Math.sin(i),n=s*r[0]/o,a=s*r[1]/o,l=s*r[2]/o,c=Math.cos(i),u=e[0],h=e[1],d=e[2],p=e[3];t[0]=u*c+p*n+h*l-d*a,t[1]=h*c+p*a+d*n-u*l,t[2]=d*c+p*l+u*a-h*n,t[3]=p*c-u*n-h*a-d*l;var f=e[4],m=e[5],_=e[6],g=e[7];return t[4]=f*c+g*n+m*l-_*a,t[5]=m*c+g*a+_*n-f*l,t[6]=_*c+g*l+f*a-m*n,t[7]=g*c-f*n-m*a-_*l,t},ct.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t},ct.multiply=eg,ct.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t},ct.lerp=function(t,e,r,i){var o=1-i;return tg(e,r)<0&&(i=-i),t[0]=e[0]*o+r[0]*i,t[1]=e[1]*o+r[1]*i,t[2]=e[2]*o+r[2]*i,t[3]=e[3]*o+r[3]*i,t[4]=e[4]*o+r[4]*i,t[5]=e[5]*o+r[5]*i,t[6]=e[6]*o+r[6]*i,t[7]=e[7]*o+r[7]*i,t},ct.invert=function(t,e){var r=Bl(e);return t[0]=-e[0]/r,t[1]=-e[1]/r,t[2]=-e[2]/r,t[3]=e[3]/r,t[4]=-e[4]/r,t[5]=-e[5]/r,t[6]=-e[6]/r,t[7]=e[7]/r,t},ct.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},ct.normalize=function(t,e){var r=Bl(e);if(r>0){r=Math.sqrt(r);var i=e[0]/r,o=e[1]/r,s=e[2]/r,n=e[3]/r,a=e[4],l=e[5],c=e[6],u=e[7],h=i*a+o*l+s*c+n*u;t[0]=i,t[1]=o,t[2]=s,t[3]=n,t[4]=(a-i*h)/r,t[5]=(l-o*h)/r,t[6]=(c-s*h)/r,t[7]=(u-n*h)/r}return t},ct.str=function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},ct.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]},ct.equals=function(t,e){var r=t[0],i=t[1],o=t[2],s=t[3],n=t[4],a=t[5],l=t[6],c=t[7],u=e[0],h=e[1],d=e[2],p=e[3],f=e[4],m=e[5],_=e[6],g=e[7];return Math.abs(r-u)<=Or.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-h)<=Or.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=Or.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(s-p)<=Or.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(n-f)<=Or.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(a-m)<=Or.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Or.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Or.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},ct.sqrLen=ct.squaredLength=ct.len=ct.length=ct.dot=ct.mul=ct.setReal=ct.getReal=void 0;var Or=ad(gr),mo=ad(Ze),Y_=ad(Xe);function J_(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(J_=function(i){return i?r:e})(t)}function ad(t,e){if(t&&t.__esModule)return t;if(t===null||nd(t)!=="object"&&typeof t!="function")return{default:t};var r=J_(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}function K_(t,e,r){var i=.5*r[0],o=.5*r[1],s=.5*r[2],n=e[0],a=e[1],l=e[2],c=e[3];return t[0]=n,t[1]=a,t[2]=l,t[3]=c,t[4]=i*c+o*l-s*a,t[5]=o*c+s*n-i*l,t[6]=s*c+i*a-o*n,t[7]=-i*n-o*a-s*l,t}function Q_(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 eg(t,e,r){var i=e[0],o=e[1],s=e[2],n=e[3],a=r[4],l=r[5],c=r[6],u=r[7],h=e[4],d=e[5],p=e[6],f=e[7],m=r[0],_=r[1],g=r[2],y=r[3];return t[0]=i*y+n*m+o*g-s*_,t[1]=o*y+n*_+s*m-i*g,t[2]=s*y+n*g+i*_-o*m,t[3]=n*y-i*m-o*_-s*g,t[4]=i*u+n*a+o*c-s*l+h*y+f*m+d*g-p*_,t[5]=o*u+n*l+s*a-i*c+d*y+f*_+p*m-h*g,t[6]=s*u+n*c+i*l-o*a+p*y+f*g+h*_-d*m,t[7]=n*u-i*a-o*l-s*c+f*y-h*m-d*_-p*g,t}ct.getReal=mo.copy,ct.setReal=mo.copy,ct.mul=eg;var tg=mo.dot;ct.dot=tg;var rg=mo.length;ct.length=rg,ct.len=rg;var Bl=mo.squaredLength;ct.squaredLength=Bl,ct.sqrLen=Bl;var tt={};function ld(t){return ld=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ld(t)}Object.defineProperty(tt,"__esModule",{value:!0}),tt.create=og,tt.clone=function(t){var e=new bs.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},tt.fromValues=function(t,e){var r=new bs.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r},tt.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},tt.set=function(t,e,r){return t[0]=e,t[1]=r,t},tt.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},tt.subtract=sg,tt.multiply=ng,tt.divide=ag,tt.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},tt.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},tt.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},tt.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},tt.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},tt.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},tt.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},tt.distance=lg,tt.squaredDistance=cg,tt.length=ug,tt.squaredLength=hg,tt.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},tt.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},tt.normalize=function(t,e){var r=e[0],i=e[1],o=r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t},tt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},tt.cross=function(t,e,r){var i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t},tt.lerp=function(t,e,r,i){var o=e[0],s=e[1];return t[0]=o+i*(r[0]-o),t[1]=s+i*(r[1]-s),t},tt.random=function(t,e){e=e||1;var r=2*bs.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},tt.transformMat2=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t},tt.transformMat2d=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o+r[4],t[1]=r[1]*i+r[3]*o+r[5],t},tt.transformMat3=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[3]*o+r[6],t[1]=r[1]*i+r[4]*o+r[7],t},tt.transformMat4=function(t,e,r){var i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t},tt.rotate=function(t,e,r,i){var o=e[0]-r[0],s=e[1]-r[1],n=Math.sin(i),a=Math.cos(i);return t[0]=o*a-s*n+r[0],t[1]=o*n+s*a+r[1],t},tt.angle=function(t,e){var r=t[0],i=t[1],o=e[0],s=e[1],n=Math.sqrt(r*r+i*i)*Math.sqrt(o*o+s*s);return Math.acos(Math.min(Math.max(n&&(r*o+i*s)/n,-1),1))},tt.zero=function(t){return t[0]=0,t[1]=0,t},tt.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},tt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},tt.equals=function(t,e){var r=t[0],i=t[1],o=e[0],s=e[1];return Math.abs(r-o)<=bs.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=bs.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))},tt.forEach=tt.sqrLen=tt.sqrDist=tt.dist=tt.div=tt.mul=tt.sub=tt.len=void 0;var bs=function(t,e){if(t&&t.__esModule)return t;if(t===null||ld(t)!=="object"&&typeof t!="function")return{default:t};var r=ig(void 0);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}(gr);function ig(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ig=function(i){return i?r:e})(t)}function og(){var t=new bs.ARRAY_TYPE(2);return bs.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function sg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function ng(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function ag(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function lg(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function cg(t,e){var r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function ug(t){return Math.hypot(t[0],t[1])}function hg(t){var e=t[0],r=t[1];return e*e+r*r}tt.len=ug,tt.sub=sg,tt.mul=ng,tt.div=ag,tt.dist=lg,tt.sqrDist=cg,tt.sqrLen=hg;var Fb=function(){var t=og();return function(e,r,i,o,s,n){var a,l;for(r||(r=2),i||(i=0),l=o?Math.min(o*r+i,e.length):e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}}();function cd(t){return cd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cd(t)}tt.forEach=Fb,Object.defineProperty(_r,"__esModule",{value:!0});var Mt=_r.vec4=D=_r.vec3=_r.vec2=_r.quat2=Ar=_r.quat=V=_r.mat4=Fr=_r.mat3=_r.mat2d=an=_r.mat2=_r.glMatrix=void 0,Nb=Zi(gr);_r.glMatrix=Nb;var Ub=Zi(jt),an=_r.mat2=Ub,Vb=Zi(qt);_r.mat2d=Vb;var jb=Zi(zt),Fr=_r.mat3=jb,Gb=Zi(Xe),V=_r.mat4=Gb,qb=Zi(Ze),Ar=_r.quat=qb,Zb=Zi(ct);_r.quat2=Zb;var $b=Zi(tt);_r.vec2=$b;var Hb=Zi(We),D=_r.vec3=Hb,Wb=Zi(nt);function dg(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(dg=function(i){return i?r:e})(t)}function Zi(t,e){if(t&&t.__esModule)return t;if(t===null||cd(t)!=="object"&&typeof t!="function")return{default:t};var r=dg(e);if(r&&r.has(t))return r.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&Object.prototype.hasOwnProperty.call(t,s)){var n=o?Object.getOwnPropertyDescriptor(t,s):null;n&&(n.get||n.set)?Object.defineProperty(i,s,n):i[s]=t[s]}return i.default=t,r&&r.set(t,i),i}Mt=_r.vec4=Wb;const Xb=xt([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ol}=Xb,pg=xt([{name:"a_pos_3",components:3,type:"Int16"}]);var Lo=xt([{name:"a_pos",type:"Int16",components:2}]),fg={};(function(t,e){(function(r){function i(s,n,a){var l=o(256*s,256*(n=Math.pow(2,a)-n-1),a),c=o(256*(s+1),256*(n+1),a);return l[0]+","+l[1]+","+c[0]+","+c[1]}function o(s,n,a){var l=2*Math.PI*6378137/256/Math.pow(2,a);return[s*l-2*Math.PI*6378137/2,n*l-2*Math.PI*6378137/2]}r.getURL=function(s,n,a,l,c,u){return u=u||{},s+"?"+["bbox="+i(a,l,c),"format="+(u.format||"image/png"),"service="+(u.service||"WMS"),"version="+(u.version||"1.1.1"),"request="+(u.request||"GetMap"),"srs="+(u.srs||"EPSG:3857"),"width="+(u.width||256),"height="+(u.height||256),"layers="+n].join("&")},r.getTileBBox=i,r.getMercCoords=o,Object.defineProperty(r,"__esModule",{value:!0})})(e)})(0,fg);var Yb=fg;class _i{constructor(e,r,i){this.z=e,this.x=r,this.y=i,this.key=aa(0,e,e,r,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r){const i=Yb.getTileBBox(this.x,this.y,this.z),o=function(s,n,a){let l,c="";for(let u=s;u>0;u--)l=1<<u-1,c+=(n&l?1:0)+(a&l?2:0);return c}(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(r==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",o).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ud{constructor(e,r){this.wrap=e,this.canonical=r,this.key=aa(e,r.z,r.z,r.x,r.y)}}class mt{constructor(e,r,i,o,s){this.overscaledZ=e,this.wrap=r,this.canonical=new _i(i,+o,+s),this.key=r===0&&e===i?this.canonical.key:aa(r,e,i,o,s)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const r=this.canonical.z-e;return e>this.canonical.z?new mt(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new mt(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r=!0){if(this.overscaledZ===e&&r)return this.key;if(e>this.canonical.z)return aa(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return aa(this.wrap*+r,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new mt(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,i=2*this.canonical.x,o=2*this.canonical.y;return[new mt(r,this.wrap,r,i,o),new mt(r,this.wrap,r,i+1,o),new mt(r,this.wrap,r,i,o+1),new mt(r,this.wrap,r,i+1,o+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new mt(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new mt(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 ud(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function aa(t,e,r,i,o){const s=1<<Math.min(r,22);let n=s*(o%s)+i%s;return t&&r<22&&(n+=s*s*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*n+r)+(e-r)}const mg=[t=>{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,r--),new mt(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,r=t.wrap;return e===1<<t.canonical.z&&(e=0,r++),new mt(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>new mt(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(t.canonical.y===0?1<<t.canonical.z:t.canonical.y)-1),t=>new mt(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)];Ee(_i,"CanonicalTileID"),Ee(mt,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});class Fl{constructor(e,r){this.pos=e,this.dir=r}intersectsPlane(e,r,i){const o=D.dot(r,this.dir);if(Math.abs(o)<1e-6)return!1;const s=((e[0]-this.pos[0])*r[0]+(e[1]-this.pos[1])*r[1]+(e[2]-this.pos[2])*r[2])/o;return i[0]=this.pos[0]+this.dir[0]*s,i[1]=this.pos[1]+this.dir[1]*s,i[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(e,r,i){if(D.equals(this.pos,e)||r===0)return i[0]=i[1]=i[2]=0,!1;const[o,s,n]=this.dir,a=this.pos[0]-e[0],l=this.pos[1]-e[1],c=this.pos[2]-e[2],u=o*o+s*s+n*n,h=2*(a*o+l*s+c*n),d=h*h-4*u*(a*a+l*l+c*c-r*r);if(d<0){const p=Math.max(-h/2,0),f=a+o*p,m=l+s*p,_=c+n*p,g=Math.hypot(f,m,_);return i[0]=f*r/g,i[1]=m*r/g,i[2]=_*r/g,!1}{const p=(-h-Math.sqrt(d))/(2*u);if(p<0){const f=Math.hypot(a,l,c);return i[0]=a*r/f,i[1]=l*r/f,i[2]=c*r/f,!1}return i[0]=a+o*p,i[1]=l+s*p,i[2]=c+n*p,!0}}}class hd{constructor(e,r,i,o,s){this.TL=e,this.TR=r,this.BR=i,this.BL=o,this.horizon=s}static fromInvProjectionMatrix(e,r,i){const o=[-1,1,1],s=[1,1,1],n=[1,-1,1],a=[-1,-1,1],l=D.transformMat4(o,o,e),c=D.transformMat4(s,s,e),u=D.transformMat4(n,n,e),h=D.transformMat4(a,a,e);return new hd(l,c,u,h,r/i)}}function la(t,e,r){let i=1/0,o=-1/0;const s=[];for(const n of t){D.sub(s,n,e);const a=D.dot(s,r);i=Math.min(i,a),o=Math.max(o,a)}return[i,o]}function _g(t,e){let r=!0;for(let i=0;i<t.planes.length;i++){const o=t.planes[i];let s=0;for(let n=0;n<e.length;n++)s+=D.dot(o,e[n])+o[3]>=0;if(s===0)return 0;s!==e.length&&(r=!1)}return r?2:1}function gg(t,e){for(const r of t.projections){const i=la(e,t.points[0],r.axis);if(r.projection[1]<i[0]||r.projection[0]>i[1])return 0}return 1}function yg(t,e){let r=0;const i=[0,0,0,0];for(let o=0;o<t.length;o++)i[0]=t[o][0],i[1]=t[o][1],i[2]=t[o][2],i[3]=1,Mt.dot(i,e)>=0&&r++;return r}class _o{constructor(e,r){this.points=e||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=Pt.fromPoints(this.points),this.projections=[],this.frustumEdges=[D.sub([],this.points[2],this.points[3]),D.sub([],this.points[0],this.points[3]),D.sub([],this.points[4],this.points[0]),D.sub([],this.points[5],this.points[1]),D.sub([],this.points[6],this.points[2]),D.sub([],this.points[7],this.points[3])];for(const i of this.frustumEdges){const o=[0,-i[2],i[1]],s=[i[2],0,-i[0]];this.projections.push({axis:o,projection:la(this.points,this.points[0],o)}),this.projections.push({axis:s,projection:la(this.points,this.points[0],s)})}}static fromInvProjectionMatrix(e,r,i,o){const s=Math.pow(2,i),n=[[-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(c=>{const u=Mt.transformMat4([],c,e),h=1/u[3]/r*s;return Mt.mul(u,u,[h,h,o?1/u[3]:h,h])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(c=>{const u=D.sub([],n[c[0]],n[c[1]]),h=D.sub([],n[c[2]],n[c[1]]),d=D.normalize([],D.cross([],u,h)),p=-D.dot(d,n[c[1]]);return d.concat(p)}),l=[];for(let c=0;c<n.length;c++)l.push([n[c][0],n[c][1],n[c][2]]);return new _o(l,a)}intersectsPrecise(e,r,i){for(let o=0;o<r.length;o++)if(!yg(e,r[o]))return 0;for(let o=0;o<this.planes.length;o++)if(!yg(e,this.planes[o]))return 0;for(const o of i)for(const s of this.frustumEdges){const n=D.cross([],o,s),a=D.length(n);if(a===0)continue;D.scale(n,n,1/a);const l=la(this.points,this.points[0],n),c=la(e,this.points[0],n);if(l[0]>c[1]||c[0]>l[1])return 0}return 1}}class Pt{static fromPoints(e){const r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const o of e)D.min(r,r,o),D.max(i,i,o);return new Pt(r,i)}static fromTileIdAndHeight(e,r,i){const o=1<<e.canonical.z,s=e.canonical.x,n=e.canonical.y;return new Pt([s/o,n/o,r],[(s+1)/o,(n+1)/o,i])}static applyTransform(e,r){const i=e.getCorners();for(let o=0;o<i.length;++o)D.transformMat4(i[o],i[o],r);return Pt.fromPoints(i)}static projectAabbCorners(e,r){const i=e.getCorners();for(let o=0;o<i.length;++o)D.transformMat4(i[o],i[o],r);return i}constructor(e,r){this.min=e,this.max=r,this.center=D.scale([],D.add([],this.min,this.max),.5)}quadrant(e){const r=[e%2==0,e<2],i=D.clone(this.min),o=D.clone(this.max);for(let s=0;s<r.length;s++)i[s]=r[s]?this.min[s]:this.center[s],o[s]=r[s]?this.center[s]:this.max[s];return o[2]=this.max[2],new Pt(i,o)}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,r=this.max;return[[e[0],e[1],e[2]],[r[0],e[1],e[2]],[r[0],r[1],e[2]],[e[0],r[1],e[2]],[e[0],e[1],r[2]],[r[0],e[1],r[2]],[r[0],r[1],r[2]],[e[0],r[1],r[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?_g(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?_g(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,r){return r||this.intersects(e)?gg(e,this.getCorners()):0}intersectsPreciseFlat(e,r){return r||this.intersectsFlat(e)?gg(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 r=0;r<3;++r)if(this.min[r]>e.max[r]||e.min[r]>this.max[r])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 r=0;r<3;r++)this.min[r]=Math.min(this.min[r],e.min[r]),this.max[r]=Math.max(this.max[r],e.max[r])}encapsulatePoint(e){for(let r=0;r<3;r++)this.min[r]=Math.min(this.min[r],e[r]),this.max[r]=Math.max(this.max[r],e[r])}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])]}}Ee(Pt,"Aabb");const ca=5,Bo=6,Pr=W/Math.PI/2,Jb=16383,ln=64,dd=[ln,32,16],gi=-Pr,yi=Pr,Kb=[new Pt([gi,gi,gi],[yi,yi,yi]),new Pt([gi,gi,gi],[0,0,yi]),new Pt([0,gi,gi],[yi,0,yi]),new Pt([gi,0,gi],[0,yi,yi]),new Pt([0,0,gi],[yi,yi,yi])];function Nl(t){return t*Pr/un}function xg(t,e,r,i=!0){const o=D.scale([],t._camera.position,t.worldSize),s=[e,r,1,1];Mt.transformMat4(s,s,t.pixelMatrixInverse),Mt.scale(s,s,1/s[3]);const n=D.sub([],s,o),a=D.normalize([],n),l=t.globeMatrix,c=[l[12],l[13],l[14]],u=D.sub([],c,o),h=D.length(u),d=D.normalize([],u),p=t.worldSize/(2*Math.PI),f=D.dot(d,a),m=Math.asin(p/h);if(m<Math.acos(f)){if(!i)return null;const I=[],C=[];D.scale(I,a,h/f),D.normalize(C,D.sub(C,I,u)),D.normalize(a,D.add(a,u,D.scale(a,C,Math.tan(m)*h)))}const _=[];new Fl(o,a).closestPointOnSphere(c,p,_);const g=D.normalize([],$t(l,0)),y=D.normalize([],$t(l,1)),v=D.normalize([],$t(l,2)),b=D.dot(g,_),x=D.dot(y,_),w=D.dot(v,_),T=br(Math.asin(-x/p));let E=br(Math.atan2(b,w));E=t.center.lng+function(I,C){const k=(C-I+180)%360-180;return k<-180?k+360:k}(t.center.lng,E);const M=ur(E),S=Se(dr(T),0,1);return new lt(M,S)}class Qb{constructor(e,r,i){this.a=D.sub([],e,i),this.b=D.sub([],r,i),this.center=i;const o=D.normalize([],this.a),s=D.normalize([],this.b);this.angle=Math.acos(D.dot(o,s))}}function pd(t,e){if(t.angle===0)return null;let r;return r=t.a[e]===0?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)),r<0||r>1?null:function(i,o,s,n){const a=Math.sin(s);return i*(Math.sin((1-n)*s)/a)+o*(Math.sin(n*s)/a)}(t.a[e],t.b[e],t.angle,Se(r,0,1))+t.center[e]}function si(t){if(t.z<=1)return Kb[t.z+2*t.y+t.x];const e=md(Ul(t));return Pt.fromPoints(e)}function go(t,e,r){return D.scale(t,t,1-r),D.scaleAndAdd(t,t,e,r)}function vg(t,e){const r=yr(e.zoom);if(r===0)return si(t);const i=Ul(t),o=md(i),s=ur(i.getWest())*e.worldSize,n=ur(i.getEast())*e.worldSize,a=dr(i.getNorth())*e.worldSize,l=dr(i.getSouth())*e.worldSize,c=[s,a,0],u=[n,a,0],h=[s,l,0],d=[n,l,0],p=V.invert([],e.globeMatrix);return D.transformMat4(c,c,p),D.transformMat4(u,u,p),D.transformMat4(h,h,p),D.transformMat4(d,d,p),o[0]=go(o[0],h,r),o[1]=go(o[1],d,r),o[2]=go(o[2],u,r),o[3]=go(o[3],c,r),Pt.fromPoints(o)}function bg(t,e,r){for(const i of t)D.transformMat4(i,i,e),D.scale(i,i,r)}function fd(t,e,r,i){const o=e/t.worldSize,s=t.globeMatrix;if(r.z<=1){const M=si(r).getCorners();return bg(M,s,o),Pt.fromPoints(M)}const n=Ul(r,i),a=md(n);bg(a,s,o);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(n.contains(t.center)){for(const I of a)D.min(u,u,I),D.max(c,c,I);c[2]=0;const M=t.point,S=[M.x*o,M.y*o,0];return D.min(u,u,S),D.max(c,c,S),new Pt(u,c)}const h=[s[12]*o,s[13]*o,s[14]*o],d=n.getCenter(),p=Se(t.center.lat,-Jt,Jt),f=Se(d.lat,-Jt,Jt),m=ur(t.center.lng),_=dr(p);let g=m-ur(d.lng);const y=_-dr(f);g>.5?g-=1:g<-.5&&(g+=1);let v=0;if(Math.abs(g)>Math.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const M=[s[4]*o,s[5]*o,s[6]*o],S=-Math.sin($e(y>=0?n.getSouth():n.getNorth()))*Pr;D.scaleAndAdd(h,h,M,S)}const b=a[v],x=a[(v+1)%4],w=new Qb(b,x,h),T=[pd(w,0)||b[0],pd(w,1)||b[1],pd(w,2)||b[2]],E=yr(t.zoom);if(E>0){const M=function({x:I,y:C,z:k},A,L,O,U){const R=1/(1<<k);let B=I*R,G=B+R,Z=C*R,q=Z+R,X=0;const Y=(B+G)/2-O;return Y>.5?X=-1:Y<-.5&&(X=1),B=((B+X)*A-(O*=A))*L+O,G=((G+X)*A-O)*L+O,Z=(Z*A-(U*=A))*L+U,q=(q*A-U)*L+U,[[B,q,0],[G,q,0],[G,Z,0],[B,Z,0]]}(r,e,t._pixelsPerMercatorPixel,m,_);for(let I=0;I<a.length;I++)go(a[I],M[I],E);const S=D.add([],M[v],M[(v+1)%4]);D.scale(S,S,.5),go(T,S,E)}for(const M of a)D.min(u,u,M),D.max(c,c,M);return u[2]=Math.min(b[2],x[2]),D.min(u,u,T),D.max(c,c,T),new Pt(u,c)}function Ul({x:t,y:e,z:r},i=!1){const o=1/(1<<r),s=new Ne(Jr(t*o),e===(1<<r)-1&&i?-90:ar((e+1)*o)),n=new Ne(Jr((t+1)*o),e===0&&i?90:ar(e*o));return new Yr(s,n)}function md(t){const e=$e(t.getNorth()),r=$e(t.getSouth()),i=Math.cos(e),o=Math.cos(r),s=Math.sin(e),n=Math.sin(r),a=t.getWest(),l=t.getEast();return[cn(o,n,a),cn(o,n,l),cn(i,s,l),cn(i,s,a)]}function cn(t,e,r,i=Pr){return r=$e(r),[t*Math.sin(r)*i,-e*i,t*Math.cos(r)*i]}function Nr(t,e,r){return cn(Math.cos($e(t)),Math.sin($e(t)),e,r)}function ua(t,e,r,i){const o=1<<r.z,s=(t/W+r.x)/o;return Nr(ar((e/W+r.y)/o),Jr(s),i)}function Vl({min:t,max:e}){return Jb/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const wg=new Float64Array(16);function Oo(t){const e=Vl(t),r=V.fromScaling(wg,[e,e,e]);return V.translate(r,r,D.negate([],t.min))}function _d(t){const e=V.fromTranslation(wg,t.min),r=1/Vl(t);return V.scale(e,e,[r,r,r])}function gd(t){const e=W/(2*Math.PI);return t/(2*Math.PI)/e}function Tg(t,e){return W/(512*Math.pow(2,t))*Vl(si(e))}function Eg(t,e,r,i,o){const s=gd(r),n=[t,e,-r/(2*Math.PI)],a=V.identity(new Float64Array(16));return V.translate(a,a,n),V.scale(a,a,[s,s,s]),V.rotateX(a,a,$e(-o)),V.rotateY(a,a,$e(-i)),a}function Mg(t){const e=t.pixelsPerMeter,r=e/It(1,t.center.lat),i=V.identity(new Float64Array(16));return V.translate(i,i,[t.point.x,t.point.y,0]),V.scale(i,i,[r,r,e]),Float32Array.from(i)}function yr(t){return Fi(ca,Bo,t)}function Sg(t,e,r){const i=V.identity(new Float64Array(16)),o=(e/(1<<t)-.5)*Math.PI*2;return V.rotateY(i,r.globeMatrix,o),Float32Array.from(i)}function Ag(t,e,r){const i=yr(r.zoom),o=t.style.map._antialias,s=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return i===0&&!o&&!s}function Ig(t,e,r,i){const o=e.getNorth(),s=e.getSouth(),n=e.getWest(),a=e.getEast(),l=1<<t.z,c=a-n,u=o-s,h=c/ln,d=-u/dd[r],p=[0,h,0,d,0,0,o,n,0];if(t.z>0){const f=180/i;Fr.multiply(p,p,[f/c+1,0,0,0,f/u+1,0,-.5*f/h,.5*f/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p}function ew(t){const e=Jt-5;t=Se(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin($e(t))),3);return Math.round(r*(dd.length-1))}function Cg(t){const e=[0,0,0],r=V.identity(new Float64Array(16));return V.multiply(r,t.pixelMatrix,t.globeMatrix),D.transformMat4(e,e,r),new N(e[0],e[1])}function zg(t,e){const r=Nr(e.lat,e.lng),i=function(s){const n=Nr(s._center.lat,s._center.lng),a=D.fromValues(0,1,0);let l=D.cross([],a,n);const c=V.fromRotation([],-s.angle,n);l=D.transformMat4(l,l,c),V.fromRotation(c,-s._pitch,l);const u=D.normalize([],n);return D.scale(u,u,Nl(s.cameraToCenterDistance/s.pixelsPerMeter)),D.transformMat4(u,u,c),D.add([],n,u)}(t),o=D.subtract([],i,r);return D.angle(o,r)}function jl(t,e){return zg(t,e)>Math.PI/2*1.01}const Dg=$e(85),tw=Math.cos(Dg),rw=Math.sin(Dg);class iw{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,r){const i=new Wr,o=new nr,s=[],n=e+1+2,a=r[0]+1,l=r[0]+1+(1+r.length),c=(u,h,d)=>{let p=u===n-1?u-2:u===0?u:u-1;return p+=d?24575:0,[p,h]};for(let u=0;u<n;++u)i.emplaceBack(...c(u,0,!0));for(let u=0;u<a;++u)for(let h=0;h<n;++h)i.emplaceBack(...c(h,u,(h===0||h===n-1)&&!0));for(let u=0;u<r.length;++u){const h=r[u];for(let d=0;d<n;++d)i.emplaceBack(...c(d,h,!0))}for(let u=0;u<r.length;++u){const h=o.length,d=r[u]+1+2,p=new nr;for(let _=0;_<d-1;_++){const g=_===d-2,y=g?n*(l-r.length+u-_):n;for(let v=0;v<n-1;v++){const b=_*n+v;_===0||g||v===0||v===n-2?(p.emplaceBack(b+1,b,b+y),p.emplaceBack(b+y,b+y+1,b+1)):(o.emplaceBack(b+1,b,b+y),o.emplaceBack(b+y,b+y+1,b+1))}}const f=Et.simpleSegment(0,h,i.length,o.length-h);for(let _=0;_<p.uint16.length;_+=3)o.emplaceBack(p.uint16[_],p.uint16[_+1],p.uint16[_+2]);const m=Et.simpleSegment(0,h,i.length,o.length-h);s.push({withoutSkirts:f,withSkirts:m})}return{vertices:i,indices:o,segments:s}}_createGrid(e){const r=this._fillGridMeshWithLods(ln,dd);this._gridSegments=r.segments,this._gridBuffer=e.createVertexBuffer(r.vertices,Lo.members),this._gridIndexBuffer=e.createIndexBuffer(r.indices,!0)}_createPoles(e){const r=new nr;for(let a=0;a<=ln;a++)r.emplaceBack(0,a+1,a+2);this._poleIndexBuffer=e.createIndexBuffer(r,!0);const i=new gs,o=new gs,s=new gs,n=new gs;this._poleSegments=[];for(let a=0,l=0;a<ca;a++){const c=360/(1<<a);i.emplaceBack(0,-Pr,0,.5,0),o.emplaceBack(0,-Pr,0,.5,1),s.emplaceBack(0,-Pr,0,.5,.5),n.emplaceBack(0,-Pr,0,.5,.5);for(let u=0;u<=ln;u++){let h=u/ln,d=0;const p=Fe(0,c,h),[f,m,_]=cn(tw,rw,p,Pr);i.emplaceBack(f,m,_,h,d),o.emplaceBack(f,m,_,h,1-d);const g=$e(p);h=.5+.5*Math.sin(g),d=.5+.5*Math.cos(g),s.emplaceBack(f,m,_,h,d),n.emplaceBack(f,m,_,h,1-d)}this._poleSegments.push(Et.simpleSegment(l,0,66,64)),l+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Ol,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(o,Ol,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(s,Ol,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(n,Ol,!1)}getGridBuffers(e,r){return[this._gridBuffer,this._gridIndexBuffer,r?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,r){return[r?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,r?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}}const un=63710088e-1,yd=2*Math.PI*un;class Fo{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fo(Ni(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,i=this.lat*r,o=e.lat*r,s=Math.sin(i)*Math.sin(o)+Math.cos(i)*Math.cos(o)*Math.cos((e.lng-this.lng)*r);return un*Math.acos(Math.min(s,1))}toBounds(e=0){const r=360*e/40075017,i=r/Math.cos(Math.PI/180*this.lat);return new Yr(new Fo(this.lng-i,this.lat-r),new Fo(this.lng+i,this.lat+r))}toEcef(e){const r=Nl(e);return Nr(this.lat,this.lng,Pr+r)}static convert(e){if(e instanceof Fo)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Fo(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Fo(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>]")}}var Ne=Fo;const ow=0,sw=25.5;function Gl(t){return yd*Math.cos(t*Math.PI/180)}function ur(t){return(180+t)/360}function dr(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function It(t,e){return t/Gl(e)}function Jr(t){return 360*t-180}function ar(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function kg(t,e){return t*Gl(ar(e))}const Jt=85.051129;function Pg(t){return Math.cos($e(Se(t,-Jt,Jt)))}function No(t,e){const r=Se(e,ow,sw),i=Math.pow(2,r);return Pg(t)*yd/(512*i)}function xd(t){return 1/Math.cos(t*Math.PI/180)}function ha(t,e=0){const r=Math.exp(Math.PI*(1-(t.y+e/W)/(1<<t.z)*2));return 80150034*r/(r*r+1)/W/(1<<t.z)}class lt{constructor(e,r,i=0){this.x=+e,this.y=+r,this.z=+i}static fromLngLat(e,r=0){const i=Ne.convert(e);return new lt(ur(i.lng),dr(i.lat),It(r,i.lat))}toLngLat(){return new Ne(Jr(this.x),ar(this.y))}toAltitude(){return kg(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/yd*xd(ar(this.y))}}function vd(t,e,r,i,o,s,n,a,l){const c=(e+i)/2,u=(r+o)/2,h=new N(c,u);a(h),function(d,p,f,m,_,g){const y=f-_,v=m-g;return Math.abs((m-p)*y-(f-d)*v)/Math.hypot(y,v)}(h.x,h.y,s.x,s.y,n.x,n.y)>=l?(vd(t,e,r,c,u,s,h,a,l),vd(t,c,u,i,o,h,n,a,l)):t.push(n)}function Rg(t,e,r){let i=t[0],o=i.x,s=i.y;e(i);const n=[i];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:u}=l;e(l),vd(n,o,s,c,u,i,l,e,r),o=c,s=u,i=l}return n}function bd(t,e,r,i){if(i(e,r)){const o=e.add(r)._mult(.5);bd(t,e,o,i),bd(t,o,r,i)}else t.push(r)}function nw(t,e){let r=t[0];const i=[r];for(let o=1;o<t.length;o++){const s=t[o];bd(i,r,s,e),r=s}return i}const wd=Math.pow(2,14)-1,Lg=-wd-1;function aw(t,e){const r=Math.round(t.x*e),i=Math.round(t.y*e);return t.x=Se(r,Lg,wd),t.y=Se(i,Lg,wd),(r<t.x||r>t.x+1||i<t.y||i>t.y+1)&&F("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function $i(t,e,r){const i=t.loadGeometry(),o=t.extent,s=W/o;if(e&&r&&r.projection.isReprojectedInTileSpace){const n=1<<e.z,{scale:a,x:l,y:c,projection:u}=r,h=d=>{const p=Jr((e.x+d.x/o)/n),f=ar((e.y+d.y/o)/n),m=u.project(p,f);d.x=(m.x*a-l)*o,d.y=(m.y*a-c)*o};for(let d=0;d<i.length;d++)if(t.type!==1)i[d]=Rg(i[d],h,1);else{const p=[];for(const f of i[d])f.x<0||f.x>=o||f.y<0||f.y>=o||(h(f),p.push(f));i[d]=p}}for(const n of i)for(const a of n)aw(a,s);return i}function Uo(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?$i(t):[]}}function ql(t,e,r,i,o){t.emplaceBack(2*e+(i+1)/2,2*r+(o+1)/2)}function Zl(t,e,r){t.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class Td{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Wr,this.indexArray=new nr,this.segments=new Et,this.programConfigurations=new Po(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,i,o){const s=this.layers[0],n=[];let a=null;s.type==="circle"&&(a=s.layout.get("circle-sort-key"));for(const{feature:c,id:u,index:h,sourceLayerIndex:d}of e){const p=this.layers[0]._featureFilter.needGeometry,f=Uo(c,p);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),f,i))continue;const m=a?a.evaluate(f,{},i):void 0,_={id:u,properties:c.properties,type:c.type,sourceLayerIndex:d,index:h,geometry:p?f.geometry:$i(c,i,o),patterns:{},sortKey:m};n.push(_)}a&&n.sort((c,u)=>c.sortKey-u.sortKey);let l=null;o.projection.name==="globe"&&(this.globeExtVertexArray=new Cl,l=o.projection);for(const c of n){const{geometry:u,index:h,sourceLayerIndex:d}=c,p=e[h].feature;this.addFeature(c,u,h,r.availableImages,i,l,r.brightness),r.featureIndex.insert(p,u,h,d,this.index)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gb.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,yb.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,r,i,o,s,n,a){for(const l of r)for(const c of l){const u=c.x,h=c.y;if(u<0||u>=W||h<0||h>=W)continue;if(n){const f=n.projectTilePoint(u,h,s),m=n.upVector(s,u,h),_=this.globeExtVertexArray;Zl(_,f,m),Zl(_,f,m),Zl(_,f,m),Zl(_,f,m)}const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),p=d.vertexLength;ql(this.layoutVertexArray,u,h,-1,-1),ql(this.layoutVertexArray,u,h,1,-1),ql(this.layoutVertexArray,u,h,1,1),ql(this.layoutVertexArray,u,h,-1,1),this.indexArray.emplaceBack(p,p+1,p+2),this.indexArray.emplaceBack(p,p+2,p+3),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},o,s,a)}}function Bg(t,e){for(let r=0;r<t.length;r++)if(Vo(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(Vo(t,e[r]))return!0;return!!Ed(t,e)}function lw(t,e,r){return!!Vo(t,e)||!!Md(e,t,r)}function Og(t,e){if(t.length===1)return Ng(e,t[0]);for(let r=0;r<e.length;r++){const i=e[r];for(let o=0;o<i.length;o++)if(Vo(t,i[o]))return!0}for(let r=0;r<t.length;r++)if(Ng(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(Ed(t,e[r]))return!0;return!1}function cw(t,e,r){if(t.length>1){if(Ed(t,e))return!0;for(let i=0;i<e.length;i++)if(Md(e[i],t,r))return!0}for(let i=0;i<t.length;i++)if(Md(t[i],e,r))return!0;return!1}function Ed(t,e){if(t.length===0||e.length===0)return!1;for(let r=0;r<t.length-1;r++){const i=t[r],o=t[r+1];for(let s=0;s<e.length-1;s++)if(uw(i,o,e[s],e[s+1]))return!0}return!1}function uw(t,e,r,i){return te(t,r,i)!==te(e,r,i)&&te(t,e,r)!==te(t,e,i)}function Md(t,e,r){const i=r*r;if(e.length===1)return t.distSqr(e[0])<i;for(let o=1;o<e.length;o++)if(Fg(t,e[o-1],e[o])<i)return!0;return!1}function Fg(t,e,r){const i=e.distSqr(r);if(i===0)return t.distSqr(e);const o=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/i;return t.distSqr(o<0?e:o>1?r:r.sub(e)._mult(o)._add(e))}function Ng(t,e){let r,i,o,s=!1;for(let n=0;n<t.length;n++){r=t[n];for(let a=0,l=r.length-1;a<r.length;l=a++)i=r[a],o=r[l],i.y>e.y!=o.y>e.y&&e.x<(o.x-i.x)*(e.y-i.y)/(o.y-i.y)+i.x&&(s=!s)}return s}function Vo(t,e){let r=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const s=t[i],n=t[o];s.y>e.y!=n.y>e.y&&e.x<(n.x-s.x)*(e.y-s.y)/(n.y-s.y)+s.x&&(r=!r)}return r}function Ug(t,e,r,i,o){for(const n of t)if(e<=n.x&&r<=n.y&&i>=n.x&&o>=n.y)return!0;const s=[new N(e,r),new N(e,o),new N(i,o),new N(i,r)];if(t.length>2){for(const n of s)if(Vo(t,n))return!0}for(let n=0;n<t.length-1;n++)if(hw(t[n],t[n+1],s))return!0;return!1}function hw(t,e,r){const i=r[0],o=r[2];if(t.x<i.x&&e.x<i.x||t.x>o.x&&e.x>o.x||t.y<i.y&&e.y<i.y||t.y>o.y&&e.y>o.y)return!1;const s=te(t,e,r[0]);return s!==te(t,e,r[1])||s!==te(t,e,r[2])||s!==te(t,e,r[3])}function hn(t,e,r,i,o,s){let n=e.y-t.y,a=t.x-e.x;if(s=s||0){const l=n*n+a*a;if(l===0)return!0;const c=Math.sqrt(l);n/=c,a/=c}return!((r.x-t.x)*n+(r.y-t.y)*a-s<0||(i.x-t.x)*n+(i.y-t.y)*a-s<0||(o.x-t.x)*n+(o.y-t.y)*a-s<0)}function Sd(t,e,r,i,o,s,n){return!(hn(t,e,i,o,s,n)||hn(e,r,i,o,s,n)||hn(r,t,i,o,s,n)||hn(i,o,t,e,r,n)||hn(o,s,t,e,r,n)||hn(s,i,t,e,r,n))}function dn(t,e,r){const i=e.paint.get(t).value;return i.kind==="constant"?i.value:r.programConfigurations.get(e.id).getMaxValue(t)}function $l(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Vg(t,e,r,i,o){if(!e[0]&&!e[1])return t;const s=N.convert(e)._mult(o);r==="viewport"&&s._rotate(-i);const n=[];for(let a=0;a<t.length;a++)n.push(t[a].sub(s));return n}function jg(t,e,r,i){const o=N.convert(t)._mult(i);return e==="viewport"&&o._rotate(-r),o}Ee(Td,"CircleBucket",{omit:["layers"]});const dw=new Xt({"circle-sort-key":new ke(j.layout_circle["circle-sort-key"]),visibility:new se(j.layout_circle.visibility)});var pw={paint:new Xt({"circle-radius":new ke(j.paint_circle["circle-radius"]),"circle-color":new ke(j.paint_circle["circle-color"]),"circle-blur":new ke(j.paint_circle["circle-blur"]),"circle-opacity":new ke(j.paint_circle["circle-opacity"]),"circle-translate":new se(j.paint_circle["circle-translate"]),"circle-translate-anchor":new se(j.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new se(j.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new se(j.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ke(j.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ke(j.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ke(j.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new se(j.paint_circle["circle-emissive-strength"])}),layout:dw};const fw=V.create(),mw=(t,e,r,i,o,s)=>{const n=t.transform,a=n.projection.name==="globe";let l;if(s.paint.get("circle-pitch-alignment")==="map")if(a){const u=Tg(n.zoom,e.canonical)*n._pixelsPerMercatorPixel;l=Float32Array.from([u,0,0,u])}else l=n.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([n.pixelsToGLUnits[0],0,0,n.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(n.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:je.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:fw,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],c.u_zoom_transition=yr(n.zoom);const u=o[0]*W,h=o[1]*W;c.u_up_dir=n.projection.upVector(new _i(0,0,0),u,h)}return c},Gg=t=>{const e=[];return t.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),t.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function qg(t,e,r,i,o,s,n,a,l){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=r.projection.upVectorScale(c,r.center.lat,r.worldSize).metersToTile;for(const h of e)for(const d of h){const p=d.add(a),f=o&&r.elevation?r.elevation.exaggeration()*o.getElevationAt(p.x,p.y,!0):0,m=r.projection.projectTilePoint(p.x,p.y,c);if(f>0){const v=r.projection.upVector(c,p.x,p.y);m.x+=v[0]*u*f,m.y+=v[1]*u*f,m.z+=v[2]*u*f}const _=s?p:_w(m.x,m.y,m.z,i),g=s?t.tilespaceRays.map(v=>yw(v,f)):t.queryGeometry.screenGeometry,y=Mt.transformMat4([],[m.x,m.y,m.z,1],i);if(!n&&s?l*=y[3]/r.cameraToCenterDistance:n&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const v=ar((d.y/W+c.y)/(1<<c.z));l/=r.projection.pixelsPerMeter(v,1)/It(1,v)}if(lw(g,_,l))return!0}return!1}function _w(t,e,r,i){const o=Mt.transformMat4([],[t,e,r,1],i);return new N(o[0]/o[3],o[1]/o[3])}const Zg=D.fromValues(0,0,0),gw=D.fromValues(0,0,1);function yw(t,e){const r=D.create();return Zg[2]=e,t.intersectsPlane(Zg,gw,r),new N(r[0],r[1])}class $g extends Td{}function Hg(t,{width:e,height:r},i,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==e*r*i)throw new RangeError("mismatched image size")}else o=new Uint8Array(e*r*i);return t.width=e,t.height=r,t.data=o,t}function Wg(t,e,r){const{width:i,height:o}=e;i===t.width&&o===t.height||(Ad(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,i),height:Math.min(t.height,o)},r),t.width=i,t.height=o,t.data=e.data)}function Ad(t,e,r,i,o,s){if(o.width===0||o.height===0)return e;if(o.width>t.width||o.height>t.height||r.x>t.width-o.width||r.y>t.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||i.x>e.width-o.width||i.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const n=t.data,a=e.data;for(let l=0;l<o.height;l++){const c=((r.y+l)*t.width+r.x)*s,u=((i.y+l)*e.width+i.x)*s;for(let h=0;h<o.width*s;h++)a[u+h]=n[c+h]}return e}Ee($g,"HeatmapBucket",{omit:["layers"]});class yo{constructor(e,r){Hg(this,e,1,r)}resize(e){Wg(this,new yo(e),1)}clone(){return new yo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,o,s){Ad(e,r,i,o,s,1)}}class ir{constructor(e,r){Hg(this,e,4,r)}resize(e){Wg(this,new ir(e),4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new ir({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,o,s){Ad(e,r,i,o,s,4)}}class Xg{constructor(e,r){this.width=e.width,this.height=e.height,this.data=r instanceof Uint8Array?new Float32Array(r.buffer):r}}Ee(yo,"AlphaImage"),Ee(ir,"RGBAImage");const xw=new Xt({visibility:new se(j.layout_heatmap.visibility)});var vw={paint:new Xt({"heatmap-radius":new ke(j.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ke(j.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new se(j.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ta(j.paint_heatmap["heatmap-color"]),"heatmap-opacity":new se(j.paint_heatmap["heatmap-opacity"])}),layout:xw};function Hl(t){const e={},r=t.resolution||256,i=t.clips?t.clips.length:1,o=t.image||new ir({width:r,height:i}),s=(n,a,l)=>{e[t.evaluationKey]=l;const c=t.expression.evaluate(e);c&&(o.data[n+a+0]=Math.floor(255*c.r/c.a),o.data[n+a+1]=Math.floor(255*c.g/c.a),o.data[n+a+2]=Math.floor(255*c.b/c.a),o.data[n+a+3]=Math.floor(255*c.a))};if(t.clips)for(let n=0,a=0;n<i;++n,a+=4*r)for(let l=0,c=0;l<r;l++,c+=4){const u=l/(r-1),{start:h,end:d}=t.clips[n];s(a,c,h*(1-u)+d*u)}else for(let n=0,a=0;n<r;n++,a+=4)s(0,a,n/(r-1));return o}const bw=new Xt({visibility:new se(j.layout_hillshade.visibility)});var ww={paint:new Xt({"hillshade-illumination-direction":new se(j.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new se(j.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new se(j.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new se(j.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new se(j.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new se(j.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new se(j.paint_hillshade["hillshade-emissive-strength"])}),layout:bw};const Tw=xt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ew}=Tw;var Id={exports:{}};function Wl(t,e,r){r=r||2;var i,o,s,n,a,l,c,u=e&&e.length,h=u?e[0]*r:t.length,d=Yg(t,0,h,r,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(m,_,g,y){var v,b,x,w=[];for(v=0,b=_.length;v<b;v++)(x=Yg(m,_[v]*y,v<b-1?_[v+1]*y:m.length,y,!1))===x.next&&(x.steiner=!0),w.push(kw(x));for(w.sort(Cw),v=0;v<w.length;v++)g=zw(w[v],g);return g}(t,e,d,r)),t.length>80*r){i=s=t[0],o=n=t[1];for(var f=r;f<h;f+=r)(a=t[f])<i&&(i=a),(l=t[f+1])<o&&(o=l),a>s&&(s=a),l>n&&(n=l);c=(c=Math.max(s-i,n-o))!==0?32767/c:0}return da(d,p,r,i,o,c,0),p}function Yg(t,e,r,i,o){var s,n;if(o===Dd(t,e,r,i)>0)for(s=e;s<r;s+=i)n=Qg(s,t[s],t[s+1],n);else for(s=r-i;s>=e;s-=i)n=Qg(s,t[s],t[s+1],n);return n&&Xl(n,n.next)&&(fa(n),n=n.next),n}function ws(t,e){if(!t)return t;e||(e=t);var r,i=t;do if(r=!1,i.steiner||!Xl(i,i.next)&&hr(i.prev,i,i.next)!==0)i=i.next;else{if(fa(i),(i=e=i.prev)===i.next)break;r=!0}while(r||i!==e);return e}function da(t,e,r,i,o,s,n){if(t){!n&&s&&function(u,h,d,p){var f=u;do f.z===0&&(f.z=Cd(f.x,f.y,h,d,p)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==u);f.prevZ.nextZ=null,f.prevZ=null,function(m){var _,g,y,v,b,x,w,T,E=1;do{for(g=m,m=null,b=null,x=0;g;){for(x++,y=g,w=0,_=0;_<E&&(w++,y=y.nextZ);_++);for(T=E;w>0||T>0&&y;)w!==0&&(T===0||!y||g.z<=y.z)?(v=g,g=g.nextZ,w--):(v=y,y=y.nextZ,T--),b?b.nextZ=v:m=v,v.prevZ=b,b=v;g=y}b.nextZ=null,E*=2}while(x>1)}(f)}(t,i,o,s);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?Sw(t,i,o,s):Mw(t))e.push(a.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),fa(t),t=l.next,c=l.next;else if((t=l)===c){n?n===1?da(t=Aw(ws(t),e,r),e,r,i,o,s,2):n===2&&Iw(t,e,r,i,o,s):da(ws(t),e,r,i,o,s,1);break}}}function Mw(t){var e=t.prev,r=t,i=t.next;if(hr(e,r,i)>=0)return!1;for(var o=e.x,s=r.x,n=i.x,a=e.y,l=r.y,c=i.y,u=o<s?o<n?o:n:s<n?s:n,h=a<l?a<c?a:c:l<c?l:c,d=o>s?o>n?o:n:s>n?s:n,p=a>l?a>c?a:c:l>c?l:c,f=i.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&pn(o,a,s,l,n,c,f.x,f.y)&&hr(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Sw(t,e,r,i){var o=t.prev,s=t,n=t.next;if(hr(o,s,n)>=0)return!1;for(var a=o.x,l=s.x,c=n.x,u=o.y,h=s.y,d=n.y,p=a<l?a<c?a:c:l<c?l:c,f=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,_=u>h?u>d?u:d:h>d?h:d,g=Cd(p,f,e,r,i),y=Cd(m,_,e,r,i),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==o&&v!==n&&pn(a,u,l,h,c,d,v.x,v.y)&&hr(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=_&&b!==o&&b!==n&&pn(a,u,l,h,c,d,b.x,b.y)&&hr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==o&&v!==n&&pn(a,u,l,h,c,d,v.x,v.y)&&hr(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=_&&b!==o&&b!==n&&pn(a,u,l,h,c,d,b.x,b.y)&&hr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Aw(t,e,r){var i=t;do{var o=i.prev,s=i.next.next;!Xl(o,s)&&Jg(o,i,i.next,s)&&pa(o,s)&&pa(s,o)&&(e.push(o.i/r|0),e.push(i.i/r|0),e.push(s.i/r|0),fa(i),fa(i.next),i=t=s),i=i.next}while(i!==t);return ws(i)}function Iw(t,e,r,i,o,s){var n=t;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&Pw(n,a)){var l=Kg(n,a);return n=ws(n,n.next),l=ws(l,l.next),da(n,e,r,i,o,s,0),void da(l,e,r,i,o,s,0)}a=a.next}n=n.next}while(n!==t)}function Cw(t,e){return t.x-e.x}function zw(t,e){var r=function(o,s){var n,a=s,l=o.x,c=o.y,u=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var h=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(h<=l&&h>u&&(u=h,n=a.x<a.next.x?a:a.next,h===l))return n}a=a.next}while(a!==s);if(!n)return null;var d,p=n,f=n.x,m=n.y,_=1/0;a=n;do l>=a.x&&a.x>=f&&l!==a.x&&pn(c<m?l:u,c,f,m,c<m?u:l,c,a.x,a.y)&&(d=Math.abs(c-a.y)/(l-a.x),pa(a,o)&&(d<_||d===_&&(a.x>n.x||a.x===n.x&&Dw(n,a)))&&(n=a,_=d)),a=a.next;while(a!==p);return n}(t,e);if(!r)return e;var i=Kg(r,t);return ws(i,i.next),ws(r,r.next)}function Dw(t,e){return hr(t.prev,t,e.prev)<0&&hr(e.next,t,t.next)<0}function Cd(t,e,r,i,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function kw(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function pn(t,e,r,i,o,s,n,a){return(o-n)*(e-a)>=(t-n)*(s-a)&&(t-n)*(i-a)>=(r-n)*(e-a)&&(r-n)*(s-a)>=(o-n)*(i-a)}function Pw(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(r,i){var o=r;do{if(o.i!==r.i&&o.next.i!==r.i&&o.i!==i.i&&o.next.i!==i.i&&Jg(o,o.next,r,i))return!0;o=o.next}while(o!==r);return!1}(t,e)&&(pa(t,e)&&pa(e,t)&&function(r,i){var o=r,s=!1,n=(r.x+i.x)/2,a=(r.y+i.y)/2;do o.y>a!=o.next.y>a&&o.next.y!==o.y&&n<(o.next.x-o.x)*(a-o.y)/(o.next.y-o.y)+o.x&&(s=!s),o=o.next;while(o!==r);return s}(t,e)&&(hr(t.prev,t,e.prev)||hr(t,e.prev,e))||Xl(t,e)&&hr(t.prev,t,t.next)>0&&hr(e.prev,e,e.next)>0)}function hr(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Xl(t,e){return t.x===e.x&&t.y===e.y}function Jg(t,e,r,i){var o=Jl(hr(t,e,r)),s=Jl(hr(t,e,i)),n=Jl(hr(r,i,t)),a=Jl(hr(r,i,e));return o!==s&&n!==a||!(o!==0||!Yl(t,r,e))||!(s!==0||!Yl(t,i,e))||!(n!==0||!Yl(r,t,i))||!(a!==0||!Yl(r,e,i))}function Yl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Jl(t){return t>0?1:t<0?-1:0}function pa(t,e){return hr(t.prev,t,t.next)<0?hr(t,e,t.next)>=0&&hr(t,t.prev,e)>=0:hr(t,e,t.prev)<0||hr(t,t.next,e)<0}function Kg(t,e){var r=new zd(t.i,t.x,t.y),i=new zd(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=o,o.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function Qg(t,e,r,i){var o=new zd(t,e,r);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function fa(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 zd(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Dd(t,e,r,i){for(var o=0,s=e,n=r-i;s<r;s+=i)o+=(t[n]-t[s])*(t[s+1]+t[n+1]),n=s;return o}Id.exports=Wl,Id.exports.default=Wl,Wl.deviation=function(t,e,r,i){var o=e&&e.length,s=Math.abs(Dd(t,0,o?e[0]*r:t.length,r));if(o)for(var n=0,a=e.length;n<a;n++)s-=Math.abs(Dd(t,e[n]*r,n<a-1?e[n+1]*r:t.length,r));var l=0;for(n=0;n<i.length;n+=3){var c=i[n]*r,u=i[n+1]*r,h=i[n+2]*r;l+=Math.abs((t[c]-t[h])*(t[u+1]-t[c+1])-(t[c]-t[u])*(t[h+1]-t[c+1]))}return s===0&&l===0?0:Math.abs((l-s)/s)},Wl.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},i=0,o=0;o<t.length;o++){for(var s=0;s<t[o].length;s++)for(var n=0;n<e;n++)r.vertices.push(t[o][s][n]);o>0&&r.holes.push(i+=t[o-1].length)}return r};var Kl=li(Id.exports);function kd(t,e){const r=t.length;if(r<=1)return[t];const i=[];let o,s;for(let n=0;n<r;n++){const a=ie(t[n]);a!==0&&(t[n].area=Math.abs(a),s===void 0&&(s=a<0),s===a<0?(o&&i.push(o),o=[t[n]]):o.push(t[n]))}if(o&&i.push(o),e>1)for(let n=0;n<i.length;n++)i[n].length<=e||(_v(i[n],e,1,i[n].length-1,Rw),i[n]=i[n].slice(0,e));return i}function Rw(t,e){return e.area-t.area}function Pd(t,e,r){const i=r.patternDependencies;let o=!1;for(const s of e){const n=s.paint.get(`${t}-pattern`);n.isConstant()||(o=!0);const a=n.constantOr(null);a&&(o=!0,i[a]=!0)}return o}function Rd(t,e,r,i,o){const s=o.patternDependencies;for(const n of e){const a=n.paint.get(`${t}-pattern`).value;if(a.kind!=="constant"){let l=a.evaluate({zoom:i},r,{},o.availableImages);l=l&&l.name?l.name:l,s[l]=!0,r.patterns[n.id]=l}}return r}class Ql{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Wr,this.indexArray=new nr,this.indexArray2=new Do,this.programConfigurations=new Po(e.layers,e.zoom),this.segments=new Et,this.segments2=new Et,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.projection=e.projection}populate(e,r,i,o){this.hasPattern=Pd("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),n=[];for(const{feature:a,id:l,index:c,sourceLayerIndex:u}of e){const h=this.layers[0]._featureFilter.needGeometry,d=Uo(a,h);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),d,i))continue;const p=s?s.evaluate(d,{},i,r.availableImages):void 0,f={id:l,properties:a.properties,type:a.type,sourceLayerIndex:u,index:c,geometry:h?d.geometry:$i(a,i,o),patterns:{},sortKey:p};n.push(f)}s&&n.sort((a,l)=>a.sortKey-l.sortKey);for(const a of n){const{geometry:l,index:c,sourceLayerIndex:u}=a;if(this.hasPattern){const h=Rd("fill",this.layers,a,this.zoom,r);this.patternFeatures.push(h)}else this.addFeature(a,l,c,i,{},r.availableImages,r.brightness);r.featureIndex.insert(e[c].feature,l,c,u,this.index)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}addFeatures(e,r,i,o,s,n){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,r,i,o,n)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ew),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,i,o,s,n=[],a){for(const l of kd(r,500)){let c=0;for(const m of l)c+=m.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),h=u.vertexLength,d=[],p=[];for(const m of l){if(m.length===0)continue;m!==l[0]&&p.push(d.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),d.push(m[0].x),d.push(m[0].y);for(let y=1;y<m.length;y++)this.layoutVertexArray.emplaceBack(m[y].x,m[y].y),this.indexArray2.emplaceBack(g+y-1,g+y),d.push(m[y].x),d.push(m[y].y);_.vertexLength+=m.length,_.primitiveLength+=m.length}const f=Kl(d,p);for(let m=0;m<f.length;m+=3)this.indexArray.emplaceBack(h+f[m],h+f[m+1],h+f[m+2]);u.vertexLength+=c,u.primitiveLength+=f.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,a)}}Ee(Ql,"FillBucket",{omit:["layers","patternFeatures"]});const Lw=new Xt({"fill-sort-key":new ke(j.layout_fill["fill-sort-key"]),visibility:new se(j.layout_fill.visibility)});var Bw={paint:new Xt({"fill-antialias":new se(j.paint_fill["fill-antialias"]),"fill-opacity":new ke(j.paint_fill["fill-opacity"]),"fill-color":new ke(j.paint_fill["fill-color"]),"fill-outline-color":new ke(j.paint_fill["fill-outline-color"]),"fill-translate":new se(j.paint_fill["fill-translate"]),"fill-translate-anchor":new se(j.paint_fill["fill-translate-anchor"]),"fill-pattern":new ke(j.paint_fill["fill-pattern"]),"fill-emissive-strength":new se(j.paint_fill["fill-emissive-strength"])}),layout:Lw};const Ow=xt([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Fw=xt([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Nw=xt([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Uw=xt([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Vw=xt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:jw}=Ow;var ec={},Gw=Ps,ey=fn;function fn(t,e,r,i,o){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,t.readFields(qw,this,e)}function qw(t,e,r){t==1?e.id=r.readVarint():t==2?function(i,o){for(var s=i.readVarint()+i.pos;i.pos<s;){var n=o._keys[i.readVarint()],a=o._values[i.readVarint()];o.properties[n]=a}}(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Zw(t){for(var e,r,i=0,o=0,s=t.length,n=s-1;o<s;n=o++)i+=((r=t[n]).x-(e=t[o]).x)*(e.y+r.y);return i}fn.types=["Unknown","Point","LineString","Polygon"],fn.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,r=t.readVarint()+t.pos,i=1,o=0,s=0,n=0,a=[];t.pos<r;){if(o<=0){var l=t.readVarint();i=7&l,o=l>>3}if(o--,i===1||i===2)s+=t.readSVarint(),n+=t.readSVarint(),i===1&&(e&&a.push(e),e=[]),e.push(new Gw(s,n));else{if(i!==7)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&a.push(e),a},fn.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,n=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(i<=0){var u=t.readVarint();r=7&u,i=u>>3}if(i--,r===1||r===2)(o+=t.readSVarint())<n&&(n=o),o>a&&(a=o),(s+=t.readSVarint())<l&&(l=s),s>c&&(c=s);else if(r!==7)throw new Error("unknown command "+r)}return[n,l,a,c]},fn.prototype.toGeoJSON=function(t,e,r){var i,o,s=this.extent*Math.pow(2,r),n=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=fn.types[this.type];function u(p){for(var f=0;f<p.length;f++){var m=p[f];p[f]=[360*(m.x+n)/s-180,360/Math.PI*Math.atan(Math.exp((180-360*(m.y+a)/s)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(i=0;i<l.length;i++)h[i]=l[i][0];u(l=h);break;case 2:for(i=0;i<l.length;i++)u(l[i]);break;case 3:for(l=function(p){var f=p.length;if(f<=1)return[p];for(var m,_,g=[],y=0;y<f;y++){var v=Zw(p[y]);v!==0&&(_===void 0&&(_=v<0),_===v<0?(m&&g.push(m),m=[p[y]]):m.push(p[y]))}return m&&g.push(m),g}(l),i=0;i<l.length;i++)for(o=0;o<l[i].length;o++)u(l[i][o])}l.length===1?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d};var $w=ey,ty=ry;function ry(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(Hw,this,e),this.length=this._features.length}function Hw(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(function(i){for(var o=null,s=i.readVarint()+i.pos;i.pos<s;){var n=i.readVarint()>>3;o=n===1?i.readString():n===2?i.readFloat():n===3?i.readDouble():n===4?i.readVarint64():n===5?i.readVarint():n===6?i.readSVarint():n===7?i.readBoolean():null}return o}(r))}ry.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 $w(this._pbf,e,this.extent,this._keys,this._values)};var Ww=ty;function Xw(t,e,r){if(t===3){var i=new Ww(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}var Ld=ec.VectorTile=function(t,e){this.layers=t.readFields(Xw,{},e)},tc=ec.VectorTileFeature=ey;function rc(t,e,r,i){const o=[],s=i===0?(n,a,l,c,u,h)=>{n.push(new N(h,l+(h-a)/(c-a)*(u-l)))}:(n,a,l,c,u,h)=>{n.push(new N(a+(h-l)/(u-l)*(c-a),h))};for(const n of t){const a=[];for(const l of n){if(l.length<=2)continue;const c=[];for(let d=0;d<l.length-1;d++){const p=l[d].x,f=l[d].y,m=l[d+1].x,_=l[d+1].y,g=i===0?p:f,y=i===0?m:_;g<e?y>e&&s(c,p,f,m,_,e):g>r?y<r&&s(c,p,f,m,_,r):c.push(l[d]),y<e&&g>=e&&s(c,p,f,m,_,e),y>r&&g<=r&&s(c,p,f,m,_,r)}let u=l[l.length-1];const h=i===0?u.x:u.y;h>=e&&h<=r&&c.push(u),c.length&&(u=c[c.length-1],c[0].x===u.x&&c[0].y===u.y||c.push(c[0]),a.push(c))}a.length&&o.push(a)}return o}ec.VectorTileLayer=ty;class iy{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const i=e[r];this._stringToNumber[i]=r,this._numberToString[r]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}var Yw={read:function(t,e,r,i,o){var s,n,a=8*o-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?o-1:0,d=r?-1:1,p=t[e+h];for(h+=d,s=p&(1<<-u)-1,p>>=-u,u+=a;u>0;s=256*s+t[e+h],h+=d,u-=8);for(n=s&(1<<-u)-1,s>>=-u,u+=i;u>0;n=256*n+t[e+h],h+=d,u-=8);if(s===0)s=1-c;else{if(s===l)return n?NaN:1/0*(p?-1:1);n+=Math.pow(2,i),s-=c}return(p?-1:1)*n*Math.pow(2,s-i)},write:function(t,e,r,i,o,s){var n,a,l,c=8*s-o-1,u=(1<<c)-1,h=u>>1,d=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:s-1,f=i?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,n=u):(n=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-n))<1&&(n--,l*=2),(e+=n+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(n++,l/=2),n+h>=u?(a=0,n=u):n+h>=1?(a=(e*l-1)*Math.pow(2,o),n+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),n=0));o>=8;t[r+p]=255&a,p+=f,a/=256,o-=8);for(n=n<<o|a,c+=o;c>0;t[r+p]=255&n,p+=f,n/=256,c-=8);t[r+p-f]|=128*m}},oy=Ft,ic=Yw;function Ft(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ft.Varint=0,Ft.Fixed64=1,Ft.Bytes=2,Ft.Fixed32=5;var Bd=4294967296,sy=1/Bd,ny=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function xo(t){return t.type===Ft.Bytes?t.readVarint()+t.pos:t.pos+1}function Jw(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function ay(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(i);for(var o=r.pos-1;o>=t;o--)r.buf[o+i]=r.buf[o]}function Kw(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Qw(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function e2(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function t2(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function r2(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function i2(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function o2(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function s2(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function n2(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function oc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function mn(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function ly(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Ft.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),o=i>>3,s=this.pos;this.type=7&i,t(o,e,this),this.pos===s&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=oc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=ly(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=oc(this.buf,this.pos)+oc(this.buf,this.pos+4)*Bd;return this.pos+=8,t},readSFixed64:function(){var t=oc(this.buf,this.pos)+ly(this.buf,this.pos+4)*Bd;return this.pos+=8,t},readFloat:function(){var t=ic.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ic.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,i=this.buf;return e=127&(r=i[this.pos++]),r<128?e:(e|=(127&(r=i[this.pos++]))<<7,r<128?e:(e|=(127&(r=i[this.pos++]))<<14,r<128?e:(e|=(127&(r=i[this.pos++]))<<21,r<128?e:function(o,s,n){var a,l,c=n.buf;if(a=(112&(l=c[n.pos++]))>>4,l<128||(a|=(127&(l=c[n.pos++]))<<3,l<128)||(a|=(127&(l=c[n.pos++]))<<10,l<128)||(a|=(127&(l=c[n.pos++]))<<17,l<128)||(a|=(127&(l=c[n.pos++]))<<24,l<128)||(a|=(1&(l=c[n.pos++]))<<31,l<128))return Jw(o,a,s);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=i[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&&ny?function(r,i,o){return ny.decode(r.subarray(i,o))}(this.buf,e,t):function(r,i,o){for(var s="",n=i;n<o;){var a,l,c,u=r[n],h=null,d=u>239?4:u>223?3:u>191?2:1;if(n+d>o)break;d===1?u<128&&(h=u):d===2?(192&(a=r[n+1]))==128&&(h=(31&u)<<6|63&a)<=127&&(h=null):d===3?(l=r[n+2],(192&(a=r[n+1]))==128&&(192&l)==128&&((h=(15&u)<<12|(63&a)<<6|63&l)<=2047||h>=55296&&h<=57343)&&(h=null)):d===4&&(l=r[n+2],c=r[n+3],(192&(a=r[n+1]))==128&&(192&l)==128&&(192&c)==128&&((h=(15&u)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||h>=1114112)&&(h=null)),h===null?(h=65533,d=1):h>65535&&(h-=65536,s+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),s+=String.fromCharCode(h),n+=d}return s}(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!==Ft.Bytes)return t.push(this.readVarint(e));var r=xo(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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!==Ft.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===Ft.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ft.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ft.Fixed32)this.pos+=4;else{if(e!==Ft.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),mn(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),mn(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),mn(this.buf,-1&t,this.pos),mn(this.buf,Math.floor(t*sy),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),mn(this.buf,-1&t,this.pos),mn(this.buf,Math.floor(t*sy),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,r){var i,o;if(e>=0?(i=e%4294967296|0,o=e/4294967296|0):(o=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,o=o+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(s,n,a){a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7)}(i,0,r),function(s,n){var a=(7&s)<<4;n.buf[n.pos++]|=a|((s>>>=3)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s|((s>>>=7)?128:0),s&&(n.buf[n.pos++]=127&s)))))}(o,r)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(i,o,s){for(var n,a,l=0;l<o.length;l++){if((n=o.charCodeAt(l))>55295&&n<57344){if(!a){n>56319||l+1===o.length?(i[s++]=239,i[s++]=191,i[s++]=189):a=n;continue}if(n<56320){i[s++]=239,i[s++]=191,i[s++]=189,a=n;continue}n=a-55296<<10|n-56320|65536,a=null}else a&&(i[s++]=239,i[s++]=191,i[s++]=189,a=null);n<128?i[s++]=n:(n<2048?i[s++]=n>>6|192:(n<65536?i[s++]=n>>12|224:(i[s++]=n>>18|240,i[s++]=n>>12&63|128),i[s++]=n>>6&63|128),i[s++]=63&n|128)}return s}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&ay(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),ic.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ic.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 r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&ay(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Ft.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Kw,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Qw,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,r2,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,e2,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,t2,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,i2,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,o2,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,s2,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,n2,e)},writeBytesField:function(t,e){this.writeTag(t,Ft.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ft.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ft.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ft.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ft.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ft.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var sc=li(oy);const a2=["tile","layer","source","sourceLayer","state"];class cy{constructor(e,r,i,o,s){this.type="Feature",this._vectorTileFeature=e,this._z=r,this._x=i,this._y=o,this.properties=e.properties,this.id=s}get geometry(){return this._geometry===void 0&&(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};this.id!==void 0&&(e.id=this.id);for(const r of a2)this[r]!==void 0&&(e[r]=this[r]);return e}}class l2{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,i){const o=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},Te(this.stateChanges[e][o],i),this.deletedStates[e]===null){this.deletedStates[e]={};for(const s in this.state[e])s!==o&&(this.deletedStates[e][s]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(const s in this.state[e][o])i[s]||(this.deletedStates[e][o][s]=null)}else for(const s in i)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][s]===null&&delete this.deletedStates[e][o][s]}removeFeatureState(e,r,i){if(this.deletedStates[e]===null)return;const o=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&r!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(r!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,r){const i=String(r),o=Te({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const s=this.deletedStates[e][r];if(s===null)return{};for(const n in s)delete o[n]}return o}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){const i={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const s={};for(const n in this.stateChanges[o])this.state[o][n]||(this.state[o][n]={}),Te(this.state[o][n],this.stateChanges[o][n]),s[n]=this.state[o][n];i[o]=s}for(const o in this.deletedStates){this.state[o]=this.state[o]||{};const s={};if(this.deletedStates[o]===null)for(const n in this.state[o])s[n]={},this.state[o][n]={};else for(const n in this.deletedStates[o]){if(this.deletedStates[o][n]===null)this.state[o][n]={};else if(this.state[o][n])for(const a of Object.keys(this.deletedStates[o][n]))delete this.state[o][n][a];s[n]=this.state[o][n]}i[o]=i[o]||{},Te(i[o],s)}if(this.stateChanges={},this.deletedStates={},Object.keys(i).length!==0)for(const o in e)e[o].setFeatureState(i,r)}}class uy{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,r){const i=this.toIdx(e,r);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,r){return this.leaves[this.toIdx(e,r)]}toIdx(e,r){return r*this.size+e}}function hy(t,e,r,i){let o=0,s=Number.MAX_VALUE;for(let n=0;n<3;n++)if(Math.abs(i[n])<1e-15){if(r[n]<t[n]||r[n]>e[n])return null}else{const a=1/i[n];let l=(t[n]-r[n])*a,c=(e[n]-r[n])*a;if(l>c){const u=l;l=c,c=u}if(l>o&&(o=l),c<s&&(s=c),o>s)return null}return o}function dy(t,e,r,i,o,s,n,a,l,c,u){const h=i-t,d=o-e,p=s-r,f=n-t,m=a-e,_=l-r,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,v=u[0]*m-u[1]*f,b=h*g+d*y+p*v;if(Math.abs(b)<1e-15)return null;const x=1/b,w=c[0]-t,T=c[1]-e,E=c[2]-r,M=(w*g+T*y+E*v)*x;if(M<0||M>1)return null;const S=T*p-E*d,I=E*h-w*p,C=w*d-T*h,k=(u[0]*S+u[1]*I+u[2]*C)*x;return k<0||M+k>1?null:(f*S+m*I+_*C)*x}function py(t,e,r){return(t-e)/(r-e)}function fy(t,e,r,i,o,s,n,a,l){const c=1<<r,u=s-i,h=n-o,d=(t+1)/c*u+i,p=(e+0)/c*h+o,f=(e+1)/c*h+o;a[0]=(t+0)/c*u+i,a[1]=p,l[0]=d,l[1]=f}class my{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 r=function(s){const n=Math.ceil(Math.log2(s.dim/8)),a=[];let l=Math.ceil(Math.pow(2,n));const c=1/l,u=(p,f,m,_,g)=>{const y=_?1:0,v=(p+1)*m-y,b=f*m,x=(f+1)*m-y;g[0]=p*m,g[1]=b,g[2]=v,g[3]=x};let h=new uy(l);const d=[];for(let p=0;p<l*l;p++){u(p%l,Math.floor(p/l),c,!1,d);const f=jo(d[0],d[1],s),m=jo(d[2],d[1],s),_=jo(d[2],d[3],s),g=jo(d[0],d[3],s);h.minimums.push(Math.min(f,m,_,g)),h.maximums.push(Math.max(f,m,_,g)),h.leaves.push(1)}for(a.push(h),l/=2;l>=1;l/=2){const p=a[a.length-1];h=new uy(l);for(let f=0;f<l*l;f++){u(f%l,Math.floor(f/l),2,!0,d);const m=p.getElevation(d[0],d[1]),_=p.getElevation(d[2],d[1]),g=p.getElevation(d[2],d[3]),y=p.getElevation(d[0],d[3]),v=p.isLeaf(d[0],d[1]),b=p.isLeaf(d[2],d[1]),x=p.isLeaf(d[2],d[3]),w=p.isLeaf(d[0],d[3]),T=Math.min(m.min,_.min,g.min,y.min),E=Math.max(m.max,_.max,g.max,y.max),M=v&&b&&x&&w;h.maximums.push(E),h.minimums.push(T),h.leaves.push(E-T<=5&&M?1:0)}a.push(h)}return a}(this.dem),i=r.length-1,o=r[i];this._addNode(o.minimums[0],o.maximums[0],o.leaves[0]),this._construct(r,0,0,i,0)}raycastRoot(e,r,i,o,s,n,a=1){return hy([e,r,-100],[i,o,this.maximums[0]*a],s,n)}raycast(e,r,i,o,s,n,a=1){if(!this.nodeCount)return null;const l=this.raycastRoot(e,r,i,o,s,n,a);if(l==null)return null;const c=[],u=[],h=[],d=[],p=[{idx:0,t:l,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:f,t:m,nodex:_,nodey:g,depth:y}=p.pop();if(this.leaves[f]){fy(_,g,y,e,r,i,o,h,d);const b=1<<y,x=(_+0)/b,w=(_+1)/b,T=(g+0)/b,E=(g+1)/b,M=jo(x,T,this.dem)*a,S=jo(w,T,this.dem)*a,I=jo(w,E,this.dem)*a,C=jo(x,E,this.dem)*a,k=dy(h[0],h[1],M,d[0],h[1],S,d[0],d[1],I,s,n),A=dy(d[0],d[1],I,h[0],d[1],C,h[0],h[1],M,s,n),L=Math.min(k!==null?k:Number.MAX_VALUE,A!==null?A:Number.MAX_VALUE);if(L!==Number.MAX_VALUE)return L;{const O=D.scaleAndAdd([],s,n,m);if(_y(M,S,C,I,py(O[0],h[0],d[0]),py(O[1],h[1],d[1]))>=O[2])return m}continue}let v=0;for(let b=0;b<this._siblingOffset.length;b++){fy((_<<1)+this._siblingOffset[b][0],(g<<1)+this._siblingOffset[b][1],y+1,e,r,i,o,h,d),h[2]=-100,d[2]=this.maximums[this.childOffsets[f]+b]*a;const x=hy(h,d,s,n);if(x!=null){const w=x;c[b]=w;let T=!1;for(let E=0;E<v&&!T;E++)w>=c[u[E]]&&(u.splice(E,0,b),T=!0);T||(u[v]=b),v++}}for(let b=0;b<v;b++){const x=u[b];p.push({idx:this.childOffsets[f]+x,t:c[x],nodex:(_<<1)+this._siblingOffset[x][0],nodey:(g<<1)+this._siblingOffset[x][1],depth:y+1})}}return null}_addNode(e,r,i){return this.minimums.push(e),this.maximums.push(r),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,r,i,o,s){if(e[o].isLeaf(r,i)===1)return;this.childOffsets[s]||(this.childOffsets[s]=this.nodeCount);const n=o-1,a=e[n];let l=0,c=0;for(let u=0;u<this._siblingOffset.length;u++){const h=2*r+this._siblingOffset[u][0],d=2*i+this._siblingOffset[u][1],p=a.getElevation(h,d),f=a.isLeaf(h,d),m=this._addNode(p.min,p.max,f);f&&(l|=1<<u),c||(c=m)}for(let u=0;u<this._siblingOffset.length;u++)l&1<<u||this._construct(e,2*r+this._siblingOffset[u][0],2*i+this._siblingOffset[u][1],n,c+u)}}function _y(t,e,r,i,o,s){return Fe(Fe(t,r,s),Fe(e,i,s),o)}function jo(t,e,r){const i=r.dim,o=Se(t*i-.5,0,i-1),s=Se(e*i-.5,0,i-1),n=Math.floor(o),a=Math.floor(s),l=Math.min(n+1,i-1),c=Math.min(a+1,i-1);return _y(r.get(n,a),r.get(l,a),r.get(n,c),r.get(l,c),o-n,s-a)}const c2={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function u2(t,e,r){return(256*t*256+256*e+r)/10-1e4}function h2(t,e,r){return 256*t+e+r/256-32768}class nc{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,r,i,o=!1){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(i&&i!=="mapbox"&&i!=="terrarium")return F(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;const s=this.dim=r.height-2,n=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.floatView=new Float32Array(r.data.buffer),this.borderReady=o,this._modifiedForSources={},!o){for(let l=0;l<s;l++)n[this._idx(-1,l)]=n[this._idx(0,l)],n[this._idx(s,l)]=n[this._idx(s-1,l)],n[this._idx(l,-1)]=n[this._idx(l,0)],n[this._idx(l,s)]=n[this._idx(l,s-1)];n[this._idx(-1,-1)]=n[this._idx(0,0)],n[this._idx(s,-1)]=n[this._idx(s-1,0)],n[this._idx(-1,s)]=n[this._idx(0,s-1)],n[this._idx(s,s)]=n[this._idx(s-1,s-1)]}const a=i==="terrarium"?h2:u2;for(let l=0;l<n.length;++l){const c=4*l;this.floatView[l]=a(this.pixels[c],this.pixels[c+1],this.pixels[c+2])}this._timestamp=je.now()}_buildQuadTree(){this._tree=new my(this)}get(e,r,i=!1){i&&(e=Se(e,-1,this.dim),r=Se(r,-1,this.dim));const o=this._idx(e,r);return this.floatView[o]}set(e,r,i){const o=this._idx(e,r),s=this.floatView[o];return this.floatView[o]=i,i-s}static getUnpackVector(e){return c2[e]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}static pack(e,r){const i=[0,0,0,0],o=nc.getUnpackVector(r);let s=Math.floor((e+o[3])/o[2]);return i[2]=s%256,s=Math.floor(s/256),i[1]=s%256,s=Math.floor(s/256),i[0]=s,i}getPixels(){return new Xg({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,r,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(r){case-1:o=s-1;break;case 1:s=o+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const l=-r*this.dim,c=-i*this.dim;for(let u=n;u<a;u++)for(let h=o;h<s;h++){const d=4*this._idx(h,u),p=4*this._idx(h+l,u+c);this.pixels[d+0]=e.pixels[p+0],this.pixels[d+1]=e.pixels[p+1],this.pixels[d+2]=e.pixels[p+2],this.pixels[d+3]=e.pixels[p+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Ee(nc,"DEMData"),Ee(my,"DemMinMaxQuadTree",{omit:["dem"]});class d2{isDataAvailableAtPoint(e){const r=this._source();if(this.isUsingMockSource()||!r||e.y<0||e.y>1)return!1;const i=r.getSource().maxzoom,o=1<<i,s=Math.floor(e.x),n=Math.floor((e.x-s)*o),a=Math.floor(e.y*o),l=this.findDEMTileFor(new mt(i,s,i,n,a));return!(!l||!l.dem)}getAtPointOrZero(e,r=0){return this.getAtPoint(e,r)||0}getAtPoint(e,r,i=!0){if(this.isUsingMockSource())return null;r==null&&(r=null);const o=this._source();if(!o||e.y<0||e.y>1)return r;const s=o.getSource().maxzoom,n=1<<s,a=Math.floor(e.x),l=e.x-a,c=new mt(s,a,s,Math.floor(l*n),Math.floor(e.y*n)),u=this.findDEMTileFor(c);if(!u||!u.dem)return r;const h=u.dem,d=1<<u.tileID.canonical.z,p=(l*d-u.tileID.canonical.x)*h.dim,f=(e.y*d-u.tileID.canonical.y)*h.dim,m=Math.floor(p),_=Math.floor(f);return(i?this.exaggeration():1)*Fe(Fe(h.get(m,_),h.get(m,_+1),f-_),Fe(h.get(m+1,_),h.get(m+1,_+1),f-_),p-m)}getAtTileOffset(e,r,i){const o=1<<e.canonical.z;return this.getAtPointOrZero(new lt(e.wrap+(e.canonical.x+r/W)/o,(e.canonical.y+i/W)/o))}getAtTileOffsetFunc(e,r,i,o){return s=>{const n=this.getAtTileOffset(e,s.x,s.y),a=o.upVector(e.canonical,s.x,s.y),l=o.upVectorScale(e.canonical,r,i).metersToTile;return D.scale(a,a,n*l),a}}getForTilePoints(e,r,i,o){if(this.isUsingMockSource())return!1;const s=_n.create(this,e,o);return!!s&&(r.forEach(n=>{n[2]=this.exaggeration()*s.getElevationAt(n[0],n[1],i)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const r=this.findDEMTileFor(e);if(!r||!r.dem)return null;const i=r.dem.tree,o=r.tileID,s=1<<e.canonical.z-o.canonical.z;let n=e.canonical.x/s-o.canonical.x,a=e.canonical.y/s-o.canonical.y,l=0;for(let c=0;c<e.canonical.z-o.canonical.z&&!i.leaves[l];c++){n*=2,a*=2;const u=2*Math.floor(a)+Math.floor(n);l=i.childOffsets[l]+u,n%=1,a%=1}return{min:this.exaggeration()*i.minimums[l],max:this.exaggeration()*i.maximums[l]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,r,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){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(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(e.length===0)return null;let r=!1,i=Number.MAX_VALUE,o=Number.MIN_VALUE;for(const s of e){const n=this.getMinMaxForTile(s.tileID);n&&(i=Math.min(i,n.min),o=Math.max(o,n.max),r=!0)}return r?{min:i,max:o}:null}}class _n{constructor(e,r,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=r,this._offset=i}static create(e,r,i){const o=i||e.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,n=o.tileID,a=1<<r.canonical.z-n.canonical.z;return new _n(o,s.dim/W/a,[(r.canonical.x/a-n.canonical.x)*s.dim,(r.canonical.y/a-n.canonical.y)*s.dim])}tileCoordToPixel(e,r){const i=r*this._scale+this._offset[1],o=Math.floor(e*this._scale+this._offset[0]),s=Math.floor(i);return new N(o,s)}getElevationAt(e,r,i,o){const s=e*this._scale+this._offset[0],n=r*this._scale+this._offset[1],a=Math.floor(s),l=Math.floor(n),c=this._dem;return o=!!o,i?Fe(Fe(c.get(a,l,o),c.get(a,l+1,o),n-l),Fe(c.get(a+1,l,o),c.get(a+1,l+1,o),n-l),s-a):c.get(a,l,o)}getElevationAtPixel(e,r,i){return this._dem.get(e,r,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*It(1,e)*this._dem.stride}}class Od{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new en(W,16,0),this.featureIndexArray=new $m,this.promoteId=r}insert(e,r,i,o,s,n=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,o,s,n);const l=this.grid;for(let c=0;c<r.length;c++){const u=r[c],h=[1/0,1/0,-1/0,-1/0];for(let d=0;d<u.length;d++){const p=u[d];h[0]=Math.min(h[0],p.x),h[1]=Math.min(h[1],p.y),h[2]=Math.max(h[2],p.x),h[3]=Math.max(h[3],p.y)}h[0]<W&&h[1]<W&&h[2]>=0&&h[3]>=0&&l.insert(a,h[0],h[1],h[2],h[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Ld(new sc(this.rawTileData)).layers,this.sourceLayerCoder=new iy(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,r,i,o){this.loadVTLayers();const s=e.params||{},n=yl(s.filter),a=e.tileResult,l=e.transform,c=a.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(f,m,_,g)=>Ug(a.bufferedTilespaceGeometry,f,m,_,g));u.sort(p2);let h=null;l.elevation&&u.length>0&&(h=_n.create(l.elevation,this.tileID));const d={};let p;for(let f=0;f<u.length;f++){const m=u[f];if(m===p)continue;p=m;const _=this.featureIndexArray.get(m);let g=null;this.loadMatchingFeature(d,_,n,s.layers,s.availableImages,r,i,o,(y,v,b,x=0)=>(g||(g=$i(y,this.tileID.canonical,e.tileTransform)),v.queryIntersectsFeature(a,y,b,g,this.z,e.transform,e.pixelPosMatrix,h,x)))}return d}loadMatchingFeature(e,r,i,o,s,n,a,l,c){const{featureIndex:u,bucketIndex:h,sourceLayerIndex:d,layoutVertexArrayOffset:p}=r,f=this.bucketLayerIDs[h];if(o&&!function(y,v){for(let b=0;b<y.length;b++)if(v.indexOf(y[b])>=0)return!0;return!1}(o,f))return;const m=this.sourceLayerCoder.decode(d),_=this.vtLayers[m].feature(u);if(i.needGeometry){const y=Uo(_,!0);if(!i.filter(new Ut(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!i.filter(new Ut(this.tileID.overscaledZ),_))return;const g=this.getId(_,m);for(let y=0;y<f.length;y++){const v=f[y];if(o&&o.indexOf(v)<0)continue;const b=n[v];if(!b)continue;let x={};g!==void 0&&l&&(x=l.getState(b.sourceLayer||"_geojsonTileLayer",g));const w=Te({},a[v]);w.paint=gy(w.paint,b.paint,_,x,s),w.layout=gy(w.layout,b.layout,_,x,s);const T=!c||c(_,b,x,p);if(!T)continue;const E=new cy(_,this.z,this.x,this.y,g);E.layer=w;let M=e[v];M===void 0&&(M=e[v]=[]),M.push({featureIndex:u,feature:E,intersectionZ:T})}}lookupSymbolFeatures(e,r,i,o,s,n,a,l){const c={};this.loadVTLayers();const u=yl(s);for(const h of e)this.loadMatchingFeature(c,{bucketIndex:i,sourceLayerIndex:o,featureIndex:h,layoutVertexArrayOffset:0},u,n,a,l,r);return c}loadFeature(e){const{featureIndex:r,sourceLayerIndex:i}=e;this.loadVTLayers();const o=this.sourceLayerCoder.decode(i),s=this.vtFeatures[o];if(s[r])return s[r];const n=this.vtLayers[o].feature(r);return s[r]=n,n}hasLayer(e){for(const r of this.bucketLayerIDs)for(const i of r)if(e===i)return!0;return!1}getId(e,r){let i=e.id;if(this.promoteId){const o=typeof this.promoteId=="string"?this.promoteId:this.promoteId[r];o!=null&&(i=e.properties[o]),typeof i=="boolean"&&(i=Number(i))}return i}}function gy(t,e,r,i,o){return Os(t,(s,n)=>{const a=e instanceof ea?e.get(n):null;return a&&a.evaluate?a.evaluate(r,i,o):a})}function p2(t,e){return e-t}Ee(Od,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const f2=xt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),m2=xt([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),_2=xt([{name:"a_projected_pos",components:4,type:"Float32"}],4);xt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const g2=xt([{name:"a_z_offset",components:1,type:"Float32"}],4),y2=xt([{name:"a_texb",components:2,type:"Uint16"}]),x2=xt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),v2=xt([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);xt([{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 yy=xt([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),b2=xt([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);xt([{name:"triangle",components:3,type:"Uint16"}]),xt([{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"}]),xt([{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"}]),xt([{type:"Float32",name:"offsetX"}]),xt([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var xr=24;const zi=128;function Fd(t,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Ut(t+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:i,interpolationType:o}=r;let s=0;for(;s<i.length&&i[s]<=t;)s++;s=Math.max(0,s-1);let n=s;for(;n<i.length&&i[n]<t+1;)n++;n=Math.min(i.length-1,n);const a=i[s],l=i[n];return r.kind==="composite"?{kind:"composite",minZoom:a,maxZoom:l,interpolationType:o}:{kind:"camera",minZoom:a,maxZoom:l,minSize:r.evaluate(new Ut(a)),maxSize:r.evaluate(new Ut(l)),interpolationType:o}}}function ma(t,{uSize:e,uSizeT:r},{lowerSize:i,upperSize:o}){return t.kind==="source"?i/zi:t.kind==="composite"?Fe(i/zi,o/zi,r):e}function Hi(t,e){let r=0,i=0;if(t.kind==="constant")i=t.layoutSize;else if(t.kind!=="source"){const{interpolationType:o,minZoom:s,maxZoom:n}=t,a=o?Se(ji.interpolationFactor(o,e,s,n),0,1):0;t.kind==="camera"?i=Fe(t.minSize,t.maxSize,a):r=a}return{uSizeT:r,uSize:i}}var w2=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:zi,evaluateSizeForFeature:ma,evaluateSizeForZoom:Hi,getSizeData:Fd});function T2(t,e,r){return t.sections.forEach(i=>{i.text=function(o,s,n){const a=s.layout.get("text-transform").evaluate(n,{});return a==="uppercase"?o=o.toLocaleUpperCase():a==="lowercase"&&(o=o.toLocaleLowerCase()),fi.applyArabicShaping&&(o=fi.applyArabicShaping(o)),o}(i.text,e,r)}),t}const _a={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function E2(t){return t==="︶"||t==="﹈"||t==="︸"||t==="﹄"||t==="﹂"||t==="︾"||t==="︼"||t==="︺"||t==="︘"||t==="﹀"||t==="︐"||t==="︓"||t==="︔"||t==="`"||t===" ̄"||t==="︑"||t==="︒"}function M2(t){return t==="︵"||t==="﹇"||t==="︷"||t==="﹃"||t==="﹁"||t==="︽"||t==="︻"||t==="︹"||t==="︗"||t==="︿"}const Nd=3;function S2(t,e,r){e.glyphs=[],t===1&&r.readMessage(A2,e)}function A2(t,e,r){if(t===3){const{id:i,bitmap:o,width:s,height:n,left:a,top:l,advance:c}=r.readMessage(I2,{});e.glyphs.push({id:i,bitmap:new yo({width:s+2*Nd,height:n+2*Nd},o),metrics:{width:s,height:n,left:a,top:l,advance:c}})}else t===4?e.ascender=r.readSVarint():t===5&&(e.descender=r.readSVarint())}function I2(t,e,r){t===1?e.id=r.readVarint():t===2?e.bitmap=r.readBytes():t===3?e.width=r.readVarint():t===4?e.height=r.readVarint():t===5?e.left=r.readSVarint():t===6?e.top=r.readSVarint():t===7&&(e.advance=r.readVarint())}const xy=Nd,Nt={horizontal:1,vertical:2,horizontalOnly:3},vy=-17;class ga{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const i=new ga;return i.scale=e||1,i.fontStack=r,i}static forImage(e){const r=new ga;return r.imageName=e,r}}class gn{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const i=new gn;for(let o=0;o<e.sections.length;o++){const s=e.sections[o];s.image?i.addImageSection(s):i.addTextSection(s,r)}return i}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(r,i){let o="";for(let s=0;s<r.length;s++){const n=r.charCodeAt(s+1)||null,a=r.charCodeAt(s-1)||null;o+=!i&&(n&&Cm(n)&&!_a[r[s+1]]||a&&Cm(a)&&!_a[r[s-1]])||!_a[r[s]]?r[s]:_a[r[s]]}return o}(this.text,e)}trim(){let e=0;for(let i=0;i<this.text.length&&ac[this.text.charCodeAt(i)];i++)e++;let r=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&ac[this.text.charCodeAt(i)];i--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const i=new gn;return i.text=this.text.substring(e,r),i.sectionIndex=this.sectionIndex.slice(e,r),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(ga.forText(e.scale,e.fontStack||r));const i=this.sections.length-1;for(let o=0;o<e.text.length;++o)this.sectionIndex.push(i)}addImageSection(e){const r=e.image?e.image.namePrimary:"";if(r.length===0)return void F("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCodePoint(i),this.sections.push(ga.forImage(r)),this.sectionIndex.push(this.sections.length-1)):F("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ud(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f){const m=gn.fromFeature(t,o);h===Nt.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(w,T,E,M,S,I){if(!w)return[];const C=[],k=function(U,R,B,G,Z,q){let X=0;for(let Y=0;Y<U.length();Y++){const K=U.getSection(Y);X+=by(U.getCodePoint(Y),K,G,Z,R,q)}return X/Math.max(1,Math.ceil(X/B))}(w,T,E,M,S,I),A=w.text.indexOf("​")>=0;let L=0;for(let U=0;U<w.length();U++){const R=w.getSection(U),B=w.getCodePoint(U);if(ac[B]||(L+=by(B,R,M,S,T,I)),U<w.length()-1){const G=!((O=B)<11904||!(Ae["Bopomofo Extended"](O)||Ae.Bopomofo(O)||Ae["CJK Compatibility Forms"](O)||Ae["CJK Compatibility Ideographs"](O)||Ae["CJK Compatibility"](O)||Ae["CJK Radicals Supplement"](O)||Ae["CJK Strokes"](O)||Ae["CJK Symbols and Punctuation"](O)||Ae["CJK Unified Ideographs Extension A"](O)||Ae["CJK Unified Ideographs"](O)||Ae["Enclosed CJK Letters and Months"](O)||Ae["Halfwidth and Fullwidth Forms"](O)||Ae.Hiragana(O)||Ae["Ideographic Description Characters"](O)||Ae["Kangxi Radicals"](O)||Ae["Katakana Phonetic Extensions"](O)||Ae.Katakana(O)||Ae["Vertical Forms"](O)||Ae["Yi Radicals"](O)||Ae["Yi Syllables"](O)));(C2[B]||G||R.imageName)&&C.push(Ty(U+1,L,k,C,z2(B,w.getCodePoint(U+1),G&&A),!1))}}var O;return Ey(Ty(w.length(),L,k,C,0,!0))}(m,c,s,e,i,p),{processBidirectionalText:y,processStyledBidirectionalText:v}=fi;if(y&&m.sections.length===1){const w=y(m.toString(),g);for(const T of w){const E=new gn;E.text=T,E.sections=m.sections;for(let M=0;M<T.length;M++)E.sectionIndex.push(0);_.push(E)}}else if(v){const w=v(m.text,m.sectionIndex,g);for(const T of w){const E=new gn;E.text=T[0],E.sectionIndex=T[1],E.sections=m.sections,_.push(E)}}else _=function(w,T){const E=[],M=w.text;let S=0;for(const I of T)E.push(w.substring(S,I)),S=I;return S<M.length&&E.push(w.substring(S,M.length)),E}(m,g);const b=[],x={positionedLines:b,text:m.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(w,T,E,M,S,I,C,k,A,L,O,U){let R=0,B=0,G=0;const Z=k==="right"?1:k==="left"?0:.5;let q=!1;for(const de of S){const pe=de.getSections();for(const ge of pe){if(ge.imageName)continue;const xe=T[ge.fontStack];if(xe&&(q=xe.ascender!==void 0&&xe.descender!==void 0,!q))break}if(!q)break}let X=0;for(const de of S){de.trim();const pe=de.getMaxScale(),ge=(pe-1)*xr,xe={positionedGlyphs:[],lineOffset:0};w.positionedLines[X]=xe;const Oe=xe.positionedGlyphs;let Ie=0;if(!de.length()){B+=I,++X;continue}let ht=0,st=0;for(let Re=0;Re<de.length();Re++){const De=de.getSection(Re),at=de.getSectionIndex(Re),ut=de.getCodePoint(Re);let Je=De.scale,Ct=null,Kt=null,St=null,Rt=xr,rr=0;const Qt=!(A===Nt.horizontal||!O&&!vh(ut)||O&&(ac[ut]||(Y=ut,Ae.Arabic(Y)||Ae["Arabic Supplement"](Y)||Ae["Arabic Extended-A"](Y)||Ae["Arabic Presentation Forms-A"](Y)||Ae["Arabic Presentation Forms-B"](Y))));if(De.imageName){const Ot=M[De.imageName];if(!Ot)continue;St=De.imageName,w.iconsInText=w.iconsInText||!0,Kt=Ot.paddedRect;const bt=Ot.displaySize;Je=Je*xr/U,Ct={width:bt[0],height:bt[1],left:0,top:-xy,advance:Qt?bt[1]:bt[0],localGlyph:!1},rr=q?-Ct.height*Je:vy+pe*xr-bt[1]*Je,Rt=Ct.advance;const Er=(Qt?bt[0]:bt[1])*Je-xr*pe;Er>0&&Er>Ie&&(Ie=Er)}else{const Ot=E[De.fontStack];if(!Ot)continue;Ot[ut]&&(Kt=Ot[ut]);const bt=T[De.fontStack];if(!bt)continue;const Er=bt.glyphs[ut];if(!Er)continue;if(Ct=Er.metrics,Rt=ut!==8203?xr:0,q){const Qi=bt.ascender!==void 0?Math.abs(bt.ascender):0,bo=bt.descender!==void 0?Math.abs(bt.descender):0,wo=(Qi+bo)*Je;ht<wo&&(ht=wo,st=(Qi-bo)/2*Je),rr=-Qi*Je}else rr=vy+(pe-Je)*xr}Qt?(w.verticalizable=!0,Oe.push({glyph:ut,imageName:St,x:R,y:B+rr,vertical:Qt,scale:Je,localGlyph:Ct.localGlyph,fontStack:De.fontStack,sectionIndex:at,metrics:Ct,rect:Kt}),R+=Rt*Je+L):(Oe.push({glyph:ut,imageName:St,x:R,y:B+rr,vertical:Qt,scale:Je,localGlyph:Ct.localGlyph,fontStack:De.fontStack,sectionIndex:at,metrics:Ct,rect:Kt}),R+=Ct.advance*Je+L)}Oe.length!==0&&(G=Math.max(R-L,G),q?My(Oe,Z,Ie,st,I*pe/2):My(Oe,Z,Ie,0,I/2)),R=0;const Be=I*pe+Ie;xe.lineOffset=Math.max(Ie,ge),B+=Be,++X}var Y;const K=B,{horizontalAlign:H,verticalAlign:ee}=lc(C);(function(de,pe,ge,xe,Oe,Ie){const ht=(pe-ge)*Oe,st=-Ie*xe;for(const Be of de)for(const Re of Be.positionedGlyphs)Re.x+=ht,Re.y+=st})(w.positionedLines,Z,H,ee,G,K),w.top+=-ee*K,w.bottom=w.top+K,w.left+=-H*G,w.right=w.left+G,w.hasBaseline=q}(x,e,r,i,_,n,a,l,h,c,d,f),!function(w){for(const T of w)if(T.positionedGlyphs.length!==0)return!1;return!0}(b)&&x}const ac={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},C2={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 by(t,e,r,i,o,s){if(e.imageName){const n=i[e.imageName];return n?n.displaySize[0]*e.scale*xr/s+o:0}{const n=r[e.fontStack],a=n&&n.glyphs[t];return a?a.metrics.advance*e.scale+o:0}}function wy(t,e,r,i){const o=Math.pow(t-e,2);return i?t<e?o/2:2*o:o+Math.abs(r)*r}function z2(t,e,r){let i=0;return t===10&&(i-=1e4),r&&(i+=150),t!==40&&t!==65288||(i+=50),e!==41&&e!==65289||(i+=50),i}function Ty(t,e,r,i,o,s){let n=null,a=wy(e,r,o,s);for(const l of i){const c=wy(e-l.x,r,o,s)+l.badness;c<=a&&(n=l,a=c)}return{index:t,x:e,priorBreak:n,badness:a}}function Ey(t){return t?Ey(t.priorBreak).concat(t.index):[]}function lc(t){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function My(t,e,r,i,o){if(!(e||r||i||o))return;const s=t.length-1,n=t[s],a=(n.x+n.metrics.advance*n.scale)*e;for(let l=0;l<=s;l++)t[l].x-=a,t[l].y+=r+i+o}function D2(t,e,r,i){const{horizontalAlign:o,verticalAlign:s}=lc(i),n=r[0]-t.displaySize[0]*o,a=r[1]-t.displaySize[1]*s;return{imagePrimary:t,imageSecondary:e,top:a,bottom:a+t.displaySize[1],left:n,right:n+t.displaySize[0]}}function Sy(t,e,r,i,o,s){const n=t.imagePrimary;let a;if(n.content){const _=n.content,g=n.pixelRatio||1;a=[_[0]/g,_[1]/g,n.displaySize[0]-_[2]/g,n.displaySize[1]-_[3]/g]}const l=e.left*s,c=e.right*s;let u,h,d,p;r==="width"||r==="both"?(p=o[0]+l-i[3],h=o[0]+c+i[1]):(p=o[0]+(l+c-n.displaySize[0])/2,h=p+n.displaySize[0]);const f=e.top*s,m=e.bottom*s;return r==="height"||r==="both"?(u=o[1]+f-i[0],d=o[1]+m+i[2]):(u=o[1]+(f+m-n.displaySize[1])/2,d=u+n.displaySize[1]),{imagePrimary:n,imageSecondary:void 0,top:u,right:h,bottom:d,left:p,collisionPadding:a}}class vo extends N{constructor(e,r,i,o,s){super(e,r),this.angle=o,this.z=i,s!==void 0&&(this.segment=s)}clone(){return new vo(this.x,this.y,this.z,this.angle,this.segment)}}function Ay(t,e,r,i,o){if(e.segment===void 0)return!0;let s=e,n=e.segment+1,a=0;for(;a>-r/2;){if(n--,n<0)return!1;a-=t[n].dist(s),s=t[n]}a+=t[n].dist(t[n+1]),n++;const l=[];let c=0;for(;a<r/2;){const u=t[n],h=t[n+1];if(!h)return!1;let d=t[n-1].angleTo(u)-u.angleTo(h);for(d=Math.abs((d+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:d}),c+=d;a-l[0].distance>i;)c-=l.shift().angleDelta;if(c>o)return!1;n++,a+=u.dist(h)}return!0}function Iy(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function Cy(t,e,r){return t?.6*e*r:0}function zy(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function k2(t,e,r,i,o,s){const n=Cy(r,o,s),a=zy(r,i)*s;let l=0;const c=Iy(t)/2;for(let u=0;u<t.length-1;u++){const h=t[u],d=t[u+1],p=h.dist(d);if(l+p>c){const f=(c-l)/p,m=Fe(h.x,d.x,f),_=Fe(h.y,d.y,f),g=new vo(m,_,0,d.angleTo(h),u);return!n||Ay(t,g,a,n,e)?g:void 0}l+=p}}function P2(t,e,r,i,o,s,n,a,l){const c=Cy(i,s,n),u=zy(i,o),h=u*n,d=t[0].x===0||t[0].x===l||t[0].y===0||t[0].y===l;return e-h<e/4&&(e=h+e/4),Dy(t,d?e/2*a%e:(u/2+2*s)*n*a%e,e,c,r,h,d,!1,l)}function Dy(t,e,r,i,o,s,n,a,l){const c=s/2,u=Iy(t);let h=0,d=e-r,p=[];for(let f=0;f<t.length-1;f++){const m=t[f],_=t[f+1],g=m.dist(_),y=_.angleTo(m);for(;d+r<h+g;){d+=r;const v=(d-h)/g,b=Fe(m.x,_.x,v),x=Fe(m.y,_.y,v);if(b>=0&&b<l&&x>=0&&x<l&&d-c>=0&&d+c<=u){const w=new vo(b,x,0,y,f);i&&!Ay(t,w,s,i,o)||p.push(w)}}h+=g}return a||p.length||n||(p=Dy(t,h/2,r,i,o,s,n,!0,l)),p}function ky(t,e,r,i,o){const s=[];for(let n=0;n<t.length;n++){const a=t[n];let l;for(let c=0;c<a.length-1;c++){let u=a[c],h=a[c+1];u.x<e&&h.x<e||(u.x<e?u=new N(e,u.y+(e-u.x)/(h.x-u.x)*(h.y-u.y))._round():h.x<e&&(h=new N(e,u.y+(e-u.x)/(h.x-u.x)*(h.y-u.y))._round()),u.y<r&&h.y<r||(u.y<r?u=new N(u.x+(r-u.y)/(h.y-u.y)*(h.x-u.x),r)._round():h.y<r&&(h=new N(u.x+(r-u.y)/(h.y-u.y)*(h.x-u.x),r)._round()),u.x>=i&&h.x>=i||(u.x>=i?u=new N(i,u.y+(i-u.x)/(h.x-u.x)*(h.y-u.y))._round():h.x>=i&&(h=new N(i,u.y+(i-u.x)/(h.x-u.x)*(h.y-u.y))._round()),u.y>=o&&h.y>=o||(u.y>=o?u=new N(u.x+(o-u.y)/(h.y-u.y)*(h.x-u.x),o)._round():h.y>=o&&(h=new N(u.x+(o-u.y)/(h.y-u.y)*(h.x-u.x),o)._round()),l&&u.equals(l[l.length-1])||(l=[u],s.push(l)),l.push(h)))))}}return s}function Vd(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort((n,a)=>a.h-n.h);const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let o=0,s=0;for(const n of t)for(let a=i.length-1;a>=0;a--){const l=i[a];if(!(n.w>l.w||n.h>l.h)){if(n.x=l.x,n.y=l.y,s=Math.max(s,n.y+n.h),o=Math.max(o,n.x+n.w),n.w===l.w&&n.h===l.h){const c=i.pop();a<i.length&&(i[a]=c)}else n.h===l.h?(l.x+=n.w,l.w-=n.w):n.w===l.w?(l.y+=n.h,l.h-=n.h):(i.push({x:l.x+n.w,y:l.y,w:l.w-n.w,h:n.h}),l.y+=n.h,l.h-=n.h);break}}return{w:o,h:s,fill:e/(o*s)||0}}Ee(vo,"Anchor");const Kr=1;class jd{constructor(e,{pixelRatio:r,version:i,stretchX:o,stretchY:s,content:n}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+Kr,this.paddedRect.y+Kr]}get br(){return[this.paddedRect.x+this.paddedRect.w-Kr,this.paddedRect.y+this.paddedRect.h-Kr]}get displaySize(){return[(this.paddedRect.w-2*Kr)/this.pixelRatio,(this.paddedRect.h-2*Kr)/this.pixelRatio]}}class Py{constructor(e,r){const i={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(e,i,s),this.addImages(r,o,s);const{w:n,h:a}=Vd(s),l=new ir({width:n||1,height:a||1});for(const c in e){const u=e[c],h=i[c].paddedRect;ir.copy(u.data,l,{x:0,y:0},{x:h.x+Kr,y:h.y+Kr},u.data)}for(const c in r){const u=r[c],h=o[c].paddedRect,d=h.x+Kr,p=h.y+Kr,f=u.data.width,m=u.data.height;ir.copy(u.data,l,{x:0,y:0},{x:d,y:p},u.data),ir.copy(u.data,l,{x:0,y:m-1},{x:d,y:p-1},{width:f,height:1}),ir.copy(u.data,l,{x:0,y:0},{x:d,y:p+m},{width:f,height:1}),ir.copy(u.data,l,{x:f-1,y:0},{x:d-1,y:p},{width:1,height:m}),ir.copy(u.data,l,{x:0,y:0},{x:d+f,y:p},{width:1,height:m})}this.image=l,this.iconPositions=i,this.patternPositions=o}addImages(e,r,i){for(const o in e){const s=e[o],n={x:0,y:0,w:s.data.width+2*Kr,h:s.data.height+2*Kr};i.push(n),r[o]=new jd(n,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(e,r,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(o=>e.hasImage(o,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const o in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[o],e.getImage(o,i),r),this.patchUpdatedImage(this.patternPositions[o],e.getImage(o,i),r)}patchUpdatedImage(e,r,i){if(!e||!r||e.version===r.version)return;e.version=r.version;const[o,s]=e.tl;i.update(r.data,void 0,{x:o,y:s})}}Ee(jd,"ImagePosition"),Ee(Py,"ImageAtlas");const ya=1e20;function Ry(t,e,r,i,o,s,n,a,l){for(let c=e;c<e+i;c++)Ly(t,r*s+c,s,o,n,a,l);for(let c=r;c<r+o;c++)Ly(t,c*s+e,1,i,n,a,l)}function Ly(t,e,r,i,o,s,n){s[0]=0,n[0]=-ya,n[1]=ya,o[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){o[a]=t[e+a*r];const u=a*a;do{const h=s[l];c=(o[a]-o[h]+u-h*h)/(a-h)/2}while(c<=n[l]&&--l>-1);l++,s[l]=a,n[l]=c,n[l+1]=ya}for(let a=0,l=0;a<i;a++){for(;n[l+1]<a;)l++;const c=s[l],u=a-c;t[e+a*r]=o[c]+u*u}}const Di=2;class yn{constructor(e,r,i){this.requestManager=e,this.localGlyphMode=r,this.localFontFamily=i,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e,r){this.urls[r]=e}getGlyphs(e,r,i){const o=[],s=this.urls[r]||Ke.GLYPHS_URL;for(const n in e)for(const a of e[n])o.push({stack:n,id:a});os(o,({stack:n,id:a},l)=>{let c=this.entries[n];c||(c=this.entries[n]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let u=c.glyphs[a];if(u!==void 0)return void l(null,{stack:n,id:a,glyph:u});if(u=this._tinySDF(c,n,a),u)return c.glyphs[a]=u,void l(null,{stack:n,id:a,glyph:u});const h=Math.floor(a/256);if(256*h>65535)return void l(new Error("glyphs > 65535 not supported"));if(c.ranges[h])return void l(null,{stack:n,id:a,glyph:u});let d=c.requests[h];d||(d=c.requests[h]=[],yn.loadGlyphRange(n,h,s,this.requestManager,(p,f)=>{if(f){c.ascender=f.ascender,c.descender=f.descender;for(const m in f.glyphs)this._doesCharSupportLocalGlyph(+m)||(c.glyphs[+m]=f.glyphs[+m]);c.ranges[h]=!0}for(const m of d)m(p,f);delete c.requests[h]})),d.push((p,f)=>{p?l(p):f&&l(null,{stack:n,id:a,glyph:f.glyphs[a]||null})})},(n,a)=>{if(n)i(n);else if(a){const l={};for(const{stack:c,id:u,glyph:h}of a)l[c]===void 0&&(l[c]={}),l[c].glyphs===void 0&&(l[c].glyphs={}),l[c].glyphs[u]=h&&{id:h.id,bitmap:h.bitmap.clone(),metrics:h.metrics},l[c].ascender=this.entries[c].ascender,l[c].descender=this.entries[c].descender;i(null,l)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==0&&(this.localGlyphMode===2?!!this.localFontFamily:!!this.localFontFamily&&(Ae["CJK Unified Ideographs"](e)||Ae["Hangul Syllables"](e)||Ae.Hiragana(e)||Ae.Katakana(e)||Ae["CJK Symbols and Punctuation"](e)||Ae["CJK Unified Ideographs Extension A"](e)||Ae["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,r,i){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(i))return;let s=e.tinySDF;if(!s){let m="400";/bold/i.test(r)?m="900":/medium/i.test(r)?m="500":/light/i.test(r)&&(m="200"),s=e.tinySDF=new yn.TinySDF({fontFamily:o,fontWeight:m,fontSize:24*Di,buffer:3*Di,radius:8*Di}),s.fontWeight=m}if(this.localGlyphs[s.fontWeight][i])return this.localGlyphs[s.fontWeight][i];const n=String.fromCodePoint(i),{data:a,width:l,height:c,glyphWidth:u,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=s.draw(n);return this.localGlyphs[s.fontWeight][i]={id:i,bitmap:new yo({width:l,height:c},a),metrics:{width:u/Di,height:h/Di,left:d/Di,top:p/Di-27,advance:f/Di,localGlyph:!0}}}}yn.loadGlyphRange=function(t,e,r,i,o){const s=256*e,n=s+255,a=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${s}-${n}`),J.Glyphs);fe(a,(l,c)=>{if(l)o(l);else if(c){const u={},h=function(d){return new sc(d).readFields(S2,{})}(c);for(const d of h.glyphs)u[d.id]=d;o(null,{glyphs:u,ascender:h.ascender,descender:h.descender})}})},yn.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:i=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:n="normal"}={}){this.buffer=e,this.cutoff=i,this.radius=r;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${n} ${s} ${t}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(t),n=Math.ceil(r),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,n+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:n,glyphLeft:0,glyphAdvance:e};if(a===0||l===0)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+n);const y=f.getImageData(m,m,a,l);g.fill(ya,0,h),_.fill(0,0,h);for(let v=0;v<l;v++)for(let b=0;b<a;b++){const x=y.data[4*(v*a+b)+3]/255;if(x===0)continue;const w=(v+m)*c+b+m;if(x===1)g[w]=0,_[w]=ya;else{const T=.5-x;g[w]=T>0?T*T:0,_[w]=T<0?T*T:0}}Ry(g,0,0,c,u,c,this.f,this.v,this.z),Ry(_,m,m,a,l,c,this.f,this.v,this.z);for(let v=0;v<h;v++){const b=Math.sqrt(g[v])-Math.sqrt(_[v]);d[v]=Math.round(255-255*(b/this.radius+this.cutoff))}return p}};const Go=Kr;function By(t,e,r,i){const o=[],s=t.imagePrimary,n=s.pixelRatio,a=s.paddedRect.w-2*Go,l=s.paddedRect.h-2*Go,c=t.right-t.left,u=t.bottom-t.top,h=s.stretchX||[[0,a]],d=s.stretchY||[[0,l]],p=(I,C)=>I+C[1]-C[0],f=h.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,b=0,x=m,w=0,T=_,E=0,M=g;if(s.content&&i){const I=s.content;y=cc(h,0,I[0]),b=cc(d,0,I[1]),v=cc(h,I[0],I[2]),x=cc(d,I[1],I[3]),w=I[0]-y,E=I[1]-b,T=I[2]-I[0]-v,M=I[3]-I[1]-x}const S=(I,C,k,A)=>{const L=uc(I.stretch-y,v,c,t.left),O=hc(I.fixed-w,T,I.stretch,f),U=uc(C.stretch-b,x,u,t.top),R=hc(C.fixed-E,M,C.stretch,m),B=uc(k.stretch-y,v,c,t.left),G=hc(k.fixed-w,T,k.stretch,f),Z=uc(A.stretch-b,x,u,t.top),q=hc(A.fixed-E,M,A.stretch,m),X=new N(L,U),Y=new N(B,U),K=new N(B,Z),H=new N(L,Z),ee=new N(O/n,R/n),de=new N(G/n,q/n),pe=e*Math.PI/180;if(pe){const st=Math.sin(pe),Be=Math.cos(pe),Re=[Be,-st,st,Be];X._matMult(Re),Y._matMult(Re),H._matMult(Re),K._matMult(Re)}const ge=I.stretch+I.fixed,xe=k.stretch+k.fixed,Oe=C.stretch+C.fixed,Ie=A.stretch+A.fixed,ht=t.imageSecondary;return{tl:X,tr:Y,bl:H,br:K,texPrimary:{x:s.paddedRect.x+Go+ge,y:s.paddedRect.y+Go+Oe,w:xe-ge,h:Ie-Oe},texSecondary:ht?{x:ht.paddedRect.x+Go+ge,y:ht.paddedRect.y+Go+Oe,w:xe-ge,h:Ie-Oe}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ee,pixelOffsetBR:de,minFontScaleX:T/n/c,minFontScaleY:M/n/u,isSDF:r}};if(i&&(s.stretchX||s.stretchY)){const I=Oy(h,_,f),C=Oy(d,g,m);for(let k=0;k<I.length-1;k++){const A=I[k],L=I[k+1];for(let O=0;O<C.length-1;O++)o.push(S(A,C[O],L,C[O+1]))}}else o.push(S({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:l+1}));return o}function cc(t,e,r){let i=0;for(const o of t)i+=Math.max(e,Math.min(r,o[1]))-Math.max(e,Math.min(r,o[0]));return i}function Oy(t,e,r){const i=[{fixed:-Go,stretch:0}];for(const[o,s]of t){const n=i[i.length-1];i.push({fixed:o-n.stretch,stretch:n.stretch}),i.push({fixed:o-n.stretch,stretch:n.stretch+(s-o)})}return i.push({fixed:e+Go,stretch:r}),i}function uc(t,e,r,i){return t/e*r+i}function hc(t,e,r,i){return t-e*r/i}function R2(t,e,r,i){const o=e+t.positionedLines[i].lineOffset;return i===0?r+o/2:r+(o+(e+t.positionedLines[i-1].lineOffset))/2}function L2(t,e=1,r=!1){let i=1/0,o=1/0,s=-1/0,n=-1/0;const a=t[0];for(let p=0;p<a.length;p++){const f=a[p];(!p||f.x<i)&&(i=f.x),(!p||f.y<o)&&(o=f.y),(!p||f.x>s)&&(s=f.x),(!p||f.y>n)&&(n=f.y)}const l=Math.min(s-i,n-o);let c=l/2;const u=new Ru([],B2);if(l===0)return new N(i,o);for(let p=i;p<s;p+=l)for(let f=o;f<n;f+=l)u.push(new xn(p+c,f+c,c,t));let h=function(p){let f=0,m=0,_=0;const g=p[0];for(let y=0,v=g.length,b=v-1;y<v;b=y++){const x=g[y],w=g[b],T=x.x*w.y-w.x*x.y;m+=(x.x+w.x)*T,_+=(x.y+w.y)*T,f+=3*T}return new xn(m/f,_/f,0,p)}(t),d=u.length;for(;u.length;){const p=u.pop();(p.d>h.d||!h.d)&&(h=p,r&&console.log("found best %d after %d probes",Math.round(1e4*p.d)/1e4,d)),p.max-h.d<=e||(c=p.h/2,u.push(new xn(p.p.x-c,p.p.y-c,c,t)),u.push(new xn(p.p.x+c,p.p.y-c,c,t)),u.push(new xn(p.p.x-c,p.p.y+c,c,t)),u.push(new xn(p.p.x+c,p.p.y+c,c,t)),d+=4)}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function B2(t,e){return e.max-t.max}class xn{constructor(e,r,i,o){this.p=new N(e,r),this.h=i,this.d=function(s,n){let a=!1,l=1/0;for(let c=0;c<n.length;c++){const u=n[c];for(let h=0,d=u.length,p=d-1;h<d;p=h++){const f=u[h],m=u[p];f.y>s.y!=m.y>s.y&&s.x<(m.x-f.x)*(s.y-f.y)/(m.y-f.y)+f.x&&(a=!a),l=Math.min(l,Fg(s,f,m))}}return(a?1:-1)*Math.sqrt(l)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}}const vn=7,Gd=Number.POSITIVE_INFINITY,O2=Math.sqrt(2);function qd(t,[e,r]){let i=0,o=0;if(r===Gd){e<0&&(e=0);const s=e/O2;switch(t){case"top-right":case"top-left":o=s-vn;break;case"bottom-right":case"bottom-left":o=-s+vn;break;case"bottom":o=-e+vn;break;case"top":o=e-vn}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}}else{switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":o=r-vn;break;case"bottom-right":case"bottom-left":case"bottom":o=-r+vn}switch(t){case"top-right":case"bottom-right":case"right":i=-e;break;case"top-left":case"bottom-left":case"left":i=e}}return[i,o]}function F2(t,e,r,i,o,s,n,a,l,c,u){t.createArrays(),t.tilePixelRatio=W/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const h=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if(t.textSizeData.kind==="composite"){const{minZoom:g,maxZoom:y}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ut(g),a),d["text-size"].possiblyEvaluate(new Ut(y),a)]}if(t.iconSizeData.kind==="composite"){const{minZoom:g,maxZoom:y}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ut(g),a),d["icon-size"].possiblyEvaluate(new Ut(y),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ut(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ut(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ut(18),a);const f=h.get("text-rotation-alignment")==="map"&&h.get("symbol-placement")!=="point",m=h.get("text-size");let _=!1;for(const g of t.features)if(g.icon&&g.icon.nameSecondary){_=!0;break}for(const g of t.features){const y=h.get("text-font").evaluate(g,{},a).join(","),v=m.evaluate(g,{},a),b=p.layoutTextSize.evaluate(g,{},a),x=(p.layoutIconSize.evaluate(g,{},a),{horizontal:{},vertical:void 0}),w=g.text;let T,E=[0,0];if(w){const I=w.toString(),C=h.get("text-letter-spacing").evaluate(g,{},a)*xr,k=h.get("text-line-height").evaluate(g,{},a)*xr,A=ub(I)?C:0,L=h.get("text-anchor").evaluate(g,{},a),O=h.get("text-variable-anchor");if(!O){const Z=h.get("text-radial-offset").evaluate(g,{},a);E=Z?qd(L,[Z*xr,Gd]):h.get("text-offset").evaluate(g,{},a).map(q=>q*xr)}let U=f?"center":h.get("text-justify").evaluate(g,{},a);const R=h.get("symbol-placement")==="point",B=R?h.get("text-max-width").evaluate(g,{},a)*xr:1/0,G=Z=>{t.allowVerticalPlacement&&xh(I)&&(x.vertical=Ud(w,e,r,o,y,B,k,L,Z,A,E,Nt.vertical,!0,b,v))};if(!f&&O){const Z=U==="auto"?O.map(X=>Zd(X)):[U];let q=!1;for(let X=0;X<Z.length;X++){const Y=Z[X];if(!x.horizontal[Y])if(q)x.horizontal[Y]=x.horizontal[0];else{const K=Ud(w,e,r,o,y,B,k,"center",Y,A,E,Nt.horizontal,!1,b,v);K&&(x.horizontal[Y]=K,q=K.positionedLines.length===1)}}G("left")}else{if(U==="auto"&&(U=Zd(L)),R||h.get("text-writing-mode").indexOf("horizontal")>=0||!xh(I)){const Z=Ud(w,e,r,o,y,B,k,L,U,A,E,Nt.horizontal,!1,b,v);Z&&(x.horizontal[U]=Z)}G(R?"left":U)}}let M=!1;if(g.icon&&g.icon.namePrimary){const I=i[g.icon.namePrimary];I&&(T=D2(o[g.icon.namePrimary],g.icon.nameSecondary?o[g.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(g,{},a),h.get("icon-anchor").evaluate(g,{},a)),M=I.sdf,t.sdfIcons===void 0?t.sdfIcons=I.sdf:t.sdfIcons!==I.sdf&&F("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(I.pixelRatio!==t.pixelRatio||h.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}const S=Ny(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!S&&S.iconsInText),(S||T)&&N2(t,g,x,T,i,p,b,0,E,M,n,a,c,u,_)}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Zd(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 N2(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f){let m=s.textMaxSize.evaluate(e,{},h);m===void 0&&(m=n);const _=t.layers[0].layout,g=_.get("icon-offset").evaluate(e,{},h),y=Ny(r.horizontal)||r.vertical,v=d.name==="globe",b=xr,x=n/b,w=t.tilePixelRatio*m/b,T=(L=t.overscaling,t.zoom>18&&L>2&&(L>>=1),Math.max(W/(512*L),1)*_.get("symbol-spacing")),E=_.get("text-padding")*t.tilePixelRatio,M=_.get("icon-padding")*t.tilePixelRatio,S=$e(_.get("text-max-angle")),I=_.get("text-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point",C=_.get("icon-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point",k=_.get("symbol-placement"),A=T/2;var L;const O=_.get("icon-text-fit").evaluate(e,{},h),U=_.get("icon-text-fit-padding").evaluate(e,{},h),R=O!=="none";let B;t.hasAnyIconTextFit===!1&&R&&(t.hasAnyIconTextFit=!0),i&&R&&(t.allowVerticalPlacement&&r.vertical&&(B=Sy(i,r.vertical,O,U,g,x)),y&&(i=Sy(i,y,O,U,g,x)));const G=(Z,q,X)=>{if(q.x<0||q.x>=W||q.y<0||q.y>=W)return;let Y=null;if(v){const{x:K,y:H,z:ee}=d.projectTilePoint(q.x,q.y,X);Y={anchor:new vo(K,H,ee,0,void 0),up:d.upVector(X,q.x,q.y)}}(function(K,H,ee,de,pe,ge,xe,Oe,Ie,ht,st,Be,Re,De,at,ut,Je,Ct,Kt,St,Rt,rr,Qt,Ot,bt,Er,Qi){const bo=K.addToLineVertexArray(H,de);let wo,Ua,Va,nu,Z1,$1,H1,W1=0,X1=0,Y1=0,J1=0,Zp=-1,$p=-1;const eo={};let K1=qh("");const Ds=ee?ee.anchor:H,Hp=Ie.layout.get("icon-text-fit").evaluate(Rt,{},bt)!=="none";let Wp=0,Xp=0;if(Ie._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Wp,Xp]=Ie.layout.get("text-offset").evaluate(Rt,{},bt).map(ei=>ei*xr):(Wp=Ie.layout.get("text-radial-offset").evaluate(Rt,{},bt)*xr,Xp=Gd),K.allowVerticalPlacement&&pe.vertical){const ei=pe.vertical;if(at)$1=$d(ei),Oe&&(H1=$d(Oe));else{const ti=Ie.layout.get("text-rotate").evaluate(Rt,{},bt)+90;Va=dc(ht,Ds,H,st,Be,Re,ei,De,ti,ut),Oe&&(nu=dc(ht,Ds,H,st,Be,Re,Oe,Ct,ti))}}if(ge){const ei=Ie.layout.get("icon-rotate").evaluate(Rt,{},bt),ti=By(ge,ei,Qt,Hp),Dn=Oe?By(Oe,ei,Qt,Hp):void 0;Ua=dc(ht,Ds,H,st,Be,Re,ge,Ct,ei),W1=4*ti.length;const Q1=K.iconSizeData;let ks=null;Q1.kind==="source"?(ks=[zi*Ie.layout.get("icon-size").evaluate(Rt,{},bt)],ks[0]>qo&&F(`${K.layerIds[0]}: Value for "icon-size" is >= ${xa}. Reduce your "icon-size".`)):Q1.kind==="composite"&&(ks=[zi*rr.compositeIconSizes[0].evaluate(Rt,{},bt),zi*rr.compositeIconSizes[1].evaluate(Rt,{},bt)],(ks[0]>qo||ks[1]>qo)&&F(`${K.layerIds[0]}: Value for "icon-size" is >= ${xa}. Reduce your "icon-size".`)),K.addSymbols(K.icon,ti,ks,St,Kt,Rt,!1,ee,H,bo.lineStartIndex,bo.lineLength,-1,Ot,bt,Er,Qi),Zp=K.icon.placedSymbolArray.length-1,Dn&&(X1=4*Dn.length,K.addSymbols(K.icon,Dn,ks,St,Kt,Rt,Nt.vertical,ee,H,bo.lineStartIndex,bo.lineLength,-1,Ot,bt,Er,Qi),$p=K.icon.placedSymbolArray.length-1)}for(const ei in pe.horizontal){const ti=pe.horizontal[ei];wo||(K1=qh(ti.text),at?Z1=$d(ti):wo=dc(ht,Ds,H,st,Be,Re,ti,De,Ie.layout.get("text-rotate").evaluate(Rt,{},bt),ut));const Dn=ti.positionedLines.length===1;if(Y1+=Fy(K,ee,H,ti,xe,Ie,at,Rt,ut,bo,pe.vertical?Nt.horizontal:Nt.horizontalOnly,Dn?Object.keys(pe.horizontal):[ei],eo,Zp,rr,Ot,bt,Er),Dn)break}pe.vertical&&(J1+=Fy(K,ee,H,pe.vertical,xe,Ie,at,Rt,ut,bo,Nt.vertical,["vertical"],eo,$p,rr,Ot,bt,Er));let Ko=-1;const Yp=(ei,ti)=>ei?Math.max(ei,ti):ti;Ko=Yp(Z1,Ko),Ko=Yp($1,Ko),Ko=Yp(H1,Ko);const TS=Ko>-1?1:0;K.glyphOffsetArray.length>=Ea.MAX_GLYPHS&&F("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Rt.sortKey!==void 0&&K.addToSortKeyRanges(K.symbolInstances.length,Rt.sortKey),K.symbolInstances.emplaceBack(H.x,H.y,Ds.x,Ds.y,Ds.z,eo.right>=0?eo.right:-1,eo.center>=0?eo.center:-1,eo.left>=0?eo.left:-1,eo.vertical>=0?eo.vertical:-1,Zp,$p,K1,wo!==void 0?wo:K.collisionBoxArray.length,wo!==void 0?wo+1:K.collisionBoxArray.length,Va!==void 0?Va:K.collisionBoxArray.length,Va!==void 0?Va+1:K.collisionBoxArray.length,Ua!==void 0?Ua:K.collisionBoxArray.length,Ua!==void 0?Ua+1:K.collisionBoxArray.length,nu||K.collisionBoxArray.length,nu?nu+1:K.collisionBoxArray.length,st,Y1,J1,W1,X1,TS,0,Wp,Xp,Ko,0,Hp?1:0)})(t,q,Y,Z,r,i,o,B,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,E,I,l,0,M,C,g,e,s,c,u,h,p,f)};if(k==="line")for(const Z of ky(e.geometry,0,0,W,W)){const q=P2(Z,T,S,r.vertical||y,i,b,w,t.overscaling,W);for(const X of q)y&&U2(t,y.text,A,X)||G(Z,X,h)}else if(k==="line-center"){for(const Z of e.geometry)if(Z.length>1){const q=k2(Z,S,r.vertical||y,i,b,w);q&&G(Z,q,h)}}else if(e.type==="Polygon")for(const Z of kd(e.geometry,0)){const q=L2(Z,16);G(Z[0],new vo(q.x,q.y,0,0,void 0),h)}else if(e.type==="LineString")for(const Z of e.geometry)G(Z,new vo(Z[0].x,Z[0].y,0,0,void 0),h);else if(e.type==="Point")for(const Z of e.geometry)for(const q of Z)G([q],new vo(q.x,q.y,0,0,void 0),h)}const xa=255,qo=xa*zi;function Fy(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=function(x,w,T,E,M,S,I,C){const k=[];if(w.positionedLines.length===0)return k;const A=E.layout.get("text-rotate").evaluate(S,{})*Math.PI/180,L=function(G){const Z=G[0],q=G[1],X=Z*q;return X>0?[Z,-q]:X<0?[-Z,q]:Z===0?[q,Z]:[q,-Z]}(T);let O=Math.abs(w.top-w.bottom);for(const G of w.positionedLines)O-=G.lineOffset;const U=w.positionedLines.length,R=O/U;let B=w.top-T[1];for(let G=0;G<U;++G){const Z=w.positionedLines[G];B=R2(w,R,B,G);for(const q of Z.positionedGlyphs){if(!q.rect)continue;const X=q.rect||{};let Y=xy+1,K=!0,H=1,ee=0;if(q.imageName){const St=I[q.imageName];if(!St)continue;if(St.sdf){F("SDF images are not supported in formatted text and will be ignored.");continue}K=!1,H=St.pixelRatio,Y=Kr/H}const de=(M||C)&&q.vertical,pe=q.metrics.advance*q.scale/2,ge=q.metrics,xe=q.rect;if(xe===null)continue;C&&w.verticalizable&&(ee=q.imageName?pe-q.metrics.width*q.scale/2:0);const Oe=M?[q.x+pe,q.y]:[0,0];let Ie=[0,0],ht=[0,0],st=!1;M||(de?(ht=[q.x+pe+L[0],q.y+L[1]-ee],st=!0):Ie=[q.x+pe+T[0],q.y+T[1]-ee]);const Be=xe.w*q.scale/(H*(q.localGlyph?Di:1)),Re=xe.h*q.scale/(H*(q.localGlyph?Di:1));let De,at,ut,Je;if(de){const St=q.y-B,Rt=new N(-pe,pe-St),rr=-Math.PI/2,Qt=new N(...ht);De=new N(-pe+Ie[0],Ie[1]),De._rotateAround(rr,Rt)._add(Qt),De.x+=-St+pe,De.y-=(ge.left-Y)*q.scale;const Ot=q.imageName?ge.advance*q.scale:xr*q.scale,bt=String.fromCodePoint(q.glyph);E2(bt)?De.x+=(1-Y)*q.scale:M2(bt)?De.x+=Ot-ge.height*q.scale+(-Y-1)*q.scale:De.x+=q.imageName||ge.width+2*Y===xe.w&&ge.height+2*Y===xe.h?(Ot-Re)/2:(Ot-(ge.height+2*Y)*q.scale)/2,at=new N(De.x,De.y-Be),ut=new N(De.x+Re,De.y),Je=new N(De.x+Re,De.y-Be)}else{const St=(ge.left-Y)*q.scale-pe+Ie[0],Rt=(-ge.top-Y)*q.scale+Ie[1],rr=St+Be,Qt=Rt+Re;De=new N(St,Rt),at=new N(rr,Rt),ut=new N(St,Qt),Je=new N(rr,Qt)}if(A){let St;St=M?new N(0,0):st?new N(L[0],L[1]):new N(T[0],T[1]),De._rotateAround(A,St),at._rotateAround(A,St),ut._rotateAround(A,St),Je._rotateAround(A,St)}const Ct=new N(0,0),Kt=new N(0,0);k.push({tl:De,tr:at,bl:ut,br:Je,texPrimary:X,texSecondary:void 0,writingMode:w.writingMode,glyphOffset:Oe,sectionIndex:q.sectionIndex,isSDF:K,pixelOffsetTL:Ct,pixelOffsetBR:Kt,minFontScaleX:0,minFontScaleY:0})}}return k}(0,i,l,s,n,a,o,t.allowVerticalPlacement),v=t.textSizeData;let b=null;v.kind==="source"?(b=[zi*s.layout.get("text-size").evaluate(a,{},_)],b[0]>qo&&F(`${t.layerIds[0]}: Value for "text-size" is >= ${xa}. Reduce your "text-size".`)):v.kind==="composite"&&(b=[zi*f.compositeTextSizes[0].evaluate(a,{},_),zi*f.compositeTextSizes[1].evaluate(a,{},_)],(b[0]>qo||b[1]>qo)&&F(`${t.layerIds[0]}: Value for "text-size" is >= ${xa}. Reduce your "text-size".`)),t.addSymbols(t.text,y,b,l,n,a,u,e,r,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const x of h)d[x]=t.text.placedSymbolArray.length-1;return 4*y.length}function Ny(t){for(const e in t)return t[e];return null}function dc(t,e,r,i,o,s,n,a,l,c){let u=n.top,h=n.bottom,d=n.left,p=n.right;const f=n.collisionPadding;if(f&&(d-=f[0],u-=f[1],p+=f[2],h+=f[3]),l){const m=new N(d,u),_=new N(p,u),g=new N(d,h),y=new N(p,h),v=$e(l);let b=new N(0,0);c&&(b=new N(c[0],c[1])),m._rotateAround(v,b),_._rotateAround(v,b),g._rotateAround(v,b),y._rotateAround(v,b),d=Math.min(m.x,_.x,g.x,y.x),p=Math.max(m.x,_.x,g.x,y.x),u=Math.min(m.y,_.y,g.y,y.y),h=Math.max(m.y,_.y,g.y,y.y)}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,d,u,p,h,a,i,o,s),t.length-1}function $d(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 U2(t,e,r,i){const o=t.compareText;if(e in o){const s=o[e];for(let n=s.length-1;n>=0;n--)if(i.dist(s[n])<r)return!0}else o[e]=[];return o[e].push(i),!1}function Uy(t,e){const r=t.fovAboveCenter,i=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,o=(t._camera.position[2]*t.worldSize-i)/Math.cos(t._pitch),s=Math.sin(r)*o/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01)),n=Math.sin(t._pitch)*s+o;return Math.min(1.01*n,o*(1/t._horizonShift))}function Ts(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 r=Math.pow(2,-t.z),i=t.x*r,o=(t.x+1)*r,s=t.y*r,n=(t.y+1)*r,a=Jr(i),l=Jr(o),c=ar(s),u=ar(n),h=e.project(a,c),d=e.project(l,c),p=e.project(l,u),f=e.project(a,u);let m=Math.min(h.x,d.x,p.x,f.x),_=Math.min(h.y,d.y,p.y,f.y),g=Math.max(h.x,d.x,p.x,f.x),y=Math.max(h.y,d.y,p.y,f.y);const v=r/16;function b(w,T,E,M,S,I){const C=(E+S)/2,k=(M+I)/2,A=e.project(Jr(C),ar(k)),L=Math.max(0,m-A.x,_-A.y,A.x-g,A.y-y);m=Math.min(m,A.x),g=Math.max(g,A.x),_=Math.min(_,A.y),y=Math.max(y,A.y),L>v&&(b(w,A,E,M,C,k),b(A,T,C,k,S,I))}b(h,d,i,s,o,s),b(d,p,o,s,o,n),b(p,f,o,n,i,n),b(f,h,i,n,i,s),m-=v,_-=v,g+=v,y+=v;const x=1/Math.max(g-m,y-_);return{scale:x,x:m*x,y:_*x,x2:g*x,y2:y*x,projection:e}}function Vy(t,e,r,i,o,s,n,a,l){if(l.name==="globe")return fd(t,e,new _i(r,i,o),!1);const c=Ts({z:r,x:i,y:o},l);return new Pt([(s+c.x/c.scale)*e,e*(c.y/c.scale),n],[(s+c.x2/c.scale)*e,e*(c.y2/c.scale),a])}function jy(t,{x:e,y:r},i=0){return new N(((e-i)*t.scale-t.x)*W,(r*t.scale-t.y)*W)}function Gy(t,e,r=0){return D.fromValues(((e.x-r)*t.scale-t.x)*W,(e.y*t.scale-t.y)*W,kg(e.z,e.y))}const V2=V.identity(new Float32Array(16));class Zo{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,r){return{x:0,y:0,z:0}}unproject(e,r){return new Ne(0,0)}projectTilePoint(e,r,i){return{x:e,y:r,z:0}}locationPoint(e,r,i=!0){return e._coordinatePoint(e.locationCoordinate(r),i)}pixelsPerMeter(e,r){return It(1,e)*r}pixelSpaceConversion(e,r,i){return 1}farthestPixelDistance(e){return Uy(e,e.pixelsPerMeter)}pointCoordinate(e,r,i,o){const s=e.horizonLineFromTop(!1),n=new N(r,Math.max(s,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(n,o))}pointCoordinate3D(e,r,i){const o=new N(r,i);if(e.elevation)return e.elevation.pointCoordinate(o);{const s=this.pointCoordinate(e,o.x,o.y,0);return[s.x,s.y,s.z]}}isPointAboveHorizon(e,r){if(e.elevation)return!this.pointCoordinate3D(e,r.x,r.y);const i=e.horizonLineFromTop();return r.y<i}createInversionMatrix(e,r){return V2}createTileMatrix(e,r,i){let o,s,n;const a=i.canonical,l=V.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const c=Ts(a,this);o=1,s=c.x+i.wrap*c.scale,n=c.y,V.scale(l,l,[o/c.scale,o/c.scale,e.pixelsPerMeter/r])}else o=r/e.zoomScale(a.z),s=(a.x+Math.pow(2,a.z)*i.wrap)*o,n=a.y*o;return V.translate(l,l,[s,n,0]),V.scale(l,l,[o/W,o/W,1]),l}upVector(e,r,i){return[0,0,1]}upVectorScale(e,r,i){return{metersToTile:1}}}class j2 extends Zo{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[r,i]=this.parallels=e.parallels||[29.5,45.5],o=Math.sin($e(r));this.n=(o+Math.sin($e(i)))/2,this.c=1+o*(2*this.n-o),this.r0=Math.sqrt(this.c)/this.n}project(e,r){const{n:i,c:o,r0:s}=this,n=$e(e-this.center[0]),a=$e(r),l=Math.sqrt(o-2*i*Math.sin(a))/i;return{x:l*Math.sin(n*i),y:l*Math.cos(n*i)-s,z:0}}unproject(e,r){const{n:i,c:o,r0:s}=this,n=s+r;let a=Math.atan2(e,Math.abs(n))*Math.sign(n);n*i<0&&(a-=Math.PI*Math.sign(e)*Math.sign(n));const l=$e(this.center[0])*i;a=Ni(a,-Math.PI-l,Math.PI-l);const c=Se(br(a/i)+this.center[0],-180,180),u=Math.asin(Se((o-(e*e+n*n)*i*i)/(2*i),-1,1)),h=Se(br(u),-Jt,Jt);return new Ne(c,h)}}const va=1.340264,ba=-.081106,wa=893e-6,Ta=.003796,pc=Math.sqrt(3)/2;class G2 extends Zo{project(e,r){r=r/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(pc*Math.sin(r)),o=i*i,s=o*o*o;return{x:.5*(e*Math.cos(i)/(pc*(va+3*ba*o+s*(7*wa+9*Ta*o)))/Math.PI+.5),y:1-.5*(i*(va+ba*o+s*(wa+Ta*o))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let i=r=(2*(1-r)-1)*Math.PI,o=i*i,s=o*o*o;for(let u,h,d,p=0;p<12&&(h=i*(va+ba*o+s*(wa+Ta*o))-r,d=va+3*ba*o+s*(7*wa+9*Ta*o),u=h/d,i=Se(i-u,-Math.PI/3,Math.PI/3),o=i*i,s=o*o*o,!(Math.abs(u)<1e-12));++p);const n=pc*e*(va+3*ba*o+s*(7*wa+9*Ta*o))/Math.cos(i),a=Math.asin(Math.sin(i)/pc),l=Se(180*n/Math.PI,-180,180),c=Se(180*a/Math.PI,-Jt,Jt);return new Ne(l,c)}}class q2 extends Zo{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){return{x:.5+e/360,y:.5-r/360,z:0}}unproject(e,r){const i=360*(e-.5),o=Se(360*(.5-r),-Jt,Jt);return new Ne(i,o)}}const bn=Math.PI/2;function fc(t){return Math.tan((bn+t)/2)}class Z2 extends Zo{constructor(e){super(e),this.center=e.center||[0,30];const[r,i]=this.parallels=e.parallels||[30,30];let o=$e(r),s=$e(i);this.southernCenter=o+s<0,this.southernCenter&&(o=-o,s=-s);const n=Math.cos(o),a=fc(o);this.n=o===s?Math.sin(o):Math.log(n/Math.cos(s))/Math.log(fc(s)/a),this.f=n*Math.pow(fc(o),this.n)/this.n}project(e,r){r=$e(r),this.southernCenter&&(r=-r),e=$e(e-this.center[0]);const i=1e-6,{n:o,f:s}=this;s>0?r<-bn+i&&(r=-bn+i):r>bn-i&&(r=bn-i);const n=s/Math.pow(fc(r),o);let a=n*Math.sin(o*e),l=s-n*Math.cos(o*e);return a=.5*(a/Math.PI+.5),l=.5*(l/Math.PI+.5),{x:a,y:this.southernCenter?l:1-l,z:0}}unproject(e,r){e=(2*e-.5)*Math.PI,this.southernCenter&&(r=1-r),r=(2*(1-r)-.5)*Math.PI;const{n:i,f:o}=this,s=o-r,n=Math.sign(s),a=Math.sign(i)*Math.sqrt(e*e+s*s);let l=Math.atan2(e,Math.abs(s))*n;s*i<0&&(l-=Math.PI*Math.sign(e)*n);const c=Se(br(l/i)+this.center[0],-180,180),u=Se(br(2*Math.atan(Math.pow(o/a,1/i))-bn),-Jt,Jt);return new Ne(c,this.southernCenter?-u:u)}}class qy extends Zo{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,r){return{x:ur(e),y:dr(r),z:0}}unproject(e,r){const i=Jr(e),o=ar(r);return new Ne(i,o)}}const Zy=$e(Jt);class $2 extends Zo{project(e,r){const i=(r=$e(r))*r,o=i*i;return{x:.5*((e=$e(e))*(.8707-.131979*i+o*(o*(.003971*i-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+i*(.015085+o*(.028874*i-.044475-.005916*o)))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let i=r=(2*(1-r)-1)*Math.PI,o=25,s=0,n=i*i;do{n=i*i;const c=n*n;s=(i*(1.007226+n*(.015085+c*(.028874*n-.044475-.005916*c)))-r)/(1.007226+n*(.045255+c*(.259866*n-.311325-.005916*11*c))),i=Se(i-s,-Zy,Zy)}while(Math.abs(s)>1e-6&&--o>0);n=i*i;const a=Se(br(e/(.8707+n*(n*(n*n*n*(.003971-.001529*n)-.013791)-.131979))),-180,180),l=br(i);return new Ne(a,l)}}const $y=$e(Jt);class H2 extends Zo{project(e,r){r=$e(r),e=$e(e);const i=Math.cos(r),o=2/Math.PI,s=Math.acos(i*Math.cos(e/2)),n=Math.sin(s)/s,a=.5*(e*o+2*i*Math.sin(e/2)/n)||0,l=.5*(r+Math.sin(r)/n)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+1),z:0}}unproject(e,r){let i=e=(2*e-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25;const n=1e-6;let a=0,l=0;do{const c=Math.cos(o),u=Math.sin(o),h=2*u*c,d=u*u,p=c*c,f=Math.cos(i/2),m=Math.sin(i/2),_=2*f*m,g=m*m,y=1-p*f*f,v=y?1/y:0,b=y?Math.acos(c*f)*Math.sqrt(1/y):0,x=.5*(2*b*c*m+2*i/Math.PI)-e,w=.5*(b*u+o)-r,T=.5*v*(p*g+b*c*f*d)+1/Math.PI,E=v*(_*h/4-b*u*m),M=.125*v*(h*m-b*u*p*_),S=.5*v*(d*f+b*g*c)+.5,I=E*M-S*T;a=(w*E-x*S)/I,l=(x*M-w*T)/I,i=Se(i-a,-Math.PI,Math.PI),o=Se(o-l,-$y,$y)}while((Math.abs(a)>n||Math.abs(l)>n)&&--s>0);return new Ne(br(i),br(o))}}class Hy extends Zo{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos($e(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){const{scale:i,cosPhi:o}=this;return{x:$e(e)*o*i+.5,y:-Math.sin($e(r))/o*i+.5,z:0}}unproject(e,r){const{scale:i,cosPhi:o}=this,s=-(r-.5)/i,n=Se(br((e-.5)/i)/o,-180,180),a=Math.asin(Se(s*o,-1,1)),l=Se(br(a),-Jt,Jt);return new Ne(n,l)}}class W2 extends qy{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,r,i){const o=ua(e,r,i),s=Oo(si(i));return D.transformMat4(o,o,s),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,r){const i=Nr(r.lat,r.lng),o=D.normalize([],i),s=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude,n=It(1,0)*W*s;D.scaleAndAdd(i,i,o,n);const a=V.identity(new Float64Array(16));return V.multiply(a,e.pixelMatrix,e.globeMatrix),D.transformMat4(i,i,a),new N(i[0],i[1])}pixelsPerMeter(e,r){return It(1,0)*r}pixelSpaceConversion(e,r,i){const o=It(1,e)*r,s=Fe(It(1,45)*r,o,i);return this.pixelsPerMeter(e,r)/s}createTileMatrix(e,r,i){const o=_d(si(i.canonical));return V.multiply(new Float64Array(16),e.globeMatrix,o)}createInversionMatrix(e,r){const{center:i}=e,o=Oo(si(r));return V.rotateY(o,o,$e(i.lng)),V.rotateX(o,o,$e(i.lat)),V.scale(o,o,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(o)}pointCoordinate(e,r,i,o){return xg(e,r,i,!0)||new lt(0,0)}pointCoordinate3D(e,r,i){const o=this.pointCoordinate(e,r,i,0);return[o.x,o.y,o.z]}isPointAboveHorizon(e,r){return!xg(e,r.x,r.y,!1)}farthestPixelDistance(e){const r=function(o,s){const n=o.cameraToCenterDistance,a=o._centerAltitude*s,l=o._camera,c=o._camera.forward(),u=D.add([],D.scale([],c,-n),[0,0,a]),h=o.worldSize/(2*Math.PI),d=[0,0,-h],p=o.width/o.height,f=Math.tan(o.fovAboveCenter),m=D.scale([],l.up(),f),_=D.scale([],l.right(),f*p),g=D.normalize([],D.add([],D.add([],c,m),_)),y=[];let v;if(new Fl(u,g).closestPointOnSphere(d,h,y)){const b=D.add([],y,d),x=D.sub([],b,u);v=Math.cos(o.fovAboveCenter)*D.length(x)}else{const b=D.sub([],u,d),x=D.sub([],d,u);D.normalize(x,x);const w=D.length(b)-h;v=Math.sqrt(w*(w+2*h));const T=Math.acos(v/(h+w))-Math.acos(D.dot(c,x));v*=Math.cos(T)}return 1.01*v}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=yr(e.zoom);if(i>0){const o=Uy(e,It(1,e.center.lat)*e.worldSize),s=e.worldSize/(2*Math.PI),n=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Fe(r,o+s*(1-Math.cos(n)),Math.pow(i,10))}return r}upVector(e,r,i){return ua(r,i,e,1)}upVectorScale(e){return{metersToTile:Nl(Vl(si(e)))}}}function mc(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new qy(t);case"equirectangular":return new q2(t);case"naturalEarth":return new $2(t);case"equalEarth":return new G2(t);case"winkelTripel":return new H2(t);case"albers":return r?new Hy(t):new j2(t);case"lambertConformalConic":return r?new Hy(t):new Z2(t);case"globe":return new W2(t)}throw new Error(`Invalid projection name: ${t.name}`)}const X2=new Xt({"symbol-placement":new se(j.layout_symbol["symbol-placement"]),"symbol-spacing":new se(j.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new se(j.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ke(j.layout_symbol["symbol-sort-key"]),"symbol-z-order":new se(j.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new se(j.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new se(j.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new se(j.layout_symbol["icon-ignore-placement"]),"icon-optional":new se(j.layout_symbol["icon-optional"]),"icon-rotation-alignment":new se(j.layout_symbol["icon-rotation-alignment"]),"icon-size":new ke(j.layout_symbol["icon-size"]),"icon-text-fit":new ke(j.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ke(j.layout_symbol["icon-text-fit-padding"]),"icon-image":new ke(j.layout_symbol["icon-image"]),"icon-rotate":new ke(j.layout_symbol["icon-rotate"]),"icon-padding":new se(j.layout_symbol["icon-padding"]),"icon-keep-upright":new se(j.layout_symbol["icon-keep-upright"]),"icon-offset":new ke(j.layout_symbol["icon-offset"]),"icon-anchor":new ke(j.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new se(j.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new se(j.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new se(j.layout_symbol["text-rotation-alignment"]),"text-field":new ke(j.layout_symbol["text-field"]),"text-font":new ke(j.layout_symbol["text-font"]),"text-size":new ke(j.layout_symbol["text-size"]),"text-max-width":new ke(j.layout_symbol["text-max-width"]),"text-line-height":new ke(j.layout_symbol["text-line-height"]),"text-letter-spacing":new ke(j.layout_symbol["text-letter-spacing"]),"text-justify":new ke(j.layout_symbol["text-justify"]),"text-radial-offset":new ke(j.layout_symbol["text-radial-offset"]),"text-variable-anchor":new se(j.layout_symbol["text-variable-anchor"]),"text-anchor":new ke(j.layout_symbol["text-anchor"]),"text-max-angle":new se(j.layout_symbol["text-max-angle"]),"text-writing-mode":new se(j.layout_symbol["text-writing-mode"]),"text-rotate":new ke(j.layout_symbol["text-rotate"]),"text-padding":new se(j.layout_symbol["text-padding"]),"text-keep-upright":new se(j.layout_symbol["text-keep-upright"]),"text-transform":new ke(j.layout_symbol["text-transform"]),"text-offset":new ke(j.layout_symbol["text-offset"]),"text-allow-overlap":new se(j.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new se(j.layout_symbol["text-ignore-placement"]),"text-optional":new se(j.layout_symbol["text-optional"]),visibility:new se(j.layout_symbol.visibility)});var Hd={paint:new Xt({"icon-opacity":new ke(j.paint_symbol["icon-opacity"]),"icon-emissive-strength":new ke(j.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ke(j.paint_symbol["text-emissive-strength"]),"icon-color":new ke(j.paint_symbol["icon-color"]),"icon-halo-color":new ke(j.paint_symbol["icon-halo-color"]),"icon-halo-width":new ke(j.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ke(j.paint_symbol["icon-halo-blur"]),"icon-translate":new se(j.paint_symbol["icon-translate"]),"icon-translate-anchor":new se(j.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ke(j.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ke(j.paint_symbol["text-opacity"]),"text-color":new ke(j.paint_symbol["text-color"],{runtimeType:hi,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ke(j.paint_symbol["text-halo-color"]),"text-halo-width":new ke(j.paint_symbol["text-halo-width"]),"text-halo-blur":new ke(j.paint_symbol["text-halo-blur"]),"text-translate":new se(j.paint_symbol["text-translate"]),"text-translate-anchor":new se(j.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new se(j.paint_symbol["icon-color-saturation"])}),layout:X2};class Wy{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:js,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ee(Wy,"FormatSectionOverride",{omit:["defaultValue"]});class _c extends ri{constructor(e,r){super(e,Hd,r)}recalculate(e,r){super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const o=[];for(const s of i)o.indexOf(s)<0&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,r,i,o){const s=this.layout.get(e).evaluate(r,{},i,o),n=this._unevaluatedLayout._values[e];return n.isDataDriven()||fl(n.value)||!s?s:function(a,l){return l.replace(/{([^{}]+)}/g,(c,u)=>u in a?String(a[u]):"")}(r.properties,s)}createBucket(e){return new Ea(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Hd.paint.overridableProperties){if(!_c.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),i=new Wy(r),o=new dh(i,r.property.specification);let s=null;s=r.value.kind==="constant"||r.value.kind==="source"?new ph("source",o):new Ao("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[e]=new on(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,i){return!(!this.layout||r.isDataDriven()||i.isDataDriven())&&_c.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const i=e.get("text-field"),o=Hd.paint.properties[r];let s=!1;const n=a=>{for(const l of a)if(o.overrides&&o.overrides.hasOverride(l))return void(s=!0)};if(i.value.kind==="constant"&&i.value.value instanceof $r)n(i.value.value.sections);else if(i.value.kind==="source"){const a=c=>{s||(c instanceof Vn&&mr(c.value)===Bn?n(c.value.sections):c instanceof jn?n(c.sections):c.eachChild(a))},l=i.value;l._styleExpression&&a(l._styleExpression.expression)}return s}getProgramIds(){const e=this.paint.get("icon-opacity").constantOr(1)!==0,r=this.paint.get("text-opacity").constantOr(1)!==0,i=[];return e&&i.push("symbolIcon"),r&&i.push("symbolSDF"),i}getDefaultProgramParams(e,r){return{config:new xs(this,r),overrideFog:!1}}}const Y2=tc.types,J2=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function gc(t,e,r,i,o,s,n,a,l,c,u,h,d){const p=a?Math.min(qo,Math.round(a[0])):0,f=a?Math.min(qo,Math.round(a[1])):0;t.emplaceBack(e,r,Math.round(32*i),Math.round(32*o),s,n,(p<<1)+(l?1:0),f,16*c,16*u,256*h,256*d)}function yc(t,e,r){t.emplaceBack(e,r)}function xc(t,e,r,i,o,s,n){t.emplaceBack(e,r,i,o,s,n)}function vc(t,e,r,i,o){const s=5*e+2;t.float32[s+0]=r,t.float32[s+1]=i,t.float32[s+2]=o}function wn(t,e,r,i,o){t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o),t.emplaceBack(e,r,i,o)}function K2(t){for(const e of t.sections)if(pb(e.text))return!0;return!1}class Wd{constructor(e){this.layoutVertexArray=new Dh,this.indexArray=new nr,this.programConfigurations=e,this.segments=new Et,this.dynamicLayoutVertexArray=new lo,this.opacityVertexArray=new Ph,this.placedSymbolArray=new Um,this.iconTransitioningVertexArray=new Do,this.globeExtVertexArray=new kh,this.zOffsetVertexArray=new ra}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}upload(e,r,i,o,s){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,f2.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,_2.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,J2,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,y2.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,m2.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||s)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,g2.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||o)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}Ee(Wd,"SymbolBuffers");class Xd{constructor(e,r,i){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new i,this.segments=new Et,this.collisionVertexArray=new Bh,this.collisionVertexArrayExt=new lo}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,x2.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,v2.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ee(Xd,"CollisionBuffers");class bc{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(n=>n.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=V.identity([]),this.placementViewportMatrix=V.identity([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fd(this.zoom,r["text-size"]),this.iconSizeData=Fd(this.zoom,r["icon-size"]);const i=this.layers[0].layout,o=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey=s!=="viewport-y"&&o.constantOr(1)!==void 0,this.sortFeaturesByY=(s==="viewport-y"||s==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(n=>Nt[n]),this.stateDependentLayerIds=this.layers.filter(n=>n.isStateDependent()).map(n=>n.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate")}createArrays(){this.text=new Wd(new Po(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Wd(new Po(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Gm,this.lineVertexArray=new qm,this.symbolInstances=new jm}calculateGlyphDependencies(e,r,i,o,s){for(let n=0;n<e.length;n++){const a=e.codePointAt(n);if(a===void 0)break;if(r[a]=!0,o&&s&&a<=65535){const l=_a[e.charAt(n)];l&&(r[l.charCodeAt(0)]=!0)}}}populate(e,r,i,o){const s=this.layers[0],n=s.layout,a=this.projection.name==="globe",l=n.get("text-font"),c=n.get("text-field"),u=n.get("icon-image"),h=(c.value.kind!=="constant"||c.value.value instanceof $r&&!c.value.value.isEmpty()||c.value.value.toString().length>0)&&(l.value.kind!=="constant"||l.value.value.length>0),d=u.value.kind!=="constant"||!!u.value.value||Object.keys(u.parameters).length>0,p=n.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new Ut(this.zoom);for(const{feature:y,id:v,index:b,sourceLayerIndex:x}of e){const w=s._featureFilter.needGeometry,T=Uo(y,w);if(!s._featureFilter.filter(g,T,i))continue;if(w||(T.geometry=$i(y,i,o)),a&&y.type!==1&&i.z<=5){const I=T.geometry,C=.98078528056,k=(A,L)=>{const O=ua(A.x,A.y,i,1),U=ua(L.x,L.y,i,1);return D.dot(O,U)<C};for(let A=0;A<I.length;A++)I[A]=nw(I[A],k)}let E,M;if(h){const I=s.getValueAndResolveTokens("text-field",T,i,_),C=$r.factory(I);K2(C)&&(this.hasRTLText=!0),(!this.hasRTLText||Ah()==="unavailable"||this.hasRTLText&&fi.isParsed())&&(E=T2(C,s,T))}if(d){const I=s.getValueAndResolveTokens("icon-image",T,i,_);M=I instanceof di?I:di.fromString(I)}if(!E&&!M)continue;const S=this.sortFeaturesByKey?p.evaluate(T,{},i):void 0;if(this.features.push({id:v,text:E,icon:M,index:b,sourceLayerIndex:x,geometry:T.geometry,properties:y.properties,type:Y2[y.type],sortKey:S}),M&&(f[M.namePrimary]=!0,M.nameSecondary&&(f[M.nameSecondary]=!0)),E){const I=l.evaluate(T,{},i).join(","),C=n.get("text-rotation-alignment")==="map"&&n.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Nt.vertical)>=0;for(const k of E.sections)if(k.image)f[k.image.namePrimary]=!0;else{const A=xh(E.toString()),L=k.fontStack||I,O=m[L]=m[L]||{};this.calculateGlyphDependencies(k.text,O,C,this.allowVerticalPlacement,A)}}}n.get("symbol-placement")==="line"&&(this.features=function(y){const v={},b={},x=[];let w=0;function T(I){x.push(y[I]),w++}function E(I,C,k){const A=b[I];return delete b[I],b[C]=A,x[A].geometry[0].pop(),x[A].geometry[0]=x[A].geometry[0].concat(k[0]),A}function M(I,C,k){const A=v[C];return delete v[C],v[I]=A,x[A].geometry[0].shift(),x[A].geometry[0]=k[0].concat(x[A].geometry[0]),A}function S(I,C,k){const A=k?C[0][C[0].length-1]:C[0][0];return`${I}:${A.x}:${A.y}`}for(let I=0;I<y.length;I++){const C=y[I],k=C.geometry,A=C.text?C.text.toString():null;if(!A){T(I);continue}const L=S(A,k),O=S(A,k,!0);if(L in b&&O in v&&b[L]!==v[O]){const U=M(L,O,k),R=E(L,O,x[U].geometry);delete v[L],delete b[O],b[S(A,x[R].geometry,!0)]=R,x[U].geometry=null}else L in b?E(L,O,k):O in v?M(L,O,k):(T(I),v[L]=w-1,b[O]=w-1)}return x.filter(I=>I.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((y,v)=>y.sortKey-v.sortKey)}update(e,r,i,o,s){const n=Object.keys(e).length!==0;if(n&&!this.stateDependentLayers.length)return;const a=n?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,r,a,i,o,s),this.icon.programConfigurations.updatePaintArrays(e,r,a,i,o,s)}updateZOffset(){const e=(s,n,a)=>{i+=n,i>s.length&&s.resize(i);for(let l=-n;l<0;l++)s.emplace(l+i,a)},r=(s,n,a)=>{o+=n,o>s.length&&s.resize(o);for(let l=-n;l<0;l++)s.emplace(l+o,a)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,o=0;for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,numIconVertices:c}=n,u=n.zOffset,h=c>0;if((a>0||l>0)&&(e(this.text.zOffsetVertexArray,a,u),e(this.text.zOffsetVertexArray,l,u)),h){const{placedIconSymbolIndex:d,verticalPlacedIconSymbolIndex:p}=n;d>=0&&r(this.icon.zOffsetVertexArray,c,u),p>=0&&r(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,u)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.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=mc(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const i=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:o,y:s}of r)this.lineVertexArray.emplaceBack(o,s);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_){const g=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,b=e.segments.prepareSegment(4*r.length,y,g,this.canOverlap?n.sortKey:void 0),x=this.glyphOffsetArray.length,w=b.vertexLength,T=this.allowVerticalPlacement&&a===Nt.vertical?Math.PI/2:0,E=n.text&&n.text.sections;for(let S=0;S<r.length;S++){const{tl:I,tr:C,bl:k,br:A,texPrimary:L,texSecondary:O,pixelOffsetTL:U,pixelOffsetBR:R,minFontScaleX:B,minFontScaleY:G,glyphOffset:Z,isSDF:q,sectionIndex:X}=r[S],Y=b.vertexLength,K=Z[1];if(gc(y,c.x,c.y,I.x,K+I.y,L.x,L.y,i,q,U.x,U.y,B,G),gc(y,c.x,c.y,C.x,K+C.y,L.x+L.w,L.y,i,q,R.x,U.y,B,G),gc(y,c.x,c.y,k.x,K+k.y,L.x,L.y+L.h,i,q,U.x,R.y,B,G),gc(y,c.x,c.y,A.x,K+A.y,L.x+L.w,L.y+L.h,i,q,R.x,R.y,B,G),l){const{x:H,y:ee,z:de}=l.anchor,[pe,ge,xe]=l.up;xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),xc(v,H,ee,de,pe,ge,xe),wn(e.dynamicLayoutVertexArray,H,ee,de,T)}else wn(e.dynamicLayoutVertexArray,c.x,c.y,c.z,T);if(_){const H=O||L;yc(e.iconTransitioningVertexArray,H.x,H.y),yc(e.iconTransitioningVertexArray,H.x+H.w,H.y),yc(e.iconTransitioningVertexArray,H.x,H.y+H.h),yc(e.iconTransitioningVertexArray,H.x+H.w,H.y+H.h)}g.emplaceBack(Y,Y+1,Y+2),g.emplaceBack(Y+1,Y+2,Y+3),b.vertexLength+=4,b.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Z[0]),S!==r.length-1&&X===r[S+1].sectionIndex||e.programConfigurations.populatePaintArrays(y.length,n,n.index,{},p,f,m,E&&E[X])}const M=l?l.anchor:c;e.placedSymbolArray.emplaceBack(M.x,M.y,M.z,c.x,c.y,x,this.glyphOffsetArray.length-x,w,u,h,c.segment,i?i[0]:0,i?i[1]:0,o[0],o[1],a,0,!1,0,d,0)}_commitLayoutVertex(e,r,i,o,s,n,a){e.emplaceBack(r,i,o,s,n,Math.round(a.x),Math.round(a.y))}_addCollisionDebugVertices(e,r,i,o,s,n,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=a.tileAnchorX,h=a.tileAnchorY;for(let p=0;p<4;p++)i.collisionVertexArray.emplaceBack(0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,r,e.padding,a.zOffset),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,o,s,n,u,h,new N(e.x1,e.y2)),l.vertexLength+=4;const d=i.indexArray;d.emplaceBack(c,c+1),d.emplaceBack(c+1,c+2),d.emplaceBack(c+2,c+3),d.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceTextSize(e,n,r,a);this._addCollisionDebugVertices(l,c,this.textCollisionBox,l.projectedAnchorX,l.projectedAnchorY,l.projectedAnchorZ,n)}}_addIconDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceIconSize(e,r,n.placedIconSymbolIndex);this._addCollisionDebugVertices(l,c,this.iconCollisionBox,l.projectedAnchorX,l.projectedAnchorY,l.projectedAnchorZ,n)}}generateCollisionDebugBuffers(e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Xd(zl,yy.members,Do),this.iconCollisionBox=new Xd(zl,yy.members,Do);const i=Hi(this.iconSizeData,e),o=Hi(this.textSizeData,e);for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s);this._addTextDebugCollisionBoxes(o,e,r,n.textBoxStartIndex,n.textBoxEndIndex,n),this._addTextDebugCollisionBoxes(o,e,r,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n),this._addIconDebugCollisionBoxes(i,e,r,n.iconBoxStartIndex,n.iconBoxEndIndex,n),this._addIconDebugCollisionBoxes(i,e,r,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex,n)}}getSymbolInstanceTextSize(e,r,i,o){const s=this.text.placedSymbolArray.get(r.rightJustifiedTextSymbolIndex>=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),n=ma(this.textSizeData,e,s)/xr;return this.tilePixelRatio*n}getSymbolInstanceIconSize(e,r,i){const o=this.icon.placedSymbolArray.get(i),s=ma(this.iconSizeData,e,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(e,r,i,o){e.emplaceBack(r,-i,-i,o),e.emplaceBack(r,i,-i,o),e.emplaceBack(r,i,i,o),e.emplaceBack(r,-i,i,o)}_updateTextDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceTextSize(e,n,r,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,c,l.padding,n.zOffset)}}_updateIconDebugCollisionBoxes(e,r,i,o,s,n){for(let a=o;a<s;a++){const l=i.get(a),c=this.getSymbolInstanceIconSize(e,r,n.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,c,l.padding,n.zOffset)}}updateCollisionDebugBuffers(e,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Hi(this.iconSizeData,e),o=Hi(this.textSizeData,e);for(let s=0;s<this.symbolInstances.length;s++){const n=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,e,r,n.textBoxStartIndex,n.textBoxEndIndex,n),this._updateTextDebugCollisionBoxes(o,e,r,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n),this._updateIconDebugCollisionBoxes(i,e,r,n.iconBoxStartIndex,n.iconBoxEndIndex,n),this._updateIconDebugCollisionBoxes(i,e,r,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex,n)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,r,i,o,s,n,a,l,c){const u={};if(r<i){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(r);u.textBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.textFeatureIndex=x}if(o<s){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(o);u.verticalTextBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.verticalTextFeatureIndex=x}if(n<a){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(n);u.iconBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.iconFeatureIndex=x}if(l<c){const{x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b,featureIndex:x}=e.get(l);u.verticalIconBox={x1:h,y1:d,x2:p,y2:f,padding:m,projectedAnchorX:_,projectedAnchorY:g,projectedAnchorZ:y,tileAnchorX:v,tileAnchorY:b},u.verticalIconFeatureIndex=x}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const i=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,r){const i=e.placedSymbolArray.get(r),o=i.vertexStartIndex+4*i.numGlyphs;for(let s=i.vertexStartIndex;s<o;s+=4)e.indexArray.emplaceBack(s,s+1,s+2),e.indexArray.emplaceBack(s+1,s+2,s+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),i=Math.cos(e),o=[],s=[],n=[];for(let a=0;a<this.symbolInstances.length;++a){n.push(a);const l=this.symbolInstances.get(a);o.push(0|Math.round(r*l.tileAnchorX+i*l.tileAnchorY)),s.push(l.featureIndex)}return n.sort((a,l)=>o[a]-o[l]||s[l]-s[a]),n}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,r)=>this.symbolInstances.get(r).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,r){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===r?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const i=this.symbolInstances.get(r);this.featureSortOrder.push(i.featureIndex);const{rightJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:a,placedIconSymbolIndex:l,verticalPlacedIconSymbolIndex:c}=i;o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&s!==o&&this.addIndicesForPlacedSymbol(this.text,s),n>=0&&n!==s&&n!==o&&this.addIndicesForPlacedSymbol(this.text,n),a>=0&&this.addIndicesForPlacedSymbol(this.text,a),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l),c>=0&&this.addIndicesForPlacedSymbol(this.icon,c)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ee(bc,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),bc.MAX_GLYPHS=65535,bc.addDynamicAttributes=wn;var Ea=bc;const Q2=xt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:eT}=Q2,tT=xt([{name:"a_packed",components:4,type:"Float32"}]),{members:rT}=tT,iT=tc.types,oT=Math.cos(Math.PI/180*37.5);class wc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new zh,this.layoutVertexArray2=new lo,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom),this.segments=new Et,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,i,o){this.hasPattern=Pd("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),n=[];for(const{feature:u,id:h,index:d,sourceLayerIndex:p}of e){const f=this.layers[0]._featureFilter.needGeometry,m=Uo(u,f);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),m,i))continue;const _=s?s.evaluate(m,{},i):void 0,g={id:h,properties:u.properties,type:u.type,sourceLayerIndex:p,index:d,geometry:f?m.geometry:$i(u,i,o),patterns:{},sortKey:_};n.push(g)}s&&n.sort((u,h)=>u.sortKey-h.sortKey);const{lineAtlas:a,featureIndex:l}=r,c=this.addConstantDashes(a);for(const u of n){const{geometry:h,index:d,sourceLayerIndex:p}=u;if(c&&this.addFeatureDashes(u,a),this.hasPattern){const f=Rd("line",this.layers,u,this.zoom,r);this.patternFeatures.push(f)}else this.addFeature(u,h,d,i,a.positions,r.availableImages,r.brightness);l.insert(e[d].feature,h,d,p,this.index)}}addConstantDashes(e){let r=!1;for(const i of this.layers){const o=i.paint.get("line-dasharray").value,s=i.layout.get("line-cap").value;if(o.kind!=="constant"||s.kind!=="constant")r=!0;else{const n=s.value,a=o.value;if(!a)continue;e.addDash(a,n)}}return r}addFeatureDashes(e,r){const i=this.zoom;for(const o of this.layers){const s=o.paint.get("line-dasharray").value,n=o.layout.get("line-cap").value;if(s.kind==="constant"&&n.kind==="constant")continue;let a,l;if(s.kind==="constant"){if(a=s.value,!a)continue}else a=s.evaluate({zoom:i},e);l=n.kind==="constant"?n.value:n.evaluate({zoom:i},e),r.addDash(a,l),e.patterns[o.id]=r.getKey(a,l)}}update(e,r,i,o,s){const n=Object.keys(e).length!==0;n&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,r,n?this.stateDependentLayers:this.layers,i,o,s)}addFeatures(e,r,i,o,s,n){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,r,i,o,n)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,rT)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,eT),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,i,o,s,n,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const p of r)this.addLine(p,e,c,u,h,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,a)}addLine(e,r,i,o,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let g=0;g<e.length-1;g++)this.totalDistance+=e[g].dist(e[g+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a=iT[r.type]==="Polygon";let l=e.length;for(;l>=2&&e[l-1].equals(e[l-2]);)l--;let c=0;for(;c<l-1&&e[c].equals(e[c+1]);)c++;if(l<(a?3:2))return;i==="bevel"&&(s=1.05);const u=this.overscaling<=16?15*W/(512*this.overscaling):0,h=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray);let d,p,f,m,_;this.e1=this.e2=-1,a&&(d=e[l-2],_=e[c].sub(d)._unit()._perp());for(let g=c;g<l;g++){if(f=g===l-1?a?e[c+1]:void 0:e[g+1],f&&e[g].equals(f))continue;_&&(m=_),d&&(p=d),d=e[g],_=f?f.sub(d)._unit()._perp():m,m=m||_;let y=m.add(_);y.x===0&&y.y===0||y._unit();const v=m.x*_.x+m.y*_.y,b=y.x*_.x+y.y*_.y,x=b!==0?1/b:1/0,w=2*Math.sqrt(2-2*b),T=b<oT&&p&&f,E=m.x*_.y-m.y*_.x>0;if(T&&g>c){const I=d.dist(p);if(I>2*u){const C=d.sub(d.sub(p)._mult(u/I)._round());this.updateDistance(p,C),this.addCurrentVertex(C,m,0,0,h),p=C}}const M=p&&f;let S=M?i:a?"butt":o;if(M&&S==="round"&&(x<n?S="miter":x<=2&&(S="fakeround")),S==="miter"&&x>s&&(S="bevel"),S==="bevel"&&(x>2&&(S="flipbevel"),x<s&&(S="miter")),p&&this.updateDistance(p,d),S==="miter")y._mult(x),this.addCurrentVertex(d,y,0,0,h);else if(S==="flipbevel"){if(x>100)y=_.mult(-1);else{const I=x*m.add(_).mag()/m.sub(_).mag();y._perp()._mult(I*(E?-1:1))}this.addCurrentVertex(d,y,0,0,h),this.addCurrentVertex(d,y.mult(-1),0,0,h)}else if(S==="bevel"||S==="fakeround"){const I=-Math.sqrt(x*x-1),C=E?I:0,k=E?0:I;if(p&&this.addCurrentVertex(d,m,C,k,h),S==="fakeround"){const A=Math.round(180*w/Math.PI/20);for(let L=1;L<A;L++){let O=L/A;if(O!==.5){const R=O-.5;O+=O*R*(O-1)*((1.0904+v*(v*(3.55645-1.43519*v)-3.2452))*R*R+(.848013+v*(.215638*v-1.06021)))}const U=_.sub(m)._mult(O)._add(m)._unit()._mult(E?-1:1);this.addHalfVertex(d,U.x,U.y,!1,E,0,h)}}f&&this.addCurrentVertex(d,_,-C,-k,h)}else if(S==="butt")this.addCurrentVertex(d,y,0,0,h);else if(S==="square"){const I=p?1:-1;p||this.addCurrentVertex(d,y,I,I,h),this.addCurrentVertex(d,y,0,0,h),p&&this.addCurrentVertex(d,y,I,I,h)}else S==="round"&&(p&&(this.addCurrentVertex(d,m,0,0,h),this.addCurrentVertex(d,m,1,1,h,!0)),f&&(this.addCurrentVertex(d,_,-1,-1,h,!0),this.addCurrentVertex(d,_,0,0,h)));if(T&&g<l-1){const I=d.dist(f);if(I>2*u){const C=d.add(f.sub(d)._mult(u/I)._round());this.updateDistance(d,C),this.addCurrentVertex(C,_,0,0,h),d=C}}}}addCurrentVertex(e,r,i,o,s,n=!1){const a=r.y*o-r.x,l=-r.y-r.x*o;this.addHalfVertex(e,r.x+r.y*i,r.y-r.x*i,n,!1,i,s),this.addHalfVertex(e,a,l,n,!0,-o,s)}addHalfVertex({x:e,y:r},i,o,s,n,a,l){this.layoutVertexArray.emplaceBack((e<<1)+(s?1:0),(r<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*o)+128,1+(a===0?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const c=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),l.primitiveLength++),n?this.e2=c:this.e1=c}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,r){this.distance+=e.dist(r),this.updateScaledDistance()}}Ee(wc,"LineBucket",{omit:["layers","patternFeatures"]});class Gt{constructor(e,r,i,o){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(r,o)}update(e,r,i){const{width:o,height:s}=e,{context:n}=this,{gl:a}=n,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:d}=$;if(a.bindTexture(a.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!r||r.premultiply!==!1)),i||this.size&&this.size[0]===o&&this.size[1]===s){const{x:p,y:f}=i||{x:0,y:0};if(e instanceof l||e instanceof c||e instanceof u||e instanceof h||d&&e instanceof d)a.texSubImage2D(a.TEXTURE_2D,0,p,f,a.RGBA,a.UNSIGNED_BYTE,e);else{let m=this.format,_=a.UNSIGNED_BYTE;this.format===a.R32F&&(m=a.RED,_=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,p,f,o,s,m,_,e.data)}}else if(this.size=[o,s],e instanceof l||e instanceof c||e instanceof u||e instanceof h||d&&e instanceof d){let p=this.format;this.format===a.R8&&(p=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,p,a.UNSIGNED_BYTE,e)}else{let p=this.format,f=this.format,m=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(p=a.DEPTH_COMPONENT16,m=a.UNSIGNED_SHORT),this.format===a.R32F&&(m=a.FLOAT,f=a.RED),a.texImage2D(a.TEXTURE_2D,0,p,o,s,0,f,m,e.data)}this.useMipmap=!!(r&&r.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(e,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),r!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapS=r)}bindExtraParam(e,r,i,o){const{context:s}=this,{gl:n}=s;n.bindTexture(n.TEXTURE_2D,this.texture),r!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,r),this.magFilter=r),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),i!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,i),this.wrapS=i),o!==this.wrapT&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,o),this.wrapT=o)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Tc{constructor(e,r){this.context=e,this.texture=r}bind(e,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,e),this.minFilter=e),r!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapS=r)}}const xi=32,Wi=33,$o=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,r=0,i=0,o=0,s=0,n=0,a=0;for(1&e?o=s=n=xi:r=i=a=xi;(e>>=1)>1;){const c=r+o>>1,u=i+s>>1;1&e?(o=r,s=i,r=n,i=a):(r=o,i=s,o=n,s=a),n=c,a=u}const l=4*t;$o[l+0]=r,$o[l+1]=i,$o[l+2]=o,$o[l+3]=s}const Xi=new Uint16Array(2178),Ho=new Uint8Array(1089),Ec=new Uint16Array(1089);function Xy(t){return t===0?-.03125:t===32?.03125:0}var Yd=xt([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Yy={type:2,extent:W,loadGeometry:()=>[[new N(0,0),new N(W+1,0),new N(W+1,W+1),new N(0,W+1),new N(0,0)]]};class Ma{constructor(e,r,i,o,s){this.tileID=e,this.uid=Ls(),this.uses=0,this.tileSize=r,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,o&&o.style&&(this._lastUpdatedBrightness=o.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(e){const r=e+this.timeAdded;r<je.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Ts(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,r,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(o,s){const n={};if(!s)return n;for(const a of o){const l=a.layerIds.map(c=>s.getLayer(c)).filter(Boolean);if(l.length!==0){a.layers=l,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(c=>l.filter(u=>u.id===c)[0]));for(const c of l)n[c.fqid]=a}}return n}(e.buckets,r.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const s=this.buckets[o];if(s instanceof Ea){if(this.hasSymbolBuckets=!0,!i)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const o in this.buckets){const s=this.buckets[o];if(s instanceof Ea&&s.hasRTLText){this.hasRTLText=!0,fi.isLoading()||fi.isLoaded()||Ah()!=="deferred"||km();break}}this.queryPadding=0;for(const o in this.buckets){const s=this.buckets[o],n=r.style.getOwnLayer(o);if(!n)continue;const a=n.queryRadius(s);this.queryPadding=Math.max(this.queryPadding,a)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new Gh}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._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(e){return this.buckets[e.fqid]}upload(e){for(const i in this.buckets){const o=this.buckets[i];o.uploadPending()&&o.upload(e)}const r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Gt(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Gt(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Gt(e,this.lineAtlas.image,r.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e,r,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!r||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=r.style.getBrightness();(this._lastUpdatedBrightness||o)&&(this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this._lastUpdatedBrightness=o,this.updateBuckets(void 0,r)))}queryRenderedFeatures(e,r,i,o,s,n,a,l){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:a,transform:n,params:s,tileTransform:this.tileTransform},e,r,i):{}}querySourceFeatures(e,r){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const o=i.loadVTLayers(),s=r?r.sourceLayer:"",n=o._geojsonTileLayer||o[s];if(!n)return;const a=yl(r&&r.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let d=0;d<n.length;d++){const p=n.feature(d);if(a.needGeometry){const _=Uo(p,!0);if(!a.filter(new Ut(this.tileID.overscaledZ),_,this.tileID.canonical))continue}else if(!a.filter(new Ut(this.tileID.overscaledZ),p))continue;const f=i.getId(p,s),m=new cy(p,l,c,u,f);m.tile=h,e.push(m)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}bucketsLoaded(){for(const e in this.buckets)if(this.buckets[e].uploadPending())return!1;return!0}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const r=this.expirationTime;if(e.cacheControl){const i=ze(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const i=Date.now();let o=!1;if(this.expirationTime>i)o=!1;else if(r)if(this.expirationTime<r)o=!0;else{const s=this.expirationTime-r;s?this.expirationTime=i+Math.max(s,3e4):o=!0}else o=!0;o?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,r){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&Object.keys(e).length!==0&&r&&this.updateBuckets(e,r)}updateBuckets(e,r){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),o=r.style.listImages(),s=r.style.getBrightness();for(const n in this.buckets){if(!r.style.hasLayer(n))continue;const a=this.buckets[n],l=a.layers[0].sourceLayer||"_geojsonTileLayer",c=i[l];let u={};if(e&&(u=e[l],!c||!u||Object.keys(u).length===0))continue;if(a.update(u,c,o,this.imageAtlas&&this.imageAtlas.patternPositions||{},s),a instanceof wc||a instanceof Ql){const d=r.style.getOwnSourceCache(a.layers[0].source);r._terrain&&r._terrain.enabled&&d&&a.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(d.id,this.tileID)}const h=r&&r.style&&r.style.getOwnLayer(n);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(a)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<je.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=je.now()+e}setTexture(e,r){const i=r.context,o=i.gl;this.texture=this.texture||r.getTileTexture(e.width),this.texture&&this.texture instanceof Gt?this.texture.update(e,{useMipmap:!0}):(this.texture=new Gt(i,e,o.RGBA,{useMipmap:!0}),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE))}setDependencies(e,r){const i={};for(const o of r)i[o]=!0;this.dependencies[e]=i}hasDependency(e,r){for(const i of e){const o=this.dependencies[i];if(o){for(const s of r)if(o[s])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,r){if(!r||r.name==="mercator"||this._tileDebugBuffer)return;const i=$i(Yy,this.tileID.canonical,this.tileTransform)[0],o=new Wr,s=new ia;for(let n=0;n<i.length;n++){const{x:a,y:l}=i[n];o.emplaceBack(a,l),s.emplaceBack(n)}s.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(s),this._tileDebugBuffer=e.createVertexBuffer(o,Lo.members),this._tileDebugSegments=Et.simpleSegment(0,0,o.length,s.length)}_makeTileBoundsBuffers(e,r){if(this._tileBoundsBuffer||!r||r.name==="mercator")return;const i=$i(Yy,this.tileID.canonical,this.tileTransform)[0];let o,s;if(this.isRaster){const n=function(a,l){const c=Ts(a,l),u=Math.pow(2,a.z);for(let _=0;_<Wi;_++)for(let g=0;g<Wi;g++){const y=Jr((a.x+(g+Xy(g))/xi)/u),v=ar((a.y+(_+Xy(_))/xi)/u),b=l.project(y,v),x=_*Wi+g;Xi[2*x+0]=Math.round((b.x*c.scale-c.x)*W),Xi[2*x+1]=Math.round((b.y*c.scale-c.y)*W)}Ho.fill(0),Ec.fill(0);for(let _=2045;_>=0;_--){const g=4*_,y=$o[g+0],v=$o[g+1],b=$o[g+2],x=$o[g+3],w=y+b>>1,T=v+x>>1,E=w+T-v,M=T+y-w,S=v*Wi+y,I=x*Wi+b,C=T*Wi+w,k=Math.hypot((Xi[2*S+0]+Xi[2*I+0])/2-Xi[2*C+0],(Xi[2*S+1]+Xi[2*I+1])/2-Xi[2*C+1])>=16;Ho[C]=Ho[C]||(k?1:0),_<1022&&(Ho[C]=Ho[C]||Ho[(v+M>>1)*Wi+(y+E>>1)]||Ho[(x+M>>1)*Wi+(b+E>>1)])}const h=new _s,d=new nr;let p=0;function f(_,g){const y=g*Wi+_;return Ec[y]===0&&(h.emplaceBack(Xi[2*y+0],Xi[2*y+1],_*W/xi,g*W/xi),Ec[y]=++p),Ec[y]-1}function m(_,g,y,v,b,x){const w=_+y>>1,T=g+v>>1;if(Math.abs(_-b)+Math.abs(g-x)>1&&Ho[T*Wi+w])m(b,x,_,g,w,T),m(y,v,b,x,w,T);else{const E=f(_,g),M=f(y,v),S=f(b,x);d.emplaceBack(E,M,S)}}return m(0,0,xi,xi,xi,0),m(xi,xi,0,0,0,xi),{vertices:h,indices:d}}(this.tileID.canonical,r);o=n.vertices,s=n.indices}else{o=new _s,s=new nr;for(const{x:a,y:l}of i)o.emplaceBack(a,l,0,0);const n=Kl(o.int16,void 0,4);for(let a=0;a<n.length;a+=3)s.emplaceBack(n[a],n[a+1],n[a+2])}this._tileBoundsBuffer=e.createVertexBuffer(o,Yd.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(s),this._tileBoundsSegments=Et.simpleSegment(0,0,o.length,s.length)}_makeGlobeTileDebugBuffers(e,r){const i=r.projection;if(!i||i.name!=="globe"||r.freezeTileCoverage)return;const o=this.tileID.canonical,s=Oo(vg(o,r)),n=yr(r.zoom);let a;n>0&&(a=V.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,o,r,s,a,n),this._makeGlobeTileDebugTextBuffer(e,o,r,s,a,n)}_globePoint(e,r,i,o,s,n,a){let l=ua(e,r,i);if(n){const c=1<<i.z,u=ur(o.center.lng),h=dr(o.center.lat),d=(i.x+.5)/c-u;let p=0;d>.5?p=-1:d<-.5&&(p=1);let f=(e/W+i.x)/c+p,m=(r/W+i.y)/c;f=(f-u)*o._pixelsPerMercatorPixel+u,m=(m-h)*o._pixelsPerMercatorPixel+h;const _=[f*o.worldSize,m*o.worldSize,0];D.transformMat4(_,_,n),l=go(l,_,a)}return D.transformMat4(l,l,s)}_makeGlobeTileDebugBorderBuffer(e,r,i,o,s,n){const a=new Wr,l=new ia,c=new Al,u=(d,p,f,m,_)=>{const g=(f-d)/(_-1),y=(m-p)/(_-1),v=a.length;for(let b=0;b<_;b++){const x=d+b*g,w=p+b*y;a.emplaceBack(x,w);const T=this._globePoint(x,w,r,i,o,s,n);c.emplaceBack(T[0],T[1],T[2]),l.emplaceBack(v+b)}},h=W;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(l),this._tileDebugBuffer=e.createVertexBuffer(a,Lo.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(c,pg.members),this._tileDebugSegments=Et.simpleSegment(0,0,a.length,l.length)}_makeGlobeTileDebugTextBuffer(e,r,i,o,s,n){const a=W/4,l=new Wr,c=new nr,u=new Al,h=25;c.reserve(32),l.reserve(h),u.reserve(h);const d=(p,f)=>h*p+f;for(let p=0;p<h;p++){const f=p*a;for(let m=0;m<h;m++){const _=m*a;l.emplaceBack(_,f);const g=this._globePoint(_,f,r,i,o,s,n);u.emplaceBack(g[0],g[1],g[2])}}for(let p=0;p<4;p++)for(let f=0;f<4;f++){const m=d(p,f),_=d(p,f+1),g=d(p+1,f),y=d(p+1,f+1);c.emplaceBack(m,_,g),c.emplaceBack(g,_,y)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(c),this._tileDebugTextBuffer=e.createVertexBuffer(l,Lo.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(u,pg.members),this._tileDebugTextSegments=Et.simpleSegment(0,0,h,32)}destroy(e=!1){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(),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),!e&&this.texture&&this.texture instanceof Gt&&(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.latestFeatureIndex=null,this.state="unloaded"}}class sT{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(const e in this.data)for(const r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,i){const o=e.wrapped().key;this.data[o]===void 0&&(this.data[o]=[]);const s={value:r,timeout:void 0};if(i!==void 0&&(s.timeout=setTimeout(()=>{this.remove(e,s)},i)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){const r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;const i=e.wrapped().key,o=r===void 0?0:this.data[i].indexOf(r),s=this.data[i][o];return this.data[i].splice(o,1),s.timeout&&clearTimeout(s.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(e){const r=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||r.push(o);for(const i of r)this.remove(i.value.tileID,i)}}class Wo{constructor(e,r,i,o){this.id=Wo.uniqueIdxCounter,Wo.uniqueIdxCounter++,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||o||r.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=Wo.uniqueIdxCounter,Wo.uniqueIdxCounter++;const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Wo.uniqueIdxCounter=0;const nT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class aT{constructor(e,r,i,o,s,n){this.length=r.length,this.attributes=i,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.instanceCount=n,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||s||r.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,r){for(let i=0;i<this.attributes.length;i++){const o=r.attributes[this.attributes[i].name];o!==void 0&&e.enableVertexAttribArray(o)}}setVertexAttribPointers(e,r,i){for(let o=0;o<this.attributes.length;o++){const s=this.attributes[o],n=r.attributes[s.name];n!==void 0&&e.vertexAttribPointer(n,s.components,e[nT[s.type]],!1,this.itemSize,s.offset+this.itemSize*(i||0))}}setVertexAttribDivisor(e,r,i){for(let o=0;o<this.attributes.length;o++){const s=r.attributes[this.attributes[o].name];s!==void 0&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(s,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Bt{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class lT extends Bt{getDefault(){return Qe.transparent}set(e){const r=this.current;(e.r!==r.r||e.g!==r.g||e.b!==r.b||e.a!==r.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class cT extends Bt{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class uT extends Bt{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class hT extends Bt{getDefault(){return[!0,!0,!0,!0]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class dT extends Bt{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class pT extends Bt{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class fT extends Bt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const r=this.current;(e.func!==r.func||e.ref!==r.ref||e.mask!==r.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class mT extends Bt{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class _T extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.STENCIL_TEST):r.disable(r.STENCIL_TEST),this.current=e,this.dirty=!1}}class gT extends Bt{getDefault(){return[0,1]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class yT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),this.current=e,this.dirty=!1}}class xT extends Bt{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class vT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.BLEND):r.disable(r.BLEND),this.current=e,this.dirty=!1}}class bT extends Bt{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class wT extends Bt{getDefault(){return Qe.transparent}set(e){const r=this.current;(e.r!==r.r||e.g!==r.g||e.b!==r.b||e.a!==r.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class TT extends Bt{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class ET extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;e?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),this.current=e,this.dirty=!1}}class MT extends Bt{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class ST extends Bt{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let AT=class extends Bt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}};class IT extends Bt{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class CT extends Bt{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const r=this.current;(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class zT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindFramebuffer(r.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class DT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindRenderbuffer(r.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class kT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindTexture(r.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class PT extends Bt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.bindBuffer(r.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class RT extends Bt{getDefault(){return null}set(e){const r=this.gl;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class LT extends Bt{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class BT extends Bt{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class OT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class FT extends Bt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Jd extends Bt{constructor(e,r){super(e),this.context=e,this.parent=r}getDefault(){return null}}class NT extends Jd{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Jy extends Jd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferRenderbuffer(r.FRAMEBUFFER,this.attachment(),r.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class UT extends Jd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,this.attachment(),r.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class VT extends Jy{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class jT{constructor(e,r,i,o,s){this.context=e,this.width=r,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new NT(e,n)),s&&(this.depthAttachmentType=s,this.depthAttachment=s==="renderbuffer"?new Jy(e,n):new UT(e,n))}destroy(){const e=this.context.gl;if(this.colorAttachment){const r=this.colorAttachment.get();r&&e.deleteTexture(r)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}else{const r=this.depthAttachment.get();r&&e.deleteTexture(r)}e.deleteFramebuffer(this.framebuffer)}}class Le{constructor(e,r,i){this.func=e,this.mask=r,this.range=i}}Le.ReadOnly=!1,Le.ReadWrite=!0,Le.disabled=new Le(519,Le.ReadOnly,[0,1]);const Kd=7680;class et{constructor(e,r,i,o,s,n){this.test=e,this.ref=r,this.mask=i,this.fail=o,this.depthFail=s,this.pass=n}}et.disabled=new et({func:519,mask:0},0,0,Kd,Kd,Kd);const Mc=771;class pt{constructor(e,r,i,o){this.blendFunction=e,this.blendColor=r,this.mask=i,this.blendEquation=o}}pt.Replace=[1,0,1,0],pt.disabled=new pt(pt.Replace,Qe.transparent,[!1,!1,!1,!1]),pt.unblended=new pt(pt.Replace,Qe.transparent,[!0,!0,!0,!0]),pt.alphaBlended=new pt([1,Mc,1,Mc],Qe.transparent,[!0,!0,!0,!0]),pt.multiply=new pt([774,0,774,0],Qe.transparent,[!0,!0,!0,!0]);const Qd=1029,ep=2305;class rt{constructor(e,r,i){this.enable=e,this.mode=r,this.frontFace=i}}rt.disabled=new rt(!1,Qd,ep),rt.backCCW=new rt(!0,Qd,ep),rt.backCW=new rt(!0,Qd,2304),rt.frontCW=new rt(!0,1028,2304),rt.frontCCW=new rt(!0,1028,ep);class GT{constructor(e,r){this.gl=e,this.clearColor=new lT(this),this.clearDepth=new cT(this),this.clearStencil=new uT(this),this.colorMask=new hT(this),this.depthMask=new dT(this),this.stencilMask=new pT(this),this.stencilFunc=new fT(this),this.stencilOp=new mT(this),this.stencilTest=new _T(this),this.depthRange=new gT(this),this.depthTest=new yT(this),this.depthFunc=new xT(this),this.blend=new vT(this),this.blendFunc=new bT(this),this.blendColor=new wT(this),this.blendEquation=new TT(this),this.cullFace=new ET(this),this.cullFaceSide=new MT(this),this.frontFace=new ST(this),this.program=new AT(this),this.activeTexture=new IT(this),this.viewport=new CT(this),this.bindFramebuffer=new zT(this),this.bindRenderbuffer=new DT(this),this.bindTexture=new kT(this),this.bindVertexBuffer=new PT(this),this.bindElementBuffer=new RT(this),this.bindVertexArrayOES=new LT(this),this.pixelStoreUnpack=new BT(this),this.pixelStoreUnpackPremultiplyAlpha=new OT(this),this.pixelStoreUnpackFlipY=new FT(this),this.options=r?{...r}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,r,i){return new Wo(this,e,r,i)}createVertexBuffer(e,r,i,o,s){return new aT(this,e,r,i,o,s)}createRenderbuffer(e,r,i){const o=this.gl,s=o.createRenderbuffer();return this.bindRenderbuffer.set(s),o.renderbufferStorage(o.RENDERBUFFER,e,r,i),this.bindRenderbuffer.set(null),s}createFramebuffer(e,r,i,o){return new jT(this,e,r,i,o)}clear({color:e,depth:r,stencil:i,colorMask:o}){const s=this.gl;let n=0;e&&(n|=s.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(o||[!0,!0,!0,!0])),r!==void 0&&(n|=s.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(r),this.depthMask.set(!0)),i!==void 0&&(n|=s.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),s.clear(n)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){dt(e.blendFunction,pt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}class ki extends or{constructor(e,r,i){super(),this.id=e,this._onlySymbols=i,r.on("data",o=>{o.dataType==="source"&&o.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&o.dataType==="source"&&o.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new sT(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new l2,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(e){this.map=e,this._minTileCacheSize=this._minTileCacheSize===void 0&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const e in this._tiles){const r=this._tiles[e];if(r.state!=="errored"&&(r.state!=="loaded"||!r.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,r){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,r)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const r in this._tiles){const i=this._tiles[r];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ss(this._tiles).map(e=>e.tileID).sort(Ky).map(e=>e.key)}getRenderableIds(e,r){const i=[];for(const o in this._tiles)this._isIdRenderable(+o,e,r)&&i.push(this._tiles[o]);return e?i.sort((o,s)=>{const n=o.tileID,a=s.tileID,l=new N(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),c=new N(a.canonical.x,a.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-a.overscaledZ||c.y-l.y||c.x-l.x}).map(o=>o.tileID.key):i.map(o=>o.tileID).sort(Ky).map(o=>o.key)}hasRenderableParent(e){const r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,r){const i=this._tiles[e];i&&(i.state!=="loading"&&(i.state=r),this._loadTile(i,this._tileLoaded.bind(this,i,e,r)))}_tileLoaded(e,r,i,o){if(o)if(e.state="errored",o.status!==404)this._source.fire(new Ue(o,{tile:e}));else{if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new ae("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else e.timeAdded=je.now(),i==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new ae("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const r=this.getRenderableIds();for(let o=0;o<r.length;o++){const s=r[o];if(e.neighboringTiles&&e.neighboringTiles[s]){const n=this.getTileByID(s);i(e,n),i(n,e)}}function i(o,s){if(!o.dem||o.dem.borderReady)return;o.needsHillshadePrepare=!0,o.needsDEMTextureUpload=!0;let n=s.tileID.canonical.x-o.tileID.canonical.x;const a=s.tileID.canonical.y-o.tileID.canonical.y,l=Math.pow(2,o.tileID.canonical.z),c=s.tileID.key;n===0&&a===0||Math.abs(a)>1||(Math.abs(n)>1&&(Math.abs(n+l)===1?n+=l:Math.abs(n-l)===1&&(n-=l)),s.dem&&o.dem&&(o.dem.backfillBorder(s.dem,n,a),o.neighboringTiles&&o.neighboringTiles[c]&&(o.neighboringTiles[c].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,i,o){for(const s in this._tiles){let n=this._tiles[s];if(o[s]||!n.hasData()||n.tileID.overscaledZ<=r||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>r+1;){const c=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[c.key],n&&n.hasData()&&(a=c)}let l=a;for(;l.overscaledZ>r;)if(l=l.scaledTo(l.overscaledZ-1),e[l.key]){o[a.key]=a;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=r?i:null}for(let i=e.overscaledZ-1;i>=r;i--){const o=e.scaledTo(i),s=this._getLoadedTile(o);if(s)return s}}_getLoadedTile(e){const r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,r){r=r||this._source.tileSize;const i=Math.ceil(e.width/r)+1,o=Math.ceil(e.height/r)+1,s=Math.floor(i*o*5),n=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,s):s,a=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(a)}handleWrapJump(e){const r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,r){const i={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),i[s.tileID.key]=s}this._tiles=i;for(const o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(const o in this._tiles)this._setTileReloadTimer(+o,this._tiles[o])}}update(e,r,i,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!i)return;let s;if(this.updateCacheSize(e,r),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new mt(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(s=e.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter(l=>this._source.hasTile(l)))):s=[],s.length>0&&this.castsShadows&&o&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!tp(this._source.type)){const l=e.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),c=Math.min(l,this._source.maxzoom),u=e.extendTileCoverForShadows(s,o,c);for(const h of u)this._shadowCasterTiles[h.key]=!0,s.push(h)}const n=this._updateRetainedTiles(s);if(tp(this._source.type)&&s.length!==0){const l={},c={},u=Object.keys(n);for(const d of u){const p=n[d],f=this._tiles[d];if(!f||f.fadeEndTime&&f.fadeEndTime<=je.now())continue;const m=this.findLoadedParent(p,Math.max(p.overscaledZ-ki.maxOverzooming,this._source.minzoom));m&&(this._addTile(m.tileID),l[m.tileID.key]=m.tileID),c[d]=p}const h=s[s.length-1].overscaledZ;for(const d in this._tiles){const p=this._tiles[d];if(n[d]||!p.hasData())continue;let f=p.tileID;for(;f.overscaledZ>h;){f=f.scaledTo(f.overscaledZ-1);const m=this._tiles[f.key];if(m&&m.hasData()&&c[f.key]){n[d]=p.tileID;break}}}for(const d in l)n[d]||(this._coveredTiles[d]=!0,n[d]=l[d])}for(const l in n)this._tiles[l].clearFadeHold();const a=function(l,c){const u=[];for(const h in l)h in c||u.push(h);return u}(this._tiles,n);for(const l of a){const c=this._tiles[l];c.hasSymbolBuckets&&!c.holdingForFade()?c.setHoldDuration(this.map._fadeDuration):c.hasSymbolBuckets&&!c.symbolFadeFinished()||this._removeTile(+l)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const r={};if(e.length===0)return r;const i={},o=e.reduce((c,u)=>Math.min(c,u.overscaledZ),1/0),s=e[0].overscaledZ,n=Math.max(s-ki.maxOverzooming,this._source.minzoom),a=Math.max(s+ki.maxUnderzooming,this._source.minzoom),l={};for(const c of e){const u=this._addTile(c);r[c.key]=c,u.hasData()||o<this._source.maxzoom&&(l[c.key]=c)}this._retainLoadedChildren(l,o,a,r);for(const c of e){let u=this._tiles[c.key];if(u.hasData())continue;if(c.canonical.z>=this._source.maxzoom){const d=c.children(this._source.maxzoom)[0],p=this.getTile(d);if(p&&p.hasData()){r[d.key]=d;continue}}else{const d=c.children(this._source.maxzoom);if(r[d[0].key]&&r[d[1].key]&&r[d[2].key]&&r[d[3].key])continue}let h=u.wasRequested();for(let d=c.overscaledZ-1;d>=n;--d){const p=c.scaledTo(d);if(i[p.key]||(i[p.key]=!0,u=this.getTile(p),!u&&h&&(u=this._addTile(p)),u&&(r[p.key]=p,h=u.wasRequested(),u.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const r=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(s),i)break;o=s}for(const s of r)this._loadedParentTiles[s]=i}}_addTile(e){let r=this._tiles[e.key];if(r)return r.isExtraShadowCaster!==!0||this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));const i=!!r;if(!i){const o=this.map?this.map.painter:null;r=new Ma(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,o,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))}return r?(r.uses++,this._tiles[e.key]=r,i||this._source.fire(new ae("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=r.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_removeTile(e){const r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&r.state!=="reloading"?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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(e,r,i){const o=[],s=this.transform;if(!s)return o;const n=s.projection.name==="globe",a=ur(s.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(i&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(n){const h=c.tileID.canonical;if(h.z===0){const d=[Math.abs(Se(a,...Sa(h,-1))-a),Math.abs(Se(a,...Sa(h,1))-a)];u=[0,2*d.indexOf(Math.min(...d))-1]}else{const d=[Math.abs(Se(a,...Sa(h,-1))-a),Math.abs(Se(a,...Sa(h,0))-a),Math.abs(Se(a,...Sa(h,1))-a)];u=[d.indexOf(Math.min(...d))-1]}}else u=[0];for(const h of u){const d=e.containsTile(c,s,r,h);d&&o.push(d)}}return o}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,r){const i=this.getRenderableIds(e,r).map(s=>this._tiles[s].tileID),o=this.transform.projection.name==="globe";for(const s of i)s.projMatrix=this.transform.calculateProjMatrix(s.toUnwrapped()),s.expandedProjMatrix=o?this.transform.calculateProjMatrix(s.toUnwrapped(),!1,!0):s.projMatrix;return i}sortCoordinatesByDistance(e){const r=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),s={};for(const n of r){const a=1/(1<<n.canonical.z);s[n.key]=((n.canonical.x+.5)*a+n.wrap-i[0])*o[0]+((n.canonical.y+.5)*a-i[1])*o[1]-i[2]*o[2]}return r.sort((n,a)=>s[n.key]-s[a.key]),r}hasTransition(){if(this._source.hasTransition())return!0;if(tp(this._source.type))for(const e in this._tiles){const r=this._tiles[e];if(r.fadeEndTime!==void 0&&r.fadeEndTime>=je.now())return!0}return!1}setFeatureState(e,r,i){this._state.updateState(e=e||"_geojsonTileLayer",r,i)}removeFeatureState(e,r,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,i)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,i){const o=this._tiles[e];o&&o.setDependencies(r,i)}reloadTilesForDependencies(e,r){for(const i in this._tiles)this._tiles[i].hasDependency(e,r)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,r))}_preloadTiles(e,r){if(!this._sourceLoaded){const a=()=>{this._sourceLoaded&&(this._source.off("data",a),this._preloadTiles(e,r))};return void this._source.on("data",a)}const i=new Map,o=Array.isArray(e)?e:[e],s=this.map.painter.terrain,n=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const a of o){const l=a.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const c of l)i.set(c.key,c);this.usedForTerrain&&a.updateElevation(!1)}os(Array.from(i.values()),(a,l)=>{const c=new Ma(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(c,u=>{this._source.type==="raster-dem"&&c.dem&&this._backfillDEM(c),l(u,c)})},r)}}function Ky(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),i=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||i-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function tp(t){return t==="raster"||t==="image"||t==="video"||t==="custom"}function Sa(t,e){const r=1<<t.z;return[t.x/r+e,(t.x+1)/r+e]}ki.maxOverzooming=10,ki.maxUnderzooming=3;const qT=xt([{name:"a_pos_3f",components:3,type:"Float32"}]),ZT=xt([{name:"a_color_3f",components:3,type:"Float32"}]),$T=xt([{name:"a_color_4f",components:4,type:"Float32"}]),HT=xt([{name:"a_uv_2f",components:2,type:"Float32"}]),WT=xt([{name:"a_normal_3f",components:3,type:"Float32"}]),XT=xt([{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"}]),YT=xt([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class rp{constructor(e=0,r=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(r)||r<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=r,this.left=i,this.right=o}interpolate(e,r,i){return r.top!=null&&e.top!=null&&(this.top=Fe(e.top,r.top,i)),r.bottom!=null&&e.bottom!=null&&(this.bottom=Fe(e.bottom,r.bottom,i)),r.left!=null&&e.left!=null&&(this.left=Fe(e.left,r.left,i)),r.right!=null&&e.right!=null&&(this.right=Fe(e.right,r.right,i)),this}getCenter(e,r){const i=Se((this.left+e-this.right)/2,0,e),o=Se((this.top+r-this.bottom)/2,0,r);return new N(i,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new rp(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qy(t,e){const r=$t(t,3);V.fromQuat(t,e),wr(t,3,r)}function ip(t,e){const r=Ar.identity([]);return Ar.rotateZ(r,r,-e),Ar.rotateX(r,r,-t),r}function e0(t,e){const r=[t[0],t[1],0],i=[e[0],e[1],0];if(D.length(r)>=1e-15){const n=D.normalize([],r);D.scale(i,n,D.dot(i,n)),e[0]=i[0],e[1]=i[1]}const o=D.cross([],e,t);if(D.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return ip(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class t0{constructor(e,r){this.position=e,this.orientation=r}get position(){return this._position}set position(e){if(e){const r=e instanceof lt?e:new lt(e[0],e[1],e[2]);this._renderWorldCopies&&(r.x=Ni(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(e,r){if(this.orientation=null,!this.position)return;const i=this.position,o=this._elevation?this._elevation.getAtPointOrZero(lt.fromLngLat(e)):0,s=lt.fromLngLat(e,o),n=[s.x-i.x,s.y-i.y,s.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=e0(n,r)}setPitchBearing(e,r){this.orientation=ip($e(e),$e(-r))}}class Sc{constructor(e,r){this._transform=V.identity([]),this.orientation=r,this.position=e}get mercatorPosition(){const e=this.position;return new lt(e[0],e[1],e[2])}get position(){const e=$t(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var r;e&&wr(this._transform,3,[(r=e)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||Ar.identity([]),e&&Qy(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),r=this.right();return{bearing:Math.atan2(-r[1],r[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,r){this._orientation=ip(e,r),Qy(this._transform,this._orientation)}forward(){const e=$t(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=$t(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=$t(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,r){const i=new Float64Array(16);return V.invert(i,this.getWorldToCamera(e,r)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,r,i){const o=this.position;D.scale(o,o,-e);const s=new Float64Array(16);return V.fromScaling(s,[i,i,i]),V.translate(s,s,o),s[10]*=r,s}getWorldToCamera(e,r){const i=new Float64Array(16),o=new Float64Array(4),s=this.position;return Ar.conjugate(o,this._orientation),D.scale(s,s,-e),V.fromQuat(i,o),V.translate(i,i,s),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}getCameraToClipPerspective(e,r,i,o){const s=new Float64Array(16);return V.perspective(s,e,r,i,o),s}getCameraToClipOrthographic(e,r,i,o,s,n){const a=new Float64Array(16);return V.ortho(a,e,r,i,o,s,n),a}getDistanceToElevation(e,r=!1){const i=e===0?0:It(e,r?ar(this.position[1]):this.position[1]),o=this.forward();return(i-this.position[2])/o[2]}clone(){return new Sc([...this.position],[...this.orientation])}}function r0(t,e){const r=Aa(t.projection,t.zoom,t.width,t.height),i=function(s,n,a,l,c){const u=new Ne(a.lng-180*Xo,a.lat),h=new Ne(a.lng+180*Xo,a.lat),d=s.project(u.lng,u.lat),p=s.project(h.lng,h.lat),f=-Math.atan2(p.y-d.y,p.x-d.x),m=lt.fromLngLat(a);m.y=Se(m.y,-1+Xo,1-Xo);const _=m.toLngLat(),g=s.project(_.lng,_.lat),y=lt.fromLngLat(_);y.x+=Xo;const v=y.toLngLat(),b=s.project(v.lng,v.lat),x=s0(b.x-g.x,b.y-g.y,f),w=lt.fromLngLat(_);w.y+=Xo;const T=w.toLngLat(),E=s.project(T.lng,T.lat),M=s0(E.x-g.x,E.y-g.y,f),S=Math.abs(x.x)/Math.abs(M.y),I=V.identity([]);V.rotateZ(I,I,-f*(1-(c?0:l)));const C=V.identity([]);return V.scale(C,C,[1,1-(1-S)*l,1]),C[4]=-M.x/M.y*l,V.rotateZ(C,C,f),V.multiply(C,I,C),C}(t.projection,0,t.center,r,e),o=i0(t);return V.scale(i,i,[o,o,1]),i}function i0(t){const e=t.projection,r=Aa(t.projection,t.zoom,t.width,t.height),i=o0(e,t.center),o=o0(e,Ne.convert(e.center));return Math.pow(2,i*r+(1-r)*o)}function Aa(t,e,r,i,o=1/0){const s=t.range;if(!s)return 0;const n=Math.min(o,Math.max(r,i)),a=Math.log(n/1024)/Math.LN2;return Fi(s[0]+a,s[1]+a,e)}const Xo=1/4e4;function o0(t,e){const r=Se(e.lat,-Jt,Jt),i=new Ne(e.lng-180*Xo,r),o=new Ne(e.lng+180*Xo,r),s=t.project(i.lng,r),n=t.project(o.lng,r),a=lt.fromLngLat(i),l=lt.fromLngLat(o),c=n.x-s.x,u=n.y-s.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log(p)/Math.LN2}function s0(t,e,r){const i=Math.cos(r),o=Math.sin(r);return{x:t*i-e*o,y:t*o+e*i}}function Es(t,e,r){return e*(W/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}const Tn={unknown:0,flipRequired:1,flipNotRequired:2},JT=Math.tan(85*Math.PI/180);function Ac(t,e,r,i,o,s,n){const a=V.create();if(r)if(s.name==="globe"){const l=function(c,u){const{x:h,y:d}=c.point,p=Eg(h,d,c.worldSize/c._pixelsPerMercatorPixel,0,0);return V.multiply(p,p,_d(si(u)))}(o,e);V.multiply(a,a,l)}else{const l=an.invert([],n);a[0]=l[0],a[1]=l[1],a[4]=l[2],a[5]=l[3],i||V.rotateZ(a,a,o.angle)}else V.multiply(a,o.labelPlaneMatrix,t);return a}function n0(t,e,r,i,o,s,n){const a=Ac(t,e,r,i,o,s,n);return s.name==="globe"&&r||(a[2]=a[6]=a[10]=a[14]=0),a}function a0(t,e,r,i,o,s,n){if(r){if(s.name==="globe"){const a=Ac(t,e,r,i,o,s,n);return V.invert(a,a),V.multiply(a,t,a),a}{const a=V.clone(t),l=V.identity([]);return l[0]=n[0],l[1]=n[1],l[4]=n[2],l[5]=n[3],V.multiply(a,a,l),i||V.rotateZ(a,a,-o.angle),a}}return o.glCoordMatrix}function Pi(t,e,r,i){const o=[t,e,r,1];r?Mt.transformMat4(o,o,i):f0(o,o,i);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function l0(t,e){return Math.min(.5+t/e*.5,1.5)}function KT(t,e){const r=t[0]/t[3],i=t[1]/t[3];return r>=-e[0]&&r<=e[0]&&i>=-e[1]&&i<=e[1]}function QT(t,e,r,i,o,s,n,a,l,c){const u=r.transform,h=i?t.textSizeData:t.iconSizeData,d=Hi(h,r.transform.zoom),p=u.projection.name==="globe",f=[256/r.width*2+1,256/r.height*2+1],m=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let _=null;p&&(_=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const g=t.lineVertexArray,y=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b,x=!1;for(let w=0;w<y.length;w++){const T=y.get(w),{numGlyphs:E,writingMode:M}=T;if(M!==Nt.vertical||x||b===Nt.horizontal||(x=!0),b=M,(T.hidden||M===Nt.vertical)&&!x){En(E,m);continue}x=!1;const S=new N(T.tileAnchorX,T.tileAnchorY);let{x:I,y:C,z:k}=u.projection.projectTilePoint(S.x,S.y,c.canonical);if(l){const[X,Y,K]=l(S);I+=X,C+=Y,k+=K}const A=[I,C,k,1];if(Mt.transformMat4(A,A,e),!KT(A,f)){En(E,m);continue}const L=A[3],O=l0(r.transform.getCameraToCenterDistance(u.projection),L),U=ma(h,d,T),R=n?U/O:U*O,B=Pi(I,C,k,o);if(B[3]<=0){En(E,m);continue}let G={};const Z=n?null:l,q=h0(T,R,!1,a,e,o,s,t.glyphOffsetArray,g,m,_,B,S,G,v,Z,u.projection,c,n);x=q.useVertical,Z&&q.needsFlipping&&(G={}),(q.notEnoughRoom||x||q.needsFlipping&&h0(T,R,!0,a,e,o,s,t.glyphOffsetArray,g,m,_,B,S,G,v,Z,u.projection,c,n).notEnoughRoom)&&En(E,m)}i?(t.text.dynamicLayoutVertexBuffer.updateData(m),_&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(_)):(t.icon.dynamicLayoutVertexBuffer.updateData(m),_&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(_))}function c0(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){const{lineStartIndex:_,glyphStartIndex:g,segment:y}=a,v=g+a.numGlyphs,b=_+a.lineLength,x=e.getoffsetX(g),w=e.getoffsetX(v-1),T=Ic(t*x,r,i,o,s,n,y,_,b,l,c,u,h,d,!0,p,f,m);if(!T)return null;const E=Ic(t*w,r,i,o,s,n,y,_,b,l,c,u,h,d,!0,p,f,m);return E?{first:T,last:E}:null}function u0(t,e,r,i){return t===Nt.horizontal&&Math.abs(i)>Math.abs(r)?{useVertical:!0}:t===Nt.vertical?i>0?{needsFlipping:!0}:null:e!==Tn.unknown&&function(o,s){return o===0||Math.abs(s/o)>JT}(r,i)?e===Tn.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function h0(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y){const v=e/24,b=t.lineOffsetX*v,x=t.lineOffsetY*v,{lineStartIndex:w,glyphStartIndex:T,numGlyphs:E,segment:M,writingMode:S,flipState:I}=t,C=w+t.lineLength,k=A=>{if(u){const[R,B,G]=A.up,Z=c.length;vc(u,Z+0,R,B,G),vc(u,Z+1,R,B,G),vc(u,Z+2,R,B,G),vc(u,Z+3,R,B,G)}const[L,O,U]=A.point;wn(c,L,O,U,A.angle)};if(E>1){const A=c0(v,a,b,x,r,h,d,t,l,s,p,m,!1,_,g,y);if(!A)return{notEnoughRoom:!0};if(i&&!r){let[L,O,U]=A.first.point,[R,B,G]=A.last.point;[L,O]=Pi(L,O,U,n),[R,B]=Pi(R,B,G,n);const Z=u0(S,I,(R-L)*f,B-O);if(t.flipState=Z&&Z.needsFlipping?Tn.flipRequired:Tn.flipNotRequired,Z)return Z}k(A.first);for(let L=T+1;L<T+E-1;L++){const O=Ic(v*a.getoffsetX(L),b,x,r,h,d,M,w,C,l,s,p,m,!1,!1,_,g,y);if(!O)return c.length-=4*(L-T),{notEnoughRoom:!0};k(O)}k(A.last)}else{if(i&&!r){const L=Pi(d.x,d.y,0,o),O=w+M+1,U=new N(l.getx(O),l.gety(O)),R=Pi(U.x,U.y,0,o),B=R[3]>0?R:p0(d,U,L,1,o,void 0,_,g.canonical),G=u0(S,I,(B[0]-L[0])*f,B[1]-L[1]);if(t.flipState=G&&G.needsFlipping?Tn.flipRequired:Tn.flipNotRequired,G)return G}const A=Ic(v*a.getoffsetX(T),b,x,r,h,d,M,w,C,l,s,p,m,!1,!1,_,g,y);if(!A)return{notEnoughRoom:!0};k(A)}return{}}function d0(t,e,r,i,o){const{x:s,y:n,z:a}=i.projectTilePoint(t.x,t.y,e);if(!o)return Pi(s,n,a,r);const[l,c,u]=o(t);return Pi(s+l,n+c,a+u,r)}function p0(t,e,r,i,o,s,n,a){const l=d0(t.sub(e)._unit()._add(t),a,o,n,s);return D.sub(l,r,l),D.normalize(l,l),D.scaleAndAdd(l,r,l,i)}function Ic(t,e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g){const y=i?t-e:t+e;let v=y>0?1:-1,b=0;i&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let x=a+n+(v>0?0:1)|0,w=o,T=o,E=0,M=0;const S=Math.abs(y),I=[],C=[];let k=s,A=k;const L=()=>p0(A,k,T,S-E+1,u,d,m,_.canonical);for(;E+M<=S;){if(x+=v,x<a||x>=l)return null;if(T=w,A=k,I.push(T),p&&C.push(A),k=new N(c.getx(x),c.gety(x)),w=h[x],!w){const Y=d0(k,_.canonical,u,m,d);w=Y[3]>0?h[x]=Y:L()}E+=M,M=D.distance(T,w)}f&&d&&(h[x]&&(w=L(),M=D.distance(T,w)),h[x]=w);const O=(S-E)/M,U=k.sub(A)._mult(O)._add(A),R=D.sub([],w,T),B=D.scaleAndAdd([],T,R,O);let G=[0,0,1],Z=R[0],q=R[1];if(g&&(G=m.upVector(_.canonical,U.x,U.y),G[0]!==0||G[1]!==0||G[2]!==1)){const Y=[G[2],0,-G[0]],K=D.cross([],G,Y);D.normalize(Y,Y),D.normalize(K,K),Z=D.dot(R,Y),q=D.dot(R,K)}if(r){const Y=D.cross([],G,R);D.normalize(Y,Y),D.scaleAndAdd(B,B,Y,r*v)}const X=b+Math.atan2(q,Z);return I.push(B),p&&C.push(U),{point:B,angle:X,path:I,tilePath:C,up:G}}function En(t,e){const r=e.length,i=r+4*t;e.resize(i),e.float32.fill(-1/0,4*r,4*i)}function f0(t,e,r){const i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t[3]=r[3]*i+r[7]*o+r[15],t}const m0=(t,e,r)=>(1-r)*t+r*e,_0=t=>t*t*t*t*t;class op{constructor(e,r,i,o,s,n,a){this.tileSize=512,this._renderWorldCopies=s===void 0||s,this._minZoom=e||0,this._maxZoom=r||22,this._minPitch=i??0,this._maxPitch=o??60,this.setProjection(n),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new Ne(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 rp,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Sc,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new op(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(e,r=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(r),this._calcMatrices()}getProjection(){return jr(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=mc(this.projectionOptions);const i=!dt(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=mc({name:"mercator"});const r=e!==this.projection.name;return r&&this._calcMatrices(),r}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return It(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new N(this.width,this.height)}get bearing(){return Ni(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const r=-e*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=an.create(),an.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const r=Se(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,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 e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=$e(e),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const r=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==r&&(this._unmodified=!1,this._setZoom(r),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,r=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!r||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;r||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let o=0,s=0;for(let n=0;n<r.length;n++){const a=new N(r[n][0]*this.width,i+r[n][1]*(this.height-i)),l=e.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);o+=l[3]*c,s+=c}return s===0?NaN:o/s}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const e=this._seaLevelZoom,r=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*r,o=this._mercatorZfromZoom(e),s=this._mercatorZfromZoom(this._maxZoom),n=Math.max(o-i,s);this._setZoom(this._zoomFromMercatorZ(n))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(e){const r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[r.x,r.y,r.z]:[e.x,e.y,e.z];const o=D.length(D.sub([],this._camera.position,i));return Se(this._zoomFromMercatorZ(o),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height||!e.position&&!e.orientation)return;this._updateCameraState();let r=!1;if(e.orientation&&!Ar.exactEquals(e.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];D.exactEquals(i,this._camera.position)||(this._setCameraPosition(i),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,r=new t0;return r.position=new lt(e[0],e[1],e[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(e){if(!Ar.length(e))return!1;Ar.normalize(e,e);const r=D.transformQuat([],[0,0,-1],e),i=D.transformQuat([],[0,-1,0],e);if(i[2]<0)return!1;const o=e0(r,i);return!!o&&(this._camera.orientation=o,!0)}_setCameraPosition(e){const r=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,o=this.cameraToCenterDistance;e[2]=Se(e[2],o/i,o/r),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,r,i){this._unmodified=!1,this._edgeInsets.interpolate(e,r,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const r=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,r)}getVisibleUnwrappedCoordinates(e){const r=[new ud(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new N(0,0)),o=this.pointCoordinate(new N(this.width,0)),s=this.pointCoordinate(new N(this.width,this.height)),n=this.pointCoordinate(new N(0,this.height)),a=Math.floor(Math.min(i.x,o.x,s.x,n.x)),l=Math.floor(Math.max(i.x,o.x,s.x,n.x)),c=1;for(let u=a-c;u<=l+c;u++)u!==0&&r.push(new ud(u,e))}return r}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(e,r,i){let o=[];if(r[0]===0&&r[1]===0)return o;for(const n of e){const a=n.canonical,l=n.overscaledZ,c=n.wrap,u=1<<a.z,h=a.x+1<u,d=a.x>0,p=a.y+1<u,f=a.y>0,m=n.wrap-(d?0:1),_=n.wrap+(h?0:1),g=d?a.x-1:u-1,y=h?a.x+1:0;r[0]<0?(o.push(new mt(l,_,a.z,y,a.y)),r[1]<0&&p&&(o.push(new mt(l,c,a.z,a.x,a.y+1)),o.push(new mt(l,_,a.z,y,a.y+1))),r[1]>0&&f&&(o.push(new mt(l,c,a.z,a.x,a.y-1)),o.push(new mt(l,_,a.z,y,a.y-1)))):r[0]>0?(o.push(new mt(l,m,a.z,g,a.y)),r[1]<0&&p&&(o.push(new mt(l,c,a.z,a.x,a.y+1)),o.push(new mt(l,m,a.z,g,a.y+1))),r[1]>0&&f&&(o.push(new mt(l,c,a.z,a.x,a.y-1)),o.push(new mt(l,m,a.z,g,a.y-1)))):r[1]<0&&p?o.push(new mt(l,c,a.z,a.x,a.y+1)):f&&o.push(new mt(l,c,a.z,a.x,a.y-1))}if(o.length>1){o.sort((l,c)=>l.overscaledZ-c.overscaledZ||l.wrap-c.wrap||l.canonical.z-c.canonical.z||l.canonical.x-c.canonical.x||l.canonical.y-c.canonical.y);let n=0,a=0;for(;a<o.length;)o[a].equals(o[n])?++a:o[++n]=o[a++];o.length=n+1}const s=[];for(const n of o)o.some(a=>n.isChildOf(a))||s.push(n);return o=s.filter(n=>!e.some(a=>!!(n.overscaledZ<i&&a.isChildOf(n))||n.equals(a)||n.isChildOf(a))),o}coveringTiles(e){let r=this.coveringZoomLevel(e);const i=r,o=this.elevation&&this.elevation.exaggeration(),s=o&&!e.isTerrainDEM,n=this.projection.name==="mercator";if(e.minzoom!==void 0&&r<e.minzoom)return[];e.maxzoom!==void 0&&r>e.maxzoom&&(r=e.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<r,u=[c*a.x,c*a.y,0],h=this.projection.name==="globe",d=!h,p=_o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,d),f=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*It(1,this.center.lat),_=this._camera.position[2]/It(1,this.center.lat),g=[c*f.x,c*f.y,_*(d?1:m)],y=h||o,v=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),b=this.isLODDisabled(!0)?r:0;let x;if(this._elevation&&e.isTerrainDEM)x=1e4*this._elevation.exaggeration();else if(this._elevation){const R=this._elevation.getMinMaxForVisibleTiles();x=R?R.max:this._centerAltitude}else x=this._centerAltitude;const w=e.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?i0(this):1,E=R=>{const B=new lt(R.x+25e-6,R.y,R.z),G=new lt(R.x,R.y+25e-6,R.z),Z=R.toLngLat(),q=B.toLngLat(),X=G.toLngLat(),Y=this.locationCoordinate(Z),K=this.locationCoordinate(q),H=this.locationCoordinate(X),ee=Math.hypot(K.x-Y.x,K.y-Y.y),de=Math.hypot(H.x-Y.x,H.y-Y.y);return Math.sqrt(ee*de)*T/25e-6},M=R=>{const B=x,G=w;return{aabb:Vy(this,c,0,0,0,R,G,B,this.projection),zoom:0,x:0,y:0,minZ:G,maxZ:B,wrap:R,fullyVisible:!1}},S=[];let I=[];const C=r,k=e.reparseOverscaled?i:r,A=R=>R*R,L=A((_-this._centerAltitude)*m),O=R=>{if(!this._elevation||!R.tileID||!n)return;const B=this._elevation.getMinMaxForTile(R.tileID),G=R.aabb;B?(G.min[2]=B.min,G.max[2]=B.max,G.center[2]=(G.min[2]+G.max[2])/2):(R.shouldSplit=U(R),R.shouldSplit||(G.min[2]=G.max[2]=G.center[2]=this._centerAltitude))},U=R=>{if(R.zoom<b)return!0;if(R.zoom===C)return!1;if(R.shouldSplit!=null)return R.shouldSplit;const B=R.aabb.distanceX(g),G=R.aabb.distanceY(g);let Z=L,q=1;if(h){Z=A(R.aabb.distanceZ(g));const K=Math.pow(2,R.zoom),H=ar((R.y+1)/K),ee=ar(R.y/K),de=Math.min(Math.max(l,H),ee),pe=Gl(de)/Gl(l);if(q=de===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,pe/this._mercatorScaleRatio),this.zoom<=ca&&R.zoom===C-1&&pe>=.9)return!0}else if(s&&(Z=A(R.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&i<=5){const K=Math.pow(2,R.zoom),H=E(new lt((R.x+.5)/K,(R.y+.5)/K));q=H>.85?1:H}const X=B*B+G*G+Z,Y=A((1<<C-R.zoom)*v*q*((K,H)=>{if(H*A(.707)<K)return 1;const ee=Math.sqrt(H/K);return ee/(1.4144271570014144+(Math.pow(1.1,ee-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Z,L),X));return X<Y};if(this.renderWorldCopies)for(let R=1;R<=3;R++)S.push(M(-R)),S.push(M(R));for(S.push(M(0));S.length>0;){const R=S.pop(),B=R.x,G=R.y;let Z=R.fullyVisible;const q=()=>this.projection.name==="globe"&&(R.y===0||R.y===(1<<R.zoom)-1);if(!Z){let X=y?R.aabb.intersects(p):R.aabb.intersectsFlat(p);if(X===0&&q()){const Y=new _i(R.zoom,B,G);X=fd(this,c,Y,!0).intersects(p)}if(X===0)continue;Z=X===2}if(R.zoom!==C&&U(R))for(let X=0;X<4;X++){const Y=(B<<1)+X%2,K=(G<<1)+(X>>1),H={aabb:n?R.aabb.quadrant(X):Vy(this,c,R.zoom+1,Y,K,R.wrap,R.minZ,R.maxZ,this.projection),zoom:R.zoom+1,x:Y,y:K,wrap:R.wrap,fullyVisible:Z,tileID:void 0,shouldSplit:void 0,minZ:R.minZ,maxZ:R.maxZ};s&&!h&&(H.tileID=new mt(R.zoom+1===C?k:R.zoom+1,R.wrap,R.zoom+1,Y,K),O(H)),S.push(H)}else{const X=R.zoom===C?k:R.zoom;if(e.minzoom&&e.minzoom>X)continue;if(!Z){let ee=y?R.aabb.intersectsPrecise(p):R.aabb.intersectsPreciseFlat(p);if(ee===0&&q()){const de=new _i(R.zoom,B,G);ee=fd(this,c,de,!0).intersectsPrecise(p)}if(ee===0)continue}const Y=u[0]-(.5+B+(R.wrap<<R.zoom))*(1<<r-R.zoom),K=u[1]-.5-G,H=R.tileID?R.tileID:new mt(X,R.wrap,R.zoom,B,G);I.push({tileID:H,distanceSq:Y*Y+K*K})}}if(this.fogCullDistSq){const R=this.fogCullDistSq,B=this.horizonLineFromTop();I=I.filter(G=>{const Z=[0,0,0,1],q=[W,W,0,1],X=this.calculateFogTileMatrix(G.tileID.toUnwrapped());Mt.transformMat4(Z,Z,X),Mt.transformMat4(q,q,X);const Y=function(ee,de,pe){let ge=0;for(let xe=0;xe<2;++xe)ee[xe]>0&&(ge+=(ee[xe]-0)*(ee[xe]-0)),de[xe]<0&&(ge+=(0-de[xe])*(0-de[xe]));return ge}(Mt.min([],Z,q),Mt.max([],Z,q));if(Y===0)return!0;let K=!1;const H=this._elevation;if(H&&Y>R&&B!==0){const ee=this.calculateProjMatrix(G.tileID.toUnwrapped());let de;e.isTerrainDEM||(de=H.getMinMaxForTile(G.tileID)),de||(de={min:w,max:x});const pe=function(xe){const Oe=Math.round((xe+45+360)%360/90)%4;return cu[Oe]}(this.rotation),ge=[pe[0]*W,pe[1]*W,de.max];D.transformMat4(ge,ge,ee),K=(1-ge[1])*this.height*.5<B}return Y<R||K})}return I.sort((R,B)=>R.distanceSq-B.distanceSq).map(R=>R.tileID)}resize(e,r){this.width=e,this.height=r,this.pixelsToGLUnits=[2/e,-2/r],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const r=Se(e.lat,-Jt,Jt),i=this.projection.project(e.lng,r);return new N(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/It(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,r){let i,o;const s=this.centerPoint;if(this.projection.name==="globe"){const a=this.worldSize;i=(r.x-s.x)/a,o=(r.y-s.y)/a}else{const a=this.pointCoordinate(r),l=this.pointCoordinate(s);i=a.x-l.x,o=a.y-l.y}const n=this.locationCoordinate(e);this.setLocation(new lt(n.x-i,n.y-o))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,r){const i=r?It(r,e.lat):void 0,o=this.projection.project(e.lng,e.lat);return new lt(o.x,o.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,r){const i=r??this._centerAltitude,o=[e.x,e.y,0,1],s=[e.x,e.y,1,1];Mt.transformMat4(o,o,this.pixelMatrixInverse),Mt.transformMat4(s,s,this.pixelMatrixInverse);const n=s[3];Mt.scale(o,o,1/o[3]),Mt.scale(s,s,1/n);const a=o[2],l=s[2];return{p0:o,p1:s,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(e){const r=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return Mt.transformMat4(r,r,this.pixelMatrixInverse),Mt.transformMat4(i,i,this.pixelMatrixInverse),Mt.scale(r,r,1/r[3]),Mt.scale(i,i,1/i[3]),r[2]=It(r[2],this._center.lat)*this.worldSize,i[2]=It(i[2],this._center.lat)*this.worldSize,Mt.scale(r,r,1/this.worldSize),Mt.scale(i,i,1/this.worldSize),new Fl([r[0],r[1],r[2]],D.normalize([],D.sub([],i,r)))}rayIntersectionCoordinate(e){const{p0:r,p1:i,t:o}=e,s=It(r[2],this._center.lat),n=It(i[2],this._center.lat);return new lt(Fe(r[0],i[0],o)/this.worldSize,Fe(r[1],i[1],o)/this.worldSize,Fe(s,n,o))}pointCoordinate(e,r=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,r)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let r=this.projection.pointCoordinate3D(this,e.x,e.y);if(r)return new lt(r[0],r[1],r[2]);let i=0,o=this.horizonLineFromTop();if(e.y>o)return this.pointCoordinate(e);const s=.02*o,n=e.clone();for(let a=0;a<10&&o-i>s;a++){n.y=Fe(i,o,.66);const l=this.projection.pointCoordinate3D(this,n.x,n.y);l?(o=n.y,r=l):i=n.y}return r?new lt(r[0],r[1],r[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=Bo)return!this.isPointAboveHorizon(e);const r=this.pointCoordinate(e);return r.y>=0&&r.y<=1}_coordinatePoint(e,r){const i=r&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,o=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return Mt.transformMat4(o,o,this.pixelMatrix),o[3]>0?new N(o[0]/o[3],o[1]/o[3]):new N(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=this.pointLocation3D(new N(r,e)),n=this.pointLocation3D(new N(o,e)),a=this.pointLocation3D(new N(o,i)),l=this.pointLocation3D(new N(r,i));let c=Math.min(s.lng,n.lng,a.lng,l.lng),u=Math.max(s.lng,n.lng,a.lng,l.lng),h=Math.min(s.lat,n.lat,a.lat,l.lat),d=Math.max(s.lat,n.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f=this.projection.name==="globe"?1:4,m=(_,g,y,v,b)=>{const x=(_+y)/2,w=(g+v)/2,T=new N(x,w),{lng:E,lat:M}=this.pointLocation3D(T),S=Math.max(0,c-E,h-M,E-u,M-d);c=Math.min(c,E),u=Math.max(u,E),h=Math.min(h,M),d=Math.max(d,M),(b<f||S>p)&&(m(_,g,x,w,b+1),m(x,w,y,v,b+1))};if(m(r,e,o,e,1),m(o,e,o,i,1),m(o,i,r,i,1),m(r,i,r,e,1),this.projection.name==="globe"){const[_,g]=function(y){const v=V.identity(new Float64Array(16));V.multiply(v,y.pixelMatrix,y.globeMatrix);const b=[0,gi,0],x=[0,yi,0];return D.transformMat4(b,b,v),D.transformMat4(x,x,v),[b[0]>0&&b[0]<=y.width&&b[1]>0&&b[1]<=y.height&&!jl(y,new Ne(y.center.lat,90)),x[0]>0&&x[0]<=y.width&&x[1]>0&&x[1]<=y.height&&!jl(y,new Ne(y.center.lat,-90))]}(this);_?(d=90,u=180,c=-180):g&&(h=-90,u=180,c=-180)}return new Yr(new Ne(c,h),new Ne(u,d))}_getBoundsRectangular(e,r){const{top:i,left:o}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,a=new N(o,i),l=new N(n,i),c=new N(n,s),u=new N(o,s);let h=this.pointCoordinate(a,e),d=this.pointCoordinate(l,e);const p=this.pointCoordinate(c,r),f=this.pointCoordinate(u,r),m=(_,g)=>(g.y-_.y)/(g.x-_.x);return h.y>1&&d.y>=0?h=new lt((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new lt(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new lt((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new lt(-p.y/m(p,d)+p.x,0)),new Yr().extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const r=e.visibleDemTiles.reduce((i,o)=>{if(o.dem){const s=o.dem.tree;i.min=Math.min(i.min,s.minimums[0]),i.max=Math.max(i.max,s.maximums[0])}return i},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(r.min*e.exaggeration(),r.max*e.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const r=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-r*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-Jt,this.maxLat=Jt,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=ur(this.minLng)*this.tileSize,this.worldMaxX=ur(this.maxLng)*this.tileSize,this.worldMinY=dr(this.maxLat)*this.tileSize,this.worldMaxY=dr(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,r){return this.projection.createTileMatrix(this,r,e)}calculateDistanceTileData(e){const r=e.key,i=this._distanceTileDataCache;if(i[r])return i[r];const o=e.canonical,s=1/this.height,n=this.cameraWorldSize,a=n/this.zoomScale(o.z),l=(o.x+Math.pow(2,o.z)*e.wrap)*a,c=o.y*a,u=this.point;u.x*=n/this.worldSize,u.y*=n/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return i[r]={bearing:[d,p],center:[(u.x-l)*s,(u.y-c)*s],scale:a/W*s},i[r]}calculateFogTileMatrix(e){const r=e.key,i=this._fogTileMatrixCache;if(i[r])return i[r];const o=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return V.multiply(o,this.worldToFogMatrix,o),i[r]=new Float32Array(o),i[r]}calculateProjMatrix(e,r=!1,i=!1){const o=e.key;let s;if(s=i?this._expandedProjMatrixCache:r?this._alignedProjMatrixCache:this._projMatrixCache,s[o])return s[o];const n=this.calculatePosMatrix(e,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:r?this.alignedProjMatrix:this.projMatrix,V.multiply(n,a,n),s[o]=new Float32Array(n),s[o]}calculatePixelsToTileUnitsMatrix(e){const r=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];const o=function(s,n){const{scale:a}=s.tileTransform,l=a*W/(s.tileSize*Math.pow(2,n.zoom-s.tileID.overscaledZ+s.tileID.canonical.z));return an.scale(new Float32Array(4),n.inverseAdjustmentMatrix,[l,l])}(e,this);return i[r]=o,i[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const e=1/this.worldSize,r=V.fromScaling([],[e,e,e]);return V.multiply(r,r,this.globeMatrix),r}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const e=this._elevation;this._updateCameraState();const r=It(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),o=this._camera.forward(),s=It(1,this._center.lat);i[2]/=s,o[2]/=s,D.normalize(o,o);const n=e.raycast(i,o,e.exaggeration());if(n){const a=D.scaleAndAdd([],i,o,n),l=new lt(a[0],a[1],It(a[2],ar(a[1]))),c=(l.z+D.length([l.x-i[0],l.y-i[1],l.z-i[2]*s]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(c),this._centerAltitude=l.toAltitude(),this._center=this.coordinateLocation(l),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(e=!1){if(!this._elevation)return;const r=this._elevation,i=It(1,this._center.lat)*this.worldSize,o=this._computeCameraPosition(i),s=r.getAtPointOrZero(new lt(...o)),n=this.pixelsPerMeter/this.worldSize*s,a=this._minimumHeightOverTerrain(),l=o[2]-n;if(l<=a)if(l<0||e){const c=this.locationCoordinate(this._center,this._centerAltitude),u=[o[0],o[1],c.z-o[2]],h=D.length(u);u[2]-=(a-l)/this._pixelsPerMercatorPixel;const d=D.length(u);if(d===0)return;D.scale(u,u,h/d*this._pixelsPerMercatorPixel),this._camera.position=[o[0],o[1],c.z*this._pixelsPerMercatorPixel-u[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const d=this.center;return d.lat=Se(d.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(d.lng=Se(d.lng,this.minLng,this.maxLng)),this.center=d,void(this._constraining=!1)}const r=this._unmodified,{x:i,y:o}=this.point;let s=0,n=i,a=o;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(o-c<u&&(a=u+c),o+c>h&&(a=h-c),h-u<this.height&&(s=Math.max(s,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const d=this.worldMinX*this.scale,p=this.worldMaxX*this.scale,f=this.worldSize/2-(d+p)/2;n=(i+f+this.worldSize)%this.worldSize-f,n-l<d&&(n=d+l),n+l>p&&(n=p-l),p-d<this.width&&(s=Math.max(s,this.width/(p-d)),n=(p+d)/2)}n===i&&a===o||(this.center=this.unproject(new N(n,a))),s&&(this.zoom+=this.scaleZoom(s)),this._constrainCamera(),this._unmodified=r,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,r=this.projection.name==="globe",i=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=It(1,this.center.lat)/It(1,45));const o=Aa(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,o),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 s=this.projection.zAxisUnit==="meters"?i:1,n=this._camera.getWorldToCamera(this.worldSize,s);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-e.x/this.width,l[9]=2*e.y/this.height,this.isOrthographic){let M=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),S=M*this.aspect,I=-S,C=-M;S-=e.x,I-=e.x,M+=e.y,C+=e.y,a=this._camera.getCameraToClipOrthographic(I,S,C,M,this._nearZ,this._farZ),((k,A,L,O)=>{for(let U=0;U<16;U++)k[U]=m0(A[U],L[U],O)})(a,a,l,_0(this.pitch>=15?1:this.pitch/15))}else a=l;const c=V.mul([],l,n);let u=V.mul([],a,n);if(this.projection.isReprojectedInTileSpace){const M=this.locationCoordinate(this.center),S=V.identity([]);V.translate(S,S,[M.x*this.worldSize,M.y*this.worldSize,0]),V.multiply(S,S,r0(this)),V.translate(S,S,[-M.x*this.worldSize,-M.y*this.worldSize,0]),V.multiply(u,u,S),V.multiply(c,c,S),this.inverseAdjustmentMatrix=function(I){const C=r0(I,!0);return an.invert([],[C[0],C[1],C[4],C[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=V.scale([],u,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=u,this.invProjMatrix=V.invert(new Float64Array(16),this.projMatrix),r){const M=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);M[8]=2*-e.x/this.width,M[9]=2*e.y/this.height,this.expandedFarZProjMatrix=V.mul([],M,n)}else this.expandedFarZProjMatrix=this.projMatrix;const h=V.invert([],a);this.frustumCorners=hd.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=_o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);const d=new Float32Array(16);V.identity(d),V.scale(d,d,[1,-1,1]),V.rotateX(d,d,this._pitch),V.rotateZ(d,d,this.angle);const p=V.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=V.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-e.x/this.width,p[9]=2*(e.y+f)/this.height,this.skyboxMatrix=V.multiply(d,p,d);const m=this.point,_=m.x,g=m.y,y=this.width%2/2,v=this.height%2/2,b=Math.cos(this.angle),x=Math.sin(this.angle),w=_-Math.round(_)+b*y+x*v,T=g-Math.round(g)+b*v+x*y,E=new Float64Array(u);if(V.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,u=V.create(),V.scale(u,u,[this.width/2,-this.height/2,1]),V.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=V.create(),V.scale(u,u,[1,-1,1]),V.translate(u,u,[-1,-1,0]),V.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=V.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=V.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=function(S){const{x:I,y:C}=S.point,{lng:k,lat:A}=S._center;return Eg(I,C,S.worldSize,k,A)}(this);const M=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=D.transformMat4(M,M,n),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,o=1/this.height/this._pixelsPerMercatorPixel,s=[e,e,r];D.scale(s,s,o),D.scale(i,i,-1),D.multiply(i,i,s);const n=V.create();V.translate(n,n,i),V.scale(n,n,s),this.mercatorFogMatrix=n,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,r,o)}_computeCameraPosition(e){const r=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,s=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*r-e/this.worldSize*this._centerAltitude;return[o.x/this.worldSize-i[0]*s,o.y/this.worldSize-i[1]*s,e/this.worldSize*this._centerAltitude-i[2]*s]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],o=e[2];let s=1;this.projection.wrap&&(this.center=this.center.wrap()),o>0&&(s=Math.min((r-i)/o,1)),this._camera.position=D.scaleAndAdd([],this._camera.position,e,s),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,r=this._camera.forward(),{pitch:i,bearing:o}=this._camera.getPitchBearing(),s=It(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,n=this._mercatorZfromZoom(this._maxZoom)*Math.cos($e(this._maxPitch)),a=Math.max((e[2]-s)/Math.cos(i),n),l=this._zoomFromMercatorZ(a);D.scaleAndAdd(e,e,r,a),this._pitch=Se(i,$e(this.minPitch),$e(this.maxPitch)),this.angle=Ni(o,-Math.PI,Math.PI),this._setZoom(Se(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new lt(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){let r=0,i=Bo,o=0,s=1/0;for(;i-r>1e-6&&i>r;){const n=r+.5*(i-r),a=this.tileSize*Math.pow(2,n),l=this.getCameraToCenterDistance(this.projection,n,a),c=this.scaleZoom(l/(e*this.tileSize)),u=Math.abs(n-c);u<s&&(s=u,o=n),n<c?r=n:i=n}return o}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(F("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,r){const i=Math.min(e.x,r.x),o=Math.max(e.x,r.x),s=Math.min(e.y,r.y),n=Math.max(e.y,r.y);if(s<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const a=[new N(i,s),new N(o,n),new N(i,n),new N(o,s)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const u of a){const h=this.pointRayIntersection(u);if(h.t<0)return!0;const d=this.rayIntersectionCoordinate(h);if(d.x<l||d.y<0||d.x>c||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+br(this.fovAboveCenter)>88||this.anyCornerOffEdge(new N(0,0),new N(this.width,this.height))}zoomDeltaToMovement(e,r){const i=D.length(D.sub([],this._camera.position,e)),o=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(o)}getCameraPoint(){if(this.projection.name==="globe"){const e=function([r,i,o],s){const n=[r,i,o,1];Mt.transformMat4(n,n,s);const a=n[3]=Math.max(n[3],1e-6);return n[0]/=a,n[1]/=a,n[2]/=a,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new N(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new N(0,e))}}getCameraToCenterDistance(e,r=this.zoom,i=this.worldSize){const o=Aa(e,r,this.width,this.height,1024),s=e.pixelSpaceConversion(this.center.lat,i,o);let n=.5/Math.tan(.5*this._fov)*this.height*s;return this.isOrthographic&&(n=m0(1,n,_0(this.pitch>=15?1:this.pitch/15))),n}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&V.multiply(e,e,this.globeMatrix),e}getFrustum(e){return _o.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,this.projection.zAxisUnit==="meters")}}function g0(t,e,r){V.identity(t),V.rotateZ(t,t,$e(e[2])),V.rotateX(t,t,$e(e[0])),V.rotateY(t,t,$e(e[1])),V.scale(t,t,r),V.multiply(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Cc(t,e,r,i,o,s,n,a){const l=[r[0]-e[0],r[1]-e[1],0],c=[i[0]-e[0],i[1]-e[1],0];if(D.length(l)<1e-12||D.length(c)<1e-12)return Ar.identity(t);const u=D.cross([],l,c);D.normalize(u,u),D.subtract(c,i,e),l[2]=(s-o)*a,c[2]=(n-o)*a;const h=l;return D.cross(h,l,c),D.normalize(h,h),Ar.rotationTo(t,u,h)}function y0(t,e,r=!1){const i=yr(e.zoom),o=function(s,n,a){const l=n.worldSize,c=[s[12],s[13],s[14]],u=ar(c[1]/l),h=Jr(c[0]/l),d=V.identity([]),p=It(1,u)*l,f=It(1,0)*l*No(u,n.zoom),m=1/gd(l);let _=f*m;if(a){const b=Aa(n.projection,n.zoom,n.width,n.height,1024);_=m*n.projection.pixelSpaceConversion(n.center.lat,l,b)}const g=Nr(u,h);D.add(g,g,D.scale([],D.normalize([],g),p*_*c[2]));const y=function(b){const x=[b[0],b[1],b[2]];let w=[0,1,0];const T=D.cross([],w,x);return D.cross(w,x,T),D.squaredLength(w)===0&&(w=[0,1,0],D.cross(T,x,w)),D.normalize(T,T),D.normalize(w,w),D.normalize(x,x),[T[0],T[1],T[2],0,w[0],w[1],w[2],0,x[0],x[1],x[2],0,b[0],b[1],b[2],1]}(g);V.scale(d,d,[_,_,_*p]),V.translate(d,d,[-c[0],-c[1],-c[2]]);const v=V.multiply([],n.globeMatrix,y);return V.multiply(v,v,d),V.multiply(v,v,s),v}(t,e,r);if(i>0){const s=function(n,a){const l=a.worldSize,c=It(1,0)*l*No(a.center.lat,a.zoom)/gd(l),u=It(1,a.center.lat)*l,h=V.identity([]);return V.rotateY(h,h,$e(a.center.lng)),V.rotateX(h,h,$e(a.center.lat)),V.translate(h,h,[0,0,Pr]),V.scale(h,h,[c,c,c*u]),V.translate(h,h,[a.point.x-.5*l,a.point.y-.5*l,0]),V.multiply(h,h,n),V.multiply(h,a.globeMatrix,h)}(t,e);return function(n,a,l){const c=(f,m,_)=>{const g=D.length(f),y=D.length(m),v=go(f,m,_);return D.scale(v,v,1/D.length(v)*Fe(g,y,_))},u=c([n[0],n[1],n[2]],[a[0],a[1],a[2]],l),h=c([n[4],n[5],n[6]],[a[4],a[5],a[6]],l),d=c([n[8],n[9],n[10]],[a[8],a[9],a[10]],l),p=go([n[12],n[13],n[14]],[a[12],a[13],a[14]],l);return[u[0],u[1],u[2],0,h[0],h[1],h[2],0,d[0],d[1],d[2],0,p[0],p[1],p[2],1]}(o,s,i)}return o}const Ms=64,e3=[1,1,1];class x0{constructor(e,r,i,o){this.id=e,this.position=r!=null?new Ne(r[0],r[1]):new Ne(0,0),this.orientation=i??[0,0,0],this.nodes=o,this.uploaded=!1,this.aabb=new Pt([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,r){if(V.multiply(e.matrix,r,e.matrix),e.meshes)for(const i of e.meshes){const o=Pt.applyTransform(i.aabb,e.matrix);this.aabb.encapsulate(o)}if(e.children)for(const i of e.children)this._applyTransformations(i,e.matrix)}computeBoundsAndApplyParent(){const e=V.identity([]);for(const r of this.nodes)this._applyTransformations(r,e)}_positionModelOnTerrain(e,r){const i=e.elevation;if(!i)return 0;const o=Pt.projectAabbCorners(this.aabb,this.matrix),s=It(1,this.position.lat)*e.worldSize,n=function(g,y){const v=[0,0,1],b=[{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 x of b){const w=g[x.corners[0]],T=g[x.corners[1]],E=g[x.corners[2]],M=[T[0]-w[0],T[1]-w[1],y*(T[2]-w[2])],S=D.cross(M,M,[E[0]-w[0],E[1]-w[1],y*(E[2]-w[2])]);D.normalize(S,S),x.dotProductWithUp=D.dot(S,v)}return b.sort((x,w)=>x.dotProductWithUp-w.dotProductWithUp),b[0].corners}(o,s),a=o[n[0]],l=o[n[1]],c=o[n[2]],u=o[n[3]],h=i.getAtPointOrZero(new lt(a[0]/e.worldSize,a[1]/e.worldSize),0),d=i.getAtPointOrZero(new lt(l[0]/e.worldSize,l[1]/e.worldSize),0),p=i.getAtPointOrZero(new lt(c[0]/e.worldSize,c[1]/e.worldSize),0),f=i.getAtPointOrZero(new lt(u[0]/e.worldSize,u[1]/e.worldSize),0),m=(h+f)/2,_=(d+p)/2;return m>_?d<p?Cc(r,l,u,a,d,f,h,s):Cc(r,c,a,u,p,h,f,s):h<f?Cc(r,a,l,c,h,d,p,s):Cc(r,u,c,l,f,p,d,s),Math.max(m,_)}computeModelMatrix(e,r,i,o,s,n,a=!1){const l=e.transform,c=l.zoom,u=l.project(this.position),h=No(this.position.lat,c),d=1/h;V.identity(this.matrix),V.translate(this.matrix,this.matrix,[u.x+o[0]*d,u.y+o[1]*d,o[2]]);let p=1,f=1;const m=l.worldSize;if(a){if(l.projection.name==="mercator"){let v=0;l.elevation&&(v=l.elevation.getAtPointOrZero(new lt(u.x/m,u.y/m),0));const b=Mt.transformMat4([],[u.x,u.y,v,1],l.projMatrix)[3]/l.cameraToCenterDistance;p=b,f=b*No(l.center.lat,c)}else if(l.projection.name==="globe"){const v=y0(this.matrix,l),b=V.multiply([],l.projMatrix,v),x=[0,0,0,1];Mt.transformMat4(x,x,b);const w=x[3]/l.cameraToCenterDistance,T=yr(c),E=l.projection.pixelsPerMeter(this.position.lat,m)*No(this.position.lat,c),M=l.projection.pixelsPerMeter(l.center.lat,m)*No(l.center.lat,c);p=w/Fe(E,Pg(l.center.lat),T),f=w*h/E,p*=M,f*=M}}else p=d;V.scale(this.matrix,this.matrix,[p,p,f]);const _=[...this.matrix],g=this.orientation,y=[];if(g0(y,[g[0]+r[0],g[1]+r[1],g[2]+r[2]],i),V.multiply(this.matrix,_,y),s&&l.elevation){let v=0;const b=[];if(n&&l.elevation){v=this._positionModelOnTerrain(l,b);const x=V.fromQuat([],b),w=V.multiply([],x,y);V.multiply(this.matrix,_,w)}else v=l.elevation.getAtPointOrZero(new lt(u.x/m,u.y/m),0);v!==0&&(this.matrix[14]+=v)}}upload(e){if(!this.uploaded){for(const r of this.nodes)sp(r,e);for(const r of this.nodes)zc(r);this.uploaded=!0}}destroy(){for(const e of this.nodes)Dc(e)}}function Ia(t,e,r=!1){t.uploaded||(t.gfxTexture=new Gt(e,t.image,r?e.gl.R8:e.gl.RGBA,{useMipmap:t.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function t3(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,qT.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,WT.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,HT.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(t.colorArray.bytesPerElement===12?ZT:$T).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,YT.members,!0)),t.segments=Et.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const i=t.material;i.pbrMetallicRoughness.baseColorTexture&&Ia(i.pbrMetallicRoughness.baseColorTexture,e),i.pbrMetallicRoughness.metallicRoughnessTexture&&Ia(i.pbrMetallicRoughness.metallicRoughnessTexture,e),i.normalTexture&&Ia(i.normalTexture,e),i.occlusionTexture&&Ia(i.occlusionTexture,e,r),i.emissionTexture&&Ia(i.emissionTexture,e)}function sp(t,e,r){if(t.meshes)for(const i of t.meshes)t3(i,e,r);if(t.children)for(const i of t.children)sp(i,e,r)}function zc(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)zc(e)}function Dc(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.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 r of t.children)Dc(r)}class v0{constructor(e,r){this.feature=e,this.instancedDataOffset=r,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class b0{constructor(){this.instancedDataArray=new Vh,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class w0{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.fqid),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.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,r,i,o){this.tileToMeter=ha(i);const s=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:n,id:a,index:l,sourceLayerIndex:c}of e){const u=Uo(n,s);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),u,i))continue;const h={id:a,sourceLayerIndex:c,index:l,geometry:s?u.geometry:$i(n,i,o),properties:n.properties,type:n.type,patterns:{}},d=this.addFeature(h,h.geometry,u);d&&r.featureIndex.insert(n,h.geometry,l,c,this.index,this.instancesPerModel[d].instancedDataArray.length)}this.lookup=null}update(e,r,i,o){for(const s in this.instancesPerModel){const n=this.instancesPerModel[s];for(const a in e)n.idToFeaturesIndex.hasOwnProperty(a)&&this.evaluate(n.features[n.idToFeaturesIndex[a]],e[a],n,!0)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const r in this.instancesPerModel){const i=this.instancesPerModel[r];for(const o of i.features){const s=this.layers[0],n=o.feature,a=this.canonical,l=s.paint.get("model-rotation").evaluate(n,{},a),c=s.paint.get("model-scale").evaluate(n,{},a),u=s.paint.get("model-translation").evaluate(n,{},a);D.exactEquals(o.rotation,l)&&D.exactEquals(o.scale,c)&&D.exactEquals(o.translation,u)||(this.evaluate(o,o.featureStates,i,!0),e=!0)}}return e}isEmpty(){for(const e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const r in this.instancesPerModel){const i=this.instancesPerModel[r];i.instancedDataArray.length<0||i.instancedDataArray.length===0||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,XT.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length!==0&&r.instancedDataBuffer&&r.instancedDataBuffer.destroy()}}addFeature(e,r,i){const o=this.layers[0],s=o.layout.get("model-id").evaluate(i,{},this.canonical);if(!s)return F(`modelId is not evaluated for layer ${o.id} and it is not going to get rendered.`),s;this.instancesPerModel[s]||(this.instancesPerModel[s]=new b0);const n=this.instancesPerModel[s],a=n.instancedDataArray,l=new v0(i,a.length);for(const c of r)for(const u of c){if(u.x<0||u.x>=W||u.y<0||u.y>=W)continue;const h=(this.lookupDim-1)/W,d=this.lookupDim*(u.y*h|0)+u.x*h|0;if(this.lookup){if(this.lookup[d]!==0)continue;this.lookup[d]=1}this.instanceCount++;const p=a.length;a.resize(p+1),n.instancesEvaluatedElevation.push(0),a.float32[16*p]=u.x,a.float32[16*p+1]=u.y}return l.instancedDataCount=n.instancedDataArray.length-l.instancedDataOffset,l.instancedDataCount>0&&(e.id&&(n.idToFeaturesIndex[e.id]=n.features.length),n.features.push(l),this.evaluate(l,{},n,!1)),s}evaluate(e,r,i,o){const s=this.layers[0],n=e.feature,a=this.canonical,l=e.rotation=s.paint.get("model-rotation").evaluate(n,r,a),c=e.scale=s.paint.get("model-scale").evaluate(n,r,a),u=e.translation=s.paint.get("model-translation").evaluate(n,r,a),h=s.paint.get("model-color").evaluate(n,r,a);h.a=s.paint.get("model-color-mix-intensity").evaluate(n,r,a);const d=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]),this.maxScale=Math.max(Math.max(this.maxScale,c[0]),Math.max(c[1],c[2])),g0(d,l,c);const p=Math.round(100*h.a)+h.b/1.05;for(let f=0;f<e.instancedDataCount;++f){const m=e.instancedDataOffset+f,_=16*m,g=i.instancedDataArray.float32;let y=0;o&&(y=g[_+6]-i.instancesEvaluatedElevation[m]);const v=0|g[_+1];g[_]=(0|g[_])+h.r/1.05,g[_+1]=v+h.g/1.05,g[_+2]=p,g[_+3]=1/(a.z>10?this.tileToMeter:ha(a,v)),g[_+4]=u[0],g[_+5]=u[1],g[_+6]=u[2]+y,g[_+7]=d[0],g[_+8]=d[1],g[_+9]=d[2],g[_+10]=d[4],g[_+11]=d[5],g[_+12]=d[6],g[_+13]=d[8],g[_+14]=d[9],g[_+15]=d[10],i.instancesEvaluatedElevation[m]=u[2]}}}Ee(w0,"ModelBucket",{omit:["layers"]}),Ee(b0,"PerModelAttributes"),Ee(v0,"ModelFeature");const r3=new Xt({visibility:new se(j.layout_model.visibility),"model-id":new ke(j.layout_model["model-id"])});var i3={paint:new Xt({"model-opacity":new se(j.paint_model["model-opacity"]),"model-rotation":new ke(j.paint_model["model-rotation"]),"model-scale":new ke(j.paint_model["model-scale"]),"model-translation":new ke(j.paint_model["model-translation"]),"model-color":new ke(j.paint_model["model-color"]),"model-color-mix-intensity":new ke(j.paint_model["model-color-mix-intensity"]),"model-type":new se(j.paint_model["model-type"]),"model-cast-shadows":new se(j.paint_model["model-cast-shadows"]),"model-receive-shadows":new se(j.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new se(j.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ke(j.paint_model["model-emissive-strength"]),"model-roughness":new ke(j.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ke(j.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new se(j.paint_model["model-cutoff-fade-range"])}),layout:r3};const np=new Float32Array(262144),Ss=new Uint8Array(262144);function T0(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,T0(r));return e}const E0=["","wall","door","roof","window","lamp","logo"];class M0{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:T0(e)}}}}class S0{constructor(e,r,i,o){this.nodes=e,this.id=r,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.dirty=!0,this.needsUpload=!1}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 r=this.getNodesInfo();for(const i of r){const o=i.node;this.uploaded?this.updatePbrBuffer(o):sp(o,e,!0)}for(const i of r)zc(i.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let r=!1;if(!e.meshes)return r;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),r=!0);return r}needsReEvaluation(e,r,i){const o=e.transform.projectionOptions,s=e.style.getBrightness(),n=this.brightness!==s;return!!(!this.uploaded||this.dirty||o.name!==this.projection.name||Ca(i.paint.get("model-color").value,n)||Ca(i.paint.get("model-color-mix-intensity").value,n)||Ca(i.paint.get("model-roughness").value,n)||Ca(i.paint.get("model-emissive-strength").value,n)||Ca(i.paint.get("model-height-based-emissive-strength-multiplier").value,n))&&(this.projection=o,this.brightness=s,!0)}evaluateScale(e,r){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),o=this.id.canonical;for(const s of i){const n=s.feature;s.evaluatedScale=r.paint.get("model-scale").evaluate(n,{},o)}}evaluate(e){const r=this.getNodesInfo();for(const i of r){if(!i.node.meshes)continue;const o=i.feature,s=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],a=i.evaluatedRMEA[2],l=this.id.canonical;if(i.hasTranslucentParts=!1,s){for(let c=0;c<E0.length;c++){const u=E0[c];u.length&&(o.properties.part=u);const h=e.paint.get("model-color").evaluate(o,{},l),d=e.paint.get("model-color-mix-intensity").evaluate(o,{},l);i.evaluatedColor[c]=[h.r,h.g,h.b,d],i.evaluatedRMEA[c][0]=e.paint.get("model-roughness").evaluate(o,{},l),i.evaluatedRMEA[c][2]=e.paint.get("model-emissive-strength").evaluate(o,{},l),i.evaluatedRMEA[c][3]=h.a,i.emissionHeightBasedParams[c]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(o,{},l),!i.hasTranslucentParts&&h.a<1&&(i.hasTranslucentParts=!0)}delete o.properties.part,s3(i,n!==i.evaluatedColor[2]||a!==i.evaluatedRMEA[2])}i.evaluatedScale=e.paint.get("model-scale").evaluate(o,{},l),this.updatePbrBuffer(i.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,r,i,o){const s=e.findDEMTileFor(i);if(s&&(s.tileID.canonical!==this.terrainTile||r!==this.terrainExaggeration)){if(s.dem&&s.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=s.tileID.overscaledZ;const n=_n.create(e,i,s);if(!n)return;4&this.modelTraits&&this.updateDEM(e,n,i,o);for(const a of this.getNodesInfo()){const l=a.node;if(!l.footprint||!l.footprint.vertices||!l.footprint.vertices.length)continue;const c=l.footprint.vertices;let u=n.getElevationAt(c[0].x,c[0].y,!0,!0);for(let h=1;h<c.length;h++)u=Math.min(u,n.getElevationAt(c[h].x,c[h].y,!0,!0));l.elevation=u}}this.terrainTile=s.tileID.canonical,this.terrainExaggeration=r}}updateDEM(e,r,i,o){let s=r._dem._modifiedForSources[o];if(s===void 0&&(r._dem._modifiedForSources[o]=[],s=r._dem._modifiedForSources[o]),s.includes(i.canonical))return;const n=r._dem.dim;s.push(i.canonical);let a=!1;for(const l of this.getNodesInfo()){const c=l.node;if(!c.footprint||!c.footprint.grid)continue;const u=c.footprint.grid,h=r.tileCoordToPixel(u.min.x,u.min.y),d=r.tileCoordToPixel(u.max.x,u.max.y),p=Math.min(Math.min(n-d.y,h.x),Math.min(h.y,n-d.x));if(p<0)continue;const f=Se(p,2,5);let m=Math.max(0,h.x-f),_=Math.max(0,h.y-f),g=Math.min(d.x+f,n-1),y=Math.min(d.y+f,n-1);for(let w=_;w<=y;++w)for(let T=m;T<=g;++T)Ss[w*n+T]=255;let v=0,b=0;for(let w=0;w<u.cellsY;++w)for(let T=0;T<u.cellsX;++T){if(!u.cells[w*u.cellsX+T])continue;const E=r.tileCoordToPixel(u.min.x+T/u.xScale,u.min.y+w/u.yScale),M=r.tileCoordToPixel(u.min.x+(T+1)/u.xScale,u.min.y+(w+1)/u.yScale);for(let S=E.y;S<=Math.min(M.y+1,n-1);++S)for(let I=E.x;I<=Math.min(M.x+1,n-1);++I)Ss[S*n+I]===255&&(Ss[S*n+I]=0,v+=r.getElevationAtPixel(I,S),b++)}const x=v/b;m=Math.max(1,h.x-f),_=Math.max(1,h.y-f),g=Math.min(d.x+f,n-2),y=Math.min(d.y+f,n-2),a=!0;for(let w=_;w<=y;++w)for(let T=m;T<=g;++T)Ss[w*n+T]===0&&(np[w*n+T]=r._dem.set(T,w,x));for(let w=1;w<f;++w){m=Math.max(1,h.x-w),_=Math.max(1,h.y-w),g=Math.min(d.x+w,n-2),y=Math.min(d.y+w,n-2);for(let T=_;T<=y;++T)for(let E=m;E<=g;++E){const M=T*n+E;if(Ss[M]===255){let S=0,I=0,C=-1,k=-1;for(let A=-1;A<=1;++A)for(let L=-1;L<=1;++L){const O=(T+A)*n+E+L;if(Ss[O]>=w)continue;const U=np[O],R=Math.abs(U);R>I&&(S=U,I=R,C=L,k=A)}if(I>.1){const A=1-(w+.5*Math.abs(C*k))/f;let L=r._dem.get(E,T)+S*A;const O=r._dem.get(E+C,T+k),U=r._dem.get(E-C,T-k,!0);(L-O)*(L-U)>0&&(L=(O+U)/2),np[M]=r._dem.set(E,T,L),Ss[M]=w}}}}}a&&(r._demTile.needsDEMTextureUpload=!0,r._dem._timestamp=je.now())}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new M0(e));this.freeNodes()}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Dc(e);this.nodes.splice(0,this.nodes.length)}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const r of e)zc(r.node),Dc(r.node)}isEmpty(){return!this.nodes.length}updateReplacement(e,r){if(r.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=r.updateTime;const i=r.getReplacementRegionsForTile(e.toUnwrapped()),o=this.getNodesInfo();for(let s=0;s<this.nodesInfo.length;s++){const n=o[s].node;o[s].hiddenByReplacement=!!n.footprint&&!i.find(a=>a.footprint===n.footprint)}}getHeightAtTileCoord(e,r){const i=this.getNodesInfo(),o=[];for(let s=0;s<this.nodesInfo.length;s++){const n=i[s],a=n.node.meshes[0];if(e<a.aabb.min[0]||r<a.aabb.min[1]||e>a.aabb.max[0]||r>a.aabb.max[1])continue;const l=(e-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*Ms|0,c=Math.min(63,(r-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*Ms|0)*Ms+Math.min(63,l);if(!(a.heightmap[c]<0&&n.node.footprint))return n.hiddenByReplacement?void 0:{height:a.heightmap[c],maxHeight:n.feature.properties.height,hidden:!1,verticalScale:n.evaluatedScale[2]};if(n.node.footprint.grid.query(new N(e,r),new N(e,r),o),o.length>0)return{height:void 0,maxHeight:n.feature.properties.height,hidden:n.hiddenByReplacement,verticalScale:n.evaluatedScale[2]}}}}function Ca(t,e){return!t.isLightConstant&&e}function o3(t,e,r,i,o,s,n,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,u=240&e|(240&e)>>4;r[3]>0&&(l=Fe(l,255*r[0],r[3]),c=Fe(c,255*r[1],r[3]),u=Fe(u,255*r[2],r[3]));const h=l<<8|c,d=u<<8|Math.floor(255*i[3]),p=function(w){const T=Se(w,0,2);return Math.min(Math.round(.5*T*255),255)}(i[2])<<8|15*i[0]<<4|15*i[1],f=Se(o[0],0,1),m=Se(o[1],0,1),_=Se(o[2],0,1),g=Se(o[3],0,1);let y,v,b,x;if(f!==m&&n!==s&&m!==f){const w=n-s;v=1/(w*(m-f)),b=-(s+w*f)/(w*(m-f));const T=Se(o[4],-1,1);x=Math.pow(10,T),y=255*_<<8|255*g}else y=65535,v=0,b=1,x=1;if(t.emplaceBack(h,d,p,y,v,b,x),a){const w=a.length;a.clear();for(let T=0;T<w;T++)a.emplaceBack(h,d,p,y,v,b,x)}}function s3(t,e){const r=t.node;let i=0;for(const o of r.meshes){if(r.lights&&r.lightMeshIndex===i||!o.featureData)continue;o.featureArray=new Dl,o.featureArray.reserve(o.featureData.length);let s=e;for(const n of o.featureData){let a;const l=65535&n,c=(15&l)<8?15&l:0,u=n>>16&65535,h=t.evaluatedRMEA[c],d=t.evaluatedColor[c],p=t.emissionHeightBasedParams[c];if(s&&c===2&&r.lights&&(a=new Dl,a.resize(10*r.lights.length)),o3(o.featureArray,u,d,h,p,o.aabb.min[2],o.aabb.max[2],a),a&&s){s=!1;const f=r.meshes[r.lightMeshIndex];f.featureArray=a,f.featureArray._trim()}}o.featureArray._trim(),i++}}Ee(S0,"Tiled3dModelBucket",{omit:["layers"]}),Ee(M0,"Tiled3dModelFeature");class n3{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(e){const r=C0(new N(0,0),new N(W,W),e),i=[];for(const o of this._activeRegions){if(o.hiddenByOverlap||!I0(r,o))continue;const s=a3(o.min,o.max,e);i.push({min:s.min,max:s.max,sourceId:this._sourceIds[o.priority],footprint:o.footprint,footprintTileId:o.tileId})}return i}setSources(e){this._setSources(e.map(r=>({getSourceId:()=>r.cache.id,getFootprints:()=>{const i=[];for(const o of r.cache.getVisibleCoordinates()){const s=r.cache.getTile(o).buckets[r.layer];if(s)for(const n of s.getNodesInfo()){const a=n.node;a.footprint&&i.push({footprint:a.footprint,id:o.toUnwrapped()})}}return i}})))}_addSource(e){const r=e.getFootprints();if(r.length!==0){for(const i of r){if(!i.footprint)continue;const o=C0(i.footprint.min,i.footprint.max,i.id);this._activeRegions.push({min:o.min,max:o.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:i.id,footprint:i.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort((r,i)=>r.priority-i.priority||kc(r.min,i.min)||kc(r.max,i.max));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let r=0,i=0;for(;!e&&r!==this._activeRegions.length;){const o=this._activeRegions[r],s=this._prevRegions[i];e=o.priority!==s.priority||!A0(o,s),++r,++i}}if(e){++this._updateTime;const r=i=>{const o=this._activeRegions;if(i>=o.length)return i;const s=o[i].priority;for(;i<o.length&&o[i].priority===s;)++i;return i};if(this._sourceIds.length>1){let i=0,o=r(i);for(;i!==o;){let s=i;const n=i;for(;s!==o;){const a=this._activeRegions[s];a.hiddenByOverlap=!1;for(let l=0;l<n;l++){const c=this._activeRegions[l];if(!c.hiddenByOverlap&&I0(a,c)&&(a.hiddenByOverlap=D0(a.footprint,a.tileId,c.footprint,c.tileId),a.hiddenByOverlap))break}++s}i=o,o=r(i)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let r=e.length-1;r>=0;r--)this._addSource(e[r]);this._computeReplacement()}}function kc(t,e){return t.x-e.x||t.y-e.y}function A0(t,e){return kc(t.min,e.min)===0&&kc(t.max,e.max)===0}function I0(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 C0(t,e,r){const i=1/W,o=1/(1<<r.canonical.z),s=(e.x*i+r.canonical.x)*o+r.wrap,n=(e.y*i+r.canonical.y)*o;return{min:new N((t.x*i+r.canonical.x)*o+r.wrap,(t.y*i+r.canonical.y)*o),max:new N(s,n)}}function a3(t,e,r){const i=1<<r.canonical.z,o=((e.x-r.wrap)*i-r.canonical.x)*W,s=(e.y*i-r.canonical.y)*W;return{min:new N(((t.x-r.wrap)*i-r.canonical.x)*W,(t.y*i-r.canonical.y)*W),max:new N(o,s)}}function z0(t,e,r,i,o,s,n){const a=t.indices,l=t.vertices,c=[];for(let u=i;u<i+o;u+=3){const h=e[r[u+0]+s],d=e[r[u+1]+s],p=e[r[u+2]+s],f=Math.min(h.x,d.x,p.x),m=Math.max(h.x,d.x,p.x),_=Math.min(h.y,d.y,p.y),g=Math.max(h.y,d.y,p.y);c.length=0,t.grid.query(new N(f,_),new N(m,g),c);for(let y=0;y<c.length;y++){const v=c[y];if(Sd(l[a[3*v+0]],l[a[3*v+1]],l[a[3*v+2]],h,d,p,n))return!0}}return!1}function D0(t,e,r,i){if(!t||!r)return!1;let o=t.vertices;if(!e.canonical.equals(i.canonical)||e.wrap!==i.wrap){if(r.vertices.length<t.vertices.length)return D0(r,i,t,e);const s=e.canonical,n=i.canonical,a=Math.pow(2,n.z-s.z);o=t.vertices.map(l=>new N(l.x*s.x*W*a-n.x*W,l.y*s.y*W*a-n.y*W))}return z0(r,o,t.indices,0,t.indices.length,0,0)}const l3=tc.types,c3=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],u3=["fill-extrusion-flood-light-ground-radius"],h3=Math.pow(2,13),d3=Math.pow(2,15)-1,k0=new N(0,1),Yi=2147483648;function za(t,e,r,i,o,s,n,a){t.emplaceBack((e<<1)+n,(r<<1)+s,(Math.floor(i*h3)<<1)+o,Math.round(a))}function Pc(t,e,r,i,o,s){t.emplaceBack(e.x,e.y,(r.x<<1)+i,(r.y<<1)+o,s)}function Da(t,e,r){t.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class P0{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class R0{constructor(){this.centroidXY=new N(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 N(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new N(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new N(this.max.x-this.min.x,this.max.y-this.min.y)}}class L0{constructor(){this.acc=new N(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,r){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=r.x,e.min.y=e.max.y=r.y)}appendEdge(e,r,i){this.accCount++,this.acc._add(r);let o=!!this.borders;r.x<e.min.x?(e.min.x=r.x,o=!0):r.x>e.max.x&&(e.max.x=r.x,o=!0),r.y<e.min.y?(e.min.y=r.y,o=!0):r.y>e.max.y&&(e.max.y=r.y,o=!0),((r.x===0||r.x===W)&&r.x===i.x)!=((r.y===0||r.y===W)&&r.y===i.y)&&this.processBorderOverlap(r,i),o&&this.checkBorderIntersection(r,i)}checkBorderIntersection(e,r){r.x<0!=e.x<0&&this.addBorderIntersection(0,Fe(r.y,e.y,(0-r.x)/(e.x-r.x))),r.x>W!=e.x>W&&this.addBorderIntersection(1,Fe(r.y,e.y,(W-r.x)/(e.x-r.x))),r.y<0!=e.y<0&&this.addBorderIntersection(2,Fe(r.x,e.x,(0-r.y)/(e.y-r.y))),r.y>W!=e.y>W&&this.addBorderIntersection(3,Fe(r.x,e.x,(W-r.y)/(e.y-r.y)))}addBorderIntersection(e,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];r<i[0]&&(i[0]=r),r>i[1]&&(i[1]=r)}processBorderOverlap(e,r){if(e.x===r.x){if(e.y===r.y)return;const i=e.x===0?0:1;this.addBorderIntersection(i,r.y),this.addBorderIntersection(i,e.y)}else{const i=e.y===0?2:3;this.addBorderIntersection(i,r.x),this.addBorderIntersection(i,e.x)}}centroid(){return this.accCount===0?new N(0,0):new N(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,r)=>e+ +(r[0]!==Number.MAX_VALUE),0):0}}function B0(t,e){const r=t.add(e)._unit(),i=Se(t.x*r.x+t.y*r.y,-1,1);var o,s,n;return o=Math.acos(i),Math.min(4,Math.max(-4,Math.tan(o)))/4*d3*((s=t).x*(n=e).y-s.y*n.x<0?-1:1)}const p3=[t=>t.x<0,t=>t.x>W,t=>t.y<0,t=>t.y>W];function f3(t,e,r,i){const o=[4];if(i===0)return o;r._mult(i);const s=t.sub(r),n=e.sub(r),a=[t,e,s,n];for(let l=0;l<4;l++)for(const c of a)if(p3[l](c)){o.push(l);break}return o}class O0{constructor(e){this.vertexArray=new Ch,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom,r=>u3.includes(r)),this._segments=new Et,this.hiddenByLandmarkVertexArray=new jh,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Et}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,r,i,o=!1){const s=e.length;if(s>2){let n=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*s,this.vertexArray.length,2*this._segmentToGroundQuads[n].length);let l;n!==this._segments.get().length-1&&(n++,this._segmentToGroundQuads[n]=[],this._segmentToRegionTriCounts[n]=[0,0,0,0,0]);{const c=e[0],u=e[1];l=B0(c.sub(e[s-1])._perp()._unit(),u.sub(c)._perp()._unit())}for(let c=0;c<s;c++){const u=c===s-1?0:c+1,h=e[c],d=e[u],p=e[u===s-1?0:u+1],f=d.sub(h)._perp()._unit(),m=B0(f,p.sub(d)._perp()._unit()),_=l,g=m;if(ap(h,d,r)||o&&U0(h,r)&&U0(d,r)){l=m;continue}const y=a.vertexLength;Pc(this.vertexArray,h,d,1,1,_),Pc(this.vertexArray,h,d,1,0,_),Pc(this.vertexArray,h,d,0,1,g),Pc(this.vertexArray,h,d,0,0,g),a.vertexLength+=4;const v=f3(h,d,f,i);for(const b of v)this._segmentToGroundQuads[n].push({id:y,region:b}),this._segmentToRegionTriCounts[n][b]+=2,a.primitiveLength+=2;l=m}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),r=e.length;for(let i=0;i<r;i++)this._segmentToGroundQuads[i].sort((o,s)=>o.region-s.region);for(let i=0;i<r;i++){const o=this._segmentToGroundQuads[i],s=e[i],n=this._segmentToRegionTriCounts[i];n.reduce((l,c)=>l+c,0);let a=0;for(let l=0;l<=4;l++){const c=n[l];if(c!==0){let u=this.regionSegments[l];u||(u=this.regionSegments[l]=new Et);const h={vertexOffset:s.vertexOffset,primitiveOffset:s.primitiveOffset+a,vertexLength:s.vertexLength,primitiveLength:c};u.get().push(h)}a+=c}for(let l=0;l<o.length;l++){const c=o[l].id;this.indexArray.emplaceBack(c,c+1,c+3),this.indexArray.emplaceBack(c,c+3,c+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,r,i,o,s,n){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,r,i,o,s,n)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Fw.members),this.indexBuffer=e.createIndexBuffer(this.indexArray))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,r,i,o,s,n){this.hasData()&&this.programConfigurations.updatePaintArrays(e,r,i,o,s,n)}updateHiddenByLandmark(e){if(!this.hasData())return;const r=e.groundVertexCount+e.groundVertexArrayOffset;if(e.groundVertexCount===0)return;const i=e.flags&Yi?1:0;for(let o=e.groundVertexArrayOffset;o<r;++o)this.hiddenByLandmarkVertexArray.emplace(o,i);this._needsHiddenByLandmarkUpdate=!0}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Uw.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 r=this.regionSegments[e];r&&r.destroy()}}}}class ka{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.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 nr,this.footprintVertices=new Wr,this.footprintSegments=[],this.layoutVertexArray=new _s,this.centroidVertexArray=new Hm,this.indexArray=new nr,this.programConfigurations=new Po(e.layers,e.zoom,r=>c3.includes(r)),this.segments=new Et,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.groundEffect=new O0(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,r,i,o){this.features=[],this.hasPattern=Pd("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ha(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:s,id:n,index:a,sourceLayerIndex:l}of e){const c=this.layers[0]._featureFilter.needGeometry,u=Uo(s,c);if(!this.layers[0]._featureFilter.filter(new Ut(this.zoom),u,i))continue;const h={id:n,sourceLayerIndex:l,index:a,geometry:c?u.geometry:$i(s,i,o),properties:s.properties,type:s.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Rd("fill-extrusion",this.layers,h,this.zoom,r)):this.addFeature(h,h.geometry,a,i,{},r.availableImages,o,r.brightness),r.featureIndex.insert(s,h.geometry,a,l,this.index,d)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,r,i,o,s,n){for(const a of this.features){const{geometry:l}=a;this.addFeature(a,l,a.index,r,i,o,s,n)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,r,i,o,s){const n=Object.keys(e).length!==0;if(n&&!this.stateDependentLayers.length)return;const a=n?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,r,a,i,o,s),this.groundEffect.update(e,r,a,i,o,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jw),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Vw.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,Nw.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,r,i,o,s,n,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new N(0,0),new N(W,W)],h=a.projection,d=h.name==="globe",p=l3[e.type]==="Polygon",f=new L0;f.centroidDataIndex=this.centroidData.length;const m=new R0,_=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},o)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},o);m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Cl);const y=kd(r,500);for(let E=y.length-1;E>=0;E--){const M=y[E];(M.length===0||(v=M[0]).every(S=>S.x<=0)||v.every(S=>S.x>=W)||v.every(S=>S.y<=0)||v.every(S=>S.y>=W))&&y.splice(E,1)}var v;let b;if(d)b=q0(y,u,o);else{b=[];for(const E of y)b.push({polygon:E,bounds:u})}const x=p?this.edgeRadius:0,w=x>0&&this.zoom<17,T=(E,M)=>{if(E.length===0)return!1;const S=E[E.length-1];return M.x===S.x&&M.y===S.y};for(const{polygon:E,bounds:M}of b){let S=0,I=0;for(const L of E)p&&!L[0].equals(L[L.length-1])&&L.push(L[0]),I+=p?L.length-1:L.length;const C=this.segments.prepareSegment((p?5:4)*I,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const k={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},A=new P0;if(A.vertexOffset=this.footprintVertices.length,A.indexOffset=3*this.footprintIndices.length,A.ringIndices=[],p){const L=[],O=[];S=C.vertexLength;for(let R=0;R<E.length;R++){const B=E[R];B.length&&R!==0&&O.push(L.length/2);const G=[];let Z,q;Z=B[1].sub(B[0])._perp()._unit(),A.ringIndices.push(B.length-1);for(let X=1;X<B.length;X++){const Y=B[X],K=B[X===B.length-1?1:X+1],H=Y.clone();if(x){q=K.sub(Y)._perp()._unit();const ee=Z.add(q)._unit(),de=x*Math.min(4,1/(Z.x*ee.x+Z.y*ee.y));H.x+=de*ee.x,H.y+=de*ee.y,H.x=Math.round(H.x),H.y=Math.round(H.y),Z=q}!_||x!==0&&!w||T(G,H)||G.push(H),za(this.layoutVertexArray,H.x,H.y,0,0,1,1,0),C.vertexLength++,this.footprintVertices.emplaceBack(Y.x,Y.y),L.push(Y.x,Y.y),d&&Da(this.layoutVertexExtArray,h.projectTilePoint(H.x,H.y,o),h.upVector(o,H.x,H.y))}_&&(x===0||w)&&(G.length!==0&&T(G,G[0])&&G.pop(),this.groundEffect.addData(G,M,c))}const U=Kl(L,O);for(let R=0;R<U.length;R+=3)this.footprintIndices.emplaceBack(A.vertexOffset+U[R+0],A.vertexOffset+U[R+1],A.vertexOffset+U[R+2]),this.indexArray.emplaceBack(S+U[R],S+U[R+2],S+U[R+1]),C.primitiveLength++;A.indexCount+=U.length,A.vertexCount+=this.footprintVertices.length-A.vertexOffset}for(let L=0;L<E.length;L++){const O=E[L];f.startRing(m,O[0]);let U=O.length>4&&V0(O[O.length-2],O[0],O[1]),R=x?m3(O[O.length-2],O[0],O[1],x):0;const B=[];let G,Z,q;Z=O[1].sub(O[0])._perp()._unit();let X=!0;for(let Y=1,K=0;Y<O.length;Y++){let H=O[Y-1],ee=O[Y];const de=O[Y===O.length-1?1:Y+1];if(f.appendEdge(m,ee,H),ap(ee,H,M)){x&&(Z=de.sub(ee)._perp()._unit(),X=!X);continue}const pe=ee.sub(H)._perp(),ge=pe.x/(Math.abs(pe.x)+Math.abs(pe.y)),xe=pe.y>0?1:0,Oe=H.dist(ee);if(K+Oe>32768&&(K=0),x){q=de.sub(ee)._perp()._unit();let Be=N0(H,ee,de,F0(Z,q),x);isNaN(Be)&&(Be=0);const Re=ee.sub(H)._unit();H=H.add(Re.mult(R))._round(),ee=ee.add(Re.mult(-Be))._round(),R=Be,Z=q,_&&this.zoom>=17&&(T(B,H)||B.push(H),T(B,ee)||B.push(ee))}const Ie=C.vertexLength,ht=O.length>4&&V0(H,ee,de);let st=j0(K,U,X);if(za(this.layoutVertexArray,H.x,H.y,ge,xe,0,0,st),za(this.layoutVertexArray,H.x,H.y,ge,xe,0,1,st),K+=Oe,st=j0(K,ht,!X),U=ht,za(this.layoutVertexArray,ee.x,ee.y,ge,xe,0,0,st),za(this.layoutVertexArray,ee.x,ee.y,ge,xe,0,1,st),C.vertexLength+=4,this.indexArray.emplaceBack(Ie+0,Ie+1,Ie+2),this.indexArray.emplaceBack(Ie+1,Ie+3,Ie+2),C.primitiveLength+=2,x){const Be=S+(Y===1?O.length-2:Y-2),Re=Y===1?S:Be+1;if(this.indexArray.emplaceBack(Ie+1,Be,Ie+3),this.indexArray.emplaceBack(Be,Re,Ie+3),C.primitiveLength+=2,G===void 0&&(G=Ie),!ap(de,O[Y],M)){const De=Y===O.length-1?G:C.vertexLength;this.indexArray.emplaceBack(Ie+2,Ie+3,De),this.indexArray.emplaceBack(Ie+3,De+1,De),this.indexArray.emplaceBack(Ie+3,Re,De+1),C.primitiveLength+=3}X=!X}if(d){const Be=this.layoutVertexExtArray,Re=h.projectTilePoint(H.x,H.y,o),De=h.projectTilePoint(ee.x,ee.y,o),at=h.upVector(o,H.x,H.y),ut=h.upVector(o,ee.x,ee.y);Da(Be,Re,at),Da(Be,Re,at),Da(Be,De,ut),Da(Be,De,ut)}}p&&(S+=O.length-1),_&&x&&this.zoom>=17&&(B.length!==0&&T(B,B[0])&&B.pop(),this.groundEffect.addData(B,M,c,x>0))}this.footprintSegments.push(A),k.triangleCount=this.indexArray.length-k.triangleArrayOffset,this.polygonSegments.push(k),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,m.vertexCount!==0){if(m.centroidXY=f.borders?k0:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const E=this.featuresOnBorder.length-1;for(let M=0;M<f.borders.length;M++)f.borders[M][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[M].push(E)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,s,n,o,l),this.groundEffect.addPaintPropertiesData(e,i,s,n,o,l),this.maxHeight=Math.max(this.maxHeight,g)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((r,i)=>this.featuresOnBorder[r].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let a=0;a<this.centroidData.length;a++){const l=this.centroidData[a],c=+(l.min.y+l.max.y>W),u=2*c+(+(l.min.x+l.max.x>W)^c);for(let h=0;h<l.polygonSegLen;h++){const d=l.polygonSegIdx+h;e.push({centroidIdx:a,subtile:u,polygonSegmentIdx:d,triangleSegmentIdx:this.polygonSegments[d].triangleSegIdx})}}const r=new nr;e.sort((a,l)=>a.triangleSegmentIdx===l.triangleSegmentIdx?a.subtile-l.subtile:a.triangleSegmentIdx-l.triangleSegmentIdx);let i=0,o=0,s=0;for(const a of e){if(a.triangleSegmentIdx!==i)break;s++}const n=e.length;for(;o!==e.length;){i=e[o].triangleSegmentIdx;let a=0,l=o,c=o;for(let u=l;u<s&&e[u].subtile===a;u++)c++;for(;l!==s;){const u=e[l];a=u.subtile;const h=this.centroidData[u.centroidIdx].min.clone(),d=this.centroidData[u.centroidIdx].max.clone(),p={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:r.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let f=l;f<c;f++){const m=e[f],_=this.polygonSegments[m.polygonSegmentIdx],g=this.centroidData[m.centroidIdx].min,y=this.centroidData[m.centroidIdx].max,v=this.indexArray.uint16;for(let b=_.triangleArrayOffset;b<_.triangleArrayOffset+_.triangleCount;b++)r.emplaceBack(v[3*b],v[3*b+1],v[3*b+2]);p.primitiveLength+=_.triangleCount,h.x=Math.min(h.x,g.x),h.y=Math.min(h.y,g.y),d.x=Math.max(d.x,y.x),d.y=Math.max(d.y,y.y)}p.primitiveLength>0&&this.triangleSubSegments.push({segment:p,min:h,max:d}),l=c;for(let f=l;f<s&&e[f].subtile===e[l].subtile;f++)c++}o=s;for(let u=o;u<n&&e[u].triangleSegmentIdx===e[o].triangleSegmentIdx;u++)s++}r._trim(),this.indexArray=r}getVisibleSegments(e,r,i){let o=0,s=0;const n=1<<e.canonical.z;if(r){const m=r.getMinMaxForTile(e);m&&(o=m.min,s=m.max)}s+=this.maxHeight;const a=e.toUnwrapped();let l;const c=[a.canonical.x/n+a.wrap,a.canonical.y/n],u=[(a.canonical.x+1)/n+a.wrap,(a.canonical.y+1)/n],h=new Et,d=(m,_,g)=>[m[0]*(1-g[0])+_[0]*g[0],m[1]*(1-g[1])+_[1]*g[1]],p=[],f=[];for(const m of this.triangleSubSegments){p[0]=m.min.x/W,p[1]=m.min.y/W,f[0]=m.max.x/W,f[1]=m.max.y/W;const _=d(c,u,p),g=d(c,u,f);if(new Pt([_[0],_[1],o],[g[0],g[1],s]).intersectsPrecise(i)===0){l&&(h.segments.push(l),l=void 0);continue}const y=m.segment;l&&l.vertexOffset!==y.vertexOffset&&(h.segments.push(l),l=void 0),l?(l.vertexLength+=y.vertexLength,l.primitiveLength+=y.primitiveLength):l={vertexOffset:y.vertexOffset,primitiveLength:y.primitiveLength,vertexLength:y.vertexLength,primitiveOffset:y.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&h.segments.push(l),h}encodeCentroid(e,r){const i=e.centroid(),o=r.span(),s=Math.min(7,Math.round(o.x*this.tileToMeter/10)),n=Math.min(7,Math.round(o.y*this.tileToMeter/10));return new N(Se(i.x,1,W-1)<<3|s,Se(i.y,1,W-1)<<3|n)}showCentroid(e){const r=this.centroidData[e.centroidDataIndex];r.flags&=Yi,r.centroidXY.x=0,r.centroidXY.y=0,this.writeCentroidToBuffer(r)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const r=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,o=e.flags&Yi?k0:e.centroidXY,s=this.centroidVertexArray.geta_centroid_pos0(r);if(this.centroidVertexArray.geta_centroid_pos1(r)!==o.y||s!==o.x){for(let n=r;n<i;++n)this.centroidVertexArray.emplace(n,o.x,o.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,r){if(r.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=r.updateTime;const i=r.getReplacementRegionsForTile(e.toUnwrapped());if(function(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a].sourceId!==n[a].sourceId||!A0(s[a],n[a]))return!1;return!0}(this.activeReplacements,i))return;if(this.activeReplacements=i,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(const s of this.centroidData)s.flags&=2147483647;const o=[];for(const s of this.activeReplacements){const n=Math.pow(2,s.footprintTileId.canonical.z-e.canonical.z);for(const a of this.centroidData)if(!(a.flags&Yi||s.min.x>a.max.x||a.min.x>s.max.x||s.min.y>a.max.y||a.min.y>s.max.y))for(let l=0;l<a.footprintSegLen;l++){const c=this.footprintSegments[a.footprintSegIdx+l];if(o.length=0,_3(this.footprintVertices,c.vertexOffset,c.vertexCount,s.footprintTileId.canonical,e.canonical,o),z0(s.footprint,o,this.footprintIndices.uint16,c.indexOffset,c.indexCount,-c.vertexOffset,-n)){a.flags|=Yi;break}}}for(const s of this.centroidData)this.writeCentroidToBuffer(s);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,r,i){let o=!1;for(let s=0;s<i.footprintSegLen;s++){const n=this.footprintSegments[i.footprintSegIdx+s];let a=0;for(const l of n.ringIndices){for(let c=a,u=l+a-1;c<l+a;u=c++){const h=this.footprintVertices.int16[2*(c+n.vertexOffset)+0],d=this.footprintVertices.int16[2*(c+n.vertexOffset)+1],p=this.footprintVertices.int16[2*(u+n.vertexOffset)+1];d>r!=p>r&&e<(this.footprintVertices.int16[2*(u+n.vertexOffset)+0]-h)*(r-d)/(p-d)+h&&(o=!o)}a=l}}return o}getHeightAtTileCoord(e,r){let i=Number.NEGATIVE_INFINITY,o=!0;const s=4*(e+W)*W+(r+W);if(this.partLookup.hasOwnProperty(s)){const n=this.partLookup[s];return n?{height:n.height,hidden:!!(n.flags&Yi)}:void 0}for(const n of this.centroidData)e>n.max.x||n.min.x>e||r>n.max.y||n.min.y>r||this.footprintContainsPoint(e,r,n)&&n&&n.height>i&&(i=n.height,this.partLookup[s]=n,o=!!(n.flags&Yi));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:o};this.partLookup[s]=void 0}}function F0(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function m3(t,e,r,i){const o=e.sub(t)._perp()._unit(),s=r.sub(e)._perp()._unit();return N0(t,e,r,F0(o,s),i)}function N0(t,e,r,i,o){const s=Math.sqrt(1-i*i);return Math.min(t.dist(e)/3,e.dist(r)/3,o*s/i)}function ap(t,e,r){return t.x<r[0].x&&e.x<r[0].x||t.x>r[1].x&&e.x>r[1].x||t.y<r[0].y&&e.y<r[0].y||t.y>r[1].y&&e.y>r[1].y}function U0(t,e){return t.x<e[0].x||t.x>e[1].x||t.y<e[0].y||t.y>e[1].y}function V0(t,e,r){if(t.x<0||t.x>=W||e.x<0||e.x>=W||r.x<0||r.x>=W)return!1;const i=r.sub(e),o=i.perp(),s=t.sub(e);return(i.x*s.x+i.y*s.y)/Math.sqrt((i.x*i.x+i.y*i.y)*(s.x*s.x+s.y*s.y))>-.866&&o.x*s.x+o.y*s.y<0}function j0(t,e,r){const i=e?2|t:-3&t;return r?1|i:-2&i}function G0(){const t=Math.PI/32,e=Math.tan(t),r=un;return r*Math.sqrt(1+2*e*e)-r}function q0(t,e,r){const i=1<<r.z,o=Jr(r.x/i),s=Jr((r.x+1)/i),n=ar(r.y/i),a=ar((r.y+1)/i);return function(l,c,u,h,d=0,p){const f=[];if(!l.length||!u||!h)return f;const m=(w,T)=>{for(const E of w)f.push({polygon:E,bounds:T})},_=Math.ceil(Math.log2(u)),g=Math.ceil(Math.log2(h)),y=_-g,v=[];for(let w=0;w<Math.abs(y);w++)v.push(y>0?0:1);for(let w=0;w<Math.min(_,g);w++)v.push(0),v.push(1);let b=l;if(b=rc(b,c[0].y-d,c[1].y+d,1),b=rc(b,c[0].x-d,c[1].x+d,0),!b.length)return f;const x=[];for(v.length?x.push({polygons:b,bounds:c,depth:0}):m(b,c);x.length;){const w=x.pop(),T=w.depth,E=v[T],M=w.bounds[0],S=w.bounds[1],I=E===0?M.x:M.y,C=E===0?S.x:S.y,k=p?p(E,I,C):.5*(I+C),A=rc(w.polygons,I-d,k+d,E),L=rc(w.polygons,k-d,C+d,E);if(A.length){const O=[M,new N(E===0?k:S.x,E===1?k:S.y)];v.length>T+1?x.push({polygons:A,bounds:O,depth:T+1}):m(A,O)}if(L.length){const O=[new N(E===0?k:M.x,E===1?k:M.y),S];v.length>T+1?x.push({polygons:L,bounds:O,depth:T+1}):m(L,O)}}return f}(t,e,Math.ceil((s-o)/11.25),Math.ceil((n-a)/11.25),1,(l,c,u)=>{if(l===0)return .5*(c+u);{const h=ar((r.y+c/W)/i);return(dr(.5*(ar((r.y+u/W)/i)+h))*i-r.y)*W}})}function _3(t,e,r,i,o,s){const n=Math.pow(2,i.z-o.z);for(let a=0;a<r;a++){let l=t.int16[2*(a+e)+0],c=t.int16[2*(a+e)+1];l=(l+o.x*W)*n-i.x*W,c=(c+o.y*W)*n-i.y*W,s.push(new N(l,c))}}Ee(ka,"FillExtrusionBucket",{omit:["layers","features"]}),Ee(R0,"PartData"),Ee(P0,"FootprintSegment"),Ee(L0,"BorderCentroidData"),Ee(O0,"GroundEffect");const g3=new Xt({visibility:new se(j["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new se(j["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var y3={paint:new Xt({"fill-extrusion-opacity":new se(j["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ke(j["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new se(j["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new se(j["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ke(j["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ke(j["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ke(j["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new se(j["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new se(j["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ke(j["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ke(j["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new se(j["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new se(j["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new se(j["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new se(j["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new se(j["paint_fill-extrusion"]["fill-extrusion-emissive-strength"])}),layout:g3};class Mn extends N{constructor(e,r,i){super(e,r),this.z=i}}function Pa(t,e){return t.x*e.x+t.y*e.y}function Z0(t,e){if(t.length===1){let r=0;const i=e[r++];let o;for(;!o||i.equals(o);)if(o=e[r++],!o)return 1/0;for(;r<e.length;r++){const s=e[r],n=t[0],a=o.sub(i),l=s.sub(i),c=n.sub(i),u=Pa(a,a),h=Pa(a,l),d=Pa(l,l),p=Pa(c,a),f=Pa(c,l),m=u*d-h*h,_=(d*p-h*f)/m,g=(u*f-h*p)/m,y=i.z*(1-_-g)+o.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let r=1/0;for(const i of e)r=Math.min(r,i.z);return r}}function $0(t,e,r,i,o,s,n,a){const l=n*o.getElevationAt(t,e,!0,!0),c=s[0]!==0,u=c?s[1]===0?n*(s[0]/7-450):n*function(h,d,p){const f=Math.floor(d[0]/8),m=Math.floor(d[1]/8),_=10*(d[0]-8*f),g=10*(d[1]-8*m),y=h.getElevationAt(f,m,!0,!0),v=h.getMeterToDEM(p),b=Math.floor(.5*(_*v-1)),x=Math.floor(.5*(g*v-1)),w=h.tileCoordToPixel(f,m),T=2*b+1,E=2*x+1,M=function(L,O,U,R,B){return[L.getElevationAtPixel(O,U,!0),L.getElevationAtPixel(O+B,U,!0),L.getElevationAtPixel(O,U+B,!0),L.getElevationAtPixel(O+R,U+B,!0)]}(h,w.x-b,w.y-x,T,E),S=Math.abs(M[0]-M[1]),I=Math.abs(M[2]-M[3]),C=Math.abs(M[0]-M[2])+Math.abs(M[1]-M[3]),k=Math.min(.25,.5*v*(S+I)/T),A=Math.min(.25,.5*v*C/E);return y+Math.max(k*_,A*g)}(o,s,a):l;return{base:l+(r===0)?-1:r,top:c?Math.max(u+i,l+r+2):l+i}}const x3=new Xt({"line-cap":new ke(j.layout_line["line-cap"]),"line-join":new ke(j.layout_line["line-join"]),"line-miter-limit":new se(j.layout_line["line-miter-limit"]),"line-round-limit":new se(j.layout_line["line-round-limit"]),"line-sort-key":new ke(j.layout_line["line-sort-key"]),visibility:new se(j.layout_line.visibility)});var H0={paint:new Xt({"line-opacity":new ke(j.paint_line["line-opacity"]),"line-color":new ke(j.paint_line["line-color"]),"line-translate":new se(j.paint_line["line-translate"]),"line-translate-anchor":new se(j.paint_line["line-translate-anchor"]),"line-width":new ke(j.paint_line["line-width"]),"line-gap-width":new ke(j.paint_line["line-gap-width"]),"line-offset":new ke(j.paint_line["line-offset"]),"line-blur":new ke(j.paint_line["line-blur"]),"line-dasharray":new ke(j.paint_line["line-dasharray"]),"line-pattern":new ke(j.paint_line["line-pattern"]),"line-gradient":new ta(j.paint_line["line-gradient"]),"line-trim-offset":new se(j.paint_line["line-trim-offset"]),"line-emissive-strength":new se(j.paint_line["line-emissive-strength"]),"line-border-width":new ke(j.paint_line["line-border-width"]),"line-border-color":new ke(j.paint_line["line-border-color"])}),layout:x3};const v3=(t,e,r,i,o,s,n)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:X0(t,e,r,i),u_pixels_to_tile_units:l,u_device_pixel_ratio:s,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:J0(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:W0(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:n,u_emissive_strength:r.paint.get("line-emissive-strength")}},b3=(t,e,r,i,o)=>{const s=t.transform;return{u_matrix:X0(t,e,r,i),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:o,u_image:0,u_tile_units_to_pixels:W0(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function W0(t,e){return 1/Es(t,1,e.tileZoom)}function X0(t,e,r,i){return t.translatePosMatrix(i||e.tileID.projMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Y0=t=>{const e=[];J0(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");return r[0]===0&&r[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),t.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER"),e};function J0(t){const e=t.paint.get("line-dasharray").value;return e.value||e.kind!=="constant"}const K0=new class extends ke{possiblyEvaluate(t,e){return e=new Ut(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,i){return e=Te({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,i)}}(H0.paint.properties["line-width"].specification);function Q0(t,e){return e>0?e+2*t:t}K0.useIntegerZoom=!0;const w3=new Xt({visibility:new se(j.layout_background.visibility)});var T3={paint:new Xt({"background-color":new se(j.paint_background["background-color"]),"background-pattern":new se(j.paint_background["background-pattern"]),"background-opacity":new se(j.paint_background["background-opacity"]),"background-emissive-strength":new se(j.paint_background["background-emissive-strength"])}),layout:w3};const E3=new Xt({visibility:new se(j.layout_raster.visibility)});var M3={paint:new Xt({"raster-opacity":new se(j.paint_raster["raster-opacity"]),"raster-color":new ta(j.paint_raster["raster-color"]),"raster-color-mix":new se(j.paint_raster["raster-color-mix"]),"raster-color-range":new se(j.paint_raster["raster-color-range"]),"raster-hue-rotate":new se(j.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new se(j.paint_raster["raster-brightness-min"]),"raster-brightness-max":new se(j.paint_raster["raster-brightness-max"]),"raster-saturation":new se(j.paint_raster["raster-saturation"]),"raster-contrast":new se(j.paint_raster["raster-contrast"]),"raster-resampling":new se(j.paint_raster["raster-resampling"]),"raster-fade-duration":new se(j.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new se(j.paint_raster["raster-emissive-strength"]),"raster-array-band":new se(j.paint_raster["raster-array-band"]),"raster-elevation":new se(j.paint_raster["raster-elevation"])}),layout:E3};function ex(t,e,r,i,o,s,n,a){const l=[t,r,o,e,i,s,1,1,1],c=[n,a,1],u=Fr.adjoint([],l),[h,d,p]=D.transformMat3(c,c,Fr.transpose(u,u));return Fr.multiply(l,[h,0,0,0,d,0,0,0,p],l)}class vi extends or{constructor(e,r,i,o){super(),this.id=e,this.dispatcher=i,this.coordinates=r.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(o),this.options=r,this._dirty=!1}load(e,r){if(this._loaded=r||!1,this.fire(new ae("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ye(this.map._requestManager.transformRequest(this.url,J.Image),(i,o)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new Ue(i));else if(o){const{HTMLImageElement:s}=$;this.image=o instanceof s?je.getImageData(o):o,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 Tc(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 ae("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 Tc||this.texture.destroy()}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let r=e[0][1],i=e[0][1];for(const s of e)s[1]>i&&(i=s[1]),s[1]<r&&(r=s[1]);const o=(i+r)/2;if(o>Jt?this.onNorthPole=!0:o<-Jt&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const s=e.map(lt.fromLngLat);this.tileID=function(n){let a=1/0,l=1/0,c=-1/0,u=-1/0;for(const f of n)a=Math.min(a,f.x),l=Math.min(l,f.y),c=Math.max(c,f.x),u=Math.max(u,f.y);const h=Math.max(c-a,u-l),d=Math.max(0,Math.floor(-Math.log(h)/Math.LN2)),p=Math.pow(2,d);return new _i(d,Math.floor((a+c)/2*p),Math.floor((l+u)/2*p))}(s),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ae("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const l in this.tiles){const c=this.tiles[l];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture)}if(this._boundsArray)return;const r=Ts(this.tileID,this.map.transform.projection),[i,o,s,n]=this.coordinates.map(l=>{const c=r.projection.project(l[0],l[1]);return jy(r,c)._round()});this.perspectiveTransform=function(l,c,u,h,d,p,f,m,_,g){const y=ex(0,0,l,0,0,c,l,c),v=ex(u,h,d,p,f,m,_,g);return Fr.multiply(v,Fr.adjoint(y,y),v),[v[6]/v[8]*l/W,v[7]/v[8]*c/W]}(this.width,this.height,i.x,i.y,o.x,o.y,n.x,n.y,s.x,s.y);const a=this._boundsArray=new _s;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(o.x,o.y,W,0),a.emplaceBack(n.x,n.y,0,W),a.emplaceBack(s.x,s.y,W,W),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Yd.members),this.boundsSegments=Et.simpleSegment(0,0,4,2)}prepare(){const e=Object.keys(this.tiles).length!==0;if(this.tileID&&!e)return;const r=this.map.painter.context,i=r.gl;!this._dirty||this.texture instanceof Tc||(this.texture?this.texture.update(this.image):(this.texture=new Gt(r,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(r)}loadTile(e,r){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},r(null)):(e.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class S3 extends ri{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(e){return this.implementation.renderToTile!==void 0}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 A3=new Xt({visibility:new se(j.layout_sky.visibility)});var I3={paint:new Xt({"sky-type":new se(j.paint_sky["sky-type"]),"sky-atmosphere-sun":new se(j.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new se(j.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new se(j.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new se(j.paint_sky["sky-gradient-radius"]),"sky-gradient":new ta(j.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new se(j.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new se(j.paint_sky["sky-atmosphere-color"]),"sky-opacity":new se(j.paint_sky["sky-opacity"])}),layout:A3};function lp(t,e,r){const i=[0,0,1],o=Ar.identity([]);return Ar.rotateY(o,o,r?-$e(t)+Math.PI:$e(t)),Ar.rotateX(o,o,-$e(e)),D.transformQuat(i,i,o),D.normalize(i,i)}var C3={paint:new Xt({})};const z3={circle:class extends ri{constructor(t,e){super(t,pw,e)}createBucket(t){return new Td(t)}queryRadius(t){const e=t;return dn("circle-radius",this,e)+dn("circle-stroke-width",this,e)+$l(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,i,o,s,n,a){const l=jg(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return qg(t,i,s,n,a,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",l,c)}getProgramIds(){return["circle"]}getDefaultProgramParams(t,e){const r=Gg(this);return{config:new xs(this,e),defines:r,overrideFog:!1}}},heatmap:class extends ri{createBucket(t){return new $g(t)}constructor(t,e){super(t,vw,e),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Hl({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 dn("heatmap-radius",this,t)}queryIntersectsFeature(t,e,r,i,o,s,n,a){const l=this.paint.get("heatmap-radius").evaluate(e,r);return qg(t,i,s,n,a,!0,!0,new N(0,0),l)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(t,e){return t==="heatmap"?{config:new xs(this,e),overrideFog:!1}:{}}},hillshade:class extends ri{constructor(t,e){super(t,ww,e)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},fill:class extends ri{constructor(t,e){super(t,Bw,e)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(t,e){return{config:new xs(this,e),overrideFog:!1}}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Ql(t)}queryRadius(){return $l(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,i,o,s){return!t.queryGeometry.isAboveHorizon&&Og(Vg(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),i)}isTileClipped(){return!0}},"fill-extrusion":class extends ri{constructor(t,e){super(t,y3,e),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new ka(t)}queryRadius(){return $l(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,r,i,o,s,n,a,l){const c=jg(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),d=[0,0],p=a&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=t.tile.getBucket(this);if(p&&m instanceof ka){const b=m.centroidVertexArray,x=l+1;x<b.length&&(d[0]=b.geta_centroid_pos0(x),d[1]=b.geta_centroid_pos1(x))}if(d[0]===0&&d[1]===1)return!1;s.projection.name==="globe"&&(i=q0([i],[new N(0,0),new N(W,W)],t.tileID.canonical).map(b=>b.polygon).flat());const _=p?a:null,[g,y]=function(b,x,w,T,E,M,S,I,C,k,A){return b.projection.name==="globe"?function(L,O,U,R,B,G,Z,q,X,Y,K){const H=[],ee=[],de=L.projection.upVectorScale(K,L.center.lat,L.worldSize).metersToTile,pe=[0,0,0,1],ge=[0,0,0,1],xe=(Ie,ht,st,Be)=>{Ie[0]=ht,Ie[1]=st,Ie[2]=Be,Ie[3]=1},Oe=G0();U>0&&(U+=Oe),R+=Oe;for(const Ie of O){const ht=[],st=[];for(const Be of Ie){const Re=Be.x+B.x,De=Be.y+B.y,at=L.projection.projectTilePoint(Re,De,K),ut=L.projection.upVector(K,Be.x,Be.y);let Je=U,Ct=R;if(Z){const Kt=$0(Re,De,U,R,Z,q,X,Y);Je+=Kt.base,Ct+=Kt.top}U!==0?xe(pe,at.x+ut[0]*de*Je,at.y+ut[1]*de*Je,at.z+ut[2]*de*Je):xe(pe,at.x,at.y,at.z),xe(ge,at.x+ut[0]*de*Ct,at.y+ut[1]*de*Ct,at.z+ut[2]*de*Ct),D.transformMat4(pe,pe,G),D.transformMat4(ge,ge,G),ht.push(new Mn(pe[0],pe[1],pe[2])),st.push(new Mn(ge[0],ge[1],ge[2]))}H.push(ht),ee.push(st)}return[H,ee]}(b,x,w,T,E,M,S,I,C,k,A):S?function(L,O,U,R,B,G,Z,q,X){const Y=[],K=[],H=[0,0,0,1];for(const ee of L){const de=[],pe=[];for(const ge of ee){const xe=ge.x+R.x,Oe=ge.y+R.y,Ie=$0(xe,Oe,O,U,G,Z,q,X);H[0]=xe,H[1]=Oe,H[2]=Ie.base,H[3]=1,Mt.transformMat4(H,H,B),H[3]=Math.max(H[3],1e-5);const ht=new Mn(H[0]/H[3],H[1]/H[3],H[2]/H[3]);H[0]=xe,H[1]=Oe,H[2]=Ie.top,H[3]=1,Mt.transformMat4(H,H,B),H[3]=Math.max(H[3],1e-5);const st=new Mn(H[0]/H[3],H[1]/H[3],H[2]/H[3]);de.push(ht),pe.push(st)}Y.push(de),K.push(pe)}return[Y,K]}(x,w,T,E,M,S,I,C,k):function(L,O,U,R,B){const G=[],Z=[],q=B[8]*O,X=B[9]*O,Y=B[10]*O,K=B[11]*O,H=B[8]*U,ee=B[9]*U,de=B[10]*U,pe=B[11]*U;for(const ge of L){const xe=[],Oe=[];for(const Ie of ge){const ht=Ie.x+R.x,st=Ie.y+R.y,Be=B[0]*ht+B[4]*st+B[12],Re=B[1]*ht+B[5]*st+B[13],De=B[2]*ht+B[6]*st+B[14],at=B[3]*ht+B[7]*st+B[15],ut=Be+q,Je=Re+X,Ct=De+Y,Kt=Math.max(at+K,1e-5),St=Be+H,Rt=Re+ee,rr=De+de,Qt=Math.max(at+pe,1e-5);xe.push(new Mn(ut/Kt,Je/Kt,Ct/Kt)),Oe.push(new Mn(St/Qt,Rt/Qt,rr/Qt))}G.push(xe),Z.push(Oe)}return[G,Z]}(x,w,T,E,M)}(s,i,h,u,c,n,_,d,f,s.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(b,x,w){let T=1/0;Og(w,x)&&(T=Z0(w,x[0]));for(let E=0;E<x.length;E++){const M=x[E],S=b[E];for(let I=0;I<M.length-1;I++){const C=M[I],k=[C,M[I+1],S[I+1],S[I],C];Bg(w,k)&&(T=Math.min(T,Z0(w,k)))}}return T!==1/0&&T}(g,y,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},line:class extends ri{constructor(t,e){super(t,H0,e),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Wu,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"]=K0.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new wc(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e){const r=Y0(this);return{config:new xs(this,e),defines:r,overrideFog:!1}}queryRadius(t){const e=t,r=Q0(dn("line-width",this,e),dn("line-gap-width",this,e)),i=dn("line-offset",this,e);return r/2+Math.abs(i)+$l(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,i,o,s){if(t.queryGeometry.isAboveHorizon)return!1;const n=Vg(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*Q0(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(i=function(c,u){const h=[],d=new N(0,0);for(let p=0;p<c.length;p++){const f=c[p],m=[];for(let _=0;_<f.length;_++){const g=f[_],y=f[_+1],v=_===0?d:g.sub(f[_-1])._unit()._perp(),b=_===f.length-1?d:y.sub(g)._unit()._perp(),x=v._add(b)._unit();x._mult(1/(x.x*b.x+x.y*b.y)),m.push(x._mult(u)._add(g))}h.push(m)}return h}(i,l*t.pixelToTileUnitsFactor)),function(c,u,h){for(let d=0;d<u.length;d++){const p=u[d];if(c.length>=3){for(let f=0;f<p.length;f++)if(Vo(c,p[f]))return!0}if(cw(c,p,h))return!0}return!1}(n,i,a)}isTileClipped(){return!0}},symbol:_c,background:class extends ri{constructor(t,e){super(t,T3,e)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,e){return{overrideFog:!1}}},raster:class extends ri{constructor(t,e){super(t,M3,e),this._updateColorRamp()}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}isLayerDraped(t){return!(t&&t._source instanceof vi)||!t._source.onNorthPole&&!t._source.onSouthPole&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(t){t!=="raster-color"&&t!=="raster-color-range"||this._updateColorRamp()}_updateColorRamp(){if(!this.hasColorMap())return;const t=this._transitionablePaint._values["raster-color"].value.expression,[e,r]=this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0});this.colorRamp=Hl({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:e,end:r}],resolution:256}),this.colorRampTexture=null}},sky:class extends ri{constructor(t,e){super(t,I3,e),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="sky-gradient"?this._updateColorRamp():t!=="sky-atmosphere-sun"&&t!=="sky-atmosphere-halo-color"&&t!=="sky-atmosphere-color"&&t!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Hl({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(this.paint.get("sky-type")==="atmosphere"){const i=this.paint.get("sky-atmosphere-sun"),o=!i,s=t.style.light,n=s.properties.get("position");return o&&s.properties.get("anchor")==="viewport"&&F("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),o?lp(n.azimuthal,90-n.polar,e):lp(i[0],90-i[1],e)}const r=this.paint.get("sky-gradient-center");return lp(r[0],90-r[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 t==="atmosphere"?["skyboxCapture","skybox"]:t==="gradient"?["skyboxGradient"]:null}},slot:class extends ri{constructor(t,e){super(t,C3)}},model:class extends ri{constructor(t,e){super(t,i3,e)}createBucket(t){return new w0(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(){return 0}queryIntersectsFeature(){return!1}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven()||t!=="model-color"&&t!=="model-color-mix-intensity"&&t!=="model-rotation"&&t!=="model-scale"&&t!=="model-translation"&&t!=="model-emissive-strength")}_isPropertyZoomDependent(t){const e=this._transitionablePaint._values[t];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof Ao}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}}};function Rc(t,e){return t.type==="custom"?new S3(t):new z3[t.type](t,e)}function D3(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class k3 extends or{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(e){this.images[e]={},this.loaded[e]=!1,this.updatedImages[e]={},this.patterns[e]={},this.callbackDispatchedThisFrame[e]={},this.atlasImage[e]=new ir({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,r){if(this.loaded[r]!==e&&(this.loaded[r]=e,e)){for(const{ids:i,callback:o}of this.requestors)this._notify(i,r,o);this.requestors=[]}}hasImage(e,r){return!!this.getImage(e,r)}getImage(e,r){return this.images[r][e]}addImage(e,r,i){this._validate(e,i)&&(this.images[r][e]=i)}_validate(e,r){let i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new Ue(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,r){if(!e)return!0;let i=0;for(const o of e){if(o[0]<i||o[1]<o[0]||r<o[1])return!1;i=o[1]}return!0}_validateContent(e,r){return!(e&&(e.length!==4||e[0]<0||r.data.width<e[0]||e[1]<0||r.data.height<e[1]||e[2]<0||r.data.width<e[2]||e[3]<0||r.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,r,i){i.version=this.images[r][e].version+1,this.images[r][e]=i,this.updatedImages[r][e]=!0}removeImage(e,r){const i=this.images[r][e];delete this.images[r][e],delete this.patterns[r][e],i.userImage&&i.userImage.onRemove&&i.userImage.onRemove()}listImages(e){return Object.keys(this.images[e])}getImages(e,r,i){let o=!0;const s=!!this.loaded[r];if(!s)for(const n of e)this.images[r][n]||(o=!1);s||o?this._notify(e,r,i):this.requestors.push({ids:e,scope:r,callback:i})}getUpdatedImages(e){return this.updatedImages[e]}_notify(e,r,i){const o={};for(const s of e){this.images[r][s]||this.fire(new ae("styleimagemissing",{id:s}));const n=this.images[r][s];n?o[s]={data:n.data.clone(),pixelRatio:n.pixelRatio,sdf:n.sdf,version:n.version,stretchX:n.stretchX,stretchY:n.stretchY,content:n.content,hasRenderCallback:!!(n.userImage&&n.userImage.render)}:F(`Image "${s}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,o)}getPixelSize(e){const{width:r,height:i}=this.atlasImage[e];return{width:r,height:i}}getPattern(e,r){const i=this.patterns[r][e],o=this.getImage(e,r);if(!o)return null;if(i&&i.position.version===o.version)return i.position;if(i)i.position.version=o.version;else{const s={w:o.data.width+2,h:o.data.height+2,x:0,y:0},n=new jd(s,o);this.patterns[r][e]={bin:s,position:n}}return this._updatePatternAtlas(r),this.patterns[r][e].position}bind(e,r){const i=e.gl;let o=this.atlasTexture[r];o?this.dirty&&(o.update(this.atlasImage[r]),this.dirty=!1):(o=new Gt(e,this.atlasImage[r],i.RGBA),this.atlasTexture[r]=o),o.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(e){const r=[];for(const n in this.patterns[e])r.push(this.patterns[e][n].bin);const{w:i,h:o}=Vd(r),s=this.atlasImage[e];s.resize({width:i||1,height:o||1});for(const n in this.patterns[e]){const{bin:a}=this.patterns[e][n],l=a.x+1,c=a.y+1,u=this.images[e][n].data,h=u.width,d=u.height;ir.copy(u,s,{x:0,y:0},{x:l,y:c},{width:h,height:d}),ir.copy(u,s,{x:0,y:d-1},{x:l,y:c-1},{width:h,height:1}),ir.copy(u,s,{x:0,y:0},{x:l,y:c+d},{width:h,height:1}),ir.copy(u,s,{x:h-1,y:0},{x:l-1,y:c},{width:1,height:d}),ir.copy(u,s,{x:0,y:0},{x:l+h,y:c},{width:1,height:d})}this.dirty=!0}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={}}dispatchRenderCallbacks(e,r){for(const i of e){if(this.callbackDispatchedThisFrame[r][i])continue;this.callbackDispatchedThisFrame[r][i]=!0;const o=this.images[r][i];D3(o)&&this.updateImage(i,r,o)}}}const P3=new Xt({anchor:new se(j.light.anchor),position:new class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return ve(t.expression.evaluate(e))}interpolate(t,e,r){return{x:Fe(t.x,e.x,r),y:Fe(t.y,e.y,r),z:Fe(t.z,e.z,r),azimuthal:Fe(t.azimuthal,e.azimuthal,r),polar:Fe(t.polar,e.polar,r)}}}(j.light.position),color:new se(j.light.color),intensity:new se(j.light.intensity)});class tx extends or{constructor(e,r="flat"){super(),this._transitionable=new Qn(P3),this.setLight(e,r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,r,i={}){this._validate(tb,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=r)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,r,i){return(!i||i.validate!==!1)&&bl(this,e.call(Qs,Te({value:r,style:{glyphs:!0,sprite:!0},styleSpec:j})))}}const R3=new Xt({source:new se(j.terrain.source),exaggeration:new se(j.terrain.exaggeration)});let L3=class extends or{constructor(t,e,r,i){super(),this.scope=r,this._transitionable=new Qn(R3,i),this._transitionable.setTransitionOrValue(t,i),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=e}get(){return this._transitionable.serialize()}set(t,e){this._transitionable.setTransitionOrValue(t,e)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new Ut(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return t!=null&&t.value!=null&&t.value.expression!=null&&t.value.expression instanceof Ao}};const rx=45,ix=65,As=.05;function Lc(t,e,r,i){const o=Fi(rx,ix,r),[s,n]=ox(t,i);let a=1-Math.min(1,Math.exp((e-s)/(n-s)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*o*t.alpha}function ox(t,e){const r=.5/Math.tan(.5*e);return[t.range[0]+r,t.range[1]+r]}function sx(t,e,r,i,o){const s=D.transformMat4([],[e,r,i],o.mercatorFogMatrix);return Lc(t,D.length(s),o.pitch,o._fov)}function nx(t,e,r,i,o,s,n){const a=[[r,i,0],[o,i,0],[o,s,0],[r,s,0]];let l=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(const u of a){const h=D.transformMat4([],u,e),d=D.length(h);l=Math.min(l,d),c=Math.max(c,d)}return[Lc(t,l,n.pitch,n._fov),Lc(t,c,n.pitch,n._fov)]}const B3=new Xt({range:new se(j.fog.range),color:new se(j.fog.color),"high-color":new se(j.fog["high-color"]),"space-color":new se(j.fog["space-color"]),"horizon-blend":new se(j.fog["horizon-blend"]),"star-intensity":new se(j.fog["star-intensity"]),"vertical-range":new se(j.fog["vertical-range"])});class O3 extends or{constructor(e,r){super(),this._transitionable=new Qn(B3),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=r}get state(){const e=this._transform,r=e.projection.name==="globe",i=yr(e.zoom),o=this.properties.get("range"),s=[.5,3];return{range:r?[Fe(s[0],o[0],i),Fe(s[1],o[1],i)]:o,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,r={}){if(this._validate(ob,e,r))return;const i=Te({},e);for(const o of Object.keys(j.fog))i[o]===void 0&&(i[o]=j.fog[o].default);this._transitionable.setTransitionOrValue(i)}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const r=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:Fi(rx,ix,e))*r.a}getOpacityAtLatLng(e,r){return this._transform.projection.supportsFog?function(i,o,s){const n=lt.fromLngLat(o),a=s.elevation?s.elevation.getAtPointOrZero(n):0;return sx(i,n.x,n.y,a,s)}(this.state,e,r):0}getOpacityForTile(e){if(!this._transform.projection.supportsFog)return[1,1];const r=this._transform.calculateFogTileMatrix(e.toUnwrapped());return nx(this.state,r,0,0,W,W,this._transform)}getOpacityForBounds(e,r,i,o,s){return this._transform.projection.supportsFog?nx(this.state,e,r,i,o,s,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?ox(this.state,e):[0,1]}isVisibleOnFrustum(e){if(!this._transform.projection.supportsFog)return!1;const r=[4,5,6,7];for(const i of r){const o=e.points[i];let s;if(o[2]>=0)s=o;else{const n=e.points[i-4];s=Rf(n,o,n[2]/(n[2]-o[2]))}if(sx(this.state,s[0],s[1],0,this._transform)>=As)return!0}return!1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,r,i){return(!i||i.validate!==!1)&&bl(this,e.call(Qs,Te({value:r,style:{glyphs:!0,sprite:!0},styleSpec:j})))}}class F3{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 N3{constructor(){this.tasks={},this.taskQueue=[],pr(["process"],this),this.invoker=new F3(this.process),this.nextId=0}add(e,r){const i=this.nextId++,o=function({type:s,isSymbolTile:n,zoom:a}){return a=a||0,s==="message"?0:s!=="maybePrepare"||n?s!=="parseTile"||n?s==="parseTile"&&n?300-a:s==="maybePrepare"&&n?400-a:500:200-a:100-a}(r);if(o===0){oe();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:r,priority:o,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){oe();try{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}finally{}}pick(){let e=null,r=1/0;for(let o=0;o<this.taskQueue.length;o++){const s=this.tasks[this.taskQueue[o]];s.priority<r&&(r=s.priority,e=o)}if(e===null)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class ax{constructor(e,r,i){this.target=e,this.parent=r,this.mapId=i,this.callbacks={},this.cancelCallbacks={},pr(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new N3}send(e,r,i,o,s=!1,n){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=n,this.callbacks[a]=i);const l=new Set;return this.target.postMessage({id:a,type:e,hasCallback:!!i,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:tn(r,l)},l),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"<cancel>",targetMapId:o,sourceMapId:this.mapId})}}}receive(e){const r=e.data,i=r.id;if(i&&(!r.targetMapId||this.mapId===r.targetMapId))if(r.type==="<cancel>"){const o=this.cancelCallbacks[i];delete this.cancelCallbacks[i],o&&o.cancel()}else if(r.mustQueue||oe()){const o=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,r),o&&o.metadata||{type:"message"})}else this.processTask(i,r)}processTask(e,r){if(r.type==="<response>"){const i=this.callbacks[e];delete this.callbacks[e],i&&(r.error?i(rn(r.error)):i(null,rn(r.data)))}else{const i=new Set,o=r.hasCallback?(n,a)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:n?tn(n):null,data:tn(a,i)},i)}:n=>{},s=rn(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,s,o);else if(this.parent.getWorkerSource){const n=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,n[0],s.source,s.scope)[n[1]](s,o)}else o(new Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Is{constructor(e,r){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ls();const i=this.workerPool.acquire(this.id);for(let o=0;o<i.length;o++){const s=new Is.Actor(i[o],r,this.id);s.name=`Worker ${o}`,this.actors.push(s)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(e,r,i){os(this.actors,(o,s)=>{o.send(e,r,s)},i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}Is.Actor=ax;class lx extends or{constructor(e,r,i,o){super(),this.scope=i,this._options=e,this.properties=new ea(r),this._transitionable=new Qn(r,new Map(o)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,r){this._options=e,this._transitionable.setTransitionOrValue(e.properties,r)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const U3=new Xt({color:new se(j.properties_light_ambient.color),intensity:new se(j.properties_light_ambient.intensity)}),V3=new Xt({direction:new class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([r,i]){const o=ve([1,r,i]);return{x:o.x,y:o.y,z:o.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return{x:Fe(t.x,e.x,r),y:Fe(t.y,e.y,r),z:Fe(t.z,e.z,r)}}}(j.properties_light_directional.direction),color:new se(j.properties_light_directional.color),intensity:new se(j.properties_light_directional.intensity),"cast-shadows":new se(j.properties_light_directional["cast-shadows"]),"shadow-intensity":new se(j.properties_light_directional["shadow-intensity"])});class cp{constructor(e,r,i,o){this.screenBounds=e,this.cameraPoint=r,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o)}static createFromScreenPoints(e,r){let i,o;if(e instanceof N||typeof e[0]=="number"){const s=N.convert(e);i=[s],o=r.isPointAboveHorizon(s)}else{const s=N.convert(e[0]),n=N.convert(e[1]);i=[s,n],o=rs(s,n).every(a=>r.isPointAboveHorizon(a))}return new cp(i,r.getCameraPoint(),o,r)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(e){return rs(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const r=this.screenBounds[0],i=this.screenBounds.length===1?this.screenBounds[0].add(new N(1,1)):this.screenBounds[1],o=rs(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<i.x?o.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?o[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(o[3]=this.cameraPoint)),function(s,n){const a=[];for(let l=0;l<s.length;l++){const c=Ni(l-1,-1,s.length-1),u=Ni(l+1,-1,s.length-1),h=s[l],d=s[u],p=s[c].sub(h).unit(),f=d.sub(h).unit(),m=f.angleWithSep(p.x,p.y),_=p.add(f).unit().mult(-1*n/Math.sin(m/2));a.push(h.add(_))}return a}(o,e)}bufferedCameraGeometryGlobe(e){const r=this.screenBounds[0],i=this.screenBounds.length===1?this.screenBounds[0].add(new N(1,1)):this.screenBounds[1],o=rs(r,i,e),s=this.cameraPoint.clone();switch(3*((s.y>r.y)+(s.y>i.y))+((s.x>r.x)+(s.x>i.x))){case 0:o[0]=s,o[4]=s.clone();break;case 1:o.splice(1,0,s);break;case 2:o[1]=s;break;case 3:o.splice(4,0,s);break;case 5:o.splice(2,0,s);break;case 6:o[3]=s;break;case 7:o.splice(3,0,s);break;case 8:o[2]=s}return o}containsTile(e,r,i,o=0){const s=e.queryPadding/r._pixelsPerMercatorPixel+1,n=i?this._bufferedCameraMercator(s,r):this._bufferedScreenMercator(s,r);let a=e.tileID.wrap+(n.unwrapped?o:0);const l=n.polygon.map(_=>jy(e.tileTransform,_,a));if(!Ug(l,0,0,W,W))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?o:0);const c=this.screenGeometryMercator.polygon.map(_=>Gy(e.tileTransform,_,a)),u=c.map(_=>new N(_[0],_[1])),h=r.getFreeCameraOptions().position||new lt(0,0,0),d=Gy(e.tileTransform,h,a),p=c.map(_=>{const g=D.sub(_,_,d);return D.normalize(g,g),new Fl(d,g)}),f=Es(e,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=uu(l),m.min.x=Se(m.min.x,0,W),m.min.y=Se(m.min.y,0,W),m.max.x=Se(m.max.x,0,W),m.max.y=Se(m.max.y,0,W),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,r){const i=cx(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o=r.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(e),r):{polygon:this.bufferedScreenGeometry(e).map(s=>r.pointCoordinate3D(s)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,r){const i=cx(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o=r.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),r):{polygon:this.bufferedCameraGeometry(e).map(s=>r.pointCoordinate3D(s)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(e,r){const i=function(s,n){const a=V.multiply([],n.pixelMatrix,n.globeMatrix),l=[0,-Pr,0,1],c=[0,Pr,0,1],u=[0,0,0,1];Mt.transformMat4(l,l,a),Mt.transformMat4(c,c,a),Mt.transformMat4(u,u,a);const h=new N(l[0]/l[3],l[1]/l[3]),d=new N(c[0]/c[3],c[1]/c[3]),p=Vo(s,h)&&l[3]<u[3],f=Vo(s,d)&&c[3]<u[3];if(!p&&!f)return null;const m=function(T,E,M){for(let S=1;S<T.length;S++){const I=Ra(E.pointCoordinate3D(T[S-1]).x),C=Ra(E.pointCoordinate3D(T[S]).x);if(M<0){if(I<C)return{idx:S,t:-I/(C-1-I)}}else if(C<I)return{idx:S,t:(1-I)/(C+1-I)}}return null}(s,n,p?-1:1);if(!m)return null;const{idx:_,t:g}=m;let y=_>1?up(s.slice(0,_),n):[],v=_<s.length?up(s.slice(_),n):[];y=y.map(T=>new N(Ra(T.x),T.y)),v=v.map(T=>new N(Ra(T.x),T.y));const b=[...y];b.length===0&&b.push(v[v.length-1]);const x=Fe(b[b.length-1].y,(v.length===0?y[0]:v[0]).y,g);let w;return w=p?[new N(0,x),new N(0,0),new N(1,0),new N(1,x)]:[new N(1,x),new N(1,1),new N(0,1),new N(0,x)],b.push(...w),v.length===0?b.push(y[0]):b.push(...v),{polygon:b.map(T=>new lt(T.x,T.y)),unwrapped:!1}}(e,r);if(i)return i;const o=function(s,n){let a=!1,l=-1/0,c=0;for(let h=0;h<s.length-1;h++)s[h].x>l&&(l=s[h].x,c=h);for(let h=0;h<s.length-1;h++){const d=(c+h)%(s.length-1),p=s[d],f=s[d+1];Math.abs(p.x-f.x)>.5&&(p.x<f.x?(p.x+=1,d===0&&(s[s.length-1].x+=1)):(f.x+=1,d+1===s.length-1&&(s[0].x+=1)),a=!0)}const u=ur(n.center.lng);return a&&u<Math.abs(u-1)&&s.forEach(h=>{h.x-=1}),{polygon:s,unwrapped:a}}(up(e,r).map(s=>new N(Ra(s.x),s.y)),r);return{polygon:o.polygon.map(s=>new lt(s.x,s.y)),unwrapped:o.unwrapped}}}function up(t,e){return Rg(t,r=>{const i=e.pointCoordinate3D(r);r.x=i.x,r.y=i.y},1/256)}function Ra(t){return t<0?1+t%1:t%1}function cx(t){return 100*t|0}function hp(t,e,r,i,o){const s=function(n,a){if(n)return o(n);if(a){t.url&&a.tiles&&t.tiles&&delete t.tiles;const l=jr(Te(a,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(c=>c.id)),l.tiles=e.canonicalizeTileset(l,t.url),o(null,l)}};return t.url?ue(e.transformRequest(e.normalizeSourceURL(t.url,null,r,i),J.Source),s):je.frame(()=>s(null,t))}class Bc{constructor(e,r,i){this.bounds=Yr.convert(this.validateBounds(e)),this.minzoom=r||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const r=Math.pow(2,e.z),i=Math.floor(ur(this.bounds.getWest())*r),o=Math.floor(dr(this.bounds.getNorth())*r),s=Math.ceil(ur(this.bounds.getEast())*r),n=Math.ceil(dr(this.bounds.getSouth())*r);return e.x>=i&&e.x<s&&e.y>=o&&e.y<n}}class ux{constructor(e,r){this.width=e,this.height=r,this.nextRow=0,this.image=new yo({width:e,height:r}),this.positions={},this.uploaded=!1}getDash(e,r){const i=this.getKey(e,r);return this.positions[i]}trim(){const e=this.width,r=this.height=$a(this.nextRow);this.image.resize({width:e,height:r})}getKey(e,r){return e.join(",")+r}getDashRanges(e,r,i){const o=[];let s=e.length%2==1?-e[e.length-1]*i:0,n=e[0]*i,a=!0;o.push({left:s,right:n,isDash:a,zeroLength:e[0]===0});let l=e[0];for(let c=1;c<e.length;c++){a=!a;const u=e[c];s=l*i,l+=u,n=l*i,o.push({left:s,right:n,isDash:a,zeroLength:u===0})}return o}addRoundDash(e,r,i){const o=r/2;for(let s=-i;s<=i;s++){const n=this.width*(this.nextRow+i+s);let a=0,l=e[a];for(let c=0;c<this.width;c++){c/l.right>1&&(l=e[++a]);const u=Math.abs(c-l.left),h=Math.abs(c-l.right),d=Math.min(u,h);let p;const f=s/i*(o+1);if(l.isDash){const m=o-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=o-Math.sqrt(d*d+f*f);this.image.data[n+c]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e,r){for(let l=e.length-1;l>=0;--l){const c=e[l],u=e[l+1];c.zeroLength?e.splice(l,1):u&&u.isDash===c.isDash&&(u.left=c.left,e.splice(l,1))}const i=e[0],o=e[e.length-1];i.isDash===o.isDash&&(i.left=o.left-this.width,o.right=i.right+this.width);const s=this.width*this.nextRow;let n=0,a=e[n];for(let l=0;l<this.width;l++){l/a.right>1&&(a=e[++n]);const c=Math.abs(l-a.left),u=Math.abs(l-a.right),h=Math.min(c,u);this.image.data[s+l]=Math.max(0,Math.min(255,(a.isDash?h:-h)+r+128))}}addDash(e,r){const i=this.getKey(e,r);if(this.positions[i])return this.positions[i];const o=r==="round",s=o?7:0,n=2*s+1;if(this.nextRow+n>this.height)return F("LineAtlas out of space"),null;e.length===0&&e.push(1);let a=0;for(let u=0;u<e.length;u++)e[u]<0&&(F("Negative value is found in line dasharray, replacing values with 0"),e[u]=0),a+=e[u];if(a!==0){const u=this.width/a,h=this.getDashRanges(e,this.width,u);o?this.addRoundDash(h,u,s):this.addRegularDash(h,r==="square"?.5*u:0)}const l=this.nextRow+s;this.nextRow+=n;const c={tl:[l,s],br:[a,0]};return this.positions[i]=c,c}}Ee(ux,"LineAtlas");const hx=1*Di;class dx{constructor(e){const r={},i=[];for(const a in e){const l=e[a],c=r[a]={};for(const u in l.glyphs){const h=l.glyphs[+u];if(!h||h.bitmap.width===0||h.bitmap.height===0)continue;const d=h.metrics.localGlyph?hx:1,p={x:0,y:0,w:h.bitmap.width+2*d,h:h.bitmap.height+2*d};i.push(p),c[u]=p}}const{w:o,h:s}=Vd(i),n=new yo({width:o||1,height:s||1});for(const a in e){const l=e[a];for(const c in l.glyphs){const u=l.glyphs[+c];if(!u||u.bitmap.width===0||u.bitmap.height===0)continue;const h=r[a][c],d=u.metrics.localGlyph?hx:1;yo.copy(u.bitmap,n,{x:0,y:0},{x:h.x+d,y:h.y+d},u.bitmap)}}this.image=n,this.positions=r}}Ee(dx,"GlyphAtlas");class j3{constructor(e){this.tileID=new mt(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=Ts(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster}parse(e,r,i,o,s){this.status="parsing",this.data=e,this.collisionBoxArray=new Gh;const n=new iy(Object.keys(e.layers).sort()),a=new Od(this.tileID,this.promoteId);a.bucketLayerIDs=[];const l={},c=new ux(256,256),u={featureIndex:a,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:c,availableImages:i,brightness:this.brightness},h=r.familiesBySource[this.source];for(const y in h){const v=e.layers[y];if(!v)continue;let b=!1,x=!1,w=!1;for(const M of h[y])M[0].type==="symbol"?b=!0:x=!0,M[0].is3D()&&M[0].type!=="model"&&(w=!0);if(this.extraShadowCaster&&!w||this.isSymbolTile===!0&&!b||this.isSymbolTile===!1&&!x)continue;v.version===1&&F(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=n.encode(y),E=[];for(let M=0;M<v.length;M++){const S=v.feature(M),I=a.getId(S,y);E.push({feature:S,id:I,index:M,sourceLayerIndex:T})}for(const M of h[y]){const S=M[0];(!this.extraShadowCaster||S.is3D()&&S.type!=="model")&&(this.isSymbolTile!==void 0&&S.type==="symbol"!==this.isSymbolTile||S.minzoom&&this.zoom<Math.floor(S.minzoom)||S.maxzoom&&this.zoom>=S.maxzoom||S.visibility!=="none"&&(dp(M,this.zoom,u.brightness,i),(l[S.id]=S.createBucket({index:a.bucketLayerIDs.length,layers:M,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,projection:this.projection.spec})).populate(E,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(M.map(I=>I.id))))}}let d,p,f,m;c.trim();const _={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=()=>{if(d)return this.status="done",s(d);if(this.extraShadowCaster)this.status="done",s(null,{buckets:ss(l).filter(y=>!y.isEmpty()),featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:u.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(p&&f&&m){const y=new dx(p),v=new Py(f,m);for(const b in l){const x=l[b];x instanceof Ea?(dp(x.layers,this.zoom,u.brightness,i),F2(x,p,y.positions,f,v.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):x.hasPattern&&(x instanceof wc||x instanceof Ql||x instanceof ka)&&(dp(x.layers,this.zoom,u.brightness,i),x.addFeatures(u,this.tileID.canonical,v.patternPositions,i,this.tileTransform,this.brightness))}this.status="done",s(null,{buckets:ss(l).filter(b=>!b.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:y.image,lineAtlas:c,imageAtlas:v,brightness:u.brightness})}};if(!this.extraShadowCaster){const y=Os(u.glyphDependencies,x=>Object.keys(x).map(Number));Object.keys(y).length?o.send("getGlyphs",{uid:this.uid,stacks:y,scope:this.scope},(x,w)=>{d||(d=x,p=w,g())},void 0,!1,_):p={};const v=Object.keys(u.iconDependencies);v.length?o.send("getImages",{icons:v,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(x,w)=>{d||(d=x,f=w,g())},void 0,!1,_):f={};const b=Object.keys(u.patternDependencies);b.length?o.send("getImages",{icons:b,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(x,w)=>{d||(d=x,m=w,g())},void 0,!1,_):m={}}g()}}function dp(t,e,r,i){const o=new Ut(e,{brightness:r});for(const s of t)s.recalculate(o,i)}class px{constructor(e){this.entries={},this.scheduler=e}request(e,r,i,o){const s=this.entries[e]=this.entries[e]||{callbacks:[]};if(s.result){const[n,a]=s.result;return this.scheduler?this.scheduler.add(()=>{o(n,a)},r):o(n,a),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=i((n,a)=>{s.result=[n,a];for(const l of s.callbacks)this.scheduler?this.scheduler.add(()=>{l(n,a)},r):l(n,a);setTimeout(()=>delete this.entries[e],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(n=>n!==o),s.callbacks.length||(s.cancel(),delete this.entries[e]))}}}function fx(t,e,r){const i=JSON.stringify(t.request);return t.data&&(this.deduped.entries[i]={result:[null,t.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},o=>{const s=fe(t.request,(n,a,l,c)=>{n?o(n):a&&o(null,{vectorTile:r?void 0:new Ld(new sc(a)),rawData:a,cacheControl:l,expires:c})});return()=>{s.cancel(),o()}},e)}class mx extends or{constructor(e,r,i,o){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Te(this,jr(r,["url","scheme","tileSize","promoteId"])),this._options=Te({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o),this._tileWorkers={},this._deduped=new px}load(e){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=hp(this._options,this.map._requestManager,r,i,(o,s)=>{this._tileJSONRequest=null,this._loaded=!0,o?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&i.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new Ue(o))):s&&(Te(this,s),s.bounds&&(this.tileBounds=new Bc(s.bounds,this.minzoom,this.maxzoom)),du(s.tiles,this.map._requestManager._customAccessToken),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),e&&e(o)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=Dr(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return Te({},this._options)}loadTile(e,r){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),o={request:this.map._requestManager.transformRequest(i,J.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:je.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(o.request.collectResourceTiming=this._collectResourceTiming,e.actor&&e.state!=="expired")e.state==="loading"?e.reloadCallback=r:e.request=e.actor.send("reloadTile",o,s.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",o,s.bind(this),void 0,!0);else{const n=fx.call({deduped:this._deduped},o,(a,l)=>{a||!l?s.call(this,a):(o.data={cacheControl:l.cacheControl,expires:l.expires,rawData:l.rawData.slice(0)},e.actor&&e.actor.send("loadTile",o,s.bind(this),void 0,!0))},!0);e.request={cancel:n}}function s(n,a){return delete e.request,e.aborted?r(null):n&&n.status!==404?r(n):(a&&a.resourceTiming&&(e.resourceTiming=a.resourceTiming),this.map._refreshExpiredTiles&&a&&e.setExpiryData(a),e.loadVectorData(a,this.map.painter),Ns(this.dispatcher),r(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class pp extends or{constructor(e,r,i,o){super(),this.id=e,this.dispatcher=i,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Te({type:"raster"},r),Te(this,jr(r,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"})),this._tileJSONRequest=hp(this._options,this.map._requestManager,null,null,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new Ue(r)):i&&(Te(this,i),i.bounds&&(this.tileBounds=new Bc(i.bounds,this.minzoom,this.maxzoom)),du(i.tiles),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=Dr(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return Te({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,r){const i=je.devicePixelRatio>=2,o=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=Ye(this.map._requestManager.transformRequest(o,J.Tile),(s,n,a,l)=>(delete e.request,e.aborted?(e.state="unloaded",r(null)):s?(e.state="errored",r(s)):n?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:a,expires:l}),e.setTexture(n,this.map.painter),e.state="loaded",Ns(this.dispatcher),void r(null)):r(null)))}abortTile(e,r){e.request&&(e.request.cancel(),delete e.request),r()}unloadTile(e,r){e.texture&&e.texture instanceof Gt?(e.destroy(!0),e.texture&&e.texture instanceof Gt&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function G3(){return su.workerClass!=null?new su.workerClass:new $.Worker(su.workerUrl)}const fp="mapboxgl_preloaded_worker_pool";class Sn{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Sn.workerCount;)this.workers.push(new G3);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&this.numActive()===0&&(this.workers.forEach(r=>{r.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[fp]}numActive(){return Object.keys(this.active).length}}let La;function Ba(){return La||(La=new Sn),La}Sn.workerCount=2;let Oc,mp,Ri,_p=null;function _x(){return oe()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:mp||Ke.DRACO_URL}const gp=5123,yp=5126,xp={5120:Int8Array,5121:Uint8Array,5122:Int16Array,[gp]:Uint16Array,5125:Uint32Array,[yp]:Float32Array},q3={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",[gp]:"DT_UINT16",5125:"DT_UINT32",[yp]:"DT_FLOAT32"},vp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function gx(t,e,r){const i=r.json.bufferViews.length,o=r.buffers.length;e.bufferView=i,r.json.bufferViews[i]={buffer:o,byteLength:t.byteLength},r.buffers[o]=t}const bp="KHR_draco_mesh_compression";function Z3(t,e){const r=t.extensions&&t.extensions[bp];if(!r)return;const i=new Ri.Decoder,o=bx(e,r.bufferView),s=new Ri.Mesh;if(!i.DecodeArrayToMesh(o,o.byteLength,s))throw new Error("Failed to decode Draco mesh");const n=e.json.accessors[t.indices],a=xp[n.componentType],l=n.count*a.BYTES_PER_ELEMENT,c=Ri._malloc(l);a===Uint16Array?i.GetTrianglesUInt16Array(s,l,c):i.GetTrianglesUInt32Array(s,l,c),gx(Ri.memory.buffer.slice(c,c+l),n,e),Ri._free(c);for(const u of Object.keys(r.attributes)){const h=i.GetAttributeByUniqueId(s,r.attributes[u]),d=e.json.accessors[t.attributes[u]],p=q3[d.componentType],f=d.count*vp[d.type]*xp[d.componentType].BYTES_PER_ELEMENT,m=Ri._malloc(f);i.GetAttributeDataArrayForAllPoints(s,h,Ri[p],f,m),gx(Ri.memory.buffer.slice(m,m+f),d,e),Ri._free(m)}i.destroy(),s.destroy(),delete t.extensions[bp]}const yx=1179937895,xx=new TextDecoder("utf8");function vx(t,e){return new URL(t,e).href}function $3(t,e,r,i){return fetch(vx(t.uri,i)).then(o=>o.arrayBuffer()).then(o=>{e.buffers[r]=o})}function bx(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function H3(t,e,r,i){if(t.uri){const o=vx(t.uri,i);return fetch(o).then(s=>s.blob()).then(s=>$.createImageBitmap(s)).then(s=>{e.images[r]=s})}if(t.bufferView!==void 0){const o=bx(e,t.bufferView),s=new $.Blob([o],{type:t.mimeType});return $.createImageBitmap(s).then(n=>{e.images[r]=n})}}function wx(t,e=0,r){const i={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===yx){const c=new Uint32Array(t,e);let u=2;const h=(c[u++]>>2)-3,d=c[u++]>>2;if(u++,i.json=JSON.parse(xx.decode(c.subarray(u,u+d))),u+=d,u<h){const p=c[u++];u++;const f=e+(u<<2);i.buffers[0]=t.slice(f,f+p)}}else i.json=JSON.parse(xx.decode(new Uint8Array(t,e)));const{buffers:o,images:s,meshes:n,extensionsUsed:a}=i.json;let l=Promise.resolve();if(o){const c=[];for(let u=0;u<o.length;u++){const h=o[u];h.uri?c.push($3(h,i,u,r)):i.buffers[u]||(i.buffers[u]=null)}l=Promise.all(c)}return l.then(()=>{const c=[],u=a&&a.includes(bp);if(u&&c.push(function(){if(!Ri)return Oc||(Oc=function(h){let d,p=null;function f(){d=new Uint8Array(p.buffer)}function m(){throw new Error("Unexpected Draco error.")}const _={a:{a:m,d:function(g,y,v){return d.copyWithin(g,y,y+v)},c:function(g){const y=d.length,v=Math.max(g>>>0,Math.ceil(1.2*y)),b=Math.ceil((v-y)/65536);try{return p.grow(b),f(),!0}catch{return!1}},b:m}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,_):h.then(g=>g.arrayBuffer()).then(g=>WebAssembly.instantiate(g,_))).then(g=>{const{Rb:y,Qb:v,P:b,T:x,X:w,Ja:T,La:E,Qa:M,Va:S,Wa:I,eb:C,jb:k,f:A,e:L,yb:O,zb:U,Ab:R,Bb:B,Db:G,Gb:Z}=g.instance.exports;p=L;const q=(()=>{let X=0,Y=0,K=0,H=0;return ee=>{K&&(y(H),y(X),Y+=K,K=X=0),X||(Y+=128,X=v(Y));const de=ee.length+7&-8;let pe=X;de>=Y&&(K=de,pe=H=v(de));for(let ge=0;ge<ee.length;ge++)d[pe+ge]=ee[ge];return pe}})();return f(),A(),{memory:L,_free:y,_malloc:v,Mesh:class{constructor(){this.ptr=b()}destroy(){x(this.ptr)}},Decoder:class{constructor(){this.ptr=T()}destroy(){k(this.ptr)}DecodeArrayToMesh(X,Y,K){const H=q(X),ee=E(this.ptr,H,Y,K.ptr);return!!w(ee)}GetAttributeByUniqueId(X,Y){return{ptr:M(this.ptr,X.ptr,Y)}}GetTrianglesUInt16Array(X,Y,K){S(this.ptr,X.ptr,Y,K)}GetTrianglesUInt32Array(X,Y,K){I(this.ptr,X.ptr,Y,K)}GetAttributeDataArrayForAllPoints(X,Y,K,H,ee){C(this.ptr,X.ptr,Y.ptr,K,H,ee)}},DT_INT8:O(),DT_UINT8:U(),DT_INT16:R(),DT_UINT16:B(),DT_UINT32:G(),DT_FLOAT32:Z()}})}(fetch(_x())),Oc.then(h=>{Ri=h,Oc=void 0}))}()),s)for(let h=0;h<s.length;h++)c.push(H3(s[h],i,h,r));return(c.length?Promise.all(c):Promise.resolve()).then(()=>{if(u&&n)for(const{primitives:h}of n)for(const d of h)Z3(d,i);return i})})}function Tx(t){return fetch(t).then(e=>e.arrayBuffer()).then(e=>wx(e,0,t))}class Ex{constructor(e,r,i){if(this.triangleCount=r.length/3,this.min=new N(0,0),this.max=new N(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0||i===0)return;const o=e.map(u=>u.x),s=e.map(u=>u.y);this.min=new N(Math.min(...o),Math.min(...s)),this.max=new N(Math.max(...o),Math.max(...s));const n=this.max.sub(this.min);n.x=Math.max(n.x,1),n.y=Math.max(n.y,1);const a=Math.max(n.x,n.y)/i;this.cellsX=Math.max(1,Math.ceil(n.x/a)),this.cellsY=Math.max(1,Math.ceil(n.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let u=0;u<this.triangleCount;u++){const h=e[r[3*u+0]].sub(this.min),d=e[r[3*u+1]].sub(this.min),p=e[r[3*u+2]].sub(this.min),f=Yo(Math.floor(Math.min(h.x,d.x,p.x)),this.xScale,this.cellsX),m=Yo(Math.floor(Math.max(h.x,d.x,p.x)),this.xScale,this.cellsX),_=Yo(Math.floor(Math.min(h.y,d.y,p.y)),this.yScale,this.cellsY),g=Yo(Math.floor(Math.max(h.y,d.y,p.y)),this.yScale,this.cellsY),y=new N(0,0),v=new N(0,0),b=new N(0,0),x=new N(0,0);for(let w=_;w<=g;++w){y.y=v.y=w*a,b.y=x.y=(w+1)*a;for(let T=f;T<=m;++T)y.x=b.x=T*a,v.x=x.x=(T+1)*a,(Sd(h,d,p,y,v,x)||Sd(h,d,p,y,x,b))&&l.push({cellIdx:w*this.cellsX+T,triIdx:u})}}if(l.length===0)return;l.sort((u,h)=>u.cellIdx-h.cellIdx||u.triIdx-h.triIdx);let c=0;for(;c<l.length;){const u=l[c].cellIdx,h={start:this.payload.length,len:0};for(;c<l.length&&l[c].cellIdx===u;)++h.len,this.payload.push(l[c++].triIdx);this.cells[u]=h}}query(e,r,i){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>r.x||e.y>this.max.y||this.min.y>r.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let l=0;l<this.lookup.length;l++)this.lookup[l]=0;const o=Yo(e.x-this.min.x,this.xScale,this.cellsX),s=Yo(r.x-this.min.x,this.xScale,this.cellsX),n=Yo(e.y-this.min.y,this.yScale,this.cellsY),a=Yo(r.y-this.min.y,this.yScale,this.cellsY);for(let l=n;l<=a;l++)for(let c=o;c<=s;c++){const u=this.cells[l*this.cellsX+c];if(u)for(let h=0;h<u.len;h++){const d=this.payload[u.start+h],p=Math.floor(d/8),f=1<<d%8;if(!(this.lookup[p]&f)&&(this.lookup[p]|=f,i.push(d),i.length===this.triangleCount))return}}}}function Yo(t,e,r){return Math.max(0,Math.min(r-1,Math.floor(t*e)))}function Cs(t,e){const r=t.json.bufferViews[e.bufferView];return new xp[e.componentType](t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*vp[e.type])}function W3(t,e,r){const i=t.indices,o=t.attributes,s={};s.indexArray=new nr;const n=e.json.accessors[i],a=n.count/3;s.indexArray.reserve(a);const l=Cs(e,n);for(let d=0;d<a;d++)s.indexArray.emplaceBack(l[3*d],l[3*d+1],l[3*d+2]);s.indexArray._trim(),s.vertexArray=new ys;const c=e.json.accessors[o.POSITION];s.vertexArray.reserve(c.count);const u=Cs(e,c);for(let d=0;d<c.count;d++)s.vertexArray.emplaceBack(u[3*d],u[3*d+1],u[3*d+2]);if(s.vertexArray._trim(),s.aabb=new Pt(c.min,c.max),s.centroid=function(d,p){const f=[0,0,0],m=d.length;if(m>0){for(let _=0;_<m;_++){const g=3*d[_];f[0]+=p[g],f[1]+=p[g+1],f[2]+=p[g+2]}f[0]/=m,f[1]/=m,f[2]/=m}return f}(l,u),o.COLOR_0!==void 0){const d=e.json.accessors[o.COLOR_0],p=vp[d.type];if(d.componentType===yp){s.colorArray=p===3?new ys:new lo,s.colorArray.reserve(d.count);const f=Cs(e,d);if(p===3)for(let m=0;m<d.count;m++)s.colorArray.emplaceBack(f[3*m],f[3*m+1],f[3*m+2]);else for(let m=0;m<d.count;m++)s.colorArray.emplaceBack(f[4*m],f[4*m+1],f[4*m+2],f[4*m+3]);s.colorArray._trim()}else if(d.componentType===gp&&p===4){s.colorArray=new lo,s.colorArray.resize(d.count);const f=Cs(e,d),m=1/65535,_=s.colorArray.float32;for(let g=0;g<4*f.length;++g)_[g]=f[g]*m}else F(`glTF color buffer parsing for accessor ${JSON.stringify(d)} is not supported`)}if(o.NORMAL!==void 0){s.normalArray=new ys;const d=e.json.accessors[o.NORMAL];s.normalArray.reserve(d.count);const p=Cs(e,d);for(let f=0;f<d.count;f++)s.normalArray.emplaceBack(p[3*f],p[3*f+1],p[3*f+2]);s.normalArray._trim()}if(o.TEXCOORD_0!==void 0&&r.length>0){s.texcoordArray=new oa;const d=e.json.accessors[o.TEXCOORD_0];s.texcoordArray.reserve(d.count);const p=Cs(e,d);for(let f=0;f<d.count;f++)s.texcoordArray.emplaceBack(p[2*f],p[2*f+1]);s.texcoordArray._trim()}const h=t.material;return s.material=function(d,p){const{emissiveFactor:f=[0,0,0],alphaMode:m="OPAQUE",alphaCutoff:_=.5,normalTexture:g,occlusionTexture:y,emissiveTexture:v,doubleSided:b}=d,{baseColorFactor:x=[1,1,1,1],metallicFactor:w=1,roughnessFactor:T=1,baseColorTexture:E,metallicRoughnessTexture:M}=d.pbrMetallicRoughness||{};return{pbrMetallicRoughness:{baseColorFactor:new Qe(...x),metallicFactor:w,roughnessFactor:T,baseColorTexture:E?p[E.index]:void 0,metallicRoughnessTexture:M?p[M.index]:void 0},doubleSided:b,emissiveFactor:f,alphaMode:m,alphaCutoff:_,normalTexture:g?p[g.index]:void 0,occlusionTexture:y?p[y.index]:void 0,emissionTexture:v?p[v.index]:void 0,defined:d.defined===void 0}}(h!==void 0?e.json.materials[h]:{defined:!1},r),o._FEATURE_RGBA4444!==void 0&&(s.featureData=new Uint32Array(Cs(e,e.json.accessors[o._FEATURE_RGBA4444]).buffer)),s}function Mx(t,e,r){const{matrix:i,rotation:o,translation:s,scale:n,mesh:a,extras:l,children:c}=t,u={};if(u.matrix=i||V.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],n||[1,1,1]),a!==void 0){u.meshes=r[a];const h=u.anchor=[0,0];for(const d of u.meshes){const{min:p,max:f}=d.aabb;h[0]+=p[0]+f[0],h[1]+=p[1]+f[1]}h[0]=Math.floor(h[0]/u.meshes.length/2),h[1]=Math.floor(h[1]/u.meshes.length/2)}if(l&&(l.id&&(u.id=l.id),l.lights&&(u.lights=function(h){if(!h.length)return[];const d=function(g){const y=atob(g),v=new Uint8Array(y.length);for(let b=0;b<y.length;b++)v[b]=y.codePointAt(b);return v}(h),p=[],f=d.length/24,m=new Uint16Array(d.buffer),_=new Float32Array(d.buffer);for(let g=0;g<f;g++){const y=m[2*g*6]/30,v=m[2*g*6+1]/30,b=m[2*g*6+10]/100,x=_[6*g+1],w=_[6*g+2],T=_[6*g+3],E=_[6*g+4],M=T-x,S=E-w,I=Math.hypot(M,S);p.push({pos:[x+.5*M,w+.5*S,v],normal:[S/I,-M/I,0],width:I,height:y,depth:b,points:[x,w,T,E]})}return p}(l.lights))),c){const h=[];for(const d of c)h.push(Mx(e.json.nodes[d],e,r));u.children=h}return u}function X3(t){if(t.vertices.length===0||t.indices.length===0)return null;const[e,r]=[t.vertices[0].clone(),t.vertices[0].clone()];for(let n=1;n<t.vertices.length;++n){const a=t.vertices[n];e.x=Math.min(e.x,a.x),e.y=Math.min(e.y,a.y),r.x=Math.max(r.x,a.x),r.y=Math.max(r.y,a.y)}const i=Math.ceil(Math.max(r.x-e.x,r.y-e.y)/256),o=Math.max(8,i),s=new Ex(t.vertices,t.indices,o);return{vertices:t.vertices,indices:t.indices,grid:s,min:e,max:r}}function Y3(t){if(!t.extras||!t.extras.ground)return null;const e=t.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;const r=e[0];if(!r||!Array.isArray(r)||r.length===0)return null;const i=[];for(const n of r){if(!Array.isArray(n)||n.length!==2)continue;const a=n[0],l=n[1];typeof a=="number"&&typeof l=="number"&&i.push(new N(a,l))}if(i.length<3)return null;i.length>1&&i[i.length-1].equals(i[0])&&i.pop();let o=0;for(let n=0;n<i.length;n++){const a=i[n],l=i[(n+1)%i.length],c=i[(n+2)%i.length];o+=(a.x-l.x)*(c.y-l.y)-(c.x-l.x)*(a.y-l.y)}o>0&&i.reverse();const s=Kl(i.flatMap(n=>[n.x,n.y]),[]);return s.length===0?null:{vertices:i,indices:s}}function J3(t){const e=[],r=[];let i=0;for(const o of t){i=e.length;const s=o.vertexArray.float32,n=o.indexArray.uint16;for(let a=0;a<o.vertexArray.length;a++)e.push(new N(s[3*a+0],s[3*a+1]));for(let a=0;a<3*o.indexArray.length;a++)r.push(n[a]+i)}if(r.length%3!=0)return null;for(let o=0;o<r.length;o+=3){const s=e[r[o+0]],n=e[r[o+1]],a=e[r[o+2]];(s.x-n.x)*(a.y-n.y)-(a.x-n.x)*(s.y-n.y)>0&&([r[o+1],r[o+2]]=[r[o+2],r[o+1]])}return{vertices:e,indices:r}}function wp(t){const e=function(l,c){const u=[],h=$.WebGL2RenderingContext;if(l.json.textures)for(const d of l.json.textures){const p={magFilter:h.LINEAR,minFilter:h.NEAREST,wrapS:h.REPEAT,wrapT:h.REPEAT};d.sampler!==void 0&&Object.assign(p,l.json.samplers[d.sampler]),u.push({image:c[d.source],sampler:p,uploaded:!1})}return u}(t,t.images),r=function(l,c){const u=[];for(const h of l.json.meshes){const d=[];for(const p of h.primitives)d.push(W3(p,l,c));u.push(d)}return u}(t,e),{scenes:i,scene:o,nodes:s}=t.json,n=i?i[o||0].nodes:s,a=[];for(const l of n)a.push(Mx(s[l],t,r));return function(l,c,u){const h={},d=new Set;for(let p=0;p<l.length;p++){const f=u[c[p]];if(!f.extras)continue;const m=f.extras["mapbox:footprint:version"],_=f.extras["mapbox:footprint:id"];(m||_)&&d.add(p),m==="1.0.0"&&_&&(h[_]=p)}for(let p=0;p<l.length;p++){if(d.has(p))continue;const f=l[p],m=u[c[p]];if(!m.extras)continue;let _=null;f.id in h&&(_=J3(l[h[f.id]].meshes)),_||(_=Y3(m)),_&&(f.footprint=X3(_))}if(d.size>0){const p=Array.from(d.values()).sort((f,m)=>f-m);for(let f=p.length-1;f>=0;f--)l.splice(p[f],1)}}(a,n,t.json.nodes),a}function K3(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,i=t.aabb.min[1]-1,o=Ms/(t.aabb.max[0]-r+2),s=Ms/(t.aabb.max[1]-i+2);for(let n=0;n<e.length;n+=3){const a=e[n+2],l=(e[n+0]-r)*o|0,c=(e[n+1]-i)*s|0;a>t.heightmap[c*Ms+l]&&(t.heightmap[c*Ms+l]=a)}}function Q3(t,e){const r={};r.indexArray=new nr,r.indexArray.reserve(4*t.length),r.vertexArray=new ys,r.vertexArray.reserve(10*t.length),r.colorArray=new lo,r.vertexArray.reserve(10*t.length);let i=0;for(const n of t){const a=Math.min(10,Math.max(4,1.3*n.height))*e,l=[-n.normal[1],n.normal[0],0],c=Math.min(.29,.1*n.width/n.depth),u=n.width-2*n.depth*e*(c+.01),h=D.scaleAndAdd([],n.pos,l,u/2),d=D.scaleAndAdd([],n.pos,l,-u/2),p=[h[0],h[1],h[2]+n.height],f=[d[0],d[1],d[2]+n.height],m=D.scaleAndAdd([],n.normal,l,c);D.scale(m,m,a);const _=D.scaleAndAdd([],n.normal,l,-c);D.scale(_,_,a),D.add(m,h,m),D.add(_,d,_),h[2]+=.1,d[2]+=.1,r.vertexArray.emplaceBack(m[0],m[1],m[2]),r.vertexArray.emplaceBack(_[0],_[1],_[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(m[0],m[1],m[2]),r.vertexArray.emplaceBack(_[0],_[1],_[2]);const g=u/a/2;r.colorArray.emplaceBack(-g-c,-1,g,.8),r.colorArray.emplaceBack(g+c,-1,g,.8),r.colorArray.emplaceBack(-g,0,g,1.3),r.colorArray.emplaceBack(g,0,g,1.3),r.colorArray.emplaceBack(g+c,-.8,g,.7),r.colorArray.emplaceBack(g+c,-.8,g,.7),r.colorArray.emplaceBack(0,0,g,1.3),r.colorArray.emplaceBack(0,0,g,1.3),r.colorArray.emplaceBack(g+c,-1.2,g,.8),r.colorArray.emplaceBack(g+c,-1.2,g,.8),r.indexArray.emplaceBack(6+i,4+i,8+i),r.indexArray.emplaceBack(7+i,9+i,5+i),r.indexArray.emplaceBack(0+i,1+i,2+i),r.indexArray.emplaceBack(1+i,3+i,2+i),i+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Qe.white,o.pbrMetallicRoughness=s,r.material=o,r.aabb=new Pt([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}Ee(Ex,"TriangleGridIndex");const Tp={vector:mx,raster:pp,"raster-dem":class extends pp{constructor(t,e,r,i){super(t,e,r,i),this.type="raster-dem",this.maxzoom=22,this._options=Te({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}loadTile(t,e){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(o,s){o&&(t.state="errored",e(o)),s&&(t.dem=s,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",e(null))}t.request=Ye(this.map._requestManager.transformRequest(r,J.Tile),function(o,s,n,a){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(o)t.state="errored",e(o);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:a});const c=$.ImageBitmap&&s instanceof $.ImageBitmap&&af(),u=1-(s.width-((l=s.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;u<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const h=c?s:je.getImageData(s,u),d={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:h,encoding:this.encoding,padding:u};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",d,i.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(t){const e=t.canonical,r=Math.pow(2,e.z),i=(e.x-1+r)%r,o=e.x===0?t.wrap-1:t.wrap,s=(e.x+1+r)%r,n=e.x+1===r?t.wrap+1:t.wrap,a={};return a[new mt(t.overscaledZ,o,e.z,i,e.y).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new mt(t.overscaledZ,o,e.z,i,e.y-1).key]={backfilled:!1},a[new mt(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<r&&(a[new mt(t.overscaledZ,o,e.z,i,e.y+1).key]={backfilled:!1},a[new mt(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new mt(t.overscaledZ,n,e.z,s,e.y+1).key]={backfilled:!1}),a}},geojson:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(i),this._data=e.data,this._options=Te({},e),this._collectResourceTiming=e.collectResourceTiming,e.maxzoom!==void 0&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const o=W/this.tileSize;this.workerOptions=Te({source:this.id,scope:this.scope,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(e.buffer!==void 0?e.buffer:128)*o,tolerance:(e.tolerance!==void 0?e.tolerance:.375)*o,extent:W,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:e.clusterMaxZoom!==void 0?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:W,radius:(e.clusterRadius!==void 0?e.clusterRadius:50)*o,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id,scope:this.scope},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id,scope:this.scope},e),this}getClusterLeaves(t,e,r,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:t,limit:e,offset:r},i),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new ae("dataloading",{dataType:"source"})),this._loaded=!1;const t=Te({},this.workerOptions);t.scope=this.scope;const e=this._data;typeof e=="string"?(t.request=this.map._requestManager.transformRequest(je.resolveURL(e),J.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(e),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,(r,i)=>{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new Ue(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(o.resourceTiming=i.resourceTiming[this.id]),this.fire(new ae("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,e){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:je.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(r,i,(o,s)=>(delete t.request,t.destroy(),t.aborted?e(null):o?e(o):(t.loadVectorData(s,this.map.painter,r==="reloadTile"),e(null))),void 0,r==="loadTile")}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Te({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends vi{constructor(t,e,r,i){super(t,e,r,i),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,J.Source).url);(function(e,r){const i=$.document.createElement("video");i.muted=!0,i.onloadstart=function(){r(null,i)};for(let o=0;o<e.length;o++){const s=$.document.createElement("source");_e(e[o])||(i.crossOrigin="Anonymous"),s.src=e[o],i.appendChild(s)}})(this.urls,(e,r)=>{this._loaded=!0,e?this.fire(new Ue(e)):r&&(this.video=r,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(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new Ue(new be(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new Gt(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:vi,model:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="model",this.models=[],this._loaded=!1,this._options=e}load(){const t=[];for(const e in this._options.models){const r=this._options.models[e],i=Tx(this.map._requestManager.transformRequest(r.uri,J.Model).url).then(o=>{if(!o)return;const s=wp(o),n=new x0(e,r.position,r.orientation,s);n.computeBoundsAndApplyParent(),this.models.push(n)}).catch(o=>{this.fire(new Ue(new Error(`Could not load model ${e} from ${r.uri}: ${o.message}`)))});t.push(i)}return Promise.allSettled(t).then(()=>{this._loaded=!0,this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this.fire(new Ue(new Error(`Could not load models: ${e.message}`)))})}onAdd(t){this.map=t,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(t,e){}serialize(){return{type:"model"}}},"batched-model":class extends or{constructor(t,e,r,i){super(),this.type="batched-model",this.id=t,this.tileSize=512,this._options=e,this.tiles=this._options.tiles,this.maxzoom=e.maxzoom||19,this.minzoom=e.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=r,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(i)}onAdd(t){this.map=t,this.load()}load(t){this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"}));const e=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=hp(this._options,this.map._requestManager,e,r,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?(e&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${e}`),r&&r.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new Ue(i))):o&&(Te(this,o),o.bounds&&(this.tileBounds=new Bc(o.bounds,this.minzoom,this.maxzoom)),du(o.tiles,this.map._requestManager._customAccessToken),this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}hasTransition(){return!1}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loaded(){return this._loaded}loadTile(t,e){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,J.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&t.state!=="expired")if(t.state==="loading")t.reloadCallback=e;else{if(t.buckets){const s=Object.values(t.buckets);for(const n of s)n.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",i,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);function o(s,n){return t.aborted?e(null):s&&s.status!==404?e(s):(n&&(n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(n),t.buckets={...t.buckets,...n.buckets}),t.state="loaded",void e(null))}}serialize(){return Te({},this._options)}},canvas:class extends vi{constructor(t,e,r,i){super(t,e,r,i),e.coordinates?Array.isArray(e.coordinates)&&e.coordinates.length===4&&!e.coordinates.some(o=>!Array.isArray(o)||o.length!==2||o.some(s=>typeof s!="number"))||this.fire(new Ue(new be(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Ue(new be(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&typeof e.animate!="boolean"&&this.fire(new Ue(new be(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?typeof e.canvas=="string"||e.canvas instanceof $.HTMLCanvasElement||this.fire(new Ue(new be(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new Ue(new be(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=e.animate===void 0||e.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 Ue(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const e=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof Tc||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Gt(e,this.canvas,e.gl.RGBA,{premultiply:!0}),this._prepareData(e)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends or{constructor(t,e,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=e,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new Ue(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new Ue(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Bc(this._implementation.bounds,this.minzoom,this.maxzoom)),e.update=this._update.bind(this),e.clearTiles=this._clearTiles.bind(this),e.coveringTiles=this._coveringTiles.bind(this),Te(this,jr(e,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return jr(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new ae("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new ae("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:r,z:i}=t.canonical;return this._implementation.hasTile({x:e,y:r,z:i})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const{x:r,y:i,z:o}=t.tileID.canonical,s=new $.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:s.signal})).then(function(n){return delete t.request,t.aborted?(t.state="unloaded",e(null)):n===void 0?(t.state="errored",e(null)):n===null?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",e(null)):function(a){return a instanceof $.ImageData||a instanceof $.HTMLCanvasElement||a instanceof $.ImageBitmap||a instanceof $.HTMLImageElement}(n)?(this.loadTileData(t,n),t.state="loaded",void e(null)):(t.state="errored",e(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(n=>{n.code!==20&&(t.state="errored",e(n))}),t.request.cancel=()=>s.abort()}loadTileData(t,e){t.setTexture(e,this._map.painter)}unloadTile(t,e){if(t.texture&&t.texture instanceof Gt?(t.destroy(!0),t.texture&&t.texture instanceof Gt&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:r,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:r,y:i,z:o})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z}))}_clearTiles(){const t=Dr(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new ae("data",{dataType:"source",sourceDataType:"content"}))}}},Ep=function(t,e,r,i){const o=new Tp[e.type](t,e,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return pr(["load","abort","unload","serialize","prepare"],o),o};function eE(t,e){const r=V.identity([]);return V.scale(r,r,[.5*t.width,.5*-t.height,1]),V.translate(r,r,[1,-1,0]),V.multiply(r,r,t.calculateProjMatrix(e.toUnwrapped())),Float32Array.from(r)}function tE(t,e,r,i,o,s,n,a=!1){const l=t.tilesIn(i,n,a);l.sort(Sx);const c=[];for(const h of l)c.push({wrappedTileID:h.tile.tileID.wrapped().key,queryResults:h.tile.queryRenderedFeatures(e,r,t._state,h,o,s,eE(t.transform,h.tile.tileID),a)});const u=function(h){const d={},p={};for(const f of h){const m=f.queryResults,_=f.wrappedTileID,g=p[_]=p[_]||{};for(const y in m){const v=m[y],b=g[y]=g[y]||{},x=d[y]=d[y]||[];for(const w of v)b[w.featureIndex]||(b[w.featureIndex]=!0,x.push(w))}}return d}(c);for(const h in u)u[h].forEach(d=>{const p=d.feature,f=p.layer;f&&f.type!=="background"&&f.type!=="sky"&&f.type!=="slot"&&(p.source=f.source,f["source-layer"]&&(p.sourceLayer=f["source-layer"]),p.state=p.id!==void 0?t.getFeatureState(f["source-layer"],p.id):{})});return u}function rE(t,e){const r=t.getRenderableIds().map(s=>t.getTileByID(s)),i=[],o={};for(let s=0;s<r.length;s++){const n=r[s],a=n.tileID.canonical.key;o[a]||(o[a]=!0,n.querySourceFeatures(i,e))}return i}function Sx(t,e){const r=t.tileID,i=e.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}class iE{constructor(e){this.style=e}processLayersChanged(){this.layers=[];for(const e in this.style._mergedLayers){const r=this.style._mergedLayers[e];if(r.type==="fill-extrusion")this.layers.push(r);else if(r.type==="model"){const i=this.style.getLayerSource(r);i&&i.type==="batched-model"&&this.layers.push(r)}}}updateZOffset(e,r){this.currentBuildingBuckets=[];for(let o=0;o<this.layers.length;++o){const s=this.layers[o],n=this.style.getLayerSourceCache(s);let a=1;s.type==="fill-extrusion"&&(a=s.paint.get("fill-extrusion-opacity")>0?s.paint.get("fill-extrusion-vertical-scale"):0);let l=n?n.getTile(r):null;if(!l&&n&&r.canonical.z>n.getSource().minzoom){let c=r.scaledTo(Math.min(n.getSource().maxzoom,r.overscaledZ-1));for(;c.overscaledZ>=n.getSource().minzoom&&(l=n.getTile(c),!l&&c.overscaledZ!==0);)c=c.scaledTo(c.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:l?l.getBucket(s):null,tileID:l?l.tileID:r,verticalScale:a})}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o<e.symbolInstances.length;o++){const s=e.symbolInstances.get(o),n=s.zOffset,a=this._getHeightAtTileOffset(r,s.tileAnchorX,s.tileAnchorY);s.zOffset=a!==-1?a:n,i||n===s.zOffset||(i=!0),e.hasAnyZOffset||s.zOffset===0||(e.hasAnyZOffset=!0)}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(e,r,i,o){let s=r,n=i;if(e.canonical.z!==o.canonical.z){const a=o.canonical,l=1/(1<<e.canonical.z-a.z);s=(r+e.canonical.x*W)*l-a.x*W|0,n=(i+e.canonical.y*W)*l-a.y*W|0}return{tileX:s,tileY:n}}_getHeightAtTileOffset(e,r,i){let o;for(let s=0;s<this.layers.length;++s){if(this.layers[s].type!=="fill-extrusion")continue;const{bucket:n,tileID:a,verticalScale:l}=this.currentBuildingBuckets[s];if(!n)continue;const{tileX:c,tileY:u}=this._mapCoordToOverlappingTile(e,r,i,a),h=n.getHeightAtTileCoord(c,u);if(h&&h.height!==void 0){if(!h.hidden)return h.height*l;o=h.height}}for(let s=0;s<this.layers.length;++s){if(this.layers[s].type!=="model")continue;const{bucket:n,tileID:a}=this.currentBuildingBuckets[s];if(!n)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,r,i,a),u=n.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return u.height===void 0&&o!==void 0?Math.min(u.maxHeight,o)*u.verticalScale:(u.height||0)*u.verticalScale}return-1}}var Ax=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function oE(t,e){const r={};for(const i in t)i!=="ref"&&(r[i]=t[i]);return Ax.forEach(i=>{i in e&&(r[i]=e[i])}),r}function Ix(t){t=t.slice();const e=Object.create(null);for(let r=0;r<t.length;r++)e[t[r].id]=t[r];for(let r=0;r<t.length;r++)"ref"in t[r]&&(t[r]=oE(t[r],e[t[r].ref]));return t}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",setImportUrl:"setImportUrl",setImportData:"setImportData",setImportConfig:"setImportConfig"};function Cx(t,e,r){r.push({command:gt.addSource,args:[t,e[t]]})}function zx(t,e,r){e.push({command:gt.removeSource,args:[t]}),r[t]=!0}function sE(t,e,r,i){zx(t,r,i),Cx(t,e,r)}function nE(t,e,r){let i;for(i in t[r])if(t[r].hasOwnProperty(i)&&i!=="data"&&!dt(t[r][i],e[r][i]))return!1;for(i in e[r])if(e[r].hasOwnProperty(i)&&i!=="data"&&!dt(t[r][i],e[r][i]))return!1;return!0}function Fc(t,e,r,i,o,s){let n;for(n in e=e||{},t=t||{})t.hasOwnProperty(n)&&(dt(t[n],e[n])||r.push({command:s,args:[i,n,e[n],o]}));for(n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(dt(t[n],e[n])||r.push({command:s,args:[i,n,e[n],o]}))}function Nc(t){return t.id}function Uc(t,e){return t[e.id]=e,t}class aE{constructor(e,r){this.reset(e,r)}reset(e,r){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(r||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=Se(e,0,1);let r=1,i=this._distances[r];const o=e*this.paddedLength+this.padding;for(;i<o&&r<this._distances.length;)i=this._distances[++r];const s=r-1,n=this._distances[s],a=i-n,l=a>0?(o-n)/a:0;return this.points[s].mult(1-l).add(this.points[r].mult(l))}}class Dx{constructor(e,r,i){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(r/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)o.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=r,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/r,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,r,i,o,s){this._forEachCell(r,i,o,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(o),this.bboxes.push(s)}insertCircle(e,r,i,o){this._forEachCell(r-o,i-o,r+o,i+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(r),this.circles.push(i),this.circles.push(o)}_insertBoxCell(e,r,i,o,s,n){this.boxCells[s].push(n)}_insertCircleCell(e,r,i,o,s,n){this.circleCells[s].push(n)}_query(e,r,i,o,s,n){if(i<0||e>this.width||o<0||r>this.height)return!s&&[];const a=[];if(e<=0&&r<=0&&this.width<=i&&this.height<=o){if(s)return!0;for(let l=0;l<this.boxKeys.length;l++)a.push({key:this.boxKeys[l],x1:this.bboxes[4*l],y1:this.bboxes[4*l+1],x2:this.bboxes[4*l+2],y2:this.bboxes[4*l+3]});for(let l=0;l<this.circleKeys.length;l++){const c=this.circles[3*l],u=this.circles[3*l+1],h=this.circles[3*l+2];a.push({key:this.circleKeys[l],x1:c-h,y1:u-h,x2:c+h,y2:u+h})}return n?a.filter(n):a}return this._forEachCell(e,r,i,o,this._queryCell,a,{hitTest:s,seenUids:{box:{},circle:{}}},n),s?a.length>0:a}_queryCircle(e,r,i,o,s){const n=e-i,a=e+i,l=r-i,c=r+i;if(a<0||n>this.width||c<0||l>this.height)return!o&&[];const u=[];return this._forEachCell(n,l,a,c,this._queryCellCircle,u,{hitTest:o,circle:{x:e,y:r,radius:i},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(e,r,i,o,s){return this._query(e,r,i,o,!1,s)}hitTest(e,r,i,o,s){return this._query(e,r,i,o,!0,s)}hitTestCircle(e,r,i,o){return this._queryCircle(e,r,i,!0,o)}_queryCell(e,r,i,o,s,n,a,l){const c=a.seenUids,u=this.boxCells[s];if(u!==null){const d=this.bboxes;for(const p of u)if(!c.box[p]){c.box[p]=!0;const f=4*p;if(e<=d[f+2]&&r<=d[f+3]&&i>=d[f+0]&&o>=d[f+1]&&(!l||l(this.boxKeys[p]))){if(a.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const h=this.circleCells[s];if(h!==null){const d=this.circles;for(const p of h)if(!c.circle[p]){c.circle[p]=!0;const f=3*p;if(this._circleAndRectCollide(d[f],d[f+1],d[f+2],e,r,i,o)&&(!l||l(this.circleKeys[p]))){if(a.hitTest)return n.push(!0),!0;{const m=d[f],_=d[f+1],g=d[f+2];n.push({key:this.circleKeys[p],x1:m-g,y1:_-g,x2:m+g,y2:_+g})}}}}}_queryCellCircle(e,r,i,o,s,n,a,l){const c=a.circle,u=a.seenUids,h=this.boxCells[s];if(h!==null){const p=this.bboxes;for(const f of h)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(c.x,c.y,c.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!l||l(this.boxKeys[f])))return n.push(!0),!0}}const d=this.circleCells[s];if(d!==null){const p=this.circles;for(const f of d)if(!u.circle[f]){u.circle[f]=!0;const m=3*f;if(this._circlesCollide(p[m],p[m+1],p[m+2],c.x,c.y,c.radius)&&(!l||l(this.circleKeys[f])))return n.push(!0),!0}}}_forEachCell(e,r,i,o,s,n,a,l){const c=this._convertToXCellCoord(e),u=this._convertToYCellCoord(r),h=this._convertToXCellCoord(i),d=this._convertToYCellCoord(o);for(let p=c;p<=h;p++)for(let f=u;f<=d;f++)if(s.call(this,e,r,i,o,this.xCellCount*f+p,n,a,l))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,r,i,o,s,n){const a=o-e,l=s-r,c=i+n;return c*c>a*a+l*l}_circleAndRectCollide(e,r,i,o,s,n,a){const l=(n-o)/2,c=Math.abs(e-(o+l));if(c>l+i)return!1;const u=(a-s)/2,h=Math.abs(r-(s+u));if(h>u+i)return!1;if(c<=l||h<=u)return!0;const d=c-l,p=h-u;return d*d+p*p<=i*i}}const Ji=100;class lE{constructor(e,r,i=new Dx(e.width+200,e.height+200,25),o=new Dx(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Ji,this.screenBottomBoundary=e.height+Ji,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=r}placeCollisionBox(e,r,i,o,s,n,a,l){let c=i.projectedAnchorX,u=i.projectedAnchorY,h=i.projectedAnchorZ;const d=i.elevation,p=i.tileID,f=e.getProjection();if(d&&p){const[w,T,E]=f.upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),M=f.upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;c+=w*d*M,u+=T*d*M,h+=E*d*M}const m=this.projectAndGetPerspectiveRatio(a,c,u,h,i.tileID,f.name==="globe"||!!d||this.transform.pitch>0,f),_=n*m.perspectiveRatio,g=(i.x1*r+o.x-i.padding)*_+m.point.x,y=(i.y1*r+o.y-i.padding)*_+m.point.y,v=(i.x2*r+o.x+i.padding)*_+m.point.x,b=(i.y2*r+o.y+i.padding)*_+m.point.y,x=m.perspectiveRatio<=.55||m.occluded;return!this.isInsideGrid(g,y,v,b)||!s&&this.grid.hitTest(g,y,v,b,l)||x?{box:[],offscreen:!1,occluded:m.occluded}:{box:[g,y,v,b],offscreen:this.isOffscreen(g,y,v,b),occluded:!1}}placeCollisionCircles(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m){const _=[],g=this.transform.elevation,y=e.getProjection(),v=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,b=new N(i.tileAnchorX,i.tileAnchorY);let{x,y:w,z:T}=y.projectTilePoint(b.x,b.y,m.canonical);if(v){const[U,R,B]=v(b);x+=U,w+=R,T+=B}const E=y.name==="globe",M=this.projectAndGetPerspectiveRatio(a,x,w,T,m,E||!!g||this.transform.pitch>0,y),{perspectiveRatio:S}=M,I=(h?n/S:n*S)/xr,C=Pi(x,w,T,l),k=M.signedDistanceFromCamera>0?c0(I,s,i.lineOffsetX*I,i.lineOffsetY*I,!1,C,b,i,o,l,{},g&&!h?v:null,h&&!!g,y,m,h):null;let A=!1,L=!1,O=!0;if(k&&!M.occluded){const U=.5*p*S+f,R=new N(-100,-100),B=new N(this.screenRightBoundary,this.screenBottomBoundary),G=new aE,{first:Z,last:q}=k,X=Z.path.length;let Y=[];for(let ee=X-1;ee>=1;ee--)Y.push(Z.path[ee]);for(let ee=1;ee<q.path.length;ee++)Y.push(q.path[ee]);const K=2.5*U;c&&(Y=Y.map(([ee,de,pe],ge)=>(v&&!E&&(pe=v(ge<X-1?Z.tilePath[X-1-ge]:q.tilePath[ge-X+2])[2]),Pi(ee,de,pe,c))),Y.some(ee=>ee[3]<=0)&&(Y=[]));let H=[];if(Y.length>0){let ee=1/0,de=-1/0,pe=1/0,ge=-1/0;for(const xe of Y)ee=Math.min(ee,xe[0]),pe=Math.min(pe,xe[1]),de=Math.max(de,xe[0]),ge=Math.max(ge,xe[1]);de>=R.x&&ee<=B.x&&ge>=R.y&&pe<=B.y&&(H=[Y.map(xe=>new N(xe[0],xe[1]))],(ee<R.x||de>B.x||pe<R.y||ge>B.y)&&(H=ky(H,R.x,R.y,B.x,B.y)))}for(const ee of H){G.reset(ee,.25*U);let de=0;de=G.length<=.5*U?1:Math.ceil(G.paddedLength/K)+1;for(let pe=0;pe<de;pe++){const ge=pe/Math.max(de-1,1),xe=G.lerp(ge),Oe=xe.x+Ji,Ie=xe.y+Ji;_.push(Oe,Ie,U,0);const ht=Oe-U,st=Ie-U,Be=Oe+U,Re=Ie+U;if(O=O&&this.isOffscreen(ht,st,Be,Re),L=L||this.isInsideGrid(ht,st,Be,Re),!r&&this.grid.hitTestCircle(Oe,Ie,U,d)&&(A=!0,!u))return{circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return{circles:!u&&A||!L?[]:_,offscreen:O,collisionDetected:A,occluded:M.occluded}}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const r=[];let i=1/0,o=1/0,s=-1/0,n=-1/0;for(const u of e){const h=new N(u.x+Ji,u.y+Ji);i=Math.min(i,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x),n=Math.max(n,h.y),r.push(h)}const a=this.grid.query(i,o,s,n).concat(this.ignoredGrid.query(i,o,s,n)),l={},c={};for(const u of a){const h=u.key;l[h.bucketInstanceId]===void 0&&(l[h.bucketInstanceId]={}),l[h.bucketInstanceId][h.featureIndex]||Bg(r,[new N(u.x1,u.y1),new N(u.x2,u.y1),new N(u.x2,u.y2),new N(u.x1,u.y2)])&&(l[h.bucketInstanceId][h.featureIndex]=!0,c[h.bucketInstanceId]===void 0&&(c[h.bucketInstanceId]=[]),c[h.bucketInstanceId].push(h.featureIndex))}return c}insertCollisionBox(e,r,i,o,s){(r?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:o,collisionGroupID:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,r,i,o,s){const n=r?this.ignoredGrid:this.grid,a={bucketInstanceId:i,featureIndex:o,collisionGroupID:s};for(let l=0;l<e.length;l+=4)n.insertCircle(a,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,r,i,o,s,n,a){const l=[r,i,o,1];let c=!1;o||this.transform.pitch>0?(Mt.transformMat4(l,l,e),this.fogState&&s&&a.name!=="globe"&&(c=function(h,d,p,f,m,_){const g=_.calculateFogTileMatrix(m),y=[d,p,f];return D.transformMat4(y,y,g),Lc(h,D.length(y),_.pitch,_._fov)}(this.fogState,r,i,o,s.toUnwrapped(),this.transform)>.9)):f0(l,l,e);const u=l[3];return{point:new N((l[0]/u+1)/2*this.transform.width+Ji,(-l[1]/u+1)/2*this.transform.height+Ji),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:n&&l[2]>u||c}}isOffscreen(e,r,i,o){return i<Ji||e>=this.screenRightBoundary||o<Ji||r>this.screenBottomBoundary}isInsideGrid(e,r,i,o){return i>=0&&e<this.gridRightBoundary&&o>=0&&r<this.gridBottomBoundary}getViewportMatrix(){const e=V.identity([]);return V.translate(e,e,[-100,-100,0]),e}}function Mp(t,e,r){const i=e.createTileMatrix(t,t.worldSize,r.toUnwrapped());return V.multiply(new Float32Array(16),t.projMatrix,i)}function cE(t,e,r){if(e.projection.name===r.projection.name)return t.projMatrix;const i=r.clone();return i.setProjection(e.projection),Mp(i,e.getProjection(),t)}function Sp(t,e,r){return e.name===r.projection.name?t.projMatrix:Mp(r,e,t)}class kx{constructor(e,r,i,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?r:-r))):o&&i?1:0,this.placed=i}isHidden(){return this.opacity===0&&!this.placed}}class Oa{constructor(e,r,i,o,s,n=!1){this.text=new kx(e?e.text:null,r,i,s),this.icon=new kx(e?e.icon:null,r,o,s),this.clipped=n}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ap{constructor(e,r,i,o=!1){this.text=e,this.icon=r,this.skipFade=i,this.clipped=o}}class uE{constructor(){this.invProjMatrix=V.create(),this.viewportMatrix=V.create(),this.circles=[]}}class hE{constructor(e,r,i,o,s){this.bucketInstanceId=e,this.featureIndex=r,this.sourceLayerIndex=i,this.bucketIndex=o,this.tileID=s}}class dE{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const r=++this.maxGroupID;this.collisionGroups[e]={ID:r,predicate:i=>i.collisionGroupID===r}}return this.collisionGroups[e]}}function Px(t,e,r,i,o){const{horizontalAlign:s,verticalAlign:n}=lc(t),a=-(s-.5)*e,l=-(n-.5)*r,c=qd(t,i);return new N(a+c[0]*o,l+c[1]*o)}function Ip(t,e,r,i,o){const s=new N(t,e);return r&&s._rotate(i?o:-o),s}class pE{constructor(e,r,i,o,s,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new lE(this.transform,s),this.buildingIndex=n,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new dE(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,r,i,o){const s=i.getBucket(r),n=i.latestFeatureIndex;if(!s||!n||r.fqid!==s.layerIds[0])return;const a=s.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/W,h=i.tileID.toUnwrapped();this.transform.setProjection(s.projection);const d=(p=i.tileID,f=s.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Mp(m,f,p));var p,f,m;const _=a.get("text-pitch-alignment")==="map",g=a.get("text-rotation-alignment")==="map";r.compileFilter();const y=r.dynamicFilter(),v=r.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(i),x=n0(d,i.tileID.canonical,_,g,this.transform,s.getProjection(),b);let w=null;if(_){const M=a0(d,i.tileID.canonical,_,g,this.transform,s.getProjection(),b);w=V.multiply([],this.transform.labelPlaneMatrix,M)}let T=null;y&&i.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[s.bucketInstanceId]=new hE(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);const E={bucket:s,layout:a,posMatrix:d,textLabelPlaneMatrix:x,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:Hi(s.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:Hi(s.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(o)for(const M of s.sortKeyRanges){const{sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C}=M;e.push({sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C,parameters:E})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,r,i,o,s,n,a,l,c,u,h,d,p,f,m,_,g,y){const{textOffset0:v,textOffset1:b,crossTileID:x}=d,w=[v,b],T=Px(e,i,o,w,s),E=this.collisionIndex.placeCollisionBox(f,s,r,Ip(T.x,T.y,n,a,this.transform.angle),h,l,c,u.predicate);if(_){const M=f.getSymbolInstanceIconSize(y,this.transform.zoom,d.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(f,M,_,Ip(T.x,T.y,n,a,this.transform.angle),h,l,c,u.predicate).box.length===0)return}if(E.box.length>0){let M;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(M=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:w,width:i,height:o,anchor:e,textScale:s,prevAnchor:M},this.markUsedJustification(f,e,d,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,d),this.placedOrientations[x]=m),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(e,r,i,o){const{bucket:s,layout:n,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=n.get("text-optional"),y=n.get("icon-optional"),v=n.get("text-allow-overlap"),b=n.get("icon-allow-overlap"),x=n.get("text-rotation-alignment")==="map",w=n.get("text-pitch-alignment")==="map",T=n.get("symbol-z-order")==="viewport-y",E=n.get("symbol-z-elevate");this.transform.setProjection(s.projection);let M=v&&(b||!s.hasIconData()||y),S=b&&(v||!s.hasTextData()||g);!s.collisionArrays&&p&&s.deserializeCollisionBoxes(p),i&&o&&s.updateCollisionDebugBuffers(this.transform.zoom,p);const I=(C,k,A)=>{const{crossTileID:L,numVerticalGlyphVertices:O}=C;if(u){const Be={zoom:this.transform.zoom,pitch:this.transform.pitch};let Re=null;if(u.dynamicFilterNeedsFeature){const De=this.retainedQueryData[s.bucketInstanceId];Re=u.featureIndex.loadFeature({featureIndex:C.featureIndex,bucketIndex:De.bucketIndex,sourceLayerIndex:De.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(Be,Re,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new N(C.tileAnchorX,C.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[L]=new Ap(!1,!1,!1,!0),void r.add(L)}if(r.has(L))return;if(d)return void(this.placements[L]=new Ap(!1,!1,!1));let U=!1,R=!1,B=!0,G=!1,Z=!1,q=null,X={box:null,offscreen:null,occluded:null},Y={box:null,offscreen:null,occluded:null},K=null,H=null,ee=null,de=0,pe=0,ge=0;A.textFeatureIndex?de=A.textFeatureIndex:C.useRuntimeCollisionCircles&&(de=C.featureIndex),A.verticalTextFeatureIndex&&(pe=A.verticalTextFeatureIndex);const xe=Be=>{Be.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const Re=this.transform.elevation;Be.elevation=C.zOffset+(Re?Re.getAtTileOffset(Be.tileID,Be.tileAnchorX,Be.tileAnchorY):0)},Oe=A.textBox;if(Oe){xe(Oe);const Be=De=>{let at=Nt.horizontal;if(s.allowVerticalPlacement&&!De&&this.prevPlacement){const ut=this.prevPlacement.placedOrientations[L];ut&&(this.placedOrientations[L]=ut,at=ut,this.markUsedOrientation(s,at,C))}return at},Re=(De,at)=>{if(s.allowVerticalPlacement&&O>0&&A.verticalTextBox){for(const ut of s.writingModes)if(ut===Nt.vertical?(X=at(),Y=X):X=De(),X&&X.box&&X.box.length)break}else X=De()};if(n.get("text-variable-anchor")){let De=n.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[L]){const Je=this.prevPlacement.variableOffsets[L];De.indexOf(Je.anchor)>0&&(De=De.filter(Ct=>Ct!==Je.anchor),De.unshift(Je.anchor))}const at=(Je,Ct,Kt)=>{const St=s.getSymbolInstanceTextSize(f,C,this.transform.zoom,k),Rt=(Je.x2-Je.x1)*St+2*Je.padding,rr=(Je.y2-Je.y1)*St+2*Je.padding,Qt=C.hasIconTextFit&&!b?Ct:null;Qt&&xe(Qt);let Ot={box:[],offscreen:!1,occluded:!1};const bt=v?2*De.length:De.length;for(let Er=0;Er<bt;++Er){const Qi=this.attemptAnchorPlacement(De[Er%De.length],Je,Rt,rr,St,x,w,h,a,_,Er>=De.length,C,k,s,Kt,Qt,f,m);if(Qi&&(Ot=Qi.placedGlyphBoxes,Ot&&Ot.box&&Ot.box.length)){U=!0,q=Qi.shift;break}}return Ot};Re(()=>at(Oe,A.iconBox,Nt.horizontal),()=>{const Je=A.verticalTextBox;return Je&&xe(Je),s.allowVerticalPlacement&&!(X&&X.box&&X.box.length)&&O>0&&Je?at(Je,A.verticalIconBox,Nt.vertical):{box:null,offscreen:null,occluded:null}}),X&&(U=X.box,B=X.offscreen,G=X.occluded);const ut=Be(!(!X||!X.box));if(!U&&this.prevPlacement){const Je=this.prevPlacement.variableOffsets[L];Je&&(this.variableOffsets[L]=Je,this.markUsedJustification(s,Je.anchor,C,ut))}}else{const De=(at,ut)=>{const Je=s.getSymbolInstanceTextSize(f,C,this.transform.zoom,k),Ct=this.collisionIndex.placeCollisionBox(s,Je,at,new N(0,0),v,h,a,_.predicate);return Ct&&Ct.box&&Ct.box.length&&(this.markUsedOrientation(s,ut,C),this.placedOrientations[L]=ut),Ct};Re(()=>De(Oe,Nt.horizontal),()=>{const at=A.verticalTextBox;return s.allowVerticalPlacement&&O>0&&at?(xe(at),De(at,Nt.vertical)):{box:null,offscreen:null,occluded:null}}),Be(!!(X&&X.box&&X.box.length))}}if(K=X,U=K&&K.box&&K.box.length>0,B=K&&K.offscreen,G=K&&K.occluded,C.useRuntimeCollisionCircles){const Be=s.text.placedSymbolArray.get(C.centerJustifiedTextSymbolIndex>=0?C.centerJustifiedTextSymbolIndex:C.verticalPlacedTextSymbolIndex),Re=ma(s.textSizeData,f,Be),De=n.get("text-padding");H=this.collisionIndex.placeCollisionCircles(s,v,Be,s.lineVertexArray,s.glyphOffsetArray,Re,a,l,c,i,w,_.predicate,C.collisionCircleDiameter*Re/xr,De,this.retainedQueryData[s.bucketInstanceId].tileID),U=v||H.circles.length>0&&!H.collisionDetected,B=B&&H.offscreen,G=H.occluded}if(A.iconFeatureIndex&&(ge=A.iconFeatureIndex),A.iconBox){const Be=Re=>{xe(Re);const De=C.hasIconTextFit&&q?Ip(q.x,q.y,x,w,this.transform.angle):new N(0,0),at=s.getSymbolInstanceIconSize(m,this.transform.zoom,C.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,at,Re,De,b,h,a,_.predicate)};Y&&Y.box&&Y.box.length&&A.verticalIconBox?(ee=Be(A.verticalIconBox),R=ee.box.length>0):(ee=Be(A.iconBox),R=ee.box.length>0),B=B&&ee.offscreen,Z=ee.occluded}const Ie=g||C.numHorizontalGlyphVertices===0&&O===0,ht=y||C.numIconVertices===0;if(Ie||ht?ht?Ie||(R=R&&U):U=R&&U:R=U=R&&U,U&&K&&K.box&&this.collisionIndex.insertCollisionBox(K.box,n.get("text-ignore-placement"),s.bucketInstanceId,Y&&Y.box&&pe?pe:de,_.ID),R&&ee&&this.collisionIndex.insertCollisionBox(ee.box,n.get("icon-ignore-placement"),s.bucketInstanceId,ge,_.ID),H&&(U&&this.collisionIndex.insertCollisionCircles(H.circles,n.get("text-ignore-placement"),s.bucketInstanceId,de,_.ID),i)){const Be=s.bucketInstanceId;let Re=this.collisionCircleArrays[Be];Re===void 0&&(Re=this.collisionCircleArrays[Be]=new uE);for(let De=0;De<H.circles.length;De+=4)Re.circles.push(H.circles[De+0]),Re.circles.push(H.circles[De+1]),Re.circles.push(H.circles[De+2]),Re.circles.push(H.collisionDetected?1:0)}const st=s.projection.name!=="globe";M=M&&(st||!G),S=S&&(st||!Z),this.placements[L]=new Ap(U||M,R||S,B||s.justReloaded),r.add(L)};if(E&&this.buildingIndex&&(this.buildingIndex.updateZOffset(s,this.retainedQueryData[s.bucketInstanceId].tileID),s.updateZOffset()),T){const C=s.getSortedSymbolIndexes(this.transform.angle);for(let k=C.length-1;k>=0;--k){const A=C[k];I(s.symbolInstances.get(A),A,s.collisionArrays[A])}s.hasAnyZOffset&&F(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const C=s.getSortedIndexesByZOffset();for(let k=0;k<C.length;++k){const A=C[k];I(s.symbolInstances.get(A),A,s.collisionArrays[A])}}else for(let C=e.symbolInstanceStart;C<e.symbolInstanceEnd;C++)I(s.symbolInstances.get(C),C,s.collisionArrays[C]);if(i&&s.bucketInstanceId in this.collisionCircleArrays){const C=this.collisionCircleArrays[s.bucketInstanceId];V.invert(C.invProjMatrix,a),C.viewportMatrix=this.collisionIndex.getViewportMatrix()}s.justReloaded=!1}markUsedJustification(e,r,i,o){const{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=i,u=Zd(r),h=o===Nt.vertical?l:u==="left"?s:u==="center"?n:u==="right"?a:-1;s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),n>=0&&(e.text.placedSymbolArray.get(n).crossTileID=h>=0&&n!==h?0:c),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(e.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(e,r,i){const o=r===Nt.horizontal||r===Nt.horizontalOnly?r:0,s=r===Nt.vertical?r:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=i,u=e.text.placedSymbolArray;n>=0&&(u.get(n).placedOrientation=o),a>=0&&(u.get(a).placedOrientation=o),l>=0&&(u.get(l).placedOrientation=o),c>=0&&(u.get(c).placedOrientation=s)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let i=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(e):1,s=r?r.opacities:{},n=r?r.variableOffsets:{},a=r?r.placedOrientations:{};for(const l in this.placements){const c=this.placements[l],u=s[l];u?(this.opacities[l]=new Oa(u,o,c.text,c.icon,null,c.clipped),i=i||c.text!==u.text.placed||c.icon!==u.icon.placed):(this.opacities[l]=new Oa(null,o,c.text,c.icon,c.skipFade,c.clipped),i=i||c.text||c.icon)}for(const l in s){const c=s[l];if(!this.opacities[l]){const u=new Oa(c,o,!1,!1);u.isHidden()||(this.opacities[l]=u,i=i||c.text.placed||c.icon.placed)}}for(const l in n)this.variableOffsets[l]||!this.opacities[l]||this.opacities[l].isHidden()||(this.variableOffsets[l]=n[l]);for(const l in a)this.placedOrientations[l]||!this.opacities[l]||this.opacities[l].isHidden()||(this.placedOrientations[l]=a[l]);i?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:e)}updateLayerOpacities(e,r){const i=new Set;for(const o of r){const s=o.getBucket(e);s&&o.latestFeatureIndex&&e.fqid===s.layerIds[0]&&(this.updateBucketOpacities(s,i,o.collisionBoxArray),s.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(s,o.tileID),s.updateZOffset()))}}updateBucketOpacities(e,r,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0].layout,s=!!e.layers[0].dynamicFilter(),n=new Oa(null,0,!1,!1,!0),a=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),c=o.get("text-variable-anchor"),u=o.get("text-rotation-alignment")==="map",h=o.get("text-pitch-alignment")==="map",d=new Oa(null,0,a&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(a||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const p=(m,_,g)=>{for(let y=0;y<_/4;y++)m.opacityVertexArray.emplaceBack(g)};let f=0;for(let m=0;m<e.symbolInstances.length;m++){const _=e.symbolInstances.get(m),{numHorizontalGlyphVertices:g,numVerticalGlyphVertices:y,crossTileID:v,numIconVertices:b}=_,x=r.has(v);let w=this.opacities[v];x?w=n:w||(w=d,this.opacities[v]=w),r.add(v);const T=g>0||y>0,E=b>0,M=this.placedOrientations[v],S=M===Nt.vertical,I=M===Nt.horizontal||M===Nt.horizontalOnly;if(!T&&!E||w.isHidden()||f++,T){const C=Rx(w.text);p(e.text,g,S?jc:C),p(e.text,y,I?jc:C);const k=w.text.isHidden(),{leftJustifiedTextSymbolIndex:A,centerJustifiedTextSymbolIndex:L,rightJustifiedTextSymbolIndex:O,verticalPlacedTextSymbolIndex:U}=_,R=e.text.placedSymbolArray,B=k||S?1:0;A>=0&&(R.get(A).hidden=B),L>=0&&(R.get(L).hidden=B),O>=0&&(R.get(O).hidden=B),U>=0&&(R.get(U).hidden=k||I?1:0);const G=this.variableOffsets[v];G&&this.markUsedJustification(e,G.anchor,_,M);const Z=this.placedOrientations[v];Z&&(this.markUsedJustification(e,"left",_,Z),this.markUsedOrientation(e,Z,_))}if(E){const C=Rx(w.icon),{placedIconSymbolIndex:k,verticalPlacedIconSymbolIndex:A}=_,L=e.icon.placedSymbolArray,O=w.icon.isHidden()?1:0;k>=0&&(p(e.icon,b,S?jc:C),L.get(k).hidden=O),A>=0&&(p(e.icon,_.numVerticalIconVertices,I?jc:C),L.get(A).hidden=O)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const C=e.collisionArrays[m];if(C){let k=new N(0,0),A=!0;if(C.textBox||C.verticalTextBox){if(c){const O=this.variableOffsets[v];O?(k=Px(O.anchor,O.width,O.height,O.textOffset,O.textScale),u&&k._rotate(h?this.transform.angle:-this.transform.angle)):A=!1}s&&(A=!w.clipped),C.textBox&&Vc(e.textCollisionBox.collisionVertexArray,w.text.placed,!A||S,k.x,k.y),C.verticalTextBox&&Vc(e.textCollisionBox.collisionVertexArray,w.text.placed,!A||I,k.x,k.y)}const L=A&&!!(!I&&C.verticalIconBox);C.iconBox&&Vc(e.iconCollisionBox.collisionVertexArray,w.icon.placed,L,_.hasIconTextFit?k.x:0,_.hasIconTextFit?k.y:0),C.verticalIconBox&&Vc(e.iconCollisionBox.collisionVertexArray,w.icon.placed,!L,_.hasIconTextFit?k.x:0,_.hasIconTextFit?k.y:0)}}}if(e.fullyClipped=f===0,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const m=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=m.invProjMatrix,e.placementViewportMatrix=m.viewportMatrix,e.collisionCircleArray=m.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,r){const i=this.zoomAtLastRecencyCheck===r?1-this.zoomAdjustment(r):1;return this.zoomAtLastRecencyCheck=r,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function Vc(t,e,r,i,o){t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0),t.emplaceBack(e?1:0,r?1:0,i||0,o||0)}const fE=Math.pow(2,25),mE=Math.pow(2,24),_E=Math.pow(2,17),gE=Math.pow(2,16),yE=Math.pow(2,9),xE=Math.pow(2,8),vE=Math.pow(2,1);function Rx(t){if(t.opacity===0&&!t.placed)return 0;if(t.opacity===1&&t.placed)return 4294967295;const e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*fE+e*mE+r*_E+e*gE+r*yE+e*xE+r*vE+e}const jc=0;class bE{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&e.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,r,i,o,s){const n=this._bucketParts;for(;this._currentTileIndex<e.length;)if(r.getBucketParts(n,o,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((a,l)=>a.sortKey-l.sortKey));this._currentPartIndex<n.length;){const a=n[this._currentPartIndex];if(r.placeLayerBucketPart(a,this._seenCrossTileIDs,i,a.symbolInstanceStart===0),this._currentPartIndex++,s())return!0}return!1}}class wE{constructor(e,r,i,o,s,n,a,l,c){this.placement=new pE(e,s,n,a,l,c),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=o,this._done=!1}isDone(){return this._done}continuePlacement(e,r,i,o){const s=je.now(),n=()=>{const a=je.now()-s;return!this._forceFullPlacement&&a>2};for(;this._currentPlacementIndex>=0;){const a=r[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if(a.type==="symbol"&&(!a.minzoom||a.minzoom<=l)&&(!a.maxzoom||a.maxzoom>l)){const c=a,u=c.layout.get("symbol-z-elevate"),h=this._inProgressLayer=this._inProgressLayer||new bE(c),d=Dr(a.source,a.scope);if(h.continuePlacement(u?o[d]:i[d],this.placement,this._showCollisionBoxes,a,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Lx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Gc{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,i]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=i>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const s=Lx[15&i];if(!s)throw new Error("Unrecognized array type.");const[n]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Gc(a,n,s,e)}constructor(e,r=64,i=Float64Array,o){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const s=Lx.indexOf(this.ArrayType),n=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${i}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+l,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+n+a+l),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=r,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Cp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,i,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:n,nodeSize:a}=this,l=[0,s.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let _=d;_<=h;_++){const g=n[2*_],y=n[2*_+1];g>=e&&g<=i&&y>=r&&y<=o&&c.push(s[_])}continue}const p=d+h>>1,f=n[2*p],m=n[2*p+1];f>=e&&f<=i&&m>=r&&m<=o&&c.push(s[p]),(u===0?e<=f:r<=m)&&(l.push(d),l.push(p-1),l.push(1-u)),(u===0?i>=f:o>=m)&&(l.push(p+1),l.push(h),l.push(1-u))}return c}within(e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:s,nodeSize:n}=this,a=[0,o.length-1,0],l=[],c=i*i;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=n){for(let _=d;_<=h;_++)Ox(s[2*_],s[2*_+1],e,r)<=c&&l.push(o[_]);continue}const p=d+h>>1,f=s[2*p],m=s[2*p+1];Ox(f,m,e,r)<=c&&l.push(o[p]),(u===0?e-i<=f:r-i<=m)&&(a.push(d),a.push(p-1),a.push(1-u)),(u===0?e+i>=f:r+i>=m)&&(a.push(p+1),a.push(h),a.push(1-u))}return l}}function Cp(t,e,r,i,o,s){if(o-i<=r)return;const n=i+o>>1;Bx(t,e,n,i,o,s),Cp(t,e,r,i,n-1,1-s),Cp(t,e,r,n+1,o,1-s)}function Bx(t,e,r,i,o,s){for(;o>i;){if(o-i>600){const c=o-i+1,u=r-i+1,h=Math.log(c),d=.5*Math.exp(2*h/3),p=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1);Bx(t,e,r,Math.max(i,Math.floor(r-u*d/c+p)),Math.min(o,Math.floor(r+(c-u)*d/c+p)),s)}const n=e[2*r+s];let a=i,l=o;for(Fa(t,e,i,r),e[2*o+s]>n&&Fa(t,e,i,o);a<l;){for(Fa(t,e,a,l),a++,l--;e[2*a+s]<n;)a++;for(;e[2*l+s]>n;)l--}e[2*i+s]===n?Fa(t,e,i,l):(l++,Fa(t,e,l,o)),l<=r&&(i=l+1),r<=l&&(o=l-1)}}function Fa(t,e,r,i){zp(t,r,i),zp(e,2*r,2*i),zp(e,2*r+1,2*i+1)}function zp(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function Ox(t,e,r,i){const o=t-r,s=e-i;return o*o+s*s}const Dp=512/W/2;class TE{constructor(e,r,i){this.tileID=e,this.bucketInstanceId=i,this.index=new Gc(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const o=e.canonical.x*W,s=e.canonical.y*W;for(let n=0;n<r.length;n++){const{key:a,crossTileID:l,tileAnchorX:c,tileAnchorY:u}=r.get(n),h=Math.floor((o+c)*Dp),d=Math.floor((s+u)*Dp);this.index.add(h,d),this.keys.push(a),this.crossTileIDs.push(l)}this.index.finish()}findMatches(e,r,i){const o=this.tileID.canonical.z<r.canonical.z?1:Math.pow(2,this.tileID.canonical.z-r.canonical.z),s=Dp/Math.pow(2,r.canonical.z-this.tileID.canonical.z),n=r.canonical.x*W,a=r.canonical.y*W;for(let l=0;l<e.length;l++){const c=e.get(l);if(c.crossTileID)continue;const{key:u,tileAnchorX:h,tileAnchorY:d}=c,p=Math.floor((n+h)*s),f=Math.floor((a+d)*s),m=this.index.range(p-o,f-o,p+o,f+o);for(const _ of m){const g=this.crossTileIDs[_];if(this.keys[_]===u&&!i.has(g)){i.add(g),c.crossTileID=g;break}}}}}class EE{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ME{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const r=Math.round((e-this.lng)/360);if(r!==0)for(const i in this.indexes){const o=this.indexes[i],s={};for(const n in o){const a=o[n];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+r),s[a.tileID.key]=a}this.indexes[i]=s}this.lng=e}addBucket(e,r,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===r.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let s=0;s<r.symbolInstances.length;s++)r.symbolInstances.get(s).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const o=this.usedCrossTileIDs[e.overscaledZ];for(const s in this.indexes){const n=this.indexes[s];if(Number(s)>e.overscaledZ)for(const a in n){const l=n[a];l.tileID.isChildOf(e)&&l.findMatches(r.symbolInstances,e,o)}else{const a=n[e.scaledTo(Number(s)).key];a&&a.findMatches(r.symbolInstances,e,o)}}for(let s=0;s<r.symbolInstances.length;s++){const n=r.symbolInstances.get(s);n.crossTileID||(n.crossTileID=i.generate(),o.add(n.crossTileID))}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new TE(e,r.symbolInstances,r.bucketInstanceId),!0}removeBucketCrossTileIDs(e,r){for(const i of r.crossTileIDs)this.usedCrossTileIDs[e].delete(i)}removeStaleBuckets(e){let r=!1;for(const i in this.indexes){const o=this.indexes[i];for(const s in o)e[o[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,o[s]),delete o[s],r=!0)}return r}}class SE{constructor(){this.layerIndexes={},this.crossTileIDs=new EE,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,r,i,o){let s=this.layerIndexes[e.fqid];s===void 0&&(s=this.layerIndexes[e.fqid]=new ME);let n=!1;const a={};o.name!=="globe"&&s.handleWrapJump(i);for(const l of r){const c=l.getBucket(e);c&&e.fqid===c.layerIds[0]&&(c.bucketInstanceId||(c.bucketInstanceId=++this.maxBucketInstanceId),s.addBucket(l.tileID,c,this.crossTileIDs)&&(n=!0),a[c.bucketInstanceId]=!0)}return s.removeStaleBuckets(a)&&(n=!0),n}pruneUnusedLayers(e){const r={};e.forEach(i=>{r[i]=!0});for(const i in this.layerIndexes)r[i]||delete this.layerIndexes[i]}}var Fx=`
9
9
  #define EPSILON 0.0000001
10
10
  #define PI 3.141592653589793
11
11
  #ifdef RENDER_CUTOFF