var HDmap=function(){"use strict";var $l=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bp(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function I1(x){if(x.__esModule)return x;var d=x.default;if(typeof d=="function"){var w=function k(){return this instanceof k?Reflect.construct(d,arguments,this.constructor):d.apply(this,arguments)};w.prototype=d.prototype}else w={};return Object.defineProperty(w,"__esModule",{value:!0}),Object.keys(x).forEach(function(k){var A=Object.getOwnPropertyDescriptor(x,k);Object.defineProperty(w,k,A.get?A:{enumerable:!0,get:function(){return x[k]}})}),w}var fg={exports:{}};(function(x,d){(function(w,k){x.exports=k()})($l,function(){var w,k,A;function O(s,Z){if(!w)w=Z;else if(!k)k=Z;else{var oe="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 = {}; ("+w+")(sharedChunk); ("+k+")(sharedChunk); self.onerror = null;",pe={};w(pe),A=Z(pe),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(A.workerUrl=window.URL.createObjectURL(new Blob([oe],{type:"text/javascript"})))}}O(["exports"],function(s){var Z=typeof self<"u"?self:{},oe="2.15.0";let pe;const he={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(pe==null){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{pe=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):t}catch{pe=t}}return pe},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(!he.API_URL)return null;try{const t=new URL(he.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,MAX_PARALLEL_IMAGE_REQUESTS:16},we={supported:!1,testSupport:function(t){!Tt&&Ie&&(gt?Mt(t):ye=t)}};let ye,Ie,Tt=!1,gt=!1;function Mt(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,Ie),t.isContextLost())return;we.supported=!0}catch{}t.deleteTexture(e),Tt=!0}Z.document&&(Ie=Z.document.createElement("img"),Ie.onload=function(){ye&&Mt(ye),ye=null,gt=!0},Ie.onerror=function(){Tt=!0,ye=null},Ie.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Le="01";function Qe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Et=ut;function ut(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}ut.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 i=t,r=0;r<8;r++){var u=this.sampleCurveX(i)-t;if(Math.abs(u)u?m=i:y=i,i=.5*(y-m)+m;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var yt=Qe(Et),_t=It;function It(t,e){this.x=t,this.y=e}It.prototype={clone:function(){return new It(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),u=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=u,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},It.convert=function(t){return t instanceof It?t:Array.isArray(t)?new It(t[0],t[1]):t};var Oe=Qe(_t);const gi=Math.PI/180,ti=180/Math.PI;function At(t){return t*gi}function Xt(t){return t*ti}const bt=[[0,0],[1,0],[1,1],[0,1]];function Jt(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function Bt(t,e,i,r){const u=new yt(t,e,i,r);return function(f){return u.solve(f)}}const Ri=Bt(.25,.1,.25,1);function Rt(t,e,i){return Math.min(i,Math.max(e,t))}function pi(t,e,i){return(i=Rt((i-t)/(e-t),0,1))*i*(3-2*i)}function St(t,e,i){const r=i-e,u=((t-e)%r+r)%r+e;return u===e?i:u}function wi(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const u=new Array(t.length);let f=null;t.forEach((m,y)=>{e(m,(E,T)=>{E&&(f=E),u[y]=T,--r==0&&i(f,u)})})}function Oi(t){const e=[];for(const i in t)e.push(t[i]);return e}function Wt(t,...e){for(const i of e)for(const r in i)t[r]=i[r];return t}let Dt=1;function Ni(){return Dt++}function Dn(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function vn(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Fe(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 no(t,e){t.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Ci(t,e){return t.indexOf(e,t.length-e.length)!==-1}function ft(t,e,i){const r={};for(const u in t)r[u]=e.call(this,t[u],u,t);return r}function me(t,e,i){const r={};for(const u in t)e.call(i||this,t[u],u,t)&&(r[u]=t[u]);return r}function rn(t){return Array.isArray(t)?t.map(rn):typeof t=="object"&&t?ft(t,rn):t}const $r={};function Ti(t){$r[t]||(typeof console<"u"&&console.warn(t),$r[t]=!0)}function pr(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function ps(t){let e=0;for(let i,r,u=0,f=t.length,m=f-1;u@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,r,u,f)=>{const m=u||f;return e[r]=!m||m.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let ds=null;function Do(t){if(ds==null){const e=t.navigator?t.navigator.userAgent:null;ds=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return ds}function Dr(t){try{const e=Z[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function xo(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const ii="mapbox-tiles";let bo=500,Oo=50,tr,$t;function zo(){try{return Z.caches}catch{}}function _i(){zo()&&!tr&&(tr=Z.caches.open(ii))}function Yt(t){const e=t.indexOf("?");if(e<0)return t;const i=function(u){const f=u.indexOf("?");return f>0?u.slice(f+1).split("&"):[]}(t),r=i.filter(u=>{const f=u.split("=");return f[0]==="language"||f[0]==="worldview"});return r.length?`${t.slice(0,e)}?${r.join("&")}`:t.slice(0,e)}let zs=1/0;const Wn={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(Wn);class wo extends Error{constructor(e,i,r){i===401&&Pe(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const qt=ro()?()=>self.worker&&self.worker.referrer:()=>(Z.location.protocol==="blob:"?Z.parent:Z).location.href,No=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(qt())&&!/^\w+:/.test(i))){if(Z.fetch&&Z.Request&&Z.AbortController&&Z.Request.prototype.hasOwnProperty("signal"))return function(r,u){const f=new Z.AbortController,m=new Z.Request(r.url,{method:r.method||"GET",body:r.body,credentials:r.credentials,headers:r.headers,referrer:qt(),referrerPolicy:r.referrerPolicy,signal:f.signal});let y=!1,E=!1;const T=(C=m.url).indexOf("sku=")>0&&Pe(C);var C;r.type==="json"&&m.headers.set("Accept","application/json");const L=(B,U,G)=>{if(E)return;if(B&&B.message!=="SecurityError"&&Ti(B.toString()),U&&G)return D(U);const H=Date.now();Z.fetch(m).then(ne=>{if(ne.ok){const de=T?ne.clone():null;return D(ne,de,H)}return u(new wo(ne.statusText,ne.status,r.url))}).catch(ne=>{ne.name!=="AbortError"&&u(new Error(`${ne.message} ${r.url}`))})},D=(B,U,G)=>{(r.type==="arrayBuffer"?B.arrayBuffer():r.type==="json"?B.json():B.text()).then(H=>{E||(U&&G&&function(ne,de,re){if(_i(),!tr)return;const fe={status:de.status,statusText:de.statusText,headers:new Z.Headers};de.headers.forEach((Be,De)=>fe.headers.set(De,Be));const ve=ct(de.headers.get("Cache-Control")||"");if(ve["no-store"])return;ve["max-age"]&&fe.headers.set("Expires",new Date(re+1e3*ve["max-age"]).toUTCString());const ge=fe.headers.get("Expires");ge&&(new Date(ge).getTime()-re<42e4||function(Be,De){if($t===void 0)try{new Response(new ReadableStream),$t=!0}catch{$t=!1}$t?De(Be.body):Be.blob().then(De)}(de,Be=>{const De=new Z.Response(Be,fe);_i(),tr&&tr.then(qe=>qe.put(Yt(ne.url),De)).catch(qe=>Ti(qe.message))}))}(m,U,G),y=!0,u(null,H,B.headers.get("Cache-Control"),B.headers.get("Expires")))}).catch(H=>{E||u(new Error(H.message))})};return T?function(B,U){if(_i(),!tr)return U(null);const G=Yt(B.url);tr.then(H=>{H.match(G).then(ne=>{const de=function(re){if(!re)return!1;const fe=new Date(re.headers.get("Expires")||0),ve=ct(re.headers.get("Cache-Control")||"");return fe>Date.now()&&!ve["no-cache"]}(ne);H.delete(G),de&&H.put(G,ne.clone()),U(null,ne,de)}).catch(U)}).catch(U)}(m,L):L(null,null),{cancel:()=>{E=!0,y||f.abort()}}}(t,e);if(ro()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(r,u){const f=new Z.XMLHttpRequest;f.open(r.method||"GET",r.url,!0),r.type==="arrayBuffer"&&(f.responseType="arraybuffer");for(const m in r.headers)f.setRequestHeader(m,r.headers[m]);return r.type==="json"&&(f.responseType="text",f.setRequestHeader("Accept","application/json")),f.withCredentials=r.credentials==="include",f.onerror=()=>{u(new Error(f.statusText))},f.onload=()=>{if((f.status>=200&&f.status<300||f.status===0)&&f.response!==null){let m=f.response;if(r.type==="json")try{m=JSON.parse(f.response)}catch(y){return u(y)}u(null,m,f.getResponseHeader("Cache-Control"),f.getResponseHeader("Expires"))}else u(new wo(f.statusText,f.status,r.url))},f.send(r.body),{cancel:()=>f.abort()}}(t,e)},ms=function(t,e){return No(Wt(t,{type:"arrayBuffer"}),e)};function gs(t){const e=Z.document.createElement("a");return e.href=t,e.protocol===Z.document.location.protocol&&e.host===Z.document.location.host}const ce="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let X,W;X=[],W=0;const ue=function(t,e){if(we.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),W>=he.MAX_PARALLEL_IMAGE_REQUESTS){const f={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return X.push(f),f}W++;let i=!1;const r=()=>{if(!i)for(i=!0,W--;X.length&&W{r(),f?e(f):m&&(Z.createImageBitmap?function(T,C){const L=new Z.Blob([new Uint8Array(T)],{type:"image/png"});Z.createImageBitmap(L).then(D=>{C(null,D)}).catch(D=>{C(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.`))})}(m,(T,C)=>e(T,C,y,E)):function(T,C){const L=new Z.Image,D=Z.URL;L.onload=()=>{C(null,L),D.revokeObjectURL(L.src),L.onload=null,Z.requestAnimationFrame(()=>{L.src=ce})},L.onerror=()=>C(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 B=new Z.Blob([new Uint8Array(T)],{type:"image/png"});L.src=T.byteLength?D.createObjectURL(B):ce}(m,(T,C)=>e(T,C,y,E)))});return{cancel:()=>{u.cancel(),r()}}},_e="NO_ACCESS_TOKEN";function Se(t){return t.indexOf("mapbox:")===0}function Pe(t){return he.API_URL_REGEX.test(t)}function Ce(t){return he.API_CDN_URL_REGEX.test(t)}function se(t){return he.API_STYLE_REGEX.test(t)&&!Ue(t)}function Ue(t){return he.API_SPRITE_REGEX.test(t)}const ot=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ht(t){const e=t.match(ot);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 nt(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const Ht="mapbox.eventData";function li(t){if(!t)return null;const e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(Z.atob(e[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Zt{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=li(he.ACCESS_TOKEN);let r="";return r=i&&i.u?Z.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,(u,f)=>String.fromCharCode(+("0x"+f)))):he.ACCESS_TOKEN||"",e?`${Ht}.${e}:${r}`:`${Ht}:${r}`}fetchEventData(){const e=Dr("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const u=Z.localStorage.getItem(i);u&&(this.eventData=JSON.parse(u));const f=Z.localStorage.getItem(r);f&&(this.anonId=f)}catch{Ti("Unable to read from LocalStorage")}}saveEventData(){const e=Dr("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{Z.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&Z.localStorage.setItem(i,JSON.stringify(this.eventData))}catch{Ti("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,i,r,u){if(!he.EVENTS_URL)return;const f=ht(he.EVENTS_URL);f.params.push(`access_token=${u||he.ACCESS_TOKEN||""}`);const m={event:this.type,created:new Date(e).toISOString()},y=i?Wt(m,i):m,E={url:nt(f),headers:{"Content-Type":"text/plain"},body:JSON.stringify([y])};this.pendingRequest=function(T,C){return No(Wt(T,{method:"POST"}),C)}(E,T=>{this.pendingRequest=null,r(T),this.saveEventData(),this.processRequests(u)})}queueRequest(e,i){this.queue.push(e),this.processRequests(i)}}const ui=new class extends Zt{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){he.EVENTS_URL&&he.ACCESS_TOKEN&&Array.isArray(t)&&t.some(i=>Se(i)||Pe(i))&&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=li(he.ACCESS_TOKEN),i=e?e.u:he.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;Fe(this.anonId)||(this.anonId=Dn(),r=!0);const u=this.queue.shift();if(this.eventData.lastSuccess){const f=new Date(this.eventData.lastSuccess),m=new Date(u),y=(u-this.eventData.lastSuccess)/864e5;r=r||y>=1||y<-1||f.getDate()!==m.getDate()}else r=!0;r?this.postEvent(u,{sdkIdentifier:"mapbox-gl-js",sdkVersion:oe,skuId:Le,"enabled.telemetry":!1,userId:this.anonId},f=>{f||(this.eventData.lastSuccess=u,this.eventData.tokenU=i)},t):this.processRequests()}},hi=ui.postTurnstileEvent.bind(ui),tn=new class extends Zt{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,he.EVENTS_URL&&(i||he.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(_e)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Fe(this.anonId)||(this.anonId=Dn()),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:oe,skuId:Le,skuToken:this.skuToken,userId:this.anonId},r=>{r?this.errorCb(r):e&&(this.success[e]=!0)},t))}},un=tn.postMapLoadEvent.bind(tn),Un=new class extends Zt{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){he.EVENTS_URL&&(t||he.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:i}=this.queue.shift(),r=function(u){const f=Z.performance.getEntriesByType("resource"),m=Z.performance.getEntriesByType("mark"),y=function(D){const B={};if(D){for(const U in D)if(U!=="other")for(const G of D[U]){const H=`${U}ResolveRangeMin`,ne=`${U}ResolveRangeMax`,de=`${U}RequestCount`,re=`${U}RequestCachedCount`;B[H]=Math.min(B[H]||1/0,G.startTime),B[ne]=Math.max(B[ne]||-1/0,G.responseEnd);const fe=ve=>{B[ve]===void 0&&(B[ve]=0),++B[ve]};G.transferSize!==void 0&&G.transferSize===0&&fe(re),fe(de)}}return B}(function(D,B){const U={};if(D)for(const G of D){const H=B(G);U[H]===void 0&&(U[H]=[]),U[H].push(G)}return U}(f,Ns)),E=Z.devicePixelRatio,T=Z.navigator.connection||Z.navigator.mozConnection||Z.navigator.webkitConnection,C={counters:[],metadata:[],attributes:[]},L=(D,B,U)=>{U!=null&&D.push({name:B,value:U.toString()})};for(const D in y)L(C.counters,D,y[D]);if(u.interactionRange[0]!==1/0&&u.interactionRange[1]!==-1/0&&(L(C.counters,"interactionRangeMin",u.interactionRange[0]),L(C.counters,"interactionRangeMax",u.interactionRange[1])),m)for(const D of Object.keys(br)){const B=br[D],U=m.find(G=>G.name===B);U&&L(C.counters,B,U.startTime)}return L(C.counters,"visibilityHidden",u.visibilityHidden),L(C.attributes,"style",function(D){if(D)for(const B of D){const U=B.name.split("?")[0];if(se(U)){const G=U.split("/").slice(-2);if(G.length===2)return`mapbox://styles/${G[0]}/${G[1]}`}}}(f)),L(C.attributes,"terrainEnabled",u.terrainEnabled?"true":"false"),L(C.attributes,"fogEnabled",u.fogEnabled?"true":"false"),L(C.attributes,"projection",u.projection),L(C.attributes,"zoom",u.zoom),L(C.metadata,"devicePixelRatio",E),L(C.metadata,"connectionEffectiveType",T?T.effectiveType:void 0),L(C.metadata,"navigatorUserAgent",Z.navigator.userAgent),L(C.metadata,"screenWidth",Z.screen.width),L(C.metadata,"screenHeight",Z.screen.height),L(C.metadata,"windowWidth",Z.innerWidth),L(C.metadata,"windowHeight",Z.innerHeight),L(C.metadata,"mapWidth",u.width/E),L(C.metadata,"mapHeight",u.height/E),L(C.metadata,"webglRenderer",u.renderer),L(C.metadata,"webglVendor",u.vendor),L(C.metadata,"sdkVersion",oe),L(C.metadata,"sdkIdentifier","mapbox-gl-js"),C}(i);for(const u of r.metadata);for(const u of r.counters);for(const u of r.attributes);this.postEvent(e,r,()=>{},t)}},Pi=Un.postPerformanceEvent.bind(Un),xr=new class extends Zt{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!he.API_URL||!he.SESSION_PATH)return;const u=ht(he.API_URL+he.SESSION_PATH);u.params.push(`sku=${e||""}`),u.params.push(`access_token=${r||he.ACCESS_TOKEN||""}`);const f={url:nt(u),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(m,y){return No(Wt(m,{method:"GET"}),y)}(f,m=>{this.pendingRequest=null,i(m),this.saveEventData(),this.processRequests(r)})}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,he.SESSION_PATH&&he.API_URL&&(i||he.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(_e)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,r=>{r?this.errorCb(r):e&&(this.success[e]=!0)},t)}},cn=xr.getSessionAPI.bind(xr),pn=new Set,br={create:"create",load:"load",fullLoad:"fullLoad"},al={mark(t){Z.performance.mark(t)},measure(t,e,i){Z.performance.measure(t,e,i)}};function Ns(t){const e=t.name.split("?")[0];return Ce(e)&&e.includes("mapbox-gl.js")?"javascript":Ce(e)&&e.includes("mapbox-gl.css")?"css":function(i){return he.API_FONTS_REGEX.test(i)}(e)?"fontRange":Ue(e)?"sprite":se(e)?"style":function(i){return he.API_TILEJSON_REGEX.test(i)}(e)?"tilejson":"other"}const xi=Z.performance;function dn(t){const e=t?t.url.toString():void 0;return xi.getEntriesByName(e)}let Bs,ll,Bo,ir;const Or={now:()=>Bo!==void 0?Bo:Z.performance.now(),setNow(t){Bo=t},restoreNow(){Bo=void 0},frame(t){const e=Z.requestAnimationFrame(t);return{cancel:()=>Z.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:r}=t;ir||(ir=Z.document.createElement("canvas"));const u=ir.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("failed to create canvas 2d context");return(i>ir.width||r>ir.height)&&(ir.width=i,ir.height=r),u.clearRect(-e,-e,i+2*e,r+2*e),u.drawImage(t,0,0,i,r),u.getImageData(-e,-e,i+2*e,r+2*e)},resolveURL:t=>(Bs||(Bs=Z.document.createElement("a")),Bs.href=t,Bs.href),get devicePixelRatio(){return Z.devicePixelRatio},get prefersReducedMotion(){return!!Z.matchMedia&&(ll==null&&(ll=Z.matchMedia("(prefers-reduced-motion: reduce)")),ll.matches)}};function Fs(t,e,i){i[t]&&i[t].indexOf(e)!==-1||(i[t]=i[t]||[],i[t].push(e))}function _a(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);r!==-1&&i[t].splice(r,1)}}class Fo{constructor(e,i={}){Wt(this,i),this.type=e}}class xn extends Fo{constructor(e,i={}){super("error",Wt({error:e},i))}}class qr{on(e,i){return this._listeners=this._listeners||{},Fs(e,i,this._listeners),this}off(e,i){return _a(e,i,this._listeners),_a(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},Fs(e,i,this._oneTimeListeners),this):new Promise(r=>this.once(e,r))}fire(e,i){typeof e=="string"&&(e=new Fo(e,i||{}));const r=e.type;if(this.listens(r)){e.target=this;const u=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const y of u)y.call(this,e);const f=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const y of f)_a(r,y,this._oneTimeListeners),y.call(this,e);const m=this._eventedParent;m&&(Wt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),m.fire(e))}else e instanceof xn&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}var Ge=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"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"]},"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"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"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,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"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"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function nr(t,...e){for(const i of e)for(const r in i)t[r]=i[r];return t}function sn(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function An(t){if(Array.isArray(t))return t.map(An);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=An(t[i]);return e}return sn(t)}class hu extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}var Zr=hu;class ya{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[r,u]of i)this.bindings[r]=u}concat(e){return new ya(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 ul=ya;const oo={kind:"null"},mt={kind:"number"},Qt={kind:"string"},ci={kind:"boolean"},Cn={kind:"color"},zr={kind:"object"},fi={kind:"value"},dr={kind:"collator"},Us={kind:"formatted"},Eo={kind:"resolvedImage"};function jn(t,e){return{kind:"array",itemType:t,N:e}}function Zi(t){if(t.kind==="array"){const e=Zi(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}const fu=[oo,mt,Qt,ci,Cn,Us,zr,jn(fi),Eo];function Xr(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Xr(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 i of fu)if(!Xr(i,e))return null}}return`Expected ${Zi(t)} but found ${Zi(e)} instead.`}function js(t,e){return e.some(i=>i.kind===t.kind)}function Uo(t,e){return e.some(i=>i==="null"?t===null:i==="array"?Array.isArray(t):i==="object"?t&&!Array.isArray(t)&&typeof t=="object":i===typeof t)}var Ji,To={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 Vs(t){return(t=Math.round(t))<0?0:t>255?255:t}function jo(t){return Vs(t[t.length-1]==="%"?parseFloat(t)/100*255:parseInt(t))}function Yn(t){return(e=t[t.length-1]==="%"?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function On(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(.6666666666666666-i)*6:t}try{Ji={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in To)return To[i].slice();if(i[0]==="#")return i.length===4?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:i.length===7&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var r=i.indexOf("("),u=i.indexOf(")");if(r!==-1&&u+1===i.length){var f=i.substr(0,r),m=i.substr(r+1,u-(r+1)).split(","),y=1;switch(f){case"rgba":if(m.length!==4)return null;y=Yn(m.pop());case"rgb":return m.length!==3?null:[jo(m[0]),jo(m[1]),jo(m[2]),y];case"hsla":if(m.length!==4)return null;y=Yn(m.pop());case"hsl":if(m.length!==3)return null;var E=(parseFloat(m[0])%360+360)%360/360,T=Yn(m[1]),C=Yn(m[2]),L=C<=.5?C*(T+1):C+T-C*T,D=2*C-L;return[Vs(255*On(D,L,E+.3333333333333333)),Vs(255*On(D,L,E)),Vs(255*On(D,L,E-.3333333333333333)),y];default:return null}}return null}}catch{}class zn{constructor(e,i,r,u=1){this.r=e,this.g=i,this.b=r,this.a=u}static parse(e){if(!e)return;if(e instanceof zn)return e;if(typeof e!="string")return;const i=Ji(e);return i?new zn(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,i,r,u]=this.toArray();return`rgba(${Math.round(e)},${Math.round(i)},${Math.round(r)},${u})`}toArray(){const{r:e,g:i,b:r,a:u}=this;return u===0?[0,0,0,0]:[255*e/u,255*i/u,255*r/u,u]}toArray01(){const{r:e,g:i,b:r,a:u}=this;return u===0?[0,0,0,0]:[e/u,i/u,r/u,u]}toArray01PremultipliedAlpha(){const{r:e,g:i,b:r,a:u}=this;return[e,i,r,u]}}zn.black=new zn(0,0,0,1),zn.white=new zn(1,1,1,1),zn.transparent=new zn(0,0,0,0),zn.red=new zn(1,0,0,1),zn.blue=new zn(0,0,1,1);var hn=zn;class cl{constructor(e,i,r){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class va{constructor(e,i,r,u,f){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=r,this.fontStack=u,this.textColor=f}}class Nn{constructor(e){this.sections=e}static fromString(e){return new Nn([new va(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Nn?e:Nn.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){e.push(["image",i.image.name]);continue}e.push(i.text);const r={};i.fontStack&&(r["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(r["font-scale"]=i.scale),i.textColor&&(r["text-color"]=["rgba"].concat(i.textColor.toArray())),e.push(r)}return e}}class wr{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new wr({name:e,available:!1}):null}serialize(){return["image",this.name]}}function hl(t,e,i,r){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ei(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof hn||t instanceof cl||t instanceof Nn||t instanceof wr)return!0;if(Array.isArray(t)){for(const e of t)if(!Ei(e))return!1;return!0}if(typeof t=="object"){for(const e in t)if(!Ei(t[e]))return!1;return!0}return!1}function Li(t){if(t===null)return oo;if(typeof t=="string")return Qt;if(typeof t=="boolean")return ci;if(typeof t=="number")return mt;if(t instanceof hn)return Cn;if(t instanceof cl)return dr;if(t instanceof Nn)return Us;if(t instanceof wr)return Eo;if(Array.isArray(t)){const e=t.length;let i;for(const r of t){const u=Li(r);if(i){if(i===u)continue;i=fi;break}i=u}return jn(i||fi,e)}return zr}function Vo(t){const e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof hn||t instanceof Nn||t instanceof wr?t.toString():JSON.stringify(t)}class xa{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ei(e[1]))return i.error("invalid value");const r=e[1];let u=Li(r);const f=i.expectedType;return u.kind!=="array"||u.N!==0||!f||f.kind!=="array"||typeof f.N=="number"&&f.N!==0||(u=f),new xa(u,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof hn?["rgba"].concat(this.value.toArray()):this.value instanceof Nn?this.value.serialize():this.value}}var Nr=xa,Pn=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Bn={string:Qt,number:mt,boolean:ci,object:zr};class ba{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r,u=1;const f=e[0];if(f==="array"){let y,E;if(e.length>2){const T=e[1];if(typeof T!="string"||!(T in Bn)||T==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);y=Bn[T],u++}else y=fi;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);E=e[2],u++}r=jn(y,E)}else r=Bn[f];const m=[];for(;ue.outputDefined())}serialize(){const e=this.type,i=[e.kind];if(e.kind==="array"){const r=e.itemType;if(r.kind==="string"||r.kind==="number"||r.kind==="boolean"){i.push(r.kind);const u=e.N;(typeof u=="number"||this.args.length>1)&&i.push(u)}}return i.concat(this.args.map(r=>r.serialize()))}}var Br=ba;class so{constructor(e){this.type=Us,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&typeof r=="object")return i.error("First argument must be an image or text section.");const u=[];let f=!1;for(let m=1;m<=e.length-1;++m){const y=e[m];if(f&&typeof y=="object"&&!Array.isArray(y)){f=!1;let E=null;if(y["font-scale"]&&(E=i.parse(y["font-scale"],1,mt),!E))return null;let T=null;if(y["text-font"]&&(T=i.parse(y["text-font"],1,jn(Qt)),!T))return null;let C=null;if(y["text-color"]&&(C=i.parse(y["text-color"],1,Cn),!C))return null;const L=u[u.length-1];L.scale=E,L.font=T,L.textColor=C}else{const E=i.parse(e[m],1,fi);if(!E)return null;const T=E.type.kind;if(T!=="string"&&T!=="value"&&T!=="null"&&T!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");f=!0,u.push({content:E,scale:null,font:null,textColor:null})}}return new so(u)}evaluate(e){return new Nn(this.sections.map(i=>{const r=i.content.evaluate(e);return Li(r)===Eo?new va("",r,null,null,null):new va(Vo(r),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const i of this.sections){e.push(i.content.serialize());const r={};i.scale&&(r["font-scale"]=i.scale.serialize()),i.font&&(r["text-font"]=i.font.serialize()),i.textColor&&(r["text-color"]=i.textColor.serialize()),e.push(r)}return e}}class Gs{constructor(e){this.type=Eo,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const r=i.parse(e[1],1,Qt);return r?new Gs(r):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),r=wr.fromString(i);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(i)>-1),r}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const vc={"to-boolean":ci,"to-color":Cn,"to-number":mt,"to-string":Qt};class wa{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const r=e[0];if((r==="to-boolean"||r==="to-string")&&e.length!==2)return i.error("Expected one argument.");const u=vc[r],f=[];for(let m=1;m4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:hl(i[0],i[1],i[2],i[3]),!r))return new hn(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new Pn(r||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(const r of this.args){if(i=r.evaluate(e),i===null)return 0;const u=Number(i);if(!isNaN(u))return u}throw new Pn(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?Nn.fromString(Vo(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?wr.fromString(Vo(this.args[0].evaluate(e))):Vo(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 so([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Gs(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}var rr=wa;const mr=["Unknown","Point","LineString","Polygon"];var fl=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?mr[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=hn.parse(t)),e}};class Ln{constructor(e,i,r,u){this.name=e,this.type=i,this._evaluate=r,this.args=u}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,i){const r=e[0],u=Ln.definitions[r];if(!u)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const f=Array.isArray(u)?u[0]:u.type,m=Array.isArray(u)?[[u[1],u[2]]]:u.overloads,y=m.filter(([T])=>!Array.isArray(T)||T.length===e.length-1);let E=null;for(const[T,C]of y){E=new Hn(i.registry,i.path,null,i.scope);const L=[];let D=!1;for(let B=1;B{return D=L,Array.isArray(D)?`(${D.map(Zi).join(", ")})`:`(${Zi(D.type)}...)`;var D}).join(" | "),C=[];for(let L=1;L=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Zs(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,u=Math.pow(2,e.z);return[Math.round(i*u*sr),Math.round(r*u*sr)]}function Ur(t,e,i){const r=t[0]-e[0],u=t[1]-e[1],f=t[0]-i[0],m=t[1]-i[1];return r*m-f*u==0&&r*f<=0&&u*m<=0}function Xs(t,e){let i=!1;for(let m=0,y=e.length;m(r=t)[1]!=(f=E[T+1])[1]>r[1]&&r[0]<(f[0]-u[0])*(r[1]-u[1])/(f[1]-u[1])+u[0]&&(i=!i)}}var r,u,f;return i}function pl(t,e){for(let i=0;i0&&y<0||m<0&&y>0}function _s(t,e,i){for(const T of i)for(let C=0;Ci[2]){const u=.5*r;let f=t[0]-i[0]>u?-r:i[0]-t[0]>u?r:0;f===0&&(f=t[0]-i[2]>u?-r:i[2]-t[0]>u?r:0),t[0]+=f}qs(e,t)}function ar(t,e,i,r){const u=Math.pow(2,r.z)*sr,f=[r.x*sr,r.y*sr],m=[];if(!t)return m;for(const y of t)for(const E of y){const T=[E.x+f[0],E.y+f[1]];ao(T,e,i,u),m.push(T)}return m}function gl(t,e,i,r){const u=Math.pow(2,r.z)*sr,f=[r.x*sr,r.y*sr],m=[];if(!t)return m;for(const E of t){const T=[];for(const C of E){const L=[C.x+f[0],C.y+f[1]];qs(e,L),T.push(L)}m.push(T)}if(e[2]-e[0]<=u/2){(y=e)[0]=y[1]=1/0,y[2]=y[3]=-1/0;for(const E of m)for(const T of E)ao(T,e,i,u)}var y;return m}class Go{constructor(e,i){this.type=ci,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ei(e[1])){const r=e[1];if(r.type==="FeatureCollection")for(let u=0;u{e&&!So(i)&&(e=!1)}),e}function Wr(t){if(t instanceof or&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(i=>{e&&!Wr(i)&&(e=!1)}),e}function lo(t,e){if(t instanceof or&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild(r=>{i&&!lo(r,e)&&(i=!1)}),i}class Ws{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const r=e[1];return i.scope.has(r)?new Ws(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" 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 Er=Ws;class ys{constructor(e,i=[],r,u=new ul,f=[]){this.registry=e,this.path=i,this.key=i.map(m=>`[${m}]`).join(""),this.scope=u,this.errors=f,this.expectedType=r}parse(e,i,r,u,f={}){return i?this.concat(i,r,u)._parse(e,f):this._parse(e,f)}_parse(e,i){function r(u,f,m){return m==="assert"?new Br(f,[u]):m==="coerce"?new rr(f,[u]):u}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 u=e[0];if(typeof u!="string")return this.error(`Expression name must be a string, but found ${typeof u} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const f=this.registry[u];if(f){let m=f.parse(e,this);if(!m)return null;if(this.expectedType){const y=this.expectedType,E=m.type;if(y.kind!=="string"&&y.kind!=="number"&&y.kind!=="boolean"&&y.kind!=="object"&&y.kind!=="array"||E.kind!=="value")if(y.kind!=="color"&&y.kind!=="formatted"&&y.kind!=="resolvedImage"||E.kind!=="value"&&E.kind!=="string"){if(this.checkSubtype(y,E))return null}else m=r(m,y,i.typeAnnotation||"coerce");else m=r(m,y,i.typeAnnotation||"assert")}if(!(m instanceof Nr)&&m.type.kind!=="resolvedImage"&&$o(m)){const y=new fl;try{m=new Nr(m.type,m.evaluate(y))}catch(E){return this.error(E.message),null}}return m}return this.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,r){const u=typeof e=="number"?this.path.concat(e):this.path,f=r?this.scope.concat(r):this.scope;return new ys(this.registry,u,i||null,f,this.errors)}error(e,...i){const r=`${this.key}${i.map(u=>`[${u}]`).join("")}`;this.errors.push(new Zr(r,e))}checkSubtype(e,i){const r=Xr(e,i);return r&&this.error(r),r}}var Hn=ys;function $o(t){if(t instanceof Er)return $o(t.boundExpression);if(t instanceof or&&t.name==="error"||t instanceof $s||t instanceof Ea)return!1;const e=t instanceof rr||t instanceof Br;let i=!0;return t.eachChild(r=>{i=e?i&&$o(r):i&&r instanceof Nr}),!!i&&So(t)&&lo(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Ta(t,e){const i=t.length-1;let r,u,f=0,m=i,y=0;for(;f<=m;)if(y=Math.floor((f+m)/2),r=t[y],u=t[y+1],r<=e){if(y===i||ee))throw new Pn("Input is not a number.");m=y-1}return 0}class Ys{constructor(e,i,r){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[u,f]of r)this.labels.push(u),this.outputs.push(f)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const r=i.parse(e[1],1,mt);if(!r)return null;const u=[];let f=null;i.expectedType&&i.expectedType.kind!=="value"&&(f=i.expectedType);for(let m=1;m=y)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',T);const L=i.parse(E,C,f);if(!L)return null;f=f||L.type,u.push([y,L])}return new Ys(f,r,u)}evaluate(e){const i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);const u=this.input.evaluate(e);if(u<=i[0])return r[0].evaluate(e);const f=i.length;return u>=i[f-1]?r[f-1].evaluate(e):r[Ta(i,u)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let i=0;i0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}var Sa=Ys;function bi(t,e,i){return t*(1-i)+e*i}var qo=Object.freeze({__proto__:null,array:function(t,e,i){return t.map((r,u)=>bi(r,e[u],i))},color:function(t,e,i){return new hn(bi(t.r,e.r,i),bi(t.g,e.g,i),bi(t.b,e.b,i),bi(t.a,e.a,i))},number:bi});const du=.95047,_l=1.08883,mu=4/29,Zo=6/29,yl=3*Zo*Zo,bc=Zo*Zo*Zo,wc=Math.PI/180,Ec=180/Math.PI;function Ia(t){return t>bc?Math.pow(t,.3333333333333333):t/yl+mu}function vl(t){return t>Zo?t*t*t:yl*(t-mu)}function ka(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,.4166666666666667)-.055)}function Ma(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function gu(t){const e=Ma(t.r),i=Ma(t.g),r=Ma(t.b),u=Ia((.4124564*e+.3575761*i+.1804375*r)/du),f=Ia((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*f-16,a:500*(u-f),b:200*(f-Ia((.0193339*e+.119192*i+.9503041*r)/_l)),alpha:t.a}}function _u(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*vl(e),i=du*vl(i),r=_l*vl(r),new hn(ka(3.2404542*i-1.5371385*e-.4985314*r),ka(-.969266*i+1.8760108*e+.041556*r),ka(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Tc(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Hs={forward:gu,reverse:_u,interpolate:function(t,e,i){return{l:bi(t.l,e.l,i),a:bi(t.a,e.a,i),b:bi(t.b,e.b,i),alpha:bi(t.alpha,e.alpha,i)}}},vs={forward:function(t){const{l:e,a:i,b:r}=gu(t),u=Math.atan2(r,i)*Ec;return{h:u<0?u+360:u,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*wc,i=t.c;return _u({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Tc(t.h,e.h,i),c:bi(t.c,e.c,i),l:bi(t.l,e.l,i),alpha:bi(t.alpha,e.alpha,i)}}};var xl=Object.freeze({__proto__:null,hcl:vs,lab:Hs});class xs{constructor(e,i,r,u,f){this.type=e,this.operator=i,this.interpolation=r,this.input=u,this.labels=[],this.outputs=[];for(const[m,y]of f)this.labels.push(m),this.outputs.push(y)}static interpolationFactor(e,i,r,u){let f=0;if(e.name==="exponential")f=Aa(i,e.base,r,u);else if(e.name==="linear")f=Aa(i,1,r,u);else if(e.name==="cubic-bezier"){const m=e.controlPoints;f=new yt(m[0],m[1],m[2],m[3]).solve(Aa(i,1,r,u))}return f}static parse(e,i){let[r,u,f,...m]=e;if(!Array.isArray(u)||u.length===0)return i.error("Expected an interpolation type expression.",1);if(u[0]==="linear")u={name:"linear"};else if(u[0]==="exponential"){const T=u[1];if(typeof T!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);u={name:"exponential",base:T}}else{if(u[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(u[0])}`,1,0);{const T=u.slice(1);if(T.length!==4||T.some(C=>typeof C!="number"||C<0||C>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);u={name:"cubic-bezier",controlPoints:T}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(f=i.parse(f,2,mt),!f)return null;const y=[];let E=null;r==="interpolate-hcl"||r==="interpolate-lab"?E=Cn:i.expectedType&&i.expectedType.kind!=="value"&&(E=i.expectedType);for(let T=0;T=C)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',D);const U=i.parse(L,B,E);if(!U)return null;E=E||U.type,y.push([C,U])}return E.kind==="number"||E.kind==="color"||E.kind==="array"&&E.itemType.kind==="number"&&typeof E.N=="number"?new xs(E,r,u,f,y):i.error(`Type ${Zi(E)} is not interpolatable.`)}evaluate(e){const i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);const u=this.input.evaluate(e);if(u<=i[0])return r[0].evaluate(e);const f=i.length;if(u>=i[f-1])return r[f-1].evaluate(e);const m=Ta(i,u),y=xs.interpolationFactor(this.interpolation,u,i[m],i[m+1]),E=r[m].evaluate(e),T=r[m+1].evaluate(e);return this.operator==="interpolate"?qo[this.type.kind.toLowerCase()](E,T,y):this.operator==="interpolate-hcl"?vs.reverse(vs.interpolate(vs.forward(E),vs.forward(T),y)):Hs.reverse(Hs.interpolate(Hs.forward(E),Hs.forward(T),y))}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=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 i=[this.operator,e,this.input.serialize()];for(let r=0;rXr(u,y.type));return new Ca(m?fi:r,f)}evaluate(e){let i,r=null,u=0;for(const f of this.args){if(u++,r=f.evaluate(e),r&&r instanceof wr&&!r.available&&(i||(i=r),r=null,u===this.args.length))return i;if(r!==null)break}return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var Pa=Ca;class bs{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let f=1;f=r.length)throw new Pn(`Array index out of bounds: ${i} > ${r.length-1}.`);if(i!==Math.floor(i))throw new Pn(`Array index must be an integer, but found ${i} instead.`);return r[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var vu=La;class bl{constructor(e,i){this.type=ci,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=i.parse(e[1],1,fi),u=i.parse(e[2],2,fi);return r&&u?js(r.type,[ci,Qt,mt,oo,fi])?new bl(r,u):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Zi(r.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(r==null)return!1;if(!Uo(i,["boolean","string","number","null"]))throw new Pn(`Expected first argument to be of type boolean, string, number or null, but found ${Zi(Li(i))} instead.`);if(!Uo(r,["string","array"]))throw new Pn(`Expected second argument to be of type array or string, but found ${Zi(Li(r))} instead.`);return r.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Ra=bl;class Yr{constructor(e,i,r){this.type=mt,this.needle=e,this.haystack=i,this.fromIndex=r}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=i.parse(e[1],1,fi),u=i.parse(e[2],2,fi);if(!r||!u)return null;if(!js(r.type,[ci,Qt,mt,oo,fi]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Zi(r.type)} instead`);if(e.length===4){const f=i.parse(e[3],3,mt);return f?new Yr(r,u,f):null}return new Yr(r,u)}evaluate(e){const i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Uo(i,["boolean","string","number","null"]))throw new Pn(`Expected first argument to be of type boolean, string, number or null, but found ${Zi(Li(i))} instead.`);if(!Uo(r,["string","array"]))throw new Pn(`Expected second argument to be of type array or string, but found ${Zi(Li(r))} instead.`);if(this.fromIndex){const u=this.fromIndex.evaluate(e);return r.indexOf(i,u)}return r.indexOf(i)}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 xu=Yr;class Da{constructor(e,i,r,u,f,m){this.inputType=e,this.type=i,this.input=r,this.cases=u,this.outputs=f,this.otherwise=m}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let r,u;i.expectedType&&i.expectedType.kind!=="value"&&(u=i.expectedType);const f={},m=[];for(let T=2;TNumber.MAX_SAFE_INTEGER)return D.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof U=="number"&&Math.floor(U)!==U)return D.error("Numeric branch labels must be integer values.");if(r){if(D.checkSubtype(r,Li(U)))return null}else r=Li(U);if(f[String(U)]!==void 0)return D.error("Branch labels must be unique.");f[String(U)]=m.length}const B=i.parse(L,T,u);if(!B)return null;u=u||B.type,m.push(B)}const y=i.parse(e[1],1,fi);if(!y)return null;const E=i.parse(e[e.length-1],e.length-1,u);return E?y.type.kind!=="value"&&i.concat(1).checkSubtype(r,y.type)?null:new Da(r,u,y,f,m,E):null}evaluate(e){const i=this.input.evaluate(e);return(Li(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),r=[],u={};for(const m of i){const y=u[this.cases[m]];y===void 0?(u[this.cases[m]]=r.length,r.push([this.cases[m],[m]])):r[y][1].push(m)}const f=m=>this.inputType.kind==="number"?Number(m):m;for(const[m,y]of r)e.push(y.length===1?f(y[0]):y.map(f)),e.push(this.outputs[m].serialize());return e.push(this.otherwise.serialize()),e}}var Tr=Da;class Sr{constructor(e,i,r){this.type=e,this.branches=i,this.otherwise=r}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);const u=[];for(let m=1;mi.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var v=Sr;class o{constructor(e,i,r,u){this.type=e,this.input=i,this.beginIndex=r,this.endIndex=u}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=i.parse(e[1],1,fi),u=i.parse(e[2],2,mt);if(!r||!u)return null;if(!js(r.type,[jn(fi),Qt,fi]))return i.error(`Expected first argument to be of type array or string, but found ${Zi(r.type)} instead`);if(e.length===4){const f=i.parse(e[3],3,mt);return f?new o(r.type,r,u,f):null}return new o(r.type,r,u)}evaluate(e){const i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!Uo(i,["string","array"]))throw new Pn(`Expected first argument to be of type array or string, but found ${Zi(Li(i))} instead.`);if(this.endIndex){const u=this.endIndex.evaluate(e);return i.slice(r,u)}return i.slice(r)}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 l=o;function c(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 g(t,e,i,r){return r.compare(e,i)===0}function S(t,e,i){const r=t!=="=="&&t!=="!=";return class S1{constructor(f,m,y){this.type=ci,this.lhs=f,this.rhs=m,this.collator=y,this.hasUntypedArgument=f.type.kind==="value"||m.type.kind==="value"}static parse(f,m){if(f.length!==3&&f.length!==4)return m.error("Expected two or three arguments.");const y=f[0];let E=m.parse(f[1],1,fi);if(!E)return null;if(!c(y,E.type))return m.concat(1).error(`"${y}" comparisons are not supported for type '${Zi(E.type)}'.`);let T=m.parse(f[2],2,fi);if(!T)return null;if(!c(y,T.type))return m.concat(2).error(`"${y}" comparisons are not supported for type '${Zi(T.type)}'.`);if(E.type.kind!==T.type.kind&&E.type.kind!=="value"&&T.type.kind!=="value")return m.error(`Cannot compare types '${Zi(E.type)}' and '${Zi(T.type)}'.`);r&&(E.type.kind==="value"&&T.type.kind!=="value"?E=new Br(T.type,[E]):E.type.kind!=="value"&&T.type.kind==="value"&&(T=new Br(E.type,[T])));let C=null;if(f.length===4){if(E.type.kind!=="string"&&T.type.kind!=="string"&&E.type.kind!=="value"&&T.type.kind!=="value")return m.error("Cannot use collator to compare non-string types.");if(C=m.parse(f[3],3,dr),!C)return null}return new S1(E,T,C)}evaluate(f){const m=this.lhs.evaluate(f),y=this.rhs.evaluate(f);if(r&&this.hasUntypedArgument){const E=Li(m),T=Li(y);if(E.kind!==T.kind||E.kind!=="string"&&E.kind!=="number")throw new Pn(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${E.kind}, ${T.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const E=Li(m),T=Li(y);if(E.kind!=="string"||T.kind!=="string")return e(f,m,y)}return this.collator?i(f,m,y,this.collator.evaluate(f)):e(f,m,y)}eachChild(f){f(this.lhs),f(this.rhs),this.collator&&f(this.collator)}outputDefined(){return!0}serialize(){const f=[t];return this.eachChild(m=>{f.push(m.serialize())}),f}}}const R=S("==",function(t,e,i){return e===i},g),F=S("!=",function(t,e,i){return e!==i},function(t,e,i,r){return!g(0,e,i,r)}),q=S("<",function(t,e,i){return e",function(t,e,i){return e>i},function(t,e,i,r){return r.compare(e,i)>0}),Ee=S("<=",function(t,e,i){return e<=i},function(t,e,i,r){return r.compare(e,i)<=0}),Me=S(">=",function(t,e,i){return e>=i},function(t,e,i,r){return r.compare(e,i)>=0});class Xe{constructor(e,i,r,u,f,m){this.type=Qt,this.number=e,this.locale=i,this.currency=r,this.unit=u,this.minFractionDigits=f,this.maxFractionDigits=m}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const r=i.parse(e[1],1,mt);if(!r)return null;const u=e[2];if(typeof u!="object"||Array.isArray(u))return i.error("NumberFormat options argument must be an object.");let f=null;if(u.locale&&(f=i.parse(u.locale,1,Qt),!f))return null;let m=null;if(u.currency&&(m=i.parse(u.currency,1,Qt),!m))return null;let y=null;if(u.unit&&(y=i.parse(u.unit,1,Qt),!y))return null;let E=null;if(u["min-fraction-digits"]&&(E=i.parse(u["min-fraction-digits"],1,mt),!E))return null;let T=null;return u["max-fraction-digits"]&&(T=i.parse(u["max-fraction-digits"],1,mt),!T)?null:new Xe(r,f,m,y,E,T)}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 pt{constructor(e){this.type=mt,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=i.parse(e[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Zi(r.type)} instead.`):new pt(r):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new Pn(`Expected value to be of type string or array, but found ${Zi(Li(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}const dt={"==":R,"!=":F,">":Q,"<":q,">=":Me,"<=":Ee,array:Br,at:vu,boolean:Br,case:v,coalesce:Pa,collator:$s,format:so,image:Gs,in:Ra,"index-of":xu,interpolate:jr,"interpolate-hcl":jr,"interpolate-lab":jr,length:pt,let:yu,literal:Nr,match:Tr,number:Br,"number-format":Xe,object:Br,slice:l,step:Sa,string:Br,"to-boolean":rr,"to-color":rr,"to-number":rr,"to-string":rr,var:Er,within:Ea};function Vt(t,[e,i,r,u]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const f=u?u.evaluate(t):1,m=hl(e,i,r,f);if(m)throw new Pn(m);return new hn(e/255*f,i/255*f,r/255*f,f)}function Ut(t,e){return t in e}function ei(t,e){const i=e[t];return i===void 0?null:i}function yi(t){return{type:t}}or.register(dt,{error:[{kind:"error"},[Qt],(t,[e])=>{throw new Pn(e.evaluate(t))}],typeof:[Qt,[fi],(t,[e])=>Zi(Li(e.evaluate(t)))],"to-rgba":[jn(mt,4),[Cn],(t,[e])=>e.evaluate(t).toArray()],rgb:[Cn,[mt,mt,mt],Vt],rgba:[Cn,[mt,mt,mt,mt],Vt],has:{type:ci,overloads:[[[Qt],(t,[e])=>Ut(e.evaluate(t),t.properties())],[[Qt,zr],(t,[e,i])=>Ut(e.evaluate(t),i.evaluate(t))]]},get:{type:fi,overloads:[[[Qt],(t,[e])=>ei(e.evaluate(t),t.properties())],[[Qt,zr],(t,[e,i])=>ei(e.evaluate(t),i.evaluate(t))]]},"feature-state":[fi,[Qt],(t,[e])=>ei(e.evaluate(t),t.featureState||{})],properties:[zr,[],t=>t.properties()],"geometry-type":[Qt,[],t=>t.geometryType()],id:[fi,[],t=>t.id()],zoom:[mt,[],t=>t.globals.zoom],pitch:[mt,[],t=>t.globals.pitch||0],"distance-from-center":[mt,[],t=>t.distanceFromCenter()],"heatmap-density":[mt,[],t=>t.globals.heatmapDensity||0],"line-progress":[mt,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[mt,[],t=>t.globals.skyRadialProgress||0],accumulated:[fi,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[mt,yi(mt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[mt,yi(mt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:mt,overloads:[[[mt,mt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[mt],(t,[e])=>-e.evaluate(t)]]},"/":[mt,[mt,mt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[mt,[mt,mt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[mt,[],()=>Math.LN2],pi:[mt,[],()=>Math.PI],e:[mt,[],()=>Math.E],"^":[mt,[mt,mt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[mt,[mt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[mt,[mt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[mt,[mt],(t,[e])=>Math.log(e.evaluate(t))],log2:[mt,[mt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[mt,[mt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[mt,[mt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[mt,[mt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[mt,[mt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[mt,[mt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[mt,[mt],(t,[e])=>Math.atan(e.evaluate(t))],min:[mt,yi(mt),(t,e)=>Math.min(...e.map(i=>i.evaluate(t)))],max:[mt,yi(mt),(t,e)=>Math.max(...e.map(i=>i.evaluate(t)))],abs:[mt,[mt],(t,[e])=>Math.abs(e.evaluate(t))],round:[mt,[mt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[mt,[mt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[mt,[mt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ci,[Qt,fi],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ci,[fi],(t,[e])=>t.id()===e.value],"filter-type-==":[ci,[Qt],(t,[e])=>t.geometryType()===e.value],"filter-<":[ci,[Qt,fi],(t,[e,i])=>{const r=t.properties()[e.value],u=i.value;return typeof r==typeof u&&r{const i=t.id(),r=e.value;return typeof i==typeof r&&i":[ci,[Qt,fi],(t,[e,i])=>{const r=t.properties()[e.value],u=i.value;return typeof r==typeof u&&r>u}],"filter-id->":[ci,[fi],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ci,[Qt,fi],(t,[e,i])=>{const r=t.properties()[e.value],u=i.value;return typeof r==typeof u&&r<=u}],"filter-id-<=":[ci,[fi],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ci,[Qt,fi],(t,[e,i])=>{const r=t.properties()[e.value],u=i.value;return typeof r==typeof u&&r>=u}],"filter-id->=":[ci,[fi],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ci,[fi],(t,[e])=>e.value in t.properties()],"filter-has-id":[ci,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[ci,[jn(Qt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ci,[jn(fi)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ci,[Qt,jn(fi)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ci,[Qt,jn(fi)],(t,[e,i])=>function(r,u,f,m){for(;f<=m;){const y=f+m>>1;if(u[y]===r)return!0;u[y]>r?m=y-1:f=y+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ci,overloads:[[[ci,ci],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[yi(ci),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ci,overloads:[[[ci,ci],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[yi(ci),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ci,[ci],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ci,[Qt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Qt,[Qt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Qt,[Qt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Qt,yi(fi),(t,e)=>e.map(i=>Vo(i.evaluate(t))).join("")],"resolved-locale":[Qt,[dr],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Xi=dt;function Fn(t){return{result:"success",value:t}}function bn(t){return{result:"error",value:t}}function Vn(t){return t["property-type"]==="data-driven"}function Ir(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Hr(t){return!!t.expression&&t.expression.interpolated}function vi(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}function uo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Xo(t){return t}function Ks(t,e){const i=e.type==="color",r=t.stops&&typeof t.stops[0][0]=="object",u=r||!(r||t.property!==void 0),f=t.type||(Hr(e)?"exponential":"interval");if(i&&((t=nr({},t)).stops&&(t.stops=t.stops.map(T=>[T[0],hn.parse(T[1])])),t.default=hn.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!xl[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let m,y,E;if(f==="exponential")m=Yo;else if(f==="interval")m=ws;else if(f==="categorical"){m=Oa,y=Object.create(null);for(const T of t.stops)y[T[0]]=T[1];E=typeof t.stops[0][0]}else{if(f!=="identity")throw new Error(`Unknown function type "${f}"`);m=bf}if(r){const T={},C=[];for(let B=0;BB[0]),evaluate:({zoom:B},U)=>Yo({stops:L,base:t.base},e,B).evaluate(B,U)}}if(u){const T=f==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:T,interpolationFactor:jr.interpolationFactor.bind(void 0,T),zoomStops:t.stops.map(C=>C[0]),evaluate:({zoom:C})=>m(t,e,C,y,E)}}return{kind:"source",evaluate(T,C){const L=C&&C.properties?C.properties[t.property]:void 0;return L===void 0?Wo(t.default,e.default):m(t,e,L,y,E)}}}function Wo(t,e,i){return t!==void 0?t:e!==void 0?e:i!==void 0?i:void 0}function Oa(t,e,i,r,u){return Wo(typeof i===u?r[i]:void 0,t.default,e.default)}function ws(t,e,i){if(vi(i)!=="number")return Wo(t.default,e.default);const r=t.stops.length;if(r===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const u=Ta(t.stops.map(f=>f[0]),i);return t.stops[u][1]}function Yo(t,e,i){const r=t.base!==void 0?t.base:1;if(vi(i)!=="number")return Wo(t.default,e.default);const u=t.stops.length;if(u===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[u-1][0])return t.stops[u-1][1];const f=Ta(t.stops.map(C=>C[0]),i),m=function(C,L,D,B){const U=B-D,G=C-D;return U===0?0:L===1?G/U:(Math.pow(L,G)-1)/(Math.pow(L,U)-1)}(i,r,t.stops[f][0],t.stops[f+1][0]),y=t.stops[f][1],E=t.stops[f+1][1];let T=qo[e.type]||Xo;if(t.colorSpace&&t.colorSpace!=="rgb"){const C=xl[t.colorSpace];T=(L,D)=>C.reverse(C.interpolate(C.forward(L),C.forward(D),m))}return typeof y.evaluate=="function"?{evaluate(...C){const L=y.evaluate.apply(void 0,C),D=E.evaluate.apply(void 0,C);if(L!==void 0&&D!==void 0)return T(L,D,m)}}:T(y,E,m)}function bf(t,e,i){return e.type==="color"?i=hn.parse(i):e.type==="formatted"?i=Nn.fromString(i.toString()):e.type==="resolvedImage"?i=wr.fromString(i.toString()):vi(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),Wo(i,t.default,e.default)}class bu{constructor(e,i){this.expression=e,this._warningHistory={},this._evaluator=new fl,this._defaultValue=i?function(r){return r.type==="color"&&(uo(r.default)||Array.isArray(r.default))?new hn(0,0,0,0):r.type==="color"?hn.parse(r.default)||null:r.default===void 0?null:r.default}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(e,i,r,u,f,m,y,E){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=u||null,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m,this._evaluator.featureTileCoord=y||null,this._evaluator.featureDistanceData=E||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,r,u,f,m,y,E){this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=r||null,this._evaluator.canonical=u||null,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m||null,this._evaluator.featureTileCoord=y||null,this._evaluator.featureDistanceData=E||null;try{const T=this.expression.evaluate(this._evaluator);if(T==null||typeof T=="number"&&T!=T)return this._defaultValue;if(this._enumValues&&!(T in this._enumValues))throw new Pn(`Expected value to be one of ${Object.keys(this._enumValues).map(C=>JSON.stringify(C)).join(", ")}, but found ${JSON.stringify(T)} instead.`);return T}catch(T){return this._warningHistory[T.message]||(this._warningHistory[T.message]=!0,typeof console<"u"&&console.warn(T.message)),this._defaultValue}}}function za(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in Xi}function Na(t,e){const i=new Hn(Xi,[],e?function(u){const f={color:Cn,string:Qt,number:mt,enum:Qt,boolean:ci,formatted:Us,resolvedImage:Eo};return u.type==="array"?jn(f[u.value]||fi,u.length):f[u.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return r?Fn(new bu(r,e)):bn(i.errors)}class Sc{constructor(e,i){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!Wr(i.expression)}evaluateWithoutErrorHandling(e,i,r,u,f,m){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,u,f,m)}evaluate(e,i,r,u,f,m){return this._styleExpression.evaluate(e,i,r,u,f,m)}}class wl{constructor(e,i,r,u){this.kind=e,this.zoomStops=r,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!Wr(i.expression),this.interpolationType=u}evaluateWithoutErrorHandling(e,i,r,u,f,m){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,u,f,m)}evaluate(e,i,r,u,f,m){return this._styleExpression.evaluate(e,i,r,u,f,m)}interpolationFactor(e,i,r){return this.interpolationType?jr.interpolationFactor(this.interpolationType,e,i,r):0}}function El(t,e){if((t=Na(t,e)).result==="error")return t;const i=t.value.expression,r=So(i);if(!r&&!Vn(e))return bn([new Zr("","data expressions not supported")]);const u=lo(i,["zoom","pitch","distance-from-center"]);if(!u&&!Ir(e))return bn([new Zr("","zoom expressions not supported")]);const f=Eu(i);return f||u?f instanceof Zr?bn([f]):f instanceof jr&&!Hr(e)?bn([new Zr("",'"interpolate" expressions cannot be used with this property')]):Fn(f?new wl(r?"camera":"composite",t.value,f.labels,f instanceof jr?f.interpolation:void 0):new Sc(r?"constant":"source",t.value)):bn([new Zr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class wu{constructor(e,i){this._parameters=e,this._specification=i,nr(this,Ks(this._parameters,this._specification))}static deserialize(e){return new wu(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Eu(t){let e=null;if(t instanceof yu)e=Eu(t.result);else if(t instanceof Pa){for(const i of t.args)if(e=Eu(i),e)break}else(t instanceof Sa||t instanceof jr)&&t.input instanceof or&&t.input.name==="zoom"&&(e=t);return e instanceof Zr||t.eachChild(i=>{const r=Eu(i);r instanceof Zr?e=r:!e&&r?e=new Zr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new Zr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class kt{constructor(e,i,r,u){this.message=(e?`${e}: `:"")+r,u&&(this.identifier=u),i!=null&&i.__line__&&(this.line=i.__line__)}}function co(t){const e=t.key,i=t.value,r=t.valueSpec||{},u=t.objectElementValidators||{},f=t.style,m=t.styleSpec;let y=[];const E=vi(i);if(E!=="object")return[new kt(e,i,`object expected, ${E} found`)];for(const T in i){const C=T.split(".")[0];let L;u[C]?L=u[C]:r[C]?L=lr:u["*"]?L=u["*"]:r["*"]&&(L=lr),L?y=y.concat(L({key:(e&&`${e}.`)+T,value:i[T],valueSpec:r[C]||r["*"],style:f,styleSpec:m,object:i,objectKey:T},i)):y.push(new kt(e,i[T],`unknown property "${T}"`))}for(const T in r)u[T]||r[T].required&&r[T].default===void 0&&i[T]===void 0&&y.push(new kt(e,i,`missing required property "${T}"`));return y}function wf(t){const e=t.value,i=t.valueSpec,r=t.style,u=t.styleSpec,f=t.key,m=t.arrayElementValidator||lr;if(vi(e)!=="array")return[new kt(f,e,`array expected, ${vi(e)} found`)];if(i.length&&e.length!==i.length)return[new kt(f,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.lengthf)return[new kt(e,i,`${i} is greater than the maximum value ${f}`)]}return[]}function Sl(t){const e=t.valueSpec,i=sn(t.value.type);let r,u,f,m={};const y=i!=="categorical"&&t.value.property===void 0,E=!y,T=vi(t.value.stops)==="array"&&vi(t.value.stops[0])==="array"&&vi(t.value.stops[0][0])==="object",C=co({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(B){if(i==="identity")return[new kt(B.key,B.value,'identity function may not have a "stops" property')];let U=[];const G=B.value;return U=U.concat(wf({key:B.key,value:G,valueSpec:B.valueSpec,style:B.style,styleSpec:B.styleSpec,arrayElementValidator:L})),vi(G)==="array"&&G.length===0&&U.push(new kt(B.key,G,"array must have at least one stop")),U},default:function(B){return lr({key:B.key,value:B.value,valueSpec:e,style:B.style,styleSpec:B.styleSpec})}}});return i==="identity"&&y&&C.push(new kt(t.key,t.value,'missing required property "property"')),i==="identity"||t.value.stops||C.push(new kt(t.key,t.value,'missing required property "stops"')),i==="exponential"&&t.valueSpec.expression&&!Hr(t.valueSpec)&&C.push(new kt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(E&&!Vn(t.valueSpec)?C.push(new kt(t.key,t.value,"property functions not supported")):y&&!Ir(t.valueSpec)&&C.push(new kt(t.key,t.value,"zoom functions not supported"))),i!=="categorical"&&!T||t.value.property!==void 0||C.push(new kt(t.key,t.value,'"property" property is required')),C;function L(B){let U=[];const G=B.value,H=B.key;if(vi(G)!=="array")return[new kt(H,G,`array expected, ${vi(G)} found`)];if(G.length!==2)return[new kt(H,G,`array length 2 expected, length ${G.length} found`)];if(T){if(vi(G[0])!=="object")return[new kt(H,G,`object expected, ${vi(G[0])} found`)];if(G[0].zoom===void 0)return[new kt(H,G,"object stop key must have zoom")];if(G[0].value===void 0)return[new kt(H,G,"object stop key must have value")];const ne=sn(G[0].zoom);if(typeof ne!="number")return[new kt(H,G[0].zoom,"stop zoom values must be numbers")];if(f&&f>ne)return[new kt(H,G[0].zoom,"stop zoom values must appear in ascending order")];ne!==f&&(f=ne,u=void 0,m={}),U=U.concat(co({key:`${H}[0]`,value:G[0],valueSpec:{zoom:{}},style:B.style,styleSpec:B.styleSpec,objectElementValidators:{zoom:Tl,value:D}}))}else U=U.concat(D({key:`${H}[0]`,value:G[0],valueSpec:{},style:B.style,styleSpec:B.styleSpec},G));return za(An(G[1]))?U.concat([new kt(`${H}[1]`,G[1],"expressions are not allowed in function stops.")]):U.concat(lr({key:`${H}[1]`,value:G[1],valueSpec:e,style:B.style,styleSpec:B.styleSpec}))}function D(B,U){const G=vi(B.value),H=sn(B.value),ne=B.value!==null?B.value:U;if(r){if(G!==r)return[new kt(B.key,ne,`${G} stop domain type must match previous stop domain type ${r}`)]}else r=G;if(G!=="number"&&G!=="string"&&G!=="boolean"&&typeof H!="number"&&typeof H!="string"&&typeof H!="boolean")return[new kt(B.key,ne,"stop domain value must be a number, string, or boolean")];if(G!=="number"&&i!=="categorical"){let de=`number expected, ${G} found`;return Vn(e)&&i===void 0&&(de+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new kt(B.key,ne,de)]}return i!=="categorical"||G!=="number"||typeof H=="number"&&isFinite(H)&&Math.floor(H)===H?i!=="categorical"&&G==="number"&&typeof H=="number"&&typeof u=="number"&&u!==void 0&&Hnew kt(`${t.key}${r.key}`,t.value,r.message));const i=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!i.outputDefined())return[new kt(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"&&!Wr(i))return[new kt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return Il(i,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!lo(i,["zoom","feature-state"]))return[new kt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!So(i))return[new kt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Il(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const u of e.valueSpec.expression.parameters)i.delete(u);if(i.size===0)return[];const r=[];return t instanceof or&&i.has(t.name)?[new kt(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(u=>{r.push(...Il(u,e))}),r)}function Tu(t){const e=t.key,i=t.value,r=t.valueSpec,u=[];return Array.isArray(r.values)?r.values.indexOf(sn(i))===-1&&u.push(new kt(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(r.values).indexOf(sn(i))===-1&&u.push(new kt(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),u}function Ic(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(!Ic(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Su(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Ic(t)||(t=Fa(t));const i=t;let r=!0;try{r=function(T){if(!Ba(T))return T;let C=An(T);return Iu(C),C=Ef(C),C}(i)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. 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 and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(i,null,2)} `)}const u=Ge[`filter_${e}`],f=Na(r,u);let m=null;if(f.result==="error")throw new Error(f.value.map(T=>`${T.key}: ${T.message}`).join(", "));m=(T,C,L)=>f.value.evaluate(T,C,{},L);let y=null,E=null;if(r!==i){const T=Na(i,u);if(T.result==="error")throw new Error(T.value.map(C=>`${C.key}: ${C.message}`).join(", "));y=(C,L,D,B,U)=>T.value.evaluate(C,L,{},D,void 0,void 0,B,U),E=!So(T.value.expression)}return{filter:m,dynamicFilter:y||void 0,needGeometry:Tf(r),needFeature:!!E}}function Ef(t){if(!Array.isArray(t))return t;const e=function(i){if(kc.has(i[0])){for(let r=1;rEf(i))}function Iu(t){let e=!1;const i=[];if(t[0]==="case"){for(let r=1;r",">=","<","<=","to-boolean"]);function Xd(t,e){return te?1:0}function Tf(t){if(!Array.isArray(t))return!1;if(t[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?Mc(t[1],t[2],e):e==="any"?(i=t.slice(1),["any"].concat(i.map(Fa))):e==="all"?["all"].concat(t.slice(1).map(Fa)):e==="none"?["all"].concat(t.slice(1).map(Fa).map(ku)):e==="in"?Ac(t[1],t.slice(2)):e==="!in"?ku(Ac(t[1],t.slice(2))):e==="has"?Cc(t[1]):e==="!has"?ku(Cc(t[1])):e!=="within"||t;var i}function Mc(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Ac(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(i=>typeof i!=typeof e[0])?["filter-in-large",t,["literal",e.sort(Xd)]]:["filter-in-small",t,["literal",e]]}}function Cc(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ku(t){return["!",t]}function kl(t){return Ic(An(t.value))?Gn(nr({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Ml(t)}function Ml(t){const e=t.value,i=t.key;if(vi(e)!=="array")return[new kt(i,e,`array expected, ${vi(e)} found`)];const r=t.styleSpec;let u,f=[];if(e.length<1)return[new kt(i,e,"filter array must have at least 1 element")];switch(f=f.concat(Tu({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),sn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&sn(e[1])==="$type"&&f.push(new kt(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&f.push(new kt(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(u=vi(e[1]),u!=="string"&&f.push(new kt(`${i}[1]`,e[1],`string expected, ${u} found`)));for(let m=2;m{T in i&&e.push(new kt(r,i[T],`"${T}" is prohibited for ref layers`))}),u.layers.forEach(T=>{sn(T.id)===y&&(E=T)}),E?E.ref?e.push(new kt(r,i.ref,"ref cannot reference another ref layer")):m=sn(E.type):typeof y=="string"&&e.push(new kt(r,i.ref,`ref layer "${y}" not found`))}else if(m!=="background"&&m!=="sky")if(i.source){const E=u.sources&&u.sources[i.source],T=E&&sn(E.type);E?T==="vector"&&m==="raster"?e.push(new kt(r,i.source,`layer "${i.id}" requires a raster source`)):T==="raster"&&m!=="raster"?e.push(new kt(r,i.source,`layer "${i.id}" requires a vector source`)):T!=="vector"||i["source-layer"]?T==="raster-dem"&&m!=="hillshade"?e.push(new kt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):m!=="line"||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||T==="geojson"&&E.lineMetrics||e.push(new kt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new kt(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new kt(r,i.source,`source "${i.source}" not found`))}else e.push(new kt(r,i,'missing required property "source"'));return e=e.concat(co({key:r,value:i,valueSpec:f.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>lr({key:`${r}.type`,value:i.type,valueSpec:f.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:E=>kl(nr({layerType:m},E)),layout:E=>co({layer:i,key:E.key,value:E.value,valueSpec:{},style:E.style,styleSpec:E.styleSpec,objectElementValidators:{"*":T=>Lc(nr({layerType:m},T))}}),paint:E=>co({layer:i,key:E.key,value:E.value,valueSpec:{},style:E.style,styleSpec:E.styleSpec,objectElementValidators:{"*":T=>Sf(nr({layerType:m},T))}})}})),e}function Es(t){const e=t.value,i=t.key,r=vi(e);return r!=="string"?[new kt(i,e,`string expected, ${r} found`)]:[]}const kf={promoteId:function({key:t,value:e}){if(vi(e)==="string")return Es({key:t,value:e});{const i=[];for(const r in e)i.push(...Es({key:`${t}.${r}`,value:e[r]}));return i}}};function Mf(t){const e=t.value,i=t.key,r=t.styleSpec,u=t.style;if(!e.type)return[new kt(i,e,'"type" is required')];const f=sn(e.type);let m;switch(f){case"vector":case"raster":case"raster-dem":return m=co({key:i,value:e,valueSpec:r[`source_${f.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:kf}),m;case"geojson":if(m=co({key:i,value:e,valueSpec:r.source_geojson,style:u,styleSpec:r,objectElementValidators:kf}),e.cluster)for(const y in e.clusterProperties){const[E,T]=e.clusterProperties[y],C=typeof E=="string"?[E,["accumulated"],["get",y]]:E;m.push(...Gn({key:`${i}.${y}.map`,value:T,expressionContext:"cluster-map"})),m.push(...Gn({key:`${i}.${y}.reduce`,value:C,expressionContext:"cluster-reduce"}))}return m;case"video":return co({key:i,value:e,valueSpec:r.source_video,style:u,styleSpec:r});case"image":return co({key:i,value:e,valueSpec:r.source_image,style:u,styleSpec:r});case"canvas":return[new kt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Tu({key:`${i}.type`,value:e.type,valueSpec:{values:Wd(r)},style:u,styleSpec:r})}}function Wd(t){return t.source.reduce((e,i)=>{const r=t[i];return r.type.type==="enum"&&(e=e.concat(Object.keys(r.type.values))),e},[])}function Af(t){const e=t.value,i=t.styleSpec,r=i.light,u=t.style;let f=[];const m=vi(e);if(e===void 0)return f;if(m!=="object")return f=f.concat([new kt("light",e,`object expected, ${m} found`)]),f;for(const y in e){const E=y.match(/^(.*)-transition$/);f=f.concat(E&&r[E[1]]&&r[E[1]].transition?lr({key:y,value:e[y],valueSpec:i.transition,style:u,styleSpec:i}):r[y]?lr({key:y,value:e[y],valueSpec:r[y],style:u,styleSpec:i}):[new kt(y,e[y],`unknown property "${y}"`)])}return f}function Rc(t){const e=t.value,i=t.key,r=t.style,u=t.styleSpec,f=u.terrain;let m=[];const y=vi(e);if(e===void 0)return m;if(y!=="object")return m=m.concat([new kt("terrain",e,`object expected, ${y} found`)]),m;for(const E in e){const T=E.match(/^(.*)-transition$/);m=m.concat(T&&f[T[1]]&&f[T[1]].transition?lr({key:E,value:e[E],valueSpec:u.transition,style:r,styleSpec:u}):f[E]?lr({key:E,value:e[E],valueSpec:f[E],style:r,styleSpec:u}):[new kt(E,e[E],`unknown property "${E}"`)])}if(e.source){const E=r.sources&&r.sources[e.source],T=E&&sn(E.type);E?T!=="raster-dem"&&m.push(new kt(i,e.source,`terrain cannot be used with a source of type ${String(T)}, it only be used with a "raster-dem" source type`)):m.push(new kt(i,e.source,`source "${e.source}" not found`))}else m.push(new kt(i,e,'terrain is missing required property "source"'));return m}function Cf(t){const e=t.value,i=t.style,r=t.styleSpec,u=r.fog;let f=[];const m=vi(e);if(e===void 0)return f;if(m!=="object")return f=f.concat([new kt("fog",e,`object expected, ${m} found`)]),f;for(const y in e){const E=y.match(/^(.*)-transition$/);f=f.concat(E&&u[E[1]]&&u[E[1]].transition?lr({key:y,value:e[y],valueSpec:r.transition,style:i,styleSpec:r}):u[y]?lr({key:y,value:e[y],valueSpec:u[y],style:i,styleSpec:r}):[new kt(y,e[y],`unknown property "${y}"`)])}return f}const Pf={"*":()=>[],array:wf,boolean:function(t){const e=t.value,i=t.key,r=vi(e);return r!=="boolean"?[new kt(i,e,`boolean expected, ${r} found`)]:[]},number:Tl,color:function(t){const e=t.key,i=t.value,r=vi(i);return r!=="string"?[new kt(e,i,`color expected, ${r} found`)]:Ji(i)===null?[new kt(e,i,`color expected, "${i}" found`)]:[]},enum:Tu,filter:kl,function:Sl,layer:If,object:co,source:Mf,light:Af,terrain:Rc,fog:Cf,string:Es,formatted:function(t){return Es(t).length===0?[]:Gn(t)},resolvedImage:function(t){return Es(t).length===0?[]:Gn(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,u=t.style;let f=[];const m=vi(e);if(m==="object")for(const y in e)f=f.concat(lr({key:y,value:e[y],valueSpec:r[y],style:u,styleSpec:i}));else m!=="string"&&(f=f.concat([new kt("projection",e,`object or string expected, ${m} found`)]));return f}};function lr(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&uo(sn(e))?Sl(t):i.expression&&za(An(e))?Gn(t):i.type&&Pf[i.type]?Pf[i.type](t):co(nr({},t,{valueSpec:i.type?r[i.type]:i}))}function Yd(t){const e=t.value,i=t.key,r=Es(t);return r.length||(e.indexOf("{fontstack}")===-1&&r.push(new kt(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&r.push(new kt(i,e,'"glyphs" url must include a "{range}" token'))),r}function Lf(t,e=Ge){return Kr(lr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Yd,"*":()=>[]}}))}const Hd=t=>Kr(Sf(t)),Kd=t=>Kr(Lc(t));function Kr(t){return t.slice().sort((e,i)=>e.line&&i.line?e.line-i.line:0)}function Rf(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new xn(new Error(r.message))),i=!0;return i}var Jd=Io,ho=3;function Io(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var u=new Int32Array(this.arrayBuffer);t=u[0],this.d=(e=u[1])+2*(i=u[2]);for(var f=0;f=C[B+0]&&r>=C[B+1])?(m[D]=!0,f.push(T[D])):m[D]=!1}}},Io.prototype._forEachCell=function(t,e,i,r,u,f,m,y){for(var E=this._convertToCellCoord(t),T=this._convertToCellCoord(e),C=this._convertToCellCoord(i),L=this._convertToCellCoord(r),D=E;D<=C;D++)for(var B=T;B<=L;B++){var U=this.d*B+D;if((!y||y(this._convertFromCellCoord(D),this._convertFromCellCoord(B),this._convertFromCellCoord(D+1),this._convertFromCellCoord(B+1)))&&u.call(this,t,e,i,r,U,f,m,y))return}},Io.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Io.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Io.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=ho+this.cells.length+1+1,i=0,r=0;r=0||(u[f]=Ua(t[f],e)));t instanceof Error&&(u.message=t.message)}if(u.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(u.$name=r),u}throw new Error("can't serialize object of type "+typeof t)}function Qs(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||Dc(t)||Oc(t)||ArrayBuffer.isView(t)||t instanceof Z.ImageData)return t;if(Array.isArray(t))return t.map(Qs);if(typeof t=="object"){const e=t.$name||"Object",{klass:i}=Mu[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const u of Object.keys(t))u!=="$name"&&(r[u]=Qs(t[u]));return r}throw new Error("can't deserialize object of type "+typeof t)}const wt={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function zc(t){for(const e of t)if(Nc(e.charCodeAt(0)))return!0;return!1}function Qd(t){for(const e of t)if(!Df(e.charCodeAt(0)))return!1;return!0}function Df(t){return!(wt.Arabic(t)||wt["Arabic Supplement"](t)||wt["Arabic Extended-A"](t)||wt["Arabic Presentation Forms-A"](t)||wt["Arabic Presentation Forms-B"](t))}function Nc(t){return!(t!==746&&t!==747&&(t<4352||!(wt["Bopomofo Extended"](t)||wt.Bopomofo(t)||wt["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||wt["CJK Compatibility Ideographs"](t)||wt["CJK Compatibility"](t)||wt["CJK Radicals Supplement"](t)||wt["CJK Strokes"](t)||!(!wt["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||wt["CJK Unified Ideographs Extension A"](t)||wt["CJK Unified Ideographs"](t)||wt["Enclosed CJK Letters and Months"](t)||wt["Hangul Compatibility Jamo"](t)||wt["Hangul Jamo Extended-A"](t)||wt["Hangul Jamo Extended-B"](t)||wt["Hangul Jamo"](t)||wt["Hangul Syllables"](t)||wt.Hiragana(t)||wt["Ideographic Description Characters"](t)||wt.Kanbun(t)||wt["Kangxi Radicals"](t)||wt["Katakana Phonetic Extensions"](t)||wt.Katakana(t)&&t!==12540||!(!wt["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)||!(!wt["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||wt["Unified Canadian Aboriginal Syllabics"](t)||wt["Unified Canadian Aboriginal Syllabics Extended"](t)||wt["Vertical Forms"](t)||wt["Yijing Hexagram Symbols"](t)||wt["Yi Syllables"](t)||wt["Yi Radicals"](t))))}function Of(t){return!(Nc(t)||function(e){return!!(wt["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||wt["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)||wt["Letterlike Symbols"](e)||wt["Number Forms"](e)||wt["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)||wt["Control Pictures"](e)&&e!==9251||wt["Optical Character Recognition"](e)||wt["Enclosed Alphanumerics"](e)||wt["Geometric Shapes"](e)||wt["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||wt["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||wt["CJK Symbols and Punctuation"](e)||wt.Katakana(e)||wt["Private Use Area"](e)||wt["CJK Compatibility Forms"](e)||wt["Small Form Variants"](e)||wt["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 zf(t){return t>=1424&&t<=2303||wt["Arabic Presentation Forms-A"](t)||wt["Arabic Presentation Forms-B"](t)}function em(t,e){return!(!e&&zf(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||wt.Khmer(t))}function tm(t){for(const e of t)if(zf(e.charCodeAt(0)))return!0;return!1}const Bc="deferred",Fc="loading",Uc="loaded";let ja=null,h="unavailable",n=null;const a=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(h="error"),ja&&ja(t)};function p(){_.fire(new Fo("pluginStateChange",{pluginStatus:h,pluginURL:n}))}const _=new qr,b=function(){return h},I=function(){if(h!==Bc||!n)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");h=Fc,p(),n&&ms({url:n},t=>{t?a(t):(h=Uc,p())})},M={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>h===Uc||M.applyArabicShaping!=null,isLoading:()=>h===Fc,setState(t){h=t.pluginStatus,n=t.pluginURL},isParsed:()=>M.applyArabicShaping!=null&&M.processBidirectionalText!=null&&M.processStyledBidirectionalText!=null,getPluginURL:()=>n};class P{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(i,r){for(const u of i)if(!em(u.charCodeAt(0),r))return!1;return!0}(e,M.isLoaded())}}class N{constructor(e,i){this.property=e,this.value=i,this.expression=function(r,u){if(uo(r))return new wu(r,u);if(za(r)){const f=El(r,u);if(f.result==="error")throw new Error(f.value.map(m=>`${m.key}: ${m.message}`).join(", "));return f.value}{let f=r;return typeof r=="string"&&u.type==="color"&&(f=hn.parse(r)),{kind:"constant",evaluate:()=>f}}}(i===void 0?e.specification.default:i,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,r){return this.property.possiblyEvaluate(this,e,i,r)}}class z{constructor(e){this.property=e,this.value=new N(e,void 0)}transitioned(e,i){return new Y(this.property,this.value,i,Wt({},e.transition,this.transition),e.now)}untransitioned(){return new Y(this.property,this.value,null,{},0)}}class j{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return rn(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new z(this._values[e].property)),this._values[e].value=new N(this._values[e].property,i===null?void 0:rn(i))}getTransition(e){return rn(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new z(this._values[e].property)),this._values[e].transition=rn(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const r=this.getValue(i);r!==void 0&&(e[i]=r);const u=this.getTransition(i);u!==void 0&&(e[`${i}-transition`]=u)}return e}transitioned(e,i){const r=new J(this._properties);for(const u of Object.keys(this._values))r._values[u]=this._values[u].transitioned(e,i._values[u]);return r}untransitioned(){const e=new J(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class Y{constructor(e,i,r,u,f){const m=u.delay||0,y=u.duration||0;f=f||0,this.property=e,this.value=i,this.begin=f+m,this.end=this.begin+y,e.specification.transition&&(u.delay||u.duration)&&(this.prior=r)}possiblyEvaluate(e,i,r){const u=e.now||0,f=this.value.possiblyEvaluate(e,i,r),m=this.prior;if(m){if(u>this.end)return this.prior=null,f;if(this.value.isDataDriven())return this.prior=null,f;if(uthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_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 ke(t,e=1){let i=0,r=0;return{members:t.map(u=>{const f=Te[u.type].BYTES_PER_ELEMENT,m=i=Ne(i,Math.max(e,f)),y=u.components||1;return r=Math.max(r,f),i+=f*y,{name:u.name,type:u.type,components:y,offset:m}}),size:Ne(i,Math.max(r,e)),alignment:e}}function Ne(t,e){return Math.ceil(t/e)*e}class tt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){const u=2*e;return this.int16[u+0]=i,this.int16[u+1]=r,e}}tt.prototype.bytesPerElement=4,Ct(tt,"StructArrayLayout2i4");class Re extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,r)}emplace(e,i,r,u){const f=3*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=u,e}}Re.prototype.bytesPerElement=6,Ct(Re,"StructArrayLayout3i6");class We extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,u){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,u)}emplace(e,i,r,u,f){const m=4*e;return this.int16[m+0]=i,this.int16[m+1]=r,this.int16[m+2]=u,this.int16[m+3]=f,e}}We.prototype.bytesPerElement=8,Ct(We,"StructArrayLayout4i8");class je extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y){const E=this.length;return this.resize(E+1),this.emplace(E,e,i,r,u,f,m,y)}emplace(e,i,r,u,f,m,y,E){const T=6*e,C=12*e,L=3*e;return this.int16[T+0]=i,this.int16[T+1]=r,this.uint8[C+4]=u,this.uint8[C+5]=f,this.uint8[C+6]=m,this.uint8[C+7]=y,this.float32[L+2]=E,e}}je.prototype.bytesPerElement=12,Ct(je,"StructArrayLayout2i4ub1f12");class et extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,u)}emplace(e,i,r,u,f){const m=4*e;return this.float32[m+0]=i,this.float32[m+1]=r,this.float32[m+2]=u,this.float32[m+3]=f,e}}et.prototype.bytesPerElement=16,Ct(et,"StructArrayLayout4f16");class ze extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,r,u,f)}emplace(e,i,r,u,f,m){const y=6*e,E=3*e;return this.uint16[y+0]=i,this.uint16[y+1]=r,this.uint16[y+2]=u,this.uint16[y+3]=f,this.float32[E+2]=m,e}}ze.prototype.bytesPerElement=12,Ct(ze,"StructArrayLayout4ui1f12");class Ze extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,u){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,u)}emplace(e,i,r,u,f){const m=4*e;return this.uint16[m+0]=i,this.uint16[m+1]=r,this.uint16[m+2]=u,this.uint16[m+3]=f,e}}Ze.prototype.bytesPerElement=8,Ct(Ze,"StructArrayLayout4ui8");class rt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,i,r,u,f,m)}emplace(e,i,r,u,f,m,y){const E=6*e;return this.int16[E+0]=i,this.int16[E+1]=r,this.int16[E+2]=u,this.int16[E+3]=f,this.int16[E+4]=m,this.int16[E+5]=y,e}}rt.prototype.bytesPerElement=12,Ct(rt,"StructArrayLayout6i12");class Ke extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y,E,T,C,L,D){const B=this.length;return this.resize(B+1),this.emplace(B,e,i,r,u,f,m,y,E,T,C,L,D)}emplace(e,i,r,u,f,m,y,E,T,C,L,D,B){const U=12*e;return this.int16[U+0]=i,this.int16[U+1]=r,this.int16[U+2]=u,this.int16[U+3]=f,this.uint16[U+4]=m,this.uint16[U+5]=y,this.uint16[U+6]=E,this.uint16[U+7]=T,this.int16[U+8]=C,this.int16[U+9]=L,this.int16[U+10]=D,this.int16[U+11]=B,e}}Ke.prototype.bytesPerElement=24,Ct(Ke,"StructArrayLayout4i4ui4i24");class st extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,i,r,u,f,m)}emplace(e,i,r,u,f,m,y){const E=10*e,T=5*e;return this.int16[E+0]=i,this.int16[E+1]=r,this.int16[E+2]=u,this.float32[T+2]=f,this.float32[T+3]=m,this.float32[T+4]=y,e}}st.prototype.bytesPerElement=20,Ct(st,"StructArrayLayout3i3f20");class zt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}zt.prototype.bytesPerElement=4,Ct(zt,"StructArrayLayout1ul4");class Kt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y,E,T,C,L,D,B){const U=this.length;return this.resize(U+1),this.emplace(U,e,i,r,u,f,m,y,E,T,C,L,D,B)}emplace(e,i,r,u,f,m,y,E,T,C,L,D,B,U){const G=20*e,H=10*e;return this.int16[G+0]=i,this.int16[G+1]=r,this.int16[G+2]=u,this.int16[G+3]=f,this.int16[G+4]=m,this.float32[H+3]=y,this.float32[H+4]=E,this.float32[H+5]=T,this.float32[H+6]=C,this.int16[G+14]=L,this.uint32[H+8]=D,this.uint16[G+18]=B,this.uint16[G+19]=U,e}}Kt.prototype.bytesPerElement=40,Ct(Kt,"StructArrayLayout5i4f1i1ul2ui40");class Pt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y){const E=this.length;return this.resize(E+1),this.emplace(E,e,i,r,u,f,m,y)}emplace(e,i,r,u,f,m,y,E){const T=8*e;return this.int16[T+0]=i,this.int16[T+1]=r,this.int16[T+2]=u,this.int16[T+4]=f,this.int16[T+5]=m,this.int16[T+6]=y,this.int16[T+7]=E,e}}Pt.prototype.bytesPerElement=16,Ct(Pt,"StructArrayLayout3i2i2i16");class jt extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,r,u,f)}emplace(e,i,r,u,f,m){const y=4*e,E=8*e;return this.float32[y+0]=i,this.float32[y+1]=r,this.float32[y+2]=u,this.int16[E+6]=f,this.int16[E+7]=m,e}}jt.prototype.bytesPerElement=16,Ct(jt,"StructArrayLayout2f1f2i16");class mi extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,u)}emplace(e,i,r,u,f){const m=12*e,y=3*e;return this.uint8[m+0]=i,this.uint8[m+1]=r,this.float32[y+1]=u,this.float32[y+2]=f,e}}mi.prototype.bytesPerElement=12,Ct(mi,"StructArrayLayout2ub2f12");class di extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,r)}emplace(e,i,r,u){const f=3*e;return this.float32[f+0]=i,this.float32[f+1]=r,this.float32[f+2]=u,e}}di.prototype.bytesPerElement=12,Ct(di,"StructArrayLayout3f12");class Ot extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,r)}emplace(e,i,r,u){const f=3*e;return this.uint16[f+0]=i,this.uint16[f+1]=r,this.uint16[f+2]=u,e}}Ot.prototype.bytesPerElement=6,Ct(Ot,"StructArrayLayout3ui6");class Di extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve){const ge=this.length;return this.resize(ge+1),this.emplace(ge,e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve)}emplace(e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve,ge){const Be=30*e,De=15*e,qe=60*e;return this.int16[Be+0]=i,this.int16[Be+1]=r,this.int16[Be+2]=u,this.float32[De+2]=f,this.float32[De+3]=m,this.uint16[Be+8]=y,this.uint16[Be+9]=E,this.uint32[De+5]=T,this.uint32[De+6]=C,this.uint32[De+7]=L,this.uint16[Be+16]=D,this.uint16[Be+17]=B,this.uint16[Be+18]=U,this.float32[De+10]=G,this.float32[De+11]=H,this.uint8[qe+48]=ne,this.uint8[qe+49]=de,this.uint8[qe+50]=re,this.uint32[De+13]=fe,this.int16[Be+28]=ve,this.uint8[qe+58]=ge,e}}Di.prototype.bytesPerElement=60,Ct(Di,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Bi extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve,ge,Be,De,qe,it,Ve,Ye,He,Je){const at=this.length;return this.resize(at+1),this.emplace(at,e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve,ge,Be,De,qe,it,Ve,Ye,He,Je)}emplace(e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H,ne,de,re,fe,ve,ge,Be,De,qe,it,Ve,Ye,He,Je,at){const $e=38*e,vt=19*e;return this.int16[$e+0]=i,this.int16[$e+1]=r,this.int16[$e+2]=u,this.float32[vt+2]=f,this.float32[vt+3]=m,this.int16[$e+8]=y,this.int16[$e+9]=E,this.int16[$e+10]=T,this.int16[$e+11]=C,this.int16[$e+12]=L,this.int16[$e+13]=D,this.uint16[$e+14]=B,this.uint16[$e+15]=U,this.uint16[$e+16]=G,this.uint16[$e+17]=H,this.uint16[$e+18]=ne,this.uint16[$e+19]=de,this.uint16[$e+20]=re,this.uint16[$e+21]=fe,this.uint16[$e+22]=ve,this.uint16[$e+23]=ge,this.uint16[$e+24]=Be,this.uint16[$e+25]=De,this.uint16[$e+26]=qe,this.uint16[$e+27]=it,this.uint16[$e+28]=Ve,this.uint32[vt+15]=Ye,this.float32[vt+16]=He,this.float32[vt+17]=Je,this.float32[vt+18]=at,e}}Bi.prototype.bytesPerElement=76,Ct(Bi,"StructArrayLayout3i2f6i15ui1ul3f76");class Fi extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}Fi.prototype.bytesPerElement=4,Ct(Fi,"StructArrayLayout1f4");class Ui extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,u,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,r,u,f)}emplace(e,i,r,u,f,m){const y=5*e;return this.float32[y+0]=i,this.float32[y+1]=r,this.float32[y+2]=u,this.float32[y+3]=f,this.float32[y+4]=m,e}}Ui.prototype.bytesPerElement=20,Ct(Ui,"StructArrayLayout5f20");class ur extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,u){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,u)}emplace(e,i,r,u,f){const m=6*e;return this.uint32[3*e+0]=i,this.uint16[m+2]=r,this.uint16[m+3]=u,this.uint16[m+4]=f,e}}ur.prototype.bytesPerElement=12,Ct(ur,"StructArrayLayout1ul3ui12");class $n extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){const u=2*e;return this.uint16[u+0]=i,this.uint16[u+1]=r,e}}$n.prototype.bytesPerElement=4,Ct($n,"StructArrayLayout2ui4");class Jr extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}Jr.prototype.bytesPerElement=2,Ct(Jr,"StructArrayLayout1ui2");class ko extends Ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){const u=2*e;return this.float32[u+0]=i,this.float32[u+1]=r,e}}ko.prototype.bytesPerElement=8,Ct(ko,"StructArrayLayout2f8");class on extends be{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]}}on.prototype.size=40;class ji extends Kt{get(e){return new on(this,e)}}Ct(ji,"CollisionBoxArray");class ki extends be{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}}ki.prototype.size=60;class wn extends Di{get(e){return new ki(this,e)}}Ct(wn,"PlacedSymbolArray");class gr extends be{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}gr.prototype.size=76;class nn extends Bi{get(e){return new gr(this,e)}}Ct(nn,"SymbolInstanceArray");class kr extends Fi{getoffsetX(e){return this.float32[1*e+0]}}Ct(kr,"GlyphOffsetArray");class Au extends tt{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ct(Au,"SymbolLineVertexArray");class ea extends be{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]}}ea.prototype.size=12;class Al extends ur{get(e){return new ea(this,e)}}Ct(Al,"FeatureIndexArray");class Ho extends $n{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ct(Ho,"FillExtrusionCentroidArray");const Ts=ke([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ta=ke([{name:"a_dash",components:4,type:"Uint16"}]);var Cu={exports:{}},Cl={exports:{}};Cl.exports=function(t,e){var i,r,u,f,m,y,E,T;for(r=t.length-(i=3&t.length),u=e,m=3432918353,y=461845907,T=0;T>>16)*m&65535)<<16)&4294967295)<<15|E>>>17))*y+(((E>>>16)*y&65535)<<16)&4294967295)<<13|u>>>19))+((5*(u>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(E=0,i){case 3:E^=(255&t.charCodeAt(T+2))<<16;case 2:E^=(255&t.charCodeAt(T+1))<<8;case 1:u^=E=(65535&(E=(E=(65535&(E^=255&t.charCodeAt(T)))*m+(((E>>>16)*m&65535)<<16)&4294967295)<<15|E>>>17))*y+(((E>>>16)*y&65535)<<16)&4294967295}return u^=t.length,u=2246822507*(65535&(u^=u>>>16))+((2246822507*(u>>>16)&65535)<<16)&4294967295,u=3266489909*(65535&(u^=u>>>13))+((3266489909*(u>>>16)&65535)<<16)&4294967295,(u^=u>>>16)>>>0};var jc=Cl.exports,Yv={exports:{}};Yv.exports=function(t,e){for(var i,r=t.length,u=e^r,f=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(f)|(255&t.charCodeAt(++f))<<8|(255&t.charCodeAt(++f))<<16|(255&t.charCodeAt(++f))<<24))+((1540483477*(i>>>16)&65535)<<16),u=1540483477*(65535&u)+((1540483477*(u>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++f;switch(r){case 3:u^=(255&t.charCodeAt(f+2))<<16;case 2:u^=(255&t.charCodeAt(f+1))<<8;case 1:u=1540483477*(65535&(u^=255&t.charCodeAt(f)))+((1540483477*(u>>>16)&65535)<<16)}return u=1540483477*(65535&(u^=u>>>13))+((1540483477*(u>>>16)&65535)<<16),(u^=u>>>15)>>>0};var Hv=jc,pI=Yv.exports;Cu.exports=Hv,Cu.exports.murmur3=Hv,Cu.exports.murmur2=pI;var im=Qe(Cu.exports);class Nf{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,r,u){this.ids.push(Kv(e)),this.positions.push(i,r,u)}getPositions(e){const i=Kv(e);let r=0,u=this.ids.length-1;for(;r>1;this.ids[m]>=i?u=m:r=m+1}const f=[];for(;this.ids[r]===i;)f.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return f}static serialize(e,i){const r=new Float64Array(e.ids),u=new Uint32Array(e.positions);return nm(r,u,0,r.length-1),i&&i.push(r.buffer,u.buffer),{ids:r,positions:u}}static deserialize(e){const i=new Nf;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function Kv(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:im(String(t))}function nm(t,e,i,r){for(;i>1];let f=i-1,m=r+1;for(;;){do f++;while(t[f]u);if(f>=m)break;Bf(t,f,m),Bf(e,3*f,3*m),Bf(e,3*f+1,3*m+1),Bf(e,3*f+2,3*m+2)}m-i`u_${u}`),this.type=r}setUniform(e,i,r,u,f){i.set(e,f,u.constantOr(this.value))}getBinding(e,i){return this.type==="color"?new Qv(e):new Ff(e)}}class Pu{constructor(e,i){this.uniformNames=i.map(r=>`u_${r}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,i,r,u,f){const m=f==="u_pattern"||f==="u_dash"?this.pattern:f==="u_pixel_ratio"?this.pixelRatio:null;m&&i.set(e,f,m)}getBinding(e,i){return i==="u_pattern"||i==="u_dash"?new Jv(e):new Ff(e)}}class na{constructor(e,i,r,u){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(f=>({name:`a_${f}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,r,u,f,m){const y=this.paintVertexArray.length,E=this.expression.evaluate(new P(0),i,{},f,u,m);this.paintVertexArray.resize(e),this._setPaintValue(y,e,E)}updatePaintArray(e,i,r,u,f){const m=this.expression.evaluate({zoom:0},r,u,void 0,f);this._setPaintValue(e,i,m)}_setPaintValue(e,i,r){if(this.type==="color"){const u=rm(r);for(let f=e;f`u_${y}_t`),this.type=r,this.useIntegerZoom=u,this.zoom=f,this.maxValue=0,this.paintVertexAttributes=i.map(y=>({name:`a_${y}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new m}populatePaintArray(e,i,r,u,f,m){const y=this.expression.evaluate(new P(this.zoom),i,{},f,u,m),E=this.expression.evaluate(new P(this.zoom+1),i,{},f,u,m),T=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(T,e,y,E)}updatePaintArray(e,i,r,u,f){const m=this.expression.evaluate({zoom:this.zoom},r,u,void 0,f),y=this.expression.evaluate({zoom:this.zoom+1},r,u,void 0,f);this._setPaintValue(e,i,m,y)}_setPaintValue(e,i,r,u){if(this.type==="color"){const f=rm(r),m=rm(u);for(let y=e;y!0){this.binders={},this._buffers=[];const u=[];for(const f in e.paint._values){if(!r(f))continue;const m=e.paint.get(f);if(!(m instanceof ee&&Vn(m.property.specification)))continue;const y=yI(f,e.type),E=m.value,T=m.property.specification.type,C=!!m.property.useIntegerZoom,L=f==="line-dasharray"||f.endsWith("pattern"),D=f==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(E.kind!=="constant"||D)if(E.kind==="source"||D||L){const B=e0(f,T,"source");this.binders[f]=L?new Va(E,y,T,B,e.id):new na(E,y,T,B),u.push(`/a_${f}`)}else{const B=e0(f,T,"composite");this.binders[f]=new Ko(E,y,T,C,i,B),u.push(`/z_${f}`)}else this.binders[f]=L?new Pu(E.value,y):new Vc(E.value,y,T),u.push(`/u_${f}`)}this.cacheKey=u.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof na||i instanceof Ko?i.maxValue:0}populatePaintArrays(e,i,r,u,f,m){for(const y in this.binders){const E=this.binders[y];(E instanceof na||E instanceof Ko||E instanceof Va)&&E.populatePaintArray(e,i,r,u,f,m)}}setConstantPatternPositions(e){for(const i in this.binders){const r=this.binders[i];r instanceof Pu&&r.setConstantPatternPositions(e)}}updatePaintArrays(e,i,r,u,f,m){let y=!1;for(const E in e){const T=i.getPositions(E);for(const C of T){const L=r.feature(C.index);for(const D in this.binders){const B=this.binders[D];if((B instanceof na||B instanceof Ko||B instanceof Va)&&B.expression.isStateDependent===!0){const U=u.paint.get(D);B.expression=U.value,B.updatePaintArray(C.start,C.end,L,e[E],f,m),y=!0}}}}return y}defines(){const e=[];for(const i in this.binders){const r=this.binders[i];(r instanceof Vc||r instanceof Pu)&&e.push(...r.uniformNames.map(u=>`#define HAS_UNIFORM_${u}`))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof na||r instanceof Ko||r instanceof Va)for(let u=0;u!0){this.programConfigurations={};for(const u of e)this.programConfigurations[u.id]=new Ga(u,i,r);this.needsUpload=!1,this._featureMap=new Nf,this._bufferOffset=0}populatePaintArrays(e,i,r,u,f,m,y){for(const E in this.programConfigurations)this.programConfigurations[E].populatePaintArrays(e,i,u,f,m,y);i.id!==void 0&&this._featureMap.add(i.id,r,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,r,u,f){for(const m of r)this.needsUpload=this.programConfigurations[m.id].updatePaintArrays(e,this._featureMap,i,m,u,f)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const _I={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function yI(t,e){return _I[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const vI={"line-pattern":{source:ze,composite:ze},"fill-pattern":{source:ze,composite:ze},"fill-extrusion-pattern":{source:ze,composite:ze},"line-dasharray":{source:Ze,composite:Ze}},xI={color:{source:ko,composite:et},number:{source:Fi,composite:ko}};function e0(t,e,i){const r=vI[t];return r&&r[i]||xI[e][i]}Ct(Vc,"ConstantBinder"),Ct(Pu,"PatternConstantBinder"),Ct(na,"SourceExpressionBinder"),Ct(Va,"PatternCompositeBinder"),Ct(Ko,"CompositeExpressionBinder"),Ct(Ga,"ProgramConfiguration",{omit:["_buffers"]}),Ct(Pl,"ProgramConfigurationSet");const t0="-transition";class Jo extends qr{constructor(e,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),i.layout&&(this._unevaluatedLayout=new te(i.layout)),i.paint)){this._transitionablePaint=new j(i.paint);for(const r in e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(const r in e.layout)this.setLayoutProperty(r,e.layout[r],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ie(i.paint)}}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i,r={}){i!=null&&this._validate(Kd,`layers.${this.id}.layout.${e}`,e,i,r)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,i):this.visibility=i)}getPaintProperty(e){return Ci(e,t0)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,r={}){if(i!=null&&this._validate(Hd,`layers.${this.id}.paint.${e}`,e,i,r))return!1;if(Ci(e,t0))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const u=this._transitionablePaint._values[e],f=u.value.isDataDriven(),m=u.value;this._transitionablePaint.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const y=this._transitionablePaint._values[e].value,E=y.isDataDriven(),T=Ci(e,"pattern")||e==="line-dasharray";return E||f||T||this._handleOverridablePaintPropertyUpdate(e,m,y)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,i,r){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),me(e,(i,r)=>!(i===void 0||r==="layout"&&!Object.keys(i).length||r==="paint"&&!Object.keys(i).length))}_validate(e,i,r,u,f={}){return(!f||f.validate!==!1)&&Rf(this,e.call(Lf,{key:i,layerType:this.type,objectKey:r,value:u,styleSpec:Ge,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof ee&&Vn(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Su(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const bI=ke([{name:"a_pos",components:2,type:"Int16"}],4),wI=ke([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class En{constructor(e=[]){this.segments=e}prepareSegment(e,i,r,u){let f=this.segments[this.segments.length-1];return e>En.MAX_VERTEX_ARRAY_LENGTH&&Ti(`Max vertices per segment is ${En.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!f||f.vertexLength+e>En.MAX_VERTEX_ARRAY_LENGTH||f.sortKey!==u)&&(f={vertexOffset:i.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},u!==void 0&&(f.sortKey=u),this.segments.push(f)),f}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,r,u){return new En([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:u,vaos:{},sortKey:0}])}}En.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ct(En,"SegmentVector");var Ft=8192;class $a{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):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 Vi?new Vi(e.lng,e.lat):Vi.convert(e),this}setSouthWest(e){return this._sw=e instanceof Vi?new Vi(e.lng,e.lat):Vi.convert(e),this}extend(e){const i=this._sw,r=this._ne;let u,f;if(e instanceof Vi)u=e,f=e;else{if(!(e instanceof $a))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend($a.convert(e)):this.extend(Vi.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Vi.convert(e)):this;if(u=e._sw,f=e._ne,!u||!f)return this}return i||r?(i.lng=Math.min(u.lng,i.lng),i.lat=Math.min(u.lat,i.lat),r.lng=Math.max(f.lng,r.lng),r.lat=Math.max(f.lat,r.lat)):(this._sw=new Vi(u.lng,u.lat),this._ne=new Vi(f.lng,f.lat)),this}getCenter(){return new Vi((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 Vi(this.getWest(),this.getNorth())}getSouthEast(){return new Vi(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=Vi.convert(e);let u=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(u=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&u}static convert(e){return!e||e instanceof $a?e:new $a(e)}}var Uf=1e-6,Qr=typeof Float32Array<"u"?Float32Array:Array;function i0(){var t=new Qr(9);return Qr!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function n0(t,e,i){var r=e[0],u=e[1],f=e[2],m=e[3],y=e[4],E=e[5],T=e[6],C=e[7],L=e[8],D=i[0],B=i[1],U=i[2],G=i[3],H=i[4],ne=i[5],de=i[6],re=i[7],fe=i[8];return t[0]=D*r+B*m+U*T,t[1]=D*u+B*y+U*C,t[2]=D*f+B*E+U*L,t[3]=G*r+H*m+ne*T,t[4]=G*u+H*y+ne*C,t[5]=G*f+H*E+ne*L,t[6]=de*r+re*m+fe*T,t[7]=de*u+re*y+fe*C,t[8]=de*f+re*E+fe*L,t}function Qo(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 om(t,e){var i=e[0],r=e[1],u=e[2],f=e[3],m=e[4],y=e[5],E=e[6],T=e[7],C=e[8],L=e[9],D=e[10],B=e[11],U=e[12],G=e[13],H=e[14],ne=e[15],de=i*y-r*m,re=i*E-u*m,fe=i*T-f*m,ve=r*E-u*y,ge=r*T-f*y,Be=u*T-f*E,De=C*G-L*U,qe=C*H-D*U,it=C*ne-B*U,Ve=L*H-D*G,Ye=L*ne-B*G,He=D*ne-B*H,Je=de*He-re*Ye+fe*Ve+ve*it-ge*qe+Be*De;return Je?(t[0]=(y*He-E*Ye+T*Ve)*(Je=1/Je),t[1]=(u*Ye-r*He-f*Ve)*Je,t[2]=(G*Be-H*ge+ne*ve)*Je,t[3]=(D*ge-L*Be-B*ve)*Je,t[4]=(E*it-m*He-T*qe)*Je,t[5]=(i*He-u*it+f*qe)*Je,t[6]=(H*fe-U*Be-ne*re)*Je,t[7]=(C*Be-D*fe+B*re)*Je,t[8]=(m*Ye-y*it+T*De)*Je,t[9]=(r*it-i*Ye-f*De)*Je,t[10]=(U*ge-G*fe+ne*de)*Je,t[11]=(L*fe-C*ge-B*de)*Je,t[12]=(y*qe-m*Ve-E*De)*Je,t[13]=(i*Ve-r*qe+u*De)*Je,t[14]=(G*re-U*ve-H*de)*Je,t[15]=(C*ve-L*re+D*de)*Je,t):null}function Ll(t,e,i){var r=e[0],u=e[1],f=e[2],m=e[3],y=e[4],E=e[5],T=e[6],C=e[7],L=e[8],D=e[9],B=e[10],U=e[11],G=e[12],H=e[13],ne=e[14],de=e[15],re=i[0],fe=i[1],ve=i[2],ge=i[3];return t[0]=re*r+fe*y+ve*L+ge*G,t[1]=re*u+fe*E+ve*D+ge*H,t[2]=re*f+fe*T+ve*B+ge*ne,t[3]=re*m+fe*C+ve*U+ge*de,t[4]=(re=i[4])*r+(fe=i[5])*y+(ve=i[6])*L+(ge=i[7])*G,t[5]=re*u+fe*E+ve*D+ge*H,t[6]=re*f+fe*T+ve*B+ge*ne,t[7]=re*m+fe*C+ve*U+ge*de,t[8]=(re=i[8])*r+(fe=i[9])*y+(ve=i[10])*L+(ge=i[11])*G,t[9]=re*u+fe*E+ve*D+ge*H,t[10]=re*f+fe*T+ve*B+ge*ne,t[11]=re*m+fe*C+ve*U+ge*de,t[12]=(re=i[12])*r+(fe=i[13])*y+(ve=i[14])*L+(ge=i[15])*G,t[13]=re*u+fe*E+ve*D+ge*H,t[14]=re*f+fe*T+ve*B+ge*ne,t[15]=re*m+fe*C+ve*U+ge*de,t}function Gc(t,e,i){var r,u,f,m,y,E,T,C,L,D,B,U,G=i[0],H=i[1],ne=i[2];return e===t?(t[12]=e[0]*G+e[4]*H+e[8]*ne+e[12],t[13]=e[1]*G+e[5]*H+e[9]*ne+e[13],t[14]=e[2]*G+e[6]*H+e[10]*ne+e[14],t[15]=e[3]*G+e[7]*H+e[11]*ne+e[15]):(u=e[1],f=e[2],m=e[3],y=e[4],E=e[5],T=e[6],C=e[7],L=e[8],D=e[9],B=e[10],U=e[11],t[0]=r=e[0],t[1]=u,t[2]=f,t[3]=m,t[4]=y,t[5]=E,t[6]=T,t[7]=C,t[8]=L,t[9]=D,t[10]=B,t[11]=U,t[12]=r*G+y*H+L*ne+e[12],t[13]=u*G+E*H+D*ne+e[13],t[14]=f*G+T*H+B*ne+e[14],t[15]=m*G+C*H+U*ne+e[15]),t}function Rl(t,e,i){var r=i[0],u=i[1],f=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*u,t[5]=e[5]*u,t[6]=e[6]*u,t[7]=e[7]*u,t[8]=e[8]*f,t[9]=e[9]*f,t[10]=e[10]*f,t[11]=e[11]*f,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function sm(t,e,i){var r=Math.sin(i),u=Math.cos(i),f=e[4],m=e[5],y=e[6],E=e[7],T=e[8],C=e[9],L=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]=f*u+T*r,t[5]=m*u+C*r,t[6]=y*u+L*r,t[7]=E*u+D*r,t[8]=T*u-f*r,t[9]=C*u-m*r,t[10]=L*u-y*r,t[11]=D*u-E*r,t}function jf(t,e,i){var r=Math.sin(i),u=Math.cos(i),f=e[0],m=e[1],y=e[2],E=e[3],T=e[8],C=e[9],L=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]=f*u-T*r,t[1]=m*u-C*r,t[2]=y*u-L*r,t[3]=E*u-D*r,t[8]=f*r+T*u,t[9]=m*r+C*u,t[10]=y*r+L*u,t[11]=E*r+D*u,t}function r0(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}function o0(t,e,i){var r,u,f,m=i[0],y=i[1],E=i[2],T=Math.hypot(m,y,E);return T0&&(f=1/Math.sqrt(f)),t[0]=e[0]*f,t[1]=e[1]*f,t[2]=e[2]*f,t}function Mo(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function um(t,e,i){var r=e[0],u=e[1],f=e[2],m=i[0],y=i[1],E=i[2];return t[0]=u*E-f*y,t[1]=f*m-r*E,t[2]=r*y-u*m,t}function gn(t,e,i){var r=e[0],u=e[1],f=e[2],m=i[3]*r+i[7]*u+i[11]*f+i[15];return t[0]=(i[0]*r+i[4]*u+i[8]*f+i[12])/(m=m||1),t[1]=(i[1]*r+i[5]*u+i[9]*f+i[13])/m,t[2]=(i[2]*r+i[6]*u+i[10]*f+i[14])/m,t}function l0(t,e,i){var r=i[0],u=i[1],f=i[2],m=e[0],y=e[1],E=e[2],T=u*E-f*y,C=f*m-r*E,L=r*y-u*m,D=u*L-f*C,B=f*T-r*L,U=r*C-u*T,G=2*i[3];return C*=G,L*=G,B*=2,U*=2,t[0]=m+(T*=G)+(D*=2),t[1]=y+C+B,t[2]=E+L+U,t}var Wc,es=lm,TI=a0,SI=$c;function u0(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function c0(t,e){var i=e[0],r=e[1],u=e[2],f=e[3],m=i*i+r*r+u*u+f*f;return m>0&&(m=1/Math.sqrt(m)),t[0]=i*m,t[1]=r*m,t[2]=u*m,t[3]=f*m,t}function Dl(t,e,i){var r=e[0],u=e[1],f=e[2],m=e[3];return t[0]=i[0]*r+i[4]*u+i[8]*f+i[12]*m,t[1]=i[1]*r+i[5]*u+i[9]*f+i[13]*m,t[2]=i[2]*r+i[6]*u+i[10]*f+i[14]*m,t[3]=i[3]*r+i[7]*u+i[11]*f+i[15]*m,t}function h0(){var t=new Qr(4);return Qr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function f0(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function p0(t,e,i){i*=.5;var r=e[0],u=e[1],f=e[2],m=e[3],y=Math.sin(i),E=Math.cos(i);return t[0]=r*E+m*y,t[1]=u*E+f*y,t[2]=f*E-u*y,t[3]=m*E-r*y,t}function d0(t,e,i){i*=.5;var r=e[0],u=e[1],f=e[2],m=e[3],y=Math.sin(i),E=Math.cos(i);return t[0]=r*E-f*y,t[1]=u*E+m*y,t[2]=f*E+r*y,t[3]=m*E-u*y,t}am(),Wc=new Qr(4),Qr!=Float32Array&&(Wc[0]=0,Wc[1]=0,Wc[2]=0,Wc[3]=0);var II=c0;am(),Lu(1,0,0),Lu(0,1,0),h0(),h0(),i0();const kI=ke([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:m0}=kI,g0=ke([{name:"a_pos_3",components:3,type:"Int16"}]);var Yc=ke([{name:"a_pos",type:"Int16",components:2}]);class cm{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){const u=Mo(i,this.dir);if(Math.abs(u)<1e-6)return!1;const f=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/u;return r[0]=this.pos[0]+this.dir[0]*f,r[1]=this.pos[1]+this.dir[1]*f,r[2]=this.pos[2]+this.dir[2]*f,!0}closestPointOnSphere(e,i,r){if(function(B,U){var G=B[0],H=B[1],ne=B[2],de=U[0],re=U[1],fe=U[2];return Math.abs(G-de)<=Uf*Math.max(1,Math.abs(G),Math.abs(de))&&Math.abs(H-re)<=Uf*Math.max(1,Math.abs(H),Math.abs(re))&&Math.abs(ne-fe)<=Uf*Math.max(1,Math.abs(ne),Math.abs(fe))}(this.pos,e)||i===0)return r[0]=r[1]=r[2]=0,!1;const[u,f,m]=this.dir,y=this.pos[0]-e[0],E=this.pos[1]-e[1],T=this.pos[2]-e[2],C=u*u+f*f+m*m,L=2*(y*u+E*f+T*m),D=L*L-4*C*(y*y+E*E+T*T-i*i);if(D<0){const B=Math.max(-L/2,0),U=y+u*B,G=E+f*B,H=T+m*B,ne=Math.hypot(U,G,H);return r[0]=U*i/ne,r[1]=G*i/ne,r[2]=H*i/ne,!1}{const B=(-L-Math.sqrt(D))/(2*C);if(B<0){const U=Math.hypot(y,E,T);return r[0]=y*i/U,r[1]=E*i/U,r[2]=T*i/U,!1}return r[0]=y+u*B,r[1]=E+f*B,r[2]=T+m*B,!0}}}class hm{constructor(e,i,r,u,f){this.TL=e,this.TR=i,this.BR=r,this.BL=u,this.horizon=f}static fromInvProjectionMatrix(e,i,r){const u=[-1,1,1],f=[1,1,1],m=[1,-1,1],y=[-1,-1,1],E=gn(u,u,e),T=gn(f,f,e),C=gn(m,m,e),L=gn(y,y,e);return new hm(E,T,C,L,i/r)}}class fm{constructor(e,i){this.points=e,this.planes=i}static fromInvProjectionMatrix(e,i,r,u){const f=Math.pow(2,r),m=[[-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(E=>{const T=Dl([],E,e),C=1/T[3]/i*f;return function(L,D,B){return L[0]=D[0]*B[0],L[1]=D[1]*B[1],L[2]=D[2]*B[2],L[3]=D[3]*B[3],L}(T,T,[C,C,u?1/T[3]:C,C])}),y=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{const T=Mr([],um([],es([],m[E[0]],m[E[1]]),es([],m[E[2]],m[E[1]]))),C=-Mo(T,m[E[1]]);return T.concat(C)});return new fm(m,y)}}class Ar{static fromPoints(e){const i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const u of e)qc(i,i,u),Zc(r,r,u);return new Ar(i,r)}static applyTransform(e,i){const r=e.getCorners();for(let u=0;u=0;if(m===0)return 0;m!==i.length&&(r=!1)}if(r)return 2;for(let u=0;u<3;u++){let f=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let y=0;ythis.max[u]-this.min[u])return 0}return 1}}const pm=5,_0=6,Ss=Ft/Math.PI/2,MI=16383,Ol=64,Hc=[Ol,32,16],Ao=-Ss,Co=Ss,AI=[new Ar([Ao,Ao,Ao],[Co,Co,Co]),new Ar([Ao,Ao,Ao],[0,0,Co]),new Ar([0,Ao,Ao],[Co,0,Co]),new Ar([Ao,0,Ao],[0,Co,Co]),new Ar([0,0,Ao],[Co,Co,Co])];function Vf(t){return t*Ss/Qc}function y0(t,e,i,r=!0){const u=fo([],t._camera.position,t.worldSize),f=[e,i,1,1];Dl(f,f,t.pixelMatrixInverse),u0(f,f,1/f[3]);const m=Mr([],es([],f,u)),y=t.globeMatrix,E=[y[12],y[13],y[14]],T=es([],E,u),C=$c(T),L=Mr([],T),D=t.worldSize/(2*Math.PI),B=Mo(L,m),U=Math.asin(D/C);if(U1?null:function(r,u,f,m){const y=Math.sin(f);return r*(Math.sin((1-m)*f)/y)+u*(Math.sin(m*f)/y)}(t.a[e],t.b[e],t.angle,Rt(i,0,1))+t.center[e]}function Is(t){if(t.z<=1)return AI[t.z+2*t.y+t.x];const e=mm(Gf(t));return Ar.fromPoints(e)}function zl(t,e,i){return fo(t,t,1-i),Xc(t,t,e,i)}function v0(t,e){const i=Ou(e.zoom);if(i===0)return Is(t);const r=Gf(t),u=mm(r),f=ks(r.getWest())*e.worldSize,m=ks(r.getEast())*e.worldSize,y=Ms(r.getNorth())*e.worldSize,E=Ms(r.getSouth())*e.worldSize,T=[f,y,0],C=[m,y,0],L=[f,E,0],D=[m,E,0],B=om([],e.globeMatrix);return gn(T,T,B),gn(C,C,B),gn(L,L,B),gn(D,D,B),u[0]=zl(u[0],L,i),u[1]=zl(u[1],D,i),u[2]=zl(u[2],C,i),u[3]=zl(u[3],T,i),Ar.fromPoints(u)}function x0(t,e,i){for(const r of t)gn(r,r,e),fo(r,r,i)}function PI(t,e,i){const r=e/t.worldSize,u=t.globeMatrix;if(i.z<=1){const De=Is(i).getCorners();return x0(De,u,r),Ar.fromPoints(De)}const f=Gf(i),m=mm(f);x0(m,u,r);const y=Number.MAX_VALUE,E=[-y,-y,-y],T=[y,y,y];if(f.contains(t.center)){for(const it of m)qc(T,T,it),Zc(E,E,it);E[2]=0;const De=t.point,qe=[De.x*r,De.y*r,0];return qc(T,T,qe),Zc(E,E,qe),new Ar(T,E)}const C=[u[12]*r,u[13]*r,u[14]*r],L=f.getCenter(),D=Rt(t.center.lat,-hr,hr),B=Rt(L.lat,-hr,hr),U=ks(t.center.lng),G=Ms(D);let H=U-ks(L.lng);const ne=G-Ms(B);H>.5?H-=1:H<-.5&&(H+=1);let de=0;Math.abs(H)>Math.abs(ne)?de=H>=0?1:3:(de=ne>=0?0:2,Xc(C,C,[u[4]*r,u[5]*r,u[6]*r],-Math.sin(At(ne>=0?f.getSouth():f.getNorth()))*Ss));const re=m[de],fe=m[(de+1)%4],ve=new CI(re,fe,C),ge=[dm(ve,0)||re[0],dm(ve,1)||re[1],dm(ve,2)||re[2]],Be=Ou(t.zoom);if(Be>0){const De=function({x:it,y:Ve,z:Ye},He,Je,at,$e){const vt=1/(1<.5?Nt=-1:ri<-.5&&(Nt=1),Lt=((Lt+Nt)*He-(at*=He))*Je+at,xt=((xt+Nt)*He-at)*Je+at,ni=(ni*He-($e*=He))*Je+$e,lt=(lt*He-$e)*Je+$e,[[Lt,lt,0],[xt,lt,0],[xt,ni,0],[Lt,ni,0]]}(i,e,t._pixelsPerMercatorPixel,U,G);for(let it=0;itMath.PI/2*1.01}const T0=At(85),LI=Math.cos(T0),RI=Math.sin(T0),Qc=63710088e-1,S0=2*Math.PI*Qc;class qa{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new qa(St(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,r=this.lat*i,u=e.lat*i,f=Math.sin(r)*Math.sin(u)+Math.cos(r)*Math.cos(u)*Math.cos((e.lng-this.lng)*i);return Qc*Math.acos(Math.min(f,1))}toBounds(e=0){const i=360*e/40075017,r=i/Math.cos(Math.PI/180*this.lat);return new $a(new qa(this.lng-r,this.lat-i),new qa(this.lng+r,this.lat+i))}toEcef(e){const i=Vf(e);return Du(this.lat,this.lng,Ss+i)}static convert(e){if(e instanceof qa)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new qa(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new qa(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var Vi=qa;function ym(t){return S0*Math.cos(t*Math.PI/180)}function ks(t){return(180+t)/360}function Ms(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ts(t,e){return t/ym(e)}function po(t){return 360*t-180}function cr(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function I0(t,e){return t*ym(cr(e))}const hr=85.051129;function k0(t){return 1/Math.cos(t*Math.PI/180)}class zu{constructor(e,i,r=0){this.x=+e,this.y=+i,this.z=+r}static fromLngLat(e,i=0){const r=Vi.convert(e);return new zu(ks(r.lng),Ms(r.lat),ts(i,r.lat))}toLngLat(){return new Vi(po(this.x),cr(this.y))}toAltitude(){return I0(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/S0*k0(cr(this.y))}}function vm(t,e,i,r,u,f,m,y,E){const T=(e+r)/2,C=(i+u)/2,L=new Oe(T,C);y(L),function(D,B,U,G,H,ne){const de=U-H,re=G-ne;return Math.abs((G-B)*de-(U-D)*re)/Math.hypot(de,re)}(L.x,L.y,f.x,f.y,m.x,m.y)>=E?(vm(t,e,i,T,C,f,L,y,E),vm(t,T,C,r,u,L,m,y,E)):t.push(m)}function M0(t,e,i){let r=t[0],u=r.x,f=r.y;e(r);const m=[r];for(let y=1;yt.x+1||rt.y+1)&&Ti("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function oa(t,e,i){const r=t.loadGeometry(),u=t.extent,f=Ft/u;if(e&&i&&i.projection.isReprojectedInTileSpace){const m=1<{const B=po((e.x+D.x/u)/m),U=cr((e.y+D.y/u)/m),G=C.project(B,U);D.x=(G.x*y-E)*u,D.y=(G.y*y-T)*u};for(let D=0;D=u||U.y<0||U.y>=u||(L(U),B.push(U));r[D]=B}}for(const m of r)for(const y of m)OI(y,f);return r}function Nl(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?oa(t):[]}}function qf(t,e,i,r,u){t.emplaceBack(2*e+(r+1)/2,2*i+(u+1)/2)}function Zf(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class wm{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new tt,this.indexArray=new Ot,this.segments=new En,this.programConfigurations=new Pl(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,r,u){const f=this.layers[0],m=[];let y=null;f.type==="circle"&&(y=f.layout.get("circle-sort-key"));for(const{feature:T,id:C,index:L,sourceLayerIndex:D}of e){const B=this.layers[0]._featureFilter.needGeometry,U=Nl(T,B);if(!this.layers[0]._featureFilter.filter(new P(this.zoom),U,r))continue;const G=y?y.evaluate(U,{},r):void 0,H={id:C,properties:T.properties,type:T.type,sourceLayerIndex:D,index:L,geometry:B?U.geometry:oa(T,r,u),patterns:{},sortKey:G};m.push(H)}y&&m.sort((T,C)=>T.sortKey-C.sortKey);let E=null;u.projection.name==="globe"&&(this.globeExtVertexArray=new rt,E=u.projection);for(const T of m){const{geometry:C,index:L,sourceLayerIndex:D}=T,B=e[L].feature;this.addFeature(T,C,L,i.availableImages,r,E),i.featureIndex.insert(B,C,L,D,this.index)}}update(e,i,r,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,r,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,bI.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,wI.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,i,r,u,f,m){for(const y of i)for(const E of y){const T=E.x,C=E.y;if(T<0||T>=Ft||C<0||C>=Ft)continue;if(m){const B=m.projectTilePoint(T,C,f),U=m.upVector(f,T,C),G=this.globeExtVertexArray;Zf(G,B,U),Zf(G,B,U),Zf(G,B,U),Zf(G,B,U)}const L=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),D=L.vertexLength;qf(this.layoutVertexArray,T,C,-1,-1),qf(this.layoutVertexArray,T,C,1,-1),qf(this.layoutVertexArray,T,C,1,1),qf(this.layoutVertexArray,T,C,-1,1),this.indexArray.emplaceBack(D,D+1,D+2),this.indexArray.emplaceBack(D,D+2,D+3),L.vertexLength+=4,L.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},u,f)}}function C0(t,e){for(let i=0;i1){if(Em(t,e))return!0;for(let r=0;r1?i:i.sub(e)._mult(u)._add(e))}function R0(t,e){let i,r,u,f=!1;for(let m=0;me.y!=u.y>e.y&&e.x<(u.x-r.x)*(e.y-r.y)/(u.y-r.y)+r.x&&(f=!f)}return f}function Bl(t,e){let i=!1;for(let r=0,u=t.length-1;re.y!=m.y>e.y&&e.x<(m.x-f.x)*(e.y-f.y)/(m.y-f.y)+f.x&&(i=!i)}return i}function D0(t,e,i,r,u){for(const m of t)if(e<=m.x&&i<=m.y&&r>=m.x&&u>=m.y)return!0;const f=[new Oe(e,i),new Oe(e,u),new Oe(r,u),new Oe(r,i)];if(t.length>2){for(const m of f)if(Bl(t,m))return!0}for(let m=0;mu.x&&e.x>u.x||t.yu.y&&e.y>u.y)return!1;const f=pr(t,e,i[0]);return f!==pr(t,e,i[1])||f!==pr(t,e,i[2])||f!==pr(t,e,i[3])}function Nu(t,e,i){const r=e.paint.get(t).value;return r.kind==="constant"?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Xf(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function O0(t,e,i,r,u){if(!e[0]&&!e[1])return t;const f=Oe.convert(e)._mult(u);i==="viewport"&&f._rotate(-r);const m=[];for(let y=0;y0){const re=i.projection.upVector(T,B.x,B.y);G.x+=re[0]*C*U,G.y+=re[1]*C*U,G.z+=re[2]*C*U}const H=f?B:VI(G.x,G.y,G.z,r),ne=f?t.tilespaceRays.map(re=>$I(re,U)):t.queryGeometry.screenGeometry,de=Dl([],[G.x,G.y,G.z,1],r);if(!m&&f?E*=de[3]/i.cameraToCenterDistance:m&&!f&&(E*=i.cameraToCenterDistance/de[3]),f){const re=cr((D.y/Ft+T.y)/(1<t.width||u.height>t.height||i.x>t.width-u.width||i.y>t.height-u.height)throw new RangeError("out of range source coordinates for image copy");if(u.width>e.width||u.height>e.height||r.x>e.width-u.width||r.y>e.height-u.height)throw new RangeError("out of range destination coordinates for image copy");const m=t.data,y=e.data;for(let E=0;E{e[t.evaluationKey]=E;const T=t.expression.evaluate(e);u.data[m+y+0]=Math.floor(255*T.r/T.a),u.data[m+y+1]=Math.floor(255*T.g/T.a),u.data[m+y+2]=Math.floor(255*T.b/T.a),u.data[m+y+3]=Math.floor(255*T.a)};if(t.clips)for(let m=0,y=0;m80*i){r=f=t[0],u=m=t[1];for(var U=i;Uf&&(f=y),E>m&&(m=E);T=(T=Math.max(f-r,m-u))!==0?32767/T:0}return eh(D,B,i,r,u,T,0),B}function V0(t,e,i,r,u){var f,m;if(u===Cm(t,e,i,r)>0)for(f=e;f=e;f-=r)m=q0(f,t[f],t[f+1],m);return m&&Yf(m,m.next)&&(ih(m),m=m.next),m}function Fl(t,e){if(!t)return t;e||(e=t);var i,r=t;do if(i=!1,r.steiner||!Yf(r,r.next)&&Tn(r.prev,r,r.next)!==0)r=r.next;else{if(ih(r),(r=e=r.prev)===r.next)break;i=!0}while(i||r!==e);return e}function eh(t,e,i,r,u,f,m){if(t){!m&&f&&function(C,L,D,B){var U=C;do U.z===0&&(U.z=Mm(U.x,U.y,L,D,B)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==C);U.prevZ.nextZ=null,U.prevZ=null,function(G){var H,ne,de,re,fe,ve,ge,Be,De=1;do{for(ne=G,G=null,fe=null,ve=0;ne;){for(ve++,de=ne,ge=0,H=0;H0||Be>0&&de;)ge!==0&&(Be===0||!de||ne.z<=de.z)?(re=ne,ne=ne.nextZ,ge--):(re=de,de=de.nextZ,Be--),fe?fe.nextZ=re:G=re,re.prevZ=fe,fe=re;ne=de}fe.nextZ=null,De*=2}while(ve>1)}(U)}(t,r,u,f);for(var y,E,T=t;t.prev!==t.next;)if(y=t.prev,E=t.next,f?HI(t,r,u,f):YI(t))e.push(y.i/i|0),e.push(t.i/i|0),e.push(E.i/i|0),ih(t),t=E.next,T=E.next;else if((t=E)===T){m?m===1?eh(t=KI(Fl(t),e,i),e,i,r,u,f,2):m===2&&JI(t,e,i,r,u,f):eh(Fl(t),e,i,r,u,f,1);break}}}function YI(t){var e=t.prev,i=t,r=t.next;if(Tn(e,i,r)>=0)return!1;for(var u=e.x,f=i.x,m=r.x,y=e.y,E=i.y,T=r.y,C=uf?u>m?u:m:f>m?f:m,B=y>E?y>T?y:T:E>T?E:T,U=r.next;U!==e;){if(U.x>=C&&U.x<=D&&U.y>=L&&U.y<=B&&Bu(u,y,f,E,m,T,U.x,U.y)&&Tn(U.prev,U,U.next)>=0)return!1;U=U.next}return!0}function HI(t,e,i,r){var u=t.prev,f=t,m=t.next;if(Tn(u,f,m)>=0)return!1;for(var y=u.x,E=f.x,T=m.x,C=u.y,L=f.y,D=m.y,B=yE?y>T?y:T:E>T?E:T,H=C>L?C>D?C:D:L>D?L:D,ne=Mm(B,U,e,i,r),de=Mm(G,H,e,i,r),re=t.prevZ,fe=t.nextZ;re&&re.z>=ne&&fe&&fe.z<=de;){if(re.x>=B&&re.x<=G&&re.y>=U&&re.y<=H&&re!==u&&re!==m&&Bu(y,C,E,L,T,D,re.x,re.y)&&Tn(re.prev,re,re.next)>=0||(re=re.prevZ,fe.x>=B&&fe.x<=G&&fe.y>=U&&fe.y<=H&&fe!==u&&fe!==m&&Bu(y,C,E,L,T,D,fe.x,fe.y)&&Tn(fe.prev,fe,fe.next)>=0))return!1;fe=fe.nextZ}for(;re&&re.z>=ne;){if(re.x>=B&&re.x<=G&&re.y>=U&&re.y<=H&&re!==u&&re!==m&&Bu(y,C,E,L,T,D,re.x,re.y)&&Tn(re.prev,re,re.next)>=0)return!1;re=re.prevZ}for(;fe&&fe.z<=de;){if(fe.x>=B&&fe.x<=G&&fe.y>=U&&fe.y<=H&&fe!==u&&fe!==m&&Bu(y,C,E,L,T,D,fe.x,fe.y)&&Tn(fe.prev,fe,fe.next)>=0)return!1;fe=fe.nextZ}return!0}function KI(t,e,i){var r=t;do{var u=r.prev,f=r.next.next;!Yf(u,f)&&G0(u,r,r.next,f)&&th(u,f)&&th(f,u)&&(e.push(u.i/i|0),e.push(r.i/i|0),e.push(f.i/i|0),ih(r),ih(r.next),r=t=f),r=r.next}while(r!==t);return Fl(r)}function JI(t,e,i,r,u,f){var m=t;do{for(var y=m.next.next;y!==m.prev;){if(m.i!==y.i&&nk(m,y)){var E=$0(m,y);return m=Fl(m,m.next),E=Fl(E,E.next),eh(m,e,i,r,u,f,0),void eh(E,e,i,r,u,f,0)}y=y.next}m=m.next}while(m!==t)}function QI(t,e){return t.x-e.x}function ek(t,e){var i=function(u,f){var m,y=f,E=u.x,T=u.y,C=-1/0;do{if(T<=y.y&&T>=y.next.y&&y.next.y!==y.y){var L=y.x+(T-y.y)*(y.next.x-y.x)/(y.next.y-y.y);if(L<=E&&L>C&&(C=L,m=y.x=y.x&&y.x>=U&&E!==y.x&&Bu(Tm.x||y.x===m.x&&tk(m,y)))&&(m=y,H=D)),y=y.next;while(y!==B);return m}(t,e);if(!i)return e;var r=$0(i,t);return Fl(r,r.next),Fl(i,i.next)}function tk(t,e){return Tn(t.prev,t,e.prev)<0&&Tn(e.next,t,t.next)<0}function Mm(t,e,i,r,u){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*u|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*u|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ik(t){var e=t,i=t;do(e.x=(t-m)*(f-y)&&(t-m)*(r-y)>=(i-m)*(e-y)&&(i-m)*(f-y)>=(u-m)*(r-y)}function nk(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(i,r){var u=i;do{if(u.i!==i.i&&u.next.i!==i.i&&u.i!==r.i&&u.next.i!==r.i&&G0(u,u.next,i,r))return!0;u=u.next}while(u!==i);return!1}(t,e)&&(th(t,e)&&th(e,t)&&function(i,r){var u=i,f=!1,m=(i.x+r.x)/2,y=(i.y+r.y)/2;do u.y>y!=u.next.y>y&&u.next.y!==u.y&&m<(u.next.x-u.x)*(y-u.y)/(u.next.y-u.y)+u.x&&(f=!f),u=u.next;while(u!==i);return f}(t,e)&&(Tn(t.prev,t,e.prev)||Tn(t,e.prev,e))||Yf(t,e)&&Tn(t.prev,t,t.next)>0&&Tn(e.prev,e,e.next)>0)}function Tn(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Yf(t,e){return t.x===e.x&&t.y===e.y}function G0(t,e,i,r){var u=Kf(Tn(t,e,i)),f=Kf(Tn(t,e,r)),m=Kf(Tn(i,r,t)),y=Kf(Tn(i,r,e));return u!==f&&m!==y||!(u!==0||!Hf(t,i,e))||!(f!==0||!Hf(t,r,e))||!(m!==0||!Hf(i,t,r))||!(y!==0||!Hf(i,e,r))}function Hf(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Kf(t){return t>0?1:t<0?-1:0}function th(t,e){return Tn(t.prev,t,t.next)<0?Tn(t,e,t.next)>=0&&Tn(t,t.prev,e)>=0:Tn(t,e,t.prev)<0||Tn(t,t.next,e)<0}function $0(t,e){var i=new Am(t.i,t.x,t.y),r=new Am(e.i,e.x,e.y),u=t.next,f=e.prev;return t.next=e,e.prev=t,i.next=u,u.prev=i,r.next=i,i.prev=r,f.next=r,r.prev=f,r}function q0(t,e,i,r){var u=new Am(t,e,i);return r?(u.next=r.next,u.prev=r,r.next.prev=u,r.next=u):(u.prev=u,u.next=u),u}function ih(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 Am(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cm(t,e,i,r){for(var u=0,f=e,m=i-r;f0&&i.holes.push(r+=t[u-1].length)}return i};var Pm=Qe(km.exports);function rk(t,e,i,r,u){Z0(t,e,i,r||t.length-1,u||ok)}function Z0(t,e,i,r,u){for(;r>i;){if(r-i>600){var f=r-i+1,m=e-i+1,y=Math.log(f),E=.5*Math.exp(2*y/3),T=.5*Math.sqrt(y*E*(f-E)/f)*(m-f/2<0?-1:1);Z0(t,e,Math.max(i,Math.floor(e-m*E/f+T)),Math.min(r,Math.floor(e+(f-m)*E/f+T)),u)}var C=t[e],L=i,D=r;for(nh(t,i,e),u(t[r],C)>0&&nh(t,i,r);L0;)D--}u(t[i],C)===0?nh(t,i,D):nh(t,++D,r),D<=e&&(i=D+1),e<=D&&(r=D-1)}}function nh(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function ok(t,e){return te?1:0}function Lm(t,e){const i=t.length;if(i<=1)return[t];const r=[];let u,f;for(let m=0;m1)for(let m=0;mi.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new tt,this.indexArray=new Ot,this.indexArray2=new $n,this.programConfigurations=new Pl(e.layers,e.zoom),this.segments=new En,this.segments2=new En,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection}populate(e,i,r,u){this.hasPattern=Rm("fill",this.layers,i);const f=this.layers[0].layout.get("fill-sort-key"),m=[];for(const{feature:y,id:E,index:T,sourceLayerIndex:C}of e){const L=this.layers[0]._featureFilter.needGeometry,D=Nl(y,L);if(!this.layers[0]._featureFilter.filter(new P(this.zoom),D,r))continue;const B=f?f.evaluate(D,{},r,i.availableImages):void 0,U={id:E,properties:y.properties,type:y.type,sourceLayerIndex:C,index:T,geometry:L?D.geometry:oa(y,r,u),patterns:{},sortKey:B};m.push(U)}f&&m.sort((y,E)=>y.sortKey-E.sortKey);for(const y of m){const{geometry:E,index:T,sourceLayerIndex:C}=y;if(this.hasPattern){const L=Dm("fill",this.layers,y,this.zoom,i);this.patternFeatures.push(L)}else this.addFeature(y,E,T,r,{},i.availableImages);i.featureIndex.insert(e[T].feature,E,T,C,this.index)}}update(e,i,r,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,r,u)}addFeatures(e,i,r,u,f){for(const m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,i,r,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,WI),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,i,r,u,f,m=[]){for(const y of Lm(i,500)){let E=0;for(const U of y)E+=U.length;const T=this.segments.prepareSegment(E,this.layoutVertexArray,this.indexArray),C=T.vertexLength,L=[],D=[];for(const U of y){if(U.length===0)continue;U!==y[0]&&D.push(L.length/2);const G=this.segments2.prepareSegment(U.length,this.layoutVertexArray,this.indexArray2),H=G.vertexLength;this.layoutVertexArray.emplaceBack(U[0].x,U[0].y),this.indexArray2.emplaceBack(H+U.length-1,H),L.push(U[0].x),L.push(U[0].y);for(let ne=1;ne>3}if(u--,r===1||r===2)f+=t.readSVarint(),m+=t.readSVarint(),r===1&&(e&&y.push(e),e=[]),e.push(new pk(f,m));else{if(r!==7)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&y.push(e),y},Fu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,u=0,f=0,m=1/0,y=-1/0,E=1/0,T=-1/0;t.pos>3}if(r--,i===1||i===2)(u+=t.readSVarint())y&&(y=u),(f+=t.readSVarint())T&&(T=f);else if(i!==7)throw new Error("unknown command "+i)}return[m,E,y,T]},Fu.prototype.toGeoJSON=function(t,e,i){var r,u,f=this.extent*Math.pow(2,i),m=this.extent*t,y=this.extent*e,E=this.loadGeometry(),T=Fu.types[this.type];function C(B){for(var U=0;U>3;u=m===1?r.readString():m===2?r.readFloat():m===3?r.readDouble():m===4?r.readVarint64():m===5?r.readVarint():m===6?r.readSVarint():m===7?r.readBoolean():null}return u}(i))}Y0.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 gk(this._pbf,e,this.extent,this._keys,this._values)};var yk=W0;function vk(t,e,i){if(t===3){var r=new yk(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}var Om=Qf.VectorTile=function(t,e){this.layers=t.readFields(vk,{},e)},ep=Qf.VectorTileFeature=X0;function tp(t,e,i,r){const u=[],f=r===0?(m,y,E,T,C,L)=>{m.push(new Oe(L,E+(L-y)/(T-y)*(C-E)))}:(m,y,E,T,C,L)=>{m.push(new Oe(y+(L-E)/(C-E)*(T-y),L))};for(const m of t){const y=[];for(const E of m){if(E.length<=2)continue;const T=[];for(let D=0;De&&f(T,B,U,G,H,e):ne>i?de=e&&f(T,B,U,G,H,e),de>i&&ne<=i&&f(T,B,U,G,H,i)}let C=E[E.length-1];const L=r===0?C.x:C.y;L>=e&&L<=i&&T.push(C),T.length&&(C=T[T.length-1],T[0].x===C.x&&T[0].y===C.y||T.push(T[0]),y.push(T))}y.length&&u.push(y)}return u}Qf.VectorTileLayer=W0;const xk=ep.types,bk=Math.pow(2,13);function rh(t,e,i,r,u,f,m,y){t.emplaceBack((e<<1)+m,(i<<1)+f,(Math.floor(r*bk)<<1)+u,Math.round(y))}function oh(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class H0{constructor(){this.acc=new Oe(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Oe(e.x,e.y),this.max=new Oe(e.x,e.y))}append(e,i){this.currentPolyCount.edges++,this.acc._add(e);const r=this.min,u=this.max;e.xu.x&&(u.x=e.x),e.yu.y&&(u.y=e.y),((e.x===0||e.x===Ft)&&e.x===i.x)!=((e.y===0||e.y===Ft)&&e.y===i.y)&&this.processBorderOverlap(e,i),i.x<0!=e.x<0&&this.addBorderIntersection(0,bi(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>Ft!=e.x>Ft&&this.addBorderIntersection(1,bi(i.y,e.y,(Ft-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,bi(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>Ft!=e.y>Ft&&this.addBorderIntersection(3,bi(i.x,e.x,(Ft-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[e];ir[1]&&(r[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const r=e.x===0?0:1;this.addBorderIntersection(r,i.y),this.addBorderIntersection(r,e.y)}else{const r=e.y===0?2:3;this.addBorderIntersection(r,i.x),this.addBorderIntersection(r,e.x)}}centroid(){const e=this.polyCount.reduce((i,r)=>i+r.edges,0);return e!==0?this.acc.div(e)._round():new Oe(0,0)}span(){return new Oe(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0)}}class sh{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new We,this.centroidVertexArray=new Ho,this.indexArray=new Ot,this.programConfigurations=new Pl(e.layers,e.zoom),this.segments=new En,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=e.enableTerrain}populate(e,i,r,u){this.features=[],this.hasPattern=Rm("fill-extrusion",this.layers,i),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(f){const m=Math.exp(Math.PI*(1-f.y/(1<=0;ne--){const de=B[ne];(de.length===0||(U=de[0]).every(re=>re.x<=0)||U.every(re=>re.x>=Ft)||U.every(re=>re.y<=0)||U.every(re=>re.y>=Ft))&&B.splice(ne,1)}var U;let G;if(C)G=nx(B,E,u);else{G=[];for(const ne of B)G.push({polygon:ne,bounds:E})}const H=D?this.edgeRadius:0;for(const{polygon:ne,bounds:de}of G){let re=0,fe=0;for(const ge of ne)D&&!ge[0].equals(ge[ge.length-1])&&ge.push(ge[0]),fe+=D?ge.length-1:ge.length;const ve=this.segments.prepareSegment((D?5:4)*fe,this.layoutVertexArray,this.indexArray);if(D){const ge=[],Be=[];re=ve.vertexLength;for(const qe of ne){let it,Ve;qe.length&&qe!==ne[0]&&Be.push(ge.length/2),it=qe[1].sub(qe[0])._perp()._unit();for(let Ye=1;Ye4&&ex(ge[ge.length-2],ge[0],ge[1]),Ve=H?wk(ge[ge.length-2],ge[0],ge[1],H):0;De=ge[1].sub(ge[0])._perp()._unit();let Ye=!0;for(let He=1,Je=0;He0?1:0,lt=at.dist($e);if(Je+lt>32768&&(Je=0),H){qe=vt.sub($e)._perp()._unit();let oi=J0(at,$e,vt,K0(De,qe),H);isNaN(oi)&&(oi=0);const Gt=$e.sub(at)._unit();at=at.add(Gt.mult(Ve))._round(),$e=$e.add(Gt.mult(-oi))._round(),Ve=oi,De=qe}const Nt=ve.vertexLength,ri=ge.length>4&&ex(at,$e,vt);let Ii=tx(Je,it,Ye);if(rh(this.layoutVertexArray,at.x,at.y,xt,ni,0,0,Ii),rh(this.layoutVertexArray,at.x,at.y,xt,ni,0,1,Ii),Je+=lt,Ii=tx(Je,ri,!Ye),it=ri,rh(this.layoutVertexArray,$e.x,$e.y,xt,ni,0,0,Ii),rh(this.layoutVertexArray,$e.x,$e.y,xt,ni,0,1,Ii),ve.vertexLength+=4,this.indexArray.emplaceBack(Nt+0,Nt+1,Nt+2),this.indexArray.emplaceBack(Nt+1,Nt+3,Nt+2),ve.primitiveLength+=2,H){const oi=re+(He===1?ge.length-2:He-2),Gt=He===1?re:oi+1;if(this.indexArray.emplaceBack(Nt+1,oi,Nt+3),this.indexArray.emplaceBack(oi,Gt,Nt+3),ve.primitiveLength+=2,Be===void 0&&(Be=Nt),!Q0(vt,ge[He],de)){const Qi=He===ge.length-1?Be:ve.vertexLength;this.indexArray.emplaceBack(Nt+2,Nt+3,Qi),this.indexArray.emplaceBack(Nt+3,Qi+1,Qi),this.indexArray.emplaceBack(Nt+3,Gt,Qi+1),ve.primitiveLength+=3}Ye=!Ye}if(C){const oi=this.layoutVertexExtArray,Gt=T.projectTilePoint(at.x,at.y,u),Qi=T.projectTilePoint($e.x,$e.y,u),si=T.upVector(u,at.x,at.y),ai=T.upVector(u,$e.x,$e.y);oh(oi,Gt,si),oh(oi,Gt,si),oh(oi,Qi,ai),oh(oi,Qi,ai)}}D&&(re+=ge.length-1)}}if(L&&L.polyCount.length>0){if(L.borders){L.vertexArrayOffset=this.centroidVertexArray.length;const ne=L.borders,de=this.featuresOnBorder.push(L)-1;for(let re=0;re<4;re++)ne[re][0]!==Number.MAX_VALUE&&this.borders[re].push(de)}this.encodeCentroid(L.borders?void 0:L.centroid(),L)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,f,m,u)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((i,r)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[r].borders[e][0])}encodeCentroid(e,i,r=!0){let u,f;if(e)if(e.y!==0){const y=i.span()._mult(this.tileToMeter);u=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(y.x/10)),f=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(y.y/10))}else u=Math.ceil(7*(e.x+450)),f=0;else u=0,f=+r;let m=r?this.centroidVertexArray.length:i.vertexArrayOffset;for(const y of i.polyCount){r&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*y.edges+y.top);for(let E=0;Ei[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function ex(t,e,i){if(t.x<0||t.x>=Ft||e.x<0||e.x>=Ft||i.x<0||i.x>=Ft)return!1;const r=i.sub(e),u=r.perp(),f=t.sub(e);return(r.x*f.x+r.y*f.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(f.x*f.x+f.y*f.y))>-.866&&u.x*f.x+u.y*f.y<0}function tx(t,e,i){const r=e?2|t:-3&t;return i?1|r:-2&r}function ix(){const t=Math.PI/32,e=Math.tan(t),i=Qc;return i*Math.sqrt(1+2*e*e)-i}function nx(t,e,i){const r=1<{for(const De of ge)U.push({polygon:De,bounds:Be})},H=Math.ceil(Math.log2(C)),ne=Math.ceil(Math.log2(L)),de=H-ne,re=[];for(let ge=0;ge0?0:1);for(let ge=0;geBe+1?ve.push({polygons:Je,bounds:$e,depth:Be+1}):G(Je,$e)}if(at.length){const $e=[new Oe(De===0?He:qe.x,De===1?He:qe.y),it];re.length>Be+1?ve.push({polygons:at,bounds:$e,depth:Be+1}):G(at,$e)}}return U}(t,e,Math.ceil((f-u)/11.25),Math.ceil((m-y)/11.25),1,(E,T,C)=>{if(E===0)return .5*(T+C);{const L=cr((i.y+T/Ft)/r);return(Ms(.5*(cr((i.y+C/Ft)/r)+L))*r-i.y)*Ft}})}Ct(sh,"FillExtrusionBucket",{omit:["layers","features"]}),Ct(H0,"PartMetadata");const Ek=new le({"fill-extrusion-edge-radius":new V(Ge["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Tk={paint:new le({"fill-extrusion-opacity":new V(Ge["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new K(Ge["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new V(Ge["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new V(Ge["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new K(Ge["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new K(Ge["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new K(Ge["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new V(Ge["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new V(Ge["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new V(Ge["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new V(Ge["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:Ek};function rx(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class ip{constructor(e,i,r){this.z=e,this.x=i,this.y=r,this.key=ah(0,e,e,i,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i){const r=function(f,m,y){var E=rx(256*f,256*(m=Math.pow(2,y)-m-1),y),T=rx(256*(f+1),256*(m+1),y);return E[0]+","+E[1]+","+T[0]+","+T[1]}(this.x,this.y,this.z),u=function(f,m,y){let E,T="";for(let C=f;C>0;C--)E=1<this.canonical.z?new Cr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Cr(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return ah(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return ah(this.wrap*+i,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const i=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new Cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,r=2*this.canonical.x,u=2*this.canonical.y;return[new Cr(i,this.wrap,i,r,u),new Cr(i,this.wrap,i,r+1,u),new Cr(i,this.wrap,i,r,u+1),new Cr(i,this.wrap,i,r+1,u+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.yi.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new je,this.layoutVertexArray2=new et,this.indexArray=new Ot,this.programConfigurations=new Pl(e.layers,e.zoom),this.segments=new En,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,r,u){this.hasPattern=Rm("line",this.layers,i);const f=this.layers[0].layout.get("line-sort-key"),m=[];for(const{feature:C,id:L,index:D,sourceLayerIndex:B}of e){const U=this.layers[0]._featureFilter.needGeometry,G=Nl(C,U);if(!this.layers[0]._featureFilter.filter(new P(this.zoom),G,r))continue;const H=f?f.evaluate(G,{},r):void 0,ne={id:L,properties:C.properties,type:C.type,sourceLayerIndex:B,index:D,geometry:U?G.geometry:oa(C,r,u),patterns:{},sortKey:H};m.push(ne)}f&&m.sort((C,L)=>C.sortKey-L.sortKey);const{lineAtlas:y,featureIndex:E}=i,T=this.addConstantDashes(y);for(const C of m){const{geometry:L,index:D,sourceLayerIndex:B}=C;if(T&&this.addFeatureDashes(C,y),this.hasPattern){const U=Dm("line",this.layers,C,this.zoom,i);this.patternFeatures.push(U)}else this.addFeature(C,L,D,r,y.positions,i.availableImages);E.insert(e[D].feature,L,D,B,this.index)}}addConstantDashes(e){let i=!1;for(const r of this.layers){const u=r.paint.get("line-dasharray").value,f=r.layout.get("line-cap").value;if(u.kind!=="constant"||f.kind!=="constant")i=!0;else{const m=f.value,y=u.value;if(!y)continue;e.addDash(y,m)}}return i}addFeatureDashes(e,i){const r=this.zoom;for(const u of this.layers){const f=u.paint.get("line-dasharray").value,m=u.layout.get("line-cap").value;if(f.kind==="constant"&&m.kind==="constant")continue;let y,E;if(f.kind==="constant"){if(y=f.value,!y)continue}else y=f.evaluate({zoom:r},e);E=m.kind==="constant"?m.value:m.evaluate({zoom:r},e),i.addDash(y,E),e.patterns[u.id]=i.getKey(y,E)}}update(e,i,r,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,r,u)}addFeatures(e,i,r,u,f){for(const m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,i,r,u)}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,Mk)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ik),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,i,r,u,f,m){const y=this.layers[0].layout,E=y.get("line-join").evaluate(e,{}),T=y.get("line-cap").evaluate(e,{}),C=y.get("line-miter-limit"),L=y.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const D of i)this.addLine(D,e,E,T,C,L);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,f,m,u)}addLine(e,i,r,u,f,m){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ne=0;ne=2&&e[E-1].equals(e[E-2]);)E--;let T=0;for(;T0;if(Be&&ne>T){const Ve=D.dist(B);if(Ve>2*C){const Ye=D.sub(D.sub(B)._mult(C/Ve)._round());this.updateDistance(B,Ye),this.addCurrentVertex(Ye,G,0,0,L),B=Ye}}const qe=B&&U;let it=qe?r:y?"butt":u;if(qe&&it==="round"&&(vef&&(it="bevel"),it==="bevel"&&(ve>2&&(it="flipbevel"),ve100)de=H.mult(-1);else{const Ve=ve*G.add(H).mag()/G.sub(H).mag();de._perp()._mult(Ve*(De?-1:1))}this.addCurrentVertex(D,de,0,0,L),this.addCurrentVertex(D,de.mult(-1),0,0,L)}else if(it==="bevel"||it==="fakeround"){const Ve=-Math.sqrt(ve*ve-1),Ye=De?Ve:0,He=De?0:Ve;if(B&&this.addCurrentVertex(D,G,Ye,He,L),it==="fakeround"){const Je=Math.round(180*ge/Math.PI/20);for(let at=1;at2*C){const Ye=D.add(U.sub(D)._mult(C/Ve)._round());this.updateDistance(D,Ye),this.addCurrentVertex(Ye,H,0,0,L),D=Ye}}}}addCurrentVertex(e,i,r,u,f,m=!1){const y=i.y*u-i.x,E=-i.y-i.x*u;this.addHalfVertex(e,i.x+i.y*r,i.y-i.x*r,m,!1,r,f),this.addHalfVertex(e,y,E,m,!0,-u,f)}addHalfVertex({x:e,y:i},r,u,f,m,y,E){this.layoutVertexArray.emplaceBack((e<<1)+(f?1:0),(i<<1)+(m?1:0),Math.round(63*r)+128,Math.round(63*u)+128,1+(y===0?0:y<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const T=E.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,T),E.primitiveLength++),m?this.e2=T:this.e1=T}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}}Ct(np,"LineBucket",{omit:["layers","patternFeatures"]});const Pk=new le({"line-cap":new K(Ge.layout_line["line-cap"]),"line-join":new K(Ge.layout_line["line-join"]),"line-miter-limit":new V(Ge.layout_line["line-miter-limit"]),"line-round-limit":new V(Ge.layout_line["line-round-limit"]),"line-sort-key":new K(Ge.layout_line["line-sort-key"])});var lx={paint:new le({"line-opacity":new K(Ge.paint_line["line-opacity"]),"line-color":new K(Ge.paint_line["line-color"]),"line-translate":new V(Ge.paint_line["line-translate"]),"line-translate-anchor":new V(Ge.paint_line["line-translate-anchor"]),"line-width":new K(Ge.paint_line["line-width"]),"line-gap-width":new K(Ge.paint_line["line-gap-width"]),"line-offset":new K(Ge.paint_line["line-offset"]),"line-blur":new K(Ge.paint_line["line-blur"]),"line-dasharray":new K(Ge.paint_line["line-dasharray"]),"line-pattern":new K(Ge.paint_line["line-pattern"]),"line-gradient":new ae(Ge.paint_line["line-gradient"]),"line-trim-offset":new V(Ge.paint_line["line-trim-offset"])}),layout:Pk};const ux=new class extends K{possiblyEvaluate(t,e){return e=new P(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=Wt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(lx.paint.properties["line-width"].specification);function cx(t,e){return e>0?e+2*t:t}ux.useIntegerZoom=!0;const Lk=ke([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Rk=ke([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Dk=ke([{name:"a_projected_pos",components:4,type:"Float32"}],4);ke([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ok=ke([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),zk=ke([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);ke([{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 hx=ke([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Nk=ke([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ke([{name:"triangle",components:3,type:"Uint16"}]),ke([{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"}]),ke([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),ke([{type:"Float32",name:"offsetX"}]),ke([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Kn=24;const is=128;function zm(t,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new P(t+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:r,interpolationType:u}=i;let f=0;for(;f{r.text=function(u,f,m){const y=f.layout.get("text-transform").evaluate(m,{});return y==="uppercase"?u=u.toLocaleUpperCase():y==="lowercase"&&(u=u.toLocaleLowerCase()),M.applyArabicShaping&&(u=M.applyArabicShaping(u)),u}(r.text,e,i)}),t}const uh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Uk(t){return t==="︶"||t==="﹈"||t==="︸"||t==="﹄"||t==="﹂"||t==="︾"||t==="︼"||t==="︺"||t==="︘"||t==="﹀"||t==="︐"||t==="︓"||t==="︔"||t==="`"||t===" ̄"||t==="︑"||t==="︒"}function jk(t){return t==="︵"||t==="﹇"||t==="︷"||t==="﹃"||t==="﹁"||t==="︽"||t==="︻"||t==="︹"||t==="︗"||t==="︿"}var fx=Wi,px=function(t,e,i,r,u){var f,m,y=8*u-r-1,E=(1<>1,C=-7,L=u-1,D=-1,B=t[e+L];for(L+=D,f=B&(1<<-C)-1,B>>=-C,C+=y;C>0;f=256*f+t[e+L],L+=D,C-=8);for(m=f&(1<<-C)-1,f>>=-C,C+=r;C>0;m=256*m+t[e+L],L+=D,C-=8);if(f===0)f=1-T;else{if(f===E)return m?NaN:1/0*(B?-1:1);m+=Math.pow(2,r),f-=T}return(B?-1:1)*m*Math.pow(2,f-r)},dx=function(t,e,i,r,u,f){var m,y,E,T=8*f-u-1,C=(1<>1,D=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=0,U=1,G=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(y=isNaN(e)?1:0,m=C):(m=Math.floor(Math.log(e)/Math.LN2),e*(E=Math.pow(2,-m))<1&&(m--,E*=2),(e+=m+L>=1?D/E:D*Math.pow(2,1-L))*E>=2&&(m++,E/=2),m+L>=C?(y=0,m=C):m+L>=1?(y=(e*E-1)*Math.pow(2,u),m+=L):(y=e*Math.pow(2,L-1)*Math.pow(2,u),m=0));u>=8;t[i+B]=255&y,B+=U,y/=256,u-=8);for(m=m<0;t[i+B]=255&m,B+=U,m/=256,T-=8);t[i+B-U]|=128*G};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function Wi(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Wi.Varint=0,Wi.Fixed64=1,Wi.Bytes=2,Wi.Fixed32=5;var Nm=4294967296,mx=1/Nm,gx=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function aa(t){return t.type===Wi.Bytes?t.readVarint()+t.pos:t.pos+1}function Vu(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function _x(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var u=i.pos-1;u>=t;u--)i.buf[u+r]=i.buf[u]}function Vk(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function yx(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Wi.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos>3,f=this.pos;this.type=7&r,t(u,e,this),this.pos===f&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=op(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=yx(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=op(this.buf,this.pos)+op(this.buf,this.pos+4)*Nm;return this.pos+=8,t},readSFixed64:function(){var t=op(this.buf,this.pos)+yx(this.buf,this.pos+4)*Nm;return this.pos+=8,t},readFloat:function(){var t=px(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=px(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(u,f,m){var y,E,T=m.buf;if(y=(112&(E=T[m.pos++]))>>4,E<128||(y|=(127&(E=T[m.pos++]))<<3,E<128)||(y|=(127&(E=T[m.pos++]))<<10,E<128)||(y|=(127&(E=T[m.pos++]))<<17,E<128)||(y|=(127&(E=T[m.pos++]))<<24,E<128)||(y|=(1&(E=T[m.pos++]))<<31,E<128))return Vu(u,y,f);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&gx?function(i,r,u){return gx.decode(i.subarray(r,u))}(this.buf,e,t):function(i,r,u){for(var f="",m=r;m239?4:C>223?3:C>191?2:1;if(m+D>u)break;D===1?C<128&&(L=C):D===2?(192&(y=i[m+1]))==128&&(L=(31&C)<<6|63&y)<=127&&(L=null):D===3?(E=i[m+2],(192&(y=i[m+1]))==128&&(192&E)==128&&((L=(15&C)<<12|(63&y)<<6|63&E)<=2047||L>=55296&&L<=57343)&&(L=null)):D===4&&(E=i[m+2],T=i[m+3],(192&(y=i[m+1]))==128&&(192&E)==128&&(192&T)==128&&((L=(15&C)<<18|(63&y)<<12|(63&E)<<6|63&T)<=65535||L>=1114112)&&(L=null)),L===null?(L=65533,D=1):L>65535&&(L-=65536,f+=String.fromCharCode(L>>>10&1023|55296),L=56320|1023&L),f+=String.fromCharCode(L),m+=D}return f}(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!==Wi.Bytes)return t.push(this.readVarint(e));var i=aa(this);for(t=t||[];this.pos127;);else if(e===Wi.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Wi.Fixed32)this.pos+=4;else{if(e!==Wi.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;e268435455||t<0?function(e,i){var r,u;if(e>=0?(r=e%4294967296|0,u=e/4294967296|0):(u=~(-e/4294967296),4294967295^(r=~(-e%4294967296))?r=r+1|0:(r=0,u=u+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(f,m,y){y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,y.buf[y.pos]=127&(f>>>=7)}(r,0,i),function(f,m){var y=(7&f)<<4;m.buf[m.pos++]|=y|((f>>>=3)?128:0),f&&(m.buf[m.pos++]=127&f|((f>>>=7)?128:0),f&&(m.buf[m.pos++]=127&f|((f>>>=7)?128:0),f&&(m.buf[m.pos++]=127&f|((f>>>=7)?128:0),f&&(m.buf[m.pos++]=127&f|((f>>>=7)?128:0),f&&(m.buf[m.pos++]=127&f)))))}(u,i)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(r,u,f){for(var m,y,E=0;E55295&&m<57344){if(!y){m>56319||E+1===u.length?(r[f++]=239,r[f++]=191,r[f++]=189):y=m;continue}if(m<56320){r[f++]=239,r[f++]=191,r[f++]=189,y=m;continue}m=y-55296<<10|m-56320|65536,y=null}else y&&(r[f++]=239,r[f++]=191,r[f++]=189,y=null);m<128?r[f++]=m:(m<2048?r[f++]=m>>6|192:(m<65536?r[f++]=m>>12|224:(r[f++]=m>>18|240,r[f++]=m>>12&63|128),r[f++]=m>>6&63|128),r[f++]=63&m|128)}return f}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&_x(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dx(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dx(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&_x(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,Wi.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Vk,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Gk,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Zk,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,$k,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,qk,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Xk,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Wk,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Yk,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Hk,e)},writeBytesField:function(t,e){this.writeTag(t,Wi.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Wi.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Wi.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Wi.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Wi.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Wi.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Wi.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Wi.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Wi.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Wi.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var sp=Qe(fx);const Bm=3;function Kk(t,e,i){e.glyphs=[],t===1&&i.readMessage(Jk,e)}function Jk(t,e,i){if(t===3){const{id:r,bitmap:u,width:f,height:m,left:y,top:E,advance:T}=i.readMessage(Qk,{});e.glyphs.push({id:r,bitmap:new sa({width:f+2*Bm,height:m+2*Bm},u),metrics:{width:f,height:m,left:y,top:E,advance:T}})}else t===4?e.ascender=i.readSVarint():t===5&&(e.descender=i.readSVarint())}function Qk(t,e,i){t===1?e.id=i.readVarint():t===2?e.bitmap=i.readBytes():t===3?e.width=i.readVarint():t===4?e.height=i.readVarint():t===5?e.left=i.readSVarint():t===6?e.top=i.readSVarint():t===7&&(e.advance=i.readVarint())}const vx=Bm;function Fm(t){let e=0,i=0;for(const m of t)e+=m.w*m.h,i=Math.max(i,m.w);t.sort((m,y)=>y.h-m.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let u=0,f=0;for(const m of t)for(let y=r.length-1;y>=0;y--){const E=r[y];if(!(m.w>E.w||m.h>E.h)){if(m.x=E.x,m.y=E.y,f=Math.max(f,m.y+m.h),u=Math.max(u,m.x+m.w),m.w===E.w&&m.h===E.h){const T=r.pop();ye.hasImage(r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const r in e.updatedImages)this.patchUpdatedImage(this.iconPositions[r],e.getImage(r),i),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r),i)}patchUpdatedImage(e,i,r){if(!e||!i||e.version===i.version)return;e.version=i.version;const[u,f]=e.tl;r.update(i.data,void 0,{x:u,y:f})}}Ct(Um,"ImagePosition"),Ct(xx,"ImageAtlas");const mo={horizontal:1,vertical:2,horizontalOnly:3},bx=-17;class ch{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,i){const r=new ch;return r.scale=e||1,r.fontStack=i,r}static forImage(e){const i=new ch;return i.imageName=e,i}}class $u{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i){const r=new $u;for(let u=0;u=0&&r>=e&&ap[this.text.charCodeAt(r)];r--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){const r=new $u;return r.text=this.text.substring(e,i),r.sectionIndex=this.sectionIndex.slice(e,i),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(ch.forText(e.scale,e.fontStack||i));const r=this.sections.length-1;for(let u=0;u=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function jm(t,e,i,r,u,f,m,y,E,T,C,L,D,B,U){const G=$u.fromFeature(t,u);L===mo.vertical&&G.verticalizePunctuation(D);let H=[];const ne=function(ge,Be,De,qe,it,Ve){if(!ge)return[];const Ye=[],He=function(vt,Lt,xt,ni,lt,Nt){let ri=0;for(let Ii=0;Ii=0;let at=0;for(let vt=0;vt0&&os>$i&&($i=os)}else{const Lr=De[Rn.fontStack];if(!Lr)continue;Lr[fn]&&(Ki=Lr[fn]);const Zn=Be[Rn.fontStack];if(!Zn)continue;const os=Zn.glyphs[fn];if(!os)continue;if(kn=os.metrics,Mn=fn!==8203?Kn:0,Nt){const Ku=Zn.ascender!==void 0?Math.abs(Zn.ascender):0,xh=Zn.descender!==void 0?Math.abs(Zn.descender):0,bh=(Ku+xh)*Mi;an-i/2;){if(m--,m<0)return!1;y-=t[m].dist(f),f=t[m]}y+=t[m].dist(t[m+1]),m++;const E=[];let T=0;for(;yr;)T-=E.shift().angleDelta;if(T>u)return!1;m++,y+=C.dist(L)}return!0}function Ax(t){let e=0;for(let i=0;iT){const U=(T-E)/B,G=bi(L.x,D.x,U),H=bi(L.y,D.y,U),ne=new la(G,H,0,D.angleTo(L),C);return!m||Mx(t,ne,y,m,e)?ne:void 0}E+=B}}function rM(t,e,i,r,u,f,m,y,E){const T=Cx(r,f,m),C=Px(r,u),L=C*m,D=t[0].x===0||t[0].x===E||t[0].y===0||t[0].y===E;return e-L=0&&fe=0&&ve=0&&D+T<=C){const ge=new la(fe,ve,0,de,U);ge._round(),r&&!Mx(t,ge,f,r,u)||B.push(ge)}}L+=ne}return y||B.length||m||(B=Lx(t,L/2,i,r,u,f,m,!0,E)),B}function Rx(t,e,i,r,u){const f=[];for(let m=0;m=r&&L.x>=r||(C.x>=r?C=new Oe(r,C.y+(r-C.x)/(L.x-C.x)*(L.y-C.y))._round():L.x>=r&&(L=new Oe(r,C.y+(r-C.x)/(L.x-C.x)*(L.y-C.y))._round()),C.y>=u&&L.y>=u||(C.y>=u?C=new Oe(C.x+(u-C.y)/(L.y-C.y)*(L.x-C.x),u)._round():L.y>=u&&(L=new Oe(C.x+(u-C.y)/(L.y-C.y)*(L.x-C.x),u)._round()),E&&C.equals(E[E.length-1])||(E=[C],f.push(E)),E.push(L)))))}}return f}Ct(la,"Anchor");const hh=1e20;function Dx(t,e,i,r,u,f,m,y,E){for(let T=e;T-1);E++,f[E]=y,m[E]=T,m[E+1]=hh}for(let y=0,E=0;y{let y=this.entries[u];y||(y=this.entries[u]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let E=y.glyphs[f];if(E!==void 0)return void m(null,{stack:u,id:f,glyph:E});if(E=this._tinySDF(y,u,f),E)return y.glyphs[f]=E,void m(null,{stack:u,id:f,glyph:E});const T=Math.floor(f/256);if(256*T>65535)return void m(new Error("glyphs > 65535 not supported"));if(y.ranges[T])return void m(null,{stack:u,id:f,glyph:E});let C=y.requests[T];C||(C=y.requests[T]=[],qu.loadGlyphRange(u,T,this.url,this.requestManager,(L,D)=>{if(D){y.ascender=D.ascender,y.descender=D.descender;for(const B in D.glyphs)this._doesCharSupportLocalGlyph(+B)||(y.glyphs[+B]=D.glyphs[+B]);y.ranges[T]=!0}for(const B of C)B(L,D);delete y.requests[T]})),C.push((L,D)=>{L?m(L):D&&m(null,{stack:u,id:f,glyph:D.glyphs[f]||null})})},(u,f)=>{if(u)i(u);else if(f){const m={};for(const{stack:y,id:E,glyph:T}of f)m[y]===void 0&&(m[y]={}),m[y].glyphs===void 0&&(m[y].glyphs={}),m[y].glyphs[E]=T&&{id:T.id,bitmap:T.bitmap.clone(),metrics:T.metrics},m[y].ascender=this.entries[y].ascender,m[y].descender=this.entries[y].descender;i(null,m)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Gm.none&&(this.localGlyphMode===Gm.all?!!this.localFontFamily:!!this.localFontFamily&&(wt["CJK Unified Ideographs"](e)||wt["Hangul Syllables"](e)||wt.Hiragana(e)||wt.Katakana(e)||wt["CJK Symbols and Punctuation"](e)))}_tinySDF(e,i,r){const u=this.localFontFamily;if(!u||!this._doesCharSupportLocalGlyph(r))return;let f=e.tinySDF;if(!f){let G="400";/bold/i.test(i)?G="900":/medium/i.test(i)?G="500":/light/i.test(i)&&(G="200"),f=e.tinySDF=new qu.TinySDF({fontFamily:u,fontWeight:G,fontSize:24*ns,buffer:3*ns,radius:8*ns}),f.fontWeight=G}if(this.localGlyphs[f.fontWeight][r])return this.localGlyphs[f.fontWeight][r];const m=String.fromCharCode(r),{data:y,width:E,height:T,glyphWidth:C,glyphHeight:L,glyphLeft:D,glyphTop:B,glyphAdvance:U}=f.draw(m);return this.localGlyphs[f.fontWeight][r]={id:r,bitmap:new sa({width:E,height:T},y),metrics:{width:C/ns,height:L/ns,left:D/ns,top:B/ns-27,advance:U/ns,localGlyph:!0}}}}qu.loadGlyphRange=function(t,e,i,r,u){const f=256*e,m=f+255,y=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${f}-${m}`),Wn.Glyphs);ms(y,(E,T)=>{if(E)u(E);else if(T){const C={},L=function(D){return new sp(D).readFields(Kk,{})}(T);for(const D of L.glyphs)C[D.id]=D;u(null,{glyphs:C,ascender:L.ascender,descender:L.descender})}})},qu.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:u="sans-serif",fontWeight:f="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const y=this.size=t+4*e,E=this._createCanvas(y),T=this.ctx=E.getContext("2d",{willReadFrequently:!0});T.font=`${m} ${f} ${t}px ${u}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(y*y),this.gridInner=new Float64Array(y*y),this.f=new Float64Array(y),this.z=new Float64Array(y+1),this.v=new Uint16Array(y)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:u,actualBoundingBoxRight:f}=this.ctx.measureText(t),m=Math.ceil(i),y=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(f-u))),E=Math.min(this.size-this.buffer,m+Math.ceil(r)),T=y+2*this.buffer,C=E+2*this.buffer,L=Math.max(T*C,0),D=new Uint8ClampedArray(L),B={data:D,width:T,height:C,glyphWidth:y,glyphHeight:E,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(y===0||E===0)return B;const{ctx:U,buffer:G,gridInner:H,gridOuter:ne}=this;U.clearRect(G,G,y,E),U.fillText(t,G,G+m);const de=U.getImageData(G,G,y,E);ne.fill(hh,0,L),H.fill(0,0,L);for(let re=0;re0?Be*Be:0,H[ge]=Be<0?Be*Be:0}}Dx(ne,0,0,T,C,T,this.f,this.v,this.z),Dx(H,G,G,y,E,T,this.f,this.v,this.z);for(let re=0;reVe+Ye[1]-Ye[0],U=L.reduce(B,0),G=D.reduce(B,0),H=y-U,ne=E-G;let de=0,re=U,fe=0,ve=G,ge=0,Be=H,De=0,qe=ne;if(f.content&&r){const Ve=f.content;de=lp(L,0,Ve[0]),fe=lp(D,0,Ve[1]),re=lp(L,Ve[0],Ve[2]),ve=lp(D,Ve[1],Ve[3]),ge=Ve[0]-de,De=Ve[1]-fe,Be=Ve[2]-Ve[0]-re,qe=Ve[3]-Ve[1]-ve}const it=(Ve,Ye,He,Je)=>{const at=up(Ve.stretch-de,re,T,t.left),$e=cp(Ve.fixed-ge,Be,Ve.stretch,U),vt=up(Ye.stretch-fe,ve,C,t.top),Lt=cp(Ye.fixed-De,qe,Ye.stretch,G),xt=up(He.stretch-de,re,T,t.left),ni=cp(He.fixed-ge,Be,He.stretch,U),lt=up(Je.stretch-fe,ve,C,t.top),Nt=cp(Je.fixed-De,qe,Je.stretch,G),ri=new Oe(at,vt),Ii=new Oe(xt,vt),oi=new Oe(xt,lt),Gt=new Oe(at,lt),Qi=new Oe($e/m,Lt/m),si=new Oe(ni/m,Nt/m),ai=e*Math.PI/180;if(ai){const Hi=Math.sin(ai),$i=Math.cos(ai),an=[$i,-Hi,Hi,$i];ri._matMult(an),Ii._matMult(an),Gt._matMult(an),oi._matMult(an)}const Gi=Ve.stretch+Ve.fixed,Yi=Ye.stretch+Ye.fixed;return{tl:ri,tr:Ii,bl:Gt,br:oi,tex:{x:f.paddedRect.x+Zu+Gi,y:f.paddedRect.y+Zu+Yi,w:He.stretch+He.fixed-Gi,h:Je.stretch+Je.fixed-Yi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Qi,pixelOffsetBR:si,minFontScaleX:Be/m/T,minFontScaleY:qe/m/C,isSDF:i}};if(r&&(f.stretchX||f.stretchY)){const Ve=Nx(L,H,U),Ye=Nx(D,ne,G);for(let He=0;He0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:r}=this,u=i[e];for(;e>0;){const f=e-1>>1,m=i[f];if(r(u,m)>=0)break;i[e]=m,e=f}i[e]=u}_down(e){const{data:i,compare:r}=this,u=this.length>>1,f=i[e];for(;e=0)break;i[e]=y,e=m}i[e]=f}}function aM(t,e){return te?1:0}function lM(t,e=1,i=!1){let r=1/0,u=1/0,f=-1/0,m=-1/0;const y=t[0];for(let B=0;Bf)&&(f=U.x),(!B||U.y>m)&&(m=U.y)}const E=Math.min(f-r,m-u);let T=E/2;const C=new sM([],uM);if(E===0)return new Oe(r,u);for(let B=r;BL.d||!L.d)&&(L=B,i&&console.log("found best %d after %d probes",Math.round(1e4*B.d)/1e4,D)),B.max-L.d<=e||(T=B.h/2,C.push(new Xu(B.p.x-T,B.p.y-T,T,t)),C.push(new Xu(B.p.x+T,B.p.y-T,T,t)),C.push(new Xu(B.p.x-T,B.p.y+T,T,t)),C.push(new Xu(B.p.x+T,B.p.y+T,T,t)),D+=4)}return i&&(console.log(`num probes: ${D}`),console.log(`best distance: ${L.d}`)),L.p}function uM(t,e){return e.max-t.max}class Xu{constructor(e,i,r,u){this.p=new Oe(e,i),this.h=r,this.d=function(f,m){let y=!1,E=1/0;for(let T=0;Tf.y!=G.y>f.y&&f.x<(G.x-U.x)*(f.y-U.y)/(G.y-U.y)+U.x&&(y=!y),E=Math.min(E,L0(f,U,G))}}return(y?1:-1)*Math.sqrt(E)}(this.p,u),this.max=this.d+this.h*Math.SQRT2}}const Wu=7,$m=Number.POSITIVE_INFINITY,cM=Math.sqrt(2);function Bx(t,[e,i]){let r=0,u=0;if(i===$m){e<0&&(e=0);const f=e/cM;switch(t){case"top-right":case"top-left":u=f-Wu;break;case"bottom-right":case"bottom-left":u=-f+Wu;break;case"bottom":u=-e+Wu;break;case"top":u=e-Wu}switch(t){case"top-right":case"bottom-right":r=-f;break;case"top-left":case"bottom-left":r=f;break;case"left":r=e;break;case"right":r=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":u=i-Wu;break;case"bottom-right":case"bottom-left":case"bottom":u=-i+Wu}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}}return[r,u]}function hM(t,e,i,r,u,f,m,y,E,T){t.createArrays(),t.tilePixelRatio=Ft/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const C=t.layers[0].layout,L=t.layers[0]._unevaluatedLayout._values,D={};if(t.textSizeData.kind==="composite"){const{minZoom:G,maxZoom:H}=t.textSizeData;D.compositeTextSizes=[L["text-size"].possiblyEvaluate(new P(G),y),L["text-size"].possiblyEvaluate(new P(H),y)]}if(t.iconSizeData.kind==="composite"){const{minZoom:G,maxZoom:H}=t.iconSizeData;D.compositeIconSizes=[L["icon-size"].possiblyEvaluate(new P(G),y),L["icon-size"].possiblyEvaluate(new P(H),y)]}D.layoutTextSize=L["text-size"].possiblyEvaluate(new P(E+1),y),D.layoutIconSize=L["icon-size"].possiblyEvaluate(new P(E+1),y),D.textMaxSize=L["text-size"].possiblyEvaluate(new P(18),y);const B=C.get("text-rotation-alignment")==="map"&&C.get("symbol-placement")!=="point",U=C.get("text-size");for(const G of t.features){const H=C.get("text-font").evaluate(G,{},y).join(","),ne=U.evaluate(G,{},y),de=D.layoutTextSize.evaluate(G,{},y),re=(D.layoutIconSize.evaluate(G,{},y),{horizontal:{},vertical:void 0}),fe=G.text;let ve,ge=[0,0];if(fe){const qe=fe.toString(),it=C.get("text-letter-spacing").evaluate(G,{},y)*Kn,Ve=C.get("text-line-height").evaluate(G,{},y)*Kn,Ye=Qd(qe)?it:0,He=C.get("text-anchor").evaluate(G,{},y),Je=C.get("text-variable-anchor");if(!Je){const xt=C.get("text-radial-offset").evaluate(G,{},y);ge=xt?Bx(He,[xt*Kn,$m]):C.get("text-offset").evaluate(G,{},y).map(ni=>ni*Kn)}let at=B?"center":C.get("text-justify").evaluate(G,{},y);const $e=C.get("symbol-placement")==="point",vt=$e?C.get("text-max-width").evaluate(G,{},y)*Kn:1/0,Lt=xt=>{t.allowVerticalPlacement&&zc(qe)&&(re.vertical=jm(fe,e,i,u,H,vt,Ve,He,xt,Ye,ge,mo.vertical,!0,de,ne))};if(!B&&Je){const xt=at==="auto"?Je.map(lt=>qm(lt)):[at];let ni=!1;for(let lt=0;lt=0||!zc(qe)){const xt=jm(fe,e,i,u,H,vt,Ve,He,at,Ye,ge,mo.horizontal,!1,de,ne);xt&&(re.horizontal[at]=xt)}Lt($e?"left":at)}}let Be=!1;if(G.icon&&G.icon.name){const qe=r[G.icon.name];qe&&(ve=iM(u[G.icon.name],C.get("icon-offset").evaluate(G,{},y),C.get("icon-anchor").evaluate(G,{},y)),Be=qe.sdf,t.sdfIcons===void 0?t.sdfIcons=qe.sdf:t.sdfIcons!==qe.sdf&&Ti("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(qe.pixelRatio!==t.pixelRatio||C.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}const De=Ux(re.horizontal)||re.vertical;t.iconsInText||(t.iconsInText=!!De&&De.iconsInText),(De||ve)&&fM(t,G,re,ve,r,D,de,0,ge,Be,m,y,T)}f&&t.generateCollisionDebugBuffers(E,t.collisionBoxArray)}function qm(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 fM(t,e,i,r,u,f,m,y,E,T,C,L,D){let B=f.textMaxSize.evaluate(e,{},L);B===void 0&&(B=m);const U=t.layers[0].layout,G=U.get("icon-offset").evaluate(e,{},L),H=Ux(i.horizontal)||i.vertical,ne=D.name==="globe",de=Kn,re=m/de,fe=t.tilePixelRatio*B/de,ve=(He=t.overscaling,t.zoom>18&&He>2&&(He>>=1),Math.max(Ft/(512*He),1)*U.get("symbol-spacing")),ge=U.get("text-padding")*t.tilePixelRatio,Be=U.get("icon-padding")*t.tilePixelRatio,De=At(U.get("text-max-angle")),qe=U.get("text-rotation-alignment")==="map"&&U.get("symbol-placement")!=="point",it=U.get("icon-rotation-alignment")==="map"&&U.get("symbol-placement")!=="point",Ve=U.get("symbol-placement"),Ye=ve/2;var He;const Je=U.get("icon-text-fit");let at;r&&Je!=="none"&&(t.allowVerticalPlacement&&i.vertical&&(at=kx(r,i.vertical,Je,U.get("icon-text-fit-padding"),G,re)),H&&(r=kx(r,H,Je,U.get("icon-text-fit-padding"),G,re)));const $e=(vt,Lt,xt)=>{if(Lt.x<0||Lt.x>=Ft||Lt.y<0||Lt.y>=Ft)return;let ni=null;if(ne){const{x:lt,y:Nt,z:ri}=D.projectTilePoint(Lt.x,Lt.y,xt);ni={anchor:new la(lt,Nt,ri,0,void 0),up:D.upVector(xt,Lt.x,Lt.y)}}(function(lt,Nt,ri,Ii,oi,Gt,Qi,si,ai,Gi,Yi,Hi,$i,an,mn,Sn,qi,Rn,In,fn,Mi,kn,Ki,Pr,Mn){const Jn=lt.addToLineVertexArray(Nt,Ii);let qn,Lr,Zn,os,Ku,xh,bh,v1=0,x1=0,b1=0,w1=0,sg=-1,ag=-1;const Ls={};let E1=im("");const Vl=ri?ri.anchor:Nt;let lg=0,ug=0;if(ai._unevaluatedLayout.getValue("text-radial-offset")===void 0?[lg,ug]=ai.layout.get("text-offset").evaluate(Mi,{},Mn).map(to=>to*Kn):(lg=ai.layout.get("text-radial-offset").evaluate(Mi,{},Mn)*Kn,ug=$m),lt.allowVerticalPlacement&&oi.vertical){const to=oi.vertical;if(mn)xh=Zm(to),si&&(bh=Zm(si));else{const io=ai.layout.get("text-rotate").evaluate(Mi,{},Mn)+90;Zn=hp(Gi,Vl,Nt,Yi,Hi,$i,to,an,io,Sn),si&&(os=hp(Gi,Vl,Nt,Yi,Hi,$i,si,Rn,io))}}if(Gt){const to=ai.layout.get("icon-rotate").evaluate(Mi,{},Mn),io=ai.layout.get("icon-text-fit")!=="none",wh=zx(Gt,to,Ki,io),hg=si?zx(si,to,Ki,io):void 0;Lr=hp(Gi,Vl,Nt,Yi,Hi,$i,Gt,Rn,to),v1=4*wh.length;const T1=lt.iconSizeData;let Gl=null;T1.kind==="source"?(Gl=[is*ai.layout.get("icon-size").evaluate(Mi,{},Mn)],Gl[0]>Za&&Ti(`${lt.layerIds[0]}: Value for "icon-size" is >= ${fh}. Reduce your "icon-size".`)):T1.kind==="composite"&&(Gl=[is*kn.compositeIconSizes[0].evaluate(Mi,{},Mn),is*kn.compositeIconSizes[1].evaluate(Mi,{},Mn)],(Gl[0]>Za||Gl[1]>Za)&&Ti(`${lt.layerIds[0]}: Value for "icon-size" is >= ${fh}. Reduce your "icon-size".`)),lt.addSymbols(lt.icon,wh,Gl,fn,In,Mi,!1,ri,Nt,Jn.lineStartIndex,Jn.lineLength,-1,Pr,Mn),sg=lt.icon.placedSymbolArray.length-1,hg&&(x1=4*hg.length,lt.addSymbols(lt.icon,hg,Gl,fn,In,Mi,mo.vertical,ri,Nt,Jn.lineStartIndex,Jn.lineLength,-1,Pr,Mn),ag=lt.icon.placedSymbolArray.length-1)}for(const to in oi.horizontal){const io=oi.horizontal[to];qn||(E1=im(io.text),mn?Ku=Zm(io):qn=hp(Gi,Vl,Nt,Yi,Hi,$i,io,an,ai.layout.get("text-rotate").evaluate(Mi,{},Mn),Sn));const wh=io.positionedLines.length===1;if(b1+=Fx(lt,ri,Nt,io,Qi,ai,mn,Mi,Sn,Jn,oi.vertical?mo.horizontal:mo.horizontalOnly,wh?Object.keys(oi.horizontal):[to],Ls,sg,kn,Pr,Mn),wh)break}oi.vertical&&(w1+=Fx(lt,ri,Nt,oi.vertical,Qi,ai,mn,Mi,Sn,Jn,mo.vertical,["vertical"],Ls,ag,kn,Pr,Mn));let Ja=-1;const cg=(to,io)=>to?Math.max(to,io):io;Ja=cg(Ku,Ja),Ja=cg(xh,Ja),Ja=cg(bh,Ja);const UM=Ja>-1?1:0;lt.glyphOffsetArray.length>=Wa.MAX_GLYPHS&&Ti("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Mi.sortKey!==void 0&<.addToSortKeyRanges(lt.symbolInstances.length,Mi.sortKey),lt.symbolInstances.emplaceBack(Vl.x,Vl.y,Vl.z,Nt.x,Nt.y,Ls.right>=0?Ls.right:-1,Ls.center>=0?Ls.center:-1,Ls.left>=0?Ls.left:-1,Ls.vertical>=0?Ls.vertical:-1,sg,ag,E1,qn!==void 0?qn:lt.collisionBoxArray.length,qn!==void 0?qn+1:lt.collisionBoxArray.length,Zn!==void 0?Zn:lt.collisionBoxArray.length,Zn!==void 0?Zn+1:lt.collisionBoxArray.length,Lr!==void 0?Lr:lt.collisionBoxArray.length,Lr!==void 0?Lr+1:lt.collisionBoxArray.length,os||lt.collisionBoxArray.length,os?os+1:lt.collisionBoxArray.length,Yi,b1,w1,v1,x1,UM,0,lg,ug,Ja)})(t,Lt,ni,vt,i,r,u,at,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,ge,qe,E,0,Be,it,G,e,f,T,C,L)};if(Ve==="line")for(const vt of Rx(e.geometry,0,0,Ft,Ft)){const Lt=rM(vt,ve,De,i.vertical||H,r,de,fe,t.overscaling,Ft);for(const xt of Lt)H&&pM(t,H.text,Ye,xt)||$e(vt,xt,L)}else if(Ve==="line-center"){for(const vt of e.geometry)if(vt.length>1){const Lt=nM(vt,De,i.vertical||H,r,de,fe);Lt&&$e(vt,Lt,L)}}else if(e.type==="Polygon")for(const vt of Lm(e.geometry,0)){const Lt=lM(vt,16);$e(vt[0],new la(Lt.x,Lt.y,0,0,void 0),L)}else if(e.type==="LineString")for(const vt of e.geometry)$e(vt,new la(vt[0].x,vt[0].y,0,0,void 0),L);else if(e.type==="Point")for(const vt of e.geometry)for(const Lt of vt)$e([Lt],new la(Lt.x,Lt.y,0,0,void 0),L)}const fh=255,Za=fh*is;function Fx(t,e,i,r,u,f,m,y,E,T,C,L,D,B,U,G,H){const ne=function(fe,ve,ge,Be,De,qe,it,Ve){const Ye=[];if(ve.positionedLines.length===0)return Ye;const He=Be.layout.get("text-rotate").evaluate(qe,{})*Math.PI/180,Je=function(xt){const ni=xt[0],lt=xt[1],Nt=ni*lt;return Nt>0?[ni,-lt]:Nt<0?[-ni,lt]:ni===0?[lt,ni]:[lt,-ni]}(ge);let at=Math.abs(ve.top-ve.bottom);for(const xt of ve.positionedLines)at-=xt.lineOffset;const $e=ve.positionedLines.length,vt=at/$e;let Lt=ve.top-ge[1];for(let xt=0;xt<$e;++xt){const ni=ve.positionedLines[xt];Lt=oM(ve,vt,Lt,xt);for(const lt of ni.positionedGlyphs){if(!lt.rect)continue;const Nt=lt.rect||{};let ri=vx+1,Ii=!0,oi=1,Gt=0;if(lt.imageName){const Ki=it[lt.imageName];if(!Ki)continue;if(Ki.sdf){Ti("SDF images are not supported in formatted text and will be ignored.");continue}Ii=!1,oi=Ki.pixelRatio,ri=Vr/oi}const Qi=(De||Ve)&<.vertical,si=lt.metrics.advance*lt.scale/2,ai=lt.metrics,Gi=lt.rect;if(Gi===null)continue;Ve&&ve.verticalizable&&(Gt=lt.imageName?si-lt.metrics.width*lt.scale/2:0);const Yi=De?[lt.x+si,lt.y]:[0,0];let Hi=[0,0],$i=[0,0],an=!1;De||(Qi?($i=[lt.x+si+Je[0],lt.y+Je[1]-Gt],an=!0):Hi=[lt.x+si+ge[0],lt.y+ge[1]-Gt]);const mn=Gi.w*lt.scale/(oi*(lt.localGlyph?ns:1)),Sn=Gi.h*lt.scale/(oi*(lt.localGlyph?ns:1));let qi,Rn,In,fn;if(Qi){const Ki=lt.y-Lt,Pr=new Oe(-si,si-Ki),Mn=-Math.PI/2,Jn=new Oe(...$i);qi=new Oe(-si+Hi[0],Hi[1]),qi._rotateAround(Mn,Pr)._add(Jn),qi.x+=-Ki+si,qi.y-=(ai.left-ri)*lt.scale;const qn=lt.imageName?ai.advance*lt.scale:Kn*lt.scale,Lr=String.fromCharCode(lt.glyph);Uk(Lr)?qi.x+=(1-ri)*lt.scale:jk(Lr)?qi.x+=qn-ai.height*lt.scale+(-ri-1)*lt.scale:qi.x+=lt.imageName||ai.width+2*ri===Gi.w&&ai.height+2*ri===Gi.h?(qn-Sn)/2:(qn-(ai.height+2*ri)*lt.scale)/2,Rn=new Oe(qi.x,qi.y-mn),In=new Oe(qi.x+Sn,qi.y),fn=new Oe(qi.x+Sn,qi.y-mn)}else{const Ki=(ai.left-ri)*lt.scale-si+Hi[0],Pr=(-ai.top-ri)*lt.scale+Hi[1],Mn=Ki+mn,Jn=Pr+Sn;qi=new Oe(Ki,Pr),Rn=new Oe(Mn,Pr),In=new Oe(Ki,Jn),fn=new Oe(Mn,Jn)}if(He){let Ki;Ki=De?new Oe(0,0):an?new Oe(Je[0],Je[1]):new Oe(ge[0],ge[1]),qi._rotateAround(He,Ki),Rn._rotateAround(He,Ki),In._rotateAround(He,Ki),fn._rotateAround(He,Ki)}const Mi=new Oe(0,0),kn=new Oe(0,0);Ye.push({tl:qi,tr:Rn,bl:In,br:fn,tex:Nt,writingMode:ve.writingMode,glyphOffset:Yi,sectionIndex:lt.sectionIndex,isSDF:Ii,pixelOffsetTL:Mi,pixelOffsetBR:kn,minFontScaleX:0,minFontScaleY:0})}}return Ye}(0,r,E,f,m,y,u,t.allowVerticalPlacement),de=t.textSizeData;let re=null;de.kind==="source"?(re=[is*f.layout.get("text-size").evaluate(y,{},H)],re[0]>Za&&Ti(`${t.layerIds[0]}: Value for "text-size" is >= ${fh}. Reduce your "text-size".`)):de.kind==="composite"&&(re=[is*U.compositeTextSizes[0].evaluate(y,{},H),is*U.compositeTextSizes[1].evaluate(y,{},H)],(re[0]>Za||re[1]>Za)&&Ti(`${t.layerIds[0]}: Value for "text-size" is >= ${fh}. Reduce your "text-size".`)),t.addSymbols(t.text,ne,re,E,m,y,C,e,i,T.lineStartIndex,T.lineLength,B,G,H);for(const fe of L)D[fe]=t.text.placedSymbolArray.length-1;return 4*ne.length}function Ux(t){for(const e in t)return t[e];return null}function hp(t,e,i,r,u,f,m,y,E,T){let C=m.top,L=m.bottom,D=m.left,B=m.right;const U=m.collisionPadding;if(U&&(D-=U[0],C-=U[1],B+=U[2],L+=U[3]),E){const G=new Oe(D,C),H=new Oe(B,C),ne=new Oe(D,L),de=new Oe(B,L),re=At(E);let fe=new Oe(0,0);T&&(fe=new Oe(T[0],T[1])),G._rotateAround(re,fe),H._rotateAround(re,fe),ne._rotateAround(re,fe),de._rotateAround(re,fe),D=Math.min(G.x,H.x,ne.x,de.x),B=Math.max(G.x,H.x,ne.x,de.x),C=Math.min(G.y,H.y,ne.y,de.y),L=Math.max(G.y,H.y,ne.y,de.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,D,C,B,L,y,r,u,f),t.length-1}function Zm(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 pM(t,e,i,r){const u=t.compareText;if(e in u){const f=u[e];for(let m=f.length-1;m>=0;m--)if(r.dist(f[m])re&&(fe(ge,Je,De,qe,Ye,He),fe(Je,Be,Ye,He,it,Ve))}fe(L,D,r,f,u,f),fe(D,B,u,f,u,m),fe(B,U,u,m,r,m),fe(U,L,r,m,r,f),G-=re,H-=re,ne+=re,de+=re;const ve=1/Math.max(ne-G,de-H);return{scale:ve,x:G*ve,y:H*ve,x2:ne*ve,y2:de*ve,projection:e}}const dM=Qo(new Float32Array(16));class Xa{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new Vi(0,0)}projectTilePoint(e,i,r){return{x:e,y:i,z:0}}locationPoint(e,i,r=!0){return e._coordinatePoint(e.locationCoordinate(i),r)}pixelsPerMeter(e,i){return ts(1,e)*i}pixelSpaceConversion(e,i,r){return 1}farthestPixelDistance(e){return jx(e,e.pixelsPerMeter)}pointCoordinate(e,i,r,u){const f=e.horizonLineFromTop(!1),m=new Oe(i,Math.max(f,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(m,u))}pointCoordinate3D(e,i,r){const u=new Oe(i,r);if(e.elevation)return e.elevation.pointCoordinate(u);{const f=this.pointCoordinate(e,u.x,u.y,0);return[f.x,f.y,f.z]}}isPointAboveHorizon(e,i){if(e.elevation)return!this.pointCoordinate3D(e,i.x,i.y);const r=e.horizonLineFromTop();return i.y0?i<-Yu+r&&(i=-Yu+r):i>Yu-r&&(i=Yu-r);const m=f/Math.pow(pp(i),u);let y=m*Math.sin(u*e),E=f-m*Math.cos(u*e);return y=.5*(y/Math.PI+.5),E=.5*(E/Math.PI+.5),{x:y,y:this.southernCenter?E:1-E,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;const{n:r,f:u}=this,f=u-i,m=Math.sign(f),y=Math.sign(r)*Math.sqrt(e*e+f*f);let E=Math.atan2(e,Math.abs(f))*m;f*r<0&&(E-=Math.PI*Math.sign(e)*m);const T=Rt(Xt(E/r)+this.center[0],-180,180),C=Rt(Xt(2*Math.atan(Math.pow(u/y,1/r))-Yu),-hr,hr);return new Vi(T,this.southernCenter?-C:C)}}class Vx extends Xa{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:ks(e),y:Ms(i),z:0}}unproject(e,i){const r=po(e),u=cr(i);return new Vi(r,u)}}const Gx=At(hr);class vM extends Xa{project(e,i){const r=(i=At(i))*i,u=r*r;return{x:.5*((e=At(e))*(.8707-.131979*r+u*(u*(.003971*r-.001529*u)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+r*(.015085+u*(.028874*r-.044475-.005916*u)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,u=25,f=0,m=r*r;do{m=r*r;const T=m*m;f=(r*(1.007226+m*(.015085+T*(.028874*m-.044475-.005916*T)))-i)/(1.007226+m*(.045255+T*(.259866*m-.311325-.06507600000000001*T))),r=Rt(r-f,-Gx,Gx)}while(Math.abs(f)>1e-6&&--u>0);m=r*r;const y=Rt(Xt(e/(.8707+m*(m*(m*m*m*(.003971-.001529*m)-.013791)-.131979))),-180,180),E=Xt(r);return new Vi(y,E)}}const $x=At(hr);class xM extends Xa{project(e,i){i=At(i),e=At(e);const r=Math.cos(i),u=2/Math.PI,f=Math.acos(r*Math.cos(e/2)),m=Math.sin(f)/f,y=.5*(e*u+2*r*Math.sin(e/2)/m)||0,E=.5*(i+Math.sin(i)/m)||0;return{x:.5*(y/Math.PI+.5),y:1-.5*(E/Math.PI+1),z:0}}unproject(e,i){let r=e=(2*e-.5)*Math.PI,u=i=(2*(1-i)-1)*Math.PI,f=25;const m=1e-6;let y=0,E=0;do{const T=Math.cos(u),C=Math.sin(u),L=2*C*T,D=C*C,B=T*T,U=Math.cos(r/2),G=Math.sin(r/2),H=2*U*G,ne=G*G,de=1-B*U*U,re=de?1/de:0,fe=de?Math.acos(T*U)*Math.sqrt(1/de):0,ve=.5*(2*fe*T*G+2*r/Math.PI)-e,ge=.5*(fe*C+u)-i,Be=.5*re*(B*ne+fe*T*U*D)+1/Math.PI,De=re*(H*L/4-fe*C*G),qe=.125*re*(L*G-fe*C*B*H),it=.5*re*(D*U+fe*ne*T)+.5,Ve=De*qe-it*Be;y=(ge*De-ve*it)/Ve,E=(ve*qe-ge*Be)/Ve,r=Rt(r-y,-Math.PI,Math.PI),u=Rt(u-E,-$x,$x)}while((Math.abs(y)>m||Math.abs(E)>m)&&--f>0);return new Vi(Xt(r),Xt(u))}}class qx extends Xa{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(At(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){const{scale:r,cosPhi:u}=this;return{x:At(e)*u*r+.5,y:-Math.sin(At(i))/u*r+.5,z:0}}unproject(e,i){const{scale:r,cosPhi:u}=this,f=-(i-.5)/r,m=Rt(Xt((e-.5)/r)/u,-180,180),y=Math.asin(Rt(f*u,-1,1)),E=Rt(Xt(y),-hr,hr);return new Vi(m,E)}}class bM extends Vx{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,r){const u=Kc(e,i,r);return gn(u,u,Jc(Is(r))),{x:u[0],y:u[1],z:u[2]}}locationPoint(e,i){const r=Du(i.lat,i.lng),u=Mr([],r),f=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;Xc(r,r,u,ts(1,0)*Ft*f);const m=Qo(new Float64Array(16));return Ll(m,e.pixelMatrix,e.globeMatrix),gn(r,r,m),new Oe(r[0],r[1])}pixelsPerMeter(e,i){return ts(1,0)*i}pixelSpaceConversion(e,i,r){const u=ts(1,e)*i,f=bi(ts(1,45)*i,u,r);return this.pixelsPerMeter(e,i)/f}createTileMatrix(e,i,r){const u=gm(Is(r.canonical));return Ll(new Float64Array(16),e.globeMatrix,u)}createInversionMatrix(e,i){const{center:r}=e,u=Jc(Is(i));return jf(u,u,At(r.lng)),sm(u,u,At(r.lat)),Rl(u,u,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(u)}pointCoordinate(e,i,r,u){return y0(e,i,r,!0)||new zu(0,0)}pointCoordinate3D(e,i,r){const u=this.pointCoordinate(e,i,r,0);return[u.x,u.y,u.z]}isPointAboveHorizon(e,i){return!y0(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=function(u,f){const m=u.cameraToCenterDistance,y=u._centerAltitude*f,E=u._camera,T=u._camera.forward(),C=ra([],fo([],T,-m),[0,0,y]),L=u.worldSize/(2*Math.PI),D=[0,0,-L],B=u.width/u.height,U=Math.tan(u.fovAboveCenter),G=fo([],E.up(),U),H=fo([],E.right(),U*B),ne=Mr([],ra([],ra([],T,G),H)),de=[];let re;if(new cm(C,ne).closestPointOnSphere(D,L,de)){const fe=ra([],de,D),ve=es([],fe,C);re=Math.cos(u.fovAboveCenter)*$c(ve)}else{const fe=es([],C,D),ve=es([],D,C);Mr(ve,ve);const ge=$c(fe)-L;re=Math.sqrt(ge*(ge+2*L));const Be=Math.acos(re/(L+ge))-Math.acos(Mo(T,ve));re*=Math.cos(Be)}return 1.01*re}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Ou(e.zoom);if(r>0){const u=jx(e,ts(1,e.center.lat)*e.worldSize),f=e.worldSize/(2*Math.PI),m=Math.max(e.width,e.height)/e.worldSize*Math.PI;return bi(i,u+f*(1-Math.cos(m)),Math.pow(r,10))}return i}upVector(e,i,r){return Kc(i,r,e,1)}upVectorScale(e){return{metersToTile:Vf($f(Is(e)))}}}function Zx(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Vx(t);case"equirectangular":return new _M(t);case"naturalEarth":return new vM(t);case"equalEarth":return new gM(t);case"winkelTripel":return new xM(t);case"albers":return i?new qx(t):new mM(t);case"lambertConformalConic":return i?new qx(t):new yM(t);case"globe":return new bM(t)}throw new Error(`Invalid projection name: ${t.name}`)}const wM=ep.types,EM=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function dp(t,e,i,r,u,f,m,y,E,T,C,L,D){const B=y?Math.min(Za,Math.round(y[0])):0,U=y?Math.min(Za,Math.round(y[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*u),f,m,(B<<1)+(E?1:0),U,16*T,16*C,256*L,256*D)}function mp(t,e,i,r,u,f,m){t.emplaceBack(e,i,r,u,f,m)}function gp(t,e,i,r,u){t.emplaceBack(e,i,r,u),t.emplaceBack(e,i,r,u),t.emplaceBack(e,i,r,u),t.emplaceBack(e,i,r,u)}function TM(t){for(const e of t.sections)if(tm(e.text))return!0;return!1}class Xm{constructor(e){this.layoutVertexArray=new Ke,this.indexArray=new Ot,this.programConfigurations=e,this.segments=new En,this.dynamicLayoutVertexArray=new et,this.opacityVertexArray=new zt,this.placedSymbolArray=new wn,this.globeExtVertexArray=new st}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,r,u){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Lk.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Dk.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,EM,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Rk.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||u)&&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.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Ct(Xm,"SymbolBuffers");class Wm{constructor(e,i,r){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new r,this.segments=new En,this.collisionVertexArray=new mi,this.collisionVertexArrayExt=new di}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ok.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,zk.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ct(Wm,"CollisionBuffers");class Wa{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(m=>m.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Qo([]),this.placementViewportMatrix=Qo([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=zm(this.zoom,i["text-size"]),this.iconSizeData=zm(this.zoom,i["icon-size"]);const r=this.layers[0].layout,u=r.get("symbol-sort-key"),f=r.get("symbol-z-order");this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=f!=="viewport-y"&&u.constantOr(1)!==void 0,this.sortFeaturesByY=(f==="viewport-y"||f==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(m=>mo[m]),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Xm(new Pl(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Xm(new Pl(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new kr,this.lineVertexArray=new Au,this.symbolInstances=new nn}calculateGlyphDependencies(e,i,r,u,f){for(let m=0;m0)&&(E.value.kind!=="constant"||E.value.value.length>0),D=C.value.kind!=="constant"||!!C.value.value||Object.keys(C.parameters).length>0,B=m.get("symbol-sort-key");if(this.features=[],!L&&!D)return;const U=i.iconDependencies,G=i.glyphDependencies,H=i.availableImages,ne=new P(this.zoom);for(const{feature:de,id:re,index:fe,sourceLayerIndex:ve}of e){const ge=f._featureFilter.needGeometry,Be=Nl(de,ge);if(!f._featureFilter.filter(ne,Be,r))continue;if(ge||(Be.geometry=oa(de,r,u)),y&&de.type!==1&&r.z<=5){const Ve=Be.geometry,Ye=.98078528056,He=(Je,at)=>Mo(Kc(Je.x,Je.y,r,1),Kc(at.x,at.y,r,1))=0;for(const He of De.sections)if(He.image)U[He.image.name]=!0;else{const Je=zc(De.toString()),at=He.fontStack||Ve,$e=G[at]=G[at]||{};this.calculateGlyphDependencies(He.text,$e,Ye,this.allowVerticalPlacement,Je)}}}m.get("symbol-placement")==="line"&&(this.features=function(de){const re={},fe={},ve=[];let ge=0;function Be(Ve){ve.push(de[Ve]),ge++}function De(Ve,Ye,He){const Je=fe[Ve];return delete fe[Ve],fe[Ye]=Je,ve[Je].geometry[0].pop(),ve[Je].geometry[0]=ve[Je].geometry[0].concat(He[0]),Je}function qe(Ve,Ye,He){const Je=re[Ye];return delete re[Ye],re[Ve]=Je,ve[Je].geometry[0].shift(),ve[Je].geometry[0]=He[0].concat(ve[Je].geometry[0]),Je}function it(Ve,Ye,He){const Je=He?Ye[0][Ye[0].length-1]:Ye[0][0];return`${Ve}:${Je.x}:${Je.y}`}for(let Ve=0;VeVe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((de,re)=>de.sortKey-re.sortKey)}update(e,i,r,u){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,i,this.layers,r,u),this.icon.programConfigurations.updatePaintArrays(e,i,this.layers,r,u))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Zx(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const r=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:u,y:f}of i)this.lineVertexArray.emplaceBack(u,f);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,i,r,u,f,m,y,E,T,C,L,D,B,U){const G=e.indexArray,H=e.layoutVertexArray,ne=e.globeExtVertexArray,de=e.segments.prepareSegment(4*i.length,H,G,this.canOverlap?m.sortKey:void 0),re=this.glyphOffsetArray.length,fe=de.vertexLength,ve=this.allowVerticalPlacement&&y===mo.vertical?Math.PI/2:0,ge=m.text&&m.text.sections;for(let De=0;De=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:u),m=rp(this.textSizeData,e,f)/Kn;return this.tilePixelRatio*m}getSymbolInstanceIconSize(e,i,r){const u=this.icon.placedSymbolArray.get(r),f=rp(this.iconSizeData,e,u);return this.tilePixelRatio*f}_commitDebugCollisionVertexUpdate(e,i,r){e.emplaceBack(i,-r,-r),e.emplaceBack(i,r,-r),e.emplaceBack(i,r,r),e.emplaceBack(i,-r,r)}_updateTextDebugCollisionBoxes(e,i,r,u,f,m){for(let y=u;y0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,i){const r=e.placedSymbolArray.get(i),u=r.vertexStartIndex+4*r.numGlyphs;for(let f=r.vertexStartIndex;fu[y]-u[E]||f[E]-f[y]),m}addToSortKeyRanges(e,i){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===i?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const r=this.symbolInstances.get(i);this.featureSortOrder.push(r.featureIndex);const{rightJustifiedTextSymbolIndex:u,centerJustifiedTextSymbolIndex:f,leftJustifiedTextSymbolIndex:m,verticalPlacedTextSymbolIndex:y,placedIconSymbolIndex:E,verticalPlacedIconSymbolIndex:T}=r;u>=0&&this.addIndicesForPlacedSymbol(this.text,u),f>=0&&f!==u&&this.addIndicesForPlacedSymbol(this.text,f),m>=0&&m!==f&&m!==u&&this.addIndicesForPlacedSymbol(this.text,m),y>=0&&this.addIndicesForPlacedSymbol(this.text,y),E>=0&&this.addIndicesForPlacedSymbol(this.icon,E),T>=0&&this.addIndicesForPlacedSymbol(this.icon,T)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ct(Wa,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Wa.MAX_GLYPHS=65535,Wa.addDynamicAttributes=gp;const SM=new le({"symbol-placement":new V(Ge.layout_symbol["symbol-placement"]),"symbol-spacing":new V(Ge.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new V(Ge.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new K(Ge.layout_symbol["symbol-sort-key"]),"symbol-z-order":new V(Ge.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new V(Ge.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new V(Ge.layout_symbol["icon-ignore-placement"]),"icon-optional":new V(Ge.layout_symbol["icon-optional"]),"icon-rotation-alignment":new V(Ge.layout_symbol["icon-rotation-alignment"]),"icon-size":new K(Ge.layout_symbol["icon-size"]),"icon-text-fit":new V(Ge.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new V(Ge.layout_symbol["icon-text-fit-padding"]),"icon-image":new K(Ge.layout_symbol["icon-image"]),"icon-rotate":new K(Ge.layout_symbol["icon-rotate"]),"icon-padding":new V(Ge.layout_symbol["icon-padding"]),"icon-keep-upright":new V(Ge.layout_symbol["icon-keep-upright"]),"icon-offset":new K(Ge.layout_symbol["icon-offset"]),"icon-anchor":new K(Ge.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new V(Ge.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new V(Ge.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new V(Ge.layout_symbol["text-rotation-alignment"]),"text-field":new K(Ge.layout_symbol["text-field"]),"text-font":new K(Ge.layout_symbol["text-font"]),"text-size":new K(Ge.layout_symbol["text-size"]),"text-max-width":new K(Ge.layout_symbol["text-max-width"]),"text-line-height":new K(Ge.layout_symbol["text-line-height"]),"text-letter-spacing":new K(Ge.layout_symbol["text-letter-spacing"]),"text-justify":new K(Ge.layout_symbol["text-justify"]),"text-radial-offset":new K(Ge.layout_symbol["text-radial-offset"]),"text-variable-anchor":new V(Ge.layout_symbol["text-variable-anchor"]),"text-anchor":new K(Ge.layout_symbol["text-anchor"]),"text-max-angle":new V(Ge.layout_symbol["text-max-angle"]),"text-writing-mode":new V(Ge.layout_symbol["text-writing-mode"]),"text-rotate":new K(Ge.layout_symbol["text-rotate"]),"text-padding":new V(Ge.layout_symbol["text-padding"]),"text-keep-upright":new V(Ge.layout_symbol["text-keep-upright"]),"text-transform":new K(Ge.layout_symbol["text-transform"]),"text-offset":new K(Ge.layout_symbol["text-offset"]),"text-allow-overlap":new V(Ge.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new V(Ge.layout_symbol["text-ignore-placement"]),"text-optional":new V(Ge.layout_symbol["text-optional"])});var Ym={paint:new le({"icon-opacity":new K(Ge.paint_symbol["icon-opacity"]),"icon-color":new K(Ge.paint_symbol["icon-color"]),"icon-halo-color":new K(Ge.paint_symbol["icon-halo-color"]),"icon-halo-width":new K(Ge.paint_symbol["icon-halo-width"]),"icon-halo-blur":new K(Ge.paint_symbol["icon-halo-blur"]),"icon-translate":new V(Ge.paint_symbol["icon-translate"]),"icon-translate-anchor":new V(Ge.paint_symbol["icon-translate-anchor"]),"text-opacity":new K(Ge.paint_symbol["text-opacity"]),"text-color":new K(Ge.paint_symbol["text-color"],{runtimeType:Cn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new K(Ge.paint_symbol["text-halo-color"]),"text-halo-width":new K(Ge.paint_symbol["text-halo-width"]),"text-halo-blur":new K(Ge.paint_symbol["text-halo-blur"]),"text-translate":new V(Ge.paint_symbol["text-translate"]),"text-translate-anchor":new V(Ge.paint_symbol["text-translate-anchor"])}),layout:SM};class Xx{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:oo,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ct(Xx,"FormatSectionOverride",{omit:["defaultValue"]});class _p extends Jo{constructor(e){super(e,Ym)}recalculate(e,i){super.recalculate(e,i),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 r=this.layout.get("text-writing-mode");if(r){const u=[];for(const f of r)u.indexOf(f)<0&&u.push(f);this.layout._values["text-writing-mode"]=u}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,i,r,u){const f=this.layout.get(e).evaluate(i,{},r,u),m=this._unevaluatedLayout._values[e];return m.isDataDriven()||za(m.value)||!f?f:function(y,E){return E.replace(/{([^{}]+)}/g,(T,C)=>C in y?String(y[C]):"")}(i.properties,f)}createBucket(e){return new Wa(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ym.paint.overridableProperties){if(!_p.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),r=new Xx(i),u=new bu(r,i.property.specification);let f=null;f=i.value.kind==="constant"||i.value.kind==="source"?new Sc("source",u):new wl("composite",u,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new ee(i.property,f,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&_p.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const r=e.get("text-field"),u=Ym.paint.properties[i];let f=!1;const m=y=>{for(const E of y)if(u.overrides&&u.overrides.hasOverride(E))return void(f=!0)};if(r.value.kind==="constant"&&r.value.value instanceof Nn)m(r.value.value.sections);else if(r.value.kind==="source"){const y=T=>{f||(T instanceof Nr&&Li(T.value)===Us?m(T.value.sections):T instanceof so?m(T.sections):T.eachChild(y))},E=r.value;E._styleExpression&&y(E._styleExpression.expression)}return f}getProgramConfiguration(e){return new Ga(this,e)}}var IM={paint:new le({"background-color":new V(Ge.paint_background["background-color"]),"background-pattern":new V(Ge.paint_background["background-pattern"]),"background-opacity":new V(Ge.paint_background["background-opacity"])})},kM={paint:new le({"raster-opacity":new V(Ge.paint_raster["raster-opacity"]),"raster-hue-rotate":new V(Ge.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new V(Ge.paint_raster["raster-brightness-min"]),"raster-brightness-max":new V(Ge.paint_raster["raster-brightness-max"]),"raster-saturation":new V(Ge.paint_raster["raster-saturation"]),"raster-contrast":new V(Ge.paint_raster["raster-contrast"]),"raster-resampling":new V(Ge.paint_raster["raster-resampling"]),"raster-fade-duration":new V(Ge.paint_raster["raster-fade-duration"])})};class MM extends Jo{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(){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)}}var AM={paint:new le({"sky-type":new V(Ge.paint_sky["sky-type"]),"sky-atmosphere-sun":new V(Ge.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new V(Ge.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new V(Ge.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new V(Ge.paint_sky["sky-gradient-radius"]),"sky-gradient":new ae(Ge.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new V(Ge.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new V(Ge.paint_sky["sky-atmosphere-color"]),"sky-opacity":new V(Ge.paint_sky["sky-opacity"])})};function Hm(t,e,i){const r=[0,0,1],u=f0([]);return d0(u,u,i?-At(t)+Math.PI:At(t)),p0(u,u,-At(e)),l0(r,r,u),Mr(r,r)}const CM={circle:class extends Jo{constructor(t){super(t,jI)}createBucket(t){return new wm(t)}queryRadius(t){const e=t;return Nu("circle-radius",this,e)+Nu("circle-stroke-width",this,e)+Xf(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,u,f,m,y){const E=z0(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),f.angle,t.pixelToTileUnitsFactor),T=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return N0(t,r,f,m,y,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",E,T)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Ga(this,t)}},heatmap:class extends Jo{createBucket(t){return new F0(t)}constructor(t){super(t,qI),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Im({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 Nu("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,u,f,m,y){const E=this.paint.get("heatmap-radius").evaluate(e,i);return N0(t,r,f,m,y,!0,!0,new Oe(0,0),E)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Ga(this,t)}},hillshade:class extends Jo{constructor(t){super(t,ZI)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Jo{constructor(t){super(t,lk)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new Ga(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Jf(t)}queryRadius(){return Xf(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,u,f){return!t.queryGeometry.isAboveHorizon&&P0(O0(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),f.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Jo{constructor(t){super(t,Tk)}createBucket(t){return new sh(t)}queryRadius(){return Xf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Ga(this,t)}queryIntersectsFeature(t,e,i,r,u,f,m,y,E){const T=z0(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),f.angle,t.pixelToTileUnitsFactor),C=this.paint.get("fill-extrusion-height").evaluate(e,i),L=this.paint.get("fill-extrusion-base").evaluate(e,i),D=[0,0],B=y&&f.elevation,U=f.elevation?f.elevation.exaggeration():1,G=t.tile.getBucket(this);if(B&&G instanceof sh){const fe=G.centroidVertexArray,ve=E+1;vefe.polygon).flat());const H=B?y:null,[ne,de]=function(fe,ve,ge,Be,De,qe,it,Ve,Ye,He,Je){return fe.projection.name==="globe"?function(at,$e,vt,Lt,xt,ni,lt,Nt,ri,Ii,oi){const Gt=[],Qi=[],si=at.projection.upVectorScale(oi,at.center.lat,at.worldSize).metersToTile,ai=[0,0,0,1],Gi=[0,0,0,1],Yi=($i,an,mn,Sn)=>{$i[0]=an,$i[1]=mn,$i[2]=Sn,$i[3]=1},Hi=ix();vt>0&&(vt+=Hi),Lt+=Hi;for(const $i of $e){const an=[],mn=[];for(const Sn of $i){const qi=Sn.x+xt.x,Rn=Sn.y+xt.y,In=at.projection.projectTilePoint(qi,Rn,oi),fn=at.projection.upVector(oi,Sn.x,Sn.y);let Mi=vt,kn=Lt;if(lt){const Ki=ax(qi,Rn,vt,Lt,lt,Nt,ri,Ii);Mi+=Ki.base,kn+=Ki.top}vt!==0?Yi(ai,In.x+fn[0]*si*Mi,In.y+fn[1]*si*Mi,In.z+fn[2]*si*Mi):Yi(ai,In.x,In.y,In.z),Yi(Gi,In.x+fn[0]*si*kn,In.y+fn[1]*si*kn,In.z+fn[2]*si*kn),gn(ai,ai,ni),gn(Gi,Gi,ni),an.push(new Uu(ai[0],ai[1],ai[2])),mn.push(new Uu(Gi[0],Gi[1],Gi[2]))}Gt.push(an),Qi.push(mn)}return[Gt,Qi]}(fe,ve,ge,Be,De,qe,it,Ve,Ye,He,Je):it?function(at,$e,vt,Lt,xt,ni,lt,Nt,ri){const Ii=[],oi=[],Gt=[0,0,0,1];for(const Qi of at){const si=[],ai=[];for(const Gi of Qi){const Yi=Gi.x+Lt.x,Hi=Gi.y+Lt.y,$i=ax(Yi,Hi,$e,vt,ni,lt,Nt,ri);Gt[0]=Yi,Gt[1]=Hi,Gt[2]=$i.base,Gt[3]=1,Dl(Gt,Gt,xt),Gt[3]=Math.max(Gt[3],1e-5);const an=new Uu(Gt[0]/Gt[3],Gt[1]/Gt[3],Gt[2]/Gt[3]);Gt[0]=Yi,Gt[1]=Hi,Gt[2]=$i.top,Gt[3]=1,Dl(Gt,Gt,xt),Gt[3]=Math.max(Gt[3],1e-5);const mn=new Uu(Gt[0]/Gt[3],Gt[1]/Gt[3],Gt[2]/Gt[3]);si.push(an),ai.push(mn)}Ii.push(si),oi.push(ai)}return[Ii,oi]}(ve,ge,Be,De,qe,it,Ve,Ye,He):function(at,$e,vt,Lt,xt){const ni=[],lt=[],Nt=xt[8]*$e,ri=xt[9]*$e,Ii=xt[10]*$e,oi=xt[11]*$e,Gt=xt[8]*vt,Qi=xt[9]*vt,si=xt[10]*vt,ai=xt[11]*vt;for(const Gi of at){const Yi=[],Hi=[];for(const $i of Gi){const an=$i.x+Lt.x,mn=$i.y+Lt.y,Sn=xt[0]*an+xt[4]*mn+xt[12],qi=xt[1]*an+xt[5]*mn+xt[13],Rn=xt[2]*an+xt[6]*mn+xt[14],In=xt[3]*an+xt[7]*mn+xt[15],fn=Sn+Nt,Mi=qi+ri,kn=Rn+Ii,Ki=Math.max(In+oi,1e-5),Pr=Sn+Gt,Mn=qi+Qi,Jn=Rn+si,qn=Math.max(In+ai,1e-5);Yi.push(new Uu(fn/Ki,Mi/Ki,kn/Ki)),Hi.push(new Uu(Pr/qn,Mn/qn,Jn/qn))}ni.push(Yi),lt.push(Hi)}return[ni,lt]}(ve,ge,Be,De,qe)}(f,r,L,C,T,m,H,D,U,f.center.lat,t.tileID.canonical),re=t.queryGeometry;return function(fe,ve,ge){let Be=1/0;P0(ge,ve)&&(Be=sx(ge,ve[0]));for(let De=0;De=3){for(let U=0;U{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 LM{constructor(){this.tasks={},this.taskQueue=[],no(["process"],this),this.invoker=new PM(this.process),this.nextId=0}add(e,i){const r=this.nextId++,u=function({type:f,isSymbolTile:m,zoom:y}){return y=y||0,f==="message"?0:f!=="maybePrepare"||m?f!=="parseTile"||m?f==="parseTile"&&m?300-y:f==="maybePrepare"&&m?400-y:500:200-y:100-y}(i);if(u===0){ro();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[r]={fn:e,metadata:i,priority:u,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){ro();try{if(this.taskQueue=this.taskQueue.filter(r=>!!this.tasks[r]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let u=0;u>=1)>1;){const T=i+u>>1,C=r+f>>1;1&e?(u=i,f=r,i=m,r=y):(i=u,r=f,u=m,f=y),m=T,y=C}const E=4*t;Ya[E+0]=i,Ya[E+1]=r,Ya[E+2]=u,Ya[E+3]=f}const Cs=new Uint16Array(2178),Ha=new Uint8Array(1089),yp=new Uint16Array(1089);function Hx(t){return t===0?-.03125:t===32?.03125:0}var Kx=ke([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Jx={type:2,extent:Ft,loadGeometry:()=>[[new Oe(0,0),new Oe(Ft+1,0),new Oe(Ft+1,Ft+1),new Oe(0,Ft+1),new Oe(0,0)]]};class Km{constructor(e,i,r,u,f){this.tileID=e,this.uid=Ni(),this.uses=0,this.tileSize=i,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=f,this.expiredRequestCount=0,this.state="loading",u&&u.transform&&(this.projection=u.transform.projection)}registerFadeDuration(e){const i=e+this.timeAdded;if.getLayer(T)).filter(Boolean);if(E.length!==0){y.layers=E,y.stateDependentLayerIds&&(y.stateDependentLayers=y.stateDependentLayerIds.map(T=>E.filter(C=>C.id===T)[0]));for(const T of E)m[T.id]=y}}return m}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const u in this.buckets){const f=this.buckets[u];if(f instanceof Wa){if(this.hasSymbolBuckets=!0,!r)break;f.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const u in this.buckets){const f=this.buckets[u];if(f instanceof Wa&&f.hasRTLText){this.hasRTLText=!0,M.isLoading()||M.isLoaded()||b()!=="deferred"||I();break}}this.queryPadding=0;for(const u in this.buckets){const f=this.buckets[u];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(u).queryRadius(f))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new ji}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.id]}upload(e){for(const r in this.buckets){const u=this.buckets[r];u.uploadPending()&&u.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new _h(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new _h(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new _h(e,this.lineAtlas.image,i.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,i,r,u,f,m,y,E){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:u,pixelPosMatrix:y,transform:m,params:f,tileTransform:this.tileTransform},e,i,r):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const u=r.loadVTLayers(),f=i?i.sourceLayer:"",m=u._geojsonTileLayer||u[f];if(!m)return;const y=Su(i&&i.filter),{z:E,x:T,y:C}=this.tileID.canonical,L={z:E,x:T,y:C};for(let D=0;Dr)u=!1;else if(i)if(this.expirationTime=0;H--){const ne=4*H,de=Ya[ne+0],re=Ya[ne+1],fe=Ya[ne+2],ve=Ya[ne+3],ge=de+fe>>1,Be=re+ve>>1,De=ge+Be-re,qe=Be+de-ge,it=re*As+de,Ve=ve*As+fe,Ye=Be*As+ge,He=Math.hypot((Cs[2*it+0]+Cs[2*Ve+0])/2-Cs[2*Ye+0],(Cs[2*it+1]+Cs[2*Ve+1])/2-Cs[2*Ye+1])>=16;Ha[Ye]=Ha[Ye]||(He?1:0),H<1022&&(Ha[Ye]=Ha[Ye]||Ha[(re+qe>>1)*As+(de+De>>1)]||Ha[(ve+qe>>1)*As+(fe+De>>1)])}const L=new We,D=new Ot;let B=0;function U(H,ne){const de=ne*As+H;return yp[de]===0&&(L.emplaceBack(Cs[2*de+0],Cs[2*de+1],H*Ft/Po,ne*Ft/Po),yp[de]=++B),yp[de]-1}function G(H,ne,de,re,fe,ve){const ge=H+de>>1,Be=ne+re>>1;if(Math.abs(H-fe)+Math.abs(ne-ve)>1&&Ha[Be*As+ge])G(fe,ve,H,ne,ge,Be),G(de,re,fe,ve,ge,Be);else{const De=U(H,ne),qe=U(de,re),it=U(fe,ve);D.emplaceBack(De,qe,it)}}return G(0,0,Po,Po,Po,0),G(Po,Po,0,0,0,Po),{vertices:L,indices:D}}(this.tileID.canonical,i);u=m.vertices,f=m.indices}else{u=new We,f=new Ot;for(const{x:y,y:E}of r)u.emplaceBack(y,E,0,0);const m=Pm(u.int16,void 0,4);for(let y=0;y0&&(y=om(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,u,i,f,y,m),this._makeGlobeTileDebugTextBuffer(e,u,i,f,y,m)}_globePoint(e,i,r,u,f,m,y){let E=Kc(e,i,r);if(m){const T=1<.5?B=-1:D<-.5&&(B=1);let U=(e/Ft+r.x)/T+B,G=(i/Ft+r.y)/T;U=(U-C)*u._pixelsPerMercatorPixel+C,G=(G-L)*u._pixelsPerMercatorPixel+L;const H=[U*u.worldSize,G*u.worldSize,0];gn(H,H,m),E=zl(E,H,y)}return gn(E,E,f)}_makeGlobeTileDebugBorderBuffer(e,i,r,u,f,m){const y=new tt,E=new Jr,T=new Re,C=(D,B,U,G,H)=>{const ne=(U-D)/(H-1),de=(G-B)/(H-1),re=y.length;for(let fe=0;feL*B+U;for(let B=0;Be[m])return null}else{const y=1/r[m];let E=(t[m]-i[m])*y,T=(e[m]-i[m])*y;if(E>T){const C=E;E=T,T=C}if(E>u&&(u=E),Tf)return null}return u}function t1(t,e,i,r,u,f,m,y,E,T,C){const L=r-t,D=u-e,B=f-i,U=m-t,G=y-e,H=E-i,ne=C[1]*H-C[2]*G,de=C[2]*U-C[0]*H,re=C[0]*G-C[1]*U,fe=L*ne+D*de+B*re;if(Math.abs(fe)<1e-15)return null;const ve=1/fe,ge=T[0]-t,Be=T[1]-e,De=T[2]-i,qe=(ge*ne+Be*de+De*re)*ve;if(qe<0||qe>1)return null;const it=Be*B-De*D,Ve=De*L-ge*B,Ye=ge*D-Be*L,He=(C[0]*it+C[1]*Ve+C[2]*Ye)*ve;return He<0||qe+He>1?null:(U*it+G*Ve+H*Ye)*ve}function i1(t,e,i){return(t-e)/(i-e)}function n1(t,e,i,r,u,f,m,y,E){const T=1<{const de=H?1:0,re=(B+1)*G-de,fe=U*G,ve=(U+1)*G-de;ne[0]=B*G,ne[1]=fe,ne[2]=re,ne[3]=ve};let L=new Qx(E);const D=[];for(let B=0;B=1;E/=2){const B=y[y.length-1];L=new Qx(E);for(let U=0;U0;){const{idx:U,t:G,nodex:H,nodey:ne,depth:de}=B.pop();if(this.leaves[U]){n1(H,ne,de,e,i,r,u,L,D);const fe=1<=$e[2])return G}continue}let re=0;for(let fe=0;fe=T[C[De]]&&(C.splice(De,0,fe),Be=!0);Be||(C[re]=fe),re++}}for(let fe=0;fe=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(e+1)}static pack(e,i){const r=[0,0,0,0],u=vp.getUnpackVector(i);let f=Math.floor((e+u[3])/u[2]);return r[2]=f%256,f=Math.floor(f/256),r[1]=f%256,f=Math.floor(f/256),r[0]=f,r}getPixels(){return new eo({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let u=i*this.dim,f=i*this.dim+this.dim,m=r*this.dim,y=r*this.dim+this.dim;switch(i){case-1:u=f-1;break;case 1:f=u+1}switch(r){case-1:m=y-1;break;case 1:y=m+1}const E=-i*this.dim,T=-r*this.dim;for(let C=m;C{this.remove(e,f)},r)),this.data[u].push(f),this.order.push(u),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}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 i=this.data[e].shift();return i.timeout&&clearTimeout(i.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),i.value}getByKey(e){const i=this.data[e];return i?i[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,i){if(!this.has(e))return this;const r=e.wrapped().key,u=i===void 0?0:this.data[r].indexOf(i),f=this.data[r][u];return this.data[r].splice(u,1),f.timeout&&clearTimeout(f.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(f.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const i=this._getAndRemoveByKey(this.order[0]);i&&this.onRemove(i)}return this}filter(e){const i=[];for(const r in this.data)for(const u of this.data[r])e(u.value)||i.push(u);for(const r of i)this.remove(r.value.tileID,r)}}class Hu{constructor(e,i,r){this.func=e,this.mask=i,this.range=r}}Hu.ReadOnly=!1,Hu.ReadWrite=!0,Hu.disabled=new Hu(519,Hu.ReadOnly,[0,1]);const Jm=7680;class Qm{constructor(e,i,r,u,f,m){this.test=e,this.ref=i,this.mask=r,this.fail=u,this.depthFail=f,this.pass=m}}Qm.disabled=new Qm({func:519,mask:0},0,0,Jm,Jm,Jm);class Ps{constructor(e,i,r){this.blendFunction=e,this.blendColor=i,this.mask=r}}Ps.Replace=[1,0],Ps.disabled=new Ps(Ps.Replace,hn.transparent,[!1,!1,!1,!1]),Ps.unblended=new Ps(Ps.Replace,hn.transparent,[!0,!0,!0,!0]),Ps.alphaBlended=new Ps([1,771],hn.transparent,[!0,!0,!0,!0]);const eg=1029,tg=2305;class rs{constructor(e,i,r){this.enable=e,this.mode=i,this.frontFace=r}}rs.disabled=new rs(!1,eg,tg),rs.backCCW=new rs(!0,eg,tg),rs.backCW=new rs(!0,eg,2304),rs.frontCW=new rs(!0,1028,2304),rs.frontCCW=new rs(!0,1028,tg);class jl extends qr{constructor(e,i,r){super(),this.id=e,this._onlySymbols=r,i.on("data",u=>{u.dataType==="source"&&u.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&u.dataType==="source"&&u.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),i.on("error",()=>{this._sourceErrored=!0}),this._source=i,this._tiles={},this._cache=new NM(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=i.minTileCacheSize,this._maxTileCacheSize=i.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new DM,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 i=this._tiles[e];if(i.state!=="loaded"&&i.state!=="errored")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,i){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,i)}_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 i in this._tiles){const r=this._tiles[i];r.upload(e),r.prepare(this.map.style.imageManager)}}getIds(){return Oi(this._tiles).map(e=>e.tileID).sort(a1).map(e=>e.key)}getRenderableIds(e){const i=[];for(const r in this._tiles)this._isIdRenderable(+r,e)&&i.push(this._tiles[r]);return e?i.sort((r,u)=>{const f=r.tileID,m=u.tileID,y=new Oe(f.canonical.x,f.canonical.y)._rotate(this.transform.angle),E=new Oe(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return f.overscaledZ-m.overscaledZ||E.y-y.y||E.x-y.x}).map(r=>r.tileID.key):i.map(r=>r.tileID).sort(a1).map(r=>r.key)}hasRenderableParent(e){const i=this.findLoadedParent(e,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(e,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(i||!this._tiles[e].holdingForFade())}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,i){const r=this._tiles[e];r&&(r.state!=="loading"&&(r.state=i),this._loadTile(r,this._tileLoaded.bind(this,r,e,i)))}_tileLoaded(e,i,r,u){if(u)if(e.state="errored",u.status!==404)this._source.fire(new xn(u,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const f=this.map.painter.terrain;this.update(this.transform,f.getScaledDemTileSize(),!0),f.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=Or.now(),r==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,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 Fo("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const i=this.getRenderableIds();for(let u=0;u1||(Math.abs(m)>1&&(Math.abs(m+E)===1?m+=E:Math.abs(m-E)===1&&(m-=E)),f.dem&&u.dem&&(u.dem.backfillBorder(f.dem,m,y),u.neighboringTiles&&u.neighboringTiles[T]&&(u.neighboringTiles[T].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,i,r,u){for(const f in this._tiles){let m=this._tiles[f];if(u[f]||!m.hasData()||m.tileID.overscaledZ<=i||m.tileID.overscaledZ>r)continue;let y=m.tileID;for(;m&&m.tileID.overscaledZ>i+1;){const T=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[T.key],m&&m.hasData()&&(y=T)}let E=y;for(;E.overscaledZ>i;)if(E=E.scaledTo(E.overscaledZ-1),e[E.key]){u[y.key]=y;break}}}findLoadedParent(e,i){if(e.key in this._loadedParentTiles){const r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=i?r:null}for(let r=e.overscaledZ-1;r>=i;r--){const u=e.scaledTo(r),f=this._getLoadedTile(u);if(f)return f}}_getLoadedTile(e){const i=this._tiles[e.key];return i&&i.hasData()?i:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,i){i=i||this._source.tileSize;const r=Math.ceil(e.width/i)+1,u=Math.ceil(e.height/i)+1,f=Math.floor(r*u*5),m=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,f):f,y=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,m):m;this._cache.setMaxSize(y)}handleWrapJump(e){const i=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,i){const r={};for(const u in this._tiles){const f=this._tiles[u];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+i),r[f.tileID.key]=f}this._tiles=r;for(const u in this._timers)clearTimeout(this._timers[u]),delete this._timers[u];for(const u in this._tiles)this._setTileReloadTimer(+u,this._tiles[u])}}update(e,i,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!r)return;let u;this.updateCacheSize(e,i),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?u=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(y=>new Cr(y.canonical.z,y.wrap,y.canonical.z,y.canonical.x,y.canonical.y)):(u=e.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(u=u.filter(y=>this._source.hasTile(y)))):u=[];const f=this._updateRetainedTiles(u);if(l1(this._source.type)&&u.length!==0){const y={},E={},T=Object.keys(f);for(const L of T){const D=f[L],B=this._tiles[L];if(!B||B.fadeEndTime&&B.fadeEndTime<=Or.now())continue;const U=this.findLoadedParent(D,Math.max(D.overscaledZ-jl.maxOverzooming,this._source.minzoom));U&&(this._addTile(U.tileID),y[U.tileID.key]=U.tileID),E[L]=D}const C=u[u.length-1].overscaledZ;for(const L in this._tiles){const D=this._tiles[L];if(f[L]||!D.hasData())continue;let B=D.tileID;for(;B.overscaledZ>C;){B=B.scaledTo(B.overscaledZ-1);const U=this._tiles[B.key];if(U&&U.hasData()&&E[B.key]){f[L]=D.tileID;break}}}for(const L in y)f[L]||(this._coveredTiles[L]=!0,f[L]=y[L])}for(const y in f)this._tiles[y].clearFadeHold();const m=function(y,E){const T=[];for(const C in y)C in E||T.push(C);return T}(this._tiles,f);for(const y of m){const E=this._tiles[y];E.hasSymbolBuckets&&!E.holdingForFade()?E.setHoldDuration(this.map._fadeDuration):E.hasSymbolBuckets&&!E.symbolFadeFinished()||this._removeTile(+y)}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 i={};if(e.length===0)return i;const r={},u=e.reduce((T,C)=>Math.min(T,C.overscaledZ),1/0),f=e[0].overscaledZ,m=Math.max(f-jl.maxOverzooming,this._source.minzoom),y=Math.max(f+jl.maxUnderzooming,this._source.minzoom),E={};for(const T of e){const C=this._addTile(T);i[T.key]=T,C.hasData()||u=this._source.maxzoom){const D=T.children(this._source.maxzoom)[0],B=this.getTile(D);if(B&&B.hasData()){i[D.key]=D;continue}}else{const D=T.children(this._source.maxzoom);if(i[D[0].key]&&i[D[1].key]&&i[D[2].key]&&i[D[3].key])continue}let L=C.wasRequested();for(let D=T.overscaledZ-1;D>=m;--D){const B=T.scaledTo(D);if(r[B.key]||(r[B.key]=!0,C=this.getTile(B),!C&&L&&(C=this._addTile(B)),C&&(i[B.key]=B,L=C.wasRequested(),C.hasData())))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const i=[];let r,u=this._tiles[e].tileID;for(;u.overscaledZ>0;){if(u.key in this._loadedParentTiles){r=this._loadedParentTiles[u.key];break}i.push(u.key);const f=u.scaledTo(u.overscaledZ-1);if(r=this._getLoadedTile(f),r)break;u=f}for(const f of i)this._loadedParentTiles[f]=r}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=!!i;if(!r){const u=this.map?this.map.painter:null;i=new Km(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,u,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))}return i?(i.uses++,this._tiles[e.key]=i,r||this._source.fire(new Fo("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_setTileReloadTimer(e,i){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const r=i.getExpiryTimeout();r&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},r))}_removeTile(e){const i=this._tiles[e];i&&(i.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),i.uses>0||(i.hasData()&&i.state!=="reloading"?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}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,i,r){const u=[],f=this.transform;if(!f)return u;const m=f.projection.name==="globe",y=ks(f.center.lng);for(const E in this._tiles){const T=this._tiles[E];if(r&&T.clearQueryDebugViz(),T.holdingForFade())continue;let C;if(m){const L=T.tileID.canonical;if(L.z===0){const D=[Math.abs(Rt(y,...yh(L,-1))-y),Math.abs(Rt(y,...yh(L,1))-y)];C=[0,2*D.indexOf(Math.min(...D))-1]}else{const D=[Math.abs(Rt(y,...yh(L,-1))-y),Math.abs(Rt(y,...yh(L,0))-y),Math.abs(Rt(y,...yh(L,1))-y)];C=[D.indexOf(Math.min(...D))-1]}}else C=[0];for(const L of C){const D=e.containsTile(T,f,i,L);D&&u.push(D)}}return u}getVisibleCoordinates(e){const i=this.getRenderableIds(e).map(r=>this._tiles[r].tileID);for(const r of i)r.projMatrix=this.transform.calculateProjMatrix(r.toUnwrapped());return i}hasTransition(){if(this._source.hasTransition())return!0;if(l1(this._source.type))for(const e in this._tiles){const i=this._tiles[e];if(i.fadeEndTime!==void 0&&i.fadeEndTime>=Or.now())return!0}return!1}setFeatureState(e,i,r){this._state.updateState(e=e||"_geojsonTileLayer",i,r)}removeFeatureState(e,i,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",i,r)}getFeatureState(e,i){return this._state.getState(e=e||"_geojsonTileLayer",i)}setDependencies(e,i,r){const u=this._tiles[e];u&&u.setDependencies(i,r)}reloadTilesForDependencies(e,i){for(const r in this._tiles)this._tiles[r].hasDependency(e,i)&&this._reloadTile(+r,"reloading");this._cache.filter(r=>!r.hasDependency(e,i))}_preloadTiles(e,i){if(!this._sourceLoaded){const y=()=>{this._sourceLoaded&&(this._source.off("data",y),this._preloadTiles(e,i))};return void this._source.on("data",y)}const r=new Map,u=Array.isArray(e)?e:[e],f=this.map.painter.terrain,m=this.usedForTerrain&&f?f.getScaledDemTileSize():this._source.tileSize;for(const y of u){const E=y.coveringTiles({tileSize:m,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const T of E)r.set(T.key,T);this.usedForTerrain&&y.updateElevation(!1)}wi(Array.from(r.values()),(y,E)=>{const T=new Km(y,this._source.tileSize*y.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(T,C=>{this._source.type==="raster-dem"&&T.dem&&this._backfillDEM(T),E(C,T)})},i)}}function a1(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function l1(t){return t==="raster"||t==="image"||t==="video"||t==="custom"}function yh(t,e){const i=1<=0&&L[3]>=0&&E.insert(y,L[0],L[1],L[2],L[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Om(new sp(this.rawTileData)).layers,this.sourceLayerCoder=new Wx(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i,r,u){this.loadVTLayers();const f=e.params||{},m=Su(f.filter),y=e.tileResult,E=e.transform,T=y.bufferedTilespaceBounds,C=this.grid.query(T.min.x,T.min.y,T.max.x,T.max.y,(U,G,H,ne)=>D0(y.bufferedTilespaceGeometry,U,G,H,ne));C.sort(BM);let L=null;E.elevation&&C.length>0&&(L=xp.create(E.elevation,this.tileID));const D={};let B;for(let U=0;U(ne||(ne=oa(de,this.tileID.canonical,e.tileTransform)),re.queryIntersectsFeature(y,de,fe,ne,this.z,e.transform,e.pixelPosMatrix,L,ve)))}return D}loadMatchingFeature(e,i,r,u,f,m,y,E,T){const{featureIndex:C,bucketIndex:L,sourceLayerIndex:D,layoutVertexArrayOffset:B}=i,U=this.bucketLayerIDs[L];if(u&&!function(de,re){for(let fe=0;fe=0)return!0;return!1}(u,U))return;const G=this.sourceLayerCoder.decode(D),H=this.vtLayers[G].feature(C);if(r.needGeometry){const de=Nl(H,!0);if(!r.filter(new P(this.tileID.overscaledZ),de,this.tileID.canonical))return}else if(!r.filter(new P(this.tileID.overscaledZ),H))return;const ne=this.getId(H,G);for(let de=0;de{const y=e instanceof ie?e.get(m):null;return y&&y.evaluate?y.evaluate(i,r,u):y})}function BM(t,e){return e-t}Ct(u1,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class h1{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new sa({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){const r=this.getKey(e,i);return this.positions[r]}trim(){const e=this.width,i=this.height=vn(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,r){const u=[];let f=e.length%2==1?-e[e.length-1]*r:0,m=e[0]*r,y=!0;u.push({left:f,right:m,isDash:y,zeroLength:e[0]===0});let E=e[0];for(let T=1;T1&&(E=e[++y]);const C=Math.abs(T-E.left),L=Math.abs(T-E.right),D=Math.min(C,L);let B;const U=f/r*(u+1);if(E.isDash){const G=u-Math.abs(U);B=Math.sqrt(D*D+G*G)}else B=u-Math.sqrt(D*D+U*U);this.image.data[m+T]=Math.max(0,Math.min(255,B+128))}}}addRegularDash(e,i){for(let E=e.length-1;E>=0;--E){const T=e[E],C=e[E+1];T.zeroLength?e.splice(E,1):C&&C.isDash===T.isDash&&(C.left=T.left,e.splice(E,1))}const r=e[0],u=e[e.length-1];r.isDash===u.isDash&&(r.left=u.left-this.width,u.right=r.right+this.width);const f=this.width*this.nextRow;let m=0,y=e[m];for(let E=0;E1&&(y=e[++m]);const T=Math.abs(E-y.left),C=Math.abs(E-y.right),L=Math.min(T,C);this.image.data[f+E]=Math.max(0,Math.min(255,(y.isDash?L:-L)+i+128))}}addDash(e,i){const r=this.getKey(e,i);if(this.positions[r])return this.positions[r];const u=i==="round",f=u?7:0,m=2*f+1;if(this.nextRow+m>this.height)return Ti("LineAtlas out of space"),null;e.length===0&&e.push(1);let y=0;for(let C=0;C=Ye.maxzoom||Ye.visibility!=="none"&&(ig(Ve,this.zoom,r),(E[Ye.id]=Ye.createBucket({index:y.bucketLayerIDs.length,layers:Ve,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:qe,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:r})).populate(it,C,this.tileID.canonical,this.tileTransform),y.bucketLayerIDs.push(Ve.map(He=>He.id)))}}let D,B,U,G;T.trim();const H={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},ne=()=>{if(D)return f(D);if(B&&U&&G){const ve=new p1(B),ge=new xx(U,G);for(const Be in E){const De=E[Be];De instanceof Wa?(ig(De.layers,this.zoom,r),hM(De,B,ve.positions,U,ge.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection)):De.hasPattern&&(De instanceof np||De instanceof Jf||De instanceof sh)&&(ig(De.layers,this.zoom,r),De.addFeatures(C,this.tileID.canonical,ge.patternPositions,r,this.tileTransform))}this.status="done",f(null,{buckets:Oi(E).filter(Be=>!Be.isEmpty()),featureIndex:y,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ve.image,lineAtlas:T,imageAtlas:ge,glyphMap:this.returnDependencies?B:null,iconMap:this.returnDependencies?U:null,glyphPositions:this.returnDependencies?ve.positions:null})}},de=ft(C.glyphDependencies,ve=>Object.keys(ve).map(Number));Object.keys(de).length?u.send("getGlyphs",{uid:this.uid,stacks:de},(ve,ge)=>{D||(D=ve,B=ge,ne())},void 0,!1,H):B={};const re=Object.keys(C.iconDependencies);re.length?u.send("getImages",{icons:re,source:this.source,tileID:this.tileID,type:"icons"},(ve,ge)=>{D||(D=ve,U=ge,ne())},void 0,!1,H):U={};const fe=Object.keys(C.patternDependencies);fe.length?u.send("getImages",{icons:fe,source:this.source,tileID:this.tileID,type:"patterns"},(ve,ge)=>{D||(D=ve,G=ge,ne())},void 0,!1,H):G={},ne()}}function ig(t,e,i){const r=new P(e);for(const u of t)u.recalculate(r,i)}class d1{constructor(e){this.entries={},this.scheduler=e}request(e,i,r,u){const f=this.entries[e]=this.entries[e]||{callbacks:[]};if(f.result){const[m,y]=f.result;return this.scheduler?this.scheduler.add(()=>{u(m,y)},i):u(m,y),()=>{}}return f.callbacks.push(u),f.cancel||(f.cancel=r((m,y)=>{f.result=[m,y];for(const E of f.callbacks)this.scheduler?this.scheduler.add(()=>{E(m,y)},i):E(m,y);setTimeout(()=>delete this.entries[e],3e3)})),()=>{f.result||(f.callbacks=f.callbacks.filter(m=>m!==u),f.callbacks.length||(f.cancel(),delete this.entries[e]))}}}function m1(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},u=>{const f=ms(t.request,(m,y,E,T)=>{m?u(m):y&&u(null,{vectorTile:i?void 0:new Om(new sp(y)),rawData:y,cacheControl:E,expires:T})});return()=>{f.cancel(),u()}},e)}const g1=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ng{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,r]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const u=r>>4;if(u!==1)throw new Error(`Got v${u} data when expected v1.`);const f=g1[15&r];if(!f)throw new Error("Unrecognized array type.");const[m]=new Uint16Array(e,2,1),[y]=new Uint32Array(e,4,1);return new ng(y,m,f,e)}constructor(e,i=64,r=Float64Array,u){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const f=g1.indexOf(this.ArrayType),m=2*e*this.ArrayType.BYTES_PER_ELEMENT,y=e*this.IndexArrayType.BYTES_PER_ELEMENT,E=(8-y%8)%8;if(f<0)throw new Error(`Unexpected typed array class: ${r}.`);u&&u instanceof ArrayBuffer?(this.data=u,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+E,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+m+y+E),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+E,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+f]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=i,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return rg(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,r,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:f,coords:m,nodeSize:y}=this,E=[0,f.length-1,0],T=[];for(;E.length;){const C=E.pop()||0,L=E.pop()||0,D=E.pop()||0;if(L-D<=y){for(let H=D;H<=L;H++){const ne=m[2*H],de=m[2*H+1];ne>=e&&ne<=r&&de>=i&&de<=u&&T.push(f[H])}continue}const B=D+L>>1,U=m[2*B],G=m[2*B+1];U>=e&&U<=r&&G>=i&&G<=u&&T.push(f[B]),(C===0?e<=U:i<=G)&&(E.push(D),E.push(B-1),E.push(1-C)),(C===0?r>=U:u>=G)&&(E.push(B+1),E.push(L),E.push(1-C))}return T}within(e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:u,coords:f,nodeSize:m}=this,y=[0,u.length-1,0],E=[],T=r*r;for(;y.length;){const C=y.pop()||0,L=y.pop()||0,D=y.pop()||0;if(L-D<=m){for(let H=D;H<=L;H++)y1(f[2*H],f[2*H+1],e,i)<=T&&E.push(u[H]);continue}const B=D+L>>1,U=f[2*B],G=f[2*B+1];y1(U,G,e,i)<=T&&E.push(u[B]),(C===0?e-r<=U:i-r<=G)&&(y.push(D),y.push(B-1),y.push(1-C)),(C===0?e+r>=U:i+r>=G)&&(y.push(B+1),y.push(L),y.push(1-C))}return E}}function rg(t,e,i,r,u,f){if(u-r<=i)return;const m=r+u>>1;_1(t,e,m,r,u,f),rg(t,e,i,r,m-1,1-f),rg(t,e,i,m+1,u,1-f)}function _1(t,e,i,r,u,f){for(;u>r;){if(u-r>600){const T=u-r+1,C=i-r+1,L=Math.log(T),D=.5*Math.exp(2*L/3),B=.5*Math.sqrt(L*D*(T-D)/T)*(C-T/2<0?-1:1);_1(t,e,i,Math.max(r,Math.floor(i-C*D/T+B)),Math.min(u,Math.floor(i+(T-C)*D/T+B)),f)}const m=e[2*i+f];let y=r,E=u;for(vh(t,e,r,i),e[2*u+f]>m&&vh(t,e,r,u);ym;)E--}e[2*r+f]===m?vh(t,e,r,E):(E++,vh(t,e,E,u)),E<=i&&(r=E+1),i<=E&&(u=E-1)}}function vh(t,e,i,r){og(t,i,r),og(e,2*i,2*r),og(e,2*i+1,2*r+1)}function og(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function y1(t,e,i,r){const u=t-i,f=e-r;return u*u+f*f}s.ARRAY_TYPE=Qr,s.AUTH_ERR_MSG=_e,s.Aabb=Ar,s.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},no(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ro()?t:Z,this.scheduler=new LM}send(t,e,i,r,u=!1,f){const m=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=f,this.callbacks[m]=i);const y=Do(this.globalScope)?void 0:[];return this.target.postMessage({id:m,type:t,hasCallback:!!i,targetMapId:r,mustQueue:u,sourceMapId:this.mapId,data:Ua(e,y)},y),{cancel:()=>{i&&delete this.callbacks[m],this.target.postMessage({id:m,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type===""){const r=this.cancelCallbacks[i];delete this.cancelCallbacks[i],r&&r.cancel()}else if(e.mustQueue||ro()){const r=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,e),r&&r.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(e.type===""){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Qs(e.error)):i(null,Qs(e.data)))}else{const i=Do(this.globalScope)?void 0:[],r=e.hasCallback?(f,m)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:f?Ua(f):null,data:Ua(m,i)},i)}:f=>{},u=Qs(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,u,r);else if(this.parent.getWorkerSource){const f=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,f[0],u.source)[f[1]](u,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.CanonicalTileID=ip,s.Color=hn,s.ColorMode=Ps,s.CullFaceMode=rs,s.DEMData=vp,s.DataConstantProperty=V,s.DedupedRequest=d1,s.DepthMode=Hu,s.EXTENT=Ft,s.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<1)return e;const u=r.getSource().maxzoom,f=1<{const f=this.getAtTileOffset(t,u.x,u.y),m=r.upVector(t.canonical,u.x,u.y);return fo(m,m,f*r.upVectorScale(t.canonical,e,i).metersToTile),m}}getForTilePoints(t,e,i,r){if(this.isUsingMockSource())return!1;const u=xp.create(this,t,r);return!!u&&(e.forEach(f=>{f[2]=this.exaggeration()*u.getElevationAt(f[0],f[1],i)}),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,u=1<{let D=T===f-1?T-2:T===0?T:T-1;return D+=L?24575:0,[D,C]};for(let T=0;Tthis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!Se(t))return t;const i=ht(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Se(t))return t;const i=ht(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,r){if(!Se(t))return t;const u=ht(t);return u.path=`/v4/${u.authority}.json`,u.params.push("secure"),i&&u.params.push(`language=${i}`),r&&u.params.push(`worldview=${r}`),this._makeAPIURL(u,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const u=ht(t);return Se(t)?(u.path=`/styles/v1${u.path}/sprite${e}${i}`,this._makeAPIURL(u,this._customAccessToken||r)):(u.path+=`${e}${i}`,nt(u))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Se(t))return t;const r=ht(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&r.authority!=="raster"&&i===512?"@2x":""}${we.supported?".webp":"$1"}`),r.authority==="raster"?r.path=`/${he.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${he.TILE_URL_VERSION}${r.path}`);const u=this._customAccessToken||function(f){for(const m of f){const y=m.match(/^access_token=(.*)$/);if(y)return y[1]}return null}(r.params)||he.ACCESS_TOKEN;return he.REQUIRE_ACCESS_TOKEN&&u&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,u)}canonicalizeTileURL(t,e){const i=ht(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${he.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${he.TILE_URL_VERSION}/`,"")}`;let u=i.params;return e&&(u=u.filter(f=>!f.match(/^access_token=/))),u.length&&(r+=`?${u.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&Se(e),r=[];for(const u of t.tiles||[])Pe(u)?r.push(this.canonicalizeTileURL(u,i)):r.push(u);return r}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=ht(he.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,t.protocol==="http"){const u=t.params.indexOf("secure");u>=0&&t.params.splice(u,1)}if(r.path!=="/"&&(t.path=`${r.path}${t.path}`),!he.REQUIRE_ACCESS_TOKEN)return nt(t);if(e=e||he.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter(u=>u.indexOf("access_token")===-1),t.params.push(`access_token=${e||""}`),nt(t)}},s.ResourceType=Wn,s.SegmentVector=En,s.SourceCache=jl,s.StencilMode=Qm,s.StructArrayLayout1ui2=Jr,s.StructArrayLayout2f1f2i16=jt,s.StructArrayLayout2i4=tt,s.StructArrayLayout2ui4=$n,s.StructArrayLayout3f12=di,s.StructArrayLayout3ui6=Ot,s.StructArrayLayout4i8=We,s.StructArrayLayout5f20=Ui,s.Texture=_h,s.Tile=Km,s.Transitionable=j,s.Uniform1f=Ff,s.Uniform1i=class extends ia{constructor(t){super(t),this.current=0}set(t,e,i){this.fetchUniformLocation(t,e)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},s.Uniform2f=class extends ia{constructor(t){super(t),this.current=[0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}},s.Uniform3f=class extends ia{constructor(t){super(t),this.current=[0,0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(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])))}},s.Uniform4f=Jv,s.UniformColor=Qv,s.UniformMatrix2f=class extends ia{constructor(t){super(t),this.current=gI}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}},s.UniformMatrix3f=class extends ia{constructor(t){super(t),this.current=mI}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}},s.UniformMatrix4f=class extends ia{constructor(t){super(t),this.current=dI}set(t,e,i){if(this.fetchUniformLocation(t,e)){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 r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}},s.UnwrappedTileID=ox,s.ValidationError=kt,s.VectorTileFeature=ep,s.VectorTileWorkerSource=class extends qr{constructor(t,e,i,r,u){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=u||m1,this.loading={},this.loaded={},this.deduped=new d1(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,u=r&&r.collectResourceTiming,f=this.loading[i]=new FM(t);f.abort=this.loadVectorData(t,(m,y)=>{const E=!this.loading[i];if(delete this.loading[i],E||m||!y)return f.status="done",E||(this.loaded[i]=f),e(m);const T=y.rawData,C={};y.expires&&(C.expires=y.expires),y.cacheControl&&(C.cacheControl=y.cacheControl),f.vectorTile=y.vectorTile||new Om(new sp(T));const L=()=>{f.parse(f.vectorTile,this.layerIndex,this.availableImages,this.actor,(D,B)=>{if(D||!B)return e(D);const U={};if(u){const G=dn(r);G.length>0&&(U.resourceTiming=JSON.parse(JSON.stringify(G)))}e(null,Wt({rawTileData:T.slice(0)},B,C,U))})};this.isSpriteLoaded?L():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(L,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):L()}),this.loaded=this.loaded||{},this.loaded[i]=f})}reloadTile(t,e){const i=this.loaded,r=t.uid,u=this;if(i&&i[r]){const f=i[r];f.showCollisionBoxes=t.showCollisionBoxes,f.enableTerrain=!!t.enableTerrain,f.projection=t.projection,f.tileTransform=Ul(t.tileID.canonical,t.projection);const m=(y,E)=>{const T=f.reloadCallback;T&&(delete f.reloadCallback,f.parse(f.vectorTile,u.layerIndex,this.availableImages,u.actor,T)),e(y,E)};f.status==="parsing"?f.reloadCallback=m:f.status==="done"&&(f.vectorTile?f.parse(f.vectorTile,this.layerIndex,this.availableImages,this.actor,m):m())}}abortTile(t,e){const i=t.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}},s.WritingMode=mo,s.ZoomDependentExpression=wl,s.add=ra,s.addDynamicAttributes=gp,s.adjoint=function(t,e){var i=e[0],r=e[1],u=e[2],f=e[3],m=e[4],y=e[5],E=e[6],T=e[7],C=e[8];return t[0]=m*C-y*T,t[1]=u*T-r*C,t[2]=r*y-u*m,t[3]=y*E-f*C,t[4]=i*C-u*E,t[5]=u*f-i*y,t[6]=f*T-m*E,t[7]=r*E-i*T,t[8]=i*m-r*f,t},s.asyncAll=wi,s.bezier=Bt,s.bindAll=no,s.boundsAttributes=Kx,s.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;rOo&&(t.getActor().send("enforceCacheSizeLimit",bo),zs=0)},s.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:r}=t.point,u=w0(i,r,t.worldSize/t._pixelsPerMercatorPixel,0,0);return Ll(u,u,gm(Is(e)))},s.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:r,lat:u}=t._center;return w0(e,i,t.worldSize,r,u)},s.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,i=e/ts(1,t.center.lat),r=Qo(new Float64Array(16));return Gc(r,r,[t.point.x,t.point.y,0]),Rl(r,r,[i,i,e]),Float32Array.from(r)},s.circumferenceAtLatitude=ym,s.clamp=Rt,s.clearTileCache=function(t){if(!zo())return;const e=Z.caches.delete(ii);t&&e.catch(t).then(()=>t())},s.clipLine=Rx,s.clone=function(t){var e=new Qr(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},s.clone$1=rn,s.collisionCircleLayout=Nk,s.config=he,s.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},s.create=function(){var t=new Qr(16);return Qr!=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},s.create$1=i0,s.createExpression=Na,s.createLayout=ke,s.createStyleLayer=function(t){return t.type==="custom"?new MM(t):new CM[t.type](t)},s.cross=um,s.degToRad=At,s.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},s.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},s.dot=Mo,s.earthRadius=Qc,s.ease=Ri,s.easeCubicInOut=Jt,s.ecefToLatLng=function([t,e,i]){const r=Math.hypot(t,e,i),u=Math.atan2(t,i),f=.5*Math.PI-Math.acos(-e/r);return new Vi(Xt(u),Xt(f))},s.emitValidationErrors=Rf,s.endsWith=Ci,s.enforceCacheSizeLimit=function(t){_i(),tr&&tr.then(e=>{e.keys().then(i=>{for(let r=0;rf&&(r+=(t[u]-f)*(t[u]-f)),e[u]0){const U=180/r;n0(B,B,[U/T+1,0,0,0,U/C+1,0,-.5*U/L,.5*U/D,1])}return B[2]=E,B[5]=t.x,B[8]=t.y,B},s.getImage=ue,s.getJSON=function(t,e){return No(Wt(t,{type:"json"}),e)},s.getLatitudinalLod=function(t){const e=hr-5;t=Rt(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(At(t))),3);return Math.round(i*(Hc.length-1))},s.getMapSessionAPI=cn,s.getPerformanceMeasurement=dn,s.getProjection=Zx,s.getRTLTextPluginStatus=b,s.getReferrer=qt,s.getTilePoint=function(t,{x:e,y:i},r=0){return new Oe(((e-r)*t.scale-t.x)*Ft,(i*t.scale-t.y)*Ft)},s.getTileVec3=function(t,e,i=0){return Lu(((e.x-i)*t.scale-t.x)*Ft,(e.y*t.scale-t.y)*Ft,I0(e.z,e.y))},s.getVideo=function(t,e){const i=Z.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let r=0;r{}}},s.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=Qo(new Float64Array(16));return Ll(i,t.pixelMatrix,t.globeMatrix),gn(e,e,i),new Oe(e[0],e[1])},s.globeDenormalizeECEF=gm,s.globeECEFOrigin=function(t,e){const i=[0,0,0];return gn(i,i,Jc(Is(e.canonical))),gn(i,i,t),i},s.globeMetersToEcef=Vf,s.globeNormalizeECEF=Jc,s.globePixelsToTileUnits=function(t,e){return Ft/(512*Math.pow(2,t))*$f(Is(e))},s.globePoleMatrixForTile=function(t,e,i){const r=Qo(new Float64Array(16)),u=(e/(1<0;return r===0&&!u&&!m&&f},s.identity=Qo,s.identity$1=f0,s.invert=om,s.isFullscreen=function(){return!!Z.document.fullscreenElement||!!Z.document.webkitFullscreenElement},s.isLngLatBehindGlobe=_m,s.isMapAuthenticated=function(t){return pn.has(t)},s.isMapboxURL=Se,s.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!Do(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},s.latFromMercatorY=cr,s.latLngToECEF=Du,s.len=SI,s.length=$c,s.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},s.lngFromMercatorX=po,s.loadVectorTile=m1,s.makeRequest=No,s.mapValue=function(t,e,i,r,u){return Rt((t-e)/(i-e)*(u-r)+r,r,u)},s.mercatorScale=k0,s.mercatorXfromLng=ks,s.mercatorYfromLat=Ms,s.mercatorZfromAltitude=ts,s.mul=EI,s.mul$1=TI,s.multiply=Ll,s.multiply$1=n0,s.multiply$2=a0,s.nextPowerOfTwo=vn,s.normalize=Mr,s.normalize$1=II,s.normalize$2=c0,s.number=bi,s.ortho=function(t,e,i,r,u,f,m){var y=1/(e-i),E=1/(r-u),T=1/(f-m);return t[0]=-2*y,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*E,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*T,t[11]=0,t[12]=(e+i)*y,t[13]=(u+r)*E,t[14]=(m+f)*T,t[15]=1,t},s.pbf=fx,s.perspective=function(t,e,i,r,u){var f,m=1/Math.tan(e/2);return t[0]=m/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=m,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,u!=null&&u!==1/0?(t[10]=(u+r)*(f=1/(r-u)),t[14]=2*u*r*f):(t[10]=-1,t[14]=-2*r),t},s.pick=function(t,e){const i={};for(let r=0;r0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!_m(t,new Vi(t.center.lat,90)),r[0]>0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!_m(t,new Vi(t.center.lat,-90))]},s.polygonContainsPoint=Bl,s.polygonIntersectsBox=D0,s.polygonIntersectsPolygon=C0,s.polygonizeBounds=function(t,e,i=0,r=!0){const u=new Oe(i,i),f=t.sub(u),m=e.add(u),y=[f,new Oe(m.x,f.y),m,new Oe(f.x,m.y)];return r&&y.push(f.clone()),y},s.posAttributes=Yc,s.postMapLoadEvent=un,s.postPerformanceEvent=Pi,s.postTurnstileEvent=hi,s.potpack=Fm,s.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},s.radToDeg=Xt,s.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],s.registerForPluginStateChange=function(t){return t({pluginStatus:h,pluginURL:n}),_.on("pluginStateChange",t),t},s.removeAuthState=function(t){pn.delete(t)},s.renderColorRamp=Im,s.resample=M0,s.rotateX=sm,s.rotateX$1=p0,s.rotateY=jf,s.rotateY$1=d0,s.rotateZ=function(t,e,i){var r=Math.sin(i),u=Math.cos(i),f=e[0],m=e[1],y=e[2],E=e[3],T=e[4],C=e[5],L=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]=f*u+T*r,t[1]=m*u+C*r,t[2]=y*u+L*r,t[3]=E*u+D*r,t[4]=T*u-f*r,t[5]=C*u-m*r,t[6]=L*u-y*r,t[7]=D*u-E*r,t},s.rotateZ$1=function(t,e,i){i*=.5;var r=e[0],u=e[1],f=e[2],m=e[3],y=Math.sin(i),E=Math.cos(i);return t[0]=r*E+u*y,t[1]=u*E-r*y,t[2]=f*E+m*y,t[3]=m*E-f*y,t},s.scale=Rl,s.scale$1=u0,s.scale$2=fo,s.scaleAndAdd=Xc,s.set=function(t,e,i,r){return t[0]=e,t[1]=i,t[2]=r,t},s.setCacheLimits=function(t,e){bo=t,Oo=e},s.setColumn=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},s.setRTLTextPlugin=function(t,e,i=!1){if(h===Bc||h===Fc||h===Uc)throw new Error("setRTLTextPlugin cannot be called multiple times.");n=Or.resolveURL(t),h=Bc,ja=e,p(),i||I()},s.smoothstep=pi,s.spec=Ge,s.squaredLength=function(t){var e=t[0],i=t[1],r=t[2];return e*e+i*i+r*r},s.storeAuthState=function(t,e){e?pn.add(t):pn.delete(t)},s.sub=es,s.subtract=lm,s.symbolSize=Bk,s.tileAABB=function(t,e,i,r,u,f,m,y,E){if(E.name==="globe")return PI(t,e,new ip(i,r,u));const T=Ul({z:i,x:r,y:u},E);return new Ar([(f+T.x/T.scale)*e,e*(T.y/T.scale),m],[(f+T.x2/T.scale)*e,e*(T.y2/T.scale),y])},s.tileCornersToBounds=Gf,s.tileTransform=Ul,s.transformMat3=function(t,e,i){var r=e[0],u=e[1],f=e[2];return t[0]=r*i[0]+u*i[3]+f*i[6],t[1]=r*i[1]+u*i[4]+f*i[7],t[2]=r*i[2]+u*i[5]+f*i[8],t},s.transformMat4=gn,s.transformMat4$1=Dl,s.transformQuat=l0,s.transitionTileAABBinECEF=v0,s.translate=Gc,s.transpose=function(t,e){if(t===e){var i=e[1],r=e[2],u=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=r,t[7]=u}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},s.triggerPluginCompletionEvent=a,s.uniqueId=Ni,s.updateGlobeVertexNormal=function(t,e,i,r,u){const f=5*e+2;t.float32[f+0]=i,t.float32[f+1]=r,t.float32[f+2]=u},s.validateCustomStyleLayer=function(t){const e=[],i=t.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),t.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&t.renderingMode!=="2d"&&t.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},s.validateFilter=t=>Kr(kl(t)),s.validateFog=t=>Kr(Cf(t)),s.validateLayer=t=>Kr(If(t)),s.validateLight=t=>Kr(Af(t)),s.validateSource=t=>Kr(Mf(t)),s.validateStyle=Lf,s.validateTerrain=t=>Kr(Rc(t)),s.values=Oi,s.vectorTile=Qf,s.version=oe,s.warnOnce=Ti,s.window=Z,s.wrap=St}),O(["./shared"],function(s){function Z(ce){if(typeof ce=="number"||typeof ce=="boolean"||typeof ce=="string"||ce==null)return JSON.stringify(ce);if(Array.isArray(ce)){let W="[";for(const ue of ce)W+=`${Z(ue)},`;return`${W}]`}let X="{";for(const W of Object.keys(ce).sort())X+=`${W}:${Z(ce[W])},`;return`${X}}`}function oe(ce){let X="";for(const W of s.refProperties)X+=`/${Z(ce[W])}`;return X}class pe{constructor(X){this.keyCache={},X&&this.replace(X)}replace(X){this._layerConfigs={},this._layers={},this.update(X,[])}update(X,W){for(const _e of X)this._layerConfigs[_e.id]=_e,(this._layers[_e.id]=s.createStyleLayer(_e)).compileFilter(),this.keyCache[_e.id]&&delete this.keyCache[_e.id];for(const _e of W)delete this.keyCache[_e],delete this._layerConfigs[_e],delete this._layers[_e];this.familiesBySource={};const ue=function(_e,Se){const Pe={};for(let se=0;se<_e.length;se++){const Ue=Se&&Se[_e[se].id]||oe(_e[se]);Se&&(Se[_e[se].id]=Ue);let ot=Pe[Ue];ot||(ot=Pe[Ue]=[]),ot.push(_e[se])}const Ce=[];for(const se in Pe)Ce.push(Pe[se]);return Ce}(s.values(this._layerConfigs),this.keyCache);for(const _e of ue){const Se=_e.map(ht=>this._layers[ht.id]),Pe=Se[0];if(Pe.visibility==="none")continue;const Ce=Pe.source||"";let se=this.familiesBySource[Ce];se||(se=this.familiesBySource[Ce]={});const Ue=Pe.sourceLayer||"_geojsonTileLayer";let ot=se[Ue];ot||(ot=se[Ue]=[]),ot.push(Se)}}}class he{loadTile(X,W){const{uid:ue,encoding:_e,rawImageData:Se,padding:Pe,buildQuadTree:Ce}=X,se=s.window.ImageBitmap&&Se instanceof s.window.ImageBitmap?this.getImageData(Se,Pe):Se;W(null,new s.DEMData(ue,se,_e,Pe<1,Ce))}getImageData(X,W){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(X.width,X.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=X.width,this.offscreenCanvas.height=X.height,this.offscreenCanvasContext.drawImage(X,0,0,X.width,X.height);const ue=this.offscreenCanvasContext.getImageData(-W,-W,X.width+2*W,X.height+2*W);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ue}}function we(ce,X){if(ce.length!==0){ye(ce[0],X);for(var W=1;W=Math.abs(Ce)?W-se+Ce:Ce-se+W,W=se}W+ue>=0!=!!X&&ce.reverse()}var Ie=s.getDefaultExportFromCjs(function ce(X,W){var ue,_e=X&&X.type;if(_e==="FeatureCollection")for(ue=0;ue>31}function bt(ce,X){for(var W=ce.loadGeometry(),ue=ce.type,_e=0,Se=0,Pe=W.length,Ce=0;Cece},Rt=Math.fround||(pi=new Float32Array(1),ce=>(pi[0]=+ce,pi[0]));var pi;const St=3,wi=5,Oi=6;class Wt{constructor(X){this.options=Object.assign(Object.create(Ri),X),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(X){const{log:W,minZoom:ue,maxZoom:_e}=this.options;W&&console.time("total time");const Se=`prepare ${X.length} points`;W&&console.time(Se),this.points=X;const Pe=[];for(let se=0;se=ue;se--){const Ue=+Date.now();Ce=this.trees[se]=this._createTree(this._cluster(Ce,se)),W&&console.log("z%d: %d clusters in %dms",se,Ce.numItems,+Date.now()-Ue)}return W&&console.timeEnd("total time"),this}getClusters(X,W){let ue=((X[0]+180)%360+360)%360-180;const _e=Math.max(-90,Math.min(90,X[1]));let Se=X[2]===180?180:((X[2]+180)%360+360)%360-180;const Pe=Math.max(-90,Math.min(90,X[3]));if(X[2]-X[0]>=360)ue=-180,Se=180;else if(ue>Se){const ht=this.getClusters([ue,_e,180,Pe],W),nt=this.getClusters([-180,_e,Se,Pe],W);return ht.concat(nt)}const Ce=this.trees[this._limitZoom(W)],se=Ce.range(Dn(ue),vn(Pe),Dn(Se),vn(_e)),Ue=Ce.data,ot=[];for(const ht of se){const nt=this.stride*ht;ot.push(Ue[nt+wi]>1?Dt(Ue,nt,this.clusterProps):this.points[Ue[nt+St]])}return ot}getChildren(X){const W=this._getOriginId(X),ue=this._getOriginZoom(X),_e="No cluster with the specified id.",Se=this.trees[ue];if(!Se)throw new Error(_e);const Pe=Se.data;if(W*this.stride>=Pe.length)throw new Error(_e);const Ce=this.options.radius/(this.options.extent*Math.pow(2,ue-1)),se=Se.within(Pe[W*this.stride],Pe[W*this.stride+1],Ce),Ue=[];for(const ot of se){const ht=ot*this.stride;Pe[ht+4]===X&&Ue.push(Pe[ht+wi]>1?Dt(Pe,ht,this.clusterProps):this.points[Pe[ht+St]])}if(Ue.length===0)throw new Error(_e);return Ue}getLeaves(X,W,ue){const _e=[];return this._appendLeaves(_e,X,W=W||10,ue=ue||0,0),_e}getTile(X,W,ue){const _e=this.trees[this._limitZoom(X)],Se=Math.pow(2,X),{extent:Pe,radius:Ce}=this.options,se=Ce/Pe,Ue=(ue-se)/Se,ot=(ue+1+se)/Se,ht={features:[]};return this._addTileFeatures(_e.range((W-se)/Se,Ue,(W+1+se)/Se,ot),_e.data,W,ue,Se,ht),W===0&&this._addTileFeatures(_e.range(1-se/Se,Ue,1,ot),_e.data,Se,ue,Se,ht),W===Se-1&&this._addTileFeatures(_e.range(0,Ue,se/Se,ot),_e.data,-1,ue,Se,ht),ht.features.length?ht:null}getClusterExpansionZoom(X){let W=this._getOriginZoom(X)-1;for(;W<=this.options.maxZoom;){const ue=this.getChildren(X);if(W++,ue.length!==1)break;X=ue[0].properties.cluster_id}return W}_appendLeaves(X,W,ue,_e,Se){const Pe=this.getChildren(W);for(const Ce of Pe){const se=Ce.properties;if(se&&se.cluster?Se+se.point_count<=_e?Se+=se.point_count:Se=this._appendLeaves(X,se.cluster_id,ue,_e,Se):Se<_e?Se++:X.push(Ce),X.length===ue)break}return Se}_createTree(X){const W=new s.KDBush(X.length/this.stride|0,this.options.nodeSize,Float32Array);for(let ue=0;ue1;let ot,ht,nt;if(Ue)ot=Ni(W,se,this.clusterProps),ht=W[se],nt=W[se+1];else{const Zt=this.points[W[se+St]];ot=Zt.properties;const[ui,hi]=Zt.geometry.coordinates;ht=Dn(ui),nt=vn(hi)}const Ht={type:1,geometry:[[Math.round(this.options.extent*(ht*Se-ue)),Math.round(this.options.extent*(nt*Se-_e))]],tags:ot};let li;li=Ue||this.options.generateId?W[se+St]:this.points[W[se+St]].id,li!==void 0&&(Ht.id=li),Pe.features.push(Ht)}}_limitZoom(X){return Math.max(this.options.minZoom,Math.min(Math.floor(+X),this.options.maxZoom+1))}_cluster(X,W){const{radius:ue,extent:_e,reduce:Se,minPoints:Pe}=this.options,Ce=ue/(_e*Math.pow(2,W)),se=X.data,Ue=[],ot=this.stride;for(let ht=0;htW&&(ui+=se[tn+wi])}if(ui>Zt&&ui>=Pe){let hi,tn=nt*Zt,un=Ht*Zt,Un=-1;const Pi=((ht/ot|0)<<5)+(W+1)+this.points.length;for(const xr of li){const cn=xr*ot;if(se[cn+2]<=W)continue;se[cn+2]=W;const pn=se[cn+wi];tn+=se[cn]*pn,un+=se[cn+1]*pn,se[cn+4]=Pi,Se&&(hi||(hi=this._map(se,ht,!0),Un=this.clusterProps.length,this.clusterProps.push(hi)),Se(hi,this._map(se,cn)))}se[ht+4]=Pi,Ue.push(tn/ui,un/ui,1/0,Pi,-1,ui),Se&&Ue.push(Un)}else{for(let hi=0;hi1)for(const hi of li){const tn=hi*ot;if(!(se[tn+2]<=W)){se[tn+2]=W;for(let un=0;un>5}_getOriginZoom(X){return(X-this.points.length)%32}_map(X,W,ue){if(X[W+wi]>1){const Pe=this.clusterProps[X[W+Oi]];return ue?Object.assign({},Pe):Pe}const _e=this.points[X[W+St]].properties,Se=this.options.map(_e);return ue&&Se===_e?Object.assign({},Se):Se}}function Dt(ce,X,W){return{type:"Feature",id:ce[X+St],properties:Ni(ce,X,W),geometry:{type:"Point",coordinates:[(ue=ce[X],360*(ue-.5)),Fe(ce[X+1])]}};var ue}function Ni(ce,X,W){const ue=ce[X+wi],_e=ue>=1e4?`${Math.round(ue/1e3)}k`:ue>=1e3?Math.round(ue/100)/10+"k":ue,Se=ce[X+Oi],Pe=Se===-1?{}:Object.assign({},W[Se]);return Object.assign(Pe,{cluster:!0,cluster_id:ce[X+St],point_count:ue,point_count_abbreviated:_e})}function Dn(ce){return ce/360+.5}function vn(ce){const X=Math.sin(ce*Math.PI/180),W=.5-.25*Math.log((1+X)/(1-X))/Math.PI;return W<0?0:W>1?1:W}function Fe(ce){const X=(180-360*ce)*Math.PI/180;return 360*Math.atan(Math.exp(X))/Math.PI-90}function no(ce,X,W,ue){for(var _e,Se=ue,Pe=W-X>>1,Ce=W-X,se=ce[X],Ue=ce[X+1],ot=ce[W],ht=ce[W+1],nt=X+3;ntSe)_e=nt,Se=Ht;else if(Ht===Se){var li=Math.abs(nt-Pe);liue&&(_e-X>3&&no(ce,X,_e,ue),ce[_e+2]=Se,W-_e>3&&no(ce,_e,W,ue))}function Ci(ce,X,W,ue,_e,Se){var Pe=_e-W,Ce=Se-ue;if(Pe!==0||Ce!==0){var se=((ce-W)*Pe+(X-ue)*Ce)/(Pe*Pe+Ce*Ce);se>1?(W=_e,ue=Se):se>0&&(W+=Pe*se,ue+=Ce*se)}return(Pe=ce-W)*Pe+(Ce=X-ue)*Ce}function ft(ce,X,W,ue){var _e={id:ce===void 0?null:ce,type:X,geometry:W,tags:ue,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Se){var Pe=Se.geometry,Ce=Se.type;if(Ce==="Point"||Ce==="MultiPoint"||Ce==="LineString")me(Se,Pe);else if(Ce==="Polygon"||Ce==="MultiLineString")for(var se=0;se0&&(Pe+=ue?(_e*Ue-se*Se)/2:Math.sqrt(Math.pow(se-_e,2)+Math.pow(Ue-Se,2))),_e=se,Se=Ue}var ot=X.length-3;X[2]=1,no(X,0,ot,W),X[ot+2]=1,X.size=Math.abs(Pe),X.start=0,X.end=X.size}function pr(ce,X,W,ue){for(var _e=0;_e1?1:W}function ct(ce,X,W,ue,_e,Se,Pe,Ce){if(ue/=X,Se>=(W/=X)&&Pe=ue)return null;for(var se=[],Ue=0;Ue=W&&li=ue)){var Zt=[];if(nt==="Point"||nt==="MultiPoint")ds(ht,Zt,W,ue,_e);else if(nt==="LineString")Do(ht,Zt,W,ue,_e,!1,Ce.lineMetrics);else if(nt==="MultiLineString")xo(ht,Zt,W,ue,_e,!1);else if(nt==="Polygon")xo(ht,Zt,W,ue,_e,!0);else if(nt==="MultiPolygon")for(var ui=0;ui=W&&Pe<=ue&&(X.push(ce[Se]),X.push(ce[Se+1]),X.push(ce[Se+2]))}}function Do(ce,X,W,ue,_e,Se,Pe){for(var Ce,se,Ue=Dr(ce),ot=_e===0?bo:Oo,ht=ce.start,nt=0;ntW&&(se=ot(Ue,Ht,li,ui,hi,W),Pe&&(Ue.start=ht+Ce*se)):tn>ue?un=W&&(se=ot(Ue,Ht,li,ui,hi,W),Un=!0),un>ue&&tn<=ue&&(se=ot(Ue,Ht,li,ui,hi,ue),Un=!0),!Se&&Un&&(Pe&&(Ue.end=ht+Ce*se),X.push(Ue),Ue=Dr(ce)),Pe&&(ht+=Ce)}var Pi=ce.length-3;Ht=ce[Pi],li=ce[Pi+1],Zt=ce[Pi+2],(tn=_e===0?Ht:li)>=W&&tn<=ue&&ii(Ue,Ht,li,Zt),Pi=Ue.length-3,Se&&Pi>=3&&(Ue[Pi]!==Ue[0]||Ue[Pi+1]!==Ue[1])&&ii(Ue,Ue[0],Ue[1],Ue[2]),Ue.length&&X.push(Ue)}function Dr(ce){var X=[];return X.size=ce.size,X.start=ce.start,X.end=ce.end,X}function xo(ce,X,W,ue,_e,Se){for(var Pe=0;PePe.maxX&&(Pe.maxX=ot),ht>Pe.maxY&&(Pe.maxY=ht)}return Pe}function zs(ce,X,W,ue){var _e=X.geometry,Se=X.type,Pe=[];if(Se==="Point"||Se==="MultiPoint")for(var Ce=0;Ce<_e.length;Ce+=3)Pe.push(_e[Ce]),Pe.push(_e[Ce+1]),ce.numPoints++,ce.numSimplified++;else if(Se==="LineString")Wn(Pe,_e,ce,W,!1,!1);else if(Se==="MultiLineString"||Se==="Polygon")for(Ce=0;Ce<_e.length;Ce++)Wn(Pe,_e[Ce],ce,W,Se==="Polygon",Ce===0);else if(Se==="MultiPolygon")for(var se=0;se<_e.length;se++){var Ue=_e[se];for(Ce=0;Ce0&&X.size<(_e?Pe:ue))W.numPoints+=X.length/3;else{for(var Ce=[],se=0;sePe)&&(W.numSimplified++,Ce.push(X[se]),Ce.push(X[se+1])),W.numPoints++;_e&&function(Ue,ot){for(var ht=0,nt=0,Ht=Ue.length,li=Ht-2;nt0===ot)for(nt=0,Ht=Ue.length;nt24)throw new Error("maxZoom should be in the 0-24 range");if(X.promoteId&&X.generateId)throw new Error("promoteId and generateId cannot be used together.");var ue=function(_e,Se){var Pe=[];if(_e.type==="FeatureCollection")for(var Ce=0;Ce<_e.features.length;Ce++)rn(Pe,_e.features[Ce],Se,Ce);else rn(Pe,_e.type==="Feature"?_e:{geometry:_e},Se);return Pe}(ce,X);this.tiles={},this.tileCoords=[],W&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",X.indexMaxZoom,X.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ue=function(_e,Se){var Pe=Se.buffer/Se.extent,Ce=_e,se=ct(_e,1,-1-Pe,Pe,0,-1,2,Se),Ue=ct(_e,1,1-Pe,2+Pe,0,-1,2,Se);return(se||Ue)&&(Ce=ct(_e,1,-Pe,1+Pe,0,-1,2,Se)||[],se&&(Ce=tr(se,1).concat(Ce)),Ue&&(Ce=Ce.concat(tr(Ue,-1)))),Ce}(ue,X),ue.length&&this.splitTile(ue,0,0,0),W&&(ue.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function qt(ce,X,W){return 32*((1<1&&console.time("creation"),nt=this.tiles[ht]=Yt(ce,X,W,ue,se),this.tileCoords.push({z:X,x:W,y:ue}),Ue)){Ue>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",X,W,ue,nt.numFeatures,nt.numPoints,nt.numSimplified),console.timeEnd("creation"));var Ht="z"+X;this.stats[Ht]=(this.stats[Ht]||0)+1,this.total++}if(nt.source=ce,_e){if(X===se.maxZoom||X===_e)continue;var li=1<<_e-X;if(W!==Math.floor(Se/li)||ue!==Math.floor(Pe/li))continue}else if(X===se.indexMaxZoom||nt.numPoints<=se.indexMaxPoints)continue;if(nt.source=null,ce.length!==0){Ue>1&&console.time("clipping");var Zt,ui,hi,tn,un,Un,Pi=.5*se.buffer/se.extent,xr=.5-Pi,cn=.5+Pi,pn=1+Pi;Zt=ui=hi=tn=null,un=ct(ce,ot,W-Pi,W+cn,0,nt.minX,nt.maxX,se),Un=ct(ce,ot,W+xr,W+pn,0,nt.minX,nt.maxX,se),ce=null,un&&(Zt=ct(un,ot,ue-Pi,ue+cn,1,nt.minY,nt.maxY,se),ui=ct(un,ot,ue+xr,ue+pn,1,nt.minY,nt.maxY,se),un=null),Un&&(hi=ct(Un,ot,ue-Pi,ue+cn,1,nt.minY,nt.maxY,se),tn=ct(Un,ot,ue+xr,ue+pn,1,nt.minY,nt.maxY,se),Un=null),Ue>1&&console.timeEnd("clipping"),Ce.push(Zt||[],X+1,2*W,2*ue),Ce.push(ui||[],X+1,2*W,2*ue+1),Ce.push(hi||[],X+1,2*W+1,2*ue),Ce.push(tn||[],X+1,2*W+1,2*ue+1)}}},wo.prototype.getTile=function(ce,X,W){var ue=this.options,_e=ue.extent,Se=ue.debug;if(ce<0||ce>24)return null;var Pe=1<1&&console.log("drilling down to z%d-%d-%d",ce,X,W);for(var se,Ue=ce,ot=X,ht=W;!se&&Ue>0;)Ue--,ot=Math.floor(ot/2),ht=Math.floor(ht/2),se=this.tiles[qt(Ue,ot,ht)];return se&&se.source?(Se>1&&console.log("found parent tile z%d-%d-%d",Ue,ot,ht),Se>1&&console.time("drilling down"),this.splitTile(se.source,Ue,ot,ht,ce,X,W),Se>1&&console.timeEnd("drilling down"),this.tiles[Ce]?zo(this.tiles[Ce],_e):null):null};class ms extends s.VectorTileWorkerSource{constructor(X,W,ue,_e,Se){super(X,W,ue,_e,No),Se&&(this.loadGeoJSON=Se)}loadData(X,W){const ue=X&&X.request,_e=ue&&ue.collectResourceTiming;this.loadGeoJSON(X,(Se,Pe)=>{if(Se||!Pe)return W(Se);if(typeof Pe!="object")return W(new Error(`Input data given to '${X.source}' is not a valid GeoJSON object.`));{Ie(Pe,!0);try{if(X.filter){const se=s.createExpression(X.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(se.result==="error")throw new Error(se.value.map(ot=>`${ot.key}: ${ot.message}`).join(", "));Pe={type:"FeatureCollection",features:Pe.features.filter(ot=>se.value.evaluate({zoom:0},ot))}}this._geoJSONIndex=X.cluster?new Wt(function({superclusterOptions:se,clusterProperties:Ue}){if(!Ue||!se)return se;const ot={},ht={},nt={accumulated:null,zoom:0},Ht={properties:null},li=Object.keys(Ue);for(const Zt of li){const[ui,hi]=Ue[Zt],tn=s.createExpression(hi),un=s.createExpression(typeof ui=="string"?[ui,["accumulated"],["get",Zt]]:ui);ot[Zt]=tn.value,ht[Zt]=un.value}return se.map=Zt=>{Ht.properties=Zt;const ui={};for(const hi of li)ui[hi]=ot[hi].evaluate(nt,Ht);return ui},se.reduce=(Zt,ui)=>{Ht.properties=ui;for(const hi of li)nt.accumulated=Zt[hi],Zt[hi]=ht[hi].evaluate(nt,Ht)},se}(X)).load(Pe.features):function(se,Ue){return new wo(se,Ue)}(Pe,X.geojsonVtOptions)}catch(se){return W(se)}this.loaded={};const Ce={};if(_e){const se=s.getPerformanceMeasurement(ue);se&&(Ce.resourceTiming={},Ce.resourceTiming[X.source]=JSON.parse(JSON.stringify(se)))}W(null,Ce)}})}reloadTile(X,W){const ue=this.loaded;return ue&&ue[X.uid]?super.reloadTile(X,W):this.loadTile(X,W)}loadGeoJSON(X,W){if(X.request)s.getJSON(X.request,W);else{if(typeof X.data!="string")return W(new Error(`Input data given to '${X.source}' is not a valid GeoJSON object.`));try{return W(null,JSON.parse(X.data))}catch{return W(new Error(`Input data given to '${X.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(X,W){try{W(null,this._geoJSONIndex.getClusterExpansionZoom(X.clusterId))}catch(ue){W(ue)}}getClusterChildren(X,W){try{W(null,this._geoJSONIndex.getChildren(X.clusterId))}catch(ue){W(ue)}}getClusterLeaves(X,W){try{W(null,this._geoJSONIndex.getLeaves(X.clusterId,X.limit,X.offset))}catch(ue){W(ue)}}}class gs{constructor(X){this.self=X,this.actor=new s.Actor(X,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=s.getProjection({name:"mercator"}),this.workerSourceTypes={vector:s.VectorTileWorkerSource,geojson:ms},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(W,ue)=>{if(this.workerSourceTypes[W])throw new Error(`Worker source with name "${W}" already registered.`);this.workerSourceTypes[W]=ue},this.self.registerRTLTextPlugin=W=>{if(s.plugin.isParsed())throw new Error("RTL text plugin already registered.");s.plugin.applyArabicShaping=W.applyArabicShaping,s.plugin.processBidirectionalText=W.processBidirectionalText,s.plugin.processStyledBidirectionalText=W.processStyledBidirectionalText}}clearCaches(X,W,ue){delete this.layerIndexes[X],delete this.availableImages[X],delete this.workerSources[X],delete this.demWorkerSources[X],ue()}checkIfReady(X,W,ue){ue()}setReferrer(X,W){this.referrer=W}spriteLoaded(X,W){this.isSpriteLoaded[X]=W;for(const ue in this.workerSources[X]){const _e=this.workerSources[X][ue];for(const Se in _e)_e[Se]instanceof s.VectorTileWorkerSource&&(_e[Se].isSpriteLoaded=W,_e[Se].fire(new s.Event("isSpriteLoaded")))}}setImages(X,W,ue){this.availableImages[X]=W;for(const _e in this.workerSources[X]){const Se=this.workerSources[X][_e];for(const Pe in Se)Se[Pe].availableImages=W}ue()}enableTerrain(X,W,ue){this.terrain=W,ue()}setProjection(X,W){this.projections[X]=s.getProjection(W)}setLayers(X,W,ue){this.getLayerIndex(X).replace(W),ue()}updateLayers(X,W,ue){this.getLayerIndex(X).update(W.layers,W.removedIds),ue()}loadTile(X,W,ue){const _e=this.enableTerrain?s.extend({enableTerrain:this.terrain},W):W;_e.projection=this.projections[X]||this.defaultProjection,this.getWorkerSource(X,W.type,W.source).loadTile(_e,ue)}loadDEMTile(X,W,ue){const _e=this.enableTerrain?s.extend({buildQuadTree:this.terrain},W):W;this.getDEMWorkerSource(X,W.source).loadTile(_e,ue)}reloadTile(X,W,ue){const _e=this.enableTerrain?s.extend({enableTerrain:this.terrain},W):W;_e.projection=this.projections[X]||this.defaultProjection,this.getWorkerSource(X,W.type,W.source).reloadTile(_e,ue)}abortTile(X,W,ue){this.getWorkerSource(X,W.type,W.source).abortTile(W,ue)}removeTile(X,W,ue){this.getWorkerSource(X,W.type,W.source).removeTile(W,ue)}removeSource(X,W,ue){if(!this.workerSources[X]||!this.workerSources[X][W.type]||!this.workerSources[X][W.type][W.source])return;const _e=this.workerSources[X][W.type][W.source];delete this.workerSources[X][W.type][W.source],_e.removeSource!==void 0?_e.removeSource(W,ue):ue()}loadWorkerSource(X,W,ue){try{this.self.importScripts(W.url),ue()}catch(_e){ue(_e.toString())}}syncRTLPluginState(X,W,ue){try{s.plugin.setState(W);const _e=s.plugin.getPluginURL();if(s.plugin.isLoaded()&&!s.plugin.isParsed()&&_e!=null){this.self.importScripts(_e);const Se=s.plugin.isParsed();ue(Se?void 0:new Error(`RTL Text Plugin failed to import scripts from ${_e}`),Se)}}catch(_e){ue(_e.toString())}}getAvailableImages(X){let W=this.availableImages[X];return W||(W=[]),W}getLayerIndex(X){let W=this.layerIndexes[X];return W||(W=this.layerIndexes[X]=new pe),W}getWorkerSource(X,W,ue){if(this.workerSources[X]||(this.workerSources[X]={}),this.workerSources[X][W]||(this.workerSources[X][W]={}),!this.workerSources[X][W][ue]){const _e={send:(Se,Pe,Ce,se,Ue,ot)=>{this.actor.send(Se,Pe,Ce,X,Ue,ot)},scheduler:this.actor.scheduler};this.workerSources[X][W][ue]=new this.workerSourceTypes[W](_e,this.getLayerIndex(X),this.getAvailableImages(X),this.isSpriteLoaded[X])}return this.workerSources[X][W][ue]}getDEMWorkerSource(X,W){return this.demWorkerSources[X]||(this.demWorkerSources[X]={}),this.demWorkerSources[X][W]||(this.demWorkerSources[X][W]=new he),this.demWorkerSources[X][W]}enforceCacheSizeLimit(X,W){s.enforceCacheSizeLimit(W)}getWorkerPerformanceMetrics(X,W,ue){ue(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new gs(self)),gs}),O(["./shared"],function(s){function Z(h,n){if(Array.isArray(h)){if(!Array.isArray(n)||h.length!==n.length)return!1;for(let a=0;a"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 p,_,b=new Blob([""],{type:"text/javascript"}),I=URL.createObjectURL(b);try{_=new Worker(I),p=!0}catch{p=!1}return _&&_.terminate(),URL.revokeObjectURL(I),p}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var p=document.createElement("canvas");p.width=p.height=1;var _=p.getContext("2d");if(!_)return!1;var b=_.getImageData(0,0,1,1);return b&&b.width===p.width}()?(he[a=n&&n.failIfMajorPerformanceCaveat]===void 0&&(he[a]=function(p){var _,b=function(I){var M=document.createElement("canvas"),P=Object.create(pe.webGLContextAttributes);return P.failIfMajorPerformanceCaveat=I,M.getContext("webgl",P)||M.getContext("experimental-webgl",P)}(p);if(!b)return!1;try{_=b.createShader(b.VERTEX_SHADER)}catch{return!1}return!(!_||b.isContextLost())&&(b.shaderSource(_,"void main() {}"),b.compileShader(_),b.getShaderParameter(_,b.COMPILE_STATUS)===!0)}(a)),he[a]?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 a}(h)}var he={};function we(h,n,a){const p=s.window.document.createElement(h);return n!==void 0&&(p.className=n),a&&a.appendChild(p),p}function ye(h,n,a){const p=s.window.document.createElementNS("http://www.w3.org/2000/svg",h);for(const _ of Object.keys(n))p.setAttributeNS(null,_,n[_]);return a&&a.appendChild(p),p}pe.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const Ie=s.window.document&&s.window.document.documentElement.style,Tt=Ie&&Ie.userSelect!==void 0?"userSelect":"WebkitUserSelect";let gt;function Mt(){Ie&&Tt&&(gt=Ie[Tt],Ie[Tt]="none")}function Le(){Ie&&Tt&&(Ie[Tt]=gt)}function Qe(h){h.preventDefault(),h.stopPropagation(),s.window.removeEventListener("click",Qe,!0)}function Et(){s.window.addEventListener("click",Qe,!0),s.window.setTimeout(()=>{s.window.removeEventListener("click",Qe,!0)},0)}function ut(h,n){const a=h.getBoundingClientRect();return It(h,a,n)}function yt(h,n){const a=h.getBoundingClientRect(),p=[];for(let _=0;_=0?0:h.button}function It(h,n,a){const p=h.offsetWidth===n.width?1:h.offsetWidth/n.width;return new s.Point((a.clientX-n.left)*p,(a.clientY-n.top)*p)}function Oe(h,n){var a=n[0],p=n[1],_=n[2],b=n[3],I=a*b-_*p;return I?(h[0]=b*(I=1/I),h[1]=-p*I,h[2]=-_*I,h[3]=a*I,h):null}function gi(h){const{userImage:n}=h;return!!(n&&n.render&&n.render())&&(h.data.replace(new Uint8Array(n.data.buffer)),!0)}class ti extends s.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(n){if(this.loaded!==n&&(this.loaded=n,n)){for(const{ids:a,callback:p}of this.requestors)this._notify(a,p);this.requestors=[]}}hasImage(n){return!!this.getImage(n)}getImage(n){return this.images[n]}addImage(n,a){this._validate(n,a)&&(this.images[n]=a)}_validate(n,a){let p=!0;return this._validateStretch(a.stretchX,a.data&&a.data.width)||(this.fire(new s.ErrorEvent(new Error(`Image "${n}" has invalid "stretchX" value`))),p=!1),this._validateStretch(a.stretchY,a.data&&a.data.height)||(this.fire(new s.ErrorEvent(new Error(`Image "${n}" has invalid "stretchY" value`))),p=!1),this._validateContent(a.content,a)||(this.fire(new s.ErrorEvent(new Error(`Image "${n}" has invalid "content" value`))),p=!1),p}_validateStretch(n,a){if(!n)return!0;let p=0;for(const _ of n){if(_[0]{this.ready=!0})}broadcast(n,a,p){s.asyncAll(this.actors,(_,b)=>{_.send(n,a,b)},p=p||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(n=>{n.remove()}),this.actors=[],this.workerPool.release(this.id)}}function wi(h,n,a){return n*(s.EXTENT/(h.tileSize*Math.pow(2,a-h.tileID.overscaledZ)))}St.Actor=s.Actor;class Oi{constructor(n,a,p,_){this.screenBounds=n,this.cameraPoint=a,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=p,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,_)}static createFromScreenPoints(n,a){let p,_;if(n instanceof s.Point||typeof n[0]=="number"){const b=s.Point.convert(n);p=[b],_=a.isPointAboveHorizon(b)}else{const b=s.Point.convert(n[0]),I=s.Point.convert(n[1]);p=[b,I],_=s.polygonizeBounds(b,I).every(M=>a.isPointAboveHorizon(M))}return new Oi(p,a.getCameraPoint(),_,a)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(n){return s.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],n)}bufferedCameraGeometry(n){const a=this.screenBounds[0],p=this.screenBounds.length===1?this.screenBounds[0].add(new s.Point(1,1)):this.screenBounds[1],_=s.polygonizeBounds(a,p,0,!1);return this.cameraPoint.y>p.y&&(this.cameraPoint.x>a.x&&this.cameraPoint.x=p.x?_[2]=this.cameraPoint:this.cameraPoint.x<=a.x&&(_[3]=this.cameraPoint)),s.bufferConvexPolygon(_,n)}bufferedCameraGeometryGlobe(n){const a=this.screenBounds[0],p=this.screenBounds.length===1?this.screenBounds[0].add(new s.Point(1,1)):this.screenBounds[1],_=s.polygonizeBounds(a,p,n),b=this.cameraPoint.clone();switch(3*((b.y>a.y)+(b.y>p.y))+((b.x>a.x)+(b.x>p.x))){case 0:_[0]=b,_[4]=b.clone();break;case 1:_.splice(1,0,b);break;case 2:_[1]=b;break;case 3:_.splice(4,0,b);break;case 5:_.splice(2,0,b);break;case 6:_[3]=b;break;case 7:_.splice(3,0,b);break;case 8:_[2]=b}return _}containsTile(n,a,p,_=0){const b=n.queryPadding/a._pixelsPerMercatorPixel+1,I=p?this._bufferedCameraMercator(b,a):this._bufferedScreenMercator(b,a);let M=n.tileID.wrap+(I.unwrapped?_:0);const P=I.polygon.map(ie=>s.getTilePoint(n.tileTransform,ie,M));if(!s.polygonIntersectsBox(P,0,0,s.EXTENT,s.EXTENT))return;M=n.tileID.wrap+(this.screenGeometryMercator.unwrapped?_:0);const N=this.screenGeometryMercator.polygon.map(ie=>s.getTileVec3(n.tileTransform,ie,M)),z=N.map(ie=>new s.Point(ie[0],ie[1])),j=a.getFreeCameraOptions().position||new s.MercatorCoordinate(0,0,0),Y=s.getTileVec3(n.tileTransform,j,M),J=N.map(ie=>{const V=s.sub(ie,ie,Y);return s.normalize(V,V),new s.Ray(Y,V)}),te=wi(n,1,a.zoom)*a._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:z,tilespaceRays:J,bufferedTilespaceGeometry:P,bufferedTilespaceBounds:(ee=s.getBounds(P),ee.min.x=s.clamp(ee.min.x,0,s.EXTENT),ee.min.y=s.clamp(ee.min.y,0,s.EXTENT),ee.max.x=s.clamp(ee.max.x,0,s.EXTENT),ee.max.y=s.clamp(ee.max.y,0,s.EXTENT),ee),tile:n,tileID:n.tileID,pixelToTileUnitsFactor:te};var ee}_bufferedScreenMercator(n,a){const p=Ni(n);if(this._screenRaycastCache[p])return this._screenRaycastCache[p];{let _;return _=a.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(n),a):{polygon:this.bufferedScreenGeometry(n).map(b=>a.pointCoordinate3D(b)),unwrapped:!0},this._screenRaycastCache[p]=_,_}}_bufferedCameraMercator(n,a){const p=Ni(n);if(this._cameraRaycastCache[p])return this._cameraRaycastCache[p];{let _;return _=a.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(n),a):{polygon:this.bufferedCameraGeometry(n).map(b=>a.pointCoordinate3D(b)),unwrapped:!0},this._cameraRaycastCache[p]=_,_}}_projectAndResample(n,a){const p=function(b,I){const M=s.multiply([],I.pixelMatrix,I.globeMatrix),P=[0,-s.GLOBE_RADIUS,0,1],N=[0,s.GLOBE_RADIUS,0,1],z=[0,0,0,1];s.transformMat4$1(P,P,M),s.transformMat4$1(N,N,M),s.transformMat4$1(z,z,M);const j=new s.Point(P[0]/P[3],P[1]/P[3]),Y=new s.Point(N[0]/N[3],N[1]/N[3]),J=s.polygonContainsPoint(b,j)&&P[3]1?Wt(b.slice(0,ie),I):[],ae=ienew s.Point(Dt(be.x),be.y)),ae=ae.map(be=>new s.Point(Dt(be.x),be.y));const le=[...K];le.length===0&&le.push(ae[ae.length-1]);const xe=s.number(le[le.length-1].y,(ae.length===0?K[0]:ae[0]).y,V);let Te;return Te=J?[new s.Point(0,xe),new s.Point(0,0),new s.Point(1,0),new s.Point(1,xe)]:[new s.Point(1,xe),new s.Point(1,1),new s.Point(0,1),new s.Point(0,xe)],le.push(...Te),ae.length===0?le.push(K[0]):le.push(...ae),{polygon:le.map(be=>new s.MercatorCoordinate(be.x,be.y)),unwrapped:!1}}(n,a);if(p)return p;const _=function(b,I){let M=!1,P=-1/0,N=0;for(let j=0;jP&&(P=b[j].x,N=j);for(let j=0;j.5&&(J.x{j.x-=1}),{polygon:b,unwrapped:M}}(Wt(n,a).map(b=>new s.Point(Dt(b.x),b.y)),a);return{polygon:_.polygon.map(b=>new s.MercatorCoordinate(b.x,b.y)),unwrapped:_.unwrapped}}}function Wt(h,n){return s.resample(h,a=>{const p=n.pointCoordinate3D(a);a.x=p.x,a.y=p.y},.00390625)}function Dt(h){return h<0?1+h%1:h%1}function Ni(h){return 100*h|0}function Dn(h,n,a,p,_){const b=function(I,M){if(I)return _(I);if(M){h.url&&M.tiles&&h.tiles&&delete h.tiles;const P=s.pick(s.extend(M,h),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);M.vector_layers&&(P.vectorLayers=M.vector_layers,P.vectorLayerIds=P.vectorLayers.map(N=>N.id)),P.tiles=n.canonicalizeTileset(P,h.url),_(null,P)}};return h.url?s.getJSON(n.transformRequest(n.normalizeSourceURL(h.url,null,a,p),s.ResourceType.Source),b):s.exported.frame(()=>b(null,h))}class vn{constructor(n,a,p){this.bounds=s.LngLatBounds.convert(this.validateBounds(n)),this.minzoom=a||0,this.maxzoom=p||24}validateBounds(n){return Array.isArray(n)&&n.length===4?[Math.max(-180,n[0]),Math.max(-90,n[1]),Math.min(180,n[2]),Math.min(90,n[3])]:[-180,-90,180,90]}contains(n){const a=Math.pow(2,n.z),p=Math.floor(s.mercatorXfromLng(this.bounds.getWest())*a),_=Math.floor(s.mercatorYfromLat(this.bounds.getNorth())*a),b=Math.ceil(s.mercatorXfromLng(this.bounds.getEast())*a),I=Math.ceil(s.mercatorYfromLat(this.bounds.getSouth())*a);return n.x>=p&&n.x=_&&n.y{this._tileJSONRequest=null,this._loaded=!0,_?(a&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${a}`),p&&p.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${p}`),this.fire(new s.ErrorEvent(_))):b&&(s.extend(this,b),b.bounds&&(this.tileBounds=new vn(b.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(b.tiles,this.map._requestManager._customAccessToken),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))),n&&n(_)})}loaded(){return this._loaded}hasTile(n){return!this.tileBounds||this.tileBounds.contains(n.canonical)}onAdd(n){this.map=n,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(n){return this._options.tiles=n,this.reload(),this}setUrl(n){return this.url=n,this._options.url=n,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return s.extend({},this._options)}loadTile(n,a){const p=this.map._requestManager.normalizeTileURL(n.tileID.canonical.url(this.tiles,this.scheme)),_={request:this.map._requestManager.transformRequest(p,s.ResourceType.Tile),data:void 0,uid:n.uid,tileID:n.tileID,tileZoom:n.tileZoom,zoom:n.tileID.overscaledZ,tileSize:this.tileSize*n.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:n.isSymbolTile};if(_.request.collectResourceTiming=this._collectResourceTiming,n.actor&&n.state!=="expired")n.state==="loading"?n.reloadCallback=a:n.request=n.actor.send("reloadTile",_,b.bind(this));else if(n.actor=this._tileWorkers[p]=this._tileWorkers[p]||this.dispatcher.getActor(),this.dispatcher.ready)n.request=n.actor.send("loadTile",_,b.bind(this),void 0,!0);else{const I=s.loadVectorTile.call({deduped:this._deduped},_,(M,P)=>{M||!P?b.call(this,M):(_.data={cacheControl:P.cacheControl,expires:P.expires,rawData:P.rawData.slice(0)},n.actor&&n.actor.send("loadTile",_,b.bind(this),void 0,!0))},!0);n.request={cancel:I}}function b(I,M){return delete n.request,n.aborted?a(null):I&&I.status!==404?a(I):(M&&M.resourceTiming&&(n.resourceTiming=M.resourceTiming),this.map._refreshExpiredTiles&&M&&n.setExpiryData(M),n.loadVectorData(M,this.map.painter),s.cacheEntryPossiblyAdded(this.dispatcher),a(null),void(n.reloadCallback&&(this.loadTile(n,n.reloadCallback),n.reloadCallback=null)))}}abortTile(n){n.request&&(n.request.cancel(),delete n.request),n.actor&&n.actor.send("abortTile",{uid:n.uid,type:this.type,source:this.id})}unloadTile(n){n.unloadVectorData(),n.actor&&n.actor.send("removeTile",{uid:n.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class nt extends s.Evented{constructor(n,a,p,_){super(),this.id=n,this.dispatcher=p,this.setEventedParent(_),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.extend({type:"raster"},a),s.extend(this,s.pick(a,["url","scheme","tileSize"]))}load(n){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Dn(this._options,this.map._requestManager,null,null,(a,p)=>{this._tileJSONRequest=null,this._loaded=!0,a?this.fire(new s.ErrorEvent(a)):p&&(s.extend(this,p),p.bounds&&(this.tileBounds=new vn(p.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(p.tiles),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))),n&&n(a)})}loaded(){return this._loaded}onAdd(n){this.map=n,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(n){return this._options.tiles=n,this.reload(),this}setUrl(n){return this.url=n,this._options.url=n,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return s.extend({},this._options)}hasTile(n){return!this.tileBounds||this.tileBounds.contains(n.canonical)}loadTile(n,a){const p=s.exported.devicePixelRatio>=2,_=this.map._requestManager.normalizeTileURL(n.tileID.canonical.url(this.tiles,this.scheme),p,this.tileSize);n.request=s.getImage(this.map._requestManager.transformRequest(_,s.ResourceType.Tile),(b,I,M,P)=>(delete n.request,n.aborted?(n.state="unloaded",a(null)):b?(n.state="errored",a(b)):I?(this.map._refreshExpiredTiles&&n.setExpiryData({cacheControl:M,expires:P}),n.setTexture(I,this.map.painter),n.state="loaded",s.cacheEntryPossiblyAdded(this.dispatcher),void a(null)):a(null)))}static loadTileData(n,a,p){n.setTexture(a,p)}static unloadTileData(n,a){n.texture&&a.saveTileTexture(n.texture)}abortTile(n,a){n.request&&(n.request.cancel(),delete n.request),a()}unloadTile(n,a){n.texture&&this.map.painter.saveTileTexture(n.texture),a()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Ht(h,n,a,p,_,b,I,M){const P=[h,a,_,n,p,b,1,1,1],N=[I,M,1],z=s.adjoint([],P),[j,Y,J]=s.transformMat3(N,N,s.transpose(z,z));return s.multiply$1(P,[j,0,0,0,Y,0,0,0,J],P)}class li extends s.Evented{constructor(n,a,p,_){super(),this.id=n,this.dispatcher=p,this.coordinates=a.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(_),this.options=a,this._dirty=!1}load(n,a){this._loaded=a||!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=s.getImage(this.map._requestManager.transformRequest(this.url,s.ResourceType.Image),(p,_)=>{if(this._imageRequest=null,this._loaded=!0,p)this.fire(new s.ErrorEvent(p));else if(_){const{HTMLImageElement:b}=s.window;this.image=_ instanceof b?s.exported.getImageData(_):_,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,n&&(this.coordinates=n),this._finishLoading()}})}loaded(){return this._loaded}updateImage(n){return this.image&&n.url?(this._imageRequest&&n.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=n.url,this.load(n.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(n){this.map=n,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(n){this.coordinates=n,this._boundsArray=void 0;const a=n.map(s.MercatorCoordinate.fromLngLat);return this.tileID=function(p){let _=1/0,b=1/0,I=-1/0,M=-1/0;for(const j of p)_=Math.min(_,j.x),b=Math.min(b,j.y),I=Math.max(I,j.x),M=Math.max(M,j.y);const P=Math.max(I-_,M-b),N=Math.max(0,Math.floor(-Math.log(P)/Math.LN2)),z=Math.pow(2,N);return new s.CanonicalTileID(N,Math.floor((_+I)/2*z),Math.floor((b+M)/2*z))}(a),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(n){for(const P in this.tiles){const N=this.tiles[P];N.state!=="loaded"&&(N.state="loaded",N.texture=this.texture)}if(this._boundsArray)return;const a=s.tileTransform(this.tileID,this.map.transform.projection),[p,_,b,I]=this.coordinates.map(P=>{const N=a.projection.project(P[0],P[1]);return s.getTilePoint(a,N)._round()});this.perspectiveTransform=function(P,N,z,j,Y,J,te,ee,ie,V){const K=Ht(0,0,P,0,0,N,P,N),ae=Ht(z,j,Y,J,te,ee,ie,V);return s.multiply$1(ae,s.adjoint(K,K),ae),[ae[6]/ae[8]*P/s.EXTENT,ae[7]/ae[8]*N/s.EXTENT]}(this.width,this.height,p.x,p.y,_.x,_.y,I.x,I.y,b.x,b.y);const M=this._boundsArray=new s.StructArrayLayout4i8;M.emplaceBack(p.x,p.y,0,0),M.emplaceBack(_.x,_.y,s.EXTENT,0),M.emplaceBack(I.x,I.y,0,s.EXTENT),M.emplaceBack(b.x,b.y,s.EXTENT,s.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=n.createVertexBuffer(M,s.boundsAttributes.members),this.boundsSegments=s.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const n=this.map.painter.context,a=n.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new s.Texture(n,this.image,a.RGBA),this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(n)}loadTile(n,a){this.tileID&&this.tileID.equals(n.tileID.canonical)?(this.tiles[String(n.tileID.wrap)]=n,n.buckets={},a(null)):(n.state="errored",a(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Zt={vector:ht,raster:nt,"raster-dem":class extends nt{constructor(h,n,a,p){super(h,n,a,p),this.type="raster-dem",this.maxzoom=22,this._options=s.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(h,n){const a=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function p(_,b){_&&(h.state="errored",n(_)),b&&(h.dem=b,h.dem.onDeserialize(),h.needsHillshadePrepare=!0,h.needsDEMTextureUpload=!0,h.state="loaded",n(null))}h.request=s.getImage(this.map._requestManager.transformRequest(a,s.ResourceType.Tile),(function(_,b,I,M){if(delete h.request,h.aborted)h.state="unloaded",n(null);else if(_)h.state="errored",n(_);else if(b){this.map._refreshExpiredTiles&&h.setExpiryData({cacheControl:I,expires:M});const P=s.window.ImageBitmap&&b instanceof s.window.ImageBitmap&&(Yt==null&&(Yt=s.window.OffscreenCanvas&&new s.window.OffscreenCanvas(1,1).getContext("2d")&&typeof s.window.createImageBitmap=="function"),Yt),N=1-(b.width-s.prevPowerOfTwo(b.width))/2;N<1||h.neighboringTiles||(h.neighboringTiles=this._getNeighboringTiles(h.tileID));const z=P?b:s.exported.getImageData(b,N),j={uid:h.uid,coord:h.tileID,source:this.id,rawImageData:z,encoding:this.encoding,padding:N};h.actor&&h.state!=="expired"||(h.actor=this.dispatcher.getActor(),h.actor.send("loadDEMTile",j,p.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(h){const n=h.canonical,a=Math.pow(2,n.z),p=(n.x-1+a)%a,_=n.x===0?h.wrap-1:h.wrap,b=(n.x+1+a)%a,I=n.x+1===a?h.wrap+1:h.wrap,M={};return M[new s.OverscaledTileID(h.overscaledZ,_,n.z,p,n.y).key]={backfilled:!1},M[new s.OverscaledTileID(h.overscaledZ,I,n.z,b,n.y).key]={backfilled:!1},n.y>0&&(M[new s.OverscaledTileID(h.overscaledZ,_,n.z,p,n.y-1).key]={backfilled:!1},M[new s.OverscaledTileID(h.overscaledZ,h.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},M[new s.OverscaledTileID(h.overscaledZ,I,n.z,b,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,a)this.fire(new s.ErrorEvent(a));else{const _={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&p&&p.resourceTiming&&p.resourceTiming[this.id]&&(_.resourceTiming=p.resourceTiming[this.id]),this.fire(new s.Event("data",_)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(h,n){const a=h.actor?"reloadTile":"loadTile";h.actor=this.actor,h.request=this.actor.send(a,{type:this.type,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(p,_)=>(delete h.request,h.unloadVectorData(),h.aborted?n(null):p?n(p):(h.loadVectorData(_,this.map.painter,a==="reloadTile"),n(null))),void 0,a==="loadTile")}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.aborted=!0}unloadTile(h){h.unloadVectorData(),this.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return s.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends li{constructor(h,n,a,p){super(h,n,a,p),this.roundZoom=!0,this.type="video",this.options=n}load(){this._loaded=!1;const h=this.options;this.urls=[];for(const n of h.urls)this.urls.push(this.map._requestManager.transformRequest(n,s.ResourceType.Source).url);s.getVideo(this.urls,(n,a)=>{this._loaded=!0,n?this.fire(new s.ErrorEvent(n)):a&&(this.video=a,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(h){if(this.video){const n=this.video.seekable;hn.end(0)?this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=h}}getVideo(){return this.video}onAdd(h){this.map||(this.map=h,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 h=this.map.painter.context,n=h.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new s.Texture(h,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(h)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:li,canvas:class extends li{constructor(h,n,a,p){super(h,n,a,p),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(_=>!Array.isArray(_)||_.length!==2||_.some(b=>typeof b!="number"))||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${h}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${h}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${h}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof s.window.HTMLCanvasElement||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${h}`,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 s.ErrorEvent(new s.ValidationError(`sources.${h}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof s.window.HTMLCanvasElement?this.options.canvas:s.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(h){this.map=h,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let h=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,h=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,h=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context;this.texture?(h||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new s.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const h of[this.canvas.width,this.canvas.height])if(isNaN(h)||h<=0)return!0;return!1}},custom:class extends s.Evented{constructor(h,n,a,p){super(),this.id=h,this.type="custom",this._dataType="raster",this._dispatcher=a,this._implementation=n,this.setEventedParent(p),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new s.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new s.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new vn(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),s.extend(this,s.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return s.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(h){this._map=h,this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(h),this.load()}onRemove(h){this._implementation.onRemove&&this._implementation.onRemove(h)}hasTile(h){if(this._implementation.hasTile){const{x:n,y:a,z:p}=h.canonical;return this._implementation.hasTile({x:n,y:a,z:p})}return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,n){const{x:a,y:p,z:_}=h.tileID.canonical,b=new s.window.AbortController;h.request=Promise.resolve(this._implementation.loadTile({x:a,y:p,z:_},{signal:b.signal})).then((function(I){return delete h.request,h.aborted?(h.state="unloaded",n(null)):I===void 0?(h.state="errored",n(null)):I===null?(this.loadTileData(h,{width:this.tileSize,height:this.tileSize,data:null}),h.state="loaded",n(null)):function(M){return M instanceof s.window.ImageData||M instanceof s.window.HTMLCanvasElement||M instanceof s.window.ImageBitmap||M instanceof s.window.HTMLImageElement}(I)?(this.loadTileData(h,I),h.state="loaded",void n(null)):(h.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(I=>{I.code!==20&&(h.state="errored",n(I))}),h.request.cancel=()=>b.abort()}loadTileData(h,n){nt.loadTileData(h,n,this._map.painter)}unloadTileData(h){nt.unloadTileData(h,this._map.painter)}unloadTile(h,n){if(this.unloadTileData(h),this._implementation.unloadTile){const{x:a,y:p,z:_}=h.tileID.canonical;this._implementation.unloadTile({x:a,y:p,z:_})}n()}abortTile(h,n){h.request&&h.request.cancel&&(h.request.cancel(),delete h.request),n()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(h=>({x:h.canonical.x,y:h.canonical.y,z:h.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ui=function(h,n,a,p){const _=new Zt[n.type](h,n,a,p);if(_.id!==h)throw new Error(`Expected Source id to be ${h} instead of ${_.id}`);return s.bindAll(["load","abort","unload","serialize","prepare"],_),_};function hi(h,n){const a=s.identity([]);return s.scale(a,a,[.5*h.width,.5*-h.height,1]),s.translate(a,a,[1,-1,0]),s.multiply(a,a,h.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(a)}function tn(h,n,a,p,_,b,I,M=!1){const P=h.tilesIn(p,I,M);P.sort(Un);const N=[];for(const j of P)N.push({wrappedTileID:j.tile.tileID.wrapped().key,queryResults:j.tile.queryRenderedFeatures(n,a,h._state,j,_,b,hi(h.transform,j.tile.tileID),M)});const z=function(j){const Y={},J={};for(const te of j){const ee=te.queryResults,ie=te.wrappedTileID,V=J[ie]=J[ie]||{};for(const K in ee){const ae=ee[K],le=V[K]=V[K]||{},xe=Y[K]=Y[K]||[];for(const Te of ae)le[Te.featureIndex]||(le[Te.featureIndex]=!0,xe.push(Te))}}return Y}(N);for(const j in z)z[j].forEach(Y=>{const J=Y.feature,te=J.layer;te&&te.type!=="background"&&te.type!=="sky"&&(J.source=te.source,te["source-layer"]&&(J.sourceLayer=te["source-layer"]),J.state=J.id!==void 0?h.getFeatureState(te["source-layer"],J.id):{})});return z}function un(h,n){const a=h.getRenderableIds().map(b=>h.getTileByID(b)),p=[],_={};for(let b=0;b{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[xr]}numActive(){return Object.keys(this.active).length}}let pn;function br(){return pn||(pn=new cn),pn}function al(h,n){const a={};for(const p in h)p!=="ref"&&(a[p]=h[p]);return s.refProperties.forEach(p=>{p in n&&(a[p]=n[p])}),a}function Ns(h){h=h.slice();const n=Object.create(null);for(let a=0;a0?(_-I)/M:0;return this.points[b].mult(1-P).add(this.points[a].mult(P))}}class Fo{constructor(n,a,p){const _=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(n/p),this.yCellCount=Math.ceil(a/p);for(let I=0;Ithis.width||_<0||a>this.height)return!b&&[];const M=[];if(n<=0&&a<=0&&this.width<=p&&this.height<=_){if(b)return!0;for(let P=0;P0:M}_queryCircle(n,a,p,_,b){const I=n-p,M=n+p,P=a-p,N=a+p;if(M<0||I>this.width||N<0||P>this.height)return!_&&[];const z=[];return this._forEachCell(I,P,M,N,this._queryCellCircle,z,{hitTest:_,circle:{x:n,y:a,radius:p},seenUids:{box:{},circle:{}}},b),_?z.length>0:z}query(n,a,p,_,b){return this._query(n,a,p,_,!1,b)}hitTest(n,a,p,_,b){return this._query(n,a,p,_,!0,b)}hitTestCircle(n,a,p,_){return this._queryCircle(n,a,p,!0,_)}_queryCell(n,a,p,_,b,I,M,P){const N=M.seenUids,z=this.boxCells[b];if(z!==null){const Y=this.bboxes;for(const J of z)if(!N.box[J]){N.box[J]=!0;const te=4*J;if(n<=Y[te+2]&&a<=Y[te+3]&&p>=Y[te+0]&&_>=Y[te+1]&&(!P||P(this.boxKeys[J]))){if(M.hitTest)return I.push(!0),!0;I.push({key:this.boxKeys[J],x1:Y[te],y1:Y[te+1],x2:Y[te+2],y2:Y[te+3]})}}}const j=this.circleCells[b];if(j!==null){const Y=this.circles;for(const J of j)if(!N.circle[J]){N.circle[J]=!0;const te=3*J;if(this._circleAndRectCollide(Y[te],Y[te+1],Y[te+2],n,a,p,_)&&(!P||P(this.circleKeys[J]))){if(M.hitTest)return I.push(!0),!0;{const ee=Y[te],ie=Y[te+1],V=Y[te+2];I.push({key:this.circleKeys[J],x1:ee-V,y1:ie-V,x2:ee+V,y2:ie+V})}}}}}_queryCellCircle(n,a,p,_,b,I,M,P){const N=M.circle,z=M.seenUids,j=this.boxCells[b];if(j!==null){const J=this.bboxes;for(const te of j)if(!z.box[te]){z.box[te]=!0;const ee=4*te;if(this._circleAndRectCollide(N.x,N.y,N.radius,J[ee+0],J[ee+1],J[ee+2],J[ee+3])&&(!P||P(this.boxKeys[te])))return I.push(!0),!0}}const Y=this.circleCells[b];if(Y!==null){const J=this.circles;for(const te of Y)if(!z.circle[te]){z.circle[te]=!0;const ee=3*te;if(this._circlesCollide(J[ee],J[ee+1],J[ee+2],N.x,N.y,N.radius)&&(!P||P(this.circleKeys[te])))return I.push(!0),!0}}}_forEachCell(n,a,p,_,b,I,M,P){const N=this._convertToXCellCoord(n),z=this._convertToYCellCoord(a),j=this._convertToXCellCoord(p),Y=this._convertToYCellCoord(_);for(let J=N;J<=j;J++)for(let te=z;te<=Y;te++)if(b.call(this,n,a,p,_,this.xCellCount*te+J,I,M,P))return}_convertToXCellCoord(n){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(n*this.xScale)))}_convertToYCellCoord(n){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(n*this.yScale)))}_circlesCollide(n,a,p,_,b,I){const M=_-n,P=b-a,N=p+I;return N*N>M*M+P*P}_circleAndRectCollide(n,a,p,_,b,I,M){const P=(I-_)/2,N=Math.abs(n-(_+P));if(N>P+p)return!1;const z=(M-b)/2,j=Math.abs(a-(b+z));if(j>z+p)return!1;if(N<=P||j<=z)return!0;const Y=N-P,J=j-z;return Y*Y+J*J<=p*p}}const xn={unknown:0,flipRequired:1,flipNotRequired:2},qr=Math.tan(85*Math.PI/180);function Ge(h,n,a,p,_,b,I){const M=s.create();if(a)if(b.name==="globe"){const P=s.calculateGlobeLabelMatrix(_,n);s.multiply(M,M,P)}else{const P=Oe([],I);M[0]=P[0],M[1]=P[1],M[4]=P[2],M[5]=P[3],p||s.rotateZ(M,M,_.angle)}else s.multiply(M,_.labelPlaneMatrix,h);return M}function nr(h,n,a,p,_,b,I){const M=Ge(h,n,a,p,_,b,I);return b.name==="globe"&&a||(M[2]=M[6]=M[10]=M[14]=0),M}function sn(h,n,a,p,_,b,I){if(a){if(b.name==="globe"){const M=Ge(h,n,a,p,_,b,I);return s.invert(M,M),s.multiply(M,h,M),M}{const M=s.clone(h),P=s.identity([]);return P[0]=I[0],P[1]=I[1],P[4]=I[2],P[5]=I[3],s.multiply(M,M,P),p||s.rotateZ(M,M,-_.angle),M}}return _.glCoordMatrix}function An(h,n,a,p){const _=[h,n,a,1];a?s.transformMat4$1(_,_,p):fi(_,_,p);const b=_[3];return _[0]/=b,_[1]/=b,_[2]/=b,_}function hu(h,n){return Math.min(.5+h/n*.5,1.5)}function Zr(h,n){const a=h[0]/h[3],p=h[1]/h[3];return a>=-n[0]&&a<=n[0]&&p>=-n[1]&&p<=n[1]}function ya(h,n,a,p,_,b,I,M,P,N){const z=a.transform,j=p?h.textSizeData:h.iconSizeData,Y=s.evaluateSizeForZoom(j,a.transform.zoom),J=z.projection.name==="globe",te=[256/a.width*2+1,256/a.height*2+1],ee=p?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;ee.clear();let ie=null;J&&(ie=p?h.text.globeExtVertexArray:h.icon.globeExtVertexArray);const V=h.lineVertexArray,K=p?h.text.placedSymbolArray:h.icon.placedSymbolArray,ae=a.transform.width/a.transform.height;let le,xe=!1;for(let Te=0;TeMath.abs(a)?{useVertical:!0}:h===s.WritingMode.vertical?p>0?{needsFlipping:!0}:null:n!==xn.unknown&&function(_,b){return _===0||Math.abs(b/_)>qr}(a,p)?n===xn.flipRequired?{needsFlipping:!0}:null:a<0?{needsFlipping:!0}:null}function mt(h,n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee,ie,V,K){const ae=n/24,le=h.lineOffsetX*ae,xe=h.lineOffsetY*ae,{lineStartIndex:Te,glyphStartIndex:be,numGlyphs:Ae,segment:ke,writingMode:Ne,flipState:tt}=h,Re=Te+h.lineLength,We=je=>{if(z){const[rt,Ke,st]=je.up,zt=N.length;s.updateGlobeVertexNormal(z,zt+0,rt,Ke,st),s.updateGlobeVertexNormal(z,zt+1,rt,Ke,st),s.updateGlobeVertexNormal(z,zt+2,rt,Ke,st),s.updateGlobeVertexNormal(z,zt+3,rt,Ke,st)}const[et,ze,Ze]=je.point;s.addDynamicAttributes(N,et,ze,Ze,je.angle)};if(Ae>1){const je=ul(ae,M,le,xe,a,j,Y,h,P,b,J,ee,!1,ie,V,K);if(!je)return{notEnoughRoom:!0};if(p&&!a){let[et,ze,Ze]=je.first.point,[rt,Ke,st]=je.last.point;[et,ze]=An(et,ze,Ze,I),[rt,Ke]=An(rt,Ke,st,I);const zt=oo(Ne,tt,(rt-et)*te,Ke-ze);if(h.flipState=zt&&zt.needsFlipping?xn.flipRequired:xn.flipNotRequired,zt)return zt}We(je.first);for(let et=be+1;et0?rt:ci(Y,Ze,et,1,_,void 0,ie,V.canonical),st=oo(Ne,tt,(Ke[0]-et[0])*te,Ke[1]-et[1]);if(h.flipState=st&&st.needsFlipping?xn.flipRequired:xn.flipNotRequired,st)return st}const je=Cn(ae*M.getoffsetX(be),le,xe,a,j,Y,ke,Te,Re,P,b,J,ee,!1,!1,ie,V,K);if(!je)return{notEnoughRoom:!0};We(je)}return{}}function Qt(h,n,a,p,_){const{x:b,y:I,z:M}=p.projectTilePoint(h.x,h.y,n);if(!_)return An(b,I,M,a);const[P,N,z]=_(h);return An(b+P,I+N,M+z,a)}function ci(h,n,a,p,_,b,I,M){const P=Qt(h.sub(n)._unit()._add(h),M,_,I,b);return s.sub(P,a,P),s.normalize(P,P),s.scaleAndAdd(P,a,P,p)}function Cn(h,n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee,ie,V){const K=p?h-n:h+n;let ae=K>0?1:-1,le=0;p&&(ae*=-1,le=Math.PI),ae<0&&(le+=Math.PI);let xe=M+I+(ae>0?0:1)|0,Te=_,be=_,Ae=0,ke=0;const Ne=Math.abs(K),tt=[],Re=[];let We=b,je=We;const et=()=>ci(je,We,be,Ne-Ae+1,z,Y,ee,ie.canonical);for(;Ae+ke<=Ne;){if(xe+=ae,xe=P)return null;if(be=Te,je=We,tt.push(be),J&&Re.push(je),We=new s.Point(N.getx(xe),N.gety(xe)),Te=j[xe],!Te){const jt=Qt(We,ie.canonical,z,ee,Y);Te=jt[3]>0?j[xe]=jt:et()}Ae+=ke,ke=s.distance(be,Te)}te&&Y&&(j[xe]&&(Te=et(),ke=s.distance(be,Te)),j[xe]=Te);const ze=(Ne-Ae)/ke,Ze=We.sub(je)._mult(ze)._add(je),rt=s.sub([],Te,be),Ke=s.scaleAndAdd([],be,rt,ze);let st=[0,0,1],zt=rt[0],Kt=rt[1];if(V&&(st=ee.upVector(ie.canonical,Ze.x,Ze.y),st[0]!==0||st[1]!==0||st[2]!==1)){const jt=[st[2],0,-st[0]],mi=s.cross([],st,jt);s.normalize(jt,jt),s.normalize(mi,mi),zt=s.dot(rt,jt),Kt=s.dot(rt,mi)}if(a){const jt=s.cross([],st,rt);s.normalize(jt,jt),s.scaleAndAdd(Ke,Ke,jt,a*ae)}const Pt=le+Math.atan2(Kt,zt);return tt.push(Ke),J&&Re.push(Ze),{point:Ke,angle:Pt,path:tt,tilePath:Re,up:st}}function zr(h,n){const a=n.length,p=a+4*h;n.resize(p),n.float32.fill(-1/0,4*a,4*p)}function fi(h,n,a){const p=n[0],_=n[1];return h[0]=a[0]*p+a[4]*_+a[12],h[1]=a[1]*p+a[5]*_+a[13],h[3]=a[3]*p+a[7]*_+a[15],h}const dr=100;class Us{constructor(n,a,p=new Fo(n.width+200,n.height+200,25),_=new Fo(n.width+200,n.height+200,25)){this.transform=n,this.grid=p,this.ignoredGrid=_,this.pitchfactor=Math.cos(n._pitch)*n.cameraToCenterDistance,this.screenRightBoundary=n.width+dr,this.screenBottomBoundary=n.height+dr,this.gridRightBoundary=n.width+200,this.gridBottomBoundary=n.height+200,this.fogState=a}placeCollisionBox(n,a,p,_,b,I,M,P){let N=p.projectedAnchorX,z=p.projectedAnchorY,j=p.projectedAnchorZ;const Y=p.elevation,J=p.tileID,te=n.getProjection();if(Y&&J){const[Te,be,Ae]=te.upVector(J.canonical,p.tileAnchorX,p.tileAnchorY),ke=te.upVectorScale(J.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;N+=Te*Y*ke,z+=be*Y*ke,j+=Ae*Y*ke}const ee=this.projectAndGetPerspectiveRatio(M,N,z,j,p.tileID,te.name==="globe"||!!Y||this.transform.pitch>0,te),ie=I*ee.perspectiveRatio,V=(p.x1*a+_.x-p.padding)*ie+ee.point.x,K=(p.y1*a+_.y-p.padding)*ie+ee.point.y,ae=(p.x2*a+_.x+p.padding)*ie+ee.point.x,le=(p.y2*a+_.y+p.padding)*ie+ee.point.y,xe=ee.perspectiveRatio<=.55||ee.occluded;return!this.isInsideGrid(V,K,ae,le)||!b&&this.grid.hitTest(V,K,ae,le,P)||xe?{box:[],offscreen:!1,occluded:ee.occluded}:{box:[V,K,ae,le],offscreen:this.isOffscreen(V,K,ae,le),occluded:!1}}placeCollisionCircles(n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee){const ie=[],V=this.transform.elevation,K=n.getProjection(),ae=V?V.getAtTileOffsetFunc(ee,this.transform.center.lat,this.transform.worldSize,K):null,le=new s.Point(p.tileAnchorX,p.tileAnchorY);let{x:xe,y:Te,z:be}=K.projectTilePoint(le.x,le.y,ee.canonical);if(ae){const[Ze,rt,Ke]=ae(le);xe+=Ze,Te+=rt,be+=Ke}const Ae=K.name==="globe",ke=this.projectAndGetPerspectiveRatio(M,xe,Te,be,ee,Ae||!!V||this.transform.pitch>0,K),{perspectiveRatio:Ne}=ke,tt=(j?I/Ne:I*Ne)/s.ONE_EM,Re=An(xe,Te,be,P),We=ke.signedDistanceFromCamera>0?ul(tt,b,p.lineOffsetX*tt,p.lineOffsetY*tt,!1,Re,le,p,_,P,{},V&&!j?ae:null,j&&!!V,K,ee,j):null;let je=!1,et=!1,ze=!0;if(We&&!ke.occluded){const Ze=.5*J*Ne+te,rt=new s.Point(-100,-100),Ke=new s.Point(this.screenRightBoundary,this.screenBottomBoundary),st=new _a,{first:zt,last:Kt}=We,Pt=zt.path.length;let jt=[];for(let Ot=Pt-1;Ot>=1;Ot--)jt.push(zt.path[Ot]);for(let Ot=1;Ot(ae&&!Ae&&(Bi=ae(FiOt[3]<=0)&&(jt=[]));let di=[];if(jt.length>0){let Ot=1/0,Di=-1/0,Bi=1/0,Fi=-1/0;for(const Ui of jt)Ot=Math.min(Ot,Ui[0]),Bi=Math.min(Bi,Ui[1]),Di=Math.max(Di,Ui[0]),Fi=Math.max(Fi,Ui[1]);Di>=rt.x&&Ot<=Ke.x&&Fi>=rt.y&&Bi<=Ke.y&&(di=[jt.map(Ui=>new s.Point(Ui[0],Ui[1]))],(OtKe.x||BiKe.y)&&(di=s.clipLine(di,rt.x,rt.y,Ke.x,Ke.y)))}for(const Ot of di){st.reset(Ot,.25*Ze);let Di=0;Di=st.length<=.5*Ze?1:Math.ceil(st.paddedLength/mi)+1;for(let Bi=0;Bi0?(s.transformMat4$1(P,P,n),this.fogState&&b&&M.name!=="globe"&&(N=function(Y,J,te,ee,ie,V){const K=V.calculateFogTileMatrix(ie),ae=[J,te,ee];return s.transformMat4(ae,ae,K),Bt(Y,ae,V.pitch,V._fov)}(this.fogState,a,p,_,b.toUnwrapped(),this.transform)>.9)):fi(P,P,n);const z=P[3];return{point:new s.Point((P[0]/z+1)/2*this.transform.width+dr,(-P[1]/z+1)/2*this.transform.height+dr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(M)/z*.5,1.5),signedDistanceFromCamera:z,occluded:I&&P[2]>z||N}}isOffscreen(n,a,p,_){return p=this.screenRightBoundary||_this.screenBottomBoundary}isInsideGrid(n,a,p,_){return p>=0&&n=0&&ap.collisionGroupID===a}}return this.collisionGroups[n]}}function Vs(h,n,a,p,_){const{horizontalAlign:b,verticalAlign:I}=s.getAnchorAlignment(h),M=-(b-.5)*n,P=-(I-.5)*a,N=s.evaluateVariableOffset(h,p);return new s.Point(M+N[0]*_,P+N[1]*_)}function jo(h,n,a,p,_){const b=new s.Point(h,n);return a&&b._rotate(p?_:-_),b}class Yn{constructor(n,a,p,_,b){this.transform=n.clone(),this.projection=n.projection.name,this.collisionIndex=new Us(this.transform,b),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new To(p),this.collisionCircleArrays={},this.prevPlacement=_,_&&(_.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(n,a,p,_){const b=p.getBucket(a),I=p.latestFeatureIndex;if(!b||!I||a.id!==b.layerIds[0])return;const M=b.layers[0].layout,P=p.collisionBoxArray,N=Math.pow(2,this.transform.zoom-p.tileID.overscaledZ),z=p.tileSize/s.EXTENT,j=p.tileID.toUnwrapped();this.transform.setProjection(b.projection);const Y=(J=p.tileID,te=b.getProjection(),ee=this.transform,te.name===this.projection?ee.calculateProjMatrix(J.toUnwrapped()):Eo(ee,te,J));var J,te,ee;const ie=M.get("text-pitch-alignment")==="map",V=M.get("text-rotation-alignment")==="map";a.compileFilter();const K=a.dynamicFilter(),ae=a.dynamicFilterNeedsFeature(),le=this.transform.calculatePixelsToTileUnitsMatrix(p),xe=nr(Y,p.tileID.canonical,ie,V,this.transform,b.getProjection(),le);let Te=null;if(ie){const ke=sn(Y,p.tileID.canonical,ie,V,this.transform,b.getProjection(),le);Te=s.multiply([],this.transform.labelPlaneMatrix,ke)}let be=null;K&&p.latestFeatureIndex&&(be={unwrappedTileID:j,dynamicFilter:K,dynamicFilterNeedsFeature:ae,featureIndex:p.latestFeatureIndex}),this.retainedQueryData[b.bucketInstanceId]=new Ji(b.bucketInstanceId,I,b.sourceLayerIndex,b.index,p.tileID);const Ae={bucket:b,layout:M,posMatrix:Y,textLabelPlaneMatrix:xe,labelToScreenMatrix:Te,clippingData:be,scale:N,textPixelRatio:z,holdingForFade:p.holdingForFade(),collisionBoxArray:P,partiallyEvaluatedTextSize:s.evaluateSizeForZoom(b.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:s.evaluateSizeForZoom(b.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(b.sourceID)};if(_)for(const ke of b.sortKeyRanges){const{sortKey:Ne,symbolInstanceStart:tt,symbolInstanceEnd:Re}=ke;n.push({sortKey:Ne,symbolInstanceStart:tt,symbolInstanceEnd:Re,parameters:Ae})}else n.push({symbolInstanceStart:0,symbolInstanceEnd:b.symbolInstances.length,parameters:Ae})}attemptAnchorPlacement(n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee,ie,V,K){const{textOffset0:ae,textOffset1:le,crossTileID:xe}=Y,Te=[ae,le],be=Vs(n,p,_,Te,b),Ae=this.collisionIndex.placeCollisionBox(te,b,a,jo(be.x,be.y,I,M,this.transform.angle),j,P,N,z.predicate);if(ie){const ke=te.getSymbolInstanceIconSize(K,this.transform.zoom,Y.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(te,ke,ie,jo(be.x,be.y,I,M,this.transform.angle),j,P,N,z.predicate).box.length===0)return}if(Ae.box.length>0){let ke;return this.prevPlacement&&this.prevPlacement.variableOffsets[xe]&&this.prevPlacement.placements[xe]&&this.prevPlacement.placements[xe].text&&(ke=this.prevPlacement.variableOffsets[xe].anchor),this.variableOffsets[xe]={textOffset:Te,width:p,height:_,anchor:n,textScale:b,prevAnchor:ke},this.markUsedJustification(te,n,Y,ee),te.allowVerticalPlacement&&(this.markUsedOrientation(te,ee,Y),this.placedOrientations[xe]=ee),{shift:be,placedGlyphBoxes:Ae}}}placeLayerBucketPart(n,a,p,_){const{bucket:b,layout:I,posMatrix:M,textLabelPlaneMatrix:P,labelToScreenMatrix:N,clippingData:z,textPixelRatio:j,holdingForFade:Y,collisionBoxArray:J,partiallyEvaluatedTextSize:te,partiallyEvaluatedIconSize:ee,collisionGroup:ie}=n.parameters,V=I.get("text-optional"),K=I.get("icon-optional"),ae=I.get("text-allow-overlap"),le=I.get("icon-allow-overlap"),xe=I.get("text-rotation-alignment")==="map",Te=I.get("text-pitch-alignment")==="map",be=I.get("icon-text-fit")!=="none",Ae=I.get("symbol-z-order")==="viewport-y";this.transform.setProjection(b.projection);let ke=ae&&(le||!b.hasIconData()||K),Ne=le&&(ae||!b.hasTextData()||V);!b.collisionArrays&&J&&b.deserializeCollisionBoxes(J),p&&_&&b.updateCollisionDebugBuffers(this.transform.zoom,J);const tt=(Re,We,je)=>{const{crossTileID:et,numVerticalGlyphVertices:ze}=Re;if(z){const on={zoom:this.transform.zoom,pitch:this.transform.pitch};let ji=null;if(z.dynamicFilterNeedsFeature){const ki=this.retainedQueryData[b.bucketInstanceId];ji=z.featureIndex.loadFeature({featureIndex:Re.featureIndex,bucketIndex:ki.bucketIndex,sourceLayerIndex:ki.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,z.dynamicFilter)(on,ji,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new s.Point(Re.tileAnchorX,Re.tileAnchorY),this.transform.calculateDistanceTileData(z.unwrappedTileID)))return this.placements[et]=new js(!1,!1,!1,!0),void a.add(et)}if(a.has(et))return;if(Y)return void(this.placements[et]=new js(!1,!1,!1));let Ze=!1,rt=!1,Ke=!0,st=!1,zt=!1,Kt=null,Pt={box:null,offscreen:null,occluded:null},jt={box:null,offscreen:null,occluded:null},mi=null,di=null,Ot=null,Di=0,Bi=0,Fi=0;je.textFeatureIndex?Di=je.textFeatureIndex:Re.useRuntimeCollisionCircles&&(Di=Re.featureIndex),je.verticalTextFeatureIndex&&(Bi=je.verticalTextFeatureIndex);const Ui=on=>{on.tileID=this.retainedQueryData[b.bucketInstanceId].tileID;const ji=this.transform.elevation;(ji||on.elevation)&&(on.elevation=ji?ji.getAtTileOffset(on.tileID,on.tileAnchorX,on.tileAnchorY):0)},ur=je.textBox;if(ur){Ui(ur);const on=ki=>{let wn=s.WritingMode.horizontal;if(b.allowVerticalPlacement&&!ki&&this.prevPlacement){const gr=this.prevPlacement.placedOrientations[et];gr&&(this.placedOrientations[et]=gr,wn=gr,this.markUsedOrientation(b,wn,Re))}return wn},ji=(ki,wn)=>{if(b.allowVerticalPlacement&&ze>0&&je.verticalTextBox){for(const gr of b.writingModes)if(gr===s.WritingMode.vertical?(Pt=wn(),jt=Pt):Pt=ki(),Pt&&Pt.box&&Pt.box.length)break}else Pt=ki()};if(I.get("text-variable-anchor")){let ki=I.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[et]){const nn=this.prevPlacement.variableOffsets[et];ki.indexOf(nn.anchor)>0&&(ki=ki.filter(kr=>kr!==nn.anchor),ki.unshift(nn.anchor))}const wn=(nn,kr,Au)=>{const ea=b.getSymbolInstanceTextSize(te,Re,this.transform.zoom,We),Al=(nn.x2-nn.x1)*ea+2*nn.padding,Ho=(nn.y2-nn.y1)*ea+2*nn.padding,Ts=be&&!le?kr:null;Ts&&Ui(Ts);let ta={box:[],offscreen:!1,occluded:!1};const Cu=ae?2*ki.length:ki.length;for(let Cl=0;Cl=ki.length,Re,We,b,Au,Ts,te,ee);if(jc&&(ta=jc.placedGlyphBoxes,ta&&ta.box&&ta.box.length)){Ze=!0,Kt=jc.shift;break}}return ta};ji(()=>wn(ur,je.iconBox,s.WritingMode.horizontal),()=>{const nn=je.verticalTextBox;return nn&&Ui(nn),b.allowVerticalPlacement&&!(Pt&&Pt.box&&Pt.box.length)&&ze>0&&nn?wn(nn,je.verticalIconBox,s.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Pt&&(Ze=Pt.box,Ke=Pt.offscreen,st=Pt.occluded);const gr=on(!(!Pt||!Pt.box));if(!Ze&&this.prevPlacement){const nn=this.prevPlacement.variableOffsets[et];nn&&(this.variableOffsets[et]=nn,this.markUsedJustification(b,nn.anchor,Re,gr))}}else{const ki=(wn,gr)=>{const nn=b.getSymbolInstanceTextSize(te,Re,this.transform.zoom,We),kr=this.collisionIndex.placeCollisionBox(b,nn,wn,new s.Point(0,0),ae,j,M,ie.predicate);return kr&&kr.box&&kr.box.length&&(this.markUsedOrientation(b,gr,Re),this.placedOrientations[et]=gr),kr};ji(()=>ki(ur,s.WritingMode.horizontal),()=>{const wn=je.verticalTextBox;return b.allowVerticalPlacement&&ze>0&&wn?(Ui(wn),ki(wn,s.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),on(!!(Pt&&Pt.box&&Pt.box.length))}}if(mi=Pt,Ze=mi&&mi.box&&mi.box.length>0,Ke=mi&&mi.offscreen,st=mi&&mi.occluded,Re.useRuntimeCollisionCircles){const on=b.text.placedSymbolArray.get(Re.centerJustifiedTextSymbolIndex>=0?Re.centerJustifiedTextSymbolIndex:Re.verticalPlacedTextSymbolIndex),ji=s.evaluateSizeForFeature(b.textSizeData,te,on),ki=I.get("text-padding");di=this.collisionIndex.placeCollisionCircles(b,ae,on,b.lineVertexArray,b.glyphOffsetArray,ji,M,P,N,p,Te,ie.predicate,Re.collisionCircleDiameter*ji/s.ONE_EM,ki,this.retainedQueryData[b.bucketInstanceId].tileID),Ze=ae||di.circles.length>0&&!di.collisionDetected,Ke=Ke&&di.offscreen,st=di.occluded}if(je.iconFeatureIndex&&(Fi=je.iconFeatureIndex),je.iconBox){const on=ji=>{Ui(ji);const ki=be&&Kt?jo(Kt.x,Kt.y,xe,Te,this.transform.angle):new s.Point(0,0),wn=b.getSymbolInstanceIconSize(ee,this.transform.zoom,Re.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(b,wn,ji,ki,le,j,M,ie.predicate)};jt&&jt.box&&jt.box.length&&je.verticalIconBox?(Ot=on(je.verticalIconBox),rt=Ot.box.length>0):(Ot=on(je.iconBox),rt=Ot.box.length>0),Ke=Ke&&Ot.offscreen,zt=Ot.occluded}const $n=V||Re.numHorizontalGlyphVertices===0&&ze===0,Jr=K||Re.numIconVertices===0;if($n||Jr?Jr?$n||(rt=rt&&Ze):Ze=rt&&Ze:rt=Ze=rt&&Ze,Ze&&mi&&mi.box&&this.collisionIndex.insertCollisionBox(mi.box,I.get("text-ignore-placement"),b.bucketInstanceId,jt&&jt.box&&Bi?Bi:Di,ie.ID),rt&&Ot&&this.collisionIndex.insertCollisionBox(Ot.box,I.get("icon-ignore-placement"),b.bucketInstanceId,Fi,ie.ID),di&&(Ze&&this.collisionIndex.insertCollisionCircles(di.circles,I.get("text-ignore-placement"),b.bucketInstanceId,Di,ie.ID),p)){const on=b.bucketInstanceId;let ji=this.collisionCircleArrays[on];ji===void 0&&(ji=this.collisionCircleArrays[on]=new Uo);for(let ki=0;ki=0;--We){const je=Re[We];tt(b.symbolInstances.get(je),je,b.collisionArrays[je])}}else for(let Re=n.symbolInstanceStart;Re=0&&(n.text.placedSymbolArray.get(b).crossTileID=j>=0&&b!==j?0:N),I>=0&&(n.text.placedSymbolArray.get(I).crossTileID=j>=0&&I!==j?0:N),M>=0&&(n.text.placedSymbolArray.get(M).crossTileID=j>=0&&M!==j?0:N),P>=0&&(n.text.placedSymbolArray.get(P).crossTileID=j>=0&&P!==j?0:N)}markUsedOrientation(n,a,p){const _=a===s.WritingMode.horizontal||a===s.WritingMode.horizontalOnly?a:0,b=a===s.WritingMode.vertical?a:0,{leftJustifiedTextSymbolIndex:I,centerJustifiedTextSymbolIndex:M,rightJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:N}=p,z=n.text.placedSymbolArray;I>=0&&(z.get(I).placedOrientation=_),M>=0&&(z.get(M).placedOrientation=_),P>=0&&(z.get(P).placedOrientation=_),N>=0&&(z.get(N).placedOrientation=b)}commit(n){this.commitTime=n,this.zoomAtLastRecencyCheck=this.transform.zoom;const a=this.prevPlacement;let p=!1;this.prevZoomAdjustment=a?a.zoomAdjustment(this.transform.zoom):0;const _=a?a.symbolFadeChange(n):1,b=a?a.opacities:{},I=a?a.variableOffsets:{},M=a?a.placedOrientations:{};for(const P in this.placements){const N=this.placements[P],z=b[P];z?(this.opacities[P]=new Xr(z,_,N.text,N.icon,null,N.clipped),p=p||N.text!==z.text.placed||N.icon!==z.icon.placed):(this.opacities[P]=new Xr(null,_,N.text,N.icon,N.skipFade,N.clipped),p=p||N.text||N.icon)}for(const P in b){const N=b[P];if(!this.opacities[P]){const z=new Xr(N,_,!1,!1);z.isHidden()||(this.opacities[P]=z,p=p||N.text.placed||N.icon.placed)}}for(const P in I)this.variableOffsets[P]||!this.opacities[P]||this.opacities[P].isHidden()||(this.variableOffsets[P]=I[P]);for(const P in M)this.placedOrientations[P]||!this.opacities[P]||this.opacities[P].isHidden()||(this.placedOrientations[P]=M[P]);p?this.lastPlacementChangeTime=n:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=a?a.lastPlacementChangeTime:n)}updateLayerOpacities(n,a){const p=new Set;for(const _ of a){const b=_.getBucket(n);b&&_.latestFeatureIndex&&n.id===b.layerIds[0]&&this.updateBucketOpacities(b,p,_.collisionBoxArray)}}updateBucketOpacities(n,a,p){n.hasTextData()&&n.text.opacityVertexArray.clear(),n.hasIconData()&&n.icon.opacityVertexArray.clear(),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexArray.clear(),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexArray.clear();const _=n.layers[0].layout,b=!!n.layers[0].dynamicFilter(),I=new Xr(null,0,!1,!1,!0),M=_.get("text-allow-overlap"),P=_.get("icon-allow-overlap"),N=_.get("text-variable-anchor"),z=_.get("text-rotation-alignment")==="map",j=_.get("text-pitch-alignment")==="map",Y=_.get("icon-text-fit")!=="none",J=new Xr(null,0,M&&(P||!n.hasIconData()||_.get("icon-optional")),P&&(M||!n.hasTextData()||_.get("text-optional")),!0);!n.collisionArrays&&p&&(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData())&&n.deserializeCollisionBoxes(p);const te=(ie,V,K)=>{for(let ae=0;ae0||ae>0,ke=xe>0,Ne=this.placedOrientations[le],tt=Ne===s.WritingMode.vertical,Re=Ne===s.WritingMode.horizontal||Ne===s.WritingMode.horizontalOnly;if(!Ae&&!ke||be.isHidden()||ee++,Ae){const We=Ei(be.text);te(n.text,K,tt?Li:We),te(n.text,ae,Re?Li:We);const je=be.text.isHidden(),{leftJustifiedTextSymbolIndex:et,centerJustifiedTextSymbolIndex:ze,rightJustifiedTextSymbolIndex:Ze,verticalPlacedTextSymbolIndex:rt}=V,Ke=n.text.placedSymbolArray,st=je||tt?1:0;et>=0&&(Ke.get(et).hidden=st),ze>=0&&(Ke.get(ze).hidden=st),Ze>=0&&(Ke.get(Ze).hidden=st),rt>=0&&(Ke.get(rt).hidden=je||Re?1:0);const zt=this.variableOffsets[le];zt&&this.markUsedJustification(n,zt.anchor,V,Ne);const Kt=this.placedOrientations[le];Kt&&(this.markUsedJustification(n,"left",V,Kt),this.markUsedOrientation(n,Kt,V))}if(ke){const We=Ei(be.icon),{placedIconSymbolIndex:je,verticalPlacedIconSymbolIndex:et}=V,ze=n.icon.placedSymbolArray,Ze=be.icon.isHidden()?1:0;je>=0&&(te(n.icon,xe,tt?Li:We),ze.get(je).hidden=Ze),et>=0&&(te(n.icon,V.numVerticalIconVertices,Re?Li:We),ze.get(et).hidden=Ze)}if(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData()){const We=n.collisionArrays[ie];if(We){let je=new s.Point(0,0),et=!0;if(We.textBox||We.verticalTextBox){if(N){const Ze=this.variableOffsets[le];Ze?(je=Vs(Ze.anchor,Ze.width,Ze.height,Ze.textOffset,Ze.textScale),z&&je._rotate(j?this.transform.angle:-this.transform.angle)):et=!1}b&&(et=!be.clipped),We.textBox&&On(n.textCollisionBox.collisionVertexArray,be.text.placed,!et||tt,je.x,je.y),We.verticalTextBox&&On(n.textCollisionBox.collisionVertexArray,be.text.placed,!et||Re,je.x,je.y)}const ze=et&&!!(!Re&&We.verticalIconBox);We.iconBox&&On(n.iconCollisionBox.collisionVertexArray,be.icon.placed,ze,Y?je.x:0,Y?je.y:0),We.verticalIconBox&&On(n.iconCollisionBox.collisionVertexArray,be.icon.placed,!ze,Y?je.x:0,Y?je.y:0)}}}if(n.fullyClipped=ee===0,n.sortFeatures(this.transform.angle),this.retainedQueryData[n.bucketInstanceId]&&(this.retainedQueryData[n.bucketInstanceId].featureSortOrder=n.featureSortOrder),n.hasTextData()&&n.text.opacityVertexBuffer&&n.text.opacityVertexBuffer.updateData(n.text.opacityVertexArray),n.hasIconData()&&n.icon.opacityVertexBuffer&&n.icon.opacityVertexBuffer.updateData(n.icon.opacityVertexArray),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexBuffer&&n.iconCollisionBox.collisionVertexBuffer.updateData(n.iconCollisionBox.collisionVertexArray),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexBuffer&&n.textCollisionBox.collisionVertexBuffer.updateData(n.textCollisionBox.collisionVertexArray),n.bucketInstanceId in this.collisionCircleArrays){const ie=this.collisionCircleArrays[n.bucketInstanceId];n.placementInvProjMatrix=ie.invProjMatrix,n.placementViewportMatrix=ie.viewportMatrix,n.collisionCircleArray=ie.circles,delete this.collisionCircleArrays[n.bucketInstanceId]}}symbolFadeChange(n){return this.fadeDuration===0?1:(n-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(n){return Math.max(0,(this.transform.zoom-n)/1.5)}hasTransitions(n){return this.stale||n-this.lastPlacementChangeTimen}setStale(){this.stale=!0}}function On(h,n,a,p,_){h.emplaceBack(n?1:0,a?1:0,p||0,_||0),h.emplaceBack(n?1:0,a?1:0,p||0,_||0),h.emplaceBack(n?1:0,a?1:0,p||0,_||0),h.emplaceBack(n?1:0,a?1:0,p||0,_||0)}const zn=Math.pow(2,25),hn=Math.pow(2,24),cl=Math.pow(2,17),va=Math.pow(2,16),Nn=Math.pow(2,9),wr=Math.pow(2,8),hl=Math.pow(2,1);function Ei(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const n=h.placed?1:0,a=Math.floor(127*h.opacity);return a*zn+n*hn+a*cl+n*va+a*Nn+n*wr+a*hl+n}const Li=0;class Vo{constructor(n){this._sortAcrossTiles=n.layout.get("symbol-z-order")!=="viewport-y"&&n.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(n,a,p,_,b){const I=this._bucketParts;for(;this._currentTileIndexM.sortKey-P.sortKey));this._currentPartIndex{const I=s.exported.now()-_;return!this._forceFullPlacement&&I>2};for(;this._currentPlacementIndex>=0;){const I=a[n[this._currentPlacementIndex]],M=this.placement.collisionIndex.transform.zoom;if(I.type==="symbol"&&(!I.minzoom||I.minzoom<=M)&&(!I.maxzoom||I.maxzoom>M)){if(this._inProgressLayer||(this._inProgressLayer=new Vo(I)),this._inProgressLayer.continuePlacement(p[I.source],this.placement,this._showCollisionBoxes,I,b))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(n){return this.placement.commit(n),this.placement}}const Nr=512/s.EXTENT/2;class Pn{constructor(n,a,p){this.tileID=n,this.bucketInstanceId=p,this.index=new s.KDBush(a.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const _=n.canonical.x*s.EXTENT,b=n.canonical.y*s.EXTENT;for(let I=0;In.overscaledZ)for(const M in I){const P=I[M];P.tileID.isChildOf(n)&&P.findMatches(a.symbolInstances,n,_)}else{const M=I[n.scaledTo(Number(b)).key];M&&M.findMatches(a.symbolInstances,n,_)}}for(let b=0;b{a[p]=!0});for(const p in this.layerIndexes)a[p]||delete this.layerIndexes[p]}}const so=(h,n)=>s.emitValidationErrors(h,n&&n.filter(a=>a.identifier!=="source.canvas")),Gs=s.pick(xi,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),vc=s.pick(xi,["setCenter","setZoom","setBearing","setPitch"]),wa={version:8,layers:[],sources:{}},rr={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class mr extends s.Evented{constructor(n,a={}){super(),this.map=n,this.dispatcher=new St(br(),this),this.imageManager=new ti,this.imageManager.setEventedParent(this),this.glyphManager=new s.GlyphManager(n._requestManager,a.localFontFamily?s.LocalGlyphMode.all:a.localIdeographFontFamily?s.LocalGlyphMode.ideographs:s.LocalGlyphMode.none,a.localFontFamily||a.localIdeographFontFamily),this.crossTileSymbolIndex=new Br,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.getReferrer());const p=this;this._rtlTextPluginCallback=mr.registerForPluginStateChange(_=>{p.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:_.pluginStatus,pluginURL:_.pluginURL},(b,I)=>{if(s.triggerPluginCompletionEvent(b),I&&I.every(M=>M))for(const M in p._sourceCaches){const P=p._sourceCaches[M],N=P.getSource().type;N!=="vector"&&N!=="geojson"||P.reload()}})}),this.on("data",_=>{if(_.dataType!=="source"||_.sourceDataType!=="metadata")return;const b=this.getSource(_.sourceId);if(b&&b.vectorLayerIds)for(const I in this._layers){const M=this._layers[I];M.source===b.id&&this._validateLayer(M)}})}loadURL(n,a={}){this.fire(new s.Event("dataloading",{dataType:"style"}));const p=typeof a.validate=="boolean"?a.validate:!s.isMapboxURL(n);n=this.map._requestManager.normalizeStyleURL(n,a.accessToken);const _=this.map._requestManager.transformRequest(n,s.ResourceType.Style);this._request=s.getJSON(_,(b,I)=>{this._request=null,b?this.fire(new s.ErrorEvent(b)):I&&this._load(I,p)})}loadJSON(n,a={}){this.fire(new s.Event("dataloading",{dataType:"style"})),this._request=s.exported.frame(()=>{this._request=null,this._load(n,a.validate!==!1)})}loadEmpty(){this.fire(new s.Event("dataloading",{dataType:"style"})),this._load(wa,!1)}_updateLayerCount(n,a){const p=a?1:-1;n.is3D()&&(this._num3DLayers+=p),n.type==="circle"&&(this._numCircleLayers+=p),n.type==="symbol"&&(this._numSymbolLayers+=p)}_load(n,a){if(a&&so(this,s.validateStyle(n)))return;this._loaded=!0,this.stylesheet=s.clone$1(n),this._updateMapProjection();for(const _ in n.sources)this.addSource(_,n.sources[_],{validate:!1});this._changed=!1,n.sprite?this._loadSprite(n.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(n.glyphs);const p=Ns(this.stylesheet.layers);this._order=p.map(_=>_.id),this._layers={},this._serializedLayers={};for(const _ of p){const b=s.createStyleLayer(_);b.setEventedParent(this,{layer:{id:b.id}}),this._layers[b.id]=b,this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Xt(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new s.Event("data",{dataType:"style"})),this.fire(new s.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(n){n?this.stylesheet.projection=n:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(n){this._spriteRequest=function(a,p,_){let b,I,M;const P=s.exported.devicePixelRatio>1?"@2x":"";let N=s.getJSON(p.transformRequest(p.normalizeSpriteURL(a,P,".json"),s.ResourceType.SpriteJSON),(Y,J)=>{N=null,M||(M=Y,b=J,j())}),z=s.getImage(p.transformRequest(p.normalizeSpriteURL(a,P,".png"),s.ResourceType.SpriteImage),(Y,J)=>{z=null,M||(M=Y,I=J,j())});function j(){if(M)_(M);else if(b&&I){const Y=s.exported.getImageData(I),J={};for(const te in b){const{width:ee,height:ie,x:V,y:K,sdf:ae,pixelRatio:le,stretchX:xe,stretchY:Te,content:be}=b[te],Ae=new s.RGBAImage({width:ee,height:ie});s.RGBAImage.copy(Y,Ae,{x:V,y:K},{x:0,y:0},{width:ee,height:ie}),J[te]={data:Ae,pixelRatio:le,sdf:ae,stretchX:xe,stretchY:Te,content:be}}_(null,J)}}return{cancel(){N&&(N.cancel(),N=null),z&&(z.cancel(),z=null)}}}(n,this.map._requestManager,(a,p)=>{if(this._spriteRequest=null,a)this.fire(new s.ErrorEvent(a));else if(p)for(const _ in p)this.imageManager.addImage(_,p[_]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new s.Event("data",{dataType:"style"}))})}_validateLayer(n){const a=this.getSource(n.source);if(!a)return;const p=n.sourceLayer;p&&(a.type==="geojson"||a.vectorLayerIds&&a.vectorLayerIds.indexOf(p)===-1)&&this.fire(new s.ErrorEvent(new Error(`Source layer "${p}" does not exist on source "${a.id}" as specified by style layer "${n.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const n in this._sourceCaches)if(!this._sourceCaches[n].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(n){const a=[];for(const p of n){const _=this._layers[p];_.type!=="custom"&&a.push(_.serialize())}return a}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const n in this._sourceCaches)if(this._sourceCaches[n].hasTransition())return!0;for(const n in this._layers)if(this._layers[n].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(n){return!!this.terrain&&(typeof n.isLayerDraped=="function"?n.isLayerDraped():rr[n.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(n){if(!this._loaded)return;const a=this._changed;if(this._changed){const _=Object.keys(this._updatedLayers),b=Object.keys(this._removedLayers);(_.length||b.length)&&this._updateWorkerLayers(_,b);for(const I in this._updatedSources){const M=this._updatedSources[I];M==="reload"?this._reloadSource(I):M==="clear"&&this._clearSource(I)}this._updateTilesForChangedImages();for(const I in this._updatedPaintProps)this._layers[I].updateTransitions(n);this.light.updateTransitions(n),this.fog&&this.fog.updateTransitions(n),this._resetUpdates()}const p={};for(const _ in this._sourceCaches){const b=this._sourceCaches[_];p[_]=b.used,b.used=!1}for(const _ of this._order){const b=this._layers[_];if(b.recalculate(n,this._availableImages),!b.isHidden(n.zoom)){const M=this._getLayerSourceCache(b);M&&(M.used=!0)}const I=this.map.painter;if(I){const M=b.getProgramIds();if(!M)continue;const P=b.getProgramConfiguration(n.zoom);for(const N of M)I.useProgram(N,P)}}for(const _ in p){const b=this._sourceCaches[_];p[_]!==b.used&&b.getSource().fire(new s.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(n),this.terrain&&this.terrain.recalculate(n),this.fog&&this.fog.recalculate(n),this.z=n.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),a&&this.fire(new s.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const n=Object.keys(this._changedImages);if(n.length){for(const a in this._sourceCaches)this._sourceCaches[a].reloadTilesForDependencies(["icons","patterns"],n);this._changedImages={}}}_updateWorkerLayers(n,a){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(n),removedIds:a})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),so(this,s.validateStyle(n)))return!1;(n=s.clone$1(n)).layers=Ns(n.layers);const a=function(_,b){if(!_)return[{command:xi.setStyle,args:[b]}];let I=[];try{if(!Z(_.version,b.version))return[{command:xi.setStyle,args:[b]}];Z(_.center,b.center)||I.push({command:xi.setCenter,args:[b.center]}),Z(_.zoom,b.zoom)||I.push({command:xi.setZoom,args:[b.zoom]}),Z(_.bearing,b.bearing)||I.push({command:xi.setBearing,args:[b.bearing]}),Z(_.pitch,b.pitch)||I.push({command:xi.setPitch,args:[b.pitch]}),Z(_.sprite,b.sprite)||I.push({command:xi.setSprite,args:[b.sprite]}),Z(_.glyphs,b.glyphs)||I.push({command:xi.setGlyphs,args:[b.glyphs]}),Z(_.transition,b.transition)||I.push({command:xi.setTransition,args:[b.transition]}),Z(_.light,b.light)||I.push({command:xi.setLight,args:[b.light]}),Z(_.fog,b.fog)||I.push({command:xi.setFog,args:[b.fog]}),Z(_.projection,b.projection)||I.push({command:xi.setProjection,args:[b.projection]});const M={},P=[];(function(j,Y,J,te){let ee;for(ee in Y=Y||{},j=j||{})j.hasOwnProperty(ee)&&(Y.hasOwnProperty(ee)||Bs(ee,J,te));for(ee in Y){if(!Y.hasOwnProperty(ee))continue;const ie=Y[ee];j.hasOwnProperty(ee)?Z(j[ee],ie)||(j[ee].type==="geojson"&&ie.type==="geojson"&&Bo(j,Y,ee)?J.push({command:xi.setGeoJSONSourceData,args:[ee,ie.data]}):ll(ee,Y,J,te)):dn(ee,Y,J)}})(_.sources,b.sources,P,M);const N=[];_.layers&&_.layers.forEach(j=>{j.source&&M[j.source]?I.push({command:xi.removeLayer,args:[j.id]}):N.push(j)});let z=_.terrain;z&&M[z.source]&&(I.push({command:xi.setTerrain,args:[void 0]}),z=void 0),I=I.concat(P),Z(z,b.terrain)||I.push({command:xi.setTerrain,args:[b.terrain]}),function(j,Y,J){Y=Y||[];const te=(j=j||[]).map(Or),ee=Y.map(Or),ie=j.reduce(Fs,{}),V=Y.reduce(Fs,{}),K=te.slice(),ae=Object.create(null);let le,xe,Te,be,Ae,ke,Ne;for(le=0,xe=0;le!(_.command in vc));if(a.length===0)return!1;const p=a.filter(_=>!(_.command in Gs));if(p.length>0)throw new Error(`Unimplemented: ${p.map(_=>_.command).join(", ")}.`);return a.forEach(_=>{_.command!=="setTransition"&&_.command!=="setProjection"&&this[_.command].apply(this,_.args)}),this.stylesheet=n,this._updateMapProjection(),!0}addImage(n,a){return this.getImage(n)?this.fire(new s.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(n,a),this._afterImageUpdated(n),this)}updateImage(n,a){this.imageManager.updateImage(n,a)}getImage(n){return this.imageManager.getImage(n)}removeImage(n){return this.getImage(n)?(this.imageManager.removeImage(n),this._afterImageUpdated(n),this):this.fire(new s.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(n){this._availableImages=this.imageManager.listImages(),this._changedImages[n]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(n,a,p={}){if(this._checkLoaded(),this.getSource(n)!==void 0)throw new Error("There is already a source with this ID");if(!a.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(a).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(a.type)>=0&&this._validate(s.validateSource,`sources.${n}`,a,null,p))return;this.map&&this.map._collectResourceTiming&&(a.collectResourceTiming=!0);const _=ui(n,a,this.dispatcher,this);_.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(n),source:_.serialize(),sourceId:n}));const b=I=>{const M=(I?"symbol:":"other:")+n,P=this._sourceCaches[M]=new s.SourceCache(M,_,I);(I?this._symbolSourceCaches:this._otherSourceCaches)[n]=P,P.style=this,P.onAdd(this.map)};b(!1),a.type!=="vector"&&a.type!=="geojson"||b(!0),_.onAdd&&_.onAdd(this.map),this._changed=!0}removeSource(n){this._checkLoaded();const a=this.getSource(n);if(!a)throw new Error("There is no source with this ID");for(const _ in this._layers)if(this._layers[_].source===n)return this.fire(new s.ErrorEvent(new Error(`Source "${n}" cannot be removed while layer "${_}" is using it.`)));if(this.terrain&&this.terrain.get().source===n)return this.fire(new s.ErrorEvent(new Error(`Source "${n}" cannot be removed while terrain is using it.`)));const p=this._getSourceCaches(n);for(const _ of p)delete this._sourceCaches[_.id],delete this._updatedSources[_.id],_.fire(new s.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:_.getSource().id})),_.setEventedParent(null),_.clearTiles();return delete this._otherSourceCaches[n],delete this._symbolSourceCaches[n],a.setEventedParent(null),a.onRemove&&a.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(n,a){this._checkLoaded(),this.getSource(n).setData(a),this._changed=!0}getSource(n){const a=this._getSourceCache(n);return a&&a.getSource()}_getSources(){const n=[];for(const a in this._otherSourceCaches){const p=this._getSourceCache(a);p&&n.push(p.getSource())}return n}addLayer(n,a,p={}){this._checkLoaded();const _=n.id;if(this.getLayer(_))return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${_}" already exists on this map`)));let b;if(n.type==="custom"){if(so(this,s.validateCustomStyleLayer(n)))return;b=s.createStyleLayer(n)}else{if(typeof n.source=="object"&&(this.addSource(_,n.source),n=s.clone$1(n),n=s.extend(n,{source:_})),this._validate(s.validateLayer,`layers.${_}`,n,{arrayIndex:-1},p))return;b=s.createStyleLayer(n),this._validateLayer(b),b.setEventedParent(this,{layer:{id:_}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const I=a?this._order.indexOf(a):this._order.length;if(a&&I===-1)return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${a}" does not exist on this map.`)));this._order.splice(I,0,_),this._layerOrderChanged=!0,this._layers[_]=b;const M=this._getLayerSourceCache(b);if(this._removedLayers[_]&&b.source&&M&&b.type!=="custom"){const P=this._removedLayers[_];delete this._removedLayers[_],P.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",M.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(n,a){if(this._checkLoaded(),this._changed=!0,!this._layers[n])return void this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be moved.`)));if(n===a)return;const p=this._order.indexOf(n);this._order.splice(p,1);const _=a?this._order.indexOf(a):this._order.length;a&&_===-1?this.fire(new s.ErrorEvent(new Error(`Layer with id "${a}" does not exist on this map.`))):(this._order.splice(_,0,n),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(n){this._checkLoaded();const a=this._layers[n];if(!a)return void this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be removed.`)));a.setEventedParent(null),this._updateLayerCount(a,!1);const p=this._order.indexOf(n);this._order.splice(p,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[n]=a,delete this._layers[n],delete this._serializedLayers[n],delete this._updatedLayers[n],delete this._updatedPaintProps[n],a.onRemove&&a.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(n){return this._layers[n]}hasLayer(n){return n in this._layers}hasLayerType(n){for(const a in this._layers)if(this._layers[a].type===n)return!0;return!1}setLayerZoomRange(n,a,p){this._checkLoaded();const _=this.getLayer(n);_?_.minzoom===a&&_.maxzoom===p||(a!=null&&(_.minzoom=a),p!=null&&(_.maxzoom=p),this._updateLayer(_)):this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,a,p={}){this._checkLoaded();const _=this.getLayer(n);if(_){if(!Z(_.filter,a))return a==null?(_.filter=void 0,void this._updateLayer(_)):void(this._validate(s.validateFilter,`layers.${_.id}.filter`,a,{layerType:_.type},p)||(_.filter=s.clone$1(a),this._updateLayer(_)))}else this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(n){const a=this.getLayer(n);return a&&s.clone$1(a.filter)}setLayoutProperty(n,a,p,_={}){this._checkLoaded();const b=this.getLayer(n);b?Z(b.getLayoutProperty(a),p)||(b.setLayoutProperty(a,p,_),this._updateLayer(b)):this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(n,a){const p=this.getLayer(n);if(p)return p.getLayoutProperty(a);this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style.`)))}setPaintProperty(n,a,p,_={}){this._checkLoaded();const b=this.getLayer(n);b?Z(b.getPaintProperty(a),p)||(b.setPaintProperty(a,p,_)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new s.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(n,a){const p=this.getLayer(n);return p&&p.getPaintProperty(a)}setFeatureState(n,a){this._checkLoaded();const p=n.source,_=n.sourceLayer,b=this.getSource(p);if(!b)return void this.fire(new s.ErrorEvent(new Error(`The source '${p}' does not exist in the map's style.`)));const I=b.type;if(I==="geojson"&&_)return void this.fire(new s.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(I==="vector"&&!_)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));n.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided.")));const M=this._getSourceCaches(p);for(const P of M)P.setFeatureState(_,n.id,a)}removeFeatureState(n,a){this._checkLoaded();const p=n.source,_=this.getSource(p);if(!_)return void this.fire(new s.ErrorEvent(new Error(`The source '${p}' does not exist in the map's style.`)));const b=_.type,I=b==="vector"?n.sourceLayer:void 0;if(b==="vector"&&!I)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(a&&typeof n.id!="string"&&typeof n.id!="number")return void this.fire(new s.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const M=this._getSourceCaches(p);for(const P of M)P.removeFeatureState(I,n.id,a)}getFeatureState(n){this._checkLoaded();const a=n.source,p=n.sourceLayer,_=this.getSource(a);if(_){if(_.type!=="vector"||p)return n.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(a)[0].getFeatureState(p,n.id);this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new s.ErrorEvent(new Error(`The source '${a}' does not exist in the map's style.`)))}getTransition(){return s.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const n={};for(const a in this._sourceCaches){const p=this._sourceCaches[a].getSource();n[p.id]||(n[p.id]=p.serialize())}return s.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:n,layers:this._serializeLayers(this._order)},a=>a!==void 0)}_updateLayer(n){this._updatedLayers[n.id]=!0;const a=this._getLayerSourceCache(n);n.source&&!this._updatedSources[n.source]&&a&&a.getSource().type!=="raster"&&(this._updatedSources[n.source]="reload",a.pause()),this._changed=!0,n.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(n){const a=I=>this._layers[I].type==="fill-extrusion",p={},_=[];for(let I=this._order.length-1;I>=0;I--){const M=this._order[I];if(a(M)){p[M]=I;for(const P of n){const N=P[M];if(N)for(const z of N)_.push(z)}}}_.sort((I,M)=>M.intersectionZ-I.intersectionZ);const b=[];for(let I=this._order.length-1;I>=0;I--){const M=this._order[I];if(a(M))for(let P=_.length-1;P>=0;P--){const N=_[P].feature;if(p[N.layer.id]{const N=this.getLayer(P);return N&&N.is3D()}):this.has3DLayers(),M=Oi.createFromScreenPoints(n,p);for(const P in this._sourceCaches){const N=this._sourceCaches[P].getSource().id;a.layers&&!_[N]||b.push(tn(this._sourceCaches[P],this._layers,this._serializedLayers,M,a,p,I,!!this.map._showQueryGeometry))}return this.placement&&b.push(function(P,N,z,j,Y,J,te){const ee={},ie=J.queryRenderedSymbols(j),V=[];for(const K of Object.keys(ie).map(Number))V.push(te[K]);V.sort(Un);for(const K of V){const ae=K.featureIndex.lookupSymbolFeatures(ie[K.bucketInstanceId],N,K.bucketIndex,K.sourceLayerIndex,Y.filter,Y.layers,Y.availableImages,P);for(const le in ae){const xe=ee[le]=ee[le]||[],Te=ae[le];Te.sort((be,Ae)=>{const ke=K.featureSortOrder;if(ke){const Ne=ke.indexOf(be.featureIndex);return ke.indexOf(Ae.featureIndex)-Ne}return Ae.featureIndex-be.featureIndex});for(const be of Te)xe.push(be)}}for(const K in ee)ee[K].forEach(ae=>{const le=ae.feature,xe=z(P[K]);if(!xe)return;const Te=xe.getFeatureState(le.layer["source-layer"],le.id);le.source=le.layer.source,le.layer["source-layer"]&&(le.sourceLayer=le.layer["source-layer"]),le.state=Te});return ee}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),M.screenGeometry,a,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(b)}querySourceFeatures(n,a){a&&a.filter&&this._validate(s.validateFilter,"querySourceFeatures.filter",a.filter,null,a);const p=this._getSourceCaches(n);let _=[];for(const b of p)_=_.concat(un(b,a));return _}addSourceType(n,a,p){return mr.getSourceType(n)?p(new Error(`A source type called "${n}" already exists.`)):(mr.setSourceType(n,a),a.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:n,url:a.workerSourceURL},p):p(null,null))}getLight(){return this.light.getLight()}setLight(n,a={}){this._checkLoaded();const p=this.light.getLight();let _=!1;for(const I in n)if(!Z(n[I],p[I])){_=!0;break}if(!_)return;const b=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(n,a),this.light.updateTransitions(b)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,a=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let p=n;if(a===1){if(typeof p.source=="object"){const _="terrain-dem-src";this.addSource(_,p.source),p=s.clone$1(p),p=s.extend(p,{source:_})}if(this._validate(s.validateTerrain,"terrain",p))return}if(!this.terrain||this.terrain&&a!==this.terrain.drapeRenderMode){if(!p)return;this._createTerrain(p,a)}else{const _=this.terrain,b=_.get();for(const I of Object.keys(s.spec.terrain))!p.hasOwnProperty(I)&&s.spec.terrain[I].default&&(p[I]=s.spec.terrain[I].default);for(const I in p)if(!Z(p[I],b[I])){_.set(p),this.stylesheet.terrain=p;const M=this._setTransitionParameters({duration:0});_.updateTransitions(M);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(n){const a=this.fog=new pi(n,this.map.transform);this.stylesheet.fog=n;const p=this._setTransitionParameters({duration:0});a.updateTransitions(p)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const n of this.map._markers)n._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(n){if(this._checkLoaded(),!n)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const a=this.fog,p=a.get();Object.keys(n).length===0&&a.set(n);for(const _ in n)if(!Z(n[_],p[_])){a.set(n),this.stylesheet.fog=n;const b=this._setTransitionParameters({duration:0});a.updateTransitions(b);break}}else this._createFog(n);this._markersNeedUpdate=!0}_setTransitionParameters(n){return{now:s.exported.now(),transition:s.extend(n,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const n=this._order.filter(p=>this.isLayerDraped(this._layers[p])),a=this._order.filter(p=>!this.isLayerDraped(this._layers[p]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...n),this._drapedFirstOrder.push(...a)}_createTerrain(n,a){const p=this.terrain=new Jt(n,a);this.stylesheet.terrain=n,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const _=this._setTransitionParameters({duration:0});p.updateTransitions(_)}_force3DLayerUpdate(){for(const n in this._layers){const a=this._layers[n];a.type==="fill-extrusion"&&this._updateLayer(a)}}_forceSymbolLayerUpdate(){for(const n in this._layers){const a=this._layers[n];a.type==="symbol"&&this._updateLayer(a)}}_validate(n,a,p,_,b={}){return(!b||b.validate!==!1)&&so(this,n.call(s.validateStyle,s.extend({key:a,style:this.serialize(),value:p,styleSpec:s.spec},_)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(n){const a=this._getSourceCaches(n);for(const p of a)p.clearTiles()}_reloadSource(n){const a=this._getSourceCaches(n);for(const p of a)p.resume(),p.reload()}_reloadSources(){for(const n of this._getSources())n.reload&&n.reload()}_updateSources(n){for(const a in this._sourceCaches)this._sourceCaches[a].update(n)}_generateCollisionBoxes(){for(const n in this._sourceCaches){const a=this._sourceCaches[n];a.resume(),a.reload()}}_updatePlacement(n,a,p,_,b=!1){let I=!1,M=!1;const P={};for(const N of this._order){const z=this._layers[N];if(z.type!=="symbol")continue;if(!P[z.source]){const Y=this._getLayerSourceCache(z);if(!Y)continue;P[z.source]=Y.getRenderableIds(!0).map(J=>Y.getTileByID(J)).sort((J,te)=>te.tileID.overscaledZ-J.tileID.overscaledZ||(J.tileID.isLessThan(te.tileID)?-1:1))}const j=this.crossTileSymbolIndex.addLayer(z,P[z.source],n.center.lng,n.projection);I=I||j}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),b=b||this._layerOrderChanged||p===0,this._layerOrderChanged&&this.fire(new s.Event("neworder")),(b||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.exported.now(),n.zoom))&&(this.pauseablePlacement=new xa(n,this._order,b,a,p,_,this.placement,this.fog&&n.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,P),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.exported.now()),M=!0),I&&this.pauseablePlacement.placement.setStale()),M||I)for(const N of this._order){const z=this._layers[N];z.type==="symbol"&&this.placement.updateLayerOpacities(z,P[z.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.exported.now())}_releaseSymbolFadeTiles(){for(const n in this._sourceCaches)this._sourceCaches[n].releaseSymbolFadeTiles()}getImages(n,a,p){this.imageManager.getImages(a.icons,p),this._updateTilesForChangedImages();const _=b=>{b&&b.setDependencies(a.tileID.key,a.type,a.icons)};_(this._otherSourceCaches[a.source]),_(this._symbolSourceCaches[a.source])}getGlyphs(n,a,p){this.glyphManager.getGlyphs(a.stacks,p)}getResource(n,a,p){return s.makeRequest(a,p)}_getSourceCache(n){return this._otherSourceCaches[n]}_getLayerSourceCache(n){return n.type==="symbol"?this._symbolSourceCaches[n.source]:this._otherSourceCaches[n.source]}_getSourceCaches(n){const a=[];return this._otherSourceCaches[n]&&a.push(this._otherSourceCaches[n]),this._symbolSourceCaches[n]&&a.push(this._symbolSourceCaches[n]),a}_isSourceCacheLoaded(n){const a=this._getSourceCaches(n);return a.length===0?(this.fire(new s.ErrorEvent(new Error(`There is no source with ID '${n}'`))),!1):a.every(p=>p.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}mr.getSourceType=function(h){return Zt[h]},mr.setSourceType=function(h,n){Zt[h]=n},mr.registerForPluginStateChange=s.registerForPluginStateChange;var fl=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #define EXTENT 8192.0 #define HALF_PI PI/2.0 #define QUARTER_PI PI/4.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0`,Ln="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",or=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt) {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifdef TERRAIN #ifdef TERRAIN_DEM_FLOAT_FORMAT uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev; #else uniform sampler2D u_dem;uniform sampler2D u_dem_prev; #endif uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos)); #ifdef TERRAIN_DEM_NEAREST_FILTER return u_exaggeration*tl; #endif float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4( unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy)) );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) { #ifdef TERRAIN_DEM_FLOAT_FORMAT float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a; #else vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack); #endif return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; } #endif`,$s=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,sr=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`;let qs={},Fr={};const Zs=[];_s(fl,Zs),_s(or,Zs),_s($s,Zs),_s(sr,Zs),qs=Si("",or),Fr=Si(sr,$s);const Ur=Si(` #if __VERSION__ >=300 #define varying in #define gl_FragColor glFragColor #define texture2D texture #define textureCube texture out vec4 glFragColor; #endif highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,` #if __VERSION__ >=300 #define attribute in #define varying out #define texture2D texture #endif float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),Xs=fl,pl=` #ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`;var dl={background:Si(`uniform vec4 u_color;uniform float u_opacity; #ifdef LIGHTING_3D_MODE varying vec4 v_color; #endif void main() {vec4 out_color; #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #ifdef LIGHTING_3D_MODE uniform vec4 u_color;varying vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef LIGHTING_3D_MODE v_color=apply_lighting(u_color); #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:Si(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),circle:Si(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif gl_FragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`#define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1); #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Si("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Si(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Si(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Si("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Si("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Si("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3; #endif varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),fill:Si(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutline:Si(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:Si(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:Si(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:Si(`varying vec4 v_color; #ifdef RENDER_SHADOWS varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif void main() { #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) vec3 normal=v_normal; #endif float z;vec4 color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z); #else color=v_color; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade; #endif #ifdef RENDER_SHADOWS #ifdef ZERO_ROOF_RADIUS normal=mix(normal,vec3(0.0,0.0,1.0),z); #endif color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec4 v_color; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) v_normal=normal; #endif base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=0.0;float c_ele;vec3 pos; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h); #else h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden); #ifdef RENDER_SHADOWS v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w; #endif float NdotL=0.0;float colorvalue=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0); #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_color=apply_lighting(color,NdotL); #else v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_color*=u_opacity; #ifdef ZERO_ROOF_RADIUS v_roof_color=vec4(0.0,0.0,0.0,1.0); #ifdef LIGHTING_3D_MODE v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0))); #else float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionPattern:Si(`uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,v_NdotL)*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec2 v_pos;varying vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_NdotL=NdotL; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),hillshadePrepare:Si(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) { #ifdef TERRAIN_DEM_FLOAT_FORMAT return texture2D(u_image,coord).a/4.0; #else vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0; #endif }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Si(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE gl_FragColor=apply_lighting(gl_FragColor); #endif #ifdef FOG gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos)); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:Si(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0); #ifdef RENDER_LINE_DASH float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture2D(u_gradient_image,v_uv.xy); #else out_color=color; #endif float trimmed=1.0; #ifdef RENDER_LINE_TRIM_OFFSET highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}} #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef RENDER_LINE_ALPHA_DISCARD if (alpha < u_alpha_discard_threshold) {discard;} #endif #ifdef RENDER_LINE_BORDER float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2); #ifdef RENDER_LINE_BORDER_AUTO float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);} #else out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha); #endif } #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define EXTRUDE_SCALE 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) attribute highp vec4 a_packed; #endif #ifdef RENDER_LINE_DASH attribute float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end); #else v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end); #endif #endif #ifdef RENDER_LINE_DASH float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),linePattern:Si(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE color=apply_lighting(color); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth; #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),raster:Si(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply(out_color,v_fog_pos)); #endif gl_FragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),symbolIcon:Si(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Si(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Si(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Si(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif void main() {vec4 color=texture2D(u_image0,v_pos0); #ifdef RENDER_SHADOWS color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height; #ifdef TERRAIN_WIREFRAME elevation+=wireframeOffset; #endif v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w; #endif }`),terrainDepth:Si(`#ifdef GL_ES precision highp float; #endif varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Si(` varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,Ln),skyboxGradient:Si(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,Ln),skyboxCapture:Si(` varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m; #ifdef GL_ES precision highp float; #endif #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Si(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias); #else color=texture2D(u_image0,v_pos0); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES attribute vec3 a_globe_pos;attribute vec2 a_uv; #else attribute vec2 a_pos; #endif varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos); #ifdef TERRAIN_WIREFRAME height+=wireframeOffset; #endif globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Si(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;} #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x: (n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y: uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function _s(h,n){const a=h.replace(/\s*\/\/[^\n]*\n/g,` `).split(` `);for(let p of a)if(p=p.trim(),p[0]==="#"&&p.includes("if")&&!p.includes("endif")){p=p.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const _=p.split(" ");for(const b of _)n.includes(b)||n.push(b)}}function Si(h,n){const a=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,p=n.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),_={},b=[...Zs];return _s(h,b),_s(n,b),{fragmentSource:h=h.replace(a,(I,M,P,N,z)=>(_[z]=!0,M==="define"?` #ifndef HAS_UNIFORM_u_${z} varying ${P} ${N} ${z}; #else uniform ${P} ${N} u_${z}; #endif `:` #ifdef HAS_UNIFORM_u_${z} ${P} ${N} ${z} = u_${z}; #endif `)),vertexSource:n=n.replace(a,(I,M,P,N,z)=>{const j=N==="float"?"vec2":"vec4",Y=z.match(/color/)?"color":j;return _[z]?M==="define"?` #ifndef HAS_UNIFORM_u_${z} uniform lowp float u_${z}_t; attribute ${P} ${j} a_${z}; varying ${P} ${N} ${z}; #else uniform ${P} ${N} u_${z}; #endif `:Y==="vec4"?` #ifndef HAS_UNIFORM_u_${z} ${z} = a_${z}; #else ${P} ${N} ${z} = u_${z}; #endif `:` #ifndef HAS_UNIFORM_u_${z} ${z} = unpack_mix_${Y}(a_${z}, u_${z}_t); #else ${P} ${N} ${z} = u_${z}; #endif `:M==="define"?` #ifndef HAS_UNIFORM_u_${z} uniform lowp float u_${z}_t; attribute ${P} ${j} a_${z}; #else uniform ${P} ${N} u_${z}; #endif `:Y==="vec4"?` #ifndef HAS_UNIFORM_u_${z} ${P} ${N} ${z} = a_${z}; #else ${P} ${N} ${z} = u_${z}; #endif `:` #ifndef HAS_UNIFORM_u_${z} ${P} ${N} ${z} = unpack_mix_${Y}(a_${z}, u_${z}_t); #else ${P} ${N} ${z} = u_${z}; #endif `}),staticAttributes:p,usedDefines:b}}class xc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(n,a,p,_,b,I,M){this.context=n;let P=this.boundPaintVertexBuffers.length!==_.length;for(let z=0;!P&&z<_.length;z++)this.boundPaintVertexBuffers[z]!==_[z]&&(P=!0);let N=this.boundDynamicVertexBuffers.length!==M.length;for(let z=0;!N&&z{const ae=V.paint.get("hillshade-shadow-color"),le=V.paint.get("hillshade-highlight-color"),xe=V.paint.get("hillshade-accent-color");let Te=V.paint.get("hillshade-illumination-direction")*(Math.PI/180);V.paint.get("hillshade-illumination-anchor")==="viewport"&&(Te-=ee.transform.angle);const be=!ee.options.moving;return{u_matrix:K||ee.transform.calculateProjMatrix(ie.tileID.toUnwrapped(),be),u_image:0,u_latrange:ml(0,ie.tileID),u_light:[V.paint.get("hillshade-exaggeration"),Te],u_shadow:ae,u_highlight:le,u_accent:xe}})(h,a,p,h.terrain?n.projMatrix:null);h.prepareDrawProgram(M,z,n.toUnwrapped());const{tileBoundsBuffer:Y,tileBoundsIndexBuffer:J,tileBoundsSegments:te}=h.getTileBoundsBuffers(a);z.draw(M,P.TRIANGLES,_,b,I,s.CullFaceMode.disabled,j,p.id,Y,J,te)}function ao(h,n,a){if(!n.needsDEMTextureUpload)return;const p=h.context,_=p.gl;p.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||h.getTileTexture(a.stride);const b=a.getPixels();n.demTexture?n.demTexture.update(b,{premultiply:!1}):n.demTexture=new s.Texture(p,b,_.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function ar(h,n,a,p,_,b){const I=h.context,M=I.gl;if(!n.dem)return;const P=n.dem;if(I.activeTexture.set(M.TEXTURE1),ao(h,n,P),!n.demTexture)return;n.demTexture.bind(M.NEAREST,M.CLAMP_TO_EDGE);const N=P.dim;I.activeTexture.set(M.TEXTURE0);let z=n.fbo;if(!z){const te=new s.Texture(I,{width:N,height:N,data:null},M.RGBA);te.bind(M.LINEAR,M.CLAMP_TO_EDGE),z=n.fbo=I.createFramebuffer(N,N,!0),z.colorAttachment.set(te.texture)}I.bindFramebuffer.set(z.framebuffer),I.viewport.set([0,0,N,N]);const{tileBoundsBuffer:j,tileBoundsIndexBuffer:Y,tileBoundsSegments:J}=h.getMercatorTileBoundsBuffers();h.useProgram("hillshadePrepare").draw(I,M.TRIANGLES,p,_,b,s.CullFaceMode.disabled,((te,ee)=>{const ie=ee.stride,V=s.create();return s.ortho(V,0,s.EXTENT,-s.EXTENT,0,0,1),s.translate(V,V,[0,-s.EXTENT,0]),{u_matrix:V,u_image:1,u_dimension:[ie,ie],u_zoom:te.overscaledZ,u_unpack:ee.unpackVector}})(n.tileID,P),a.id,j,Y,J),n.needsHillshadePrepare=!1}const gl=h=>({u_matrix:new s.UniformMatrix4f(h),u_image0:new s.Uniform1i(h),u_skirt_height:new s.Uniform1f(h)}),Go=(h,n)=>({u_matrix:h,u_image0:0,u_skirt_height:n}),Ea=(h,n,a,p,_,b,I,M,P,N,z,j,Y,J,te)=>({u_proj_matrix:Float32Array.from(h),u_globe_matrix:n,u_normalize_matrix:Float32Array.from(p),u_merc_matrix:a,u_zoom_transition:_,u_merc_center:b,u_image0:0,u_frustum_tl:I,u_frustum_tr:M,u_frustum_br:P,u_frustum_bl:N,u_globe_pos:z,u_globe_radius:j,u_viewport:Y,u_grid_matrix:te?Float32Array.from(te):new Float32Array(9),u_skirt_height:J});function So(h,n){return h!=null&&n!=null&&!(!h.hasData()||!n.hasData())&&h.demTexture!=null&&n.demTexture!=null&&h.tileID.key!==n.tileID.key}const Wr=new class{constructor(){this.operations={}}newMorphing(h,n,a,p,_){if(h in this.operations){const b=this.operations[h];b.to.tileID.key!==a.tileID.key&&(b.queued=a)}else this.operations[h]={startTime:p,phase:0,duration:_,from:n,to:a,queued:null}}getMorphValuesForProxy(h){if(!(h in this.operations))return null;const n=this.operations[h];return{from:n.from,to:n.to,phase:n.phase}}update(h){for(const n in this.operations){const a=this.operations[n];for(a.phase=(h-a.startTime)/a.duration;a.phase>=1||!this._validOp(a);)if(!this._nextOp(a,h)){delete this.operations[n];break}}}_nextOp(h,n){return!!h.queued&&(h.from=h.to,h.to=h.queued,h.queued=null,h.phase=0,h.startTime=n,!0)}_validOp(h){return h.from.hasData()&&h.to.hasData()}},lo={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Ws(h){return 6*Math.pow(1.5,22-h)}function Er(h,n){const a=1<({u_matrix:h});function Hn(h,n,a,p,_){if(_>0){const b=s.exported.now(),I=(b-h.timeAdded)/_,M=n?(b-n.timeAdded)/_:-1,P=a.getSource(),N=p.coveringZoomLevel({tileSize:P.tileSize,roundZoom:P.roundZoom}),z=!n||Math.abs(n.tileID.overscaledZ-N)>Math.abs(h.tileID.overscaledZ-N),j=z&&h.refreshedUponExpiration?1:s.clamp(z?I:1-M,0,1);return h.refreshedUponExpiration&&I>=1&&(h.refreshedUponExpiration=!1),n?{opacity:1,mix:1-j}:{opacity:j,mix:0}}return{opacity:1,mix:0}}class $o extends s.SourceCache{constructor(n){const a={type:"raster-dem",maxzoom:n.transform.maxZoom},p=new St(br(),null),_=ui("mock-dem",a,p,n.style);super("mock-dem",_,!1),_.setEventedParent(this),this._sourceLoaded=!0}_loadTile(n,a){n.state="loaded",a(null)}}class Ta extends s.SourceCache{constructor(n){const a=ui("proxy",{type:"geojson",maxzoom:n.transform.maxZoom},new St(br(),null),n.style);super("proxy",a,!1),a.setEventedParent(this),this.map=this.getSource().map=n,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(n,a,p){if(n.freezeTileCoverage)return;this.transform=n;const _=n.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((b,I)=>{if(b[I.key]="",!this._tiles[I.key]){const M=new s.Tile(I,this._source.tileSize*I.overscaleFactor(),n.tileZoom);M.state="loaded",this._tiles[I.key]=M}return b},{});for(const b in this._tiles)b in _||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(n){const a=this.proxyCachedFBO[n];if(a!==void 0){const p=Object.values(a);this.renderCachePool.push(...p),delete this.proxyCachedFBO[n]}}deallocRenderCache(){this.renderCache.forEach(n=>n.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ys extends s.OverscaledTileID{constructor(n,a,p){super(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,n.canonical.y),this.proxyTileKey=a,this.projMatrix=p}}class Sa extends s.Elevation{constructor(n,a){super(),this.painter=n,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[p,_,b]=function(P){const N=new s.StructArrayLayout2i4,z=new s.StructArrayLayout3ui6,j=131;N.reserve(17161),z.reserve(33800);const Y=s.EXTENT/128,J=s.EXTENT+Y/2,te=J+Y;for(let ie=-Y;ieJ||ie<0||ie>J?24575:0,ae=s.clamp(Math.round(V),0,s.EXTENT),le=s.clamp(Math.round(ie),0,s.EXTENT);N.emplaceBack(ae+K,le)}const ee=(ie,V)=>{const K=V*j+ie;z.emplaceBack(K+1,K,K+j),z.emplaceBack(K+j,K+j+1,K+1)};for(let ie=1;ie<129;ie++)for(let V=1;V<129;V++)ee(V,ie);return[0,129].forEach(ie=>{for(let V=0;V<130;V++)ee(V,ie),ee(ie,V)}),[N,z,32768]}(),I=n.context;this.gridBuffer=I.createVertexBuffer(p,s.posAttributes.members),this.gridIndexBuffer=I.createIndexBuffer(_),this.gridSegments=s.SegmentVector.simpleSegment(0,0,p.length,_.length),this.gridNoSkirtSegments=s.SegmentVector.simpleSegment(0,0,p.length,b),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ta(a.map),this.orthoMatrix=s.create(),s.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,s.EXTENT,0,s.EXTENT,0,1);const M=I.gl;this._overlapStencilMode=new s.StencilMode({func:M.GEQUAL,mask:255},0,255,M.KEEP,M.KEEP,M.REPLACE),this._previousZoom=n.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=a,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new $o(a.map)}set style(n){n.on("data",this._onStyleDataEvent.bind(this)),n.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=n,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(n,a,p){if(n&&n.terrain){this._style!==n&&(this.style=n),this.enabled=!0;const _=n.terrain.properties;this.sourceCache=n.terrain.drapeRenderMode===0?this._mockSourceCache:n._getSourceCache(_.get("source")),this._exaggeration=_.get("exaggeration");const b=()=>{this.sourceCache.used&&s.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const I=this.getScaledDemTileSize();this.sourceCache.update(a,I,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,b(),this._initializing=!0),b(),a.updateElevation(!0,p),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(a),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(n){this._findCoveringTileCache[n]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const n=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||n.efficiency!==100&&s.warnOnce(`Terrain render cache efficiency is not optimal (${n.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${n.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(n){n.coord&&n.dataType==="source"?this._clearRenderCacheForTile(n.sourceCacheId,n.coord):n.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const n in this._style._sourceCaches)this._style._sourceCaches[n].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(n=>n.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const n=2*this.proxySourceCache.getSource().tileSize;return[n,n]}set useVertexMorphing(n){this._useVertexMorphing=n}updateTileBinding(n){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const a=this.proxySourceCache,p=this.painter.transform;this._initializing&&(this._initializing=p._centerAltitude===0&&this.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(p.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const _=this.proxyCoords=a.getIds().map(P=>{const N=a.getTileByID(P).tileID;return N.projMatrix=p.calculateProjMatrix(N.toUnwrapped()),N});(function(P,N){const z=N.transform.pointCoordinate(N.transform.getCameraPoint()),j=new s.Point(z.x,z.y);P.sort((Y,J)=>{if(J.overscaledZ-Y.overscaledZ)return J.overscaledZ-Y.overscaledZ;const te=new s.Point(Y.canonical.x+(1<{this.proxyToSource[P.key]={}}),this.terrainTileForTile={};const I=this._style._sourceCaches;for(const P in I){const N=I[P];if(!N.used||(N!==this.sourceCache&&this.resetTileLookupCache(N.id),this._setupProxiedCoordsForOrtho(N,n[P],b),N.usedForTerrain))continue;const z=n[P];N.getSource().reparseOverscaled&&this._assignTerrainTiles(z)}this.proxiedCoords[a.id]=_.map(P=>new Ys(P,P.key,this.orthoMatrix)),this._assignTerrainTiles(_),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(b),this.renderingToTexture=!1,this._updateTimestamp=s.exported.now();const M={};this._visibleDemTiles=[];for(const P of this.proxyCoords){const N=this.terrainTileForTile[P.key];if(!N)continue;const z=N.tileID.key;z in M||(this._visibleDemTiles.push(N),M[z]=z)}}_assignTerrainTiles(n){this._initializing||n.forEach(a=>{if(this.terrainTileForTile[a.key])return;const p=this._findTileCoveringTileID(a,this.sourceCache);p&&(this.terrainTileForTile[a.key]=p)})}_prepareDEMTextures(){const n=this.painter.context,a=n.gl;for(const p in this.terrainTileForTile){const _=this.terrainTileForTile[p],b=_.dem;!b||_.demTexture&&!_.needsDEMTextureUpload||(n.activeTexture.set(a.TEXTURE1),ao(this.painter,_,b))}}_prepareDemTileUniforms(n,a,p,_){if(!a||a.demTexture==null)return!1;const b=n.tileID.canonical,I=Math.pow(2,a.tileID.canonical.z-b.z),M=_||"";return p[`u_dem_tl${M}`]=[b.x*I%1,b.y*I%1],p[`u_dem_scale${M}`]=I,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const n=this.painter.context,a=n.gl;if(!this._emptyDepthBufferTexture){const p=new s.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new s.Texture(n,p,a.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let n=0;const a=this._visibleDemTiles.reduce((p,_)=>{if(!_.dem)return p;const b=_.dem.tree.minimums[0];return b>0&&n++,p+b},0);return n?a/n:0}_updateEmptyDEMTexture(){const n=this.painter.context,a=n.gl;n.activeTexture.set(a.TEXTURE2);const p=this._getLoadedAreaMinimum(),_=new s.RGBAImage({width:1,height:1},new Uint8Array(s.DEMData.pack(p,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(_,{premultiply:!1}):b=this._emptyDEMTexture=new s.Texture(n,_,a.RGBA,{premultiply:!1}),b}setupElevationDraw(n,a,p){const _=this.painter.context,b=_.gl,I=(M=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:s.DEMData.getUnpackVector(M),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var M;I.u_dem_size=this.sourceCache.getSource().tileSize,I.u_exaggeration=this.exaggeration();let P=null,N=null,z=1;if(p&&p.morphing&&this._useVertexMorphing){const j=p.morphing.srcDemTile,Y=p.morphing.dstDemTile;z=p.morphing.phase,j&&Y&&(this._prepareDemTileUniforms(n,j,I,"_prev")&&(N=j),this._prepareDemTileUniforms(n,Y,I)&&(P=Y))}if(N&&P?(_.activeTexture.set(b.TEXTURE2),P.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),_.activeTexture.set(b.TEXTURE4),N.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),I.u_dem_lerp=z):(P=this.terrainTileForTile[n.tileID.key],_.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(n,P,I)?P.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),_.activeTexture.set(b.TEXTURE3),p&&p.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),this._depthFBO&&(I.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),I.u_depth_size_inv=[1,1]),p&&p.useMeterToDem&&P){const j=(1<{if(V===et)return;const Ze=[lo[et],"PROJECTION_GLOBE_VIEW"];le&&Ze.push("CUSTOM_ANTIALIASING"),ze&&Ze.push(lo[K]),ie=N.useProgram("globeRaster",null,Ze),V=et},Te=N.colorModeForRenderPass(),be=new s.DepthMode(ee.LEQUAL,s.DepthMode.ReadWrite,N.depthRangeFor3D);Wr.update(J);const Ae=s.calculateGlobeMercatorMatrix(ae),ke=[s.mercatorXfromLng(ae.center.lng),s.mercatorYfromLat(ae.center.lat)],Ne=K?[!1,!0]:[!1],tt=N.globeSharedBuffers,Re=[ae.width*s.exported.devicePixelRatio,ae.height*s.exported.devicePixelRatio],We=Float32Array.from(ae.globeMatrix),je={useDenormalizedUpVectorScale:!0};if(Ne.forEach(et=>{const ze=N.transform,Ze=Ws(ze.zoom)*z.exaggeration();V=-1;const rt=et?ee.LINES:ee.TRIANGLES;for(const Ke of Y){const st=j.getTile(Ke),zt=s.StencilMode.disabled,Kt=z.prevTerrainTileForTile[Ke.key],Pt=z.terrainTileForTile[Ke.key];So(Kt,Pt)&&Wr.newMorphing(Ke.key,Kt,Pt,J,250),te.activeTexture.set(ee.TEXTURE0),st.texture.bind(ee.LINEAR,ee.CLAMP_TO_EDGE);const jt=Wr.getMorphValuesForProxy(Ke.key),mi=jt?1:0;jt&&s.extend$1(je,{morphing:{srcDemTile:jt.from,dstDemTile:jt.to,phase:s.easeCubicInOut(jt.phase)}});const di=s.tileCornersToBounds(Ke.canonical),Ot=s.getLatitudinalLod(di.getCenter().lat),Di=s.getGridMatrix(Ke.canonical,di,Ot,ze.worldSize/ze._pixelsPerMercatorPixel),Bi=s.globeNormalizeECEF(s.globeTileBounds(Ke.canonical)),Fi=Ea(ze.projMatrix,We,Ae,Bi,s.globeToMercatorTransition(ze.zoom),ke,ze.frustumCorners.TL,ze.frustumCorners.TR,ze.frustumCorners.BR,ze.frustumCorners.BL,ze.globeCenterInViewSpace,ze.globeRadius,Re,Ze,Di);if(xe(mi,et),z.setupElevationDraw(st,ie,je),N.prepareDrawProgram(te,ie,Ke.toUnwrapped()),tt){const[Ui,ur,$n]=et?tt.getWirefameBuffers(N.context,Ot):tt.getGridBuffers(Ot,Ze!==0);ie.draw(te,rt,be,zt,Te,s.CullFaceMode.backCCW,Fi,"globe_raster",Ui,ur,$n)}}}),tt){const et=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];le&&et.push("CUSTOM_ANTIALIASING"),ie=N.useProgram("globeRaster",null,et);for(const ze of Y){const{x:Ze,y:rt,z:Ke}=ze.canonical,st=rt===0,zt=rt===(1<Fi.draw(te,ee.TRIANGLES,be,s.StencilMode.disabled,Te,s.CullFaceMode.disabled,Ea(ae.projMatrix,Ot,Ot,Di,0,ke,ae.frustumCorners.TL,ae.frustumCorners.TR,ae.frustumCorners.BR,ae.frustumCorners.BL,ae.globeCenterInViewSpace,ae.globeRadius,Re,0),"globe_pole_raster",Ui,jt,mi);z.setupElevationDraw(di,ie,je),N.prepareDrawProgram(te,ie,ze.toUnwrapped()),st&&Bi(ie,Kt),zt&&(Ot=s.scale(s.create(),Ot,[1,-1,1]),Bi(ie,Pt))}}}})(_,b,I,M,P);else{const N=_.context,z=N.gl;let j,Y;const J=_.options.showTerrainWireframe?2:0,te=(ae,le)=>{if(Y===ae)return;const xe=[lo[ae]];le&&xe.push(lo[J]),j=_.useProgram("terrainRaster",null,xe),Y=ae},ee=_.colorModeForRenderPass(),ie=new s.DepthMode(z.LEQUAL,s.DepthMode.ReadWrite,_.depthRangeFor3D);Wr.update(P);const V=_.transform,K=Ws(V.zoom)*b.exaggeration();(J?[!1,!0]:[!1]).forEach(ae=>{Y=-1;const le=ae?z.LINES:z.TRIANGLES,[xe,Te]=ae?b.getWirefameBuffer():[b.gridIndexBuffer,b.gridSegments];for(const be of M){const Ae=I.getTile(be),ke=s.StencilMode.disabled,Ne=b.prevTerrainTileForTile[be.key],tt=b.terrainTileForTile[be.key];So(Ne,tt)&&Wr.newMorphing(be.key,Ne,tt,P,250),N.activeTexture.set(z.TEXTURE0),Ae.texture.bind(z.LINEAR,z.CLAMP_TO_EDGE,z.LINEAR_MIPMAP_NEAREST);const Re=Wr.getMorphValuesForProxy(be.key),We=Re?1:0;let je;Re&&(je={morphing:{srcDemTile:Re.from,dstDemTile:Re.to,phase:s.easeCubicInOut(Re.phase)}});const et=Go(be.projMatrix,Er(be.canonical,V.renderWorldCopies)?K/10:K);te(We,ae),b.setupElevationDraw(Ae,j,je),_.prepareDrawProgram(N,j,be.toUnwrapped()),j.draw(N,le,ie,ke,ee,s.CullFaceMode.backCCW,et,"terrain_raster",b.gridBuffer,xe,Te)}})}}(a,this,this.proxySourceCache,n,this._updateTimestamp),this.renderingToTexture=!0,a.gpuTimingDeferredRenderEnd(),n.splice(0,n.length))}renderBatch(n){if(this._drapedRenderBatches.length===0)return n+1;this.renderingToTexture=!0;const a=this.painter,p=this.painter.context,_=this.proxySourceCache,b=this.proxiedCoords[_.id],I=this._drapedRenderBatches.shift(),M=[],P=a.style.order;let N=0;for(const z of b){const j=_.getTileByID(z.proxyTileKey),Y=_.proxyCachedFBO[z.key]?_.proxyCachedFBO[z.key][n]:void 0,J=Y!==void 0?_.renderCache[Y]:this.pool[N++],te=Y!==void 0;if(j.texture=J.tex,te&&!J.dirty){M.push(j.tileID);continue}let ee;p.bindFramebuffer.set(J.fb.framebuffer),this.renderedToTile=!1,J.dirty&&(p.clear({color:s.Color.transparent,stencil:0}),J.dirty=!1);for(let ie=I.start;ie<=I.end;++ie){const V=a.style._layers[P[ie]];if(V.isHidden(a.transform.zoom))continue;const K=a.style._getLayerSourceCache(V),ae=K?this.proxyToSource[z.key][K.id]:[z];if(!ae)continue;const le=ae;p.viewport.set([0,0,J.fb.width,J.fb.height]),ee!==(K?K.id:null)&&(this._setupStencil(J,ae,V,K),ee=K?K.id:null),a.renderLayer(a,K,V,le)}this.renderedToTile?(J.dirty=!0,M.push(j.tileID)):te||--N,N===5&&(N=0,this.renderToBackBuffer(M))}return this.renderToBackBuffer(M),this.renderingToTexture=!1,p.bindFramebuffer.set(null),p.viewport.set([0,0,a.width,a.height]),I.end+1}postRender(){}renderCacheEfficiency(n){const a=n.order.length;if(a===0)return{efficiency:100};let p,_=0,b=0,I=!1;for(let M=0;Ma.dem).forEach(a=>{n=Math.min(n,a.dem.tree.minimums[0])}),n===0?n:(n-30)*this._exaggeration}raycast(n,a,p){if(!this._visibleDemTiles)return null;const _=this._visibleDemTiles.filter(b=>b.dem).map(b=>{const I=b.tileID,M=1<(b.t!==null?b.t:Number.MAX_VALUE)-(I.t!==null?I.t:Number.MAX_VALUE));for(const b of _){if(b.t==null)return null;const I=b.tile.dem.tree.raycast(b.minx,b.miny,b.maxx,b.maxy,n,a,p);if(I!=null)return I}return null}_createFBO(){const n=this.painter.context,a=n.gl,p=this.drapeBufferSize;n.activeTexture.set(a.TEXTURE0);const _=new s.Texture(n,{width:p[0],height:p[1],data:null},a.RGBA);_.bind(a.LINEAR,a.CLAMP_TO_EDGE);const b=n.createFramebuffer(p[0],p[1],!1);return b.colorAttachment.set(_.texture),b.depthAttachment=new se(n,b.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=n.createRenderbuffer(n.gl.DEPTH_STENCIL,p[0],p[1]),this._stencilRef=0,b.depthAttachment.set(this._sharedDepthStencil),n.clear({stencil:0})):b.depthAttachment.set(this._sharedDepthStencil),n.extTextureFilterAnisotropic&&!n.extTextureFilterAnisotropicForceOff&&a.texParameterf(a.TEXTURE_2D,n.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,n.extTextureFilterAnisotropicMax),{fb:b,tex:_,dirty:!1}}_initFBOPool(){for(;this.pool.length{const a=this._style._layers[n],p=a.isHidden(this.painter.transform.zoom);return a.type==="custom"?!p&&a.shouldRedrape():!p&&a.hasTransition()})}_clearLineLayersFromRenderCache(){let n=!1;for(const p of this._style._getSources())if(p instanceof ht){n=!0;break}if(!n)return;const a={};for(let p=0;pa.renderCachePool.length){const I=Object.values(a.proxyCachedFBO);a.proxyCachedFBO={};for(let M=0;M=0;I--){const M=p[I];if(a.getTileByID(M.key),a.proxyCachedFBO[M.key]!==void 0){const P=n[M.key],N=this.proxyToSource[M.key];let z=0;for(const j in N){const Y=N[j],J=P[j];if(!J||J.length!==Y.length||Y.some((te,ee)=>te!==J[ee]||_[j]&&_[j].hasOwnProperty(te.key))){z=-1;break}++z}for(const j in a.proxyCachedFBO[M.key])a.renderCache[a.proxyCachedFBO[M.key][j]].dirty=z<0||z!==Object.values(P).length}}const b=[...this._drapedRenderBatches];b.sort((I,M)=>M.end-M.start-(I.end-I.start));for(const I of b)for(const M of p){if(a.proxyCachedFBO[M.key])continue;let P=a.renderCachePool.pop();P===void 0&&a.renderCache.length<50&&(P=a.renderCache.length,a.renderCache.push(this._createFBO())),P!==void 0&&(a.proxyCachedFBO[M.key]={},a.proxyCachedFBO[M.key][I.start]=P,a.renderCache[P].dirty=!0)}this._tilesDirty={}}_setupStencil(n,a,p,_){if(!_||!this._sourceTilesOverlap[_.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const b=this.painter.context,I=b.gl;if(a.length<=1)return void(this._overlapStencilType=!1);let M;if(p.isTileClipped())M=a.length,this._overlapStencilMode.test={func:I.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(a[0].overscaledZ>a[a.length-1].overscaledZ))return void(this._overlapStencilType=!1);M=1,this._overlapStencilMode.test={func:I.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+M>255&&(b.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=M,this._overlapStencilMode.ref=this._stencilRef,p.isTileClipped()&&this._renderTileClippingMasks(a,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(n){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[n.key]),this._overlapStencilMode):s.StencilMode.disabled}_renderTileClippingMasks(n,a){const p=this.painter,_=this.painter.context,b=_.gl;p._tileClippingMaskIDs={},_.setColorMode(s.ColorMode.disabled),_.setDepthMode(s.DepthMode.disabled);const I=p.useProgram("clippingMask");for(const M of n){const P=p._tileClippingMaskIDs[M.key]=--a;I.draw(_,b.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:b.ALWAYS,mask:0},P,255,b.KEEP,b.KEEP,b.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,ys(M.projMatrix),"$clipping",p.tileExtentBuffer,p.quadTriangleIndexBuffer,p.tileExtentSegments)}}pointCoordinate(n){const a=this.painter.transform;if(n.x<0||n.x>a.width||n.y<0||n.y>a.height)return null;const p=[n.x,n.y,1,1];s.transformMat4$1(p,p,a.pixelMatrixInverse),s.scale$1(p,p,1/p[3]),p[0]/=a.worldSize,p[1]/=a.worldSize;const _=a._camera.position,b=s.mercatorZfromAltitude(1,a.center.lat),I=[_[0],_[1],_[2]/b,0],M=s.subtract([],p.slice(0,3),I);s.normalize(M,M);const P=this.raycast(I,M,this._exaggeration);return P!==null&&P?(s.scaleAndAdd(I,I,M,P),I[3]=I[2],I[2]*=b,I):null}drawDepth(){const n=this.painter,a=n.context,p=this.proxySourceCache,_=Math.ceil(n.width),b=Math.ceil(n.height);if(!this._depthFBO||this._depthFBO.width===_&&this._depthFBO.height===b||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const I=a.gl,M=a.createFramebuffer(_,b,!0);a.activeTexture.set(I.TEXTURE0);const P=new s.Texture(a,{width:_,height:b,data:null},I.RGBA);P.bind(I.NEAREST,I.CLAMP_TO_EDGE),M.colorAttachment.set(P.texture);const N=a.createRenderbuffer(a.gl.DEPTH_COMPONENT16,_,b);M.depthAttachment.set(N),this._depthFBO=M,this._depthTexture=P}a.bindFramebuffer.set(this._depthFBO.framebuffer),a.viewport.set([0,0,_,b]),function(I,M,P,N){if(I.transform.projection.name==="globe")return;const z=I.context,j=z.gl;z.clear({depth:1});const Y=I.useProgram("terrainDepth"),J=new s.DepthMode(j.LESS,s.DepthMode.ReadWrite,I.depthRangeFor3D);for(const te of N){const ee=P.getTile(te),ie=Go(te.projMatrix,0);M.setupElevationDraw(ee,Y),Y.draw(z,j.TRIANGLES,J,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.backCCW,ie,"terrain_depth",M.gridBuffer,M.gridIndexBuffer,M.gridNoSkirtSegments)}}(n,this,p,this.proxyCoords)}_setupProxiedCoordsForOrtho(n,a,p){if(n.getSource()instanceof li)return this._setupProxiedCoordsForImageSource(n,a,p);this._findCoveringTileCache[n.id]=this._findCoveringTileCache[n.id]||{};const _=this.proxiedCoords[n.id]=[],b=this.proxyCoords;for(let M=0;M(z.min.x=Math.min(z.min.x,j.x-M.x),z.min.y=Math.min(z.min.y,j.y-M.y),z.max.x=Math.max(z.max.x,j.x-M.x),z.max.y=Math.max(z.max.y,j.y-M.y),z),{min:new s.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new s.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),N=(z,j)=>{const Y=z.wrap+z.canonical.x/(1<ee+P.max.x||J+teie+P.max.y};for(let z=0;zI.key===a.tileID.key);if(b)return b}if(a.tileID.key!==n.key){const b=n.canonical.z-a.tileID.canonical.z;let I,M,P;_=s.create();const N=a.tileID.wrap-n.wrap<0?(I=s.EXTENT>>b,M=I*((a.tileID.canonical.x<=j){const Y=n.canonical.z-j;a.getSource().reparseOverscaled?(M=Math.max(n.canonical.z+2,a.transform.tileZoom),I=new s.OverscaledTileID(M,n.wrap,j,n.canonical.x>>Y,n.canonical.y>>Y)):Y!==0&&(M=j,I=new s.OverscaledTileID(M,n.wrap,j,n.canonical.x>>Y,n.canonical.y>>Y))}I.key!==n.key&&(N.push(I.key),p=a.getTile(I))}const z=j=>{N.forEach(Y=>{_[Y]=j}),N.length=0};for(M-=1;M>=P&&(!p||!p.hasData());M--){p&&z(p.tileID.key);const j=I.calculateScaledKey(M);if(p=a.getTileByID(j),p&&p.hasData())break;const Y=_[j];if(Y===null)break;Y===void 0?N.push(j):p=a.getTileByID(Y)}return z(p?p.tileID.key:null),p&&p.hasData()?p:null}findDEMTileFor(n){return this.enabled?this._findTileCoveringTileID(n,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(n,a){let p=this._tilesDirty[n];p||(p=this._tilesDirty[n]={}),p[a.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const n=function(a){let p=0;const _=new s.StructArrayLayout2ui4,b=131;for(let I=1;I<129;I++){for(let M=1;M<129;M++)p=I*b+M,_.emplaceBack(p,p+1),_.emplaceBack(p,p+b),_.emplaceBack(p+1,p+b),I===128&&_.emplaceBack(p+b,p+b+1);_.emplaceBack(p+1,p+1+b)}return _}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(n),this.wireframeSegments=s.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,n.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class bi{static cacheKey(n,a,p,_){let b=`${a}${_?_.cacheKey:""}`;for(const I of p)n.usedDefines.includes(I)&&(b+=`/${I}`);return b}constructor(n,a,p,_,b,I){const M=n.gl;this.program=M.createProgram();const P=function(V){const K=[];for(let ae=0;ae`#define ${V}`));const Y=n.isWebGL2?`#version 300 es `:"",J=Y+j.concat(n.extStandardDerivatives&&Y.length===0?`#extension GL_OES_standard_derivatives : enable `.concat(pl):pl,pl,Xs,Ur.fragmentSource,Fr.fragmentSource,p.fragmentSource).join(` `),te=Y+j.concat(` #ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,Xs,Ur.vertexSource,Fr.vertexSource,qs.vertexSource,p.vertexSource).join(` `),ee=M.createShader(M.FRAGMENT_SHADER);if(M.isContextLost())return void(this.failedToCreate=!0);M.shaderSource(ee,J),M.compileShader(ee),M.attachShader(this.program,ee);const ie=M.createShader(M.VERTEX_SHADER);if(M.isContextLost())this.failedToCreate=!0;else{M.shaderSource(ie,te),M.compileShader(ie),M.attachShader(this.program,ie),this.attributes={},this.numAttributes=z.length;for(let V=0;V({u_dem:new s.Uniform1i(V),u_dem_prev:new s.Uniform1i(V),u_dem_unpack:new s.Uniform4f(V),u_dem_tl:new s.Uniform2f(V),u_dem_scale:new s.Uniform1f(V),u_dem_tl_prev:new s.Uniform2f(V),u_dem_scale_prev:new s.Uniform1f(V),u_dem_size:new s.Uniform1f(V),u_dem_lerp:new s.Uniform1f(V),u_exaggeration:new s.Uniform1f(V),u_depth:new s.Uniform1i(V),u_depth_size_inv:new s.Uniform2f(V),u_meter_to_dem:new s.Uniform1f(V),u_label_plane_matrix_inv:new s.UniformMatrix4f(V)}))(n)),I.includes("GLOBE")&&(this.globeUniforms=(V=>({u_tile_tl_up:new s.Uniform3f(V),u_tile_tr_up:new s.Uniform3f(V),u_tile_br_up:new s.Uniform3f(V),u_tile_bl_up:new s.Uniform3f(V),u_tile_up_scale:new s.Uniform1f(V)}))(n)),I.includes("FOG")&&(this.fogUniforms=(V=>({u_fog_matrix:new s.UniformMatrix4f(V),u_fog_range:new s.Uniform2f(V),u_fog_color:new s.Uniform4f(V),u_fog_horizon_blend:new s.Uniform1f(V),u_fog_temporal_offset:new s.Uniform1f(V),u_frustum_tl:new s.Uniform3f(V),u_frustum_tr:new s.Uniform3f(V),u_frustum_br:new s.Uniform3f(V),u_frustum_bl:new s.Uniform3f(V),u_globe_pos:new s.Uniform3f(V),u_globe_radius:new s.Uniform1f(V),u_globe_transition:new s.Uniform1f(V),u_is_globe:new s.Uniform1i(V),u_viewport:new s.Uniform2f(V)}))(n))}}setTerrainUniformValues(n,a){if(!this.terrainUniforms)return;const p=this.terrainUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const _ in a)p[_]&&p[_].set(this.program,_,a[_])}}setGlobeUniformValues(n,a){if(!this.globeUniforms)return;const p=this.globeUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const _ in a)p[_]&&p[_].set(this.program,_,a[_])}}setFogUniformValues(n,a){if(!this.fogUniforms)return;const p=this.fogUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const _ in a)p[_].set(this.program,_,a[_])}}draw(n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee){const ie=n.gl;if(this.failedToCreate)return;n.program.set(this.program),n.setDepthMode(p),n.setStencilMode(_),n.setColorMode(b),n.setCullFace(I);for(const K of Object.keys(this.fixedUniforms))this.fixedUniforms[K].set(this.program,K,M[K]);te&&te.setUniforms(this.program,n,this.binderUniforms,Y,{zoom:J});const V={[ie.LINES]:2,[ie.TRIANGLES]:3,[ie.LINE_STRIP]:1}[a];for(const K of j.get()){const ae=K.vaos||(K.vaos={});(ae[P]||(ae[P]=new xc)).bind(n,this,N,te?te.getPaintVertexBuffers():[],z,K.vertexOffset,ee||[]),ie.drawElements(a,K.primitiveLength*V,ie.UNSIGNED_SHORT,K.primitiveOffset*V*2)}}}function qo(h,n){const a=Math.pow(2,n.tileID.overscaledZ),p=n.tileSize*Math.pow(2,h.transform.tileZoom)/a,_=p*(n.tileID.canonical.x+n.tileID.wrap*a),b=p*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_tile_units_to_pixels:1/wi(n,1,h.transform.tileZoom),u_pixel_coord_upper:[_>>16,b>>16],u_pixel_coord_lower:[65535&_,65535&b]}}const du=s.create(),_l=(h,n,a,p,_,b,I,M,P,N,z)=>{const j=n.style.light,Y=j.properties.get("position"),J=[Y.x,Y.y,Y.z],te=s.create$1();j.properties.get("anchor")==="viewport"&&(s.fromRotation(te,-n.transform.angle),s.transformMat3(J,J,te));const ee=j.properties.get("color"),ie=n.transform,V={u_matrix:h,u_lightpos:J,u_lightintensity:j.properties.get("intensity"),u_lightcolor:[ee.r,ee.g,ee.b],u_vertical_gradient:+a,u_opacity:p,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:du,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:_,u_edge_radius:b};return ie.projection.name==="globe"&&(V.u_tile_id=[I.canonical.x,I.canonical.y,1<{const Y=_l(h,n,a,p,_,b,I,P,N,z,j),J={u_height_factor:-Math.pow(2,I.overscaledZ)/M.tileSize/8};return s.extend(Y,qo(n,M),J)},Zo=h=>({u_matrix:h}),yl=(h,n,a)=>s.extend(Zo(h),qo(n,a)),bc=(h,n)=>({u_matrix:h,u_world:n}),wc=(h,n,a,p)=>s.extend(yl(h,n,a),{u_world:p}),Ec=s.create(),Ia=(h,n,a,p,_,b)=>{const I=h.transform,M=I.projection.name==="globe";let P;if(b.paint.get("circle-pitch-alignment")==="map")if(M){const z=s.globePixelsToTileUnits(I.zoom,n.canonical)*I._pixelsPerMercatorPixel;P=Float32Array.from([z,0,0,z])}else P=I.calculatePixelsToTileUnitsMatrix(a);else P=new Float32Array([I.pixelsToGLUnits[0],0,0,I.pixelsToGLUnits[1]]);const N={u_camera_to_center_distance:I.cameraToCenterDistance,u_matrix:h.translatePosMatrix(n.projMatrix,a,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_device_pixel_ratio:s.exported.devicePixelRatio,u_extrude_scale:P,u_inv_rot_matrix:Ec,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(M){N.u_inv_rot_matrix=p,N.u_merc_center=_,N.u_tile_id=[n.canonical.x,n.canonical.y,1<{const n=[];return h.paint.get("circle-pitch-alignment")==="map"&&n.push("PITCH_WITH_MAP"),h.paint.get("circle-pitch-scale")==="map"&&n.push("SCALE_WITH_MAP"),n},ka=(h,n,a,p)=>{const _=s.EXTENT/a.tileSize;return{u_matrix:h,u_camera_to_center_distance:n.getCameraToCenterDistance(p),u_extrude_scale:[n.pixelsToGLUnits[0]/_,n.pixelsToGLUnits[1]/_]}},Ma=(h,n,a=1)=>({u_matrix:h,u_color:n,u_overlay:0,u_overlay_scale:a}),gu=s.create(),_u=(h,n,a,p,_,b,I)=>{const M=h.transform,P=M.projection.name==="globe",N=P?s.globePixelsToTileUnits(M.zoom,n.canonical)*M._pixelsPerMercatorPixel:wi(a,1,b),z={u_matrix:n.projMatrix,u_extrude_scale:N,u_intensity:I,u_inv_rot_matrix:gu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(P){z.u_inv_rot_matrix=p,z.u_merc_center=_,z.u_tile_id=[n.canonical.x,n.canonical.y,1<{const M=h.transform,P=M.calculatePixelsToTileUnitsMatrix(n);return{u_matrix:xl(h,n,a,p),u_pixels_to_tile_units:P,u_device_pixel_ratio:b,u_units_to_pixels:[1/M.pixelsToGLUnits[0],1/M.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:_,u_texsize:xs(a)?n.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:vs(n,h.transform),u_alpha_discard_threshold:0,u_trim_offset:I}},Hs=(h,n,a,p,_)=>{const b=h.transform;return{u_matrix:xl(h,n,a,p),u_texsize:n.imageAtlasTexture.size,u_pixels_to_tile_units:b.calculatePixelsToTileUnitsMatrix(n),u_device_pixel_ratio:_,u_image:0,u_tile_units_to_pixels:vs(n,b),u_units_to_pixels:[1/b.pixelsToGLUnits[0],1/b.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function vs(h,n){return 1/wi(h,1,n.tileZoom)}function xl(h,n,a,p){return h.translatePosMatrix(p||n.tileID.projMatrix,n,a.paint.get("line-translate"),a.paint.get("line-translate-anchor"))}function xs(h){const n=h.paint.get("line-dasharray").value;return n.value||n.kind!=="constant"}const Aa=(h,n,a,p,_,b)=>{return{u_matrix:h,u_tl_parent:n,u_scale_parent:a,u_fade_t:p.mix,u_opacity:p.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:(M=_.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(I=_.paint.get("raster-contrast"),I>0?1/(1-I):1+I),u_spin_weights:jr(_.paint.get("raster-hue-rotate")),u_perspective_transform:b};var I,M};function jr(h){h*=Math.PI/180;const n=Math.sin(h),a=Math.cos(h);return[(2*a+1)/3,(-Math.sqrt(3)*n-a+1)/3,(Math.sqrt(3)*n-a+1)/3]}const Ca=s.create(),Pa=(h,n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee)=>{const ie=_.transform,V={u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:ie.cameraToCenterDistance,u_rotate_symbol:+a,u_aspect_ratio:ie.width/ie.height,u_fade_change:_.options.fadeDuration?_.symbolFadeChange:1,u_matrix:b,u_label_plane_matrix:I,u_coord_matrix:M,u_is_text:+P,u_pitch_with_map:+p,u_texsize:N,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ca,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ca,u_up_vector:[0,-1,0]};return ee.name==="globe"&&(V.u_tile_id=[z.canonical.x,z.canonical.y,1<s.extend(Pa(h,n,a,p,_,b,I,M,P,N,j,Y,J,te,ee,ie),{u_gamma_scale:p?_.transform.cameraToCenterDistance*Math.cos(_.terrain?0:_.transform._pitch):1,u_device_pixel_ratio:s.exported.devicePixelRatio,u_is_halo:+z}),yu=(h,n,a,p,_,b,I,M,P,N,z,j,Y,J,te,ee)=>s.extend(bs(h,n,a,p,_,b,I,M,!0,P,!0,z,j,Y,J,te,ee),{u_texsize_icon:N,u_texture_icon:1}),La=(h,n,a)=>({u_matrix:h,u_opacity:n,u_color:a}),vu=(h,n,a,p,_)=>s.extend(function(b,I,M){const P=I.imageManager.getPattern(b.toString()),{width:N,height:z}=I.imageManager.getPixelSize(),j=Math.pow(2,M.tileID.overscaledZ),Y=M.tileSize*Math.pow(2,I.transform.tileZoom)/j,J=Y*(M.tileID.canonical.x+M.tileID.wrap*j),te=Y*M.tileID.canonical.y;return{u_image:0,u_pattern_tl:P.tl,u_pattern_br:P.br,u_texsize:[N,z],u_pattern_size:P.displaySize,u_tile_units_to_pixels:1/wi(M,1,I.transform.tileZoom),u_pixel_coord_upper:[J>>16,te>>16],u_pixel_coord_lower:[65535&J,65535&te]}}(p,a,_),{u_matrix:h,u_opacity:n}),bl={fillExtrusion:h=>({u_matrix:new s.UniformMatrix4f(h),u_lightpos:new s.Uniform3f(h),u_lightintensity:new s.Uniform1f(h),u_lightcolor:new s.Uniform3f(h),u_vertical_gradient:new s.Uniform1f(h),u_opacity:new s.Uniform1f(h),u_edge_radius:new s.Uniform1f(h),u_ao:new s.Uniform2f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_up_dir:new s.Uniform3f(h),u_height_lift:new s.Uniform1f(h)}),fillExtrusionPattern:h=>({u_matrix:new s.UniformMatrix4f(h),u_lightpos:new s.Uniform3f(h),u_lightintensity:new s.Uniform1f(h),u_lightcolor:new s.Uniform3f(h),u_vertical_gradient:new s.Uniform1f(h),u_height_factor:new s.Uniform1f(h),u_edge_radius:new s.Uniform1f(h),u_ao:new s.Uniform2f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_up_dir:new s.Uniform3f(h),u_height_lift:new s.Uniform1f(h),u_image:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_pixel_coord_upper:new s.Uniform2f(h),u_pixel_coord_lower:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h),u_opacity:new s.Uniform1f(h)}),fill:h=>({u_matrix:new s.UniformMatrix4f(h)}),fillPattern:h=>({u_matrix:new s.UniformMatrix4f(h),u_image:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_pixel_coord_upper:new s.Uniform2f(h),u_pixel_coord_lower:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h)}),fillOutline:h=>({u_matrix:new s.UniformMatrix4f(h),u_world:new s.Uniform2f(h)}),fillOutlinePattern:h=>({u_matrix:new s.UniformMatrix4f(h),u_world:new s.Uniform2f(h),u_image:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_pixel_coord_upper:new s.Uniform2f(h),u_pixel_coord_lower:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h)}),circle:h=>({u_camera_to_center_distance:new s.Uniform1f(h),u_extrude_scale:new s.UniformMatrix2f(h),u_device_pixel_ratio:new s.Uniform1f(h),u_matrix:new s.UniformMatrix4f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_up_dir:new s.Uniform3f(h)}),collisionBox:h=>({u_matrix:new s.UniformMatrix4f(h),u_camera_to_center_distance:new s.Uniform1f(h),u_extrude_scale:new s.Uniform2f(h)}),collisionCircle:h=>({u_matrix:new s.UniformMatrix4f(h),u_inv_matrix:new s.UniformMatrix4f(h),u_camera_to_center_distance:new s.Uniform1f(h),u_viewport_size:new s.Uniform2f(h)}),debug:h=>({u_color:new s.UniformColor(h),u_matrix:new s.UniformMatrix4f(h),u_overlay:new s.Uniform1i(h),u_overlay_scale:new s.Uniform1f(h)}),clippingMask:h=>({u_matrix:new s.UniformMatrix4f(h)}),heatmap:h=>({u_extrude_scale:new s.Uniform1f(h),u_intensity:new s.Uniform1f(h),u_matrix:new s.UniformMatrix4f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_up_dir:new s.Uniform3f(h)}),heatmapTexture:h=>({u_image:new s.Uniform1i(h),u_color_ramp:new s.Uniform1i(h),u_opacity:new s.Uniform1f(h)}),hillshade:h=>({u_matrix:new s.UniformMatrix4f(h),u_image:new s.Uniform1i(h),u_latrange:new s.Uniform2f(h),u_light:new s.Uniform2f(h),u_shadow:new s.UniformColor(h),u_highlight:new s.UniformColor(h),u_accent:new s.UniformColor(h)}),hillshadePrepare:h=>({u_matrix:new s.UniformMatrix4f(h),u_image:new s.Uniform1i(h),u_dimension:new s.Uniform2f(h),u_zoom:new s.Uniform1f(h),u_unpack:new s.Uniform4f(h)}),line:h=>({u_matrix:new s.UniformMatrix4f(h),u_pixels_to_tile_units:new s.UniformMatrix2f(h),u_device_pixel_ratio:new s.Uniform1f(h),u_units_to_pixels:new s.Uniform2f(h),u_dash_image:new s.Uniform1i(h),u_gradient_image:new s.Uniform1i(h),u_image_height:new s.Uniform1f(h),u_texsize:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h),u_alpha_discard_threshold:new s.Uniform1f(h),u_trim_offset:new s.Uniform2f(h)}),linePattern:h=>({u_matrix:new s.UniformMatrix4f(h),u_texsize:new s.Uniform2f(h),u_pixels_to_tile_units:new s.UniformMatrix2f(h),u_device_pixel_ratio:new s.Uniform1f(h),u_image:new s.Uniform1i(h),u_units_to_pixels:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h),u_alpha_discard_threshold:new s.Uniform1f(h)}),raster:h=>({u_matrix:new s.UniformMatrix4f(h),u_tl_parent:new s.Uniform2f(h),u_scale_parent:new s.Uniform1f(h),u_fade_t:new s.Uniform1f(h),u_opacity:new s.Uniform1f(h),u_image0:new s.Uniform1i(h),u_image1:new s.Uniform1i(h),u_brightness_low:new s.Uniform1f(h),u_brightness_high:new s.Uniform1f(h),u_saturation_factor:new s.Uniform1f(h),u_contrast_factor:new s.Uniform1f(h),u_spin_weights:new s.Uniform3f(h),u_perspective_transform:new s.Uniform2f(h)}),symbolIcon:h=>({u_is_size_zoom_constant:new s.Uniform1i(h),u_is_size_feature_constant:new s.Uniform1i(h),u_size_t:new s.Uniform1f(h),u_size:new s.Uniform1f(h),u_camera_to_center_distance:new s.Uniform1f(h),u_rotate_symbol:new s.Uniform1i(h),u_aspect_ratio:new s.Uniform1f(h),u_fade_change:new s.Uniform1f(h),u_matrix:new s.UniformMatrix4f(h),u_label_plane_matrix:new s.UniformMatrix4f(h),u_coord_matrix:new s.UniformMatrix4f(h),u_is_text:new s.Uniform1i(h),u_pitch_with_map:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_camera_forward:new s.Uniform3f(h),u_tile_matrix:new s.UniformMatrix4f(h),u_up_vector:new s.Uniform3f(h),u_ecef_origin:new s.Uniform3f(h),u_texture:new s.Uniform1i(h)}),symbolSDF:h=>({u_is_size_zoom_constant:new s.Uniform1i(h),u_is_size_feature_constant:new s.Uniform1i(h),u_size_t:new s.Uniform1f(h),u_size:new s.Uniform1f(h),u_camera_to_center_distance:new s.Uniform1f(h),u_rotate_symbol:new s.Uniform1i(h),u_aspect_ratio:new s.Uniform1f(h),u_fade_change:new s.Uniform1f(h),u_matrix:new s.UniformMatrix4f(h),u_label_plane_matrix:new s.UniformMatrix4f(h),u_coord_matrix:new s.UniformMatrix4f(h),u_is_text:new s.Uniform1i(h),u_pitch_with_map:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_texture:new s.Uniform1i(h),u_gamma_scale:new s.Uniform1f(h),u_device_pixel_ratio:new s.Uniform1f(h),u_tile_id:new s.Uniform3f(h),u_zoom_transition:new s.Uniform1f(h),u_inv_rot_matrix:new s.UniformMatrix4f(h),u_merc_center:new s.Uniform2f(h),u_camera_forward:new s.Uniform3f(h),u_tile_matrix:new s.UniformMatrix4f(h),u_up_vector:new s.Uniform3f(h),u_ecef_origin:new s.Uniform3f(h),u_is_halo:new s.Uniform1i(h)}),symbolTextAndIcon:h=>({u_is_size_zoom_constant:new s.Uniform1i(h),u_is_size_feature_constant:new s.Uniform1i(h),u_size_t:new s.Uniform1f(h),u_size:new s.Uniform1f(h),u_camera_to_center_distance:new s.Uniform1f(h),u_rotate_symbol:new s.Uniform1i(h),u_aspect_ratio:new s.Uniform1f(h),u_fade_change:new s.Uniform1f(h),u_matrix:new s.UniformMatrix4f(h),u_label_plane_matrix:new s.UniformMatrix4f(h),u_coord_matrix:new s.UniformMatrix4f(h),u_is_text:new s.Uniform1i(h),u_pitch_with_map:new s.Uniform1i(h),u_texsize:new s.Uniform2f(h),u_texsize_icon:new s.Uniform2f(h),u_texture:new s.Uniform1i(h),u_texture_icon:new s.Uniform1i(h),u_gamma_scale:new s.Uniform1f(h),u_device_pixel_ratio:new s.Uniform1f(h),u_is_halo:new s.Uniform1i(h)}),background:h=>({u_matrix:new s.UniformMatrix4f(h),u_opacity:new s.Uniform1f(h),u_color:new s.UniformColor(h)}),backgroundPattern:h=>({u_matrix:new s.UniformMatrix4f(h),u_opacity:new s.Uniform1f(h),u_image:new s.Uniform1i(h),u_pattern_tl:new s.Uniform2f(h),u_pattern_br:new s.Uniform2f(h),u_texsize:new s.Uniform2f(h),u_pattern_size:new s.Uniform2f(h),u_pixel_coord_upper:new s.Uniform2f(h),u_pixel_coord_lower:new s.Uniform2f(h),u_tile_units_to_pixels:new s.Uniform1f(h)}),terrainRaster:gl,terrainDepth:gl,skybox:h=>({u_matrix:new s.UniformMatrix4f(h),u_sun_direction:new s.Uniform3f(h),u_cubemap:new s.Uniform1i(h),u_opacity:new s.Uniform1f(h),u_temporal_offset:new s.Uniform1f(h)}),skyboxGradient:h=>({u_matrix:new s.UniformMatrix4f(h),u_color_ramp:new s.Uniform1i(h),u_center_direction:new s.Uniform3f(h),u_radius:new s.Uniform1f(h),u_opacity:new s.Uniform1f(h),u_temporal_offset:new s.Uniform1f(h)}),skyboxCapture:h=>({u_matrix_3f:new s.UniformMatrix3f(h),u_sun_direction:new s.Uniform3f(h),u_sun_intensity:new s.Uniform1f(h),u_color_tint_r:new s.Uniform4f(h),u_color_tint_m:new s.Uniform4f(h),u_luminance:new s.Uniform1f(h)}),globeRaster:h=>({u_proj_matrix:new s.UniformMatrix4f(h),u_globe_matrix:new s.UniformMatrix4f(h),u_normalize_matrix:new s.UniformMatrix4f(h),u_merc_matrix:new s.UniformMatrix4f(h),u_zoom_transition:new s.Uniform1f(h),u_merc_center:new s.Uniform2f(h),u_image0:new s.Uniform1i(h),u_grid_matrix:new s.UniformMatrix3f(h),u_skirt_height:new s.Uniform1f(h),u_frustum_tl:new s.Uniform3f(h),u_frustum_tr:new s.Uniform3f(h),u_frustum_br:new s.Uniform3f(h),u_frustum_bl:new s.Uniform3f(h),u_globe_pos:new s.Uniform3f(h),u_globe_radius:new s.Uniform1f(h),u_viewport:new s.Uniform2f(h)}),globeAtmosphere:h=>({u_frustum_tl:new s.Uniform3f(h),u_frustum_tr:new s.Uniform3f(h),u_frustum_br:new s.Uniform3f(h),u_frustum_bl:new s.Uniform3f(h),u_horizon:new s.Uniform1f(h),u_transition:new s.Uniform1f(h),u_fadeout_range:new s.Uniform1f(h),u_color:new s.Uniform4f(h),u_high_color:new s.Uniform4f(h),u_space_color:new s.Uniform4f(h),u_star_intensity:new s.Uniform1f(h),u_star_density:new s.Uniform1f(h),u_star_size:new s.Uniform1f(h),u_temporal_offset:new s.Uniform1f(h),u_horizon_angle:new s.Uniform1f(h),u_rotation_matrix:new s.UniformMatrix4f(h)})};let Ra;function Yr(h,n,a,p,_,b,I){const M=h.context,P=M.gl,N=h.transform,z=h.useProgram("collisionBox"),j=[];let Y=0,J=0;for(let le=0;le0){const Re=s.create(),We=ke;s.mul(Re,be.placementInvProjMatrix,N.glCoordMatrix),s.mul(Re,Re,be.placementViewportMatrix),j.push({circleArray:tt,circleOffset:J,transform:We,invTransform:Re,projection:be.getProjection()}),Y+=tt.length/4,J=Y}Ne&&(h.terrain&&h.terrain.setupElevationDraw(Te,z),z.draw(M,P.LINES,s.DepthMode.disabled,s.StencilMode.disabled,h.colorModeForRenderPass(),s.CullFaceMode.disabled,ka(ke,N,Te,be.getProjection()),a.id,Ne.layoutVertexBuffer,Ne.indexBuffer,Ne.segments,null,N.zoom,null,[Ne.collisionVertexBuffer,Ne.collisionVertexBufferExt]))}if(!I||!j.length)return;const te=h.useProgram("collisionCircle"),ee=new s.StructArrayLayout2f1f2i16;ee.resize(4*Y),ee._trim();let ie=0;for(const le of j)for(let xe=0;xe=0&&(te[le.associatedIconIndex]={x:Re,y:We,z:je,angle:Ke})}else zr(be,Y)}if(z){J.clear();const ae=h.icon.placedSymbolArray;for(let le=0;leRe.sortKey-We.sortKey);for(const Re of ke){const We=Re.state;if(h.terrain&&h.terrain.setupElevationDraw(We.tile,We.program,{useDepthForOcclusion:!Ae,labelPlaneMatrixInv:We.labelPlaneMatrixInv}),Y.activeTexture.set(J.TEXTURE0),We.atlasTexture.bind(We.atlasInterpolation,J.CLAMP_TO_EDGE),We.atlasTextureIcon&&(Y.activeTexture.set(J.TEXTURE1),We.atlasTextureIcon&&We.atlasTextureIcon.bind(We.atlasInterpolationIcon,J.CLAMP_TO_EDGE)),We.isSDF){const je=We.uniformValues;We.hasHalo&&(je.u_is_halo=1,o(We.buffers,Re.segments,a,h,We.program,xe,z,j,je)),je.u_is_halo=0}o(We.buffers,Re.segments,a,h,We.program,xe,z,j,We.uniformValues)}}function o(h,n,a,p,_,b,I,M,P){const N=p.context,z=[h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer,h.globeExtVertexBuffer];_.draw(N,N.gl.TRIANGLES,b,I,M,s.CullFaceMode.disabled,P,a.id,h.layoutVertexBuffer,h.indexBuffer,n,a.paint,p.transform.zoom,h.programConfigurations.get(a.id),z)}function l(h,n,a,p,_,b,I){const M=h.context.gl,P=a.paint.get("fill-pattern"),N=P&&P.constantOr(1);let z,j,Y,J,te;I?(j=N&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",z=M.LINES):(j=N?"fillPattern":"fill",z=M.TRIANGLES);for(const ee of p){const ie=n.getTile(ee);if(N&&!ie.patternsLoaded())continue;const V=ie.getBucket(a);if(!V)continue;h.prepareDrawTile();const K=V.programConfigurations.get(a.id),ae=h.useProgram(j,K);N&&(h.context.activeTexture.set(M.TEXTURE0),ie.imageAtlasTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),K.updatePaintBuffers());const le=P.constantOr(null);if(le&&ie.imageAtlas){const Te=ie.imageAtlas.patternPositions[le.toString()];Te&&K.setConstantPatternPositions(Te)}const xe=h.translatePosMatrix(ee.projMatrix,ie,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));if(I){J=V.indexBuffer2,te=V.segments2;const Te=h.terrain&&h.terrain.renderingToTexture?h.terrain.drapeBufferSize:[M.drawingBufferWidth,M.drawingBufferHeight];Y=j==="fillOutlinePattern"&&N?wc(xe,h,ie,Te):bc(xe,Te)}else J=V.indexBuffer,te=V.segments,Y=N?yl(xe,h,ie):Zo(xe);h.prepareDrawProgram(h.context,ae,ee.toUnwrapped()),ae.draw(h.context,z,_,h.stencilModeForClipping(ee),b,s.CullFaceMode.disabled,Y,a.id,V.layoutVertexBuffer,J,te,a.paint,h.transform.zoom,K)}}function c(h,n,a,p,_,b,I){const M=h.context,P=M.gl,N=h.transform,z=a.paint.get("fill-extrusion-pattern"),j=z.constantOr(1),Y=a.paint.get("fill-extrusion-opacity"),J=[a.paint.get("fill-extrusion-ambient-occlusion-intensity"),a.paint.get("fill-extrusion-ambient-occlusion-radius")],te=a.layout.get("fill-extrusion-edge-radius"),ee=te>0&&!a.paint.get("fill-extrusion-rounded-roof"),ie=ee?0:te,V=N.projection.name==="globe"?s.fillExtrusionHeightLift():0,K=N.projection.name==="globe",ae=K?s.globeToMercatorTransition(N.zoom):0,le=[s.mercatorXfromLng(N.center.lng),s.mercatorYfromLat(N.center.lat)],xe=[];K&&xe.push("PROJECTION_GLOBE_VIEW"),J[0]>0&&xe.push("FAUX_AO"),ee&&xe.push("ZERO_ROOF_RADIUS");for(const Te of p){const be=n.getTile(Te),Ae=be.getBucket(a);if(!Ae||Ae.projection.name!==N.projection.name)continue;const ke=Ae.programConfigurations.get(a.id),Ne=h.useProgram(j?"fillExtrusionPattern":"fillExtrusion",ke,xe);if(h.terrain){const Ze=h.terrain;if(h.style.terrainSetForDrapingOnly())Ze.setupElevationDraw(be,Ne,{useMeterToDem:!0});else{if(!Ae.enableTerrain)continue;if(Ze.setupElevationDraw(be,Ne,{useMeterToDem:!0}),g(M,n,Te,Ae,a,Ze),!Ae.centroidVertexBuffer){const rt=Ne.attributes.a_centroid_pos;rt!==void 0&&P.vertexAttrib2f(rt,0,0)}}}j&&(h.context.activeTexture.set(P.TEXTURE0),be.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ke.updatePaintBuffers());const tt=z.constantOr(null);if(tt&&be.imageAtlas){const Ze=be.imageAtlas.patternPositions[tt.toString()];Ze&&ke.setConstantPatternPositions(Ze)}const Re=h.translatePosMatrix(Te.projMatrix,be,a.paint.get("fill-extrusion-translate"),a.paint.get("fill-extrusion-translate-anchor")),We=N.projection.createInversionMatrix(N,Te.canonical),je=a.paint.get("fill-extrusion-vertical-gradient"),et=j?mu(Re,h,je,Y,J,ie,Te,be,V,ae,le,We):_l(Re,h,je,Y,J,ie,Te,V,ae,le,We);h.prepareDrawProgram(M,Ne,Te.toUnwrapped());const ze=[];h.terrain&&ze.push(Ae.centroidVertexBuffer),K&&ze.push(Ae.layoutVertexExtBuffer),Ne.draw(M,M.gl.TRIANGLES,_,b,I,s.CullFaceMode.backCCW,et,a.id,Ae.layoutVertexBuffer,Ae.indexBuffer,Ae.segments,a.paint,h.transform.zoom,ke,ze)}}function g(h,n,a,p,_,b){const I=[V=>{let K=V.canonical.x-1,ae=V.wrap;return K<0&&(K=(1<{let K=V.canonical.x+1,ae=V.wrap;return K===1<new s.OverscaledTileID(V.overscaledZ,V.wrap,V.canonical.z,V.canonical.x,(V.canonical.y===0?1<new s.OverscaledTileID(V.overscaledZ,V.wrap,V.canonical.z,V.canonical.x,V.canonical.y===(1<{const K=n.getSource().minzoom,ae=xe=>{const Te=n.getTileByID(xe);if(Te&&Te.hasData())return Te.getBucket(_)},le=[0,-1,1];for(const xe of le){if(V.overscaledZ+xe(P[0]=Math.min(V.min.y,K.min.y),P[1]=Math.max(V.max.y,K.max.y),P[2]=s.EXTENT-K.min.x>V.max.x?K.min.x-s.EXTENT:V.max.x,P),z=(V,K)=>(P[0]=Math.min(V.min.x,K.min.x),P[1]=Math.max(V.max.x,K.max.x),P[2]=s.EXTENT-K.min.y>V.max.y?K.min.y-s.EXTENT:V.max.y,P),j=[(V,K)=>N(V,K),(V,K)=>N(K,V),(V,K)=>z(V,K),(V,K)=>z(K,V)],Y=new s.Point(0,0);let J,te,ee;const ie=(V,K,ae,le,xe)=>{const Te=[[le?ae:V,le?V:ae,0],[le?ae:K,le?K:ae,0]],be=xe<0?s.EXTENT+xe:xe,Ae=[le?be:(V+K)/2,le?(V+K)/2:be,0];return ae===0&&xe<0||ae!==0&&xe>0?b.getForTilePoints(ee,[Ae],!0,te):Te.push(Ae),b.getForTilePoints(a,Te,!0,J),Math.max(Te[0][2],Te[1][2],Ae[2])/b.exaggeration()};for(let V=0;V<4;V++){const K=(V<2?1:5)-V,ae=p.borders[V];if(ae.length===0)continue;const le=ee=I[V](a),xe=M(le);if(!(xe&&xe instanceof s.FillExtrusionBucket&&xe.enableTerrain)||p.borderDoneWithNeighborZ[V]===xe.canonical.z&&xe.borderDoneWithNeighborZ[K]===p.canonical.z||(te=b.findDEMTileFor(le),!te||!te.dem))continue;if(!J){const ke=b.findDEMTileFor(a);if(!ke||!ke.dem)return;J=ke}const Te=xe.borders[K];let be=0;const Ae=xe.borderDoneWithNeighborZ[K]!==p.canonical.z;if(p.canonical.z===xe.canonical.z){for(let ke=0;kett[0]+3));)Ae&&xe.encodeCentroid(void 0,Re,!1),be++;if(Re&&bett[1]-3)&&(je++,++be!==Te.length);)Re=xe.featuresOnBorder[Te[be]];if(Re=xe.featuresOnBorder[Te[We]],Ne.intersectsCount()>1||Re.intersectsCount()>1||je!==1){je!==1&&(be=We),p.encodeCentroid(void 0,Ne,!1),Ae&&xe.encodeCentroid(void 0,Re,!1);continue}const et=j[V](Ne,Re),ze=V%2?s.EXTENT-1:0;Y.x=ie(et[0],Math.min(s.EXTENT-1,et[1]),ze,V<2,et[2]),Y.y=0,p.encodeCentroid(Y,Ne,!1),Ae&&xe.encodeCentroid(Y,Re,!1)}else p.encodeCentroid(void 0,Ne,!1)}p.borderDoneWithNeighborZ[V]=xe.canonical.z,p.needsCentroidUpdate=!0,Ae&&(xe.borderDoneWithNeighborZ[K]=p.canonical.z,xe.needsCentroidUpdate=!0)}else{for(const ke of ae)p.encodeCentroid(void 0,p.featuresOnBorder[ke],!1);if(Ae){for(const ke of Te)xe.encodeCentroid(void 0,xe.featuresOnBorder[ke],!1);xe.borderDoneWithNeighborZ[K]=p.canonical.z,xe.needsCentroidUpdate=!0}p.borderDoneWithNeighborZ[V]=xe.canonical.z,p.needsCentroidUpdate=!0}}(p.needsCentroidUpdate||!p.centroidVertexBuffer&&p.centroidVertexArray.length!==0)&&p.uploadCentroid(h)}const S=new s.Color(1,0,0,1),R=new s.Color(0,1,0,1),F=new s.Color(0,0,1,1),q=new s.Color(1,0,1,1),Q=new s.Color(0,1,1,1);function Ee(h,n,a){const p=h.context,_=h.transform,b=p.gl,I=_.projection.name==="globe",M=I?["PROJECTION_GLOBE_VIEW"]:null;let P=a.projMatrix;if(I&&s.globeToMercatorTransition(_.zoom)>0){const Ne=s.transitionTileAABBinECEF(a.canonical,_),tt=s.globeDenormalizeECEF(Ne);P=s.multiply(new Float32Array(16),_.globeMatrix,tt),s.multiply(P,_.projMatrix,P)}const N=h.useProgram("debug",null,M),z=n.getTileByID(a.key);h.terrain&&h.terrain.setupElevationDraw(z,N);const j=s.DepthMode.disabled,Y=s.StencilMode.disabled,J=h.colorModeForRenderPass(),te="$debug";p.activeTexture.set(b.TEXTURE0),h.emptyTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),I?z._makeGlobeTileDebugBuffers(h.context,_):z._makeDebugTileBoundsBuffers(h.context,_.projection);const ee=z._tileDebugBuffer||h.debugBuffer,ie=z._tileDebugIndexBuffer||h.debugIndexBuffer,V=z._tileDebugSegments||h.debugSegments;N.draw(p,b.LINE_STRIP,j,Y,J,s.CullFaceMode.disabled,Ma(P,s.Color.red),te,ee,ie,V,null,null,null,[z._globeTileDebugBorderBuffer]);const K=z.latestRawTileData,ae=Math.floor((K&&K.byteLength||0)/1024),le=n.getTile(a).tileSize,xe=512/Math.min(le,512)*(a.overscaledZ/_.zoom)*.5;let Te=a.canonical.toString();a.overscaledZ!==a.canonical.z&&(Te+=` => ${a.overscaledZ}`),Te+=` ${ae}kb`,function(Ne,tt){Ne.initDebugOverlayCanvas();const Re=Ne.debugOverlayCanvas,We=Ne.context.gl,je=Ne.debugOverlayCanvas.getContext("2d");je.clearRect(0,0,Re.width,Re.height),je.shadowColor="white",je.shadowBlur=2,je.lineWidth=1.5,je.strokeStyle="white",je.textBaseline="top",je.font="bold 36px Open Sans, sans-serif",je.fillText(tt,5,5),je.strokeText(tt,5,5),Ne.debugOverlayTexture.update(Re),Ne.debugOverlayTexture.bind(We.LINEAR,We.CLAMP_TO_EDGE)}(h,Te);const be=z._tileDebugTextBuffer||h.debugBuffer,Ae=z._tileDebugTextIndexBuffer||h.quadTriangleIndexBuffer,ke=z._tileDebugTextSegments||h.debugSegments;N.draw(p,b.TRIANGLES,j,Y,s.ColorMode.alphaBlended,s.CullFaceMode.disabled,Ma(P,s.Color.transparent,xe),te,be,Ae,ke,null,null,null,[z._globeTileDebugTextBuffer])}function Me(h,n,a,p){pt(h,0,n+a/2,h.transform.width,a,p)}function Xe(h,n,a,p){pt(h,n-a/2,0,a,h.transform.height,p)}function pt(h,n,a,p,_,b){const I=h.context,M=I.gl;M.enable(M.SCISSOR_TEST),M.scissor(n*s.exported.devicePixelRatio,a*s.exported.devicePixelRatio,p*s.exported.devicePixelRatio,_*s.exported.devicePixelRatio),I.clear({color:b}),M.disable(M.SCISSOR_TEST)}const dt=s.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Vt}=dt;function Ut(h,n,a,p){h.emplaceBack(n,a,p)}class ei{constructor(n){this.vertexArray=new s.StructArrayLayout3f12,this.indices=new s.StructArrayLayout3ui6,Ut(this.vertexArray,-1,-1,1),Ut(this.vertexArray,1,-1,1),Ut(this.vertexArray,-1,1,1),Ut(this.vertexArray,1,1,1),Ut(this.vertexArray,-1,-1,-1),Ut(this.vertexArray,1,-1,-1),Ut(this.vertexArray,-1,1,-1),Ut(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=n.createVertexBuffer(this.vertexArray,Vt),this.indexBuffer=n.createIndexBuffer(this.indices),this.segment=s.SegmentVector.simpleSegment(0,0,36,12)}}function yi(h,n,a,p,_,b){const I=h.gl,M=n.paint.get("sky-atmosphere-color"),P=n.paint.get("sky-atmosphere-halo-color"),N=n.paint.get("sky-atmosphere-sun-intensity"),z=((j,Y,J,te,ee)=>({u_matrix_3f:j,u_sun_direction:Y,u_sun_intensity:J,u_color_tint_r:[te.r,te.g,te.b,te.a],u_color_tint_m:[ee.r,ee.g,ee.b,ee.a],u_luminance:5e-5}))(s.fromMat4(s.create$1(),p),_,N,M,P);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+b,n.skyboxTexture,0),a.draw(h,I.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.frontCW,z,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Xi=s.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Fn{constructor(n){const a=new s.StructArrayLayout5f20;a.emplaceBack(-1,1,1,0,0),a.emplaceBack(1,1,1,1,0),a.emplaceBack(1,-1,1,1,1),a.emplaceBack(-1,-1,1,0,1);const p=new s.StructArrayLayout3ui6;p.emplaceBack(0,1,2),p.emplaceBack(2,3,0),this.vertexBuffer=n.createVertexBuffer(a,Xi.members),this.indexBuffer=n.createIndexBuffer(p),this.segments=s.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const bn={symbol:function(h,n,a,p,_){if(h.renderPass!=="translucent")return;const b=s.StencilMode.disabled,I=h.colorModeForRenderPass();a.layout.get("text-variable-anchor")&&function(M,P,N,z,j,Y,J){const te=P.transform,ee=j==="map",ie=Y==="map";for(const V of M){const K=z.getTile(V),ae=K.getBucket(N);if(!ae||!ae.text||!ae.text.segments.get().length)continue;const le=s.evaluateSizeForZoom(ae.textSizeData,te.zoom),xe=Zi(V,ae.getProjection(),te),Te=te.calculatePixelsToTileUnitsMatrix(K),be=Ge(xe,K.tileID.canonical,ie,ee,te,ae.getProjection(),Te),Ae=N.layout.get("icon-text-fit")!=="none"&&ae.hasIconData();if(le){const ke=Math.pow(2,te.zoom-K.tileID.overscaledZ);Tr(ae,ee,ie,J,s.symbolSize,te,be,V,ke,le,Ae)}}}(p,h,a,n,a.layout.get("text-rotation-alignment"),a.layout.get("text-pitch-alignment"),_),a.paint.get("icon-opacity").constantOr(1)!==0&&v(h,n,a,p,!1,a.paint.get("icon-translate"),a.paint.get("icon-translate-anchor"),a.layout.get("icon-rotation-alignment"),a.layout.get("icon-pitch-alignment"),a.layout.get("icon-keep-upright"),b,I),a.paint.get("text-opacity").constantOr(1)!==0&&v(h,n,a,p,!0,a.paint.get("text-translate"),a.paint.get("text-translate-anchor"),a.layout.get("text-rotation-alignment"),a.layout.get("text-pitch-alignment"),a.layout.get("text-keep-upright"),b,I),n.map.showCollisionBoxes&&(Yr(h,n,a,p,a.paint.get("text-translate"),a.paint.get("text-translate-anchor"),!0),Yr(h,n,a,p,a.paint.get("icon-translate"),a.paint.get("icon-translate-anchor"),!1))},circle:function(h,n,a,p){if(h.renderPass!=="translucent")return;const _=a.paint.get("circle-opacity"),b=a.paint.get("circle-stroke-width"),I=a.paint.get("circle-stroke-opacity"),M=a.layout.get("circle-sort-key").constantOr(1)!==void 0;if(_.constantOr(1)===0&&(b.constantOr(1)===0||I.constantOr(1)===0))return;const P=h.context,N=P.gl,z=h.transform,j=h.depthModeForSublayer(0,s.DepthMode.ReadOnly),Y=s.StencilMode.disabled,J=h.colorModeForRenderPass(),te=z.projection.name==="globe",ee=[s.mercatorXfromLng(z.center.lng),s.mercatorYfromLat(z.center.lat)],ie=[];for(let K=0;KK.sortKey-ae.sortKey);const V={useDepthForOcclusion:!te};for(const K of ie){const{programConfiguration:ae,program:le,layoutVertexBuffer:xe,globeExtVertexBuffer:Te,indexBuffer:be,uniformValues:Ae,tile:ke}=K.state,Ne=K.segments;h.terrain&&h.terrain.setupElevationDraw(ke,le,V),h.prepareDrawProgram(P,le,ke.tileID.toUnwrapped()),le.draw(P,N.TRIANGLES,j,Y,J,s.CullFaceMode.disabled,Ae,a.id,xe,be,Ne,a.paint,z.zoom,ae,[Te])}},heatmap:function(h,n,a,p){if(a.paint.get("heatmap-opacity")!==0)if(h.renderPass==="offscreen"){const _=h.context,b=_.gl,I=s.StencilMode.disabled,M=new s.ColorMode([b.ONE,b.ONE],s.Color.transparent,[!0,!0,!0,!0]);(function(J,te,ee,ie){const V=J.gl,K=te.width*ie,ae=te.height*ie;J.activeTexture.set(V.TEXTURE1),J.viewport.set([0,0,K,ae]);let le=ee.heatmapFbo;if(!le||le&&(le.width!==K||le.height!==ae)){le&&le.destroy();const xe=V.createTexture();V.bindTexture(V.TEXTURE_2D,xe),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_WRAP_S,V.CLAMP_TO_EDGE),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_WRAP_T,V.CLAMP_TO_EDGE),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_MIN_FILTER,V.LINEAR),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_MAG_FILTER,V.LINEAR),le=ee.heatmapFbo=J.createFramebuffer(K,ae,!1),function(Te,be,Ae,ke,Ne,tt){const Re=Te.gl;Re.texImage2D(Re.TEXTURE_2D,0,Te.isWebGL2&&Te.extRenderToTextureHalfFloat?Re.RGBA16F:Re.RGBA,Ne,tt,0,Re.RGBA,Te.extRenderToTextureHalfFloat?Te.isWebGL2?Re.HALF_FLOAT:Te.extTextureHalfFloat.HALF_FLOAT_OES:Re.UNSIGNED_BYTE,null),ke.colorAttachment.set(Ae)}(J,0,xe,le,K,ae)}else V.bindTexture(V.TEXTURE_2D,le.colorAttachment.get()),J.bindFramebuffer.set(le.framebuffer)})(_,h,a,h.transform.projection.name==="globe"?.5:.25),_.clear({color:s.Color.transparent});const P=h.transform,N=P.projection.name==="globe",z=N?["PROJECTION_GLOBE_VIEW"]:null,j=N?s.CullFaceMode.frontCCW:s.CullFaceMode.disabled,Y=[s.mercatorXfromLng(P.center.lng),s.mercatorYfromLat(P.center.lat)];for(let J=0;J({u_image:0,u_color_ramp:1,u_opacity:j.paint.get("heatmap-opacity")}))(0,b),b.id,_.viewportBuffer,_.quadTriangleIndexBuffer,_.viewportSegments,b.paint,_.transform.zoom)}(h,a))},line:function(h,n,a,p){if(h.renderPass!=="translucent")return;const _=a.paint.get("line-opacity"),b=a.paint.get("line-width");if(_.constantOr(1)===0||b.constantOr(1)===0)return;const I=h.depthModeForSublayer(0,s.DepthMode.ReadOnly),M=h.colorModeForRenderPass(),P=h.terrain&&h.terrain.renderingToTexture?1:s.exported.devicePixelRatio,N=a.paint.get("line-dasharray"),z=N.constantOr(1),j=a.layout.get("line-cap"),Y=a.paint.get("line-pattern"),J=Y.constantOr(1),te=a.paint.get("line-gradient"),ee=J?"linePattern":"line",ie=h.context,V=ie.gl,K=(le=>{const xe=[];xs(le)&&xe.push("RENDER_LINE_DASH"),le.paint.get("line-gradient")&&xe.push("RENDER_LINE_GRADIENT");const Te=le.paint.get("line-trim-offset");Te[0]===0&&Te[1]===0||xe.push("RENDER_LINE_TRIM_OFFSET");const be=le.paint.get("line-pattern").constantOr(1),Ae=le.paint.get("line-opacity").constantOr(1)!==1;return!be&&Ae&&xe.push("RENDER_LINE_ALPHA_DISCARD"),xe})(a);let ae=K.includes("RENDER_LINE_ALPHA_DISCARD");h.terrain&&h.terrain.clipOrMaskOverlapStencilType()&&(ae=!1);for(const le of p){const xe=n.getTile(le);if(J&&!xe.patternsLoaded())continue;const Te=xe.getBucket(a);if(!Te)continue;h.prepareDrawTile();const be=Te.programConfigurations.get(a.id),Ae=h.useProgram(ee,be,K),ke=Y.constantOr(null);if(ke&&xe.imageAtlas){const Ze=xe.imageAtlas.patternPositions[ke.toString()];Ze&&be.setConstantPatternPositions(Ze)}const Ne=N.constantOr(null),tt=j.constantOr(null);if(!J&&Ne&&tt&&xe.lineAtlas){const Ze=xe.lineAtlas.getDash(Ne,tt);Ze&&be.setConstantPatternPositions(Ze)}let[Re,We]=a.paint.get("line-trim-offset");(tt==="round"||tt==="square")&&Re!==We&&(Re===0&&(Re-=1),We===1&&(We+=1));const je=h.terrain?le.projMatrix:null,et=J?Hs(h,xe,a,je,P):Tc(h,xe,a,je,Te.lineClipsArray.length,P,[Re,We]);if(te){const Ze=Te.gradients[a.id];let rt=Ze.texture;if(a.gradientVersion!==Ze.version){let Ke=256;if(a.stepInterpolant){const st=n.getSource().maxzoom,zt=le.canonical.z===st?Math.ceil(1<{Ae.draw(ie,V.TRIANGLES,I,Ze,M,s.CullFaceMode.disabled,et,a.id,Te.layoutVertexBuffer,Te.indexBuffer,Te.segments,a.paint,h.transform.zoom,be,[Te.layoutVertexBuffer2])};if(ae){const Ze=h.stencilModeForClipping(le).ref;Ze===0&&h.terrain&&ie.clear({stencil:0});const rt={func:V.EQUAL,mask:255};et.u_alpha_discard_threshold=.8,ze(new s.StencilMode(rt,Ze,255,V.KEEP,V.KEEP,V.INVERT)),et.u_alpha_discard_threshold=0,ze(new s.StencilMode(rt,Ze,255,V.KEEP,V.KEEP,V.KEEP))}else ze(h.stencilModeForClipping(le))}ae&&(h.resetStencilClippingMasks(),h.terrain&&ie.clear({stencil:0}))},fill:function(h,n,a,p){const _=a.paint.get("fill-color"),b=a.paint.get("fill-opacity");if(b.constantOr(1)===0)return;const I=h.colorModeForRenderPass(),M=a.paint.get("fill-pattern"),P=h.opaquePassEnabledForLayer()&&!M.constantOr(1)&&_.constantOr(s.Color.transparent).a===1&&b.constantOr(0)===1?"opaque":"translucent";if(h.renderPass===P){const N=h.depthModeForSublayer(1,h.renderPass==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly);l(h,n,a,p,N,I,!1)}if(h.renderPass==="translucent"&&a.paint.get("fill-antialias")){const N=h.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,s.DepthMode.ReadOnly);l(h,n,a,p,N,I,!0)}},"fill-extrusion":function(h,n,a,p){const _=a.paint.get("fill-extrusion-opacity");if(_!==0&&h.renderPass==="translucent"){const b=new s.DepthMode(h.context.gl.LEQUAL,s.DepthMode.ReadWrite,h.depthRangeFor3D);if(_!==1||a.paint.get("fill-extrusion-pattern").constantOr(1))c(h,n,a,p,b,s.StencilMode.disabled,s.ColorMode.disabled),c(h,n,a,p,b,h.stencilModeFor3D(),h.colorModeForRenderPass()),h.resetStencilClippingMasks();else{const I=h.colorModeForRenderPass();c(h,n,a,p,b,s.StencilMode.disabled,I)}}},hillshade:function(h,n,a,p){if(h.renderPass!=="offscreen"&&h.renderPass!=="translucent")return;const _=h.context,b=h.depthModeForSublayer(0,s.DepthMode.ReadOnly),I=h.colorModeForRenderPass(),M=h.terrain&&h.terrain.renderingToTexture,[P,N]=h.renderPass!=="translucent"||M?[{},p]:h.stencilConfigForOverlap(p);for(const z of N){const j=n.getTile(z);if(j.needsHillshadePrepare&&h.renderPass==="offscreen")ar(h,j,a,b,s.StencilMode.disabled,I);else if(h.renderPass==="translucent"){const Y=M&&h.terrain?h.terrain.stencilModeForRTTOverlap(z):P[z.overscaledZ];pu(h,z,j,a,b,Y,I)}}_.viewport.set([0,0,h.width,h.height]),h.resetStencilClippingMasks()},raster:function(h,n,a,p,_,b){if(h.renderPass!=="translucent"||a.paint.get("raster-opacity")===0||!p.length)return;const I=h.context,M=I.gl,P=n.getSource(),N=h.useProgram("raster"),z=h.colorModeForRenderPass(),j=h.terrain&&h.terrain.renderingToTexture,[Y,J]=P instanceof li||j?[{},p]:h.stencilConfigForOverlap(p),te=J[J.length-1].overscaledZ,ee=!h.options.moving;for(const ie of J){const V=j?s.DepthMode.disabled:h.depthModeForSublayer(ie.overscaledZ-te,a.paint.get("raster-opacity")===1?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly,M.LESS),K=ie.toUnwrapped(),ae=n.getTile(ie);if(j&&(!ae||!ae.hasData()))continue;const le=j?ie.projMatrix:h.transform.calculateProjMatrix(K,ee),xe=h.terrain&&j?h.terrain.stencilModeForRTTOverlap(ie):Y[ie.overscaledZ],Te=b?0:a.paint.get("raster-fade-duration");ae.registerFadeDuration(Te);const be=n.findLoadedParent(ie,0),Ae=Hn(ae,be,n,h.transform,Te);let ke,Ne;h.terrain&&h.terrain.prepareDrawTile();const tt=a.paint.get("raster-resampling")==="nearest"?M.NEAREST:M.LINEAR;I.activeTexture.set(M.TEXTURE0),ae.texture.bind(tt,M.CLAMP_TO_EDGE),I.activeTexture.set(M.TEXTURE1),be?(be.texture.bind(tt,M.CLAMP_TO_EDGE),ke=Math.pow(2,be.tileID.overscaledZ-ae.tileID.overscaledZ),Ne=[ae.tileID.canonical.x*ke%1,ae.tileID.canonical.y*ke%1]):ae.texture.bind(tt,M.CLAMP_TO_EDGE),ae.texture.useMipmap&&I.extTextureFilterAnisotropic&&h.transform.pitch>20&&M.texParameterf(M.TEXTURE_2D,I.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,I.extTextureFilterAnisotropicMax);const Re=Aa(le,Ne||[0,0],ke||1,Ae,a,P instanceof li?P.perspectiveTransform:[0,0]);if(h.prepareDrawProgram(I,N,K),P instanceof li)P.boundsBuffer&&P.boundsSegments&&N.draw(I,M.TRIANGLES,V,s.StencilMode.disabled,z,s.CullFaceMode.disabled,Re,a.id,P.boundsBuffer,h.quadTriangleIndexBuffer,P.boundsSegments);else{const{tileBoundsBuffer:We,tileBoundsIndexBuffer:je,tileBoundsSegments:et}=h.getTileBoundsBuffers(ae);N.draw(I,M.TRIANGLES,V,xe,z,s.CullFaceMode.disabled,Re,a.id,We,je,et)}}h.resetStencilClippingMasks()},background:function(h,n,a,p){const _=a.paint.get("background-color"),b=a.paint.get("background-opacity");if(b===0)return;const I=h.context,M=I.gl,P=h.transform,N=P.tileSize,z=a.paint.get("background-pattern");if(h.isPatternMissing(z))return;const j=!z&&_.a===1&&b===1&&h.opaquePassEnabledForLayer()?"opaque":"translucent";if(h.renderPass!==j)return;const Y=s.StencilMode.disabled,J=h.depthModeForSublayer(0,j==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly),te=h.colorModeForRenderPass(),ee=h.useProgram(z?"backgroundPattern":"background");let ie,V=p;V||(ie=h.getBackgroundTiles(),V=Object.values(ie).map(K=>K.tileID)),z&&(I.activeTexture.set(M.TEXTURE0),h.imageManager.bind(h.context));for(const K of V){const ae=K.toUnwrapped(),le=p?K.projMatrix:h.transform.calculateProjMatrix(ae);h.prepareDrawTile();const xe=n?n.getTile(K):ie?ie[K.key]:new s.Tile(K,N,P.zoom,h),Te=z?vu(le,b,h,z,{tileID:K,tileSize:N}):La(le,b,_);h.prepareDrawProgram(I,ee,ae);const{tileBoundsBuffer:be,tileBoundsIndexBuffer:Ae,tileBoundsSegments:ke}=h.getTileBoundsBuffers(xe);ee.draw(I,M.TRIANGLES,J,Y,te,s.CullFaceMode.disabled,Te,a.id,be,Ae,ke)}},sky:function(h,n,a){const p=h.transform,_=p.projection.name==="mercator"||p.projection.name==="globe"?1:s.smoothstep(7,8,p.zoom),b=a.paint.get("sky-opacity")*_;if(b===0)return;const I=h.context,M=a.paint.get("sky-type"),P=new s.DepthMode(I.gl.LEQUAL,s.DepthMode.ReadOnly,[0,1]),N=h.frameCounter/1e3%1;M==="atmosphere"?h.renderPass==="offscreen"?a.needsSkyboxCapture(h)&&(function(z,j,Y,J){const te=z.context,ee=te.gl;let ie=j.skyboxFbo;if(!ie){ie=j.skyboxFbo=te.createFramebuffer(32,32,!1),j.skyboxGeometry=new ei(te),j.skyboxTexture=te.gl.createTexture(),ee.bindTexture(ee.TEXTURE_CUBE_MAP,j.skyboxTexture),ee.texParameteri(ee.TEXTURE_CUBE_MAP,ee.TEXTURE_WRAP_S,ee.CLAMP_TO_EDGE),ee.texParameteri(ee.TEXTURE_CUBE_MAP,ee.TEXTURE_WRAP_T,ee.CLAMP_TO_EDGE),ee.texParameteri(ee.TEXTURE_CUBE_MAP,ee.TEXTURE_MIN_FILTER,ee.LINEAR),ee.texParameteri(ee.TEXTURE_CUBE_MAP,ee.TEXTURE_MAG_FILTER,ee.LINEAR);for(let le=0;le<6;++le)ee.texImage2D(ee.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ee.RGBA,32,32,0,ee.RGBA,ee.UNSIGNED_BYTE,null)}te.bindFramebuffer.set(ie.framebuffer),te.viewport.set([0,0,32,32]);const V=j.getCenter(z,!0),K=z.useProgram("skyboxCapture"),ae=new Float64Array(16);s.identity(ae),s.rotateY(ae,ae,.5*-Math.PI),yi(te,j,K,ae,V,0),s.identity(ae),s.rotateY(ae,ae,.5*Math.PI),yi(te,j,K,ae,V,1),s.identity(ae),s.rotateX(ae,ae,.5*-Math.PI),yi(te,j,K,ae,V,2),s.identity(ae),s.rotateX(ae,ae,.5*Math.PI),yi(te,j,K,ae,V,3),s.identity(ae),yi(te,j,K,ae,V,4),s.identity(ae),s.rotateY(ae,ae,Math.PI),yi(te,j,K,ae,V,5),te.viewport.set([0,0,z.width,z.height])}(h,a),a.markSkyboxValid(h)):h.renderPass==="sky"&&function(z,j,Y,J,te){const ee=z.context,ie=ee.gl,V=z.transform,K=z.useProgram("skybox");ee.activeTexture.set(ie.TEXTURE0),ie.bindTexture(ie.TEXTURE_CUBE_MAP,j.skyboxTexture);const ae=((le,xe,Te,be,Ae)=>({u_matrix:le,u_sun_direction:xe,u_cubemap:0,u_opacity:be,u_temporal_offset:Ae}))(V.skyboxMatrix,j.getCenter(z,!1),0,J,te);z.prepareDrawProgram(ee,K),K.draw(ee,ie.TRIANGLES,Y,s.StencilMode.disabled,z.colorModeForRenderPass(),s.CullFaceMode.backCW,ae,"skybox",j.skyboxGeometry.vertexBuffer,j.skyboxGeometry.indexBuffer,j.skyboxGeometry.segment)}(h,a,P,b,N):M==="gradient"&&h.renderPass==="sky"&&function(z,j,Y,J,te){const ee=z.context,ie=ee.gl,V=z.transform,K=z.useProgram("skyboxGradient");j.skyboxGeometry||(j.skyboxGeometry=new ei(ee)),ee.activeTexture.set(ie.TEXTURE0);let ae=j.colorRampTexture;ae||(ae=j.colorRampTexture=new s.Texture(ee,j.colorRamp,ie.RGBA)),ae.bind(ie.LINEAR,ie.CLAMP_TO_EDGE);const le=((xe,Te,be,Ae,ke)=>({u_matrix:xe,u_color_ramp:0,u_center_direction:Te,u_radius:s.degToRad(be),u_opacity:Ae,u_temporal_offset:ke}))(V.skyboxMatrix,j.getCenter(z,!1),j.paint.get("sky-gradient-radius"),J,te);z.prepareDrawProgram(ee,K),K.draw(ee,ie.TRIANGLES,Y,s.StencilMode.disabled,z.colorModeForRenderPass(),s.CullFaceMode.backCW,le,"skyboxGradient",j.skyboxGeometry.vertexBuffer,j.skyboxGeometry.indexBuffer,j.skyboxGeometry.segment)}(h,a,P,b,N)},debug:function(h,n,a){for(let p=0;p_)return void(this.transform.fogCullDistSq=null);const b=p+.78*(_-p);this.transform.fogCullDistSq=b*b}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(n,a){if(this.width=n*s.exported.devicePixelRatio,this.height=a*s.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const p of this.style.order)this.style._layers[p].resize()}setup(){const n=this.context,a=new s.StructArrayLayout2i4;a.emplaceBack(0,0),a.emplaceBack(s.EXTENT,0),a.emplaceBack(0,s.EXTENT),a.emplaceBack(s.EXTENT,s.EXTENT),this.tileExtentBuffer=n.createVertexBuffer(a,s.posAttributes.members),this.tileExtentSegments=s.SegmentVector.simpleSegment(0,0,4,2);const p=new s.StructArrayLayout2i4;p.emplaceBack(0,0),p.emplaceBack(s.EXTENT,0),p.emplaceBack(0,s.EXTENT),p.emplaceBack(s.EXTENT,s.EXTENT),this.debugBuffer=n.createVertexBuffer(p,s.posAttributes.members),this.debugSegments=s.SegmentVector.simpleSegment(0,0,4,5);const _=new s.StructArrayLayout2i4;_.emplaceBack(-1,-1),_.emplaceBack(1,-1),_.emplaceBack(-1,1),_.emplaceBack(1,1),this.viewportBuffer=n.createVertexBuffer(_,s.posAttributes.members),this.viewportSegments=s.SegmentVector.simpleSegment(0,0,4,2);const b=new s.StructArrayLayout4i8;b.emplaceBack(0,0,0,0),b.emplaceBack(s.EXTENT,0,s.EXTENT,0),b.emplaceBack(0,s.EXTENT,0,s.EXTENT),b.emplaceBack(s.EXTENT,s.EXTENT,s.EXTENT,s.EXTENT),this.mercatorBoundsBuffer=n.createVertexBuffer(b,s.boundsAttributes.members),this.mercatorBoundsSegments=s.SegmentVector.simpleSegment(0,0,4,2);const I=new s.StructArrayLayout3ui6;I.emplaceBack(0,1,2),I.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=n.createIndexBuffer(I);const M=new s.StructArrayLayout1ui2;for(const N of[0,1,3,2,0])M.emplaceBack(N);this.debugIndexBuffer=n.createIndexBuffer(M),this.emptyTexture=new s.Texture(n,new s.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),n.gl.RGBA),this.identityMat=s.create();const P=this.context.gl;this.stencilClearMode=new s.StencilMode({func:P.ALWAYS,mask:0},0,255,P.ZERO,P.ZERO,P.ZERO),this.loadTimeStamps.push(s.window.performance.now()),this.atmosphereBuffer=new Fn(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(n){return n._makeTileBoundsBuffers(this.context,this.transform.projection),n._tileBoundsBuffer?{tileBoundsBuffer:n._tileBoundsBuffer,tileBoundsIndexBuffer:n._tileBoundsIndexBuffer,tileBoundsSegments:n._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const n=this.context,a=n.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(n,a.TRIANGLES,s.DepthMode.disabled,this.stencilClearMode,s.ColorMode.disabled,s.CullFaceMode.disabled,ys(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(n,a,p){if(!a||this.currentStencilSource===a.id||!n.isTileClipped()||!p||p.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let M=!1;for(const P of p)if(this._tileClippingMaskIDs[P.key]===void 0){M=!0;break}if(!M)return}this.currentStencilSource=a.id;const _=this.context,b=_.gl;this.nextStencilID+p.length>256&&this.clearStencil(),_.setColorMode(s.ColorMode.disabled),_.setDepthMode(s.DepthMode.disabled);const I=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of p){const P=a.getTile(M),N=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,{tileBoundsBuffer:z,tileBoundsIndexBuffer:j,tileBoundsSegments:Y}=this.getTileBoundsBuffers(P);I.draw(_,b.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:b.ALWAYS,mask:0},N,255,b.KEEP,b.KEEP,b.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,ys(M.projMatrix),"$clipping",z,j,Y)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const n=this.nextStencilID++,a=this.context.gl;return new s.StencilMode({func:a.NOTEQUAL,mask:255},n,255,a.KEEP,a.KEEP,a.REPLACE)}stencilModeForClipping(n){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(n);const a=this.context.gl;return new s.StencilMode({func:a.EQUAL,mask:255},this._tileClippingMaskIDs[n.key],0,a.KEEP,a.KEEP,a.REPLACE)}stencilConfigForOverlap(n){const a=this.context.gl,p=n.sort((I,M)=>M.overscaledZ-I.overscaledZ),_=p[p.length-1].overscaledZ,b=p[0].overscaledZ-_+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();const I={};for(let M=0;M=0;this.currentLayer--){const N=this.style._layers[p[this.currentLayer]],z=n._getLayerSourceCache(N);if(N.isSky())continue;const j=z?I[z.id]:void 0;this._renderTileClippingMasks(N,z,j),this.renderLayer(this,z,N,j)}if(this.style.fog&&this.transform.projection.supportsFog&&function(N,z){const j=N.context,Y=j.gl,J=N.transform,te=new s.DepthMode(Y.LEQUAL,s.DepthMode.ReadOnly,[0,1]),ee=N.useProgram("globeAtmosphere",null,J.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),ie=s.globeToMercatorTransition(J.zoom),V=z.properties.get("color").toArray01(),K=z.properties.get("high-color").toArray01(),ae=z.properties.get("space-color").toArray01PremultipliedAlpha(),le=s.identity$1([]);s.rotateY$1(le,le,-s.degToRad(J._center.lng)),s.rotateX$1(le,le,s.degToRad(J._center.lat)),s.rotateZ$1(le,le,J.angle),s.rotateX$1(le,le,-J._pitch);const xe=s.fromQuat(new Float32Array(16),le),Te=s.mapValue(z.properties.get("star-intensity"),0,1,0,.25),be=5e-4,Ae=s.mapValue(z.properties.get("horizon-blend"),0,1,be,.25),ke=s.globeUseCustomAntiAliasing(N,j,J)&&Ae===be?J.worldSize/(2*Math.PI*1.025)-1:J.globeRadius,Ne=N.frameCounter/1e3%1,tt=s.length(J.globeCenterInViewSpace),Re=Math.sqrt(Math.pow(tt,2)-Math.pow(ke,2)),We=Math.acos(Re/tt),je=((ze,Ze,rt,Ke,st,zt,Kt,Pt,jt,mi,di,Ot,Di,Bi)=>({u_frustum_tl:ze,u_frustum_tr:Ze,u_frustum_br:rt,u_frustum_bl:Ke,u_horizon:st,u_transition:zt,u_fadeout_range:Kt,u_color:Pt,u_high_color:jt,u_space_color:mi,u_star_intensity:di,u_star_size:5*s.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:Ot,u_horizon_angle:Di,u_rotation_matrix:Bi}))(J.frustumCorners.TL,J.frustumCorners.TR,J.frustumCorners.BR,J.frustumCorners.BL,J.frustumCorners.horizon,ie,Ae,V,K,ae,Te,Ne,We,xe);N.prepareDrawProgram(j,ee);const et=N.atmosphereBuffer;et&&ee.draw(j,Y.TRIANGLES,te,s.StencilMode.disabled,s.ColorMode.alphaBlended,s.CullFaceMode.backCW,je,"skybox",et.vertexBuffer,et.indexBuffer,et.segments)}(this,this.style.fog),this.renderPass="sky",(s.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const j=n._getLayerSourceCache(z);j&&!z.isHidden(this.transform.zoom)&&(!N||N.getSource().maxzoom0?a.pop():null}isPatternMissing(n){return n===null||n!==void 0&&!this.imageManager.getPattern(n.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const n=this.terrain&&this.terrain.renderingToTexture,a=this.terrain&&this.terrain.exaggeration()===0,p=this.style&&this.style.fog,_=[];return this.terrainRenderModeElevated()&&_.push("TERRAIN"),this.transform.projection.name==="globe"&&_.push("GLOBE"),a&&_.push("ZERO_EXAGGERATION"),p&&!n&&p.getOpacity(this.transform.pitch)!==0&&_.push("FOG"),n&&_.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&_.push("OVERDRAW_INSPECTOR"),_}useProgram(n,a,p){this.cache=this.cache||{};const _=p||[],b=this.currentGlobalDefines().concat(_),I=bi.cacheKey(dl[n],n,b,a);return this.cache[I]||(this.cache[I]=new bi(this.context,n,dl[n],a,bl[n],b)),this.cache[I]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const n=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(n.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=s.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new s.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(n,a,p){if(this.terrain&&this.terrain.renderingToTexture)return;const _=this.style.fog;if(_){const b=_.getOpacity(this.transform.pitch),I=((M,P,N,z,j,Y,J,te,ee,ie,V)=>{const K=M.transform,ae=P.properties.get("color").toArray01();ae[3]=z;const le=M.frameCounter/1e3%1;return{u_fog_matrix:N?K.calculateFogTileMatrix(N):M.identityMat,u_fog_range:P.getFovAdjustedRange(K._fov),u_fog_color:ae,u_fog_horizon_blend:P.properties.get("horizon-blend"),u_fog_temporal_offset:le,u_frustum_tl:j,u_frustum_tr:Y,u_frustum_br:J,u_frustum_bl:te,u_globe_pos:ee,u_globe_radius:ie,u_viewport:V,u_globe_transition:s.globeToMercatorTransition(K.zoom),u_is_globe:+(K.projection.name==="globe")}})(this,_,p,b,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*s.exported.devicePixelRatio,this.transform.height*s.exported.devicePixelRatio]);a.setFogUniformValues(n,I)}}setTileLoadedFlag(n){this.tileLoaded=n}saveCanvasCopy(){const n=this.canvasCopy();n&&(this.frameCopies.push(n),this.tileLoaded=!1)}canvasCopy(){const n=this.context.gl,a=n.createTexture();return n.bindTexture(n.TEXTURE_2D,a),n.copyTexImage2D(n.TEXTURE_2D,0,n.RGBA,0,0,n.drawingBufferWidth,n.drawingBufferHeight,0),a}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const n=this.style&&this.style.fog;return!!n&&n.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const n=this._backgroundTiles,a=this._backgroundTiles={},p=this.transform.coveringTiles({tileSize:512});for(const _ of p)a[_.key]=n[_.key]||new s.Tile(_,512,this.transform.tileZoom,this);return a}clearBackgroundTiles(){this._backgroundTiles={}}}class Ir{constructor(n=0,a=0,p=0,_=0){if(isNaN(n)||n<0||isNaN(a)||a<0||isNaN(p)||p<0||isNaN(_)||_<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=n,this.bottom=a,this.left=p,this.right=_}interpolate(n,a,p){return a.top!=null&&n.top!=null&&(this.top=s.number(n.top,a.top,p)),a.bottom!=null&&n.bottom!=null&&(this.bottom=s.number(n.bottom,a.bottom,p)),a.left!=null&&n.left!=null&&(this.left=s.number(n.left,a.left,p)),a.right!=null&&n.right!=null&&(this.right=s.number(n.right,a.right,p)),this}getCenter(n,a){const p=s.clamp((this.left+n-this.right)/2,0,n),_=s.clamp((this.top+a-this.bottom)/2,0,a);return new s.Point(p,_)}equals(n){return this.top===n.top&&this.bottom===n.bottom&&this.left===n.left&&this.right===n.right}clone(){return new Ir(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Hr(h,n){const a=s.getColumn(h,3);s.fromQuat(h,n),s.setColumn(h,3,a)}function vi(h,n){const a=s.identity$1([]);return s.rotateZ$1(a,a,-n),s.rotateX$1(a,a,-h),a}function uo(h,n){const a=[h[0],h[1],0],p=[n[0],n[1],0];if(s.length(a)>=1e-15){const I=s.normalize([],a);s.scale$2(p,I,s.dot(p,I)),n[0]=p[0],n[1]=p[1]}const _=s.cross([],n,h);if(s.len(_)<1e-15)return null;const b=Math.atan2(-_[1],_[0]);return vi(Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2]),b)}class Xo{constructor(n,a){this.position=n,this.orientation=a}get position(){return this._position}set position(n){if(n){const a=n instanceof s.MercatorCoordinate?n:new s.MercatorCoordinate(n[0],n[1],n[2]);this._renderWorldCopies&&(a.x=s.wrap(a.x,0,1)),this._position=a}else this._position=null}lookAtPoint(n,a){if(this.orientation=null,!this.position)return;const p=this.position,_=this._elevation?this._elevation.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(n)):0,b=s.MercatorCoordinate.fromLngLat(n,_),I=[b.x-p.x,b.y-p.y,b.z-p.z];a||(a=[0,0,1]),a[2]=Math.abs(a[2]),this.orientation=uo(I,a)}setPitchBearing(n,a){this.orientation=vi(s.degToRad(n),s.degToRad(-a))}}class Ks{constructor(n,a){this._transform=s.identity([]),this.orientation=a,this.position=n}get mercatorPosition(){const n=this.position;return new s.MercatorCoordinate(n[0],n[1],n[2])}get position(){const n=s.getColumn(this._transform,3);return[n[0],n[1],n[2]]}set position(n){var a;n&&s.setColumn(this._transform,3,[(a=n)[0],a[1],a[2],1])}get orientation(){return this._orientation}set orientation(n){this._orientation=n||s.identity$1([]),n&&Hr(this._transform,this._orientation)}getPitchBearing(){const n=this.forward(),a=this.right();return{bearing:Math.atan2(-a[1],a[0]),pitch:Math.atan2(Math.sqrt(n[0]*n[0]+n[1]*n[1]),-n[2])}}setPitchBearing(n,a){this._orientation=vi(n,a),Hr(this._transform,this._orientation)}forward(){const n=s.getColumn(this._transform,2);return[-n[0],-n[1],-n[2]]}up(){const n=s.getColumn(this._transform,1);return[-n[0],-n[1],-n[2]]}right(){const n=s.getColumn(this._transform,0);return[n[0],n[1],n[2]]}getCameraToWorld(n,a){const p=new Float64Array(16);return s.invert(p,this.getWorldToCamera(n,a)),p}getWorldToCameraPosition(n,a,p){const _=this.position;s.scale$2(_,_,-n);const b=new Float64Array(16);return s.fromScaling(b,[p,p,p]),s.translate(b,b,_),b[10]*=a,b}getWorldToCamera(n,a){const p=new Float64Array(16),_=new Float64Array(4),b=this.position;return s.conjugate(_,this._orientation),s.scale$2(b,b,-n),s.fromQuat(p,_),s.translate(p,p,b),p[1]*=-1,p[5]*=-1,p[9]*=-1,p[13]*=-1,p[8]*=a,p[9]*=a,p[10]*=a,p[11]*=a,p}getCameraToClipPerspective(n,a,p,_){const b=new Float64Array(16);return s.perspective(b,n,a,p,_),b}getDistanceToElevation(n,a=!1){const p=n===0?0:s.mercatorZfromAltitude(n,a?s.latFromMercatorY(this.position[1]):this.position[1]),_=this.forward();return(p-this.position[2])/_[2]}clone(){return new Ks([...this.position],[...this.orientation])}}function Wo(h,n){const a=ws(h.projection,h.zoom,h.width,h.height),p=function(b,I,M,P,N){const z=new s.LngLat(M.lng-180*Yo,M.lat),j=new s.LngLat(M.lng+180*Yo,M.lat),Y=b.project(z.lng,z.lat),J=b.project(j.lng,j.lat),te=-Math.atan2(J.y-Y.y,J.x-Y.x),ee=s.MercatorCoordinate.fromLngLat(M);ee.y=s.clamp(ee.y,-1+Yo,1-Yo);const ie=ee.toLngLat(),V=b.project(ie.lng,ie.lat),K=s.MercatorCoordinate.fromLngLat(ie);K.x+=Yo;const ae=K.toLngLat(),le=b.project(ae.lng,ae.lat),xe=bu(le.x-V.x,le.y-V.y,te),Te=s.MercatorCoordinate.fromLngLat(ie);Te.y+=Yo;const be=Te.toLngLat(),Ae=b.project(be.lng,be.lat),ke=bu(Ae.x-V.x,Ae.y-V.y,te),Ne=Math.abs(xe.x)/Math.abs(ke.y),tt=s.identity([]);s.rotateZ(tt,tt,-te*(1-(N?0:P)));const Re=s.identity([]);return s.scale(Re,Re,[1,1-(1-Ne)*P,1]),Re[4]=-ke.x/ke.y*P,s.rotateZ(Re,Re,te),s.multiply(Re,tt,Re),Re}(h.projection,0,h.center,a,n),_=Oa(h);return s.scale(p,p,[_,_,1]),p}function Oa(h){const n=h.projection,a=ws(h.projection,h.zoom,h.width,h.height),p=bf(n,h.center),_=bf(n,s.LngLat.convert(n.center));return Math.pow(2,p*a+(1-a)*_)}function ws(h,n,a,p,_=1/0){const b=h.range;if(!b)return 0;const I=Math.min(_,Math.max(a,p)),M=Math.log(I/1024)/Math.LN2;return s.smoothstep(b[0]+M,b[1]+M,n)}const Yo=1/4e4;function bf(h,n){const a=s.clamp(n.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),p=new s.LngLat(n.lng-180*Yo,a),_=new s.LngLat(n.lng+180*Yo,a),b=h.project(p.lng,a),I=h.project(_.lng,a),M=s.MercatorCoordinate.fromLngLat(p),P=s.MercatorCoordinate.fromLngLat(_),N=I.x-b.x,z=I.y-b.y,j=P.x-M.x,Y=P.y-M.y,J=Math.sqrt((j*j+Y*Y)/(N*N+z*z));return Math.log(J)/Math.LN2}function bu(h,n,a){const p=Math.cos(a),_=Math.sin(a);return{x:h*p-n*_,y:h*_+n*p}}class za{constructor(n,a,p,_,b,I,M){this.tileSize=512,this._renderWorldCopies=b===void 0||b,this._minZoom=n||0,this._maxZoom=a||22,this._minPitch=p??0,this._maxPitch=_??60,this.setProjection(I),this.setMaxBounds(M),this.width=0,this.height=0,this._center=new s.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Ir,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ks,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const n=new za(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return n._elevation=this._elevation,n._centerAltitude=this._centerAltitude,n._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,n.tileSize=this.tileSize,n.mercatorFromTransition=this.mercatorFromTransition,n.width=this.width,n.height=this.height,n.cameraElevationReference=this.cameraElevationReference,n._center=this._center,n._setZoom(this.zoom),n._seaLevelZoom=this._seaLevelZoom,n.angle=this.angle,n._fov=this._fov,n._pitch=this._pitch,n._nearZ=this._nearZ,n._farZ=this._farZ,n._averageElevation=this._averageElevation,n._unmodified=this._unmodified,n._edgeInsets=this._edgeInsets.clone(),n._camera=this._camera.clone(),n._calcMatrices(),n.freezeTileCoverage=this.freezeTileCoverage,n.frustumCorners=this.frustumCorners,n}get elevation(){return this._elevation}set elevation(n){this._elevation!==n&&(this._elevation=n,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(n,a=!1){const p=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||p)&&this._updateCameraOnTerrain(),(n||p)&&this._constrainCamera(a),this._calcMatrices()}getProjection(){return s.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const a=this.projection?this.getProjection():void 0;this.projection=s.getProjection(this.projectionOptions);const p=!Z(a,this.getProjection());return p&&this._calcMatrices(),this.mercatorFromTransition=!1,p}setMercatorFromTransition(){const n=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=s.getProjection({name:"mercator"});const a=n!==this.projection.name;return a&&this._calcMatrices(),a}get minZoom(){return this._minZoom}set minZoom(n){this._minZoom!==n&&(this._minZoom=n,this.zoom=Math.max(this.zoom,n))}get maxZoom(){return this._maxZoom}set maxZoom(n){this._maxZoom!==n&&(this._maxZoom=n,this.zoom=Math.min(this.zoom,n))}get minPitch(){return this._minPitch}set minPitch(n){this._minPitch!==n&&(this._minPitch=n,this.pitch=Math.max(this.pitch,n))}get maxPitch(){return this._maxPitch}set maxPitch(n){this._maxPitch!==n&&(this._maxPitch=n,this.pitch=Math.min(this.pitch,n))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(n){n===void 0?n=!0:n===null&&(n=!1),this._renderWorldCopies=n}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const n=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(n))}get cameraWorldSize(){const n=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(n))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return s.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.Point(this.width,this.height)}get bearing(){return s.wrap(this.rotation,-180,180)}set bearing(n){this.rotation=n}get rotation(){return-this.angle/Math.PI*180}set rotation(n){const a=-n*Math.PI/180;var p;this.angle!==a&&(this._unmodified=!1,this.angle=a,this._calcMatrices(),this.rotationMatrix=(p=new s.ARRAY_TYPE(4),s.ARRAY_TYPE!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p),function(_,b,I){var M=b[0],P=b[1],N=b[2],z=b[3],j=Math.sin(I),Y=Math.cos(I);_[0]=M*Y+N*j,_[1]=P*Y+z*j,_[2]=M*-j+N*Y,_[3]=P*-j+z*Y}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(n){const a=s.clamp(n,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==a&&(this._unmodified=!1,this._pitch=a,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 n=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/n)}set fov(n){n=Math.max(.01,Math.min(60,n)),this._fov!==n&&(this._unmodified=!1,this._fov=s.degToRad(n),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(n){this._averageElevation=n,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(n){const a=Math.min(Math.max(n,this.minZoom),this.maxZoom);this._zoom!==a&&(this._unmodified=!1,this._setZoom(a),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(n){this._zoom=n,this.scale=this.zoomScale(n),this.tileZoom=Math.floor(n),this.zoomFraction=n-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const n=this._elevation;this._centerAltitude=n.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=n.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 n=this._elevation,a=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],p=this.horizonLineFromTop();let _=0,b=0;for(let I=0;In.maxzoom&&(a=n.maxzoom);const I=this.locationCoordinate(this.center),M=this.center.lat,P=1<{const rt=new s.MercatorCoordinate(ze.x+25e-6,ze.y,ze.z),Ke=new s.MercatorCoordinate(ze.x,ze.y+25e-6,ze.z),st=ze.toLngLat(),zt=rt.toLngLat(),Kt=Ke.toLngLat(),Pt=this.locationCoordinate(st),jt=this.locationCoordinate(zt),mi=this.locationCoordinate(Kt),di=Math.hypot(jt.x-Pt.x,jt.y-Pt.y),Ot=Math.hypot(mi.x-Pt.x,mi.y-Pt.y);return Math.sqrt(di*Ot)*xe/25e-6},be=ze=>{const Ze=ae,rt=le;return{aabb:s.tileAABB(this,P,0,0,0,ze,rt,Ze,this.projection),zoom:0,x:0,y:0,minZ:rt,maxZ:Ze,wrap:ze,fullyVisible:!1}},Ae=[];let ke=[];const Ne=a,tt=n.reparseOverscaled?p:a,Re=ze=>ze*ze,We=Re((ee-this._centerAltitude)*te),je=ze=>{if(!this._elevation||!ze.tileID||!b)return;const Ze=this._elevation.getMinMaxForTile(ze.tileID),rt=ze.aabb;Ze?(rt.min[2]=Ze.min,rt.max[2]=Ze.max,rt.center[2]=(rt.min[2]+rt.max[2])/2):(ze.shouldSplit=et(ze),ze.shouldSplit||(rt.min[2]=rt.max[2]=rt.center[2]=this._centerAltitude))},et=ze=>{if(ze.zoom=.9)return!0}else if(_&&(Ke=Re(ze.aabb.distanceZ(ie)*te)),this.projection.isReprojectedInTileSpace&&p<=5){const Pt=Math.pow(2,ze.zoom),jt=Te(new s.MercatorCoordinate((ze.x+.5)/Pt,(ze.y+.5)/Pt));st=jt>.85?1:jt}const zt=Ze*Ze+rt*rt+Ke,Kt=Re((1<{if(jt*Re(.707)0;){const ze=Ae.pop(),Ze=ze.x,rt=ze.y;let Ke=ze.fullyVisible;if(!Ke){const st=ze.aabb.intersects(Y);if(st===0)continue;Ke=st===2}if(ze.zoom!==Ne&&et(ze))for(let st=0;st<4;st++){const zt=(Ze<<1)+st%2,Kt=(rt<<1)+(st>>1),Pt={aabb:b?ze.aabb.quadrant(st):s.tileAABB(this,P,ze.zoom+1,zt,Kt,ze.wrap,ze.minZ,ze.maxZ,this.projection),zoom:ze.zoom+1,x:zt,y:Kt,wrap:ze.wrap,fullyVisible:Ke,tileID:void 0,shouldSplit:void 0,minZ:ze.minZ,maxZ:ze.maxZ};_&&!z&&(Pt.tileID=new s.OverscaledTileID(ze.zoom+1===Ne?tt:ze.zoom+1,ze.wrap,ze.zoom+1,zt,Kt),je(Pt)),Ae.push(Pt)}else{const st=ze.zoom===Ne?tt:ze.zoom;if(n.minzoom&&n.minzoom>st)continue;const zt=N[0]-(.5+Ze+(ze.wrap<{const Ke=[0,0,0,1],st=[s.EXTENT,s.EXTENT,0,1],zt=this.calculateFogTileMatrix(rt.tileID.toUnwrapped());s.transformMat4$1(Ke,Ke,zt),s.transformMat4$1(st,st,zt);const Kt=s.getAABBPointSquareDist(Ke,st);if(Kt===0)return!0;let Pt=!1;const jt=this._elevation;if(jt&&Kt>ze&&Ze!==0){const mi=this.calculateProjMatrix(rt.tileID.toUnwrapped());let di;n.isTerrainDEM||(di=jt.getMinMaxForTile(rt.tileID)),di||(di={min:le,max:ae});const Ot=s.furthestTileCorner(this.rotation),Di=[Ot[0]*s.EXTENT,Ot[1]*s.EXTENT,di.max];s.transformMat4(Di,Di,mi),Pt=(1-Di[1])*this.height*.5ze.distanceSq-Ze.distanceSq).map(ze=>ze.tileID)}resize(n,a){this.width=n,this.height=a,this.pixelsToGLUnits=[2/n,-2/a],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(n){return Math.pow(2,n)}scaleZoom(n){return Math.log(n)/Math.LN2}project(n){const a=s.clamp(n.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),p=this.projection.project(n.lng,a);return new s.Point(p.x*this.worldSize,p.y*this.worldSize)}unproject(n){return this.projection.unproject(n.x/this.worldSize,n.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/s.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(n,a){let p,_;const b=this.centerPoint;if(this.projection.name==="globe"){const M=this.worldSize;p=(a.x-b.x)/M,_=(a.y-b.y)/M}else{const M=this.pointCoordinate(a),P=this.pointCoordinate(b);p=M.x-P.x,_=M.y-P.y}const I=this.locationCoordinate(n);this.setLocation(new s.MercatorCoordinate(I.x-p,I.y-_))}setLocation(n){this.center=this.coordinateLocation(n),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(n){return this.projection.locationPoint(this,n)}locationPoint3D(n){return this.projection.locationPoint(this,n,!0)}pointLocation(n){return this.coordinateLocation(this.pointCoordinate(n))}pointLocation3D(n){return this.coordinateLocation(this.pointCoordinate3D(n))}locationCoordinate(n,a){const p=a?s.mercatorZfromAltitude(a,n.lat):void 0,_=this.projection.project(n.lng,n.lat);return new s.MercatorCoordinate(_.x,_.y,p)}coordinateLocation(n){return this.projection.unproject(n.x,n.y)}pointRayIntersection(n,a){const p=a??this._centerAltitude,_=[n.x,n.y,0,1],b=[n.x,n.y,1,1];s.transformMat4$1(_,_,this.pixelMatrixInverse),s.transformMat4$1(b,b,this.pixelMatrixInverse);const I=b[3];s.scale$1(_,_,1/_[3]),s.scale$1(b,b,1/I);const M=_[2],P=b[2];return{p0:_,p1:b,t:M===P?0:(p-M)/(P-M)}}screenPointToMercatorRay(n){const a=[n.x,n.y,0,1],p=[n.x,n.y,1,1];return s.transformMat4$1(a,a,this.pixelMatrixInverse),s.transformMat4$1(p,p,this.pixelMatrixInverse),s.scale$1(a,a,1/a[3]),s.scale$1(p,p,1/p[3]),a[2]=s.mercatorZfromAltitude(a[2],this._center.lat)*this.worldSize,p[2]=s.mercatorZfromAltitude(p[2],this._center.lat)*this.worldSize,s.scale$1(a,a,1/this.worldSize),s.scale$1(p,p,1/this.worldSize),new s.Ray([a[0],a[1],a[2]],s.normalize([],s.sub([],p,a)))}rayIntersectionCoordinate(n){const{p0:a,p1:p,t:_}=n,b=s.mercatorZfromAltitude(a[2],this._center.lat),I=s.mercatorZfromAltitude(p[2],this._center.lat);return new s.MercatorCoordinate(s.number(a[0],p[0],_)/this.worldSize,s.number(a[1],p[1],_)/this.worldSize,s.number(b,I,_))}pointCoordinate(n,a=this._centerAltitude){return this.projection.pointCoordinate(this,n.x,n.y,a)}pointCoordinate3D(n){if(!this.elevation)return this.pointCoordinate(n);let a=this.projection.pointCoordinate3D(this,n.x,n.y);if(a)return new s.MercatorCoordinate(a[0],a[1],a[2]);let p=0,_=this.horizonLineFromTop();if(n.y>_)return this.pointCoordinate(n);const b=.02*_,I=n.clone();for(let M=0;M<10&&_-p>b;M++){I.y=s.number(p,_,.66);const P=this.projection.pointCoordinate3D(this,I.x,I.y);P?(_=I.y,a=P):p=I.y}return a?new s.MercatorCoordinate(a[0],a[1],a[2]):this.pointCoordinate(n)}isPointAboveHorizon(n){return this.projection.isPointAboveHorizon(this,n)}isPointOnSurface(n){if(n.y<0||n.y>this.height||n.x<0||n.x>this.width)return!1;if(this.elevation||this.zoom>=s.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(n);const a=this.pointCoordinate(n);return a.y>=0&&a.y<=1}_coordinatePoint(n,a){const p=a&&this.elevation?this.elevation.getAtPointOrZero(n,this._centerAltitude):this._centerAltitude,_=[n.x*this.worldSize,n.y*this.worldSize,p+n.toAltitude(),1];return s.transformMat4$1(_,_,this.pixelMatrix),_[3]>0?new s.Point(_[0]/_[3],_[1]/_[3]):new s.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:n,left:a}=this._edgeInsets,p=this.height-this._edgeInsets.bottom,_=this.width-this._edgeInsets.right,b=this.pointLocation3D(new s.Point(a,n)),I=this.pointLocation3D(new s.Point(_,n)),M=this.pointLocation3D(new s.Point(_,p)),P=this.pointLocation3D(new s.Point(a,p));let N=Math.min(b.lng,I.lng,M.lng,P.lng),z=Math.max(b.lng,I.lng,M.lng,P.lng),j=Math.min(b.lat,I.lat,M.lat,P.lat),Y=Math.max(b.lat,I.lat,M.lat,P.lat);const J=Math.pow(2,-this.zoom)/16*270,te=this.projection.name==="globe"?1:4,ee=(ie,V,K,ae,le)=>{const xe=(ie+K)/2,Te=(V+ae)/2,be=new s.Point(xe,Te),{lng:Ae,lat:ke}=this.pointLocation3D(be),Ne=Math.max(0,N-Ae,j-ke,Ae-z,ke-Y);N=Math.min(N,Ae),z=Math.max(z,Ae),j=Math.min(j,ke),Y=Math.max(Y,ke),(leJ)&&(ee(ie,V,xe,Te,le+1),ee(xe,Te,K,ae,le+1))};if(ee(a,n,_,n,1),ee(_,n,_,p,1),ee(_,p,a,p,1),ee(a,p,a,n,1),this.projection.name==="globe"){const[ie,V]=s.polesInViewport(this);ie?(Y=90,z=180,N=-180):V&&(j=-90,z=180,N=-180)}return new s.LngLatBounds(new s.LngLat(N,j),new s.LngLat(z,Y))}_getBoundsRectangular(n,a){const{top:p,left:_}=this._edgeInsets,b=this.height-this._edgeInsets.bottom,I=this.width-this._edgeInsets.right,M=new s.Point(_,p),P=new s.Point(I,p),N=new s.Point(I,b),z=new s.Point(_,b);let j=this.pointCoordinate(M,n),Y=this.pointCoordinate(P,n);const J=this.pointCoordinate(N,a),te=this.pointCoordinate(z,a),ee=(ie,V)=>(V.y-ie.y)/(V.x-ie.x);return j.y>1&&Y.y>=0?j=new s.MercatorCoordinate((1-te.y)/ee(te,j)+te.x,1):j.y<0&&Y.y<=1&&(j=new s.MercatorCoordinate(-te.y/ee(te,j)+te.x,0)),Y.y>1&&j.y>=0?Y=new s.MercatorCoordinate((1-J.y)/ee(J,Y)+J.x,1):Y.y<0&&j.y<=1&&(Y=new s.MercatorCoordinate(-J.y/ee(J,Y)+J.x,0)),new s.LngLatBounds().extend(this.coordinateLocation(j)).extend(this.coordinateLocation(Y)).extend(this.coordinateLocation(te)).extend(this.coordinateLocation(J))}_getBoundsRectangularTerrain(){const n=this.elevation;if(!n.visibleDemTiles.length||n.isUsingMockSource())return this._getBoundsRectangular(0,0);const a=n.visibleDemTiles.reduce((p,_)=>{if(_.dem){const b=_.dem.tree;p.min=Math.min(p.min,b.minimums[0]),p.max=Math.max(p.max,b.maximums[0])}return p},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(a.min*n.exaggeration(),a.max*n.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(n=!0){const a=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,p=this.height/2-a*(1-this._horizonShift);return n?Math.max(0,p):p}getMaxBounds(){return this.maxBounds}setMaxBounds(n){this.maxBounds=n,this.minLat=-s.MAX_MERCATOR_LATITUDE,this.maxLat=s.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,n&&(this.minLat=n.getSouth(),this.maxLat=n.getNorth(),this.minLng=n.getWest(),this.maxLng=n.getEast(),this.maxLngj&&(M=j-N),j-zJ&&(I=J-P),J-Y.5?ae-1:ae,le>.5?le-1:le,0]),this.alignedProjMatrix=xe,M=s.create(),s.scale(M,M,[this.width/2,-this.height/2,1]),s.translate(M,M,[1,-1,0]),this.labelPlaneMatrix=M,M=s.create(),s.scale(M,M,[1,-1,1]),s.translate(M,M,[-1,-1,0]),s.scale(M,M,[2/this.width,2/this.height,1]),this.glCoordMatrix=M,this.pixelMatrix=s.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},M=s.invert(new Float64Array(16),this.pixelMatrix),!M)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=M,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=s.calculateGlobeMatrix(this);const Te=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=s.transformMat4(Te,Te,b),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=M;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const n=this.cameraWorldSizeForFog,a=this.cameraPixelsPerMeter,p=this._camera.position,_=1/this.height/this._pixelsPerMercatorPixel,b=[n,n,a];s.scale$2(b,b,_),s.scale$2(p,p,-1),s.multiply$2(p,p,b);const I=s.create();s.translate(I,I,p),s.scale(I,I,b),this.mercatorFogMatrix=I,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(n,a,_)}_computeCameraPosition(n){const a=(n=n||this.pixelsPerMeter)/this.pixelsPerMeter,p=this._camera.forward(),_=this.point,b=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*a-n/this.worldSize*this._centerAltitude;return[_.x/this.worldSize-p[0]*b,_.y/this.worldSize-p[1]*b,n/this.worldSize*this._centerAltitude-p[2]*b]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(n){const a=this._maxCameraBoundsDistance()*Math.cos(this._pitch),p=this._camera.position[2],_=n[2];let b=1;this.projection.wrap&&(this.center=this.center.wrap()),_>0&&(b=Math.min((a-p)/_,1)),this._camera.position=s.scaleAndAdd([],this._camera.position,n,b),this._updateStateFromCamera()}_updateStateFromCamera(){const n=this._camera.position,a=this._camera.forward(),{pitch:p,bearing:_}=this._camera.getPitchBearing(),b=s.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,I=this._mercatorZfromZoom(this._maxZoom)*Math.cos(s.degToRad(this._maxPitch)),M=Math.max((n[2]-b)/Math.cos(p),I),P=this._zoomFromMercatorZ(M);s.scaleAndAdd(n,n,a,M),this._pitch=s.clamp(p,s.degToRad(this.minPitch),s.degToRad(this.maxPitch)),this.angle=s.wrap(_,-Math.PI,Math.PI),this._setZoom(s.clamp(P,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s.MercatorCoordinate(n[0],n[1],n[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(n){return Math.pow(2,n)*this.tileSize}_mercatorZfromZoom(n){return this.cameraToCenterDistance/this._worldSizeFromZoom(n)}_minimumHeightOverTerrain(){const n=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(n)}_zoomFromMercatorZ(n){return this.scaleZoom(this.cameraToCenterDistance/(n*this.tileSize))}zoomFromMercatorZAdjusted(n){let a=0,p=s.GLOBE_ZOOM_THRESHOLD_MAX,_=0,b=1/0;for(;p-a>1e-6&&p>a;){const I=a+.5*(p-a),M=this.tileSize*Math.pow(2,I),P=this.getCameraToCenterDistance(this.projection,I,M),N=this.scaleZoom(P/(n*this.tileSize)),z=Math.abs(I-N);zN||Y.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+s.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new s.Point(0,0),new s.Point(this.width,this.height))}zoomDeltaToMovement(n,a){const p=s.length(s.sub([],this._camera.position,n)),_=this._zoomFromMercatorZ(p)+a;return p-this._mercatorZfromZoom(_)}getCameraPoint(){if(this.projection.name==="globe"){const n=function([a,p,_],b){const I=[a,p,_,1];s.transformMat4$1(I,I,b);const M=I[3]=Math.max(I[3],1e-6);return I[0]/=M,I[1]/=M,I[2]/=M,I}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new s.Point(n[0],n[1])}{const n=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.Point(0,n))}}getCameraToCenterDistance(n,a=this.zoom,p=this.worldSize){const _=ws(n,a,this.width,this.height,1024),b=n.pixelSpaceConversion(this.center.lat,p,_);return .5/Math.tan(.5*this._fov)*this.height*b}getWorldToCameraMatrix(){const n=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&s.multiply(n,n,this.globeMatrix),n}}function Na(h,n){let a=!1,p=null;const _=()=>{p=null,a&&(h(),p=setTimeout(_,n),a=!1)};return()=>(a=!0,p||_(),p)}class Sc{constructor(n){this._hashName=n&&encodeURIComponent(n),s.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Na(this._updateHashUnthrottled.bind(this),300)}addTo(n){return this._map=n,s.window.addEventListener("hashchange",this._onHashChange,!1),n.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),s.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const n=this._map;if(!n)return"";const a=wl(n);if(this._hashName){const p=this._hashName;let _=!1;const b=s.window.location.hash.slice(1).split("&").map(I=>{const M=I.split("=")[0];return M===p?(_=!0,`${M}=${a}`):I}).filter(I=>I);return _||b.push(`${p}=${a}`),`#${b.join("&")}`}return`#${a}`}_getCurrentHash(){const n=s.window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(p=>p.split("=")).forEach(p=>{p[0]===this._hashName&&(a=p)}),(a&&a[1]||"").split("/")}return n.split("/")}_onHashChange(){const n=this._map;if(!n)return!1;const a=this._getCurrentHash();if(a.length>=3&&!a.some(p=>isNaN(p))){const p=n.dragRotate.isEnabled()&&n.touchZoomRotate.isEnabled()?+(a[3]||0):n.getBearing();return n.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:p,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const n=s.window.location.href.replace(/(#.+)?$/,this.getHashString());s.window.history.replaceState(s.window.history.state,null,n)}}function wl(h,n){const a=h.getCenter(),p=Math.round(100*h.getZoom())/100,_=Math.ceil((p*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.pow(10,_),I=Math.round(a.lng*b)/b,M=Math.round(a.lat*b)/b,P=h.getBearing(),N=h.getPitch();let z=n?`/${I}/${M}/${p}`:`${p}/${M}/${I}`;return(P||N)&&(z+="/"+Math.round(10*P)/10),N&&(z+=`/${Math.round(N)}`),z}const El={linearity:.3,easing:s.bezier(0,0,.3,1)},wu=s.extend({deceleration:2500,maxSpeed:1400},El),Eu=s.extend({deceleration:20,maxSpeed:1400},El),kt=s.extend({deceleration:1e3,maxSpeed:360},El),co=s.extend({deceleration:1e3,maxSpeed:90},El);class wf{constructor(n){this._map=n,this.clear()}clear(){this._inertiaBuffer=[]}record(n){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.exported.now(),settings:n})}_drainInertiaBuffer(){const n=this._inertiaBuffer,a=s.exported.now();for(;n.length>0&&a-n[0].time>160;)n.shift()}_onMoveEnd(n){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const a={zoom:0,bearing:0,pitch:0,pan:new s.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:b}of this._inertiaBuffer)a.zoom+=b.zoomDelta||0,a.bearing+=b.bearingDelta||0,a.pitch+=b.pitchDelta||0,b.panDelta&&a.pan._add(b.panDelta),b.around&&(a.around=b.around),b.pinchAround&&(a.pinchAround=b.pinchAround);const p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(a.pan.mag()){const b=Sl(a.pan.mag(),p,s.extend({},wu,n||{}));_.offset=a.pan.mult(b.amount/a.pan.mag()),_.center=this._map.transform.center,Tl(_,b)}if(a.zoom){const b=Sl(a.zoom,p,Eu);_.zoom=this._map.transform.zoom+b.amount,Tl(_,b)}if(a.bearing){const b=Sl(a.bearing,p,kt);_.bearing=this._map.transform.bearing+s.clamp(b.amount,-179,179),Tl(_,b)}if(a.pitch){const b=Sl(a.pitch,p,co);_.pitch=this._map.transform.pitch+b.amount,Tl(_,b)}if(_.zoom||_.bearing){const b=a.pinchAround===void 0?a.around:a.pinchAround;_.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),_.noMoveStart=!0,_}}function Tl(h,n){(!h.duration||h.durationa.unproject(P)),M=b.reduce((P,N,z,j)=>P.add(N.div(j.length)),new s.Point(0,0));super(n,{points:b,point:M,lngLats:I,lngLat:a.unproject(M),originalEvent:p}),this._defaultPrevented=!1}}class Tu extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(n,a,p){super(n,{originalEvent:p}),this._defaultPrevented=!1}}class Ic{constructor(n,a){this._map=n,this._clickTolerance=a.clickTolerance}reset(){this._mousedownPos=void 0}wheel(n){return this._firePreventable(new Tu(n.type,this._map,n))}mousedown(n,a){return this._mousedownPos=a,this._firePreventable(new Gn(n.type,this._map,n))}mouseup(n){this._map.fire(new Gn(n.type,this._map,n))}preclick(n){const a=s.extend({},n);a.type="preclick",this._map.fire(new Gn(a.type,this._map,a))}click(n,a){this._mousedownPos&&this._mousedownPos.dist(a)>=this._clickTolerance||(this.preclick(n),this._map.fire(new Gn(n.type,this._map,n)))}dblclick(n){return this._firePreventable(new Gn(n.type,this._map,n))}mouseover(n){this._map.fire(new Gn(n.type,this._map,n))}mouseout(n){this._map.fire(new Gn(n.type,this._map,n))}touchstart(n){return this._firePreventable(new Il(n.type,this._map,n))}touchmove(n){this._map.fire(new Il(n.type,this._map,n))}touchend(n){this._map.fire(new Il(n.type,this._map,n))}touchcancel(n){this._map.fire(new Il(n.type,this._map,n))}_firePreventable(n){if(this._map.fire(n),n.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Su{constructor(n){this._map=n}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(n){this._map.fire(new Gn(n.type,this._map,n))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Gn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(n){this._delayContextMenu?this._contextMenuEvent=n:this._map.fire(new Gn(n.type,this._map,n)),this._map.listens("contextmenu")&&n.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ef{constructor(n,a){this._map=n,this._el=n.getCanvasContainer(),this._container=n.getContainer(),this._clickTolerance=a.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(n,a){this.isEnabled()&&n.shiftKey&&n.button===0&&(Mt(),this._startPos=this._lastPos=a,this._active=!0)}mousemoveWindow(n,a){if(!this._active)return;const p=a,_=this._startPos,b=this._lastPos;if(!_||!b||b.equals(p)||!this._box&&p.dist(_){this._box&&(this._box.style.transform=`translate(${I}px,${P}px)`,this._box.style.width=M-I+"px",this._box.style.height=N-P+"px")})}mouseupWindow(n,a){if(!this._active)return;const p=this._startPos,_=a;if(p&&n.button===0){if(this.reset(),Et(),p.x!==_.x||p.y!==_.y)return this._map.fire(new s.Event("boxzoomend",{originalEvent:n})),{cameraAnimation:b=>b.fitScreenCoordinates(p,_,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",n)}}keydown(n){this._active&&n.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",n))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Le(),delete this._startPos,delete this._lastPos}_fireEvent(n,a){return this._map.fire(new s.Event(n,{originalEvent:a}))}}function Iu(h,n){const a={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=n.timeStamp),p.length===this.numTouches&&(this.centroid=function(_){const b=new s.Point(0,0);for(const I of _)b._add(I);return b.div(_.length)}(a),this.touches=Iu(p,a)))}touchmove(n,a,p){if(this.aborted||!this.centroid)return;const _=Iu(p,a);for(const b in this.touches){const I=_[b];(!I||I.dist(this.touches[b])>30)&&(this.aborted=!0)}}touchend(n,a,p){if((!this.centroid||n.timeStamp-this.startTime>500)&&(this.aborted=!0),p.length===0){const _=!this.aborted&&this.centroid;if(this.reset(),_)return _}}}class kc{constructor(n){this.singleTap=new Ba(n),this.numTaps=n.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(n,a,p){this.singleTap.touchstart(n,a,p)}touchmove(n,a,p){this.singleTap.touchmove(n,a,p)}touchend(n,a,p){const _=this.singleTap.touchend(n,a,p);if(_){const b=n.timeStamp-this.lastTime<500,I=!this.lastTap||this.lastTap.dist(_)<30;if(b&&I||this.reset(),this.count++,this.lastTime=n.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Xd{constructor(){this._zoomIn=new kc({numTouches:1,numTaps:2}),this._zoomOut=new kc({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(n,a,p){this._zoomIn.touchstart(n,a,p),this._zoomOut.touchstart(n,a,p)}touchmove(n,a,p){this._zoomIn.touchmove(n,a,p),this._zoomOut.touchmove(n,a,p)}touchend(n,a,p){const _=this._zoomIn.touchend(n,a,p),b=this._zoomOut.touchend(n,a,p);return _?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:I=>I.easeTo({duration:300,zoom:I.getZoom()+1,around:I.unproject(_)},{originalEvent:n})}):b?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:I=>I.easeTo({duration:300,zoom:I.getZoom()-1,around:I.unproject(b)},{originalEvent:n})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Tf={0:1,2:2};class Fa{constructor(n){this.reset(),this._clickTolerance=n.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(n,a){return!1}_move(n,a){return{}}mousedown(n,a){if(this._lastPoint)return;const p=_t(n);this._correctButton(n,p)&&(this._lastPoint=a,this._eventButton=p)}mousemoveWindow(n,a){const p=this._lastPoint;if(p){if(n.preventDefault(),this._eventButton!=null&&function(_,b){const I=Tf[b];return _.buttons===void 0||(_.buttons&I)!==I}(n,this._eventButton))this.reset();else if(this._moved||!(a.dist(p)0&&(this._active=!0);const _=Iu(p,a),b=new s.Point(0,0),I=new s.Point(0,0);let M=0;for(const N in _){const z=_[N],j=this._touches[N];j&&(b._add(z),I._add(z.sub(j)),M++,_[N]=z)}if(this._touches=_,M{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class kl{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(n){}_move(n,a,p){return{}}touchstart(n,a,p){this._firstTwoTouches||p.length<2||(this._firstTwoTouches=[p[0].identifier,p[1].identifier],this._start([a[0],a[1]]))}touchmove(n,a,p){const _=this._firstTwoTouches;if(!_)return;n.preventDefault();const[b,I]=_,M=Ml(p,a,b),P=Ml(p,a,I);if(!M||!P)return;const N=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],N,n)}touchend(n,a,p){if(!this._firstTwoTouches)return;const[_,b]=this._firstTwoTouches,I=Ml(p,a,_),M=Ml(p,a,b);I&&M||(this._active&&Et(),this.reset())}touchcancel(){this.reset()}enable(n){this._enabled=!0,this._aroundCenter=!!n&&n.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ml(h,n,a){for(let p=0;pMath.abs(h.x)}class kf extends kl{constructor(n){super(),this._map=n}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(n){this._lastPoints=n,Es(n[0].sub(n[1]))&&(this._valid=!1)}_move(n,a,p){const _=this._lastPoints;if(!_)return;const b=n[0].sub(_[0]),I=n[1].sub(_[1]);return this._map._cooperativeGestures&&!s.isFullscreen()&&p.touches.length<3||(this._valid=this.gestureBeginsVertically(b,I,p.timeStamp),!this._valid)?void 0:(this._lastPoints=n,this._active=!0,{pitchDelta:(b.y+I.y)/2*-.5})}gestureBeginsVertically(n,a,p){if(this._valid!==void 0)return this._valid;const _=n.mag()>=2,b=a.mag()>=2;if(!_&&!b)return;if(!_||!b)return this._firstMove==null&&(this._firstMove=p),p-this._firstMove<100&&void 0;const I=n.y>0==a.y>0;return Es(n)&&Es(a)&&I}}const Mf={panStep:100,bearingStep:15,pitchStep:10};class Wd{constructor(){const n=Mf;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(n){if(n.altKey||n.ctrlKey||n.metaKey)return;let a=0,p=0,_=0,b=0,I=0;switch(n.keyCode){case 61:case 107:case 171:case 187:a=1;break;case 189:case 109:case 173:a=-1;break;case 37:n.shiftKey?p=-1:(n.preventDefault(),b=-1);break;case 39:n.shiftKey?p=1:(n.preventDefault(),b=1);break;case 38:n.shiftKey?_=1:(n.preventDefault(),I=-1);break;case 40:n.shiftKey?_=-1:(n.preventDefault(),I=1);break;default:return}return this._rotationDisabled&&(p=0,_=0),{cameraAnimation:M=>{const P=M.getZoom();M.easeTo({duration:300,easeId:"keyboardHandler",easing:Af,zoom:a?Math.round(P)+a*(n.shiftKey?2:1):P,bearing:M.getBearing()+p*this._bearingStep,pitch:M.getPitch()+_*this._pitchStep,offset:[-b*this._panStep,-I*this._panStep],center:M.getCenter()},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Af(h){return h*(2-h)}const Rc=4.000244140625;class Cf{constructor(n,a){this._map=n,this._el=n.getCanvasContainer(),this._handler=a,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,s.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(n){this._defaultZoomRate=n}setWheelZoomRate(n){this._wheelZoomRate=n}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(n){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!n&&n.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(n){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(n.ctrlKey||n.metaKey||this.isZooming()||s.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let a=n.deltaMode===s.window.WheelEvent.DOM_DELTA_LINE?40*n.deltaY:n.deltaY;const p=s.exported.now(),_=p-(this._lastWheelEventTime||0);this._lastWheelEventTime=p,a!==0&&a%Rc==0?this._type="wheel":a!==0&&Math.abs(a)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=a,this._timeout=setTimeout(this._onTimeout,40,n)):this._type||(this._type=Math.abs(_*a)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,a+=this._lastValue)),n.shiftKey&&a&&(a/=4),this._type&&(this._lastWheelEvent=n,this._delta-=a,this._active||this._start(n)),n.preventDefault()}_onTimeout(n){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(n)}_start(n){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const a=ut(this._el,n);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:a,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const n=this._map.transform;this._type==="wheel"&&n.projection.wrap&&(n._center.lng>=180||n._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const a=()=>n._terrainEnabled()&&this._aroundCoord?n.computeZoomRelativeTo(this._aroundCoord):n.zoom;if(this._delta!==0){const P=this._type==="wheel"&&Math.abs(this._delta)>Rc?this._wheelZoomRate:this._defaultZoomRate;let N=2/(1+Math.exp(-Math.abs(this._delta*P)));this._delta<0&&N!==0&&(N=1/N);const z=a(),j=Math.pow(2,z),Y=typeof this._targetZoom=="number"?n.zoomScale(this._targetZoom):j;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(Y*N))),this._type==="wheel"&&(this._startZoom=z,this._easing=this._smoothOutEasing(200)),this._delta=0}const p=typeof this._targetZoom=="number"?this._targetZoom:a(),_=this._startZoom,b=this._easing;let I,M=!1;if(this._type==="wheel"&&_&&b){const P=Math.min((s.exported.now()-this._lastWheelEventTime)/200,1),N=b(P);I=s.number(_,p,N),P<1?this._frameId||(this._frameId=!0):M=!0}else I=p,M=!0;return this._active=!0,M&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!M,zoomDelta:I-a(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(n){let a=s.ease;if(this._prevEase){const p=this._prevEase,_=(s.exported.now()-p.start)/p.duration,b=p.easing(_+.01)-p.easing(_),I=.27/Math.sqrt(b*b+1e-4)*.01,M=Math.sqrt(.0729-I*I);a=s.bezier(I,M,.25,1)}return this._prevEase={start:s.exported.now(),duration:n,easing:a},a}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=we("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(s.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Pf{constructor(n,a){this._clickZoom=n,this._tapZoom=a}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class lr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(n,a){return n.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:p.getZoom()+(n.shiftKey?-1:1),around:p.unproject(a)},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Yd{constructor(){this._tap=new kc({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(n,a,p){this._swipePoint||(this._tapTime&&n.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?p.length>0&&(this._swipePoint=a[0],this._swipeTouch=p[0].identifier):this._tap.touchstart(n,a,p))}touchmove(n,a,p){if(this._tapTime){if(this._swipePoint){if(p[0].identifier!==this._swipeTouch)return;const _=a[0],b=_.y-this._swipePoint.y;return this._swipePoint=_,n.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(n,a,p)}touchend(n,a,p){this._tapTime?this._swipePoint&&p.length===0&&this.reset():this._tap.touchend(n,a,p)&&(this._tapTime=n.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Lf{constructor(n,a,p){this._el=n,this._mousePan=a,this._touchPan=p}enable(n){this._inertiaOptions=n||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Hd{constructor(n,a,p){this._pitchWithRotate=n.pitchWithRotate,this._mouseRotate=a,this._mousePitch=p}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Kd{constructor(n,a,p,_){this._el=n,this._touchZoom=a,this._touchRotate=p,this._tapDragZoom=_,this._rotationDisabled=!1,this._enabled=!0}enable(n){this._touchZoom.enable(n),this._rotationDisabled||this._touchRotate.enable(n),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Kr=h=>h.zoom||h.drag||h.pitch||h.rotate;class Rf extends s.Event{}class Jd{constructor(){this.constants=[1,1,.01],this.radius=0}setup(n,a){const p=s.sub([],a,n);this.radius=s.length(p[2]<0?s.div([],p,this.constants):[p[0],p[1],0])}projectRay(n){s.div(n,n,this.constants),s.normalize(n,n),s.mul$1(n,n,this.constants);const a=s.scale$2([],n,this.radius);if(a[2]>0){const p=s.scale$2([],[0,0,1],s.dot(a,[0,0,1])),_=s.scale$2([],s.normalize([],[a[0],a[1],0]),this.radius),b=s.add([],a,s.scale$2([],s.sub([],s.add([],_,p),a),2));a[0]=b[0],a[1]=b[1]}return a}}function ho(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class Io{constructor(n,a){this._map=n,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new wf(n),this._bearingSnap=a.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Jd,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(a),s.bindAll(["handleEvent","handleWindowEvent"],this);const p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[s.window.document,"mousemove",{capture:!0}],[s.window.document,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[s.window,"blur",void 0]];for(const[_,b,I]of this._listeners)_.addEventListener(b,_===s.window.document?this.handleWindowEvent:this.handleEvent,I)}destroy(){for(const[n,a,p]of this._listeners)n.removeEventListener(a,n===s.window.document?this.handleWindowEvent:this.handleEvent,p)}_addDefaultHandlers(n){const a=this._map,p=a.getCanvasContainer();this._add("mapEvent",new Ic(a,n));const _=a.boxZoom=new Ef(a,n);this._add("boxZoom",_);const b=new Xd,I=new lr;a.doubleClickZoom=new Pf(I,b),this._add("tapZoom",b),this._add("clickZoom",I);const M=new Yd;this._add("tapDragZoom",M);const P=a.touchPitch=new kf(a);this._add("touchPitch",P);const N=new Ac(n),z=new Cc(n);a.dragRotate=new Hd(n,N,z),this._add("mouseRotate",N,["mousePitch"]),this._add("mousePitch",z,["mouseRotate"]);const j=new Mc(n),Y=new ku(a,n);a.dragPan=new Lf(p,j,Y),this._add("mousePan",j),this._add("touchPan",Y,["touchZoom","touchRotate"]);const J=new If,te=new Sf;a.touchZoomRotate=new Kd(p,te,J,M),this._add("touchRotate",J,["touchPan","touchZoom"]),this._add("touchZoom",te,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Su(a));const ee=a.scrollZoom=new Cf(a,this);this._add("scrollZoom",ee,["mousePan"]);const ie=a.keyboard=new Wd;this._add("keyboard",ie);for(const V of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])n.interactive&&n[V]&&a[V].enable(n[V])}_add(n,a,p){this._handlers.push({handlerName:n,handler:a,allowed:p}),this._handlersById[n]=a}stop(n){if(!this._updatingCamera){for(const{handler:a}of this._handlers)a.reset();this._inertia.clear(),this._fireEvents({},{},n),this._changes=[]}}isActive(){for(const{handler:n}of this._handlers)if(n.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Kr(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(n,a,p){for(const _ in n)if(_!==p&&(!a||a.indexOf(_)<0))return!0;return!1}handleWindowEvent(n){this.handleEvent(n,`${n.type}Window`)}_getMapTouches(n){const a=[];for(const p of n)this._el.contains(p.target)&&a.push(p);return a}handleEvent(n,a){this._updatingCamera=!0;const p=n.type==="renderFrame",_=p?void 0:n,b={needsRenderFrame:!1},I={},M={},P=n.touches?this._getMapTouches(n.touches):void 0,N=P?yt(this._el,P):p?void 0:ut(this._el,n);for(const{handlerName:Y,handler:J,allowed:te}of this._handlers){if(!J.isEnabled())continue;let ee;this._blockedByActive(M,te,Y)?J.reset():J[a||n.type]&&(ee=J[a||n.type](n,N,P),this.mergeHandlerResult(b,I,ee,Y,_),ee&&ee.needsRenderFrame&&this._triggerRenderFrame()),(ee||J.isActive())&&(M[Y]=J)}const z={};for(const Y in this._previousActiveHandlers)M[Y]||(z[Y]=_);this._previousActiveHandlers=M,(Object.keys(z).length||ho(b))&&(this._changes.push([b,I,z]),this._triggerRenderFrame()),(Object.keys(M).length||ho(b))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:j}=b;j&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],j(this._map))}mergeHandlerResult(n,a,p,_,b){if(!p)return;s.extend(n,p);const I={handlerName:_,originalEvent:p.originalEvent||b};p.zoomDelta!==void 0&&(a.zoom=I),p.panDelta!==void 0&&(a.drag=I),p.pitchDelta!==void 0&&(a.pitch=I),p.bearingDelta!==void 0&&(a.rotate=I)}_applyChanges(){const n={},a={},p={};for(const[_,b,I]of this._changes)_.panDelta&&(n.panDelta=(n.panDelta||new s.Point(0,0))._add(_.panDelta)),_.zoomDelta&&(n.zoomDelta=(n.zoomDelta||0)+_.zoomDelta),_.bearingDelta&&(n.bearingDelta=(n.bearingDelta||0)+_.bearingDelta),_.pitchDelta&&(n.pitchDelta=(n.pitchDelta||0)+_.pitchDelta),_.around!==void 0&&(n.around=_.around),_.aroundCoord!==void 0&&(n.aroundCoord=_.aroundCoord),_.pinchAround!==void 0&&(n.pinchAround=_.pinchAround),_.noInertia&&(n.noInertia=_.noInertia),s.extend(a,b),s.extend(p,I);this._updateMapTransform(n,a,p),this._changes=[]}_updateMapTransform(n,a,p){const _=this._map,b=_.transform,I=K=>[K.x,K.y,K.z];if((K=>{const ae=this._eventsInProgress.drag;return ae&&!this._handlersById[ae.handlerName].isActive()})()&&!ho(n)){const K=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",K!==b.zoom&&this._map._update(!0)}if(b._isCameraConstrained&&_._stop(!0),!ho(n))return void this._fireEvents(a,p,!0);let{panDelta:M,zoomDelta:P,bearingDelta:N,pitchDelta:z,around:j,aroundCoord:Y,pinchAround:J}=n;b._isCameraConstrained&&(P>0&&(P=0),b._isCameraConstrained=!1),J!==void 0&&(j=J),(P||(K=>a[K]&&!this._eventsInProgress[K])("drag"))&&j&&(this._dragOrigin=I(b.pointCoordinate3D(j)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",_._stop(!0),j=j||_.transform.centerPoint,N&&(b.bearing+=N),z&&(b.pitch+=z),b._updateCameraState();const te=[0,0,0];if(M)if(b.projection.name==="mercator"){const K=this._trackingEllipsoid.projectRay(b.screenPointToMercatorRay(j).dir),ae=this._trackingEllipsoid.projectRay(b.screenPointToMercatorRay(j.sub(M)).dir);te[0]=ae[0]-K[0],te[1]=ae[1]-K[1]}else{const K=b.pointCoordinate(j);if(b.projection.name==="globe"){M=M.rotate(-b.angle);const ae=b._pixelsPerMercatorPixel/b.worldSize;te[0]=-M.x*s.mercatorScale(s.latFromMercatorY(K.y))*ae,te[1]=-M.y*s.mercatorScale(b.center.lat)*ae}else{const ae=b.pointCoordinate(j.sub(M));K&&ae&&(te[0]=ae.x-K.x,te[1]=ae.y-K.y)}}const ee=b.zoom,ie=[0,0,0];if(P){const K=I(Y||b.pointCoordinate3D(j)),ae={dir:s.normalize([],s.sub([],K,b._camera.position))};if(ae.dir[2]<0){const le=b.zoomDeltaToMovement(K,P);s.scale$2(ie,ae.dir,le)}}const V=s.add(te,te,ie);b._translateCameraConstrained(V),P&&Math.abs(b.zoom-ee)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),n.noInertia||this._inertia.record(n),this._fireEvents(a,p,!0)}_fireEvents(n,a,p){const _=Kr(this._eventsInProgress),b=Kr(n),I={};for(const z in n){const{originalEvent:j}=n[z];this._eventsInProgress[z]||(I[`${z}start`]=j),this._eventsInProgress[z]=n[z]}!_&&b&&this._fireEvent("movestart",b.originalEvent);for(const z in I)this._fireEvent(z,I[z]);b&&this._fireEvent("move",b.originalEvent);for(const z in n){const{originalEvent:j}=n[z];this._fireEvent(z,j)}const M={};let P;for(const z in this._eventsInProgress){const{handlerName:j,originalEvent:Y}=this._eventsInProgress[z];this._handlersById[j].isActive()||(delete this._eventsInProgress[z],P=a[j]||Y,M[`${z}end`]=P)}for(const z in M)this._fireEvent(z,M[z]);const N=Kr(this._eventsInProgress);if(p&&(_||b)&&!N){this._updatingCamera=!0;const z=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),j=Y=>Y!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Rf("renderFrame",{timeStamp:n})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Js="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Mu extends s.Evented{constructor(n,a){super(),this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=a.bearingSnap,this._respectPrefersReducedMotion=a.respectPrefersReducedMotion!==!1,s.bindAll(["_renderFrameCallback"],this)}getCenter(){return new s.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(n,a){return this.jumpTo({center:n},a)}panBy(n,a,p){return n=s.Point.convert(n).mult(-1),this.panTo(this.transform.center,s.extend({offset:n},a),p)}panTo(n,a,p){return this.easeTo(s.extend({center:n},a),p)}getZoom(){return this.transform.zoom}setZoom(n,a){return this.jumpTo({zoom:n},a),this}zoomTo(n,a,p){return this.easeTo(s.extend({zoom:n},a),p)}zoomIn(n,a){return this.zoomTo(this.getZoom()+1,n,a),this}zoomOut(n,a){return this.zoomTo(this.getZoom()-1,n,a),this}getBearing(){return this.transform.bearing}setBearing(n,a){return this.jumpTo({bearing:n},a),this}getPadding(){return this.transform.padding}setPadding(n,a){return this.jumpTo({padding:n},a),this}rotateTo(n,a,p){return this.easeTo(s.extend({bearing:n},a),p)}resetNorth(n,a){return this.rotateTo(0,s.extend({duration:1e3},n),a),this}resetNorthPitch(n,a){return this.easeTo(s.extend({bearing:0,pitch:0,duration:1e3},n),a),this}snapToNorth(n,a){return Math.abs(this.getBearing())n.aspect?p/(2*Math.tan(.5*n.fovX)*n.aspect):_/(2*Math.tan(.5*n.fovY)*n.aspect)}_cameraForBoundsOnGlobe(n,a,p,_,b,I){const M=n.clone(),P=this._extendCameraOptions(I);M.bearing=_,M.pitch=b;const N=s.LngLat.convert(a),z=s.LngLat.convert(p),j=.5*(N.lat+z.lat),Y=.5*(N.lng+z.lng),J=s.latLngToECEF(j,Y),te=s.normalize([],J),ee=s.normalize([],s.cross([],te,[0,1,0])),ie=s.cross([],ee,te),V=[ee[0],ee[1],ee[2],0,ie[0],ie[1],ie[2],0,te[0],te[1],te[2],0,0,0,0,1],K=[J,s.latLngToECEF(N.lat,N.lng),s.latLngToECEF(z.lat,N.lng),s.latLngToECEF(z.lat,z.lng),s.latLngToECEF(N.lat,z.lng),s.latLngToECEF(j,N.lng),s.latLngToECEF(j,z.lng),s.latLngToECEF(N.lat,Y),s.latLngToECEF(z.lat,Y)];let ae=s.Aabb.fromPoints(K.map(Ke=>[s.dot(ee,Ke),s.dot(ie,Ke),s.dot(te,Ke)]));const le=s.transformMat4([],ae.center,V);s.squaredLength(le)===0&&s.set(le,0,0,1),s.normalize(le,le),s.scale$2(le,le,s.GLOBE_RADIUS),M.center=s.ecefToLatLng(le);const xe=M.getWorldToCameraMatrix(),Te=s.invert(new Float64Array(16),xe);ae=s.Aabb.applyTransform(ae,s.multiply([],xe,V)),s.transformMat4(le,le,xe);const be=.5*(ae.max[2]-ae.min[2]),Ae=this._minimumAABBFrustumDistance(M,ae),ke=s.scale$2([],[0,0,1],be),Ne=s.add(ke,le,ke),tt=Ae+(M.pitch===0?0:s.distance(le,Ne)),Re=M.globeCenterInViewSpace,We=s.sub([],le,[Re[0],Re[1],Re[2]]);s.normalize(We,We),s.scale$2(We,We,tt);const je=s.add([],le,We);s.transformMat4(je,je,Te);const et=s.earthRadius/s.GLOBE_RADIUS,ze=s.length(je),Ze=s.mercatorZfromAltitude(Math.max(ze*et-s.earthRadius,Number.EPSILON),0),rt=Math.min(M.zoomFromMercatorZAdjusted(Ze),P.maxZoom);return rt>.5*(s.GLOBE_ZOOM_THRESHOLD_MIN+s.GLOBE_ZOOM_THRESHOLD_MAX)?(M.setProjection({name:"mercator"}),M.zoom=rt,this._cameraForBounds(M,a,p,_,b,I)):{center:M.center,zoom:rt,bearing:_,pitch:b}}queryTerrainElevation(n,a){const p=this.transform.elevation;return p?(a=s.extend({},{exaggerated:!0},a),p.getAtPoint(s.MercatorCoordinate.fromLngLat(n),null,a.exaggerated)):null}_cameraForBounds(n,a,p,_,b,I){if(n.projection.name==="globe")return this._cameraForBoundsOnGlobe(n,a,p,_,b,I);const M=n.clone(),P=this._extendCameraOptions(I),N=M.padding;M.bearing=_,M.pitch=b;const z=s.LngLat.convert(a),j=s.LngLat.convert(p),Y=new s.LngLat(z.lng,j.lat),J=new s.LngLat(j.lng,z.lat),te=M.project(z),ee=M.project(j),ie=this.queryTerrainElevation(z),V=this.queryTerrainElevation(j),K=this.queryTerrainElevation(Y),ae=this.queryTerrainElevation(J),le=[[te.x,te.y,Math.min(ie||0,V||0,K||0,ae||0)],[ee.x,ee.y,Math.max(ie||0,V||0,K||0,ae||0)]];let xe=s.Aabb.fromPoints(le);const Te=M.getWorldToCameraMatrix(),be=s.invert(new Float64Array(16),Te);xe=s.Aabb.applyTransform(xe,Te);const Ae=s.sub([],xe.max,xe.min),ke=N.left||0,Ne=N.right||0,tt=N.bottom||0,Re=N.top||0,{left:We,right:je,top:et,bottom:ze}=P.padding,Ze=.5*(ke+Ne),rt=.5*(Re+tt),Ke=Math.min(M.scaleZoom(M.scale*Math.min((M.width-(ke+Ne+We+je))/Ae[0],(M.height-(tt+Re+ze+et))/Ae[1])),P.maxZoom),st=M.scale/M.zoomScale(Ke);xe=new s.Aabb([xe.min[0]-(We+Ze)*st,xe.min[1]-(ze+rt)*st,xe.min[2]],[xe.max[0]+(je+Ze)*st,xe.max[1]+(et+rt)*st,xe.max[2]]);const zt=.5*Ae[2],Kt=this._minimumAABBFrustumDistance(M,xe),Pt=[0,0,1,0];s.transformMat4$1(Pt,Pt,Te),s.normalize$2(Pt,Pt);const jt=s.scale$2([],Pt,Kt+zt),mi=s.add([],xe.center,jt),di=(typeof P.offset.x=="number"&&typeof P.offset.y=="number"?new s.Point(P.offset.x,P.offset.y):s.Point.convert(P.offset)).rotate(-s.degToRad(_));xe.center[0]-=di.x*st,xe.center[1]+=di.y*st,s.transformMat4(xe.center,xe.center,be),s.transformMat4(mi,mi,be);const Ot=[xe.center[0],xe.center[1],mi[2]*M.pixelsPerMeter];s.scale$2(Ot,Ot,1/M.worldSize);const Di=s.lngFromMercatorX(Ot[0]),Bi=s.latFromMercatorY(Ot[1]),Fi=Math.min(M._zoomFromMercatorZ(Ot[2]),P.maxZoom),Ui=new s.LngLat(Di,Bi);return M.mercatorFromTransition&&Fi<.5*(s.GLOBE_ZOOM_THRESHOLD_MIN+s.GLOBE_ZOOM_THRESHOLD_MAX)?(M.setProjection({name:"globe"}),M.zoom=Fi,this._cameraForBounds(M,a,p,_,b,I)):{center:Ui,zoom:Fi,bearing:_,pitch:b}}fitBounds(n,a,p){const _=this.cameraForBounds(n,a);return this._fitInternal(_,a,p)}fitScreenCoordinates(n,a,p,_,b){const I=s.Point.convert(n),M=s.Point.convert(a),P=new s.Point(Math.min(I.x,M.x),Math.min(I.y,M.y)),N=new s.Point(Math.max(I.x,M.x),Math.max(I.y,M.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(I,M))return this;const z=this.transform.pointLocation3D(P),j=this.transform.pointLocation3D(N),Y=this.transform.pointLocation3D(new s.Point(P.x,N.y)),J=this.transform.pointLocation3D(new s.Point(N.x,P.y)),te=[Math.min(z.lng,j.lng,Y.lng,J.lng),Math.min(z.lat,j.lat,Y.lat,J.lat)],ee=[Math.max(z.lng,j.lng,Y.lng,J.lng),Math.max(z.lat,j.lat,Y.lat,J.lat)],ie=_&&_.pitch?_.pitch:this.getPitch(),V=this._cameraForBounds(this.transform,te,ee,p,ie,_);return this._fitInternal(V,_,b)}_fitInternal(n,a,p){return n?(delete(a=s.extend(n,a)).padding,a.linear?this.easeTo(a,p):this.flyTo(a,p)):this}jumpTo(n,a){this.stop();const p=n.preloadOnly?this.transform.clone():this.transform;let _=!1,b=!1,I=!1;return"zoom"in n&&p.zoom!==+n.zoom&&(_=!0,p.zoom=+n.zoom),n.center!==void 0&&(p.center=s.LngLat.convert(n.center)),"bearing"in n&&p.bearing!==+n.bearing&&(b=!0,p.bearing=+n.bearing),"pitch"in n&&p.pitch!==+n.pitch&&(I=!0,p.pitch=+n.pitch),n.padding==null||p.isPaddingEqual(n.padding)||(p.padding=n.padding),n.preloadOnly?(this._preloadTiles(p),this):(this.fire(new s.Event("movestart",a)).fire(new s.Event("move",a)),_&&this.fire(new s.Event("zoomstart",a)).fire(new s.Event("zoom",a)).fire(new s.Event("zoomend",a)),b&&this.fire(new s.Event("rotatestart",a)).fire(new s.Event("rotate",a)).fire(new s.Event("rotateend",a)),I&&this.fire(new s.Event("pitchstart",a)).fire(new s.Event("pitch",a)).fire(new s.Event("pitchend",a)),this.fire(new s.Event("moveend",a)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||s.warnOnce(Js),this.transform.getFreeCameraOptions()}setFreeCameraOptions(n,a){const p=this.transform;if(!p.projection.supportsFreeCamera)return s.warnOnce(Js),this;this.stop();const _=p.zoom,b=p.pitch,I=p.bearing;p.setFreeCameraOptions(n);const M=_!==p.zoom,P=b!==p.pitch,N=I!==p.bearing;return this.fire(new s.Event("movestart",a)).fire(new s.Event("move",a)),M&&this.fire(new s.Event("zoomstart",a)).fire(new s.Event("zoom",a)).fire(new s.Event("zoomend",a)),N&&this.fire(new s.Event("rotatestart",a)).fire(new s.Event("rotate",a)).fire(new s.Event("rotateend",a)),P&&this.fire(new s.Event("pitchstart",a)).fire(new s.Event("pitch",a)).fire(new s.Event("pitchend",a)),this.fire(new s.Event("moveend",a)),this}easeTo(n,a){this._stop(!1,n.easeId),((n=s.extend({offset:[0,0],duration:500,easing:s.ease},n)).animate===!1||this._prefersReducedMotion(n))&&(n.duration=0);const p=this.transform,_=this.getZoom(),b=this.getBearing(),I=this.getPitch(),M=this.getPadding(),P="zoom"in n?+n.zoom:_,N="bearing"in n?this._normalizeBearing(n.bearing,b):b,z="pitch"in n?+n.pitch:I,j="padding"in n?n.padding:p.padding,Y=s.Point.convert(n.offset);let J,te,ee;if(p.projection.name==="globe"){const ke=s.MercatorCoordinate.fromLngLat(p.center),Ne=Y.rotate(-p.angle);ke.x+=Ne.x/p.worldSize,ke.y+=Ne.y/p.worldSize;const tt=ke.toLngLat(),Re=s.LngLat.convert(n.center||tt);this._normalizeCenter(Re),J=p.centerPoint.add(Ne),te=new s.Point(ke.x,ke.y).mult(p.worldSize),ee=new s.Point(s.mercatorXfromLng(Re.lng),s.mercatorYfromLat(Re.lat)).mult(p.worldSize).sub(te)}else{J=p.centerPoint.add(Y);const ke=p.pointLocation(J),Ne=s.LngLat.convert(n.center||ke);this._normalizeCenter(Ne),te=p.project(ke),ee=p.project(Ne).sub(te)}const ie=p.zoomScale(P-_);let V,K;n.around&&(V=s.LngLat.convert(n.around),K=p.locationPoint(V));const ae=this._zooming||P!==_,le=this._rotating||b!==N,xe=this._pitching||z!==I,Te=!p.isPaddingEqual(j),be=ke=>Ne=>{if(ae&&(ke.zoom=s.number(_,P,Ne)),le&&(ke.bearing=s.number(b,N,Ne)),xe&&(ke.pitch=s.number(I,z,Ne)),Te&&(ke.interpolatePadding(M,j,Ne),J=ke.centerPoint.add(Y)),V)ke.setLocationAtPoint(V,K);else{const tt=ke.zoomScale(ke.zoom-_),Re=P>_?Math.min(2,ie):Math.max(.5,ie),We=Math.pow(Re,1-Ne),je=ke.unproject(te.add(ee.mult(Ne*We)).mult(tt));ke.setLocationAtPoint(ke.renderWorldCopies?je.wrap():je,J)}return n.preloadOnly||this._fireMoveEvents(a),ke};if(n.preloadOnly){const ke=this._emulate(be,n.duration,p);return this._preloadTiles(ke),this}const Ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ae,this._rotating=le,this._pitching=xe,this._padding=Te,this._easeId=n.easeId,this._prepareEase(a,n.noMoveStart,Ae),this._ease(be(p),ke=>{p.recenterOnTerrain(),this._afterEase(a,ke)},n),this}_prepareEase(n,a,p={}){this._moving=!0,this.transform.cameraElevationReference="sea",a||p.moving||this.fire(new s.Event("movestart",n)),this._zooming&&!p.zooming&&this.fire(new s.Event("zoomstart",n)),this._rotating&&!p.rotating&&this.fire(new s.Event("rotatestart",n)),this._pitching&&!p.pitching&&this.fire(new s.Event("pitchstart",n))}_fireMoveEvents(n){this.fire(new s.Event("move",n)),this._zooming&&this.fire(new s.Event("zoom",n)),this._rotating&&this.fire(new s.Event("rotate",n)),this._pitching&&this.fire(new s.Event("pitch",n))}_afterEase(n,a){if(this._easeId&&a&&this._easeId===a)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const p=this._zooming,_=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,p&&this.fire(new s.Event("zoomend",n)),_&&this.fire(new s.Event("rotateend",n)),b&&this.fire(new s.Event("pitchend",n)),this.fire(new s.Event("moveend",n))}flyTo(n,a){if(this._prefersReducedMotion(n)){const Ke=s.pick(n,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ke,a)}this.stop(),n=s.extend({offset:[0,0],speed:1.2,curve:1.42,easing:s.ease},n);const p=this.transform,_=this.getZoom(),b=this.getBearing(),I=this.getPitch(),M=this.getPadding(),P="zoom"in n?s.clamp(+n.zoom,p.minZoom,p.maxZoom):_,N="bearing"in n?this._normalizeBearing(n.bearing,b):b,z="pitch"in n?+n.pitch:I,j="padding"in n?n.padding:p.padding,Y=p.zoomScale(P-_),J=s.Point.convert(n.offset);let te=p.centerPoint.add(J);const ee=p.pointLocation(te),ie=s.LngLat.convert(n.center||ee);this._normalizeCenter(ie);const V=p.project(ee),K=p.project(ie).sub(V);let ae=n.curve;const le=Math.max(p.width,p.height),xe=le/Y,Te=K.mag();if("minZoom"in n){const Ke=s.clamp(Math.min(n.minZoom,_,P),p.minZoom,p.maxZoom),st=le/p.zoomScale(Ke-_);ae=Math.sqrt(st/Te*2)}const be=ae*ae;function Ae(Ke){const st=(xe*xe-le*le+(Ke?-1:1)*be*be*Te*Te)/(2*(Ke?xe:le)*be*Te);return Math.log(Math.sqrt(st*st+1)-st)}function ke(Ke){return(Math.exp(Ke)-Math.exp(-Ke))/2}function Ne(Ke){return(Math.exp(Ke)+Math.exp(-Ke))/2}const tt=Ae(0);let Re=function(Ke){return Ne(tt)/Ne(tt+ae*Ke)},We=function(Ke){return le*((Ne(tt)*(ke(st=tt+ae*Ke)/Ne(st))-ke(tt))/be)/Te;var st},je=(Ae(1)-tt)/ae;if(Math.abs(Te)<1e-6||!isFinite(je)){if(Math.abs(le-xe)<1e-6)return this.easeTo(n,a);const Ke=xen.maxDuration&&(n.duration=0);const et=b!==N,ze=z!==I,Ze=!p.isPaddingEqual(j),rt=Ke=>st=>{const zt=st*je,Kt=1/Re(zt);Ke.zoom=st===1?P:_+Ke.scaleZoom(Kt),et&&(Ke.bearing=s.number(b,N,st)),ze&&(Ke.pitch=s.number(I,z,st)),Ze&&(Ke.interpolatePadding(M,j,st),te=Ke.centerPoint.add(J));const Pt=st===1?ie:Ke.unproject(V.add(K.mult(We(zt))).mult(Kt));return Ke.setLocationAtPoint(Ke.renderWorldCopies?Pt.wrap():Pt,te),Ke._updateCameraOnTerrain(),n.preloadOnly||this._fireMoveEvents(a),Ke};if(n.preloadOnly){const Ke=this._emulate(rt,n.duration,p);return this._preloadTiles(Ke),this}return this._zooming=!0,this._rotating=et,this._pitching=ze,this._padding=Ze,this._prepareEase(a,!1),this._ease(rt(p),()=>this._afterEase(a),n),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(n,a){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const p=this._onEaseEnd;this._onEaseEnd=void 0,p.call(this,a)}if(!n){const p=this.handlers;p&&p.stop(!1)}return this}_ease(n,a,p){p.animate===!1||p.duration===0?(n(1),a()):(this._easeStart=s.exported.now(),this._easeOptions=p,this._onEaseFrame=n,this._onEaseEnd=a,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const n=Math.min((s.exported.now()-this._easeStart)/this._easeOptions.duration,1),a=this._onEaseFrame;a&&a(this._easeOptions.easing(n)),n<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(n,a){n=s.wrap(n,-180,180);const p=Math.abs(n-a);return Math.abs(n-360-a)180?-360:p<-180?360:0}_prefersReducedMotion(n){return this._respectPrefersReducedMotion&&s.exported.prefersReducedMotion&&!(n&&n.essential)}_emulate(n,a,p){const _=Math.ceil(15*a/1e3),b=[],I=n(p.clone());for(let M=0;M<=_;M++){const P=I(M/_);b.push(P.clone())}return b}}class Ct{constructor(n={}){this.options=n,s.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(n){const a=this.options&&this.options.compact;return this._map=n,this._container=we("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=we("button","mapboxgl-ctrl-attrib-button",this._container),we("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=we("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),a&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),a===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(n,a){const p=this._map._getUIString(`AttributionControl.${a}`);n.setAttribute("aria-label",p),n.removeAttribute("title"),n.firstElementChild&&n.firstElementChild.setAttribute("title",p)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let n=this._editLink;n||(n=this._editLink=this._container.querySelector(".mapbox-improve-map"));const a=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||s.config.ACCESS_TOKEN}];if(n){const p=a.reduce((_,b,I)=>(b.value&&(_+=`${b.key}=${b.value}${I_.length-b.length),n=n.filter((_,b)=>{for(let I=b+1;I=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?n=[...this.options.customAttribution,...n]:n.unshift(this.options.customAttribution));const p=n.join(" | ");p!==this._attribHTML&&(this._attribHTML=p,n.length?(this._innerContainer.innerHTML=p,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Dc{constructor(){s.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(n){this._map=n,this._container=we("div","mapboxgl-ctrl");const a=we("a","mapboxgl-ctrl-logo");return a.target="_blank",a.rel="noopener nofollow",a.href="https://www.mapbox.com/",a.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),a.setAttribute("rel","noopener nofollow"),this._container.appendChild(a),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(n){n&&n.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const n=this._map.style._sourceCaches;if(Object.entries(n).length===0)return!0;for(const a in n){const p=n[a].getSource();if(p.hasOwnProperty("mapbox_logo")&&!p.mapbox_logo)return!1}return!0}_updateCompact(){const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<250?a.classList.add("mapboxgl-compact"):a.classList.remove("mapboxgl-compact")}}}class Oc{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(n){const a=++this._id;return this._queue.push({callback:n,id:a,cancelled:!1}),a}remove(n){const a=this._currentlyRunning,p=a?this._queue.concat(a):this._queue;for(const _ of p)if(_.id===n)return void(_.cancelled=!0)}run(n=0){const a=this._currentlyRunning=this._queue;this._queue=[];for(const p of a)if(!p.cancelled&&(p.callback(n),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ua(h,n,a){if(h=new s.LngLat(h.lng,h.lat),n){const p=new s.LngLat(h.lng-360,h.lat),_=new s.LngLat(h.lng+360,h.lat),b=360*Math.ceil(Math.abs(h.lng-a.center.lng)/360),I=a.locationPoint(h).distSqr(n),M=n.x<0||n.y<0||n.x>a.width||n.y>a.height;a.locationPoint(p).distSqr(n)180;){const p=a.locationPoint(h);if(p.x>=0&&p.y>=0&&p.x<=a.width&&p.y<=a.height)break;h.lng>a.center.lng?h.lng-=360:h.lng+=360}return h}const Qs={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class wt extends s.Evented{constructor(n,a){if(super(),(n instanceof s.window.HTMLElement||a)&&(n=s.extend({element:n},a)),s.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._scale=n&&n.scale||1,this._draggable=n&&n.draggable||!1,this._clickTolerance=n&&n.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=n&&n.rotation||0,this._rotationAlignment=n&&n.rotationAlignment||"auto",this._pitchAlignment=n&&n.pitchAlignment&&n.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=n&&n.occludedOpacity||.2,n&&n.element)this._element=n.element,this._offset=s.Point.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=we("div");const _=41,b=27,I=ye("svg",{display:"block",height:_*this._scale+"px",width:b*this._scale+"px",viewBox:`0 0 ${b} ${_}`},this._element),M=ye("radialGradient",{id:"shadowGradient"},ye("defs",{},I));ye("stop",{offset:"10%","stop-opacity":.4},M),ye("stop",{offset:"100%","stop-opacity":.05},M),ye("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},I),ye("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},I),ye("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},I),ye("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},I),this._offset=s.Point.convert(n&&n.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",_=>{_.preventDefault()}),this._element.addEventListener("mousedown",_=>{_.preventDefault()});const p=this._element.classList;for(const _ in Qs)p.remove(`mapboxgl-marker-anchor-${_}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(n){return n===this._map||(this.remove(),this._map=n,n.getCanvasContainer().appendChild(this._element),n.on("move",this._updateMoving),n.on("moveend",this._update),n.on("remove",this._clearFadeTimer),n._addMarker(this),this.setDraggable(this._draggable),this._update(),n.on("click",this._onMapClick)),this}remove(){const n=this._map;return n&&(n.off("click",this._onMapClick),n.off("move",this._updateMoving),n.off("moveend",this._update),n.off("mousedown",this._addDragHandler),n.off("touchstart",this._addDragHandler),n.off("mouseup",this._onUp),n.off("touchend",this._onUp),n.off("mousemove",this._onMove),n.off("touchmove",this._onMove),n.off("remove",this._clearFadeTimer),n._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(n){return this._lngLat=s.LngLat.convert(n),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(n){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),n){if(!("offset"in n.options)){const _=Math.sqrt(Math.pow(13.5,2)/2);n.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[_,-1*(24.6+_)],"bottom-right":[-_,-1*(24.6+_)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=n,n._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(n){const a=n.code,p=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&p!==32&&p!==13||this.togglePopup()}_onMapClick(n){const a=n.originalEvent.target,p=this._element;this._popup&&(a===p||p.contains(a))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const n=this._popup;return n?(n.isOpen()?(n.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(n.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const n=this._map,a=this._pos;if(!n||!a)return!1;const p=n.unproject(a),_=n.getFreeCameraOptions();if(!_.position)return!1;const b=_.position.toLngLat();return b.distanceTo(p)<.9*b.distanceTo(this._lngLat)}_evaluateOpacity(){const n=this._map;if(!n)return;const a=this._pos;if(!a||a.x<0||a.x>n.transform.width||a.y<0||a.y>n.transform.height)return void this._clearFadeTimer();const p=n.unproject(a);let _;n._showingGlobe()&&s.isLngLatBehindGlobe(n.transform,this._lngLat)?_=0:(_=1-n._queryFogOpacity(p),n.transform._terrainEnabled()&&n.getTerrain()&&this._behindTerrain()&&(_*=this._occludedOpacity)),this._element.style.opacity=`${_}`,this._element.style.pointerEvents=_>0?"auto":"none",this._popup&&this._popup._setOpacity(_),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const n=this._pos;if(!n||!this._map)return;const a=this._offset.mult(this._scale);this._element.style.transform=` translate(${n.x}px,${n.y}px) ${Qs[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${a.x}px,${a.y}px) `}_calculateXYTransform(){const n=this._pos,a=this._map,p=this.getPitchAlignment();if(!a||!n||p!=="map")return"";if(!a._showingGlobe()){const P=a.getPitch();return P?`rotateX(${P}deg)`:""}const _=s.radToDeg(s.globeTiltAtLngLat(a.transform,this._lngLat)),b=n.sub(s.globeCenterToScreenPoint(a.transform)),I=Math.abs(b.x)+Math.abs(b.y);if(I===0)return"";const M=_/I;return`rotateX(${-b.y*M}deg) rotateY(${b.x*M}deg)`}_calculateZTransform(){const n=this._pos,a=this._map;if(!a||!n)return"";let p=0;const _=this.getRotationAlignment();if(_==="map")if(a._showingGlobe()){const b=a.project(new s.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),I=a.project(new s.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(b);p=s.radToDeg(Math.atan2(I.y,I.x))-90}else p=-a.getBearing();else if(_==="horizon"){const b=s.smoothstep(4,6,a.getZoom()),I=s.globeCenterToScreenPoint(a.transform);I.y+=b*a.transform.height;const M=n.sub(I),P=s.radToDeg(Math.atan2(M.y,M.x));p=(P>90?P-270:P+90)*(1-b)}return p+=this._rotation,p?`rotateZ(${p}deg)`:""}_update(n){s.window.cancelAnimationFrame(this._updateFrameId);const a=this._map;a&&(a.transform.renderWorldCopies&&(this._lngLat=Ua(this._lngLat,this._pos,a.transform)),this._pos=a.project(this._lngLat),n===!0?this._updateFrameId=s.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),a._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(a._showingGlobe()||a.getTerrain()||a.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(n){return this._offset=s.Point.convert(n),this._update(),this}_onMove(n){const a=this._map;if(!a)return;const p=this._pointerdownPos,_=this._positionDelta;if(p&&_){if(!this._isDragging){const b=this._clickTolerance||a._clickTolerance;if(n.point.dist(p)=this._endTime)return this._end;const a=s.easeCubicInOut((n-this._startTime)/(this._endTime-this._startTime));return this._start*(1-a)+this._end*a}isEasing(n){return n>=this._startTime&&n<=this._endTime}jumpTo(n){this._startTime=-1/0,this._endTime=-1/0,this._start=n,this._end=n}easeTo(n,a,p){this._start=this.getValue(a),this._end=n,this._startTime=a,this._endTime=a+p}}const Of={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},zf={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},em={showCompass:!0,showZoom:!0,visualizePitch:!1};class tm{constructor(n,a,p=!1){this._clickTolerance=10,this.element=a,this.mouseRotate=new Ac({clickTolerance:n.dragRotate._mouseRotate._clickTolerance}),this.map=n,p&&(this.mousePitch=new Cc({clickTolerance:n.dragRotate._mousePitch._clickTolerance})),s.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),a.addEventListener("mousedown",this.mousedown),a.addEventListener("touchstart",this.touchstart,{passive:!1}),a.addEventListener("touchmove",this.touchmove),a.addEventListener("touchend",this.touchend),a.addEventListener("touchcancel",this.reset)}down(n,a){this.mouseRotate.mousedown(n,a),this.mousePitch&&this.mousePitch.mousedown(n,a),Mt()}move(n,a){const p=this.map,_=this.mouseRotate.mousemoveWindow(n,a),b=_&&_.bearingDelta;if(b&&p.setBearing(p.getBearing()+b),this.mousePitch){const I=this.mousePitch.mousemoveWindow(n,a),M=I&&I.pitchDelta;M&&p.setPitch(p.getPitch()+M)}}off(){const n=this.element;n.removeEventListener("mousedown",this.mousedown),n.removeEventListener("touchstart",this.touchstart,{passive:!1}),n.removeEventListener("touchmove",this.touchmove),n.removeEventListener("touchend",this.touchend),n.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Le(),s.window.removeEventListener("mousemove",this.mousemove),s.window.removeEventListener("mouseup",this.mouseup)}mousedown(n){this.down(s.extend({},n,{ctrlKey:!0,preventDefault:()=>n.preventDefault()}),ut(this.element,n)),s.window.addEventListener("mousemove",this.mousemove),s.window.addEventListener("mouseup",this.mouseup)}mousemove(n){this.move(n,ut(this.element,n))}mouseup(n){this.mouseRotate.mouseupWindow(n),this.mousePitch&&this.mousePitch.mouseupWindow(n),this.offTemp()}touchstart(n){n.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=yt(this.element,n.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>n.preventDefault()},this._startPos))}touchmove(n){n.targetTouches.length!==1?this.reset():(this._lastPos=yt(this.element,n.targetTouches)[0],this.move({preventDefault:()=>n.preventDefault()},this._lastPos))}touchend(n){n.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)h.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(h.minPitch!=null&&h.maxPitch!=null&&h.minPitch>h.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(h.minPitch!=null&&h.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(h.maxPitch!=null&&h.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(h.antialias&&s.isSafariWithAntialiasingBug(s.window)&&(h.antialias=!1,s.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new za(h.minZoom,h.maxZoom,h.minPitch,h.maxPitch,h.renderWorldCopies),h),this._interactive=h.interactive,this._minTileCacheSize=h.minTileCacheSize,this._maxTileCacheSize=h.maxTileCacheSize,this._failIfMajorPerformanceCaveat=h.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=h.preserveDrawingBuffer,this._antialias=h.antialias,this._useWebGL2=h.useWebGL2,this._trackResize=h.trackResize,this._bearingSnap=h.bearingSnap,this._refreshExpiredTiles=h.refreshExpiredTiles,this._fadeDuration=h.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=h.crossSourceCollisions,this._collectResourceTiming=h.collectResourceTiming,this._optimizeForTerrain=h.optimizeForTerrain,this._language=this._parseLanguage(h.language),this._worldview=h.worldview,this._renderTaskQueue=new Oc,this._domRenderTaskQueue=new Oc,this._controls=[],this._markers=[],this._popups=[],this._mapId=s.uniqueId(),this._locale=s.extend({},Of,h.locale),this._clickTolerance=h.clickTolerance,this._cooperativeGestures=h.cooperativeGestures,this._performanceMetricsCollection=h.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Nc(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new s.RequestManager(h.transformRequest,h.accessToken,h.testMode),this._silenceAuthErrors=!!h.testMode,typeof h.container=="string"){if(this._container=s.window.document.getElementById(h.container),!this._container)throw new Error(`Container '${h.container}' not found.`)}else{if(!(h.container instanceof s.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=h.container}if(this._container.childNodes.length>0&&s.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),h.maxBounds&&this.setMaxBounds(h.maxBounds),s.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),s.window!==void 0&&(s.window.addEventListener("online",this._onWindowOnline,!1),s.window.addEventListener("resize",this._onWindowResize,!1),s.window.addEventListener("orientationchange",this._onWindowResize,!1),s.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),s.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Io(this,h),this._localFontFamily=h.localFontFamily,this._localIdeographFontFamily=h.localIdeographFontFamily,h.style&&this.setStyle(h.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),h.projection&&this.setProjection(h.projection),this._hash=h.hash&&new Sc(typeof h.hash=="string"&&h.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:h.center,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch}),h.bounds&&(this.resize(),this.fitBounds(h.bounds,s.extend({},h.fitBoundsOptions,{duration:0})))),this.resize(),h.attributionControl&&this.addControl(new Ct({customAttribution:h.customAttribution})),this._logoControl=new Dc,this.addControl(this._logoControl,h.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new s.Event(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new s.Event(`${n.dataType}dataloading`,n))})}_getMapId(){return this._mapId}addControl(h,n){if(n===void 0&&(n=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const a=h.onAdd(this);this._controls.push(h);const p=this._controlPositions[n];return n.indexOf("bottom")!==-1?p.insertBefore(a,p.firstChild):p.appendChild(a),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(h);return n>-1&&this._controls.splice(n,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(h){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new s.Event("movestart",h)).fire(new s.Event("move",h)),this.fire(new s.Event("resize",h)),n&&this.fire(new s.Event("moveend",h)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(h){return this.transform.setMaxBounds(s.LngLatBounds.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h?this.setZoom(h):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h?this.setPitch(h):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(h){return h==="auto"?s.window.navigator.language:Array.isArray(h)?h.length===0?void 0:h.map(n=>n==="auto"?s.window.navigator.language:n):h}setLanguage(h){const n=this._parseLanguage(h);if(!this.style||n===this._language)return this;this._language=n,this.style._reloadSources();for(const a of this._controls)a._setLanguage&&a._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(h){return this.style&&h!==this._worldview?(this._worldview=h,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(h){return this._lazyInitEmptyStyle(),h?typeof h=="string"&&(h={name:h}):h=null,this._useExplicitProjection=!!h,this._prioritizeAndUpdateProjection(h,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const h=this.transform,n=h.projection.name;let a;n==="globe"&&h.zoom>=s.GLOBE_ZOOM_THRESHOLD_MAX?(h.setMercatorFromTransition(),a=!0):n==="mercator"&&h.zoom=s.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(h),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const a in this.style._sourceCaches)this.style._sourceCaches[a].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(h){return this.transform.locationPoint3D(s.LngLat.convert(h))}unproject(h){return this.transform.pointLocation3D(s.Point.convert(h))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(h,n,a){if(h==="mouseenter"||h==="mouseover"){let p=!1;const _=I=>{const M=n.filter(N=>this.getLayer(N)),P=M.length?this.queryRenderedFeatures(I.point,{layers:M}):[];P.length?p||(p=!0,a.call(this,new Gn(h,this,I.originalEvent,{features:P}))):p=!1},b=()=>{p=!1};return{layers:new Set(n),listener:a,delegates:{mousemove:_,mouseout:b}}}if(h==="mouseleave"||h==="mouseout"){let p=!1;const _=I=>{const M=n.filter(P=>this.getLayer(P));(M.length?this.queryRenderedFeatures(I.point,{layers:M}):[]).length?p=!0:p&&(p=!1,a.call(this,new Gn(h,this,I.originalEvent)))},b=I=>{p&&(p=!1,a.call(this,new Gn(h,this,I.originalEvent)))};return{layers:new Set(n),listener:a,delegates:{mousemove:_,mouseout:b}}}{const p=_=>{const b=n.filter(M=>this.getLayer(M)),I=b.length?this.queryRenderedFeatures(_.point,{layers:b}):[];I.length&&(_.features=I,a.call(this,_),delete _.features)};return{layers:new Set(n),listener:a,delegates:{[h]:p}}}}on(h,n,a){if(a===void 0)return super.on(h,n);Array.isArray(n)||(n=[n]);const p=this._createDelegatedListener(h,n,a);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(p);for(const _ in p.delegates)this.on(_,p.delegates[_]);return this}once(h,n,a){if(a===void 0)return super.once(h,n);Array.isArray(n)||(n=[n]);const p=this._createDelegatedListener(h,n,a);for(const _ in p.delegates)this.once(_,p.delegates[_]);return this}off(h,n,a){if(a===void 0)return super.off(h,n);n=new Set(Array.isArray(n)?n:[n]);const p=(b,I)=>{if(b.size!==I.size)return!1;for(const M of b)if(!I.has(M))return!1;return!0},_=this._delegatedListeners?this._delegatedListeners[h]:void 0;return _&&(b=>{for(let I=0;I{_?this.fire(new s.ErrorEvent(_)):b&&this._updateDiff(b,n)})}else typeof h=="object"&&this._updateDiff(h,n)}_updateDiff(h,n){try{this.style.setState(h)&&this._update(!0)}catch(a){s.warnOnce(`Unable to perform style diff: ${a.message||a.error||a}. Rebuilding the style from scratch.`),this._updateStyle(h,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(s.warnOnce("There is no style added to the map."),!1)}addSource(h,n){return this._lazyInitEmptyStyle(),this.style.addSource(h,n),this._update(!0)}isSourceLoaded(h){return!!this.style&&this.style._isSourceCacheLoaded(h)}areTilesLoaded(){const h=this.style&&this.style._sourceCaches;for(const n in h){const a=h[n]._tiles;for(const p in a){const _=a[p];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}addSourceType(h,n,a){this._lazyInitEmptyStyle(),this.style.addSourceType(h,n,a)}removeSource(h){return this.style.removeSource(h),this._updateTerrain(),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,n,{pixelRatio:a=1,sdf:p=!1,stretchX:_,stretchY:b,content:I}={}){if(this._lazyInitEmptyStyle(),n instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&n instanceof s.window.ImageBitmap){const{width:M,height:P,data:N}=s.exported.getImageData(n);this.style.addImage(h,{data:new s.RGBAImage({width:M,height:P},N),pixelRatio:a,stretchX:_,stretchY:b,content:I,sdf:p,version:0})}else if(n.width===void 0||n.height===void 0)this.fire(new s.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:M,height:P}=n,N=n;this.style.addImage(h,{data:new s.RGBAImage({width:M,height:P},new Uint8Array(N.data)),pixelRatio:a,stretchX:_,stretchY:b,content:I,sdf:p,version:0,userImage:N}),N.onAdd&&N.onAdd(this,h)}}updateImage(h,n){const a=this.style.getImage(h);if(!a)return void this.fire(new s.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const p=n instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&n instanceof s.window.ImageBitmap?s.exported.getImageData(n):n,{width:_,height:b}=p;_!==void 0&&b!==void 0?_===a.data.width&&b===a.data.height?(a.data.replace(p.data,!(n instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&n instanceof s.window.ImageBitmap)),this.style.updateImage(h,a)):this.fire(new s.ErrorEvent(new Error(`The width and height of the updated image (${_}, ${b}) must be that same as the previous version of the image (${a.data.width}, ${a.data.height})`))):this.fire(new s.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new s.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h,n){s.getImage(this._requestManager.transformRequest(h,s.ResourceType.Image),(a,p)=>{n(a,p instanceof s.window.HTMLImageElement?s.exported.getImageData(p):p)})}listImages(){return this.style.listImages()}addLayer(h,n){return this._lazyInitEmptyStyle(),this.style.addLayer(h,n),this._update(!0)}moveLayer(h,n){return this.style.moveLayer(h,n),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}setLayerZoomRange(h,n,a){return this.style.setLayerZoomRange(h,n,a),this._update(!0)}setFilter(h,n,a={}){return this.style.setFilter(h,n,a),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,n,a,p={}){return this.style.setPaintProperty(h,n,a,p),this._update(!0)}getPaintProperty(h,n){return this.style.getPaintProperty(h,n)}setLayoutProperty(h,n,a,p={}){return this.style.setLayoutProperty(h,n,a,p),this._update(!0)}getLayoutProperty(h,n){return this.style.getLayoutProperty(h,n)}setLight(h,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,n),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(h){return this._lazyInitEmptyStyle(),!h&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(h),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(h){return this._lazyInitEmptyStyle(),this.style.setFog(h),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(h){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s.LngLat.convert(h),this.transform):0}setFeatureState(h,n){return this.style.setFeatureState(h,n),this._update()}removeFeatureState(h,n){return this.style.removeFeatureState(h,n),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}_updateContainerDimensions(){if(!this._container)return;const h=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let a,p,_,b=this._container;for(;b&&(!p||!_);){const I=s.window.getComputedStyle(b).transform;I&&I!=="none"&&(a=I.match(/matrix.*\((.+)\)/)[1].split(", "),a[0]&&a[0]!=="0"&&a[0]!=="1"&&(p=a[0]),a[3]&&a[3]!=="0"&&a[3]!=="1"&&(_=a[3])),b=b.parentElement}this._containerWidth=p?Math.abs(h/p):h,this._containerHeight=_?Math.abs(n/_):n}_detectMissingCSS(){s.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&s.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const h=this._container;h.classList.add("mapboxgl-map"),(this._missingCSSCanary=we("div","mapboxgl-canary",h)).style.visibility="hidden",this._detectMissingCSS();const n=this._canvasContainer=we("div","mapboxgl-canvas-container",h);this._interactive&&n.classList.add("mapboxgl-interactive"),this._canvas=we("canvas","mapboxgl-canvas",n),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const a=this._controlContainer=we("div","mapboxgl-control-container",h),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(_=>{p[_]=we("div",`mapboxgl-ctrl-${_}`,a)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,n){const a=s.exported.devicePixelRatio||1;this._canvas.width=a*Math.ceil(h),this._canvas.height=a*Math.ceil(n),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${n}px`}_addMarker(h){this._markers.push(h)}_removeMarker(h){const n=this._markers.indexOf(h);n!==-1&&this._markers.splice(n,1)}_addPopup(h){this._popups.push(h)}_removePopup(h){const n=this._popups.indexOf(h);n!==-1&&this._popups.splice(n,1)}_setupPainter(){const h=s.extend({},oe.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),n=this._useWebGL2&&this._canvas.getContext("webgl2",h),a=n||this._canvas.getContext("webgl",h)||this._canvas.getContext("experimental-webgl",h);a?(this._useWebGL2&&!n&&s.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),s.storeAuthState(a,!0),this.painter=new Vn(a,this.transform,!!n),this.on("data",p=>{p.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),s.exported$1.testSupport(a)):this.fire(new s.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(h){h.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.Event("webglcontextlost",{originalEvent:h}))}_contextRestored(h){this._setupPainter(),this.resize(),this._update(),this.fire(new s.Event("webglcontextrestored",{originalEvent:h}))}_onMapScroll(h){if(h.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_requestDomTask(h){!this.loaded()||this.loaded()&&!this.isMoving()?h():this._domRenderTaskQueue.add(h)}_render(h){let n;const a=this.painter.context.extTimerQuery,p=s.exported.now();if(this.listens("gpu-timing-frame")&&(n=a.createQueryEXT(),a.beginQueryEXT(a.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],s.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],s.window.performance.now())),this._renderTaskQueue.run(h),this._domRenderTaskQueue.run(h),this._removed)return;this._updateProjectionTransition();const _=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const M=this.transform.zoom,P=this.transform.pitch,N=s.exported.now(),z=new s.EvaluationParameters(M,{now:N,fadeDuration:_,pitch:P,transition:this.style.getTransition()});this.style.update(z)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let b=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),b=this._updateAverageElevation(p),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):b=this._updateAverageElevation(p),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,_,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:_,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new s.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new s.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const M=s.exported.now()-p;a.endQueryEXT(a.TIME_ELAPSED_EXT,n),setTimeout(()=>{const P=a.getQueryObjectEXT(n,a.QUERY_RESULT_EXT)/1e6;a.deleteQueryEXT(n),this.fire(new s.Event("gpu-timing-frame",{cpuTime:M,gpuTime:P})),s.window.performance.mark("frame-gpu",{startTime:p,detail:{gpuTime:P}})},50)}if(this.listens("gpu-timing-layer")){const M=this.painter.collectGpuTimers();setTimeout(()=>{const P=this.painter.queryGpuTimers(M);this.fire(new s.Event("gpu-timing-layer",{layerTimes:P}))},50)}if(this.listens("gpu-timing-deferred-render")){const M=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const P=this.painter.queryGpuTimeDeferredRender(M);this.fire(new s.Event("gpu-timing-deferred-render",{gpuTime:P}))},50)}const I=this._sourcesDirty||this._styleDirty||this._placementDirty||b;if(I||this._repaint)this.triggerRepaint();else{const M=!this.isMoving()&&this.loaded();if(M&&(b=this._updateAverageElevation(p,!0)),b)this.triggerRepaint();else if(this._triggerFrame(!1),M&&(this.fire(new s.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const P=this._calculateSpeedIndex();this.fire(new s.Event("speedindexcompleted",{speedIndex:P})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||I||(this._fullyLoaded=!0,s.LivePerformanceUtils.mark(s.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&s.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(h){for(const n of this._markers)h&&!this.getRenderWorldCopies()&&(n._lngLat=n._lngLat.wrap()),n._update();for(const n of this._popups)!h||this.getRenderWorldCopies()||n._trackPointer||(n._lngLat=n._lngLat.wrap()),n._update()}_updateAverageElevation(h,n=!1){const a=p=>(this.transform.averageElevation=p,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&a(0);if((n||h-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(h)){const p=this.transform.averageElevation;let _=this.transform.sampleAverageElevation(),b=!1;this.transform.elevation&&(b=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(_)?_=0:this._averageElevationLastSampledAt=h;const I=Math.abs(p-_);if(I>1){if(this._isInitialLoad||b)return this._averageElevation.jumpTo(_),a(_);this._averageElevation.easeTo(_,h,300)}else if(I>1e-4)return this._averageElevation.jumpTo(_),a(_)}return!!this._averageElevation.isEasing(h)&&a(this._averageElevation.getValue(h))}_authenticate(){s.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,h=>{if(h&&(h.message===s.AUTH_ERR_MSG||h.status===401)){const n=this.painter.context.gl;s.storeAuthState(n,!1),this._logoControl instanceof Dc&&this._logoControl._updateLogo(),n&&n.clear(n.DEPTH_BUFFER_BIT|n.COLOR_BUFFER_BIT|n.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new s.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),s.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const h=this._isDragging();this.painter.updateTerrain(this.style,h)}_calculateSpeedIndex(){const h=this.painter.canvasCopy(),n=this.painter.getCanvasCopiesAndTimestamps();n.timeStamps.push(performance.now());const a=this.painter.context.gl,p=a.createFramebuffer();function _(b){a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,b,0);const I=new Uint8Array(a.drawingBufferWidth*a.drawingBufferHeight*4);return a.readPixels(0,0,a.drawingBufferWidth,a.drawingBufferHeight,a.RGBA,a.UNSIGNED_BYTE,I),I}return a.bindFramebuffer(a.FRAMEBUFFER,p),this._canvasPixelComparison(_(h),n.canvasCopies.map(_),n.timeStamps)}_canvasPixelComparison(h,n,a){let p=a[1]-a[0];const _=h.length/4;for(let b=0;b{const a=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,a&&this._render(n)}))}_preloadTiles(h){const n=this.style?Object.values(this.style._sourceCaches):[];return s.asyncAll(n,(a,p)=>a._preloadTiles(h,p),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(h){this._trackResize&&this.resize({originalEvent:h})._update()}_onVisibilityChange(){s.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(h){this._showTerrainWireframe!==h&&(this._showTerrainWireframe=h,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(h){this._speedIndexTiming!==h&&(this._speedIndexTiming=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(h){this._showTileAABBs!==h&&(this._showTileAABBs=h,h&&this._update())}_setCacheLimits(h,n){s.setCacheLimits(h,n)}get version(){return s.version}},NavigationControl:class{constructor(h){this.options=s.extend({},em,h),this._container=we("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",n=>n.preventDefault()),this.options.showZoom&&(s.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",n=>{this._map&&this._map.zoomIn({},{originalEvent:n})}),we("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",n=>{this._map&&this._map.zoomOut({},{originalEvent:n})}),we("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(s.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",n=>{const a=this._map;a&&(this.options.visualizePitch?a.resetNorthPitch({},{originalEvent:n}):a.resetNorth({},{originalEvent:n}))}),this._compassIcon=we("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const h=this._map;if(!h)return;const n=h.getZoom(),a=n===h.getMaxZoom(),p=n===h.getMinZoom();this._zoomInButton.disabled=a,this._zoomOutButton.disabled=p,this._zoomInButton.setAttribute("aria-disabled",a.toString()),this._zoomOutButton.setAttribute("aria-disabled",p.toString())}_rotateCompassArrow(){const h=this._map;if(!h)return;const n=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(h.transform.pitch*(Math.PI/180)),.5)}) rotateX(${h.transform.pitch}deg) rotateZ(${h.transform.angle*(180/Math.PI)}deg)`:`rotate(${h.transform.angle*(180/Math.PI)}deg)`;h._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=n)})}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),h.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&h.on("pitch",this._rotateCompassArrow),h.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new tm(h,this._compass,this.options.visualizePitch)),this._container}onRemove(){const h=this._map;h&&(this._container.remove(),this.options.showZoom&&h.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&h.off("pitch",this._rotateCompassArrow),h.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(h,n){const a=we("button",h,this._container);return a.type="button",a.addEventListener("click",n),a}_setButtonTitle(h,n){if(!this._map)return;const a=this._map._getUIString(`NavigationControl.${n}`);h.setAttribute("aria-label",a),h.firstElementChild&&h.firstElementChild.setAttribute("title",a)}},GeolocateControl:class extends s.Evented{constructor(h){super(),this.options=s.extend({geolocation:s.window.navigator.geolocation},Bc,h),s.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Na(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(h){return this._map=h,this._container=we("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(h){const n=(a=!!this.options.geolocation)=>{this._supportsGeolocation=a,h(a)};this._supportsGeolocation!==void 0?h(this._supportsGeolocation):s.window.navigator.permissions!==void 0?s.window.navigator.permissions.query({name:"geolocation"}).then(a=>n(a.state!=="denied")).catch(()=>n()):n()}_isOutOfMapMaxBounds(h){const n=this._map.getMaxBounds(),a=h.coords;return!!n&&(a.longituden.getEast()||a.latituden.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(h){if(this._map){if(this._isOutOfMapMaxBounds(h))return this._setErrorState(),this.fire(new s.Event("outofmaxbounds",h)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=h,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(h),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(h),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("geolocate",h)),this._finish()}}_updateCamera(h){const n=new s.LngLat(h.coords.longitude,h.coords.latitude),a=h.coords.accuracy,p=this._map.getBearing(),_=s.extend({bearing:p},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(a),_,{geolocateSource:!0})}_updateMarker(h){if(h){const n=new s.LngLat(h.coords.longitude,h.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=h.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const h=this._map.transform,n=s.mercatorZfromAltitude(1,h._center.lat)*h.worldSize,a=Math.ceil(2*this._accuracy*n);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(h){if(this._map){if(this.options.trackUserLocation)if(h.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(h.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("error",h)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(h){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=we("button","mapboxgl-ctrl-geolocate",this._container),we("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",h===!1){s.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=we("div","mapboxgl-user-location"),this._dotElement.appendChild(we("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(we("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new wt({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=we("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new wt({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new s.Event("trackuserlocationend")))})}}_onDeviceOrientation(h){this._userLocationDotMarker&&(h.webkitCompassHeading?this._heading=h.webkitCompassHeading:h.absolute===!0&&(this._heading=-1*h.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return s.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new s.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new s.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(h={maximumAge:6e5,timeout:0},this._noTimeout=!0):(h=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,h),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const h=()=>{s.window.addEventListener("ondeviceorientationabsolute"in s.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};s.window.DeviceMotionEvent!==void 0&&typeof s.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(n=>{n==="granted"&&h()}).catch(console.error):h()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),s.window.removeEventListener("deviceorientation",this._onDeviceOrientation),s.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ct,ScaleControl:class{constructor(h){this.options=s.extend({},Fc,h),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),s.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const h=this.options.maxWidth||100,n=this._map,a=n._containerHeight/2,p=n._containerWidth/2-h/2,_=n.unproject([p,a]),b=n.unproject([p+h,a]),I=_.distanceTo(b);if(this.options.unit==="imperial"){const M=3.2808*I;M>5280?this._setScale(h,M/5280,"mile"):this._setScale(h,M,"foot")}else this.options.unit==="nautical"?this._setScale(h,I/1852,"nautical-mile"):I>=1e3?this._setScale(h,I/1e3,"kilometer"):this._setScale(h,I,"meter")}_setScale(h,n,a){this._map._requestDomTask(()=>{const p=function(b){const I=Math.pow(10,`${Math.floor(b)}`.length-1);let M=b/I;return M=M>=10?10:M>=5?5:M>=3?3:M>=2?2:M>=1?1:function(P){const N=Math.pow(10,Math.ceil(-Math.log(P)/Math.LN10));return Math.round(P*N)/N}(M),I*M}(n),_=p/n;this._container.innerHTML=this._isNumberFormatSupported&&a!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:a}).format(p):`${p} ${Uc[a]}`,this._container.style.width=h*_+"px"})}onAdd(h){return this._map=h,this._language=h.getLanguage(),this._container=we("div","mapboxgl-ctrl mapboxgl-ctrl-scale",h.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(h){this._language=h,this._update()}setUnit(h){this.options.unit=h,this._update()}},FullscreenControl:class{constructor(h){this._fullscreen=!1,h&&h.container&&(h.container instanceof s.window.HTMLElement?this._container=h.container:s.warnOnce("Full screen control 'container' must be a DOM element.")),s.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in s.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in s.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=we("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",s.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,s.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!s.window.document.fullscreenEnabled&&!s.window.document.webkitFullscreenEnabled)}_setupUI(){const h=this._fullscreenButton=we("button","mapboxgl-ctrl-fullscreen",this._controlContainer);we("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),s.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",h)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(s.window.document.fullscreenElement||s.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?s.window.document.exitFullscreen?s.window.document.exitFullscreen():s.window.document.webkitCancelFullScreen&&s.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends s.Evented{constructor(h){super(),this.options=s.extend(Object.create(zc),h),s.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(h&&h.className?h.className.trim().split(/\s+/):[])}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&h.on("preclick",this._onClose),this.options.closeOnMove&&h.on("move",this._onClose),h.on("remove",this.remove),this._update(),h._addPopup(this),this._focusFirstElement(),this._trackPointer?(h.on("mousemove",this._onMouseEvent),h.on("mouseup",this._onMouseEvent),h._canvasContainer.classList.add("mapboxgl-track-pointer")):h.on("move",this._update),this.fire(new s.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const h=this._map;return h&&(h.off("move",this._update),h.off("move",this._onClose),h.off("preclick",this._onClose),h.off("click",this._onClose),h.off("remove",this.remove),h.off("mousemove",this._onMouseEvent),h.off("mouseup",this._onMouseEvent),h.off("drag",this._onMouseEvent),h._canvasContainer&&h._canvasContainer.classList.remove("mapboxgl-track-pointer"),h._removePopup(this),this._map=void 0),this.fire(new s.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(h){this._lngLat=s.LngLat.convert(h),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const h=this._map;return h&&(h.off("move",this._update),h.on("mousemove",this._onMouseEvent),h.on("drag",this._onMouseEvent),h._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(s.window.document.createTextNode(h))}setHTML(h){const n=s.window.document.createDocumentFragment(),a=s.window.document.createElement("body");let p;for(a.innerHTML=h;p=a.firstChild,p;)n.appendChild(p);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){let n=this._content;if(n)for(;n.hasChildNodes();)n.firstChild&&n.removeChild(n.firstChild);else n=this._content=we("div","mapboxgl-popup-content",this._container||void 0);if(n.appendChild(h),this.options.closeButton){const a=this._closeButton=we("button","mapboxgl-popup-close-button",n);a.type="button",a.setAttribute("aria-label","Close popup"),a.setAttribute("aria-hidden","true"),a.innerHTML="×",a.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(h){return this._classList.add(h),this._updateClassList(),this}removeClassName(h){return this._classList.delete(h),this._updateClassList(),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){let n;return this._classList.delete(h)?n=!1:(this._classList.add(h),n=!0),this._updateClassList(),n}_onMouseEvent(h){this._update(h.point)}_getAnchor(h){if(this.options.anchor)return this.options.anchor;const n=this._map,a=this._container,p=this._pos;if(!n||!a||!p)return"bottom";const _=a.offsetWidth,b=a.offsetHeight,I=p.x<_/2,M=p.x>n.transform.width-_/2;if(p.y+hn.transform.height-b){if(I)return"bottom-left";if(M)return"bottom-right"}return I?"left":M?"right":"bottom"}_updateClassList(){const h=this._container;if(!h)return;const n=[...this._classList];n.push("mapboxgl-popup"),this._anchor&&n.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&n.push("mapboxgl-popup-track-pointer"),h.className=n.join(" ")}_update(h){const n=this._map,a=this._content;if(!n||!this._lngLat&&!this._trackPointer||!a)return;let p=this._container;if(p||(p=this._container=we("div","mapboxgl-popup",n.getContainer()),this._tip=we("div","mapboxgl-popup-tip",p),p.appendChild(a)),this.options.maxWidth&&p.style.maxWidth!==this.options.maxWidth&&(p.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ua(this._lngLat,this._pos,n.transform)),!this._trackPointer||h){const _=this._pos=this._trackPointer&&h?h:n.project(this._lngLat),b=Df(this.options.offset),I=this._anchor=this._getAnchor(b.y),M=Df(this.options.offset,I),P=_.add(M).round();n._requestDomTask(()=>{this._container&&I&&(this._container.style.transform=`${Qs[I]} translate(${P.x}px,${P.y}px)`)})}if(!this._marker&&n._showingGlobe()){const _=s.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(_)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(Qd);h&&h.focus()}_onClose(){this.remove()}_setOpacity(h){this._container&&(this._container.style.opacity=`${h}`),this._content&&(this._content.style.pointerEvents=h?"auto":"none")}},Marker:wt,Style:mr,LngLat:s.LngLat,LngLatBounds:s.LngLatBounds,Point:s.Point,MercatorCoordinate:s.MercatorCoordinate,FreeCameraOptions:Xo,Evented:s.Evented,config:s.config,prewarm:function(){br().acquire(xr)},clearPrewarmedResources:function(){const h=pn;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(xr),pn=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return s.config.ACCESS_TOKEN},set accessToken(h){s.config.ACCESS_TOKEN=h},get baseApiUrl(){return s.config.API_URL},set baseApiUrl(h){s.config.API_URL=h},get workerCount(){return cn.workerCount},set workerCount(h){cn.workerCount=h},get maxParallelImageRequests(){return s.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(h){s.config.MAX_PARALLEL_IMAGE_REQUESTS=h},clearStorage(h){s.clearTileCache(h)},workerUrl:"",workerClass:null,setNow:s.exported.setNow,restoreNow:s.exported.restoreNow};return ja});var $=A;return $})})(fg);var k1=fg.exports;const Rr=bp(k1),pg=["17763402f97aa5d363379927f5ce70a6"][0],M1="pk.eyJ1IjoiYWVzcWUiLCJhIjoiY2lmNGVxYnNnMDNrenJya2xzbmQ4M281bCJ9.GfMJ8R2NX1dDcc9Hs2PO3A",dg={TDT_ZXY_IMG:{version:8,sources:{"raster-tiles":{type:"raster",tileSize:256,tiles:["https://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk="+pg]}},layers:[{id:"raster-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]},TDT_WMTS_IMG:{version:8,sources:{"raster-white":{type:"raster",tileSize:256,tiles:["http://t0.tianditu.com/vec_w/wmts?&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=tiles&tk="+pg]}},layers:[{id:"raster-white",type:"raster",source:"raster-white",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]},SM_WMTS_VEC_WHITE:{version:8,sources:{"raster-supermap-white":{type:"raster",tileSize:256,tiles:["http://172.160.1.206:8090/iserver/services/map-nmjtjt/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-white",type:"raster",source:"raster-supermap-white",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]},SM_WMTS_VEC_BLUE:{version:8,sources:{"raster-supermap-blue":{type:"raster",tileSize:256,tiles:["http://172.160.1.206:8090/iserver/services/map-nmjtjtblue/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-blue",type:"raster",source:"raster-supermap-blue",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}},mg={center:[116.39,39.93],zoom:10},A1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABXUlEQVQ4T6VTu0oDURCdc29cENTEgPoBaiHY+cLaSmyWLEkj1lZi7Rf4AyL4A2KzIZ2VnVhpIVipP6BCTKIgJLn3yC7ZZXfdqJCtdu7MnJkzcwaS+d5dtwStF6D1LEUmAjdEPmnMK415nm40WskURAZF0HHdNXGc+Sxo0qYxT0Xfv4MIB+DhH9qVyhYKhZnfkuNi/f5bsV6/CkDCDtquu/5X5Sxw0EnJ928RcFaOs50KMKYMYE+ApfCdfCB5Llo3k3G2271Ey/NWofVi7DCmLMAxgMkUd/JDyKMkSNAFmtXqjgamomBYeyjARu4syBsqdRL5DNlBq1arQUTHCdaeZavHwwu6UGo/shXZGx0gS0GsPQCwOYTCNZU6TVMYZYjk49A1CrArIssDtd2TvMhdYxDwY5X/kGMspFAno0o5BvG8lZSocjrJPaZkXHTOVqm5MZHxwNcT+VLWvuSd8zcITMKOoWKQ5QAAAABJRU5ErkJggg==",C1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABTklEQVQ4T6WTzS4EURCFv7o9G/EbCR4AC4mFxF9kjI2V2NuItZVYS/uJhHgBkXgB8QZWdsOKhMQKL4BEMMTC9C3pnumeO60HydzdrXPq1Kl7q4TUGdnSrtYyA16OXixtEWx4D8o8fuS4v9qWFzdFaheVgs+48ehPi7r3csDd2S6XIBrGqwIq0+vMeoae35JjLLA8FXc4DUUigYKvE39VTgtXnMiFhD13KnMuQS3dalgChqrxG7EcieHZ5b0KJ5L3dSznMRgDUbKwJ0J7nahSEmXNFQldSGFT5w10xGQLqwKTWW+hcG5g3+G+ycyGLojgJUHlMF09caeUjLCccC1fzQv8aEFZEWGqQQtFAwd1LTTziIFy2/gbhUVgOKomXIvlOPMbQzzt4j/TmAxShdzkKMcieZ9Rd6iynDRYpho1Xmfj0YelJUIMnzbgIWudvwHMF6CDKyS3NAAAAABJRU5ErkJggg==";class P1{constructor(d={}){if(this._container=d.container,!this._container)throw new Error("请传入地图容器ID,才能创建地图。");Rr.accessToken=d.accessToken||M1,this._style=d.styleURL||dg.SM_WMTS_VEC_WHITE,this.map2d=new Rr.Map({container:this._container,style:this._style,center:d.center||mg.center,zoom:d.zoom||mg.zoom}),this.addSymbolImgLoad()}addSymbolImgLoad(){this.map2d.loadImage(C1,(d,w)=>{if(d)throw d;this.map2d.addImage("point",w)}),this.map2d.loadImage(A1,(d,w)=>{if(d)throw d;this.map2d.addImage("pointSelect",w);var k=document.getElementsByClassName("mapboxgl-ctrl-bottom-left");k.length>0&&(k[0].style.display="none")})}addFeaturePoint(d,w,k={}){if(!this.map2d)throw new Error("未加载控件。");if(w.length!==0){var A={type:"FeatureCollection",features:w};this.map2d.addSource(d,{type:"geojson",data:A}),this.map2d.addLayer({id:d,type:k.type?k.type:"circle",source:d,paint:k.paint?k.paint:{"circle-color":"blue","circle-radius":6},layout:k.layout?k.layout:{visibility:"visible"}})}}addFeatureLine(d,w,k={}){if(!this.map2d)throw new Error("未加载控件。");if(w.length!==0){var A={type:"FeatureCollection",features:w};this.map2d.addSource(d,{type:"geojson",data:A}),this.map2d.addLayer({id:d,type:"line",source:d,paint:k.paint?k.paint:{"line-color":"#FFBD76","line-width":4},layout:k.layout?k.layout:{visibility:"visible"}})}}addFeatureFill(d,w,k={}){if(!this.map2d)throw new Error("未加载控件。");if(w.length!==0){var A={type:"FeatureCollection",features:w};this.map2d.addSource(d,{type:"geojson",data:A}),this.map2d.addLayer({id:d,type:"fill",source:d,paint:k.paint?k.paint:{"fill-color":"rgba(93,174,255,0.4)","fill-opacity":.7,"fill-outline-color":"rgba(93,174,255,0.8)"},layout:k.layout?k.layout:{visibility:"visible"}})}}addCluster(d,w,k={clusterStyle:["#51bbd6",100,"#f1f075",750,"#f28cb1"]}){if(!this.map2d)throw new Error("未加载控件。");if(w.length===0)return;var A={type:"FeatureCollection",features:w};this.map2d.addSource(d,{type:"geojson",data:A,cluster:!0,clusterMaxZoom:14,clusterRadius:50});let O=k.clusterStyle||["#51bbd6",100,"#f1f075",750,"#f28cb1"];this.map2d.addLayer({id:d+"-cluster",type:"circle",source:d,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],...O],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),this.map2d.addLayer({id:d+"-cluster-count",type:"symbol",source:d,filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Microsoft YaHei Regular"],"text-size":12}}),this.map2d.addLayer({id:d,type:"symbol",source:d,filter:["!",["has","point_count"]],layout:{"icon-image":"point","icon-allow-overlap":!0,visibility:"visible"}})}flyTo(d){this.map2d&&this.map2d.flyTo({center:d.center,zoom:d.zoom,essential:!0,duration:d.duration||2e3,curve:1})}removeLayer(d){this.map2d.getLayer(d)&&(this.map2d.removeLayer(d),this.map2d.removeSource(d))}removeClusterLayer(d){this.map2d.getLayer(d)&&(this.map2d.removeLayer(d),this.map2d.removeLayer(d+"-cluster-count"),this.map2d.removeLayer(d+"-cluster"),this.map2d.removeSource(d))}}const L1="0.1.0";class R1{constructor(d={}){return this.hmap=d.map,this._anchor=d.anchor||"bottom-right",this._zoomcontrol=new Rr.NavigationControl({showZoom:!0,showCompass:!1}),this}addTo(d){this.hmap||(this.hmap=d),this.hmap.map2d.addControl(this._zoomcontrol,this._anchor)}remove(){if(this.hmap||this._zoomcontrol)throw new Error("未加载缩放控件。");this.hmap.map2d.removeControl(this._zoomcontrol)}}class D1{constructor(d={}){return this.hmap=d.map,this._anchor=d.anchor||"bottom-right",this._fullscreen=new Rr.FullscreenControl({container:null}),this}addTo(d){this.hmap||(this.hmap=d),this._fullscreen.container=this.hmap.map2d.getContainer(),this.hmap.map2d.addControl(this._fullscreen,this._anchor)}remove(){if(this.hmap||this._fullscreen)throw new Error("未加载全屏控件。");this.hmap.map2d.removeControl(this._fullscreen)}}class O1{constructor(d={}){return this.hmap=d.map,this._anchor=d.anchor||"bottom-right",this._compass=new Rr.NavigationControl({showCompass:!0,showZoom:!1}),this}addTo(d){this.hmap||(this.hmap=d),this.hmap.map2d.addControl(this._compass,this._anchor)}remove(){if(this.hmap||this._compass)throw new Error("未加载指北针控件。");this.hmap.map2d.removeControl(this._compass)}}class z1{constructor(d={}){return this.hmap=d.map,this._anchor=d.anchor||"bottom-right",this._scaleline=new Rr.ScaleControl({unit:d.unit?d.unit:"metric"}),this}addTo(d){this.hmap||(this.hmap=d),this.hmap.map2d.addControl(this._scaleline,this._anchor)}remove(){if(this.hmap||this._scaleline)throw new Error("未加载比例尺控件。");this.hmap.map2d.removeControl(this._scaleline)}}class N1{constructor(d={closeButton:!1,closeOnClick:!1,className:"mapbox-popup",maxWidth:"350px"}){return this.hmap=d.map,this.popup=new Rr.Popup(d),this.popup}}var gg=Object.prototype.toString,_g=function(d){var w=gg.call(d),k=w==="[object Arguments]";return k||(k=w!=="[object Array]"&&d!==null&&typeof d=="object"&&typeof d.length=="number"&&d.length>=0&&gg.call(d.callee)==="[object Function]"),k},wp,yg;function B1(){if(yg)return wp;yg=1;var x;if(!Object.keys){var d=Object.prototype.hasOwnProperty,w=Object.prototype.toString,k=_g,A=Object.prototype.propertyIsEnumerable,O=!A.call({toString:null},"toString"),$=A.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Z=function(we){var ye=we.constructor;return ye&&ye.prototype===we},oe={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},pe=function(){if(typeof window>"u")return!1;for(var we in window)try{if(!oe["$"+we]&&d.call(window,we)&&window[we]!==null&&typeof window[we]=="object")try{Z(window[we])}catch{return!0}}catch{return!0}return!1}(),he=function(we){if(typeof window>"u"||!pe)return Z(we);try{return Z(we)}catch{return!1}};x=function(ye){var Ie=ye!==null&&typeof ye=="object",Tt=w.call(ye)==="[object Function]",gt=k(ye),Mt=Ie&&w.call(ye)==="[object String]",Le=[];if(!Ie&&!Tt&&!gt)throw new TypeError("Object.keys called on a non-object");var Qe=$&&Tt;if(Mt&&ye.length>0&&!d.call(ye,0))for(var Et=0;Et0)for(var ut=0;ut"u"||!Qn?Ai:Qn(Uint8Array),el={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Ai:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Ai:ArrayBuffer,"%ArrayIteratorPrototype%":Xl&&Qn?Qn([][Symbol.iterator]()):Ai,"%AsyncFromSyncIteratorPrototype%":Ai,"%AsyncFunction%":Wl,"%AsyncGenerator%":Wl,"%AsyncGeneratorFunction%":Wl,"%AsyncIteratorPrototype%":Wl,"%Atomics%":typeof Atomics>"u"?Ai:Atomics,"%BigInt%":typeof BigInt>"u"?Ai:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Ai:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Ai:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Ai:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":sb,"%eval%":eval,"%EvalError%":ab,"%Float32Array%":typeof Float32Array>"u"?Ai:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Ai:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Ai:FinalizationRegistry,"%Function%":Sg,"%GeneratorFunction%":Wl,"%Int8Array%":typeof Int8Array>"u"?Ai:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Ai:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Ai:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Xl&&Qn?Qn(Qn([][Symbol.iterator]())):Ai,"%JSON%":typeof JSON=="object"?JSON:Ai,"%Map%":typeof Map>"u"?Ai:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Xl||!Qn?Ai:Qn(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Ai:Promise,"%Proxy%":typeof Proxy>"u"?Ai:Proxy,"%RangeError%":lb,"%ReferenceError%":ub,"%Reflect%":typeof Reflect>"u"?Ai:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Ai:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Xl||!Qn?Ai:Qn(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Ai:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Xl&&Qn?Qn(""[Symbol.iterator]()):Ai,"%Symbol%":Xl?Symbol:Ai,"%SyntaxError%":ql,"%ThrowTypeError%":hb,"%TypedArray%":pb,"%TypeError%":Zl,"%Uint8Array%":typeof Uint8Array>"u"?Ai:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Ai:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Ai:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Ai:Uint32Array,"%URIError%":cb,"%WeakMap%":typeof WeakMap>"u"?Ai:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Ai:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Ai:WeakSet};if(Qn)try{null.error}catch(x){var db=Qn(Qn(x));el["%Error.prototype%"]=db}var mb=function x(d){var w;if(d==="%AsyncFunction%")w=kp("async function () {}");else if(d==="%GeneratorFunction%")w=kp("function* () {}");else if(d==="%AsyncGeneratorFunction%")w=kp("async function* () {}");else if(d==="%AsyncGenerator%"){var k=x("%AsyncGeneratorFunction%");k&&(w=k.prototype)}else if(d==="%AsyncIteratorPrototype%"){var A=x("%AsyncGenerator%");A&&Qn&&(w=Qn(A.prototype))}return el[d]=w,w},Ig={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ju=Ip,Sh=Tg,gb=Ju.call(Function.call,Array.prototype.concat),_b=Ju.call(Function.apply,Array.prototype.splice),kg=Ju.call(Function.call,String.prototype.replace),Ih=Ju.call(Function.call,String.prototype.slice),yb=Ju.call(Function.call,RegExp.prototype.exec),vb=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xb=/\\(\\)?/g,bb=function(d){var w=Ih(d,0,1),k=Ih(d,-1);if(w==="%"&&k!=="%")throw new ql("invalid intrinsic syntax, expected closing `%`");if(k==="%"&&w!=="%")throw new ql("invalid intrinsic syntax, expected opening `%`");var A=[];return kg(d,vb,function(O,$,s,Z){A[A.length]=s?kg(Z,xb,"$1"):$||O}),A},wb=function(d,w){var k=d,A;if(Sh(Ig,k)&&(A=Ig[k],k="%"+A[0]+"%"),Sh(el,k)){var O=el[k];if(O===Wl&&(O=mb(k)),typeof O>"u"&&!w)throw new Zl("intrinsic "+d+" exists, but is not available. Please file an issue!");return{alias:A,name:k,value:O}}throw new ql("intrinsic "+d+" does not exist!")},ss=function(d,w){if(typeof d!="string"||d.length===0)throw new Zl("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof w!="boolean")throw new Zl('"allowMissing" argument must be a boolean');if(yb(/^%?[^%]*%?$/,d)===null)throw new ql("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var k=bb(d),A=k.length>0?k[0]:"",O=wb("%"+A+"%",w),$=O.name,s=O.value,Z=!1,oe=O.alias;oe&&(A=oe[0],_b(k,gb([0,1],oe)));for(var pe=1,he=!0;pe=k.length){var Tt=Qa(s,we);he=!!Tt,he&&"get"in Tt&&!("originalValue"in Tt.get)?s=Tt.get:s=s[we]}else he=Sh(s,we),s=s[we];he&&!Z&&(el[$]=s)}}return s},Ap,Mg;function Cp(){if(Mg)return Ap;Mg=1;var x=ss,d=x("%Object.defineProperty%",!0)||!1;if(d)try{d({},"a",{value:1})}catch{d=!1}return Ap=d,Ap}var Eb=ss,kh=Eb("%Object.getOwnPropertyDescriptor%",!0);if(kh)try{kh([],"length")}catch{kh=null}var Pp=kh,Ag=Cp(),Tb=bg,Yl=ua,Cg=Pp,Lp=function(d,w,k){if(!d||typeof d!="object"&&typeof d!="function")throw new Yl("`obj` must be an object or a function`");if(typeof w!="string"&&typeof w!="symbol")throw new Yl("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Yl("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Yl("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Yl("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Yl("`loose`, if provided, must be a boolean");var A=arguments.length>3?arguments[3]:null,O=arguments.length>4?arguments[4]:null,$=arguments.length>5?arguments[5]:null,s=arguments.length>6?arguments[6]:!1,Z=!!Cg&&Cg(d,w);if(Ag)Ag(d,w,{configurable:$===null&&Z?Z.configurable:!$,enumerable:A===null&&Z?Z.enumerable:!A,value:k,writable:O===null&&Z?Z.writable:!O});else if(s||!A&&!O&&!$)d[w]=k;else throw new Tb("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Rp=Cp(),Pg=function(){return!!Rp};Pg.hasArrayLengthDefineBug=function(){if(!Rp)return null;try{return Rp([],"length",{value:1}).length!==1}catch{return!0}};var Dp=Pg,Sb=Ep,Ib=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",kb=Object.prototype.toString,Mb=Array.prototype.concat,Lg=Lp,Ab=function(x){return typeof x=="function"&&kb.call(x)==="[object Function]"},Rg=Dp(),Cb=function(x,d,w,k){if(d in x){if(k===!0){if(x[d]===w)return}else if(!Ab(k)||!k())return}Rg?Lg(x,d,w,!0):Lg(x,d,w)},Dg=function(x,d){var w=arguments.length>2?arguments[2]:{},k=Sb(d);Ib&&(k=Mb.call(k,Object.getOwnPropertySymbols(d)));for(var A=0;A4294967295||Rb(w)!==w)throw new Bg("`length` must be a positive 32-bit integer");var k=arguments.length>2&&!!arguments[2],A=!0,O=!0;if("length"in d&&Ng){var $=Ng(d,"length");$&&!$.configurable&&(A=!1),$&&!$.writable&&(O=!1)}return(A||O||!k)&&(Lb?zg(d,"length",w,!0,!0):zg(d,"length",w)),d};(function(x){var d=Ip,w=ss,k=Db,A=ua,O=w("%Function.prototype.apply%"),$=w("%Function.prototype.call%"),s=w("%Reflect.apply%",!0)||d.call($,O),Z=Cp(),oe=w("%Math.max%");x.exports=function(we){if(typeof we!="function")throw new A("a function is required");var ye=s(d,$,arguments);return k(ye,1+oe(0,we.length-(arguments.length-1)),!0)};var pe=function(){return s(d,O,arguments)};Z?Z(x.exports,"apply",{value:pe}):x.exports.apply=pe})(Og);var Hl=Og.exports,Fg=ss,Ug=Hl,Ob=Ug(Fg("String.prototype.indexOf")),go=function(d,w){var k=Fg(d,!!w);return typeof k=="function"&&Ob(d,".prototype.")>-1?Ug(k):k},zb=Ep,jg=Th(),Vg=go,Gg=Object,Nb=Vg("Array.prototype.push"),$g=Vg("Object.prototype.propertyIsEnumerable"),Bb=jg?Object.getOwnPropertySymbols:null,qg=function(d,w){if(d==null)throw new TypeError("target must be an object");var k=Gg(d);if(arguments.length===1)return k;for(var A=1;A2&&!!arguments[2];return(!k||Qb)&&(Jb?Yg(d,"name",w,!0,!0):Yg(d,"name",w)),d},iw=tw,nw=ua,rw=Object,Hg=iw(function(){if(this==null||this!==rw(this))throw new nw("RegExp.prototype.flags getter called on non-object");var d="";return this.hasIndices&&(d+="d"),this.global&&(d+="g"),this.ignoreCase&&(d+="i"),this.multiline&&(d+="m"),this.dotAll&&(d+="s"),this.unicode&&(d+="u"),this.unicodeSets&&(d+="v"),this.sticky&&(d+="y"),d},"get flags",!0),ow=Hg,sw=tl.supportsDescriptors,aw=Object.getOwnPropertyDescriptor,Kg=function(){if(sw&&/a/mig.flags==="gim"){var d=aw(RegExp.prototype,"flags");if(d&&typeof d.get=="function"&&typeof RegExp.prototype.dotAll=="boolean"&&typeof RegExp.prototype.hasIndices=="boolean"){var w="",k={};if(Object.defineProperty(k,"hasIndices",{get:function(){w+="d"}}),Object.defineProperty(k,"sticky",{get:function(){w+="y"}}),w==="dy")return d.get}}return ow},lw=tl.supportsDescriptors,uw=Kg,cw=Object.getOwnPropertyDescriptor,hw=Object.defineProperty,fw=TypeError,Jg=Object.getPrototypeOf,pw=/a/,dw=function(){if(!lw||!Jg)throw new fw("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var d=uw(),w=Jg(pw),k=cw(w,"flags");return(!k||k.get!==d)&&hw(w,"flags",{configurable:!0,enumerable:!1,get:d}),d},mw=tl,gw=Hl,_w=Hg,Qg=Kg,yw=dw,e_=gw(Qg());mw(e_,{getPolyfill:Qg,implementation:_w,shim:yw});var vw=e_,Mh={exports:{}},xw=Th,il=function(){return xw()&&!!Symbol.toStringTag},bw=il(),ww=go,zp=ww("Object.prototype.toString"),Ah=function(d){return bw&&d&&typeof d=="object"&&Symbol.toStringTag in d?!1:zp(d)==="[object Arguments]"},t_=function(d){return Ah(d)?!0:d!==null&&typeof d=="object"&&typeof d.length=="number"&&d.length>=0&&zp(d)!=="[object Array]"&&zp(d.callee)==="[object Function]"},Ew=function(){return Ah(arguments)}();Ah.isLegacyArguments=t_;var i_=Ew?Ah:t_;const Tw=I1(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Np=typeof Map=="function"&&Map.prototype,Bp=Object.getOwnPropertyDescriptor&&Np?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ch=Np&&Bp&&typeof Bp.get=="function"?Bp.get:null,n_=Np&&Map.prototype.forEach,Fp=typeof Set=="function"&&Set.prototype,Up=Object.getOwnPropertyDescriptor&&Fp?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ph=Fp&&Up&&typeof Up.get=="function"?Up.get:null,r_=Fp&&Set.prototype.forEach,Sw=typeof WeakMap=="function"&&WeakMap.prototype,tc=Sw?WeakMap.prototype.has:null,Iw=typeof WeakSet=="function"&&WeakSet.prototype,ic=Iw?WeakSet.prototype.has:null,kw=typeof WeakRef=="function"&&WeakRef.prototype,o_=kw?WeakRef.prototype.deref:null,Mw=Boolean.prototype.valueOf,Aw=Object.prototype.toString,Cw=Function.prototype.toString,Pw=String.prototype.match,jp=String.prototype.slice,ca=String.prototype.replace,Lw=String.prototype.toUpperCase,s_=String.prototype.toLowerCase,a_=RegExp.prototype.test,l_=Array.prototype.concat,as=Array.prototype.join,Rw=Array.prototype.slice,u_=Math.floor,Vp=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Gp=Object.getOwnPropertySymbols,$p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Kl=typeof Symbol=="function"&&typeof Symbol.iterator=="object",_r=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Kl||!0)?Symbol.toStringTag:null,c_=Object.prototype.propertyIsEnumerable,h_=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(x){return x.__proto__}:null);function f_(x,d){if(x===1/0||x===-1/0||x!==x||x&&x>-1e3&&x<1e3||a_.call(/e/,d))return d;var w=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof x=="number"){var k=x<0?-u_(-x):u_(x);if(k!==x){var A=String(k),O=jp.call(d,A.length+1);return ca.call(A,w,"$&_")+"."+ca.call(ca.call(O,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ca.call(d,w,"$&_")}var qp=Tw,p_=qp.custom,d_=__(p_)?p_:null,Dw=function x(d,w,k,A){var O=w||{};if(ha(O,"quoteStyle")&&O.quoteStyle!=="single"&&O.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(ha(O,"maxStringLength")&&(typeof O.maxStringLength=="number"?O.maxStringLength<0&&O.maxStringLength!==1/0:O.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var $=ha(O,"customInspect")?O.customInspect:!0;if(typeof $!="boolean"&&$!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(ha(O,"indent")&&O.indent!==null&&O.indent!==" "&&!(parseInt(O.indent,10)===O.indent&&O.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(ha(O,"numericSeparator")&&typeof O.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=O.numericSeparator;if(typeof d>"u")return"undefined";if(d===null)return"null";if(typeof d=="boolean")return d?"true":"false";if(typeof d=="string")return v_(d,O);if(typeof d=="number"){if(d===0)return 1/0/d>0?"0":"-0";var Z=String(d);return s?f_(d,Z):Z}if(typeof d=="bigint"){var oe=String(d)+"n";return s?f_(d,oe):oe}var pe=typeof O.depth>"u"?5:O.depth;if(typeof k>"u"&&(k=0),k>=pe&&pe>0&&typeof d=="object")return Zp(d)?"[Array]":"[Object]";var he=Jw(O,k);if(typeof A>"u")A=[];else if(y_(A,d)>=0)return"[Circular]";function we(Xt,bt,Jt){if(bt&&(A=Rw.call(A),A.push(bt)),Jt){var Bt={depth:O.depth};return ha(O,"quoteStyle")&&(Bt.quoteStyle=O.quoteStyle),x(Xt,Bt,k+1,A)}return x(Xt,O,k+1,A)}if(typeof d=="function"&&!g_(d)){var ye=Gw(d),Ie=Lh(d,we);return"[Function"+(ye?": "+ye:" (anonymous)")+"]"+(Ie.length>0?" { "+as.call(Ie,", ")+" }":"")}if(__(d)){var Tt=Kl?ca.call(String(d),/^(Symbol\(.*\))_[^)]*$/,"$1"):$p.call(d);return typeof d=="object"&&!Kl?nc(Tt):Tt}if(Yw(d)){for(var gt="<"+s_.call(String(d.nodeName)),Mt=d.attributes||[],Le=0;Le",gt}if(Zp(d)){if(d.length===0)return"[]";var Qe=Lh(d,we);return he&&!Kw(Qe)?"["+Wp(Qe,he)+"]":"[ "+as.call(Qe,", ")+" ]"}if(Nw(d)){var Et=Lh(d,we);return!("cause"in Error.prototype)&&"cause"in d&&!c_.call(d,"cause")?"{ ["+String(d)+"] "+as.call(l_.call("[cause]: "+we(d.cause),Et),", ")+" }":Et.length===0?"["+String(d)+"]":"{ ["+String(d)+"] "+as.call(Et,", ")+" }"}if(typeof d=="object"&&$){if(d_&&typeof d[d_]=="function"&&qp)return qp(d,{depth:pe-k});if($!=="symbol"&&typeof d.inspect=="function")return d.inspect()}if($w(d)){var ut=[];return n_&&n_.call(d,function(Xt,bt){ut.push(we(bt,d,!0)+" => "+we(Xt,d))}),x_("Map",Ch.call(d),ut,he)}if(Xw(d)){var yt=[];return r_&&r_.call(d,function(Xt){yt.push(we(Xt,d))}),x_("Set",Ph.call(d),yt,he)}if(qw(d))return Xp("WeakMap");if(Ww(d))return Xp("WeakSet");if(Zw(d))return Xp("WeakRef");if(Fw(d))return nc(we(Number(d)));if(jw(d))return nc(we(Vp.call(d)));if(Uw(d))return nc(Mw.call(d));if(Bw(d))return nc(we(String(d)));if(typeof window<"u"&&d===window)return"{ [object Window] }";if(typeof globalThis<"u"&&d===globalThis||typeof $l<"u"&&d===$l)return"{ [object globalThis] }";if(!zw(d)&&!g_(d)){var _t=Lh(d,we),It=h_?h_(d)===Object.prototype:d instanceof Object||d.constructor===Object,Oe=d instanceof Object?"":"null prototype",gi=!It&&_r&&Object(d)===d&&_r in d?jp.call(fa(d),8,-1):Oe?"Object":"",ti=It||typeof d.constructor!="function"?"":d.constructor.name?d.constructor.name+" ":"",At=ti+(gi||Oe?"["+as.call(l_.call([],gi||[],Oe||[]),": ")+"] ":"");return _t.length===0?At+"{}":he?At+"{"+Wp(_t,he)+"}":At+"{ "+as.call(_t,", ")+" }"}return String(d)};function m_(x,d,w){var k=(w.quoteStyle||d)==="double"?'"':"'";return k+x+k}function Ow(x){return ca.call(String(x),/"/g,""")}function Zp(x){return fa(x)==="[object Array]"&&(!_r||!(typeof x=="object"&&_r in x))}function zw(x){return fa(x)==="[object Date]"&&(!_r||!(typeof x=="object"&&_r in x))}function g_(x){return fa(x)==="[object RegExp]"&&(!_r||!(typeof x=="object"&&_r in x))}function Nw(x){return fa(x)==="[object Error]"&&(!_r||!(typeof x=="object"&&_r in x))}function Bw(x){return fa(x)==="[object String]"&&(!_r||!(typeof x=="object"&&_r in x))}function Fw(x){return fa(x)==="[object Number]"&&(!_r||!(typeof x=="object"&&_r in x))}function Uw(x){return fa(x)==="[object Boolean]"&&(!_r||!(typeof x=="object"&&_r in x))}function __(x){if(Kl)return x&&typeof x=="object"&&x instanceof Symbol;if(typeof x=="symbol")return!0;if(!x||typeof x!="object"||!$p)return!1;try{return $p.call(x),!0}catch{}return!1}function jw(x){if(!x||typeof x!="object"||!Vp)return!1;try{return Vp.call(x),!0}catch{}return!1}var Vw=Object.prototype.hasOwnProperty||function(x){return x in this};function ha(x,d){return Vw.call(x,d)}function fa(x){return Aw.call(x)}function Gw(x){if(x.name)return x.name;var d=Pw.call(Cw.call(x),/^function\s*([\w$]+)/);return d?d[1]:null}function y_(x,d){if(x.indexOf)return x.indexOf(d);for(var w=0,k=x.length;wd.maxStringLength){var w=x.length-d.maxStringLength,k="... "+w+" more character"+(w>1?"s":"");return v_(jp.call(x,0,d.maxStringLength),d)+k}var A=ca.call(ca.call(x,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Hw);return m_(A,"single",d)}function Hw(x){var d=x.charCodeAt(0),w={8:"b",9:"t",10:"n",12:"f",13:"r"}[d];return w?"\\"+w:"\\x"+(d<16?"0":"")+Lw.call(d.toString(16))}function nc(x){return"Object("+x+")"}function Xp(x){return x+" { ? }"}function x_(x,d,w,k){var A=k?Wp(w,k):as.call(w,", ");return x+" ("+d+") {"+A+"}"}function Kw(x){for(var d=0;d=0)return!1;return!0}function Jw(x,d){var w;if(x.indent===" ")w=" ";else if(typeof x.indent=="number"&&x.indent>0)w=as.call(Array(x.indent+1)," ");else return null;return{base:w,prev:as.call(Array(d+1),w)}}function Wp(x,d){if(x.length===0)return"";var w=` `+d.prev+d.base;return w+as.call(x,","+w)+` `+d.prev}function Lh(x,d){var w=Zp(x),k=[];if(w){k.length=x.length;for(var A=0;A=k)return w+1;var A=z_(d,w);if(A<55296||A>56319)return w+1;var O=z_(d,w+1);return O<56320||O>57343?w+1:w+2},ed=function(d){var w=0;return{next:function(){var A=w>=d.length,O;return A||(O=d[w],w+=1),{done:A,value:O}}}},N_=function(d,w){if(wE(d)||L_(d))return ed(d);if(EE(d)){var k=0;return{next:function(){var O=kE(d,k),$=IE(d,k,O);return k=O,{done:O>d.length,value:$}}}}if(w&&typeof d["_es6-shim iterator_"]<"u")return d["_es6-shim iterator_"]()};if(!TE&&!SE)Mh.exports=function(d){if(d!=null)return N_(d,!0)};else{var ME=M_,AE=P_,B_=Lo("Map.prototype.forEach",!0),F_=Lo("Set.prototype.forEach",!0);if(typeof process>"u"||!process.versions||!process.versions.node)var U_=Lo("Map.prototype.iterator",!0),j_=Lo("Set.prototype.iterator",!0);var V_=Lo("Map.prototype.@@iterator",!0)||Lo("Map.prototype._es6-shim iterator_",!0),G_=Lo("Set.prototype.@@iterator",!0)||Lo("Set.prototype._es6-shim iterator_",!0),CE=function(d){if(ME(d)){if(U_)return R_(U_(d));if(V_)return V_(d);if(B_){var w=[];return B_(d,function(A,O){O_(w,[O,A])}),ed(w)}}if(AE(d)){if(j_)return R_(j_(d));if(G_)return G_(d);if(F_){var k=[];return F_(d,function(A){O_(k,A)}),ed(k)}}};Mh.exports=function(d){return CE(d)||N_(d)}}}var PE=Mh.exports,$_=function(x){return x!==x},q_=function(d,w){return d===0&&w===0?1/d===1/w:!!(d===w||$_(d)&&$_(w))},LE=q_,Z_=function(){return typeof Object.is=="function"?Object.is:LE},RE=Z_,DE=tl,OE=function(){var d=RE();return DE(Object,{is:d},{is:function(){return Object.is!==d}}),d},zE=tl,NE=Hl,BE=q_,X_=Z_,FE=OE,W_=NE(X_(),Object);zE(W_,{getPolyfill:X_,implementation:BE,shim:FE});var UE=W_,jE=Hl,Y_=go,VE=ss,td=VE("%ArrayBuffer%",!0),Nh=Y_("ArrayBuffer.prototype.byteLength",!0),GE=Y_("Object.prototype.toString"),H_=!!td&&!Nh&&new td(0).slice,K_=!!H_&&jE(H_),J_=Nh||K_?function(d){if(!d||typeof d!="object")return!1;try{return Nh?Nh(d):K_(d,0),!0}catch{return!1}}:td?function(d){return GE(d)==="[object ArrayBuffer]"}:function(d){return!1},$E=Date.prototype.getDay,qE=function(d){try{return $E.call(d),!0}catch{return!1}},ZE=Object.prototype.toString,XE="[object Date]",WE=il(),YE=function(d){return typeof d!="object"||d===null?!1:WE?qE(d):ZE.call(d)===XE},id=go,Q_=il(),ey,ty,nd,rd;if(Q_){ey=id("Object.prototype.hasOwnProperty"),ty=id("RegExp.prototype.exec"),nd={};var od=function(){throw nd};rd={toString:od,valueOf:od},typeof Symbol.toPrimitive=="symbol"&&(rd[Symbol.toPrimitive]=od)}var HE=id("Object.prototype.toString"),KE=Object.getOwnPropertyDescriptor,JE="[object RegExp]",QE=Q_?function(d){if(!d||typeof d!="object")return!1;var w=KE(d,"lastIndex"),k=w&&ey(w,"value");if(!k)return!1;try{ty(d,rd)}catch(A){return A===nd}}:function(d){return!d||typeof d!="object"&&typeof d!="function"?!1:HE(d)===JE},eT=go,iy=eT("SharedArrayBuffer.prototype.byteLength",!0),tT=iy?function(d){if(!d||typeof d!="object")return!1;try{return iy(d),!0}catch{return!1}}:function(d){return!1},iT=Number.prototype.toString,nT=function(d){try{return iT.call(d),!0}catch{return!1}},rT=Object.prototype.toString,oT="[object Number]",sT=il(),aT=function(d){return typeof d=="number"?!0:typeof d!="object"?!1:sT?nT(d):rT.call(d)===oT},ny=go,lT=ny("Boolean.prototype.toString"),uT=ny("Object.prototype.toString"),cT=function(d){try{return lT(d),!0}catch{return!1}},hT="[object Boolean]",fT=il(),pT=function(d){return typeof d=="boolean"?!0:d===null||typeof d!="object"?!1:fT&&Symbol.toStringTag in d?cT(d):uT(d)===hT},sd={exports:{}},dT=Object.prototype.toString,mT=Tp();if(mT){var gT=Symbol.prototype.toString,_T=/^Symbol\(.*\)$/,yT=function(d){return typeof d.valueOf()!="symbol"?!1:_T.test(gT.call(d))};sd.exports=function(d){if(typeof d=="symbol")return!0;if(dT.call(d)!=="[object Symbol]")return!1;try{return yT(d)}catch{return!1}}}else sd.exports=function(d){return!1};var vT=sd.exports,ad={exports:{}},ry=typeof BigInt<"u"&&BigInt,xT=function(){return typeof ry=="function"&&typeof BigInt=="function"&&typeof ry(42)=="bigint"&&typeof BigInt(42)=="bigint"},bT=xT();if(bT){var wT=BigInt.prototype.valueOf,ET=function(d){try{return wT.call(d),!0}catch{}return!1};ad.exports=function(d){return d===null||typeof d>"u"||typeof d=="boolean"||typeof d=="string"||typeof d=="number"||typeof d=="symbol"||typeof d=="function"?!1:typeof d=="bigint"?!0:ET(d)}}else ad.exports=function(d){return!1};var TT=ad.exports,ST=S_,IT=aT,kT=pT,MT=vT,AT=TT,CT=function(d){if(d==null||typeof d!="object"&&typeof d!="function")return null;if(ST(d))return"String";if(IT(d))return"Number";if(kT(d))return"Boolean";if(MT(d))return"Symbol";if(AT(d))return"BigInt"},Bh=typeof WeakMap=="function"&&WeakMap.prototype?WeakMap:null,oy=typeof WeakSet=="function"&&WeakSet.prototype?WeakSet:null,Fh;Bh||(Fh=function(d){return!1});var ld=Bh?Bh.prototype.has:null,ud=oy?oy.prototype.has:null;!Fh&&!ld&&(Fh=function(d){return!1});var PT=Fh||function(d){if(!d||typeof d!="object")return!1;try{if(ld.call(d,ld),ud)try{ud.call(d,ud)}catch{return!0}return d instanceof Bh}catch{}return!1},cd={exports:{}},LT=ss,sy=go,RT=LT("%WeakSet%",!0),hd=sy("WeakSet.prototype.has",!0);if(hd){var fd=sy("WeakMap.prototype.has",!0);cd.exports=function(d){if(!d||typeof d!="object")return!1;try{if(hd(d,hd),fd)try{fd(d,fd)}catch{return!0}return d instanceof RT}catch{}return!1}}else cd.exports=function(d){return!1};var DT=cd.exports,OT=M_,zT=P_,NT=PT,BT=DT,FT=function(d){if(d&&typeof d=="object"){if(OT(d))return"Map";if(zT(d))return"Set";if(NT(d))return"WeakMap";if(BT(d))return"WeakSet"}return!1},ay=Function.prototype.toString,Ql=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,pd,Uh;if(typeof Ql=="function"&&typeof Object.defineProperty=="function")try{pd=Object.defineProperty({},"length",{get:function(){throw Uh}}),Uh={},Ql(function(){throw 42},null,pd)}catch(x){x!==Uh&&(Ql=null)}else Ql=null;var UT=/^\s*class\b/,dd=function(d){try{var w=ay.call(d);return UT.test(w)}catch{return!1}},md=function(d){try{return dd(d)?!1:(ay.call(d),!0)}catch{return!1}},jh=Object.prototype.toString,jT="[object Object]",VT="[object Function]",GT="[object GeneratorFunction]",$T="[object HTMLAllCollection]",qT="[object HTML document.all class]",ZT="[object HTMLCollection]",XT=typeof Symbol=="function"&&!!Symbol.toStringTag,WT=!(0 in[,]),gd=function(){return!1};if(typeof document=="object"){var YT=document.all;jh.call(YT)===jh.call(document.all)&&(gd=function(d){if((WT||!d)&&(typeof d>"u"||typeof d=="object"))try{var w=jh.call(d);return(w===$T||w===qT||w===ZT||w===jT)&&d("")==null}catch{}return!1})}var HT=Ql?function(d){if(gd(d))return!0;if(!d||typeof d!="function"&&typeof d!="object")return!1;try{Ql(d,null,pd)}catch(w){if(w!==Uh)return!1}return!dd(d)&&md(d)}:function(d){if(gd(d))return!0;if(!d||typeof d!="function"&&typeof d!="object")return!1;if(XT)return md(d);if(dd(d))return!1;var w=jh.call(d);return w!==VT&&w!==GT&&!/^\[object HTML/.test(w)?!1:md(d)},KT=HT,JT=Object.prototype.toString,ly=Object.prototype.hasOwnProperty,QT=function(d,w,k){for(var A=0,O=d.length;A=3&&(A=k),JT.call(d)==="[object Array]"?QT(d,w,A):typeof d=="string"?eS(d,w,A):tS(d,w,A)},nS=iS,rS=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],_d=rS,oS=typeof globalThis>"u"?$l:globalThis,sS=function(){for(var d=[],w=0;w<_d.length;w++)typeof oS[_d[w]]=="function"&&(d[d.length]=_d[w]);return d},Vh=nS,aS=sS,uy=Hl,yd=go,Gh=Pp,lS=yd("Object.prototype.toString"),cy=il(),hy=typeof globalThis>"u"?$l:globalThis,vd=aS(),xd=yd("String.prototype.slice"),bd=Object.getPrototypeOf,uS=yd("Array.prototype.indexOf",!0)||function(d,w){for(var k=0;k-1?w:w!=="Object"?!1:hS(d)}return Gh?cS(d):null},pS=go,fy=pS("ArrayBuffer.prototype.byteLength",!0),dS=J_,mS=function(d){return dS(d)?fy?fy(d):d.byteLength:NaN},py=Yb,ls=go,dy=vw,gS=ss,eu=PE,_S=w_,my=UE,gy=i_,_y=T_,yy=J_,vy=YE,xy=QE,by=tT,wy=Ep,Ey=CT,Ty=FT,Sy=fS,Iy=mS,ky=ls("SharedArrayBuffer.prototype.byteLength",!0),My=ls("Date.prototype.getTime"),wd=Object.getPrototypeOf,Ay=ls("Object.prototype.toString"),qh=gS("%Set%",!0),Ed=ls("Map.prototype.has",!0),Zh=ls("Map.prototype.get",!0),Cy=ls("Map.prototype.size",!0),Xh=ls("Set.prototype.add",!0),Py=ls("Set.prototype.delete",!0),Wh=ls("Set.prototype.has",!0),Yh=ls("Set.prototype.size",!0);function Ly(x,d,w,k){for(var A=eu(x),O;(O=A.next())&&!O.done;)if(Ro(d,O.value,w,k))return Py(x,O.value),!0;return!1}function Ry(x){if(typeof x>"u")return null;if(typeof x!="object")return typeof x=="symbol"?!1:typeof x=="string"||typeof x=="number"?+x==+x:!0}function yS(x,d,w,k,A,O){var $=Ry(w);if($!=null)return $;var s=Zh(d,$),Z=py({},A,{strict:!1});return typeof s>"u"&&!Ed(d,$)||!Ro(k,s,Z,O)?!1:!Ed(x,$)&&Ro(k,s,Z,O)}function vS(x,d,w){var k=Ry(w);return k??(Wh(d,k)&&!Wh(x,k))}function Dy(x,d,w,k,A,O){for(var $=eu(x),s,Z;(s=$.next())&&!s.done;)if(Z=s.value,Ro(w,Z,A,O)&&Ro(k,Zh(d,Z),A,O))return Py(x,Z),!0;return!1}function Ro(x,d,w,k){var A=w||{};if(A.strict?my(x,d):x===d)return!0;var O=Ey(x),$=Ey(d);if(O!==$)return!1;if(!x||!d||typeof x!="object"&&typeof d!="object")return A.strict?my(x,d):x==d;var s=k.has(x),Z=k.has(d),oe;if(s&&Z){if(k.get(x)===k.get(d))return!0}else oe={};return s||k.set(x,oe),Z||k.set(d,oe),wS(x,d,A,k)}function Oy(x){return!x||typeof x!="object"||typeof x.length!="number"||typeof x.copy!="function"||typeof x.slice!="function"||x.length>0&&typeof x[0]!="number"?!1:!!(x.constructor&&x.constructor.isBuffer&&x.constructor.isBuffer(x))}function xS(x,d,w,k){if(Yh(x)!==Yh(d))return!1;for(var A=eu(x),O=eu(d),$,s,Z;($=A.next())&&!$.done;)if($.value&&typeof $.value=="object")Z||(Z=new qh),Xh(Z,$.value);else if(!Wh(d,$.value)){if(w.strict||!vS(x,d,$.value))return!1;Z||(Z=new qh),Xh(Z,$.value)}if(Z){for(;(s=O.next())&&!s.done;)if(s.value&&typeof s.value=="object"){if(!Ly(Z,s.value,w.strict,k))return!1}else if(!w.strict&&!Wh(x,s.value)&&!Ly(Z,s.value,w.strict,k))return!1;return Yh(Z)===0}return!0}function bS(x,d,w,k){if(Cy(x)!==Cy(d))return!1;for(var A=eu(x),O=eu(d),$,s,Z,oe,pe,he;($=A.next())&&!$.done;)if(oe=$.value[0],pe=$.value[1],oe&&typeof oe=="object")Z||(Z=new qh),Xh(Z,oe);else if(he=Zh(d,oe),typeof he>"u"&&!Ed(d,oe)||!Ro(pe,he,w,k)){if(w.strict||!yS(x,d,oe,pe,w,k))return!1;Z||(Z=new qh),Xh(Z,oe)}if(Z){for(;(s=O.next())&&!s.done;)if(oe=s.value[0],he=s.value[1],oe&&typeof oe=="object"){if(!Dy(Z,x,oe,he,w,k))return!1}else if(!w.strict&&(!x.has(oe)||!Ro(Zh(x,oe),he,w,k))&&!Dy(Z,x,oe,he,py({},w,{strict:!1}),k))return!1;return Yh(Z)===0}return!0}function wS(x,d,w,k){var A,O;if(typeof x!=typeof d||x==null||d==null||Ay(x)!==Ay(d)||gy(x)!==gy(d))return!1;var $=_y(x),s=_y(d);if($!==s)return!1;var Z=x instanceof Error,oe=d instanceof Error;if(Z!==oe||(Z||oe)&&(x.name!==d.name||x.message!==d.message))return!1;var pe=xy(x),he=xy(d);if(pe!==he||(pe||he)&&(x.source!==d.source||dy(x)!==dy(d)))return!1;var we=vy(x),ye=vy(d);if(we!==ye||(we||ye)&&My(x)!==My(d)||w.strict&&wd&&wd(x)!==wd(d))return!1;var Ie=Sy(x),Tt=Sy(d);if(Ie!==Tt)return!1;if(Ie||Tt){if(x.length!==d.length)return!1;for(A=0;A=0;A--)if(yt[A]!=_t[A])return!1;for(A=yt.length-1;A>=0;A--)if(O=yt[A],!Ro(x[O],d[O],w,k))return!1;var It=Ty(x),Oe=Ty(d);return It!==Oe?!1:It==="Set"||Oe==="Set"?xS(x,d,w,k):It==="Map"?bS(x,d,w,k):!0}var ES=function(d,w,k){return Ro(d,w,k,_S())};const TS=bp(ES);var SS=Object.defineProperty,en=(x,d)=>SS(x,"name",{value:d,configurable:!0}),IS=class{constructor(d){this.direction=!1,this.compareProperties=!0;var w,k,A;this.precision=10**-((w=d==null?void 0:d.precision)!=null?w:17),this.direction=(k=d==null?void 0:d.direction)!=null?k:!1,this.compareProperties=(A=d==null?void 0:d.compareProperties)!=null?A:!0}compare(d,w){if(d.type!==w.type||!sc(d,w))return!1;switch(d.type){case"Point":return this.compareCoord(d.coordinates,w.coordinates);case"LineString":return this.compareLine(d.coordinates,w.coordinates);case"Polygon":return this.comparePolygon(d,w);case"GeometryCollection":return this.compareGeometryCollection(d,w);case"Feature":return this.compareFeature(d,w);case"FeatureCollection":return this.compareFeatureCollection(d,w);default:if(d.type.startsWith("Multi")){const k=Td(d),A=Td(w);return k.every(O=>A.some($=>this.compare(O,$)))}}return!1}compareCoord(d,w){return d.length===w.length&&d.every((k,A)=>Math.abs(k-w[A])=0&&(k=[].concat(d.slice(A,d.length),d.slice(1,A+1))),k}comparePath(d,w){return d.every((k,A)=>this.compareCoord(k,w[A]))}comparePolygon(d,w){if(this.compareLine(d.coordinates[0],w.coordinates[0],1,!0)){const k=d.coordinates.slice(1,d.coordinates.length),A=w.coordinates.slice(1,w.coordinates.length);return k.every(O=>A.some($=>this.compareLine(O,$,1,!0)))}return!1}compareGeometryCollection(d,w){return sc(d.geometries,w.geometries)&&this.compareBBox(d,w)&&d.geometries.every((k,A)=>this.compare(k,w.geometries[A]))}compareFeature(d,w){return d.id===w.id&&(this.compareProperties?TS(d.properties,w.properties):!0)&&this.compareBBox(d,w)&&this.compare(d.geometry,w.geometry)}compareFeatureCollection(d,w){return sc(d.features,w.features)&&this.compareBBox(d,w)&&d.features.every((k,A)=>this.compare(k,w.features[A]))}compareBBox(d,w){return!d.bbox&&!w.bbox||(d.bbox&&w.bbox?this.compareCoord(d.bbox,w.bbox):!1)}};en(IS,"GeojsonEquality");function sc(x,d){return x.coordinates?x.coordinates.length===d.coordinates.length:x.length===d.length}en(sc,"sameLength");function Td(x){return x.coordinates.map(d=>({type:x.type.replace("Multi",""),coordinates:d}))}en(Td,"explode");var yr=63710088e-1,zy={centimeters:yr*100,centimetres:yr*100,degrees:360/(2*Math.PI),feet:yr*3.28084,inches:yr*39.37,kilometers:yr/1e3,kilometres:yr/1e3,meters:yr,metres:yr,miles:yr/1609.344,millimeters:yr*1e3,millimetres:yr*1e3,nauticalmiles:yr/1852,radians:1,yards:yr*1.0936},Ny={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function _o(x,d,w={}){const k={type:"Feature"};return(w.id===0||w.id)&&(k.id=w.id),w.bbox&&(k.bbox=w.bbox),k.properties=d||{},k.geometry=x,k}en(_o,"feature");function kS(x,d,w={}){switch(x){case"Point":return Xn(d).geometry;case"LineString":return us(d).geometry;case"Polygon":return nl(d).geometry;case"MultiPoint":return Fy(d).geometry;case"MultiLineString":return By(d).geometry;case"MultiPolygon":return Sd(d).geometry;default:throw new Error(x+" is invalid")}}en(kS,"geometry");function Xn(x,d,w={}){if(!x)throw new Error("coordinates is required");if(!Array.isArray(x))throw new Error("coordinates must be an Array");if(x.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tu(x[0])||!tu(x[1]))throw new Error("coordinates must contain numbers");return _o({type:"Point",coordinates:x},d,w)}en(Xn,"point");function MS(x,d,w={}){return yo(x.map(k=>Xn(k,d)),w)}en(MS,"points");function nl(x,d,w={}){for(const A of x){if(A.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(A[A.length-1].length!==A[0].length)throw new Error("First and last Position are not equivalent.");for(let O=0;Onl(k,d)),w)}en(AS,"polygons");function us(x,d,w={}){if(x.length<2)throw new Error("coordinates must be an array of two or more positions");return _o({type:"LineString",coordinates:x},d,w)}en(us,"lineString");function CS(x,d,w={}){return yo(x.map(k=>us(k,d)),w)}en(CS,"lineStrings");function yo(x,d={}){const w={type:"FeatureCollection"};return d.id&&(w.id=d.id),d.bbox&&(w.bbox=d.bbox),w.features=x,w}en(yo,"featureCollection");function By(x,d,w={}){return _o({type:"MultiLineString",coordinates:x},d,w)}en(By,"multiLineString");function Fy(x,d,w={}){return _o({type:"MultiPoint",coordinates:x},d,w)}en(Fy,"multiPoint");function Sd(x,d,w={}){return _o({type:"MultiPolygon",coordinates:x},d,w)}en(Sd,"multiPolygon");function PS(x,d,w={}){return _o({type:"GeometryCollection",geometries:x},d,w)}en(PS,"geometryCollection");function LS(x,d=0){if(d&&!(d>=0))throw new Error("precision must be a positive number");const w=Math.pow(10,d||0);return Math.round(x*w)/w}en(LS,"round");function Hh(x,d="kilometers"){const w=zy[d];if(!w)throw new Error(d+" units is invalid");return x*w}en(Hh,"radiansToLength");function ac(x,d="kilometers"){const w=zy[d];if(!w)throw new Error(d+" units is invalid");return x/w}en(ac,"lengthToRadians");function RS(x,d){return Kh(ac(x,d))}en(RS,"lengthToDegrees");function DS(x){let d=x%360;return d<0&&(d+=360),d}en(DS,"bearingToAzimuth");function Kh(x){return x%(2*Math.PI)*180/Math.PI}en(Kh,"radiansToDegrees");function pa(x){return x%360*Math.PI/180}en(pa,"degreesToRadians");function OS(x,d="kilometers",w="kilometers"){if(!(x>=0))throw new Error("length must be a positive number");return Hh(ac(x,d),w)}en(OS,"convertLength");function zS(x,d="meters",w="kilometers"){if(!(x>=0))throw new Error("area must be a positive number");const k=Ny[d];if(!k)throw new Error("invalid original units");const A=Ny[w];if(!A)throw new Error("invalid final units");return x/k*A}en(zS,"convertArea");function tu(x){return!isNaN(x)&&x!==null&&!Array.isArray(x)}en(tu,"isNumber");function Id(x){return x!==null&&typeof x=="object"&&!Array.isArray(x)}en(Id,"isObject");function NS(x){if(!x)throw new Error("bbox is required");if(!Array.isArray(x))throw new Error("bbox must be an Array");if(x.length!==4&&x.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");x.forEach(d=>{if(!tu(d))throw new Error("bbox must only contain numbers")})}en(NS,"validateBBox");function BS(x){if(!x)throw new Error("id is required");if(["string","number"].indexOf(typeof x)===-1)throw new Error("id must be a number or a string")}en(BS,"validateId");var FS=Object.defineProperty,da=(x,d)=>FS(x,"name",{value:d,configurable:!0});function lc(x){if(!x)throw new Error("coord is required");if(!Array.isArray(x)){if(x.type==="Feature"&&x.geometry!==null&&x.geometry.type==="Point")return[...x.geometry.coordinates];if(x.type==="Point")return[...x.coordinates]}if(Array.isArray(x)&&x.length>=2&&!Array.isArray(x[0])&&!Array.isArray(x[1]))return[...x];throw new Error("coord must be GeoJSON Point or an Array of numbers")}da(lc,"getCoord");function rl(x){if(Array.isArray(x))return x;if(x.type==="Feature"){if(x.geometry!==null)return x.geometry.coordinates}else if(x.coordinates)return x.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}da(rl,"getCoords");function Uy(x){if(x.length>1&&tu(x[0])&&tu(x[1]))return!0;if(Array.isArray(x[0])&&x[0].length)return Uy(x[0]);throw new Error("coordinates must only contain numbers")}da(Uy,"containsNumber");function US(x,d,w){if(!d||!w)throw new Error("type and name required");if(!x||x.type!==d)throw new Error("Invalid input to "+w+": must be a "+d+", given "+x.type)}da(US,"geojsonType");function jS(x,d,w){if(!x)throw new Error("No feature passed");if(!w)throw new Error(".featureOf() requires a name");if(!x||x.type!=="Feature"||!x.geometry)throw new Error("Invalid input to "+w+", Feature with geometry required");if(!x.geometry||x.geometry.type!==d)throw new Error("Invalid input to "+w+": must be a "+d+", given "+x.geometry.type)}da(jS,"featureOf");function VS(x,d,w){if(!x)throw new Error("No featureCollection passed");if(!w)throw new Error(".collectionOf() requires a name");if(!x||x.type!=="FeatureCollection")throw new Error("Invalid input to "+w+", FeatureCollection required");for(const k of x.features){if(!k||k.type!=="Feature"||!k.geometry)throw new Error("Invalid input to "+w+", Feature with geometry required");if(!k.geometry||k.geometry.type!==d)throw new Error("Invalid input to "+w+": must be a "+d+", given "+k.geometry.type)}}da(VS,"collectionOf");function jy(x){return x.type==="Feature"?x.geometry:x}da(jy,"getGeom");function Vy(x,d){return x.type==="FeatureCollection"?"FeatureCollection":x.type==="GeometryCollection"?"GeometryCollection":x.type==="Feature"&&x.geometry!==null?x.geometry.type:x.type}da(Vy,"getType");var GS=Object.defineProperty,$S=(x,d)=>GS(x,"name",{value:d,configurable:!0});function Gy(x,d,w,k={}){const A=lc(x),O=pa(A[0]),$=pa(A[1]),s=pa(w),Z=ac(d,k.units),oe=Math.asin(Math.sin($)*Math.cos(Z)+Math.cos($)*Math.sin(Z)*Math.cos(s)),pe=O+Math.atan2(Math.sin(s)*Math.sin(Z)*Math.cos($),Math.cos(Z)-Math.sin($)*Math.sin(oe)),he=Kh(pe),we=Kh(oe);return Xn([he,we],k.properties)}$S(Gy,"destination");var qS=Object.defineProperty,ZS=(x,d)=>qS(x,"name",{value:d,configurable:!0});function Jh(x,d,w={}){var k=lc(x),A=lc(d),O=pa(A[1]-k[1]),$=pa(A[0]-k[0]),s=pa(k[1]),Z=pa(A[1]),oe=Math.pow(Math.sin(O/2),2)+Math.pow(Math.sin($/2),2)*Math.cos(s)*Math.cos(Z);return Hh(2*Math.atan2(Math.sqrt(oe),Math.sqrt(1-oe)),w.units)}ZS(Jh,"distance");var XS=Object.defineProperty,fr=(x,d)=>XS(x,"name",{value:d,configurable:!0});function Ds(x,d,w){if(x!==null)for(var k,A,O,$,s,Z,oe,pe=0,he=0,we,ye=x.type,Ie=ye==="FeatureCollection",Tt=ye==="Feature",gt=Ie?x.features.length:1,Mt=0;MtZ||Ie>oe||Tt>pe){s=he,Z=k,oe=Ie,pe=Tt,O=0;return}var gt=us([s,he],w.properties);if(d(gt,k,A,Tt,O)===!1)return!1;O++,s=he})===!1)return!1}}})}fr(Zy,"segmentEach");function QS(x,d,w){var k=w,A=!1;return Zy(x,function(O,$,s,Z,oe){A===!1&&w===void 0?k=O:k=d(k,O,$,s,Z,oe),A=!0}),k}fr(QS,"segmentReduce");function Xy(x,d){if(!x)throw new Error("geojson is required");Os(x,function(w,k,A){if(w.geometry!==null){var O=w.geometry.type,$=w.geometry.coordinates;switch(O){case"LineString":if(d(w,k,A,0,0)===!1)return!1;break;case"Polygon":for(var s=0;s<$.length;s++)if(d(us($[s],w.properties),k,A,s)===!1)return!1;break}}})}fr(Xy,"lineEach");function e2(x,d,w){var k=w;return Xy(x,function(A,O,$,s){O===0&&w===void 0?k=A:k=d(k,A,O,$,s)}),k}fr(e2,"lineReduce");function t2(x,d){if(d=d||{},!Id(d))throw new Error("options is invalid");var w=d.featureIndex||0,k=d.multiFeatureIndex||0,A=d.geometryIndex||0,O=d.segmentIndex||0,$=d.properties,s;switch(x.type){case"FeatureCollection":w<0&&(w=x.features.length+w),$=$||x.features[w].properties,s=x.features[w].geometry;break;case"Feature":$=$||x.properties,s=x.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":s=x;break;default:throw new Error("geojson is invalid")}if(s===null)return null;var Z=s.coordinates;switch(s.type){case"Point":case"MultiPoint":return null;case"LineString":return O<0&&(O=Z.length+O-1),us([Z[O],Z[O+1]],$,d);case"Polygon":return A<0&&(A=Z.length+A),O<0&&(O=Z[A].length+O-1),us([Z[A][O],Z[A][O+1]],$,d);case"MultiLineString":return k<0&&(k=Z.length+k),O<0&&(O=Z[k].length+O-1),us([Z[k][O],Z[k][O+1]],$,d);case"MultiPolygon":return k<0&&(k=Z.length+k),A<0&&(A=Z[k].length+A),O<0&&(O=Z[k][A].length-O-1),us([Z[k][A][O],Z[k][A][O+1]],$,d)}throw new Error("geojson is invalid")}fr(t2,"findSegment");function i2(x,d){if(d=d||{},!Id(d))throw new Error("options is invalid");var w=d.featureIndex||0,k=d.multiFeatureIndex||0,A=d.geometryIndex||0,O=d.coordIndex||0,$=d.properties,s;switch(x.type){case"FeatureCollection":w<0&&(w=x.features.length+w),$=$||x.features[w].properties,s=x.features[w].geometry;break;case"Feature":$=$||x.properties,s=x.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":s=x;break;default:throw new Error("geojson is invalid")}if(s===null)return null;var Z=s.coordinates;switch(s.type){case"Point":return Xn(Z,$,d);case"MultiPoint":return k<0&&(k=Z.length+k),Xn(Z[k],$,d);case"LineString":return O<0&&(O=Z.length+O),Xn(Z[O],$,d);case"Polygon":return A<0&&(A=Z.length+A),O<0&&(O=Z[A].length+O),Xn(Z[A][O],$,d);case"MultiLineString":return k<0&&(k=Z.length+k),O<0&&(O=Z[k].length+O),Xn(Z[k][O],$,d);case"MultiPolygon":return k<0&&(k=Z.length+k),A<0&&(A=Z[k].length+A),O<0&&(O=Z[k][A].length-O),Xn(Z[k][A][O],$,d)}throw new Error("geojson is invalid")}fr(i2,"findPoint");var n2=Object.defineProperty,Qh=(x,d)=>n2(x,"name",{value:d,configurable:!0});function kd(x){return qy(x,(d,w)=>d+Wy(w),0)}Qh(kd,"area");function Wy(x){let d=0,w;switch(x.type){case"Polygon":return Md(x.coordinates);case"MultiPolygon":for(w=0;w0){d+=Math.abs(Cd(x[0]));for(let w=1;w=d?(k+2)%d:k+2],s=A[0]*Ad,Z=O[1]*Ad,oe=$[0]*Ad;w+=(oe-s)*Math.sin(Z),k++}return w*r2}Qh(Cd,"ringArea");var o2=Object.defineProperty,s2=(x,d)=>o2(x,"name",{value:d,configurable:!0});function Yy(x,d={}){if(x.bbox!=null&&d.recompute!==!0)return x.bbox;const w=[1/0,1/0,-1/0,-1/0];return Ds(x,k=>{w[0]>k[0]&&(w[0]=k[0]),w[1]>k[1]&&(w[1]=k[1]),w[2]0&&oe>0){pe=he,s=oe,$=pe[0]-we;continue}if(Z=he[0]-x[0],oe>0&&s<=0){if(O=$*oe-Z*s,O>0)A=A+1;else if(O===0)return 0}else if(s>0&&oe<=0){if(O=$*oe-Z*s,O<0)A=A+1;else if(O===0)return 0}else if(oe===0&&s<0){if(O=$*oe-Z*s,O===0)return 0}else if(s===0&&oe<0){if(O=$*oe-Z*s,O===0)return 0}else if(s===0&&oe===0){if(Z<=0&&$>=0)return 0;if($<=0&&Z>=0)return 0}pe=he,s=oe,$=Z}}return A%2!==0}var l2=Object.defineProperty,Hy=(x,d)=>l2(x,"name",{value:d,configurable:!0});function Ky(x,d,w={}){if(!x)throw new Error("point is required");if(!d)throw new Error("polygon is required");const k=lc(x),A=jy(d),O=A.type,$=d.bbox;let s=A.coordinates;if($&&Jy(k,$)===!1)return!1;O==="Polygon"&&(s=[s]);let Z=!1;for(var oe=0;oe=x[0]&&d[3]>=x[1]}Hy(Jy,"inBBox");class Qy{constructor(d=[],w=u2){if(this.data=d,this.length=this.data.length,this.compare=w,this.length>0)for(let k=(this.length>>1)-1;k>=0;k--)this._down(k)}push(d){this.data.push(d),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const d=this.data[0],w=this.data.pop();return this.length--,this.length>0&&(this.data[0]=w,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:w,compare:k}=this,A=w[d];for(;d>0;){const O=d-1>>1,$=w[O];if(k(A,$)>=0)break;w[d]=$,d=O}w[d]=A}_down(d){const{data:w,compare:k}=this,A=this.length>>1,O=w[d];for(;d=0)break;w[d]=s,d=$}w[d]=O}}function u2(x,d){return xd?1:0}function ev(x,d){return x.p.x>d.p.x?1:x.p.xd.p.y?1:-1:1}function c2(x,d){return x.rightSweepEvent.p.x>d.rightSweepEvent.p.x?1:x.rightSweepEvent.p.x0?(pe.isLeftEndpoint=!0,oe.isLeftEndpoint=!1):(oe.isLeftEndpoint=!0,pe.isLeftEndpoint=!1),d.push(oe),d.push(pe),$=s,nf=nf+1}}ef=ef+1}class f2{constructor(d){this.leftSweepEvent=d,this.rightSweepEvent=d.otherEvent}}function p2(x,d){if(x===null||d===null||x.leftSweepEvent.ringId===d.leftSweepEvent.ringId&&(x.rightSweepEvent.isSamePoint(d.leftSweepEvent)||x.rightSweepEvent.isSamePoint(d.leftSweepEvent)||x.rightSweepEvent.isSamePoint(d.rightSweepEvent)||x.leftSweepEvent.isSamePoint(d.leftSweepEvent)||x.leftSweepEvent.isSamePoint(d.rightSweepEvent)))return!1;const w=x.leftSweepEvent.p.x,k=x.leftSweepEvent.p.y,A=x.rightSweepEvent.p.x,O=x.rightSweepEvent.p.y,$=d.leftSweepEvent.p.x,s=d.leftSweepEvent.p.y,Z=d.rightSweepEvent.p.x,oe=d.rightSweepEvent.p.y,pe=(oe-s)*(A-w)-(Z-$)*(O-k),he=(Z-$)*(k-s)-(oe-s)*(w-$),we=(A-w)*(k-s)-(O-k)*(w-$);if(pe===0)return!1;const ye=he/pe,Ie=we/pe;if(ye>=0&&ye<=1&&Ie>=0&&Ie<=1){const Tt=w+ye*(A-w),gt=k+ye*(O-k);return[Tt,gt]}return!1}function d2(x,d){d=d||!1;const w=[],k=new Qy([],c2);for(;x.length;){const A=x.pop();if(A.isLeftEndpoint){const O=new f2(A);for(let $=0;$g2(x,"name",{value:d,configurable:!0});function nv(x,d={}){var w=typeof d=="object"?d.mutate:d;if(!x)throw new Error("geojson is required");var k=Vy(x),A=[];switch(k){case"LineString":A=of(x,k);break;case"MultiLineString":case"Polygon":rl(x).forEach(function($){A.push(of($,k))});break;case"MultiPolygon":rl(x).forEach(function($){var s=[];$.forEach(function(Z){s.push(of(Z,k))}),A.push(s)});break;case"Point":return x;case"MultiPoint":var O={};rl(x).forEach(function($){var s=$.join("-");Object.prototype.hasOwnProperty.call(O,s)||(A.push($),O[s]=!0)});break;default:throw new Error(k+" geometry not supported")}return x.coordinates?w===!0?(x.coordinates=A,x):{type:k,coordinates:A}:w===!0?(x.geometry.coordinates=A,x):_o({type:k,coordinates:A},x.properties,{bbox:x.bbox,id:x.id})}rf(nv,"cleanCoords");function of(x,d){var w=rl(x);if(w.length===2&&!Pd(w[0],w[1]))return w;var k=[],A=w.length-1,O=k.length;k.push(w[0]);for(var $=1;$2&&Ld(k[O-3],k[O-1],k[O-2])&&k.splice(k.length-2,1))}if(k.push(w[w.length-1]),O=k.length,(d==="Polygon"||d==="MultiPolygon")&&Pd(w[0],w[w.length-1])&&O<4)throw new Error("invalid polygon");return d==="LineString"&&O<3||Ld(k[O-3],k[O-1],k[O-2])&&k.splice(k.length-2,1),k}rf(of,"cleanLine");function Pd(x,d){return x[0]===d[0]&&x[1]===d[1]}rf(Pd,"equals");function Ld(x,d,w){var k=w[0],A=w[1],O=x[0],$=x[1],s=d[0],Z=d[1],oe=k-O,pe=A-$,he=s-O,we=Z-$,ye=oe*we-pe*he;return ye!==0?!1:Math.abs(he)>=Math.abs(we)?he>0?O<=k&&k<=s:s<=k&&k<=O:we>0?$<=A&&A<=Z:Z<=A&&A<=$}rf(Ld,"isPointOnLineSegment");function _2(x,d,w,k,A){rv(x,d,w||0,k||x.length-1,A||y2)}function rv(x,d,w,k,A){for(;k>w;){if(k-w>600){var O=k-w+1,$=d-w+1,s=Math.log(O),Z=.5*Math.exp(2*s/3),oe=.5*Math.sqrt(s*Z*(O-Z)/O)*($-O/2<0?-1:1),pe=Math.max(w,Math.floor(d-$*Z/O+oe)),he=Math.min(k,Math.floor(d+(O-$)*Z/O+oe));rv(x,d,pe,he,A)}var we=x[d],ye=w,Ie=k;for(cc(x,w,d),A(x[k],we)>0&&cc(x,w,k);ye0;)Ie--}A(x[w],we)===0?cc(x,w,Ie):(Ie++,cc(x,Ie,k)),Ie<=d&&(w=Ie+1),d<=Ie&&(k=Ie-1)}}function cc(x,d,w){var k=x[d];x[d]=x[w],x[w]=k}function y2(x,d){return xd?1:0}class ov{constructor(d=9){this._maxEntries=Math.max(4,d),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(d){let w=this.data;const k=[];if(!af(d,w))return k;const A=this.toBBox,O=[];for(;w;){for(let $=0;$=0&&O[w].children.length>this._maxEntries;)this._split(O,w),w--;this._adjustParentBBoxes(A,O,w)}_split(d,w){const k=d[w],A=k.children.length,O=this._minEntries;this._chooseSplitAxis(k,O,A);const $=this._chooseSplitIndex(k,O,A),s=nu(k.children.splice($,k.children.length-$));s.height=k.height,s.leaf=k.leaf,iu(k,this.toBBox),iu(s,this.toBBox),w?d[w-1].children.push(s):this._splitRoot(k,s)}_splitRoot(d,w){this.data=nu([d,w]),this.data.height=d.height+1,this.data.leaf=!1,iu(this.data,this.toBBox)}_chooseSplitIndex(d,w,k){let A,O=1/0,$=1/0;for(let s=w;s<=k-w;s++){const Z=hc(d,0,s,this.toBBox),oe=hc(d,s,k,this.toBBox),pe=E2(Z,oe),he=Rd(Z)+Rd(oe);pe=w;oe--){const pe=d.children[oe];fc(s,d.leaf?O(pe):pe),Z+=sf(s)}return Z}_adjustParentBBoxes(d,w,k){for(let A=k;A>=0;A--)fc(w[A],d)}_condense(d){for(let w=d.length-1,k;w>=0;w--)d[w].children.length===0?w>0?(k=d[w-1].children,k.splice(k.indexOf(d[w]),1)):this.clear():iu(d[w],this.toBBox)}}function v2(x,d,w){if(!w)return d.indexOf(x);for(let k=0;k=x.minX&&d.maxY>=x.minY}function nu(x){return{children:x,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function sv(x,d,w,k,A){const O=[d,w];for(;O.length;){if(w=O.pop(),d=O.pop(),w-d<=k)continue;const $=d+Math.ceil((w-d)/k/2)*k;_2(x,$,d,w,A),O.push(d,$,$,w)}}var T2=Object.defineProperty,lf=(x,d)=>T2(x,"name",{value:d,configurable:!0});function av(x){if(!x)throw new Error("geojson is required");const d=[];return Os(x,w=>{lv(w,d)}),yo(d)}lf(av,"lineSegment");function lv(x,d){let w=[];const k=x.geometry;if(k!==null){switch(k.type){case"Polygon":w=rl(k);break;case"LineString":w=[rl(k)]}w.forEach(A=>{uv(A,x.properties).forEach($=>{$.id=d.length,d.push($)})})}}lf(lv,"lineSegmentFeature");function uv(x,d){const w=[];return x.reduce((k,A)=>{const O=us([k,A],d);return O.bbox=cv(k,A),w.push(O),A}),w}lf(uv,"createSegments");function cv(x,d){const w=x[0],k=x[1],A=d[0],O=d[1],$=wA?w:A,oe=k>O?k:O;return[$,s,Z,oe]}lf(cv,"bbox");var S2=Object.defineProperty,I2=(x,d)=>S2(x,"name",{value:d,configurable:!0});function uf(x,d={}){const w=Yy(x),k=(w[0]+w[2])/2,A=(w[1]+w[3])/2;return Xn([k,A],d.properties,d)}I2(uf,"center");var hv={exports:{}};(function(x,d){(function(w,k){x.exports=k()})($l,function(){function w(v,o){if(!(v instanceof o))throw new TypeError("Cannot call a class as a function")}function k(v,o){for(var l=0;l"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oe(v,o,l){return oe=Z()?Reflect.construct:function(c,g,S){var R=[null];R.push.apply(R,g);var F=new(Function.bind.apply(c,R));return S&&s(F,S.prototype),F},oe.apply(null,arguments)}function pe(v){var o=typeof Map=="function"?new Map:void 0;return pe=function(l){if(l===null||(c=l,Function.toString.call(c).indexOf("[native code]")===-1))return l;var c;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,g)}function g(){return oe(l,arguments,$(this).constructor)}return g.prototype=Object.create(l.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),s(g,l)},pe(v)}function he(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function we(v,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return he(v)}function ye(v){var o=Z();return function(){var l,c=$(v);if(o){var g=$(this).constructor;l=Reflect.construct(c,arguments,g)}else l=c.apply(this,arguments);return we(this,l)}}function Ie(v,o,l){return Ie=typeof Reflect<"u"&&Reflect.get?Reflect.get:function(c,g,S){var R=function(q,Q){for(;!Object.prototype.hasOwnProperty.call(q,Q)&&(q=$(q))!==null;);return q}(c,g);if(R){var F=Object.getOwnPropertyDescriptor(R,g);return F.get?F.get.call(S):F.value}},Ie(v,o,l||v)}function Tt(v){return function(o){if(Array.isArray(o))return Mt(o)}(v)||function(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}(v)||gt(v)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function gt(v,o){if(v){if(typeof v=="string")return Mt(v,o);var l=Object.prototype.toString.call(v).slice(8,-1);return l==="Object"&&v.constructor&&(l=v.constructor.name),l==="Map"||l==="Set"?Array.from(v):l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?Mt(v,o):void 0}}function Mt(v,o){(o==null||o>v.length)&&(o=v.length);for(var l=0,c=new Array(o);l=v.length?{done:!0}:{done:!1,value:v[c++]}},e:function(q){throw q},f:g}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var S,R=!0,F=!1;return{s:function(){l=l.call(v)},n:function(){var q=l.next();return R=q.done,q},e:function(q){F=!0,S=q},f:function(){try{R||l.return==null||l.return()}finally{if(F)throw S}}}}var Qe=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(o){this._quadrantSegments=o,this._quadrantSegments===0&&(this._joinStyle=v.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=v.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),o<=0&&(this._quadrantSegments=1),this._joinStyle!==v.JOIN_ROUND&&(this._quadrantSegments=v.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(o){this._joinStyle=o}},{key:"setSimplifyFactor",value:function(o){this._simplifyFactor=o<0?0:o}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(o){this._endCapStyle=o}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(o){this._mitreLimit=o}},{key:"setSingleSided",value:function(o){this._isSingleSided=o}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=v.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=v.CAP_ROUND,this._joinStyle=v.JOIN_ROUND,this._mitreLimit=v.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=v.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this.setQuadrantSegments(o)}else if(arguments.length===2){var l=arguments[0],c=arguments[1];this.setQuadrantSegments(l),this.setEndCapStyle(c)}else if(arguments.length===4){var g=arguments[0],S=arguments[1],R=arguments[2],F=arguments[3];this.setQuadrantSegments(g),this.setEndCapStyle(S),this.setJoinStyle(R),this.setMitreLimit(F)}}}},{key:"bufferDistanceError",value:function(o){var l=Math.PI/2/o;return 1-Math.cos(l/2)}}]),v}();Qe.CAP_ROUND=1,Qe.CAP_FLAT=2,Qe.CAP_SQUARE=3,Qe.JOIN_ROUND=1,Qe.JOIN_MITRE=2,Qe.JOIN_BEVEL=3,Qe.DEFAULT_QUADRANT_SEGMENTS=8,Qe.DEFAULT_MITRE_LIMIT=5,Qe.DEFAULT_SIMPLIFY_FACTOR=.01;var Et=function(v){O(l,v);var o=ye(l);function l(c){var g;return w(this,l),(g=o.call(this,c)).name=Object.keys({Exception:l})[0],g}return A(l,[{key:"toString",value:function(){return this.message}}]),l}(pe(Error)),ut=function(v){O(l,v);var o=ye(l);function l(c){var g;return w(this,l),(g=o.call(this,c)).name=Object.keys({IllegalArgumentException:l})[0],g}return l}(Et),yt=function(){function v(){w(this,v)}return A(v,[{key:"filter",value:function(o){}}]),v}();function _t(){}function It(){}function Oe(){}var gi,ti,At,Xt,bt,Jt,Bt,Ri,Rt=function(){function v(){w(this,v)}return A(v,null,[{key:"equalsWithTolerance",value:function(o,l,c){return Math.abs(o-l)<=c}}]),v}(),pi=function(){function v(o,l){w(this,v),this.low=l||0,this.high=o||0}return A(v,null,[{key:"toBinaryString",value:function(o){var l,c="";for(l=2147483648;l>0;l>>>=1)c+=(o.high&l)===l?"1":"0";for(l=2147483648;l>0;l>>>=1)c+=(o.low&l)===l?"1":"0";return c}}]),v}();function St(){}function wi(){}St.NaN=NaN,St.isNaN=function(v){return Number.isNaN(v)},St.isInfinite=function(v){return!Number.isFinite(v)},St.MAX_VALUE=Number.MAX_VALUE,St.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,St.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,typeof Float64Array=="function"&&typeof Int32Array=="function"?(Jt=2146435072,Bt=new Float64Array(1),Ri=new Int32Array(Bt.buffer),St.doubleToLongBits=function(v){Bt[0]=v;var o=0|Ri[0],l=0|Ri[1];return(l&Jt)===Jt&&1048575&l&&o!==0&&(o=0,l=2146959360),new pi(l,o)},St.longBitsToDouble=function(v){return Ri[0]=v.low,Ri[1]=v.high,Bt[0]}):(gi=1023,ti=Math.log2,At=Math.floor,Xt=Math.pow,bt=function(){for(var v=53;v>0;v--){var o=Xt(2,v)-1;if(At(ti(o))+1===v)return o}return 0}(),St.doubleToLongBits=function(v){var o,l,c,g,S,R,F,q,Q;if(v<0||1/v===Number.NEGATIVE_INFINITY?(R=-2147483648,v=-v):R=0,v===0)return new pi(q=R,Q=0);if(v===1/0)return new pi(q=2146435072|R,Q=0);if(v!=v)return new pi(q=2146959360,Q=0);if(g=0,Q=0,(o=At(v))>1)if(o<=bt)(g=At(ti(o)))<=20?(Q=0,q=o<<20-g&1048575):(Q=o%(l=Xt(2,c=g-20))<<32-c,q=o/l&1048575);else for(c=o,Q=0;(c=At(l=c/2))!==0;)g++,Q>>>=1,Q|=(1&q)<<31,q>>>=1,l!==c&&(q|=524288);if(F=g+gi,S=o===0,o=v-o,g<52&&o!==0)for(c=0;;){if((l=2*o)>=1?(o=l-1,S?(F--,S=!1):(c<<=1,c|=1,g++)):(o=l,S?--F==0&&(g++,S=!1):(c<<=1,g++)),g===20)q|=c,c=0;else if(g===52){Q|=c;break}if(l===1){g<20?q|=c<<20-g:g<52&&(Q|=c<<52-g);break}}return q|=F<<20,new pi(q|=R,Q)},St.longBitsToDouble=function(v){var o,l,c,g,S=v.high,R=v.low,F=S&1<<31?-1:1;for(c=((2146435072&S)>>20)-gi,g=0,l=524288,o=1;o<=20;o++)S&l&&(g+=Xt(2,-o)),l>>>=1;for(l=-2147483648,o=21;o<=52;o++)R&l&&(g+=Xt(2,-o)),l>>>=1;if(c===-1023){if(g===0)return 0*F;c=-1022}else{if(c===1024)return g===0?F/0:NaN;g+=1}return F*g*Xt(2,c)});var Oi=function(v){O(l,v);var o=ye(l);function l(c){var g;return w(this,l),(g=o.call(this,c)).name=Object.keys({RuntimeException:l})[0],g}return l}(Et),Wt=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,null,[{key:"constructor_",value:function(){if(arguments.length===0)Oi.constructor_.call(this);else if(arguments.length===1){var c=arguments[0];Oi.constructor_.call(this,c)}}}]),l}(Oi),Dt=function(){function v(){w(this,v)}return A(v,null,[{key:"shouldNeverReachHere",value:function(){if(arguments.length===0)v.shouldNeverReachHere(null);else if(arguments.length===1){var o=arguments[0];throw new Wt("Should never reach here"+(o!==null?": "+o:""))}}},{key:"isTrue",value:function(){if(arguments.length===1){var o=arguments[0];v.isTrue(o,null)}else if(arguments.length===2){var l=arguments[0],c=arguments[1];if(!l)throw c===null?new Wt:new Wt(c)}}},{key:"equals",value:function(){if(arguments.length===2){var o=arguments[0],l=arguments[1];v.equals(o,l,null)}else if(arguments.length===3){var c=arguments[0],g=arguments[1],S=arguments[2];if(!g.equals(c))throw new Wt("Expected "+c+" but encountered "+g+(S!==null?": "+S:""))}}}]),v}(),Ni=new ArrayBuffer(8),Dn=new Float64Array(Ni),vn=new Int32Array(Ni),Fe=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getM",value:function(){return St.NaN}},{key:"setOrdinate",value:function(o,l){switch(o){case v.X:this.x=l;break;case v.Y:this.y=l;break;case v.Z:this.setZ(l);break;default:throw new ut("Invalid ordinate index: "+o)}}},{key:"equals2D",value:function(){if(arguments.length===1){var o=arguments[0];return this.x===o.x&&this.y===o.y}if(arguments.length===2){var l=arguments[0],c=arguments[1];return!!Rt.equalsWithTolerance(this.x,l.x,c)&&!!Rt.equalsWithTolerance(this.y,l.y,c)}}},{key:"setM",value:function(o){throw new ut("Invalid ordinate index: "+v.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(o){switch(o){case v.X:return this.x;case v.Y:return this.y;case v.Z:return this.getZ()}throw new ut("Invalid ordinate index: "+o)}},{key:"equals3D",value:function(o){return this.x===o.x&&this.y===o.y&&(this.getZ()===o.getZ()||St.isNaN(this.getZ())&&St.isNaN(o.getZ()))}},{key:"equals",value:function(o){return o instanceof v&&this.equals2D(o)}},{key:"equalInZ",value:function(o,l){return Rt.equalsWithTolerance(this.getZ(),o.getZ(),l)}},{key:"setX",value:function(o){this.x=o}},{key:"compareTo",value:function(o){var l=o;return this.xl.x?1:this.yl.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(o){this.z=o}},{key:"clone",value:function(){try{return null}catch(o){if(o instanceof CloneNotSupportedException)return Dt.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw o}}},{key:"copy",value:function(){return new v(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(o){var l=this.x-o.x,c=this.y-o.y,g=this.getZ()-o.getZ();return Math.sqrt(l*l+c*c+g*g)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(o){this.y=o}},{key:"distance",value:function(o){var l=this.x-o.x,c=this.y-o.y;return Math.sqrt(l*l+c*c)}},{key:"hashCode",value:function(){var o=17;return o=37*(o=37*o+v.hashCode(this.x))+v.hashCode(this.y)}},{key:"setCoordinate",value:function(o){this.x=o.x,this.y=o.y,this.z=o.getZ()}},{key:"interfaces_",get:function(){return[_t,It,Oe]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,arguments.length===0)v.constructor_.call(this,0,0);else if(arguments.length===1){var o=arguments[0];v.constructor_.call(this,o.x,o.y,o.getZ())}else if(arguments.length===2){var l=arguments[0],c=arguments[1];v.constructor_.call(this,l,c,v.NULL_ORDINATE)}else if(arguments.length===3){var g=arguments[0],S=arguments[1],R=arguments[2];this.x=g,this.y=S,this.z=R}}},{key:"hashCode",value:function(o){return Dn[0]=o,vn[0]^vn[1]}}]),v}(),no=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"compare",value:function(o,l){var c=v.compare(o.x,l.x);if(c!==0)return c;var g=v.compare(o.y,l.y);return g!==0?g:this._dimensionsToTest<=2?0:v.compare(o.getZ(),l.getZ())}},{key:"interfaces_",get:function(){return[wi]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,arguments.length===0)v.constructor_.call(this,2);else if(arguments.length===1){var o=arguments[0];if(o!==2&&o!==3)throw new ut("only 2 or 3 dimensions may be specified");this._dimensionsToTest=o}}},{key:"compare",value:function(o,l){return ol?1:St.isNaN(o)?St.isNaN(l)?0:-1:St.isNaN(l)?1:0}}]),v}();Fe.DimensionalComparator=no,Fe.NULL_ORDINATE=St.NaN,Fe.X=0,Fe.Y=1,Fe.Z=2,Fe.M=3;var Ci=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(o){if(!(o instanceof v))return!1;var l=o;return this.isNull()?l.isNull():this._maxx===l.getMaxX()&&this._maxy===l.getMaxY()&&this._minx===l.getMinX()&&this._miny===l.getMinY()}},{key:"intersection",value:function(o){if(this.isNull()||o.isNull()||!this.intersects(o))return new v;var l=this._minx>o._minx?this._minx:o._minx,c=this._miny>o._miny?this._miny:o._miny;return new v(l,this._maxx=this._minx&&l.getMaxX()<=this._maxx&&l.getMinY()>=this._miny&&l.getMaxY()<=this._maxy}}else if(arguments.length===2){var c=arguments[0],g=arguments[1];return!this.isNull()&&c>=this._minx&&c<=this._maxx&&g>=this._miny&&g<=this._maxy}}},{key:"intersects",value:function(){if(arguments.length===1){if(arguments[0]instanceof v){var o=arguments[0];return!this.isNull()&&!o.isNull()&&!(o._minx>this._maxx||o._maxxthis._maxy||o._maxythis._maxx)return!1;var R=c.x>g.x?c.x:g.x;if(Rthis._maxy)return!1;var q=c.y>g.y?c.y:g.y;return!(qthis._maxx||Qthis._maxy||Eethis._maxx&&(this._maxx=l._maxx),l._minythis._maxy&&(this._maxy=l._maxy))}}else if(arguments.length===2){var c=arguments[0],g=arguments[1];this.isNull()?(this._minx=c,this._maxx=c,this._miny=g,this._maxy=g):(cthis._maxx&&(this._maxx=c),gthis._maxy&&(this._maxy=g))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var o=this.getWidth(),l=this.getHeight();return ol._minx?1:this._minyl._miny?1:this._maxxl._maxx?1:this._maxyl._maxy?1:0}},{key:"translate",value:function(o,l){if(this.isNull())return null;this.init(this.getMinX()+o,this.getMaxX()+o,this.getMinY()+l,this.getMaxY()+l)}},{key:"copy",value:function(){return new v(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(o){return!(!this.isNull()&&!o.isNull())||o._minx>this._maxx||o._maxxthis._maxy||o._maxyl?o:l}},{key:"expandBy",value:function(){if(arguments.length===1){var o=arguments[0];this.expandBy(o,o)}else if(arguments.length===2){var l=arguments[0],c=arguments[1];if(this.isNull())return null;this._minx-=l,this._maxx+=l,this._miny-=c,this._maxy+=c,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(arguments.length===1){if(arguments[0]instanceof v){var o=arguments[0];return this.covers(o)}if(arguments[0]instanceof Fe){var l=arguments[0];return this.covers(l)}}else if(arguments.length===2){var c=arguments[0],g=arguments[1];return this.covers(c,g)}}},{key:"centre",value:function(){return this.isNull()?null:new Fe((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(arguments.length===0)this.setToNull();else if(arguments.length===1){if(arguments[0]instanceof Fe){var o=arguments[0];this.init(o.x,o.x,o.y,o.y)}else if(arguments[0]instanceof v){var l=arguments[0];this._minx=l._minx,this._maxx=l._maxx,this._miny=l._miny,this._maxy=l._maxy}}else if(arguments.length===2){var c=arguments[0],g=arguments[1];this.init(c.x,g.x,c.y,g.y)}else if(arguments.length===4){var S=arguments[0],R=arguments[1],F=arguments[2],q=arguments[3];So._maxx&&(l=this._minx-o._maxx);var c=0;return this._maxyo._maxy&&(c=this._miny-o._maxy),l===0?c:c===0?l:Math.sqrt(l*l+c*c)}},{key:"hashCode",value:function(){var o=17;return o=37*(o=37*(o=37*(o=37*o+Fe.hashCode(this._minx))+Fe.hashCode(this._maxx))+Fe.hashCode(this._miny))+Fe.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[_t,Oe]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,arguments.length===0)this.init();else if(arguments.length===1){if(arguments[0]instanceof Fe){var o=arguments[0];this.init(o.x,o.x,o.y,o.y)}else if(arguments[0]instanceof v){var l=arguments[0];this.init(l)}}else if(arguments.length===2){var c=arguments[0],g=arguments[1];this.init(c.x,g.x,c.y,g.y)}else if(arguments.length===4){var S=arguments[0],R=arguments[1],F=arguments[2],q=arguments[3];this.init(S,R,F,q)}}},{key:"intersects",value:function(){if(arguments.length===3){var o=arguments[0],l=arguments[1],c=arguments[2];return c.x>=(o.xl.x?o.x:l.x)&&c.y>=(o.yl.y?o.y:l.y)}if(arguments.length===4){var g=arguments[0],S=arguments[1],R=arguments[2],F=arguments[3],q=Math.min(R.x,F.x),Q=Math.max(R.x,F.x),Ee=Math.min(g.x,S.x),Me=Math.max(g.x,S.x);return!(Ee>Q)&&!(MeQ)&&!(Me=this.size())throw new Do;return this.array[c]}},{key:"push",value:function(c){return this.array.push(c),c}},{key:"pop",value:function(){if(this.array.length===0)throw new ds;return this.array.pop()}},{key:"peek",value:function(){if(this.array.length===0)throw new ds;return this.array[this.array.length-1]}},{key:"empty",value:function(){return this.array.length===0}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(c){return this.array.indexOf(c)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}]),l}(Dr);function ii(v,o){return v.interfaces_&&v.interfaces_.indexOf(o)>-1}var bo=function(){function v(o){w(this,v),this.str=o}return A(v,[{key:"append",value:function(o){this.str+=o}},{key:"setCharAt",value:function(o,l){this.str=this.str.substr(0,o)+l+this.str.substr(o+1)}},{key:"toString",value:function(){return this.str}}]),v}(),Oo=function(){function v(o){w(this,v),this.value=o}return A(v,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(o){return this.valueo?1:0}}],[{key:"compare",value:function(o,l){return ol?1:0}},{key:"isNan",value:function(o){return Number.isNaN(o)}},{key:"valueOf",value:function(o){return new v(o)}}]),v}(),tr=function(){function v(){w(this,v)}return A(v,null,[{key:"isWhitespace",value:function(o){return o<=32&&o>=0||o===127}},{key:"toUpperCase",value:function(o){return o.toUpperCase()}}]),v}(),$t=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"le",value:function(o){return this._hi9?(Me=!0,Xe="9"):Xe="0"+Ee,F.append(Xe),c=c.subtract(v.valueOf(Ee)).multiply(v.TEN),Me&&c.selfAdd(v.TEN);var pt=!0,dt=v.magnitude(c._hi);if(dt<0&&Math.abs(dt)>=q-Q&&(pt=!1),!pt)break}return l[0]=g,F.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof v){var o=arguments[0];return this.add(o.negate())}if(typeof arguments[0]=="number"){var l=arguments[0];return this.add(-l)}}},{key:"equals",value:function(){if(arguments.length===1&&arguments[0]instanceof v){var o=arguments[0];return this._hi===o._hi&&this._lo===o._lo}}},{key:"isZero",value:function(){return this._hi===0&&this._lo===0}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof v){var o=arguments[0];return this.isNaN()?this:this.selfAdd(-o._hi,-o._lo)}if(typeof arguments[0]=="number"){var l=arguments[0];return this.isNaN()?this:this.selfAdd(-l,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(o){return this.le(o)?this:o}},{key:"selfDivide",value:function(){if(arguments.length===1){if(arguments[0]instanceof v){var o=arguments[0];return this.selfDivide(o._hi,o._lo)}if(typeof arguments[0]=="number"){var l=arguments[0];return this.selfDivide(l,0)}}else if(arguments.length===2){var c=arguments[0],g=arguments[1],S=null,R=null,F=null,q=null,Q=null,Ee=null,Me=null,Xe=null;return Q=this._hi/c,Xe=(S=(Ee=v.SPLIT*Q)-(S=Ee-Q))*(F=(Xe=v.SPLIT*c)-(F=Xe-c))-(Me=Q*c)+S*(q=c-F)+(R=Q-S)*F+R*q,Xe=Q+(Ee=(this._hi-Me-Xe+this._lo-Q*g)/c),this._hi=Xe,this._lo=Q-Xe+Ee,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof v){var o=arguments[0],l=null,c=null,g=null,S=null,R=null,F=null,q=null,Q=null;c=(R=this._hi/o._hi)-(l=(F=v.SPLIT*R)-(l=F-R)),Q=l*(g=(Q=v.SPLIT*o._hi)-(g=Q-o._hi))-(q=R*o._hi)+l*(S=o._hi-g)+c*g+c*S;var Ee=Q=R+(F=(this._hi-q-Q+this._lo-R*o._lo)/o._hi),Me=R-Q+F;return new v(Ee,Me)}if(typeof arguments[0]=="number"){var Xe=arguments[0];return St.isNaN(Xe)?v.createNaN():v.copy(this).selfDivide(Xe,0)}}},{key:"ge",value:function(o){return this._hi>o._hi||this._hi===o._hi&&this._lo>=o._lo}},{key:"pow",value:function(o){if(o===0)return v.valueOf(1);var l=new v(this),c=v.valueOf(1),g=Math.abs(o);if(g>1)for(;g>0;)g%2==1&&c.selfMultiply(l),(g/=2)>0&&(l=l.sqr());else c=l;return o<0?c.reciprocal():c}},{key:"ceil",value:function(){if(this.isNaN())return v.NaN;var o=Math.ceil(this._hi),l=0;return o===this._hi&&(l=Math.ceil(this._lo)),new v(o,l)}},{key:"compareTo",value:function(o){var l=o;return this._hil._hi?1:this._lol._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof v){var o=arguments[0];return this.init(o),this}if(typeof arguments[0]=="number"){var l=arguments[0];return this.init(l),this}}},{key:"max",value:function(o){return this.ge(o)?this:o}},{key:"sqrt",value:function(){if(this.isZero())return v.valueOf(0);if(this.isNegative())return v.NaN;var o=1/Math.sqrt(this._hi),l=this._hi*o,c=v.valueOf(l),g=this.subtract(c.sqr())._hi*(.5*o);return c.add(g)}},{key:"selfAdd",value:function(){if(arguments.length===1){if(arguments[0]instanceof v){var o=arguments[0];return this.selfAdd(o._hi,o._lo)}if(typeof arguments[0]=="number"){var l=arguments[0],c=null,g=null,S=null,R=null,F=null,q=null;return R=(S=this._hi+l)-(F=S-this._hi),g=(q=(R=l-F+(this._hi-R))+this._lo)+(S-(c=S+q)),this._hi=c+g,this._lo=g+(c-this._hi),this}}else if(arguments.length===2){var Q=arguments[0],Ee=arguments[1],Me=null,Xe=null,pt=null,dt=null,Vt=null,Ut=null,ei=null;dt=this._hi+Q,Xe=this._lo+Ee,Vt=dt-(Ut=dt-this._hi),pt=Xe-(ei=Xe-this._lo);var yi=(Me=dt+(Ut=(Vt=Q-Ut+(this._hi-Vt))+Xe))+(Ut=(pt=Ee-ei+(this._lo-pt))+(Ut+(dt-Me))),Xi=Ut+(Me-yi);return this._hi=yi,this._lo=Xi,this}}},{key:"selfMultiply",value:function(){if(arguments.length===1){if(arguments[0]instanceof v){var o=arguments[0];return this.selfMultiply(o._hi,o._lo)}if(typeof arguments[0]=="number"){var l=arguments[0];return this.selfMultiply(l,0)}}else if(arguments.length===2){var c=arguments[0],g=arguments[1],S=null,R=null,F=null,q=null,Q=null,Ee=null;S=(Q=v.SPLIT*this._hi)-this._hi,Ee=v.SPLIT*c,S=Q-S,R=this._hi-S,F=Ee-c;var Me=(Q=this._hi*c)+(Ee=S*(F=Ee-F)-Q+S*(q=c-F)+R*F+R*q+(this._hi*g+this._lo*c)),Xe=Ee+(S=Q-Me);return this._hi=Me,this._lo=Xe,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return v.NaN;var o=Math.floor(this._hi),l=0;return o===this._hi&&(l=Math.floor(this._lo)),new v(o,l)}},{key:"negate",value:function(){return this.isNaN()?this:new v(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(o){if(o instanceof CloneNotSupportedException)return null;throw o}}},{key:"multiply",value:function(){if(arguments[0]instanceof v){var o=arguments[0];return o.isNaN()?v.createNaN():v.copy(this).selfMultiply(o)}if(typeof arguments[0]=="number"){var l=arguments[0];return St.isNaN(l)?v.createNaN():v.copy(this).selfMultiply(l,0)}}},{key:"isNaN",value:function(){return St.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var o=v.magnitude(this._hi);return o>=-3&&o<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var o=this.getSpecialNumberString();if(o!==null)return o;var l=new Array(1).fill(null),c=this.extractSignificantDigits(!0,l),g=l[0]+1,S=c;if(c.charAt(0)===".")S="0"+c;else if(g<0)S="0."+v.stringOfChar("0",-g)+c;else if(c.indexOf(".")===-1){var R=g-c.length;S=c+v.stringOfChar("0",R)+".0"}return this.isNegative()?"-"+S:S}},{key:"reciprocal",value:function(){var o,l,c,g,S=null,R=null,F=null,q=null;o=(c=1/this._hi)-(S=(F=v.SPLIT*c)-(S=F-c)),R=(q=v.SPLIT*this._hi)-this._hi;var Q=c+(F=(1-(g=c*this._hi)-(q=S*(R=q-R)-g+S*(l=this._hi-R)+o*R+o*l)-c*this._lo)/this._hi);return new v(Q,c-Q+F)}},{key:"toSciNotation",value:function(){if(this.isZero())return v.SCI_NOT_ZERO;var o=this.getSpecialNumberString();if(o!==null)return o;var l=new Array(1).fill(null),c=this.extractSignificantDigits(!1,l),g=v.SCI_NOT_EXPONENT_CHAR+l[0];if(c.charAt(0)==="0")throw new IllegalStateException("Found leading zero: "+c);var S="";c.length>1&&(S=c.substring(1));var R=c.charAt(0)+"."+S;return this.isNegative()?"-"+R+g:R+g}},{key:"abs",value:function(){return this.isNaN()?v.NaN:this.isNegative()?this.negate():new v(this)}},{key:"isPositive",value:function(){return this._hi>0||this._hi===0&&this._lo>0}},{key:"lt",value:function(o){return this._hio._hi||this._hi===o._hi&&this._lo>o._lo}},{key:"isNegative",value:function(){return this._hi<0||this._hi===0&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?v.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[Oe,_t,It]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,arguments.length===0)this.init(0);else if(arguments.length===1){if(typeof arguments[0]=="number"){var o=arguments[0];this.init(o)}else if(arguments[0]instanceof v){var l=arguments[0];this.init(l)}else if(typeof arguments[0]=="string"){var c=arguments[0];v.constructor_.call(this,v.parse(c))}}else if(arguments.length===2){var g=arguments[0],S=arguments[1];this.init(g,S)}}},{key:"determinant",value:function(){if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var o=arguments[0],l=arguments[1],c=arguments[2],g=arguments[3];return v.determinant(v.valueOf(o),v.valueOf(l),v.valueOf(c),v.valueOf(g))}if(arguments[3]instanceof v&&arguments[2]instanceof v&&arguments[0]instanceof v&&arguments[1]instanceof v){var S=arguments[0],R=arguments[1],F=arguments[2],q=arguments[3],Q=S.multiply(q).selfSubtract(R.multiply(F));return Q}}},{key:"sqr",value:function(o){return v.valueOf(o).selfMultiply(o)}},{key:"valueOf",value:function(){if(typeof arguments[0]=="string"){var o=arguments[0];return v.parse(o)}if(typeof arguments[0]=="number"){var l=arguments[0];return new v(l)}}},{key:"sqrt",value:function(o){return v.valueOf(o).sqrt()}},{key:"parse",value:function(o){for(var l=0,c=o.length;tr.isWhitespace(o.charAt(l));)l++;var g=!1;if(l=c);){var Me=o.charAt(l);if(l++,tr.isDigit(Me)){var Xe=Me-"0";R.selfMultiply(v.TEN),R.selfAdd(Xe),F++}else{if(Me!=="."){if(Me==="e"||Me==="E"){var pt=o.substring(l);try{Q=Oo.parseInt(pt)}catch(yi){throw yi instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+pt+" in string "+o):yi}break}throw new NumberFormatException("Unexpected character '"+Me+"' at position "+l+" in string "+o)}q=F,Ee=!0}}var dt=R;Ee||(q=F);var Vt=F-q-Q;if(Vt===0)dt=R;else if(Vt>0){var Ut=v.TEN.pow(Vt);dt=R.divide(Ut)}else if(Vt<0){var ei=v.TEN.pow(-Vt);dt=R.multiply(ei)}return g?dt.negate():dt}},{key:"createNaN",value:function(){return new v(St.NaN,St.NaN)}},{key:"copy",value:function(o){return new v(o)}},{key:"magnitude",value:function(o){var l=Math.abs(o),c=Math.log(l)/Math.log(10),g=Math.trunc(Math.floor(c));return 10*Math.pow(10,g)<=l&&(g+=1),g}},{key:"stringOfChar",value:function(o,l){for(var c=new bo,g=0;g0){if(R<=0)return v.signum(F);g=S+R}else{if(!(S<0)||R>=0)return v.signum(F);g=-S-R}var q=v.DP_SAFE_EPSILON*g;return F>=q||-F>=q?v.signum(F):2}},{key:"signum",value:function(o){return o>0?1:o<0?-1:0}}]),v}();zo.DP_SAFE_EPSILON=1e-15;var _i=function(){function v(){w(this,v)}return A(v,[{key:"getM",value:function(o){if(this.hasM()){var l=this.getDimension()-this.getMeasures();return this.getOrdinate(o,l)}return St.NaN}},{key:"setOrdinate",value:function(o,l,c){}},{key:"getZ",value:function(o){return this.hasZ()?this.getOrdinate(o,2):St.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(o,l){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(o){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(o){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(o){}},{key:"copy",value:function(){}},{key:"getY",value:function(o){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[It]}}]),v}();_i.X=0,_i.Y=1,_i.Z=2,_i.M=3;var Yt=function(){function v(){w(this,v)}return A(v,null,[{key:"index",value:function(o,l,c){return zo.orientationIndex(o,l,c)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var o=arguments[0],l=o.length-1;if(l<3)throw new ut("Ring has fewer than 4 points, so orientation cannot be determined");for(var c=o[0],g=0,S=1;S<=l;S++){var R=o[S];R.y>c.y&&(c=R,g=S)}var F=g;do(F-=1)<0&&(F=l);while(o[F].equals2D(c)&&F!==g);var q=g;do q=(q+1)%l;while(o[q].equals2D(c)&&q!==g);var Q=o[F],Ee=o[q];if(Q.equals2D(c)||Ee.equals2D(c)||Q.equals2D(Ee))return!1;var Me=v.index(Q,c,Ee),Xe=null;return Xe=Me===0?Q.x>Ee.x:Me>0,Xe}if(ii(arguments[0],_i)){var pt=arguments[0],dt=pt.size()-1;if(dt<3)throw new ut("Ring has fewer than 4 points, so orientation cannot be determined");for(var Vt=pt.getCoordinate(0),Ut=0,ei=1;ei<=dt;ei++){var yi=pt.getCoordinate(ei);yi.y>Vt.y&&(Vt=yi,Ut=ei)}var Xi=null,Fn=Ut;do(Fn-=1)<0&&(Fn=dt),Xi=pt.getCoordinate(Fn);while(Xi.equals2D(Vt)&&Fn!==Ut);var bn=null,Vn=Ut;do Vn=(Vn+1)%dt,bn=pt.getCoordinate(Vn);while(bn.equals2D(Vt)&&Vn!==Ut);if(Xi.equals2D(Vt)||bn.equals2D(Vt)||Xi.equals2D(bn))return!1;var Ir=v.index(Xi,Vt,bn);return Ir===0?Xi.x>bn.x:Ir>0}}}]),v}();Yt.CLOCKWISE=-1,Yt.RIGHT=Yt.CLOCKWISE,Yt.COUNTERCLOCKWISE=1,Yt.LEFT=Yt.COUNTERCLOCKWISE,Yt.COLLINEAR=0,Yt.STRAIGHT=Yt.COLLINEAR;var zs=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(o,l){var c=this.getRightmostSideOfSegment(o,l);return c<0&&(c=this.getRightmostSideOfSegment(o,l-1)),c<0&&(this._minCoord=null,this.checkForRightmostCoordinate(o)),c}},{key:"findRightmostEdgeAtVertex",value:function(){var o=this._minDe.getEdge().getCoordinates();Dt.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&c.y>this._minCoord.y&&g===Yt.CLOCKWISE)&&(S=!0),S&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(o,l){var c=o.getEdge().getCoordinates();if(l<0||l+1>=c.length||c[l].y===c[l+1].y)return-1;var g=ct.LEFT;return c[l].ythis._minCoord.x)&&(this._minDe=o,this._minIndex=c,this._minCoord=l[c])}},{key:"findRightmostEdgeAtNode",value:function(){var o=this._minDe.getNode().getEdges();this._minDe=o.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(o){for(var l=o.iterator();l.hasNext();){var c=l.next();c.isForward()&&this.checkForRightmostCoordinate(c)}Dt.isTrue(this._minIndex!==0||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),this._minIndex===0?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===ct.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),v}(),Wn=function(v){O(l,v);var o=ye(l);function l(c,g){var S;return w(this,l),(S=o.call(this,g?c+" [ "+g+" ]":c)).pt=g?new Fe(g):void 0,S.name=Object.keys({TopologyException:l})[0],S}return A(l,[{key:"getCoordinate",value:function(){return this.pt}}]),l}(Oi),wo=function(){function v(){w(this,v),this.array=[]}return A(v,[{key:"addLast",value:function(o){this.array.push(o)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return this.array.length===0}}]),v}(),qt=function(v,o){O(c,v);var l=ye(c);function c(g){var S;return w(this,c),(S=l.call(this)).array=[],g instanceof rn&&S.addAll(g),S}return A(c,[{key:"interfaces_",get:function(){return[Dr,rn]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(g){return arguments.length===1?this.array.push(g):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(g){var S,R=Le(g);try{for(R.s();!(S=R.n()).done;){var F=S.value;this.array.push(F)}}catch(q){R.e(q)}finally{R.f()}}},{key:"set",value:function(g,S){var R=this.array[g];return this.array[g]=S,R}},{key:"iterator",value:function(){return new No(this)}},{key:"get",value:function(g){if(g<0||g>=this.size())throw new Do;return this.array[g]}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"sort",value:function(g){g?this.array.sort(function(S,R){return g.compare(S,R)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(g){for(var S=0,R=this.array.length;S=1&&l.getDepth(ct.LEFT)<=0&&!l.isInteriorAreaEdge()&&l.setInResult(!0)}}},{key:"computeDepths",value:function(o){var l=new ps,c=new wo,g=o.getNode();for(c.addLast(g),l.add(g),o.setVisited(!0);!c.isEmpty();){var S=c.removeFirst();l.add(S),this.computeNodeDepth(S);for(var R=S.getEdges().iterator();R.hasNext();){var F=R.next().getSym();if(!F.isVisited()){var q=F.getNode();l.contains(q)||(c.addLast(q),l.add(q))}}}}},{key:"compareTo",value:function(o){var l=o;return this._rightMostCoord.xl._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(this._env===null){for(var o=new Ci,l=this._dirEdgeList.iterator();l.hasNext();)for(var c=l.next().getEdge().getCoordinates(),g=0;gl.x?o.x:l.x,q=o.y>l.y?o.y:l.y,Q=c.xg.x?c.x:g.x,Xe=c.y>g.y?c.y:g.y,pt=((S>Q?S:Q)+(FEe?R:Ee)+(qc?c:o}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var g=arguments[0],S=arguments[1],R=arguments[2];return gR?R:g}}},{key:"wrap",value:function(o,l){return o<0?l- -o%l:o%l}},{key:"max",value:function(){if(arguments.length===3){var o=arguments[0],l=arguments[1],c=arguments[2],g=o;return l>g&&(g=l),c>g&&(g=c),g}if(arguments.length===4){var S=arguments[0],R=arguments[1],F=arguments[2],q=arguments[3],Q=S;return R>Q&&(Q=R),F>Q&&(Q=F),q>Q&&(Q=q),Q}}},{key:"average",value:function(o,l){return(o+l)/2}}]),v}();X.LOG_10=Math.log(10);var W=function(){function v(){w(this,v)}return A(v,null,[{key:"segmentToSegment",value:function(o,l,c,g){if(o.equals(l))return v.pointToSegment(o,c,g);if(c.equals(g))return v.pointToSegment(g,o,l);var S=!1;if(Ci.intersects(o,l,c,g)){var R=(l.x-o.x)*(g.y-c.y)-(l.y-o.y)*(g.x-c.x);if(R===0)S=!0;else{var F=(o.y-c.y)*(g.x-c.x)-(o.x-c.x)*(g.y-c.y),q=((o.y-c.y)*(l.x-o.x)-(o.x-c.x)*(l.y-o.y))/R,Q=F/R;(Q<0||Q>1||q<0||q>1)&&(S=!0)}}else S=!0;return S?X.min(v.pointToSegment(o,c,g),v.pointToSegment(l,c,g),v.pointToSegment(c,o,l),v.pointToSegment(g,o,l)):0}},{key:"pointToSegment",value:function(o,l,c){if(l.x===c.x&&l.y===c.y)return o.distance(l);var g=(c.x-l.x)*(c.x-l.x)+(c.y-l.y)*(c.y-l.y),S=((o.x-l.x)*(c.x-l.x)+(o.y-l.y)*(c.y-l.y))/g;if(S<=0)return o.distance(l);if(S>=1)return o.distance(c);var R=((l.y-o.y)*(c.x-l.x)-(l.x-o.x)*(c.y-l.y))/g;return Math.abs(R)*Math.sqrt(g)}},{key:"pointToLinePerpendicular",value:function(o,l,c){var g=(c.x-l.x)*(c.x-l.x)+(c.y-l.y)*(c.y-l.y),S=((l.y-o.y)*(c.x-l.x)-(l.x-o.x)*(c.y-l.y))/g;return Math.abs(S)*Math.sqrt(g)}},{key:"pointToSegmentString",value:function(o,l){if(l.length===0)throw new ut("Line array must contain at least one vertex");for(var c=o.distance(l[0]),g=0;g0)&&(R=q,S=F)}return S}}},{key:"extend",value:function(o,l,c){var g=o.create(c,l.getDimension()),S=l.size();if(v.copy(l,0,g,0,S),S>0)for(var R=S;R0)&&(l=g)}return l}}]),v}(),se=function(){function v(){w(this,v)}return A(v,null,[{key:"toDimensionSymbol",value:function(o){switch(o){case v.FALSE:return v.SYM_FALSE;case v.TRUE:return v.SYM_TRUE;case v.DONTCARE:return v.SYM_DONTCARE;case v.P:return v.SYM_P;case v.L:return v.SYM_L;case v.A:return v.SYM_A}throw new ut("Unknown dimension value: "+o)}},{key:"toDimensionValue",value:function(o){switch(tr.toUpperCase(o)){case v.SYM_FALSE:return v.FALSE;case v.SYM_TRUE:return v.TRUE;case v.SYM_DONTCARE:return v.DONTCARE;case v.SYM_P:return v.P;case v.SYM_L:return v.L;case v.SYM_A:return v.A}throw new ut("Unknown dimension symbol: "+o)}}]),v}();se.P=0,se.L=1,se.A=2,se.FALSE=-1,se.TRUE=-2,se.DONTCARE=-3,se.SYM_FALSE="F",se.SYM_TRUE="T",se.SYM_DONTCARE="*",se.SYM_P="0",se.SYM_L="1",se.SYM_A="2";var Ue=function(){function v(){w(this,v)}return A(v,[{key:"filter",value:function(o){}}]),v}(),ot=function(){function v(){w(this,v)}return A(v,[{key:"filter",value:function(o,l){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),v}(),ht=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new Ci:this._points.expandEnvelope(new Ci)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new l(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof ft){var c=arguments[0],g=arguments[1];if(!this.isEquivalentClass(c))return!1;var S=c;if(this._points.size()!==S._points.size())return!1;for(var R=0;R0){var S=this._points.copy();Ce.reverse(S),this._points=S}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?se.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var c=this._points.copy();return Ce.reverse(c),this.getFactory().createLineString(c)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return ft.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return Se.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(arguments.length===1){for(var c=arguments[0],g=c,S=0,R=0;S= 2)");this._points=c}},{key:"isCoordinate",value:function(c){for(var g=0;g=1&&this.getCoordinateSequence().size()= 4)")}},{key:"getGeometryType",value:function(){return ft.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var c=arguments[0],g=arguments[1];ht.constructor_.call(this,c,g),this.validateConstruction()}}]),l}(ht);cn.MINIMUM_VALID_SIZE=4;var pn=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"setOrdinate",value:function(c,g){switch(c){case l.X:this.x=g;break;case l.Y:this.y=g;break;default:throw new ut("Invalid ordinate index: "+c)}}},{key:"getZ",value:function(){return Fe.NULL_ORDINATE}},{key:"getOrdinate",value:function(c){switch(c){case l.X:return this.x;case l.Y:return this.y}throw new ut("Invalid ordinate index: "+c)}},{key:"setZ",value:function(c){throw new ut("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new l(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(c){this.x=c.x,this.y=c.y,this.z=c.getZ()}}],[{key:"constructor_",value:function(){if(arguments.length===0)Fe.constructor_.call(this);else if(arguments.length===1){if(arguments[0]instanceof l){var c=arguments[0];Fe.constructor_.call(this,c.x,c.y)}else if(arguments[0]instanceof Fe){var g=arguments[0];Fe.constructor_.call(this,g.x,g.y)}}else if(arguments.length===2){var S=arguments[0],R=arguments[1];Fe.constructor_.call(this,S,R,Fe.NULL_ORDINATE)}}}]),l}(Fe);pn.X=0,pn.Y=1,pn.Z=-1,pn.M=-1;var br=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(c,g){switch(c){case l.X:this.x=g;break;case l.Y:this.y=g;break;case l.M:this._m=g;break;default:throw new ut("Invalid ordinate index: "+c)}}},{key:"setM",value:function(c){this._m=c}},{key:"getZ",value:function(){return Fe.NULL_ORDINATE}},{key:"getOrdinate",value:function(c){switch(c){case l.X:return this.x;case l.Y:return this.y;case l.M:return this._m}throw new ut("Invalid ordinate index: "+c)}},{key:"setZ",value:function(c){throw new ut("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new l(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(c){this.x=c.x,this.y=c.y,this.z=c.getZ(),this._m=c.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)Fe.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof l){var c=arguments[0];Fe.constructor_.call(this,c.x,c.y),this._m=c._m}else if(arguments[0]instanceof Fe){var g=arguments[0];Fe.constructor_.call(this,g.x,g.y),this._m=this.getM()}}else if(arguments.length===3){var S=arguments[0],R=arguments[1],F=arguments[2];Fe.constructor_.call(this,S,R,Fe.NULL_ORDINATE),this._m=F}}}]),l}(Fe);br.X=0,br.Y=1,br.Z=-1,br.M=2;var al=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(c,g){switch(c){case Fe.X:this.x=g;break;case Fe.Y:this.y=g;break;case Fe.Z:this.z=g;break;case Fe.M:this._m=g;break;default:throw new ut("Invalid ordinate index: "+c)}}},{key:"setM",value:function(c){this._m=c}},{key:"getOrdinate",value:function(c){switch(c){case Fe.X:return this.x;case Fe.Y:return this.y;case Fe.Z:return this.getZ();case Fe.M:return this.getM()}throw new ut("Invalid ordinate index: "+c)}},{key:"copy",value:function(){return new l(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(c){this.x=c.x,this.y=c.y,this.z=c.getZ(),this._m=c.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)Fe.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof l){var c=arguments[0];Fe.constructor_.call(this,c),this._m=c._m}else if(arguments[0]instanceof Fe){var g=arguments[0];Fe.constructor_.call(this,g),this._m=this.getM()}}else if(arguments.length===4){var S=arguments[0],R=arguments[1],F=arguments[2],q=arguments[3];Fe.constructor_.call(this,S,R,F),this._m=q}}}]),l}(Fe),Ns=function(){function v(){w(this,v)}return A(v,null,[{key:"measures",value:function(o){return o instanceof pn?0:o instanceof br||o instanceof al?1:0}},{key:"dimension",value:function(o){return o instanceof pn?2:o instanceof br?3:o instanceof al?4:3}},{key:"create",value:function(){if(arguments.length===1){var o=arguments[0];return v.create(o,0)}if(arguments.length===2){var l=arguments[0],c=arguments[1];return l===2?new pn:l===3&&c===0?new Fe:l===3&&c===1?new br:l===4&&c===1?new al:new Fe}}}]),v}(),xi=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"getCoordinate",value:function(c){return this.get(c)}},{key:"addAll",value:function(){if(arguments.length===2&&typeof arguments[1]=="boolean"&&ii(arguments[0],rn)){for(var c=arguments[0],g=arguments[1],S=!1,R=c.iterator();R.hasNext();)this.add(R.next(),g),S=!0;return S}return Ie($(l.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var c=Ie($(l.prototype),"clone",this).call(this),g=0;g=1){var q=this.get(this.size()-1);if(q.equals2D(R))return null}Ie($(l.prototype),"add",this).call(this,R)}else if(arguments[0]instanceof Object&&typeof arguments[1]=="boolean"){var Q=arguments[0],Ee=arguments[1];return this.add(Q,Ee),!0}}else if(arguments.length===3){if(typeof arguments[2]=="boolean"&&arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var Me=arguments[0],Xe=arguments[1],pt=arguments[2];if(pt)for(var dt=0;dt=0;Vt--)this.add(Me[Vt],Xe);return!0}if(typeof arguments[2]=="boolean"&&Number.isInteger(arguments[0])&&arguments[1]instanceof Fe){var Ut=arguments[0],ei=arguments[1],yi=arguments[2];if(!yi){var Xi=this.size();if(Xi>0){if(Ut>0){var Fn=this.get(Ut-1);if(Fn.equals2D(ei))return null}if(Utvi&&(uo=-1);for(var Xo=Hr;Xo!==vi;Xo+=uo)this.add(Vn[Xo],Ir);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var c=this.get(0).copy();this.add(c,!1)}}}],[{key:"constructor_",value:function(){if(arguments.length!==0){if(arguments.length===1){var c=arguments[0];this.ensureCapacity(c.length),this.add(c,!0)}else if(arguments.length===2){var g=arguments[0],S=arguments[1];this.ensureCapacity(g.length),this.add(g,S)}}}}]),l}(qt);xi.coordArrayType=new Array(0).fill(null);var dn=function(){function v(){w(this,v)}return A(v,null,[{key:"isRing",value:function(o){return!(o.length<4)&&!!o[0].equals2D(o[o.length-1])}},{key:"ptNotInList",value:function(o,l){for(var c=0;c=o?l:[]}},{key:"indexOf",value:function(o,l){for(var c=0;c0)&&(l=o[c]);return l}},{key:"extract",value:function(o,l,c){l=X.clamp(l,0,o.length);var g=(c=X.clamp(c,-1,o.length))-l+1;c<0&&(g=0),l>=o.length&&(g=0),cg.length)return 1;if(c.length===0)return 0;var S=dn.compare(c,g);return dn.isEqualReversed(c,g)?0:S}},{key:"OLDcompare",value:function(o,l){var c=o,g=l;if(c.lengthg.length)return 1;if(c.length===0)return 0;for(var S=dn.increasingDirection(c),R=dn.increasingDirection(g),F=S>0?0:c.length-1,q=R>0?0:c.length-1,Q=0;Q0){var o=new Bo(17*this._coordinates.length);o.append("("),o.append(this._coordinates[0]);for(var l=1;l3&&(g=3),g<2&&(g=2),new ir(c,g)}if(arguments.length===3){var S=arguments[0],R=arguments[1],F=arguments[2],q=R-F;return F>1&&(F=1),q>3&&(q=3),q<2&&(q=2),new ir(S,q+F,F)}}}},{key:"interfaces_",get:function(){return[ue,Oe]}}],[{key:"instance",value:function(){return v.instanceObject}}]),v}();Or.instanceObject=new Or;var Fs=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"copyInternal",value:function(){for(var c=new Array(this._geometries.length).fill(null),g=0;g=0?o:l}}]),v}(),qr=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"readResolve",value:function(){return v.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[Oe]}}],[{key:"constructor_",value:function(){this._name=null;var o=arguments[0];this._name=o,v.nameToTypeMap.put(o,this)}}]),v}();qr.nameToTypeMap=new Fo,xn.Type=qr,xn.FIXED=new qr("FIXED"),xn.FLOATING=new qr("FLOATING"),xn.FLOATING_SINGLE=new qr("FLOATING SINGLE"),xn.maximumPreciseValue=9007199254740992;var Ge=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"copyInternal",value:function(){for(var c=new Array(this._geometries.length).fill(null),g=0;g1){if(q instanceof hi)return this.createMultiPolygon(v.toPolygonArray(o));if(q instanceof ht)return this.createMultiLineString(v.toLineStringArray(o));if(q instanceof Ht)return this.createMultiPoint(v.toPointArray(o));Dt.shouldNeverReachHere("Unhandled geometry type: "+q.getGeometryType())}return q}},{key:"createMultiPointFromCoords",value:function(o){return this.createMultiPoint(o!==null?this.getCoordinateSequenceFactory().create(o):null)}},{key:"createPoint",value:function(){if(arguments.length===0)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Fe){var o=arguments[0];return this.createPoint(o!==null?this.getCoordinateSequenceFactory().create([o]):null)}if(ii(arguments[0],_i)){var l=arguments[0];return new Ht(l,this)}}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(arguments.length===0)return this.createPolygon(null,null);if(arguments.length===1){if(ii(arguments[0],_i)){var o=arguments[0];return this.createPolygon(this.createLinearRing(o))}if(arguments[0]instanceof Array){var l=arguments[0];return this.createPolygon(this.createLinearRing(l))}if(arguments[0]instanceof cn){var c=arguments[0];return this.createPolygon(c,null)}}else if(arguments.length===2){var g=arguments[0],S=arguments[1];return new hi(g,S,this)}}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){if(arguments.length===0)return new Pi(null,this);if(arguments.length===1){var o=arguments[0];return new Pi(o,this)}}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(arguments.length===0)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var o=arguments[0];return this.createLinearRing(o!==null?this.getCoordinateSequenceFactory().create(o):null)}if(ii(arguments[0],_i)){var l=arguments[0];return new cn(l,this)}}}},{key:"createMultiPolygon",value:function(){if(arguments.length===0)return new Fs(null,this);if(arguments.length===1){var o=arguments[0];return new Fs(o,this)}}},{key:"createMultiPoint",value:function(){if(arguments.length===0)return new xr(null,this);if(arguments.length===1){if(arguments[0]instanceof Array){var o=arguments[0];return new xr(o,this)}if(ii(arguments[0],_i)){var l=arguments[0];if(l===null)return this.createMultiPoint(new Array(0).fill(null));for(var c=new Array(l.size()).fill(null),g=0;g="a"&&o<="z"||o>="A"&&o<="Z"}},{key:"isNumeric_",value:function(o,l){return o>="0"&&o<="9"||o=="."&&!(l!==void 0&&l)}},{key:"isWhiteSpace_",value:function(o){return o==" "||o==" "||o=="\r"||o==` `}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var o,l=this.nextChar_(),c=this.index_,g=l;if(l=="(")o=mt;else if(l==",")o=Cn;else if(l==")")o=Qt;else if(this.isNumeric_(l)||l=="-")o=ci,g=this.readNumber_();else if(this.isAlpha_(l))o=oo,g=this.readText_();else{if(this.isWhiteSpace_(l))return this.nextToken();if(l!=="")throw new Error("Unexpected character: "+l);o=zr}return{position:c,value:g,type:o}}},{key:"readNumber_",value:function(){var o,l=this.index_,c=!1,g=!1;do o=="."?c=!0:o!="e"&&o!="E"||(g=!0),o=this.nextChar_();while(this.isNumeric_(o,c)||!g&&(o=="e"||o=="E")||g&&(o=="-"||o=="+"));return parseFloat(this.wkt.substring(l,this.index_--))}},{key:"readText_",value:function(){var o,l=this.index_;do o=this.nextChar_();while(this.isAlpha_(o));return this.wkt.substring(l,this.index_--).toUpperCase()}}]),v}(),Us=function(){function v(o,l){w(this,v),this.lexer_=o,this.token_,this.layout_=sn,this.factory=l}return A(v,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(o){return this.token_.type==o}},{key:"match",value:function(o){var l=this.isTokenType(o);return l&&this.consume_(),l}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var o=sn,l=this.token_;if(this.isTokenType(oo)){var c=l.value;c==="Z"?o=An:c==="M"?o=hu:c==="ZM"&&(o=Zr),o!==sn&&this.consume_()}return o}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(mt)){var o=[];do o.push(this.parseGeometry_());while(this.match(Cn));if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(mt)){var o=this.parsePoint_();if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(mt)){var o=this.parsePointList_();if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(mt)){var o=this.parseLineStringTextList_();if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var o;if(this.match(mt)){if(o=this.token_.type==mt?this.parsePointTextList_():this.parsePointList_(),this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(mt)){var o=this.parseLineStringTextList_();if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(mt)){var o=this.parsePolygonTextList_();if(this.match(Qt))return o}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var o=[],l=this.layout_.length,c=0;c1?o.createPolygon(ei[0],ei.slice(1)):o.createPolygon(ei[0])},g=this.token_;if(this.match(oo)){var S=g.value;if(this.layout_=this.parseGeometryLayout_(),S=="GEOMETRYCOLLECTION"){var R=this.parseGeometryCollectionText_();return o.createGeometryCollection(R)}switch(S){case"POINT":var F=this.parsePointText_();return F?o.createPoint(oe(Fe,Tt(F))):o.createPoint();case"LINESTRING":var q=this.parseLineStringText_().map(l);return o.createLineString(q);case"LINEARRING":var Q=this.parseLineStringText_().map(l);return o.createLinearRing(Q);case"POLYGON":var Ee=this.parsePolygonText_();return Ee&&Ee.length!==0?c(Ee):o.createPolygon();case"MULTIPOINT":var Me=this.parseMultiPointText_();if(!Me||Me.length===0)return o.createMultiPoint();var Xe=Me.map(l).map(function(Ut){return o.createPoint(Ut)});return o.createMultiPoint(Xe);case"MULTILINESTRING":var pt=this.parseMultiLineStringText_().map(function(Ut){return o.createLineString(Ut.map(l))});return o.createMultiLineString(pt);case"MULTIPOLYGON":var dt=this.parseMultiPolygonText_();if(!dt||dt.length===0)return o.createMultiPolygon();var Vt=dt.map(c);return o.createMultiPolygon(Vt);default:throw new Error("Invalid geometry type: "+S)}}throw new Error(this.formatErrorMessage_())}}]),v}();function Eo(v){if(v.isEmpty())return"";var o=v.getCoordinate(),l=[o.x,o.y];return o.z===void 0||Number.isNaN(o.z)||l.push(o.z),o.m===void 0||Number.isNaN(o.m)||l.push(o.m),l.join(" ")}function jn(v){for(var o=v.getCoordinates().map(function(S){var R=[S.x,S.y];return S.z===void 0||Number.isNaN(S.z)||R.push(S.z),S.m===void 0||Number.isNaN(S.m)||R.push(S.m),R}),l=[],c=0,g=o.length;c0&&(o+=" "+c),v.isEmpty()?o+" "+ul:o+" ("+l(v)+")"}var js=function(){function v(o){w(this,v),this.geometryFactory=o||new nr,this.precisionModel=this.geometryFactory.getPrecisionModel()}return A(v,[{key:"read",value:function(o){var l=new dr(o);return new Us(l,this.geometryFactory).parse()}},{key:"write",value:function(o){return Xr(o)}}]),v}(),Uo=function(){function v(o){w(this,v),this.parser=new js(o)}return A(v,[{key:"write",value:function(o){return this.parser.write(o)}}],[{key:"toLineString",value:function(o,l){if(arguments.length!==2)throw new Error("Not implemented");return"LINESTRING ( "+o.x+" "+o.y+", "+l.x+" "+l.y+" )"}}]),v}(),Ji=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getIndexAlongSegment",value:function(o,l){return this.computeIntLineIndex(),this._intLineIndex[o][l]}},{key:"getTopologySummary",value:function(){var o=new Bo;return this.isEndPoint()&&o.append(" endpoint"),this._isProper&&o.append(" proper"),this.isCollinear()&&o.append(" collinear"),o.toString()}},{key:"computeIntersection",value:function(o,l,c,g){this._inputLines[0][0]=o,this._inputLines[0][1]=l,this._inputLines[1][0]=c,this._inputLines[1][1]=g,this._result=this.computeIntersect(o,l,c,g)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(arguments.length===0)this._intLineIndex===null&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(arguments.length===1){var o=arguments[0],l=this.getEdgeDistance(o,0),c=this.getEdgeDistance(o,1);l>c?(this._intLineIndex[o][0]=0,this._intLineIndex[o][1]=1):(this._intLineIndex[o][0]=1,this._intLineIndex[o][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(o){this._precisionModel=o}},{key:"isInteriorIntersection",value:function(){if(arguments.length===0)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(arguments.length===1){for(var o=arguments[0],l=0;lS?g:S;else{var F=Math.abs(o.x-l.x),q=Math.abs(o.y-l.y);(R=g>S?F:q)!==0||o.equals(l)||(R=Math.max(F,q))}return Dt.isTrue(!(R===0&&!o.equals(l)),"Bad distance calculation"),R}},{key:"nonRobustComputeEdgeDistance",value:function(o,l,c){var g=o.x-l.x,S=o.y-l.y,R=Math.sqrt(g*g+S*S);return Dt.isTrue(!(R===0&&!o.equals(l)),"Invalid distance calculation"),R}}]),v}();Ji.DONT_INTERSECT=0,Ji.DO_INTERSECT=1,Ji.COLLINEAR=2,Ji.NO_INTERSECTION=0,Ji.POINT_INTERSECTION=1,Ji.COLLINEAR_INTERSECTION=2;var To=function(v){O(l,v);var o=ye(l);function l(){return w(this,l),o.call(this)}return A(l,[{key:"isInSegmentEnvelopes",value:function(c){var g=new Ci(this._inputLines[0][0],this._inputLines[0][1]),S=new Ci(this._inputLines[1][0],this._inputLines[1][1]);return g.contains(c)&&S.contains(c)}},{key:"computeIntersection",value:function(){if(arguments.length!==3)return Ie($(l.prototype),"computeIntersection",this).apply(this,arguments);var c=arguments[0],g=arguments[1],S=arguments[2];if(this._isProper=!1,Ci.intersects(g,S,c)&&Yt.index(g,S,c)===0&&Yt.index(S,g,c)===0)return this._isProper=!0,(c.equals(g)||c.equals(S))&&(this._isProper=!1),this._result=Ji.POINT_INTERSECTION,null;this._result=Ji.NO_INTERSECTION}},{key:"intersection",value:function(c,g,S,R){var F=this.intersectionSafe(c,g,S,R);return this.isInSegmentEnvelopes(F)||(F=new Fe(l.nearestEndpoint(c,g,S,R))),this._precisionModel!==null&&this._precisionModel.makePrecise(F),F}},{key:"checkDD",value:function(c,g,S,R,F){var q=zo.intersection(c,g,S,R),Q=this.isInSegmentEnvelopes(q);ce.out.println("DD in env = "+Q+" --------------------- "+q),F.distance(q)>1e-4&&ce.out.println("Distance = "+F.distance(q))}},{key:"intersectionSafe",value:function(c,g,S,R){var F=gs.intersection(c,g,S,R);return F===null&&(F=l.nearestEndpoint(c,g,S,R)),F}},{key:"computeCollinearIntersection",value:function(c,g,S,R){var F=Ci.intersects(c,g,S),q=Ci.intersects(c,g,R),Q=Ci.intersects(S,R,c),Ee=Ci.intersects(S,R,g);return F&&q?(this._intPt[0]=S,this._intPt[1]=R,Ji.COLLINEAR_INTERSECTION):Q&&Ee?(this._intPt[0]=c,this._intPt[1]=g,Ji.COLLINEAR_INTERSECTION):F&&Q?(this._intPt[0]=S,this._intPt[1]=c,!S.equals(c)||q||Ee?Ji.COLLINEAR_INTERSECTION:Ji.POINT_INTERSECTION):F&&Ee?(this._intPt[0]=S,this._intPt[1]=g,!S.equals(g)||q||Q?Ji.COLLINEAR_INTERSECTION:Ji.POINT_INTERSECTION):q&&Q?(this._intPt[0]=R,this._intPt[1]=c,!R.equals(c)||F||Ee?Ji.COLLINEAR_INTERSECTION:Ji.POINT_INTERSECTION):q&&Ee?(this._intPt[0]=R,this._intPt[1]=g,!R.equals(g)||F||Q?Ji.COLLINEAR_INTERSECTION:Ji.POINT_INTERSECTION):Ji.NO_INTERSECTION}},{key:"computeIntersect",value:function(c,g,S,R){if(this._isProper=!1,!Ci.intersects(c,g,S,R))return Ji.NO_INTERSECTION;var F=Yt.index(c,g,S),q=Yt.index(c,g,R);if(F>0&&q>0||F<0&&q<0)return Ji.NO_INTERSECTION;var Q=Yt.index(S,R,c),Ee=Yt.index(S,R,g);return Q>0&&Ee>0||Q<0&&Ee<0?Ji.NO_INTERSECTION:F===0&&q===0&&Q===0&&Ee===0?this.computeCollinearIntersection(c,g,S,R):(F===0||q===0||Q===0||Ee===0?(this._isProper=!1,c.equals2D(S)||c.equals2D(R)?this._intPt[0]=c:g.equals2D(S)||g.equals2D(R)?this._intPt[0]=g:F===0?this._intPt[0]=new Fe(S):q===0?this._intPt[0]=new Fe(R):Q===0?this._intPt[0]=new Fe(c):Ee===0&&(this._intPt[0]=new Fe(g))):(this._isProper=!0,this._intPt[0]=this.intersection(c,g,S,R)),Ji.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(c,g,S,R){var F=c,q=W.pointToSegment(c,S,R),Q=W.pointToSegment(g,S,R);return Qg&&(c=l.x,g=o.x),this._p.x>=c&&this._p.x<=g&&(this._isPointOnSegment=!0),null}if(o.y>this._p.y&&l.y<=this._p.y||l.y>this._p.y&&o.y<=this._p.y){var S=Yt.index(o,l,this._p);if(S===Yt.COLLINEAR)return this._isPointOnSegment=!0,null;l.ythis.location.length){var l=new Array(3).fill(null);l[ct.ON]=this.location[ct.ON],l[ct.LEFT]=me.NONE,l[ct.RIGHT]=me.NONE,this.location=l}for(var c=0;c1&&o.append(me.toLocationSymbol(this.location[ct.LEFT])),o.append(me.toLocationSymbol(this.location[ct.ON])),this.location.length>1&&o.append(me.toLocationSymbol(this.location[ct.RIGHT])),o.toString()}},{key:"setLocations",value:function(o,l,c){this.location[ct.ON]=o,this.location[ct.LEFT]=l,this.location[ct.RIGHT]=c}},{key:"get",value:function(o){return o1}},{key:"isAnyNull",value:function(){for(var o=0;othis._maxNodeDegree&&(this._maxNodeDegree=l),o=this.getNext(o)}while(o!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(o,l,c){var g=o.getCoordinates();if(l){var S=1;c&&(S=0);for(var R=S;R=0;q--)this._pts.add(g[q])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var o=this._startDe;do o.getEdge().setInResult(!0),o=o.getNext();while(o!==this._startDe)}},{key:"containsPoint",value:function(o){var l=this.getLinearRing();if(!l.getEnvelopeInternal().contains(o)||!jo.isInRing(o,l.getCoordinates()))return!1;for(var c=this._holes.iterator();c.hasNext();)if(c.next().containsPoint(o))return!1;return!0}},{key:"addHole",value:function(o){this._holes.add(o)}},{key:"isShell",value:function(){return this._shell===null}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(arguments.length===1){var o=arguments[0];this.mergeLabel(o,0),this.mergeLabel(o,1)}else if(arguments.length===2){var l=arguments[0],c=arguments[1],g=l.getLocation(c,ct.RIGHT);if(g===me.NONE)return null;if(this._label.getLocation(c)===me.NONE)return this._label.setLocation(c,g),null}}},{key:"setShell",value:function(o){this._shell=o,o!==null&&o.addHole(this)}},{key:"toPolygon",value:function(o){for(var l=new Array(this._holes.size()).fill(null),c=0;c=2,"found partial label"),this.computeIM(o)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this._label=o}}}}]),v}(),Nn=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"isIncidentEdgeInResult",value:function(){for(var c=this.getEdges().getEdges().iterator();c.hasNext();)if(c.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(c){c.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(c){}},{key:"computeMergedLocation",value:function(c,g){var S=me.NONE;if(S=this._label.getLocation(g),!c.isNull(g)){var R=c.getLocation(g);S!==me.BOUNDARY&&(S=R)}return S}},{key:"setLabel",value:function(){if(arguments.length!==2||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return Ie($(l.prototype),"setLabel",this).apply(this,arguments);var c=arguments[0],g=arguments[1];this._label===null?this._label=new On(c,g):this._label.setLocation(c,g)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof l){var c=arguments[0];this.mergeLabel(c._label)}else if(arguments[0]instanceof On)for(var g=arguments[0],S=0;S<2;S++){var R=this.computeMergedLocation(g,S),F=this._label.getLocation(S);F===me.NONE&&this._label.setLocation(S,R)}}},{key:"add",value:function(c){this._edges.insert(c),c.setNode(this)}},{key:"setLabelBoundary",value:function(c){if(this._label===null)return null;var g=me.NONE;this._label!==null&&(g=this._label.getLocation(c));var S=null;switch(g){case me.BOUNDARY:S=me.INTERIOR;break;case me.INTERIOR:default:S=me.BOUNDARY}this._label.setLocation(c,S)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var c=arguments[0],g=arguments[1];this._coord=c,this._edges=g,this._label=new On(0,me.NONE)}}]),l}(va),wr=function(v){O(l,v);var o=ye(l);function l(){return w(this,l),o.apply(this,arguments)}return l}(_a);function hl(v){return v==null?0:v.color}function Ei(v){return v==null?null:v.parent}function Li(v,o){v!==null&&(v.color=o)}function Vo(v){return v==null?null:v.left}function xa(v){return v==null?null:v.right}var Nr=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),(c=o.call(this)).root_=null,c.size_=0,c}return A(l,[{key:"get",value:function(c){for(var g=this.root_;g!==null;){var S=c.compareTo(g.key);if(S<0)g=g.left;else{if(!(S>0))return g.value;g=g.right}}return null}},{key:"put",value:function(c,g){if(this.root_===null)return this.root_={key:c,value:g,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var S,R,F=this.root_;do if(S=F,(R=c.compareTo(F.key))<0)F=F.left;else{if(!(R>0)){var q=F.value;return F.value=g,q}F=F.right}while(F!==null);var Q={key:c,left:null,right:null,value:g,parent:S,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return R<0?S.left=Q:S.right=Q,this.fixAfterInsertion(Q),this.size_++,null}},{key:"fixAfterInsertion",value:function(c){var g;for(c.color=1;c!=null&&c!==this.root_&&c.parent.color===1;)Ei(c)===Vo(Ei(Ei(c)))?hl(g=xa(Ei(Ei(c))))===1?(Li(Ei(c),0),Li(g,0),Li(Ei(Ei(c)),1),c=Ei(Ei(c))):(c===xa(Ei(c))&&(c=Ei(c),this.rotateLeft(c)),Li(Ei(c),0),Li(Ei(Ei(c)),1),this.rotateRight(Ei(Ei(c)))):hl(g=Vo(Ei(Ei(c))))===1?(Li(Ei(c),0),Li(g,0),Li(Ei(Ei(c)),1),c=Ei(Ei(c))):(c===Vo(Ei(c))&&(c=Ei(c),this.rotateRight(c)),Li(Ei(c),0),Li(Ei(Ei(c)),1),this.rotateLeft(Ei(Ei(c))));this.root_.color=0}},{key:"values",value:function(){var c=new qt,g=this.getFirstEntry();if(g!==null)for(c.add(g.value);(g=l.successor(g))!==null;)c.add(g.value);return c}},{key:"entrySet",value:function(){var c=new ps,g=this.getFirstEntry();if(g!==null)for(c.add(g);(g=l.successor(g))!==null;)c.add(g);return c}},{key:"rotateLeft",value:function(c){if(c!=null){var g=c.right;c.right=g.left,g.left!=null&&(g.left.parent=c),g.parent=c.parent,c.parent==null?this.root_=g:c.parent.left===c?c.parent.left=g:c.parent.right=g,g.left=c,c.parent=g}}},{key:"rotateRight",value:function(c){if(c!=null){var g=c.left;c.left=g.right,g.right!=null&&(g.right.parent=c),g.parent=c.parent,c.parent==null?this.root_=g:c.parent.right===c?c.parent.right=g:c.parent.left=g,g.right=c,c.parent=g}}},{key:"getFirstEntry",value:function(){var c=this.root_;if(c!=null)for(;c.left!=null;)c=c.left;return c}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(c){for(var g=this.root_;g!==null;){var S=c.compareTo(g.key);if(S<0)g=g.left;else{if(!(S>0))return!0;g=g.right}}return!1}}],[{key:"successor",value:function(c){var g;if(c===null)return null;if(c.right!==null){for(g=c.right;g.left!==null;)g=g.left;return g}g=c.parent;for(var S=c;g!==null&&S===g.right;)S=g,g=g.parent;return g}}]),l}(wr),Pn=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"find",value:function(o){return this.nodeMap.get(o)}},{key:"addNode",value:function(){if(arguments[0]instanceof Fe){var o=arguments[0],l=this.nodeMap.get(o);return l===null&&(l=this.nodeFact.createNode(o),this.nodeMap.put(o,l)),l}if(arguments[0]instanceof Nn){var c=arguments[0],g=this.nodeMap.get(c.getCoordinate());return g===null?(this.nodeMap.put(c.getCoordinate(),c),c):(g.mergeLabel(c),g)}}},{key:"print",value:function(o){for(var l=this.iterator();l.hasNext();)l.next().print(o)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(o){for(var l=new qt,c=this.iterator();c.hasNext();){var g=c.next();g.getLabel().getLocation(o)===me.BOUNDARY&&l.add(g)}return l}},{key:"add",value:function(o){var l=o.getCoordinate();this.addNode(l).add(o)}}],[{key:"constructor_",value:function(){this.nodeMap=new Nr,this.nodeFact=null;var o=arguments[0];this.nodeFact=o}}]),v}(),Bn=function(){function v(){w(this,v)}return A(v,null,[{key:"isNorthern",value:function(o){return o===v.NE||o===v.NW}},{key:"isOpposite",value:function(o,l){return o!==l&&(o-l+4)%4===2}},{key:"commonHalfPlane",value:function(o,l){if(o===l)return o;if((o-l+4)%4===2)return-1;var c=ol?o:l)===3?3:c}},{key:"isInHalfPlane",value:function(o,l){return l===v.SE?o===v.SE||o===v.SW:o===l||o===l+1}},{key:"quadrant",value:function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var o=arguments[0],l=arguments[1];if(o===0&&l===0)throw new ut("Cannot compute the quadrant for point ( "+o+", "+l+" )");return o>=0?l>=0?v.NE:v.SE:l>=0?v.NW:v.SW}if(arguments[0]instanceof Fe&&arguments[1]instanceof Fe){var c=arguments[0],g=arguments[1];if(g.x===c.x&&g.y===c.y)throw new ut("Cannot compute the quadrant for two identical points "+c);return g.x>=c.x?g.y>=c.y?v.NE:v.SE:g.y>=c.y?v.NW:v.SW}}}]),v}();Bn.NE=0,Bn.NW=1,Bn.SW=2,Bn.SE=3;var ba=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"compareDirection",value:function(o){return this._dx===o._dx&&this._dy===o._dy?0:this._quadrant>o._quadrant?1:this._quadrant2){R.linkDirectedEdgesForMinimalEdgeRings();var F=R.buildMinimalRings(),q=this.findShell(F);q!==null?(this.placePolygonHoles(q,F),l.add(q)):c.addAll(F)}else g.add(R)}return g}},{key:"buildMaximalEdgeRings",value:function(o){for(var l=new qt,c=o.iterator();c.hasNext();){var g=c.next();if(g.isInResult()&&g.getLabel().isArea()&&g.getEdgeRing()===null){var S=new cl(g,this._geometryFactory);l.add(S),S.setInResult()}}return l}},{key:"placePolygonHoles",value:function(o,l){for(var c=l.iterator();c.hasNext();){var g=c.next();g.isHole()&&g.setShell(o)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(o){for(var l=0,c=null,g=o.iterator();g.hasNext();){var S=g.next();S.isHole()||(c=S,l++)}return Dt.isTrue(l<=1,"found two shells in MinimalEdgeRing list"),c}},{key:"add",value:function(){if(arguments.length===1){var o=arguments[0];this.add(o.getEdgeEnds(),o.getNodes())}else if(arguments.length===2){var l=arguments[0],c=arguments[1];Gs.linkResultDirectedEdges(c);var g=this.buildMaximalEdgeRings(l),S=new qt,R=this.buildMinimalEdgeRings(g,this._shellList,S);this.sortShellsAndHoles(R,this._shellList,S),this.placeFreeHoles(this._shellList,S)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new qt;var o=arguments[0];this._geometryFactory=o}},{key:"findEdgeRingContaining",value:function(o,l){for(var c=o.getLinearRing(),g=c.getEnvelopeInternal(),S=c.getCoordinateN(0),R=null,F=null,q=l.iterator();q.hasNext();){var Q=q.next(),Ee=Q.getLinearRing(),Me=Ee.getEnvelopeInternal();if(!Me.equals(g)&&Me.contains(g)){S=dn.ptNotInList(c.getCoordinates(),Ee.getCoordinates());var Xe=!1;jo.isInRing(S,Ee.getCoordinates())&&(Xe=!0),Xe&&(R===null||F.contains(Me))&&(F=(R=Q).getLinearRing().getEnvelopeInternal())}}return R}}]),v}(),wa=function(){function v(){w(this,v)}return A(v,[{key:"getBounds",value:function(){}}]),v}(),rr=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[wa,Oe]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var o=arguments[0],l=arguments[1];this._bounds=o,this._item=l}}]),v}(),mr=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"poll",value:function(){if(this.isEmpty())return null;var o=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),o}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(o){for(var l=null,c=this._items.get(o);2*o<=this._size&&((l=2*o)!==this._size&&this._items.get(l+1).compareTo(this._items.get(l))<0&&l++,this._items.get(l).compareTo(c)<0);o=l)this._items.set(o,this._items.get(l));this._items.set(o,c)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return this._size===0}},{key:"add",value:function(o){this._items.add(null),this._size+=1;var l=this._size;for(this._items.set(0,o);o.compareTo(this._items.get(Math.trunc(l/2)))<0;l/=2)this._items.set(l,this._items.get(Math.trunc(l/2)));this._items.set(l,o)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new qt,this._items.add(null)}}]),v}(),fl=function(){function v(){w(this,v)}return A(v,[{key:"insert",value:function(o,l){}},{key:"remove",value:function(o,l){}},{key:"query",value:function(){}}]),v}(),Ln=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(o){Dt.isTrue(this._bounds===null),this._childBoundables.add(o)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return this._bounds===null&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[wa,Oe]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new qt,this._bounds=null,this._level=null,arguments.length!==0){if(arguments.length===1){var o=arguments[0];this._level=o}}}}]),v}(),or={reverseOrder:function(){return{compare:function(v,o){return o.compareTo(v)}}},min:function(v){return or.sort(v),v.get(0)},sort:function(v,o){var l=v.toArray();o?Zt.sort(l,o):Zt.sort(l);for(var c=v.iterator(),g=0,S=l.length;gv.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,o,l),null):(this.expand(this._boundable2,this._boundable1,!0,o,l),null);if(c)return this.expand(this._boundable1,this._boundable2,!1,o,l),null;if(g)return this.expand(this._boundable2,this._boundable1,!0,o,l),null;throw new ut("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(v.isComposite(this._boundable1)||v.isComposite(this._boundable2))}},{key:"compareTo",value:function(o){var l=o;return this._distancel._distance?1:0}},{key:"expand",value:function(o,l,c,g,S){for(var R=o.getChildBoundables().iterator();R.hasNext();){var F=R.next(),q=null;(q=c?new v(l,F,this._itemDistance):new v(F,l,this._itemDistance)).getDistance()-2),g.getLevel()===c)return S.add(g),null;for(var R=g.getChildBoundables().iterator();R.hasNext();){var F=R.next();F instanceof Ln?this.boundablesAtLevel(c,F,S):(Dt.isTrue(F instanceof rr),c===-1&&S.add(F))}return null}}},{key:"query",value:function(){if(arguments.length===1){var o=arguments[0];this.build();var l=new qt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),o)&&this.queryInternal(o,this._root,l),l}if(arguments.length===2){var c=arguments[0],g=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),c)&&this.queryInternal(c,this._root,g)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(arguments.length===2){var o=arguments[0],l=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),o)&&this.remove(o,this._root,l)}if(arguments.length===3){var c=arguments[0],g=arguments[1],S=arguments[2],R=this.removeItem(g,S);if(R)return!0;for(var F=null,q=g.getChildBoundables().iterator();q.hasNext();){var Q=q.next();if(this.getIntersectsOp().intersects(Q.getBounds(),c)&&Q instanceof Ln&&(R=this.remove(c,Q,S))){F=Q;break}}return F!==null&&F.getChildBoundables().isEmpty()&&g.getChildBoundables().remove(F),R}}},{key:"createHigherLevels",value:function(o,l){Dt.isTrue(!o.isEmpty());var c=this.createParentBoundables(o,l+1);return c.size()===1?c.get(0):this.createHigherLevels(c,l+1)}},{key:"depth",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(arguments.length===1){for(var o=arguments[0],l=0,c=o.getChildBoundables().iterator();c.hasNext();){var g=c.next();if(g instanceof Ln){var S=this.depth(g);S>l&&(l=S)}}return l+1}}},{key:"createParentBoundables",value:function(o,l){Dt.isTrue(!o.isEmpty());var c=new qt;c.add(this.createNode(l));var g=new qt(o);or.sort(g,this.getComparator());for(var S=g.iterator();S.hasNext();){var R=S.next();this.lastNode(c).getChildBoundables().size()===this.getNodeCapacity()&&c.add(this.createNode(l)),this.lastNode(c).addChildBoundable(R)}return c}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[Oe]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new qt,this._nodeCapacity=null,arguments.length===0)v.constructor_.call(this,v.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var o=arguments[0];Dt.isTrue(o>1,"Node capacity must be greater than 1"),this._nodeCapacity=o}}},{key:"compareDoubles",value:function(o,l){return o>l?1:o0);for(var S=new qt,R=0;R=0;){var Me=Q.poll(),Xe=Me.getDistance();if(Xe>=q)break;if(Me.isLeaves())if(Ee.size()Xe&&(Ee.poll(),Ee.add(Me));var dt=Ee.peek();q=dt.getDistance()}else Me.expandToQueue(Q,q)}return l.getItems(Ee)}}},{key:"createNode",value:function(c){return new Xs(c)}},{key:"size",value:function(){return arguments.length===0?Ie($(l.prototype),"size",this).call(this):Ie($(l.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof Ci))return Ie($(l.prototype),"insert",this).apply(this,arguments);var c=arguments[0],g=arguments[1];if(c.isNull())return null;Ie($(l.prototype),"insert",this).call(this,c,g)}},{key:"getIntersectsOp",value:function(){return l.intersectsOp}},{key:"verticalSlices",value:function(c,g){for(var S=Math.trunc(Math.ceil(c.size()/g)),R=new Array(g).fill(null),F=c.iterator(),q=0;q0;){var Q=q.poll(),Ee=Q.getDistance();if(Ee>=R)break;Q.isLeaves()?(R=Ee,F=Q):Q.expandToQueue(q,R)}return F===null?null:[F.getBoundable(0).getItem(),F.getBoundable(1).getItem()]}}else{if(arguments.length===2){var Me=arguments[0],Xe=arguments[1];if(this.isEmpty()||Me.isEmpty())return null;var pt=new sr(this.getRoot(),Me.getRoot(),Xe);return this.nearestNeighbour(pt)}if(arguments.length===3){var dt=arguments[0],Vt=arguments[1],Ut=arguments[2],ei=new rr(dt,Vt),yi=new sr(this.getRoot(),ei,Ut);return this.nearestNeighbour(yi)[0]}if(arguments.length===4){var Xi=arguments[0],Fn=arguments[1],bn=arguments[2],Vn=arguments[3],Ir=new rr(Xi,Fn),Hr=new sr(this.getRoot(),Ir,bn);return this.nearestNeighbourK(Hr,Vn)}}}},{key:"isWithinDistance",value:function(){if(arguments.length===2){var c=arguments[0],g=arguments[1],S=St.POSITIVE_INFINITY,R=new mr;for(R.add(c);!R.isEmpty();){var F=R.poll(),q=F.getDistance();if(q>g)return!1;if(F.maximumDistance()<=g)return!0;if(F.isLeaves()){if((S=q)<=g)return!0}else F.expandToQueue(R,S)}return!1}if(arguments.length===3){var Q=arguments[0],Ee=arguments[1],Me=arguments[2],Xe=new sr(this.getRoot(),Q.getRoot(),Ee);return this.isWithinDistance(Xe,Me)}}},{key:"interfaces_",get:function(){return[fl,Oe]}}],[{key:"constructor_",value:function(){if(arguments.length===0)l.constructor_.call(this,l.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var c=arguments[0];Fr.constructor_.call(this,c)}}},{key:"centreX",value:function(c){return l.avg(c.getMinX(),c.getMaxX())}},{key:"avg",value:function(c,g){return(c+g)/2}},{key:"getItems",value:function(c){for(var g=new Array(c.size()).fill(null),S=0;!c.isEmpty();){var R=c.poll();g[S]=R.getBoundable(0).getItem(),S++}return g}},{key:"centreY",value:function(c){return l.avg(c.getMinY(),c.getMaxY())}}]),l}(Fr),Xs=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"computeBounds",value:function(){for(var c=null,g=this.getChildBoundables().iterator();g.hasNext();){var S=g.next();c===null?c=new Ci(S.getBounds()):c.expandToInclude(S.getBounds())}return c}}],[{key:"constructor_",value:function(){var c=arguments[0];Ln.constructor_.call(this,c)}}]),l}(Ln);Ur.STRtreeNode=Xs,Ur.xComparator=new(function(){function v(){w(this,v)}return A(v,[{key:"interfaces_",get:function(){return[wi]}},{key:"compare",value:function(o,l){return Fr.compareDoubles(Ur.centreX(o.getBounds()),Ur.centreX(l.getBounds()))}}]),v}()),Ur.yComparator=new(function(){function v(){w(this,v)}return A(v,[{key:"interfaces_",get:function(){return[wi]}},{key:"compare",value:function(o,l){return Fr.compareDoubles(Ur.centreY(o.getBounds()),Ur.centreY(l.getBounds()))}}]),v}()),Ur.intersectsOp=new(function(){function v(){w(this,v)}return A(v,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(o,l){return o.intersects(l)}}]),v}()),Ur.DEFAULT_NODE_CAPACITY=10;var pl=function(){function v(){w(this,v)}return A(v,null,[{key:"relativeSign",value:function(o,l){return ol?1:0}},{key:"compare",value:function(o,l,c){if(l.equals2D(c))return 0;var g=v.relativeSign(l.x,c.x),S=v.relativeSign(l.y,c.y);switch(o){case 0:return v.compareValue(g,S);case 1:return v.compareValue(S,g);case 2:return v.compareValue(S,-g);case 3:return v.compareValue(-g,S);case 4:return v.compareValue(-g,-S);case 5:return v.compareValue(-S,-g);case 6:return v.compareValue(-S,g);case 7:return v.compareValue(g,-S)}return Dt.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(o,l){return o<0?-1:o>0?1:l<0?-1:l>0?1:0}}]),v}(),dl=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(o){o.print(this.coord),o.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(o){var l=o;return this.segmentIndexl.segmentIndex?1:this.coord.equals2D(l.coord)?0:this._isInterior?l._isInterior?pl.compare(this._segmentOctant,this.coord,l.coord):1:-1}},{key:"isEndPoint",value:function(o){return this.segmentIndex===0&&!this._isInterior||this.segmentIndex===o}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var o=arguments[0],l=arguments[1],c=arguments[2],g=arguments[3];this._segString=o,this.coord=new Fe(l),this.segmentIndex=c,this._segmentOctant=g,this._isInterior=!l.equals2D(o.getCoordinate(c))}}]),v}(),_s=function(){function v(){w(this,v)}return A(v,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),v}(),Si=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getSplitCoordinates",value:function(){var o=new xi;this.addEndpoints();for(var l=this.iterator(),c=l.next();l.hasNext();){var g=l.next();this.addEdgeCoordinates(c,g,o),c=g}return o.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var o=new qt;this.findCollapsesFromInsertedNodes(o),this.findCollapsesFromExistingVertices(o);for(var l=o.iterator();l.hasNext();){var c=l.next().intValue();this.add(this._edge.getCoordinate(c),c)}}},{key:"createSplitEdgePts",value:function(o,l){var c=l.segmentIndex-o.segmentIndex+2;if(c===2)return[new Fe(o.coord),new Fe(l.coord)];var g=this._edge.getCoordinate(l.segmentIndex),S=l.isInterior()||!l.coord.equals2D(g);S||c--;var R=new Array(c).fill(null),F=0;R[F++]=new Fe(o.coord);for(var q=o.segmentIndex+1;q<=l.segmentIndex;q++)R[F++]=this._edge.getCoordinate(q);return S&&(R[F]=new Fe(l.coord)),R}},{key:"print",value:function(o){o.println("Intersections:");for(var l=this.iterator();l.hasNext();)l.next().print(o)}},{key:"findCollapsesFromExistingVertices",value:function(o){for(var l=0;l=0?l>=0?c>=g?0:1:c>=g?7:6:l>=0?c>=g?3:2:c>=g?4:5}if(arguments[0]instanceof Fe&&arguments[1]instanceof Fe){var S=arguments[0],R=arguments[1],F=R.x-S.x,q=R.y-S.y;if(F===0&&q===0)throw new ut("Cannot compute the octant for two identical points "+S);return v.octant(F,q)}}}]),v}(),ml=function(){function v(){w(this,v)}return A(v,[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(o){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(o){}},{key:"getData",value:function(){}}]),v}(),pu=function(){function v(){w(this,v)}return A(v,[{key:"addIntersection",value:function(o,l){}},{key:"interfaces_",get:function(){return[ml]}}]),v}(),ao=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(o){return this._pts[o]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(o){return o===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(o),this.getCoordinate(o+1))}},{key:"setData",value:function(o){this._data=o}},{key:"safeOctant",value:function(o,l){return o.equals2D(l)?0:xc.octant(o,l)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(arguments.length===2){var o=arguments[0],l=arguments[1];this.addIntersectionNode(o,l)}else if(arguments.length===4){var c=arguments[0],g=arguments[1],S=arguments[3],R=new Fe(c.getIntersection(S));this.addIntersection(R,g)}}},{key:"toString",value:function(){return Uo.toLineString(new ir(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(o,l){var c=l,g=c+1;if(g=0&&c>=0||l<=0&&c<=0?Math.max(l,c):0}if(arguments[0]instanceof Fe){var g=arguments[0];return Yt.index(this.p0,this.p1,g)}}},{key:"toGeometry",value:function(o){return o.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(o){if(!(o instanceof v))return!1;var l=o;return this.p0.equals(l.p0)&&this.p1.equals(l.p1)}},{key:"intersection",value:function(o){var l=new To;return l.computeIntersection(this.p0,this.p1,o.p0,o.p1),l.hasIntersection()?l.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof Fe){var o=arguments[0];if(o.equals(this.p0)||o.equals(this.p1))return new Fe(o);var l=this.projectionFactor(o),c=new Fe;return c.x=this.p0.x+l*(this.p1.x-this.p0.x),c.y=this.p0.y+l*(this.p1.y-this.p0.y),c}if(arguments[0]instanceof v){var g=arguments[0],S=this.projectionFactor(g.p0),R=this.projectionFactor(g.p1);if(S>=1&&R>=1||S<=0&&R<=0)return null;var F=this.project(g.p0);S<0&&(F=this.p0),S>1&&(F=this.p1);var q=this.project(g.p1);return R<0&&(q=this.p0),R>1&&(q=this.p1),new v(F,q)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(o){return o===0?this.p0:this.p1}},{key:"distancePerpendicular",value:function(o){return W.pointToLinePerpendicular(o,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return v.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(o){if(o.equals(this.p0))return 0;if(o.equals(this.p1))return 1;var l=this.p1.x-this.p0.x,c=this.p1.y-this.p0.y,g=l*l+c*c;return g<=0?St.NaN:((o.x-this.p0.x)*l+(o.y-this.p0.y)*c)/g}},{key:"closestPoints",value:function(o){var l=this.intersection(o);if(l!==null)return[l,l];var c=new Array(2).fill(null),g=St.MAX_VALUE,S=null,R=this.closestPoint(o.p0);g=R.distance(o.p0),c[0]=R,c[1]=o.p0;var F=this.closestPoint(o.p1);(S=F.distance(o.p1))0&&l<1?this.project(o):this.p0.distance(o)1||St.isNaN(l))&&(l=1),l}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(o){var l=this.p1.getY()-this.p0.getY(),c=this.p0.getX()-this.p1.getX(),g=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),S=l*l+c*c,R=l*l-c*c,F=o.getX(),q=o.getY();return new Fe((-R*F-2*l*c*q-2*l*g)/S,(R*q-2*l*c*F-2*c*g)/S)}},{key:"distance",value:function(){if(arguments[0]instanceof v){var o=arguments[0];return W.segmentToSegment(this.p0,this.p1,o.p0,o.p1)}if(arguments[0]instanceof Fe){var l=arguments[0];return W.pointToSegment(l,this.p0,this.p1)}}},{key:"pointAlong",value:function(o){var l=new Fe;return l.x=this.p0.x+o*(this.p1.x-this.p0.x),l.y=this.p0.y+o*(this.p1.y-this.p0.y),l}},{key:"hashCode",value:function(){var o=St.doubleToLongBits(this.p0.x);o^=31*St.doubleToLongBits(this.p0.y);var l=Math.trunc(o)^Math.trunc(o>>32),c=St.doubleToLongBits(this.p1.x);return c^=31*St.doubleToLongBits(this.p1.y),l^(Math.trunc(c)^Math.trunc(c>>32))}},{key:"interfaces_",get:function(){return[_t,Oe]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,arguments.length===0)v.constructor_.call(this,new Fe,new Fe);else if(arguments.length===1){var o=arguments[0];v.constructor_.call(this,o.p0,o.p1)}else if(arguments.length===2){var l=arguments[0],c=arguments[1];this.p0=l,this.p1=c}else if(arguments.length===4){var g=arguments[0],S=arguments[1],R=arguments[2],F=arguments[3];v.constructor_.call(this,new Fe(g,S),new Fe(R,F))}}},{key:"midPoint",value:function(o,l){return new Fe((o.x+l.x)/2,(o.y+l.y)/2)}}]),v}(),gl=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"overlap",value:function(){if(arguments.length!==2){if(arguments.length===4){var o=arguments[0],l=arguments[1],c=arguments[2],g=arguments[3];o.getLineSegment(l,this._overlapSeg1),c.getLineSegment(g,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new ar,this._overlapSeg2=new ar}}]),v}(),Go=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getLineSegment",value:function(o,l){l.p0=this._pts[o],l.p1=this._pts[o+1]}},{key:"computeSelect",value:function(o,l,c,g){var S=this._pts[l],R=this._pts[c];if(c-l==1)return g.select(this,l),null;if(!o.intersects(S,R))return null;var F=Math.trunc((l+c)/2);l=o.length-1)return o.length-1;for(var g=Bn.quadrant(o[c],o[c+1]),S=l+1;SS.getId()&&(S.computeOverlaps(F,c),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new qt,this._index=new Ur,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,arguments.length!==0){if(arguments.length===1){var c=arguments[0];Wr.constructor_.call(this,c)}}}}]),l}(Wr),Ws=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"overlap",value:function(){if(arguments.length!==4)return Ie($(l.prototype),"overlap",this).apply(this,arguments);var c=arguments[0],g=arguments[1],S=arguments[2],R=arguments[3],F=c.getContext(),q=S.getContext();this._si.processIntersections(F,g,q,R)}}],[{key:"constructor_",value:function(){this._si=null;var c=arguments[0];this._si=c}}]),l}(gl);lo.SegmentOverlapAction=Ws;var Er=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"isDeletable",value:function(o,l,c,g){var S=this._inputLine[o],R=this._inputLine[l],F=this._inputLine[c];return!!this.isConcave(S,R,F)&&!!this.isShallow(S,R,F,g)&&this.isShallowSampled(S,R,o,c,g)}},{key:"deleteShallowConcavities",value:function(){for(var o=1,l=this.findNextNonDeletedIndex(o),c=this.findNextNonDeletedIndex(l),g=!1;c=0;g--)this.addPt(o[g])}},{key:"isRedundant",value:function(o){if(this._ptList.size()<1)return!1;var l=this._ptList.get(this._ptList.size()-1);return o.distance(l)Math.PI;)o-=v.PI_TIMES_2;for(;o<=-Math.PI;)o+=v.PI_TIMES_2;return o}},{key:"angle",value:function(){if(arguments.length===1){var o=arguments[0];return Math.atan2(o.y,o.x)}if(arguments.length===2){var l=arguments[0],c=arguments[1],g=c.x-l.x,S=c.y-l.y;return Math.atan2(S,g)}}},{key:"isAcute",value:function(o,l,c){var g=o.x-l.x,S=o.y-l.y;return g*(c.x-l.x)+S*(c.y-l.y)>0}},{key:"isObtuse",value:function(o,l,c){var g=o.x-l.x,S=o.y-l.y;return g*(c.x-l.x)+S*(c.y-l.y)<0}},{key:"interiorAngle",value:function(o,l,c){var g=v.angle(l,o),S=v.angle(l,c);return Math.abs(S-g)}},{key:"normalizePositive",value:function(o){if(o<0){for(;o<0;)o+=v.PI_TIMES_2;o>=v.PI_TIMES_2&&(o=0)}else{for(;o>=v.PI_TIMES_2;)o-=v.PI_TIMES_2;o<0&&(o=0)}return o}},{key:"angleBetween",value:function(o,l,c){var g=v.angle(l,o),S=v.angle(l,c);return v.diff(g,S)}},{key:"diff",value:function(o,l){var c=null;return(c=oMath.PI&&(c=2*Math.PI-c),c}},{key:"toRadians",value:function(o){return o*Math.PI/180}},{key:"getTurn",value:function(o,l){var c=Math.sin(l-o);return c>0?v.COUNTERCLOCKWISE:c<0?v.CLOCKWISE:v.NONE}},{key:"angleBetweenOriented",value:function(o,l,c){var g=v.angle(l,o),S=v.angle(l,c)-g;return S<=-Math.PI?S+v.PI_TIMES_2:S>Math.PI?S-v.PI_TIMES_2:S}}]),v}();Hn.PI_TIMES_2=2*Math.PI,Hn.PI_OVER_2=Math.PI/2,Hn.PI_OVER_4=Math.PI/4,Hn.COUNTERCLOCKWISE=Yt.COUNTERCLOCKWISE,Hn.CLOCKWISE=Yt.CLOCKWISE,Hn.NONE=Yt.COLLINEAR;var $o=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"addNextSegment",value:function(o,l){if(this._s0=this._s1,this._s1=this._s2,this._s2=o,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var c=Yt.index(this._s0,this._s1,this._s2),g=c===Yt.CLOCKWISE&&this._side===ct.LEFT||c===Yt.COUNTERCLOCKWISE&&this._side===ct.RIGHT;c===0?this.addCollinear(l):g?this.addOutsideTurn(c,l):this.addInsideTurn(c,l)}},{key:"addLineEndCap",value:function(o,l){var c=new ar(o,l),g=new ar;this.computeOffsetSegment(c,ct.LEFT,this._distance,g);var S=new ar;this.computeOffsetSegment(c,ct.RIGHT,this._distance,S);var R=l.x-o.x,F=l.y-o.y,q=Math.atan2(F,R);switch(this._bufParams.getEndCapStyle()){case Qe.CAP_ROUND:this._segList.addPt(g.p1),this.addDirectedFillet(l,q+Math.PI/2,q-Math.PI/2,Yt.CLOCKWISE,this._distance),this._segList.addPt(S.p1);break;case Qe.CAP_FLAT:this._segList.addPt(g.p1),this._segList.addPt(S.p1);break;case Qe.CAP_SQUARE:var Q=new Fe;Q.x=Math.abs(this._distance)*Math.cos(q),Q.y=Math.abs(this._distance)*Math.sin(q);var Ee=new Fe(g.p1.x+Q.x,g.p1.y+Q.y),Me=new Fe(S.p1.x+Q.x,S.p1.y+Q.y);this._segList.addPt(Ee),this._segList.addPt(Me)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(o,l,c,g){var S=gs.intersection(l.p0,l.p1,c.p0,c.p1);if(S!==null&&(g<=0?1:S.distance(o)/Math.abs(g))<=this._bufParams.getMitreLimit())return this._segList.addPt(S),null;this.addLimitedMitreJoin(l,c,g,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(o,l){if(this._offset0.p1.distance(this._offset1.p0)=Me&&(q-=2*Math.PI),this._segList.addPt(l),this.addDirectedFillet(o,q,Me,g,S),this._segList.addPt(c)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(o,l,c){this._s1=o,this._s2=l,this._side=c,this._seg1.setCoordinates(o,l),this.computeOffsetSegment(this._seg1,c,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(o,l,c,g){var S=this._seg0.p1,R=Hn.angle(S,this._seg0.p0),F=Hn.angleBetweenOriented(this._seg0.p0,S,this._seg1.p1)/2,q=Hn.normalize(R+F),Q=Hn.normalize(q+Math.PI),Ee=g*c,Me=c-Ee*Math.abs(Math.sin(F)),Xe=S.x+Ee*Math.cos(Q),pt=S.y+Ee*Math.sin(Q),dt=new Fe(Xe,pt),Vt=new ar(S,dt),Ut=Vt.pointAlongOffset(1,Me),ei=Vt.pointAlongOffset(1,-Me);this._side===ct.LEFT?(this._segList.addPt(Ut),this._segList.addPt(ei)):(this._segList.addPt(ei),this._segList.addPt(Ut))}},{key:"addDirectedFillet",value:function(o,l,c,g,S){var R=g===Yt.CLOCKWISE?-1:1,F=Math.abs(l-c),q=Math.trunc(F/this._filletAngleQuantum+.5);if(q<1)return null;for(var Q=F/q,Ee=new Fe,Me=0;Me0){var c=new Fe((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(c);var g=new Fe((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(g)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(o){var l=new Fe(o.x+this._distance,o.y);this._segList.addPt(l),this.addDirectedFillet(o,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(o,l){this._segList.addPt(o.p1),this._segList.addPt(l.p0)}},{key:"init",value:function(o){this._distance=o,this._maxCurveSegmentError=o*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new ys,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(o*v.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(o){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===Qe.JOIN_BEVEL||this._bufParams.getJoinStyle()===Qe.JOIN_MITRE?(o&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,Yt.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new ar,this._seg1=new ar,this._offset0=new ar,this._offset1=new ar,this._side=0,this._hasNarrowConcaveAngle=!1;var o=arguments[0],l=arguments[1],c=arguments[2];this._precisionModel=o,this._bufParams=l,this._li=new To,this._filletAngleQuantum=Math.PI/2/l.getQuadrantSegments(),l.getQuadrantSegments()>=8&&l.getJoinStyle()===Qe.JOIN_ROUND&&(this._closingSegLengthFactor=v.MAX_CLOSING_SEG_LEN_FACTOR),this.init(c)}}]),v}();$o.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,$o.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,$o.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,$o.MAX_CLOSING_SEG_LEN_FACTOR=80;var Ta=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getOffsetCurve",value:function(o,l){if(this._distance=l,l===0)return null;var c=l<0,g=Math.abs(l),S=this.getSegGen(g);o.length<=1?this.computePointCurve(o[0],S):this.computeOffsetCurve(o,c,S);var R=S.getCoordinates();return c&&dn.reverse(R),R}},{key:"computeSingleSidedBufferCurve",value:function(o,l,c){var g=this.simplifyTolerance(this._distance);if(l){c.addSegments(o,!0);var S=Er.simplify(o,-g),R=S.length-1;c.initSideSegments(S[R],S[R-1],ct.LEFT),c.addFirstSegment();for(var F=R-2;F>=0;F--)c.addNextSegment(S[F],!0)}else{c.addSegments(o,!1);var q=Er.simplify(o,g),Q=q.length-1;c.initSideSegments(q[0],q[1],ct.LEFT),c.addFirstSegment();for(var Ee=2;Ee<=Q;Ee++)c.addNextSegment(q[Ee],!0)}c.addLastSegment(),c.closeRing()}},{key:"computeRingBufferCurve",value:function(o,l,c){var g=this.simplifyTolerance(this._distance);l===ct.RIGHT&&(g=-g);var S=Er.simplify(o,g),R=S.length-1;c.initSideSegments(S[R-1],S[0],l);for(var F=1;F<=R;F++){var q=F!==1;c.addNextSegment(S[F],q)}c.closeRing()}},{key:"computeLineBufferCurve",value:function(o,l){var c=this.simplifyTolerance(this._distance),g=Er.simplify(o,c),S=g.length-1;l.initSideSegments(g[0],g[1],ct.LEFT);for(var R=2;R<=S;R++)l.addNextSegment(g[R],!0);l.addLastSegment(),l.addLineEndCap(g[S-1],g[S]);var F=Er.simplify(o,-c),q=F.length-1;l.initSideSegments(F[q],F[q-1],ct.LEFT);for(var Q=q-2;Q>=0;Q--)l.addNextSegment(F[Q],!0);l.addLastSegment(),l.addLineEndCap(F[1],F[0]),l.closeRing()}},{key:"computePointCurve",value:function(o,l){switch(this._bufParams.getEndCapStyle()){case Qe.CAP_ROUND:l.createCircle(o);break;case Qe.CAP_SQUARE:l.createSquare(o)}}},{key:"getLineCurve",value:function(o,l){if(this._distance=l,this.isLineOffsetEmpty(l))return null;var c=Math.abs(l),g=this.getSegGen(c);if(o.length<=1)this.computePointCurve(o[0],g);else if(this._bufParams.isSingleSided()){var S=l<0;this.computeSingleSidedBufferCurve(o,S,g)}else this.computeLineBufferCurve(o,g);return g.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(o){return o*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(o,l,c){if(this._distance=c,o.length<=2)return this.getLineCurve(o,c);if(c===0)return v.copyCoordinates(o);var g=this.getSegGen(c);return this.computeRingBufferCurve(o,l,g),g.getCoordinates()}},{key:"computeOffsetCurve",value:function(o,l,c){var g=this.simplifyTolerance(this._distance);if(l){var S=Er.simplify(o,-g),R=S.length-1;c.initSideSegments(S[R],S[R-1],ct.LEFT),c.addFirstSegment();for(var F=R-2;F>=0;F--)c.addNextSegment(S[F],!0)}else{var q=Er.simplify(o,g),Q=q.length-1;c.initSideSegments(q[0],q[1],ct.LEFT),c.addFirstSegment();for(var Ee=2;Ee<=Q;Ee++)c.addNextSegment(q[Ee],!0)}c.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(o){return o===0||o<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(o){return new $o(this._precisionModel,this._bufParams,o)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var o=arguments[0],l=arguments[1];this._precisionModel=o,this._bufParams=l}},{key:"copyCoordinates",value:function(o){for(var l=new Array(o.length).fill(null),c=0;cS.getMaxY()||this.findStabbedSegments(o,g.getDirectedEdges(),l)}return l}if(arguments.length===3){if(ii(arguments[2],Dr)&&arguments[0]instanceof Fe&&arguments[1]instanceof Br)for(var R=arguments[0],F=arguments[1],q=arguments[2],Q=F.getEdge().getCoordinates(),Ee=0;Eethis._seg.p1.y&&this._seg.reverse();var Me=Math.max(this._seg.p0.x,this._seg.p1.x);if(!(Methis._seg.p1.y||Yt.index(this._seg.p0,this._seg.p1,R)===Yt.RIGHT)){var Xe=F.getDepth(ct.LEFT);this._seg.p0.equals(Q[Ee])||(Xe=F.getDepth(ct.RIGHT));var pt=new Sa(this._seg,Xe);q.add(pt)}}else if(ii(arguments[2],Dr)&&arguments[0]instanceof Fe&&ii(arguments[1],Dr))for(var dt=arguments[0],Vt=arguments[1],Ut=arguments[2],ei=Vt.iterator();ei.hasNext();){var yi=ei.next();yi.isForward()&&this.findStabbedSegments(dt,yi,Ut)}}}},{key:"getDepth",value:function(o){var l=this.findStabbedSegments(o);return l.size()===0?0:or.min(l)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new ar;var o=arguments[0];this._subgraphs=o}}]),v}(),Sa=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"compareTo",value:function(o){var l=o;if(this._upwardSeg.minX()>=l._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=l._upwardSeg.minX())return-1;var c=this._upwardSeg.orientationIndex(l._upwardSeg);return c!==0||(c=-1*l._upwardSeg.orientationIndex(this._upwardSeg))!==0?c:this._upwardSeg.compareTo(l._upwardSeg)}},{key:"compareX",value:function(o,l){var c=o.p0.compareTo(l.p0);return c!==0?c:o.p1.compareTo(l.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var o=arguments[0],l=arguments[1];this._upwardSeg=new ar(o),this._leftDepth=l}}]),v}();Ys.DepthSegment=Sa;var bi=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,null,[{key:"constructor_",value:function(){Et.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),l}(Et),qo=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"getY",value:function(){var o=this.y/this.w;if(St.isNaN(o)||St.isInfinite(o))throw new bi;return o}},{key:"getX",value:function(){var o=this.x/this.w;if(St.isNaN(o)||St.isInfinite(o))throw new bi;return o}},{key:"getCoordinate",value:function(){var o=new Fe;return o.x=this.getX(),o.y=this.getY(),o}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,arguments.length===0)this.x=0,this.y=0,this.w=1;else if(arguments.length===1){var o=arguments[0];this.x=o.x,this.y=o.y,this.w=1}else if(arguments.length===2){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var l=arguments[0],c=arguments[1];this.x=l,this.y=c,this.w=1}else if(arguments[0]instanceof v&&arguments[1]instanceof v){var g=arguments[0],S=arguments[1];this.x=g.y*S.w-S.y*g.w,this.y=S.x*g.w-g.x*S.w,this.w=g.x*S.y-S.x*g.y}else if(arguments[0]instanceof Fe&&arguments[1]instanceof Fe){var R=arguments[0],F=arguments[1];this.x=R.y-F.y,this.y=F.x-R.x,this.w=R.x*F.y-F.x*R.y}}else if(arguments.length===3){var q=arguments[0],Q=arguments[1],Ee=arguments[2];this.x=q,this.y=Q,this.w=Ee}else if(arguments.length===4){var Me=arguments[0],Xe=arguments[1],pt=arguments[2],dt=arguments[3],Vt=Me.y-Xe.y,Ut=Xe.x-Me.x,ei=Me.x*Xe.y-Xe.x*Me.y,yi=pt.y-dt.y,Xi=dt.x-pt.x,Fn=pt.x*dt.y-dt.x*pt.y;this.x=Ut*Fn-Xi*ei,this.y=yi*ei-Vt*Fn,this.w=Vt*Xi-yi*Ut}}}]),v}(),du=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"area",value:function(){return v.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return v.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(o){if(o===null)throw new ut("Supplied point is null.");return v.interpolateZ(o,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return v.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return v.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return v.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return v.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return v.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return v.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var o=arguments[0],l=arguments[1],c=arguments[2];this.p0=o,this.p1=l,this.p2=c}},{key:"area",value:function(o,l,c){return Math.abs(((c.x-o.x)*(l.y-o.y)-(l.x-o.x)*(c.y-o.y))/2)}},{key:"signedArea",value:function(o,l,c){return((c.x-o.x)*(l.y-o.y)-(l.x-o.x)*(c.y-o.y))/2}},{key:"det",value:function(o,l,c,g){return o*g-l*c}},{key:"interpolateZ",value:function(o,l,c,g){var S=l.x,R=l.y,F=c.x-S,q=g.x-S,Q=c.y-R,Ee=g.y-R,Me=F*Ee-q*Q,Xe=o.x-S,pt=o.y-R,dt=(Ee*Xe-q*pt)/Me,Vt=(-Q*Xe+F*pt)/Me;return l.getZ()+dt*(c.getZ()-l.getZ())+Vt*(g.getZ()-l.getZ())}},{key:"longestSideLength",value:function(o,l,c){var g=o.distance(l),S=l.distance(c),R=c.distance(o),F=g;return S>F&&(F=S),R>F&&(F=R),F}},{key:"circumcentreDD",value:function(o,l,c){var g=$t.valueOf(o.x).subtract(c.x),S=$t.valueOf(o.y).subtract(c.y),R=$t.valueOf(l.x).subtract(c.x),F=$t.valueOf(l.y).subtract(c.y),q=$t.determinant(g,S,R,F).multiply(2),Q=g.sqr().add(S.sqr()),Ee=R.sqr().add(F.sqr()),Me=$t.determinant(S,Q,F,Ee),Xe=$t.determinant(g,Q,R,Ee),pt=$t.valueOf(c.x).subtract(Me.divide(q)).doubleValue(),dt=$t.valueOf(c.y).add(Xe.divide(q)).doubleValue();return new Fe(pt,dt)}},{key:"isAcute",value:function(o,l,c){return!!Hn.isAcute(o,l,c)&&!!Hn.isAcute(l,c,o)&&!!Hn.isAcute(c,o,l)}},{key:"circumcentre",value:function(o,l,c){var g=c.x,S=c.y,R=o.x-g,F=o.y-S,q=l.x-g,Q=l.y-S,Ee=2*v.det(R,F,q,Q),Me=v.det(F,R*R+F*F,Q,q*q+Q*Q),Xe=v.det(R,R*R+F*F,q,q*q+Q*Q);return new Fe(g-Me/Ee,S+Xe/Ee)}},{key:"perpendicularBisector",value:function(o,l){var c=l.x-o.x,g=l.y-o.y,S=new qo(o.x+c/2,o.y+g/2,1),R=new qo(o.x-g+c/2,o.y+c+g/2,1);return new qo(S,R)}},{key:"angleBisector",value:function(o,l,c){var g=l.distance(o),S=g/(g+l.distance(c)),R=c.x-o.x,F=c.y-o.y;return new Fe(o.x+S*R,o.y+S*F)}},{key:"area3D",value:function(o,l,c){var g=l.x-o.x,S=l.y-o.y,R=l.getZ()-o.getZ(),F=c.x-o.x,q=c.y-o.y,Q=c.getZ()-o.getZ(),Ee=S*Q-R*q,Me=R*F-g*Q,Xe=g*q-S*F,pt=Ee*Ee+Me*Me+Xe*Xe,dt=Math.sqrt(pt)/2;return dt}},{key:"centroid",value:function(o,l,c){var g=(o.x+l.x+c.x)/3,S=(o.y+l.y+c.y)/3;return new Fe(g,S)}},{key:"inCentre",value:function(o,l,c){var g=l.distance(c),S=o.distance(c),R=o.distance(l),F=g+S+R,q=(g*o.x+S*l.x+R*c.x)/F,Q=(g*o.y+S*l.y+R*c.y)/F;return new Fe(q,Q)}}]),v}(),_l=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"addRingSide",value:function(o,l,c,g,S){if(l===0&&o.length=cn.MINIMUM_VALID_SIZE&&Yt.isCCW(o)&&(R=S,F=g,c=ct.opposite(c));var q=this._curveBuilder.getRingCurve(o,c,l);this.addCurve(q,R,F)}},{key:"addRingBothSides",value:function(o,l){this.addRingSide(o,l,ct.LEFT,me.EXTERIOR,me.INTERIOR),this.addRingSide(o,l,ct.RIGHT,me.INTERIOR,me.EXTERIOR)}},{key:"addPoint",value:function(o){if(this._distance<=0)return null;var l=o.getCoordinates(),c=this._curveBuilder.getLineCurve(l,this._distance);this.addCurve(c,me.EXTERIOR,me.INTERIOR)}},{key:"addPolygon",value:function(o){var l=this._distance,c=ct.LEFT;this._distance<0&&(l=-this._distance,c=ct.RIGHT);var g=o.getExteriorRing(),S=dn.removeRepeatedPoints(g.getCoordinates());if(this._distance<0&&this.isErodedCompletely(g,this._distance)||this._distance<=0&&S.length<3)return null;this.addRingSide(S,l,c,me.EXTERIOR,me.INTERIOR);for(var R=0;R0&&this.isErodedCompletely(F,-this._distance)||this.addRingSide(q,l,ct.opposite(c),me.INTERIOR,me.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(o,l){var c=new du(o[0],o[1],o[2]),g=c.inCentre();return W.pointToSegment(g,c.p0,c.p1)S}},{key:"addCollection",value:function(o){for(var l=0;l=this._max)throw new $r;var o=this._parent.getGeometryN(this._index++);return o instanceof Pi?(this._subcollectionIterator=new v(o),this._subcollectionIterator.next()):o}},{key:"remove",value:function(){throw new Ti(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[_s]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var o=arguments[0];this._parent=o,this._atStart=!0,this._index=0,this._max=o.getNumGeometries()}},{key:"isAtomic",value:function(o){return!(o instanceof Pi)}}]),v}(),yl=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"locate",value:function(o){return v.locate(o,this._geom)}},{key:"interfaces_",get:function(){return[mu]}}],[{key:"constructor_",value:function(){this._geom=null;var o=arguments[0];this._geom=o}},{key:"locatePointInPolygon",value:function(o,l){if(l.isEmpty())return me.EXTERIOR;var c=l.getExteriorRing(),g=v.locatePointInRing(o,c);if(g!==me.INTERIOR)return g;for(var S=0;S=0;S--){var R=this._edgeList.get(S),F=R.getSym();g===null&&(g=F),c!==null&&F.setNext(c),c=R}g.setNext(c)}},{key:"computeDepths",value:function(){if(arguments.length===1){var c=arguments[0],g=this.findIndex(c),S=c.getDepth(ct.LEFT),R=c.getDepth(ct.RIGHT),F=this.computeDepths(g+1,this._edgeList.size(),S),q=this.computeDepths(0,g,F);if(q!==R)throw new Wn("depth mismatch at "+c.getCoordinate())}else if(arguments.length===3){for(var Q=arguments[0],Ee=arguments[1],Me=arguments[2],Xe=Me,pt=Q;pt=0;F--){var q=this._resultAreaEdgeList.get(F),Q=q.getSym();switch(g===null&&q.getEdgeRing()===c&&(g=q),R){case this._SCANNING_FOR_INCOMING:if(Q.getEdgeRing()!==c)continue;S=Q,R=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(q.getEdgeRing()!==c)continue;S.setNextMin(q),R=this._SCANNING_FOR_INCOMING}}R===this._LINKING_TO_OUTGOING&&(Dt.isTrue(g!==null,"found null for first outgoing dirEdge"),Dt.isTrue(g.getEdgeRing()===c,"unable to link last incoming dirEdge"),S.setNextMin(g))}},{key:"getOutgoingDegree",value:function(){if(arguments.length===0){for(var c=0,g=this.iterator();g.hasNext();){var S=g.next();S.isInResult()&&c++}return c}if(arguments.length===1){for(var R=arguments[0],F=0,q=this.iterator();q.hasNext();){var Q=q.next();Q.getEdgeRing()===R&&F++}return F}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var c=me.NONE,g=this.iterator();g.hasNext();){var S=g.next(),R=S.getSym();if(!S.isLineEdge()){if(S.isInResult()){c=me.INTERIOR;break}if(R.isInResult()){c=me.EXTERIOR;break}}}if(c===me.NONE)return null;for(var F=c,q=this.iterator();q.hasNext();){var Q=q.next(),Ee=Q.getSym();Q.isLineEdge()?Q.getEdge().setCovered(F===me.INTERIOR):(Q.isInResult()&&(F=me.EXTERIOR),Ee.isInResult()&&(F=me.INTERIOR))}}},{key:"computeLabelling",value:function(c){Ie($(l.prototype),"computeLabelling",this).call(this,c),this._label=new On(me.NONE);for(var g=this.iterator();g.hasNext();)for(var S=g.next().getEdge().getLabel(),R=0;R<2;R++){var F=S.getLocation(R);F!==me.INTERIOR&&F!==me.BOUNDARY||this._label.setLocation(R,me.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}]),l}(bc),Ec=function(v){O(l,v);var o=ye(l);function l(){return w(this,l),o.call(this)}return A(l,[{key:"createNode",value:function(c){return new Nn(c,new wc)}}]),l}(so),Ia=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"compareTo",value:function(o){var l=o;return v.compareOriented(this._pts,this._orientation,l._pts,l._orientation)}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var o=arguments[0];this._pts=o,this._orientation=v.orientation(o)}},{key:"orientation",value:function(o){return dn.increasingDirection(o)===1}},{key:"compareOriented",value:function(o,l,c,g){for(var S=l?1:-1,R=g?1:-1,F=l?o.length:-1,q=g?c.length:-1,Q=l?0:o.length-1,Ee=g?0:c.length-1;;){var Me=o[Q].compareTo(c[Ee]);if(Me!==0)return Me;var Xe=(Q+=S)===F,pt=(Ee+=R)===q;if(Xe&&!pt)return-1;if(!Xe&&pt)return 1;if(Xe&&pt)return 0}}}]),v}(),vl=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"print",value:function(o){o.print("MULTILINESTRING ( ");for(var l=0;l0&&o.print(","),o.print("(");for(var g=c.getCoordinates(),S=0;S0&&o.print(","),o.print(g[S].x+" "+g[S].y);o.println(")")}o.print(") ")}},{key:"addAll",value:function(o){for(var l=o.iterator();l.hasNext();)this.add(l.next())}},{key:"findEdgeIndex",value:function(o){for(var l=0;lo?1:this.distl?1:0}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var o=arguments[0],l=arguments[1],c=arguments[2];this.coord=new Fe(o),this.segmentIndex=l,this.dist=c}}]),v}(),_u=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"print",value:function(o){o.println("Intersections:");for(var l=this.iterator();l.hasNext();)l.next().print(o)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(o){this.addEndpoints();for(var l=this.iterator(),c=l.next();l.hasNext();){var g=l.next(),S=this.createSplitEdge(c,g);o.add(S),c=g}}},{key:"addEndpoints",value:function(){var o=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[o],o,0)}},{key:"createSplitEdge",value:function(o,l){var c=l.segmentIndex-o.segmentIndex+2,g=this.edge.pts[l.segmentIndex],S=l.dist>0||!l.coord.equals2D(g);S||c--;var R=new Array(c).fill(null),F=0;R[F++]=new Fe(o.coord);for(var q=o.segmentIndex+1;q<=l.segmentIndex;q++)R[F++]=this.edge.pts[q];return S&&(R[F]=l.coord),new Aa(R,new On(this.edge._label))}},{key:"add",value:function(o,l,c){var g=new gu(o,l,c),S=this._nodeMap.get(g);return S!==null?S:(this._nodeMap.put(g,g),g)}},{key:"isIntersection",value:function(o){for(var l=this.iterator();l.hasNext();)if(l.next().coord.equals(o))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new Nr,this.edge=null;var o=arguments[0];this.edge=o}}]),v}(),Tc=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])||v.isTrue(this._matrix[me.INTERIOR][me.BOUNDARY])||v.isTrue(this._matrix[me.BOUNDARY][me.INTERIOR])||v.isTrue(this._matrix[me.BOUNDARY][me.BOUNDARY]))&&this._matrix[me.EXTERIOR][me.INTERIOR]===se.FALSE&&this._matrix[me.EXTERIOR][me.BOUNDARY]===se.FALSE}},{key:"isCoveredBy",value:function(){return(v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])||v.isTrue(this._matrix[me.INTERIOR][me.BOUNDARY])||v.isTrue(this._matrix[me.BOUNDARY][me.INTERIOR])||v.isTrue(this._matrix[me.BOUNDARY][me.BOUNDARY]))&&this._matrix[me.INTERIOR][me.EXTERIOR]===se.FALSE&&this._matrix[me.BOUNDARY][me.EXTERIOR]===se.FALSE}},{key:"set",value:function(){if(arguments.length===1)for(var o=arguments[0],l=0;l=0&&l>=0&&this.setAtLeast(o,l,c)}},{key:"isWithin",value:function(){return v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])&&this._matrix[me.INTERIOR][me.EXTERIOR]===se.FALSE&&this._matrix[me.BOUNDARY][me.EXTERIOR]===se.FALSE}},{key:"isTouches",value:function(o,l){return o>l?this.isTouches(l,o):(o===se.A&&l===se.A||o===se.L&&l===se.L||o===se.L&&l===se.A||o===se.P&&l===se.A||o===se.P&&l===se.L)&&this._matrix[me.INTERIOR][me.INTERIOR]===se.FALSE&&(v.isTrue(this._matrix[me.INTERIOR][me.BOUNDARY])||v.isTrue(this._matrix[me.BOUNDARY][me.INTERIOR])||v.isTrue(this._matrix[me.BOUNDARY][me.BOUNDARY]))}},{key:"isOverlaps",value:function(o,l){return o===se.P&&l===se.P||o===se.A&&l===se.A?v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])&&v.isTrue(this._matrix[me.INTERIOR][me.EXTERIOR])&&v.isTrue(this._matrix[me.EXTERIOR][me.INTERIOR]):o===se.L&&l===se.L&&this._matrix[me.INTERIOR][me.INTERIOR]===1&&v.isTrue(this._matrix[me.INTERIOR][me.EXTERIOR])&&v.isTrue(this._matrix[me.EXTERIOR][me.INTERIOR])}},{key:"isEquals",value:function(o,l){return o===l&&v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])&&this._matrix[me.INTERIOR][me.EXTERIOR]===se.FALSE&&this._matrix[me.BOUNDARY][me.EXTERIOR]===se.FALSE&&this._matrix[me.EXTERIOR][me.INTERIOR]===se.FALSE&&this._matrix[me.EXTERIOR][me.BOUNDARY]===se.FALSE}},{key:"toString",value:function(){for(var o=new Bo("123456789"),l=0;l<3;l++)for(var c=0;c<3;c++)o.setCharAt(3*l+c,se.toDimensionSymbol(this._matrix[l][c]));return o.toString()}},{key:"setAll",value:function(o){for(var l=0;l<3;l++)for(var c=0;c<3;c++)this._matrix[l][c]=o}},{key:"get",value:function(o,l){return this._matrix[o][l]}},{key:"transpose",value:function(){var o=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=o,o=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=o,o=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=o,this}},{key:"matches",value:function(o){if(o.length!==9)throw new ut("Should be length 9: "+o);for(var l=0;l<3;l++)for(var c=0;c<3;c++)if(!v.matches(this._matrix[l][c],o.charAt(3*l+c)))return!1;return!0}},{key:"add",value:function(o){for(var l=0;l<3;l++)for(var c=0;c<3;c++)this.setAtLeast(l,c,o.get(l,c))}},{key:"isDisjoint",value:function(){return this._matrix[me.INTERIOR][me.INTERIOR]===se.FALSE&&this._matrix[me.INTERIOR][me.BOUNDARY]===se.FALSE&&this._matrix[me.BOUNDARY][me.INTERIOR]===se.FALSE&&this._matrix[me.BOUNDARY][me.BOUNDARY]===se.FALSE}},{key:"isCrosses",value:function(o,l){return o===se.P&&l===se.L||o===se.P&&l===se.A||o===se.L&&l===se.A?v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])&&v.isTrue(this._matrix[me.INTERIOR][me.EXTERIOR]):o===se.L&&l===se.P||o===se.A&&l===se.P||o===se.A&&l===se.L?v.isTrue(this._matrix[me.INTERIOR][me.INTERIOR])&&v.isTrue(this._matrix[me.EXTERIOR][me.INTERIOR]):o===se.L&&l===se.L&&this._matrix[me.INTERIOR][me.INTERIOR]===0}},{key:"interfaces_",get:function(){return[It]}}],[{key:"constructor_",value:function(){if(this._matrix=null,arguments.length===0)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(se.FALSE);else if(arguments.length===1){if(typeof arguments[0]=="string"){var o=arguments[0];v.constructor_.call(this),this.set(o)}else if(arguments[0]instanceof v){var l=arguments[0];v.constructor_.call(this),this._matrix[me.INTERIOR][me.INTERIOR]=l._matrix[me.INTERIOR][me.INTERIOR],this._matrix[me.INTERIOR][me.BOUNDARY]=l._matrix[me.INTERIOR][me.BOUNDARY],this._matrix[me.INTERIOR][me.EXTERIOR]=l._matrix[me.INTERIOR][me.EXTERIOR],this._matrix[me.BOUNDARY][me.INTERIOR]=l._matrix[me.BOUNDARY][me.INTERIOR],this._matrix[me.BOUNDARY][me.BOUNDARY]=l._matrix[me.BOUNDARY][me.BOUNDARY],this._matrix[me.BOUNDARY][me.EXTERIOR]=l._matrix[me.BOUNDARY][me.EXTERIOR],this._matrix[me.EXTERIOR][me.INTERIOR]=l._matrix[me.EXTERIOR][me.INTERIOR],this._matrix[me.EXTERIOR][me.BOUNDARY]=l._matrix[me.EXTERIOR][me.BOUNDARY],this._matrix[me.EXTERIOR][me.EXTERIOR]=l._matrix[me.EXTERIOR][me.EXTERIOR]}}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&typeof arguments[1]=="string"){var o=arguments[0],l=arguments[1];return l===se.SYM_DONTCARE||l===se.SYM_TRUE&&(o>=0||o===se.TRUE)||l===se.SYM_FALSE&&o===se.FALSE||l===se.SYM_P&&o===se.P||l===se.SYM_L&&o===se.L||l===se.SYM_A&&o===se.A}if(typeof arguments[0]=="string"&&typeof arguments[1]=="string"){var c=arguments[0],g=arguments[1],S=new v(c);return S.matches(g)}}},{key:"isTrue",value:function(o){return o>=0||o===se.TRUE}}]),v}(),Hs=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(o){return o===null||o.length===0?null:(this.ensureCapacity(this._size+o.length),ce.arraycopy(o,0,this._data,this._size,o.length),void(this._size+=o.length))}},{key:"ensureCapacity",value:function(o){if(o<=this._data.length)return null;var l=Math.max(o,2*this._data.length);this._data=Zt.copyOf(this._data,l)}},{key:"toArray",value:function(){var o=new Array(this._size).fill(null);return ce.arraycopy(this._data,0,o,0,this._size),o}},{key:"add",value:function(o){this.ensureCapacity(this._size+1),this._data[this._size]=o,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,arguments.length===0)v.constructor_.call(this,10);else if(arguments.length===1){var o=arguments[0];this._data=new Array(o).fill(null)}}}]),v}(),vs=function(){function v(){w(this,v)}return A(v,[{key:"getChainStartIndices",value:function(o){var l=0,c=new Hs(Math.trunc(o.length/2));c.add(l);do{var g=this.findChainEnd(o,l);c.add(g),l=g}while(lc?l:c}},{key:"getMinX",value:function(o){var l=this.pts[this.startIndex[o]].x,c=this.pts[this.startIndex[o+1]].x;return ll&&(g=1),this._depth[o][c]=g}}}},{key:"getDelta",value:function(o){return this._depth[o][ct.RIGHT]-this._depth[o][ct.LEFT]}},{key:"getLocation",value:function(o,l){return this._depth[o][l]<=0?me.EXTERIOR:me.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(arguments.length===1)for(var o=arguments[0],l=0;l<2;l++)for(var c=1;c<3;c++){var g=o.getLocation(l,c);g!==me.EXTERIOR&&g!==me.INTERIOR||(this.isNull(l,c)?this._depth[l][c]=v.depthAtLocation(g):this._depth[l][c]+=v.depthAtLocation(g))}else if(arguments.length===3){var S=arguments[0],R=arguments[1],F=arguments[2];F===me.INTERIOR&&this._depth[S][R]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var o=0;o<2;o++)for(var l=0;l<3;l++)this._depth[o][l]=v.NULL_VALUE}},{key:"depthAtLocation",value:function(o){return o===me.EXTERIOR?0:o===me.INTERIOR?1:v.NULL_VALUE}}]),v}();xs.NULL_VALUE=-1;var Aa=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var c=new Array(2).fill(null);return c[0]=this.pts[0],c[1]=this.pts[1],new l(c,On.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(c){this._isIsolated=c}},{key:"setName",value:function(c){this._name=c}},{key:"equals",value:function(c){if(!(c instanceof l))return!1;var g=c;if(this.pts.length!==g.pts.length)return!1;for(var S=!0,R=!0,F=this.pts.length,q=0;q0?this.pts[0]:null;if(arguments.length===1){var c=arguments[0];return this.pts[c]}}},{key:"print",value:function(c){c.print("edge "+this._name+": "),c.print("LINESTRING (");for(var g=0;g0&&c.print(","),c.print(this.pts[g].x+" "+this.pts[g].y);c.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(c){l.updateIM(this._label,c)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&this.pts.length===3&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(c){c.print("edge "+this._name+": ");for(var g=this.pts.length-1;g>=0;g--)c.print(this.pts[g]+" ");c.println("")}},{key:"getMonotoneChainEdge",value:function(){return this._mce===null&&(this._mce=new xl(this)),this._mce}},{key:"getEnvelope",value:function(){if(this._env===null){this._env=new Ci;for(var c=0;c0&&c.append(","),c.append(this.pts[g].x+" "+this.pts[g].y);return c.append(") "+this._label+" "+this._depthDelta),c.toString()}},{key:"isPointwiseEqual",value:function(c){if(this.pts.length!==c.pts.length)return!1;for(var g=0;gg||this._maxyR;if(F)return!1;var q=this.intersectsToleranceSquare(o,l);return Dt.isTrue(!(F&&q),"Found bad envelope test"),q}},{key:"initCorners",value:function(o){var l=.5;this._minx=o.x-l,this._maxx=o.x+l,this._miny=o.y-l,this._maxy=o.y+l,this._corner[0]=new Fe(this._maxx,this._maxy),this._corner[1]=new Fe(this._minx,this._maxy),this._corner[2]=new Fe(this._minx,this._miny),this._corner[3]=new Fe(this._maxx,this._miny)}},{key:"intersects",value:function(o,l){return this._scaleFactor===1?this.intersectsScaled(o,l):(this.copyScaled(o,this._p0Scaled),this.copyScaled(l,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(o){return Math.round(o*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(o,l){l.x=this.scale(o.x),l.y=this.scale(o.y)}},{key:"getSafeEnvelope",value:function(){if(this._safeEnv===null){var o=v.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new Ci(this._originalPt.x-o,this._originalPt.x+o,this._originalPt.y-o,this._originalPt.y+o)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(o,l){return this._li.computeIntersection(o,l,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,l,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,l,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(o,l,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}},{key:"intersectsToleranceSquare",value:function(o,l){var c=!1,g=!1;return this._li.computeIntersection(o,l,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(o,l,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(c=!0),this._li.computeIntersection(o,l,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(g=!0),this._li.computeIntersection(o,l,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!c||!g)||!!o.equals(this._pt)||!!l.equals(this._pt))))}},{key:"addSnappedNode",value:function(o,l){var c=o.getCoordinate(l),g=o.getCoordinate(l+1);return!!this.intersects(c,g)&&(o.addIntersection(this.getCoordinate(),l),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var o=arguments[0],l=arguments[1],c=arguments[2];if(this._originalPt=o,this._pt=o,this._scaleFactor=l,this._li=c,l<=0)throw new ut("Scale factor must be non-zero");l!==1&&(this._pt=new Fe(this.scale(o.x),this.scale(o.y)),this._p0Scaled=new Fe,this._p1Scaled=new Fe),this.initCorners(this._pt)}}]),v}();bs.SAFE_ENV_EXPANSION_FACTOR=.75;var yu=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"select",value:function(){if(arguments.length!==1){if(arguments.length===2){var o=arguments[0],l=arguments[1];o.getLineSegment(l,this.selectedSegment),this.select(this.selectedSegment)}}}}],[{key:"constructor_",value:function(){this.selectedSegment=new ar}}]),v}(),La=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"snap",value:function(){if(arguments.length===1){var o=arguments[0];return this.snap(o,null,-1)}if(arguments.length===3){var l=arguments[0],c=arguments[1],g=arguments[2],S=l.getSafeEnvelope(),R=new vu(l,c,g);return this._index.query(S,new(function(){function F(){w(this,F)}return A(F,[{key:"interfaces_",get:function(){return[qs]}},{key:"visitItem",value:function(q){q.select(S,R)}}]),F}())),R.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var o=arguments[0];this._index=o}}]),v}(),vu=function(v){O(l,v);var o=ye(l);function l(){var c;return w(this,l),c=o.call(this),l.constructor_.apply(he(c),arguments),c}return A(l,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(arguments.length===2&&Number.isInteger(arguments[1])&&arguments[0]instanceof Go))return Ie($(l.prototype),"select",this).apply(this,arguments);var c=arguments[0],g=arguments[1],S=c.getContext();if(this._parentEdge===S&&(g===this._hotPixelVertexIndex||g+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(S,g)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var c=arguments[0],g=arguments[1],S=arguments[2];this._hotPixel=c,this._parentEdge=g,this._hotPixelVertexIndex=S}}]),l}(yu);La.HotPixelSnapAction=vu;var bl=function(){function v(){w(this,v),v.constructor_.apply(this,arguments)}return A(v,[{key:"processIntersections",value:function(o,l,c,g){if(o===c&&l===g)return null;var S=o.getCoordinates()[l],R=o.getCoordinates()[l+1],F=c.getCoordinates()[g],q=c.getCoordinates()[g+1];if(this._li.computeIntersection(S,R,F,q),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var Q=0;Q=0;o--){try{this.bufferReducedPrecision(o)}catch(S){if(!(S instanceof Wn))throw S;this._saveException=S}if(this._resultGeometry!==null)return null}throw this._saveException}if(arguments.length===1){var l=arguments[0],c=v.precisionScaleFactor(this._argGeom,this._distance,l),g=new xn(c);this.bufferFixedPrecision(g)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),this._resultGeometry!==null)return null;var o=this._argGeom.getFactory().getPrecisionModel();o.getType()===xn.FIXED?this.bufferFixedPrecision(o):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(o){this._bufParams.setQuadrantSegments(o)}},{key:"bufferOriginalPrecision",value:function(){try{var o=new jr(this._bufParams);this._resultGeometry=o.buffer(this._argGeom,this._distance)}catch(l){if(!(l instanceof Oi))throw l;this._saveException=l}}},{key:"getResultGeometry",value:function(o){return this._distance=o,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(o){this._bufParams.setEndCapStyle(o)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new Qe,this._resultGeometry=null,this._saveException=null,arguments.length===1){var o=arguments[0];this._argGeom=o}else if(arguments.length===2){var l=arguments[0],c=arguments[1];this._argGeom=l,this._bufParams=c}}},{key:"bufferOp",value:function(){if(arguments.length===2){var o=arguments[0],l=arguments[1],c=new v(o),g=c.getResultGeometry(l);return g}if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof ft&&typeof arguments[1]=="number"){var S=arguments[0],R=arguments[1],F=arguments[2],q=new v(S);q.setQuadrantSegments(F);var Q=q.getResultGeometry(R);return Q}if(arguments[2]instanceof Qe&&arguments[0]instanceof ft&&typeof arguments[1]=="number"){var Ee=arguments[0],Me=arguments[1],Xe=arguments[2],pt=new v(Ee,Xe),dt=pt.getResultGeometry(Me);return dt}}else if(arguments.length===4){var Vt=arguments[0],Ut=arguments[1],ei=arguments[2],yi=arguments[3],Xi=new v(Vt);Xi.setQuadrantSegments(ei),Xi.setEndCapStyle(yi);var Fn=Xi.getResultGeometry(Ut);return Fn}}},{key:"precisionScaleFactor",value:function(o,l,c){var g=o.getEnvelopeInternal(),S=X.max(Math.abs(g.getMaxX()),Math.abs(g.getMaxY()),Math.abs(g.getMinX()),Math.abs(g.getMinY()))+2*(l>0?l:0),R=c-Math.trunc(Math.log(S)/Math.log(10)+1);return Math.pow(10,R)}}]),v}();Yr.CAP_ROUND=Qe.CAP_ROUND,Yr.CAP_BUTT=Qe.CAP_FLAT,Yr.CAP_FLAT=Qe.CAP_FLAT,Yr.CAP_SQUARE=Qe.CAP_SQUARE,Yr.MAX_PRECISION_DIGITS=12;var xu=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],Da=function(){function v(o){w(this,v),this.geometryFactory=o||new nr}return A(v,[{key:"read",value:function(o){var l,c=(l=typeof o=="string"?JSON.parse(o):o).type;if(!Tr[c])throw new Error("Unknown GeoJSON type: "+l.type);return xu.indexOf(c)!==-1?Tr[c].call(this,l.coordinates):c==="GeometryCollection"?Tr[c].call(this,l.geometries):Tr[c].call(this,l)}},{key:"write",value:function(o){var l=o.getGeometryType();if(!Sr[l])throw new Error("Geometry is not supported");return Sr[l].call(this,o)}}]),v}(),Tr={Feature:function(v){var o={};for(var l in v)o[l]=v[l];if(v.geometry){var c=v.geometry.type;if(!Tr[c])throw new Error("Unknown GeoJSON type: "+v.type);o.geometry=this.read(v.geometry)}return v.bbox&&(o.bbox=Tr.bbox.call(this,v.bbox)),o},FeatureCollection:function(v){var o={};if(v.features){o.features=[];for(var l=0;l1?0:x<-1?zi:Math.acos(x)}function ol(x){return x>1?hs:x<-1?-hs:Math.asin(x)}function pc(){}function ff(x,d){x&&gv.hasOwnProperty(x.type)&&gv[x.type](x,d)}var mv={Feature:function(x,d){ff(x.geometry,d)},FeatureCollection:function(x,d){for(var w=x.features,k=-1,A=w.length;++kzi?x-fs:x<-zi?x+fs:x,d]}Fd.invert=Fd;function P2(x,d,w){return(x%=fs)?d||w?yv(xv(x),bv(d,w)):xv(x):d||w?bv(d,w):Fd}function vv(x){return function(d,w){return d+=x,[d>zi?d-fs:d<-zi?d+fs:d,w]}}function xv(x){var d=vv(x);return d.invert=vv(-x),d}function bv(x,d){var w=_n(x),k=yn(x),A=_n(d),O=yn(d);function $(s,Z){var oe=_n(Z),pe=_n(s)*oe,he=yn(s)*oe,we=yn(Z),ye=we*w+pe*k;return[ru(he*A-ye*O,pe*w-we*k),ol(ye*A+he*O)]}return $.invert=function(s,Z){var oe=_n(Z),pe=_n(s)*oe,he=yn(s)*oe,we=yn(Z),ye=we*A-he*O;return[ru(he*A+we*O,pe*w+ye*k),ol(ye*w-pe*k)]},$}function L2(x,d,w,k,A,O){if(w){var $=_n(d),s=yn(d),Z=k*w;A==null?(A=d+k*fs,O=d-Z/2):(A=wv($,A),O=wv($,O),(k>0?AO)&&(A+=k*fs));for(var oe,pe=A;k>0?pe>O:pe1&&x.push(x.pop().concat(x.shift()))},result:function(){var w=x;return x=[],d=null,w}}}function R2(x,d,w,k,A,O){var $=x[0],s=x[1],Z=d[0],oe=d[1],pe=0,he=1,we=Z-$,ye=oe-s,Ie;if(Ie=w-$,!(!we&&Ie>0)){if(Ie/=we,we<0){if(Ie0){if(Ie>he)return;Ie>pe&&(pe=Ie)}if(Ie=A-$,!(!we&&Ie<0)){if(Ie/=we,we<0){if(Ie>he)return;Ie>pe&&(pe=Ie)}else if(we>0){if(Ie0)){if(Ie/=ye,ye<0){if(Ie0){if(Ie>he)return;Ie>pe&&(pe=Ie)}if(Ie=O-s,!(!ye&&Ie<0)){if(Ie/=ye,ye<0){if(Ie>he)return;Ie>pe&&(pe=Ie)}else if(ye>0){if(Ie0&&(x[0]=$+pe*we,x[1]=s+pe*ye),he<1&&(d[0]=$+he*we,d[1]=s+he*ye),!0}}}}}function gf(x,d){return er(x[0]-d[0])=0;--s)A.point((he=pe[s])[0],he[1]);else k(we.x,we.p.x,-1,A);we=we.p}we=we.o,pe=we.z,ye=!ye}while(!we.v);A.lineEnd()}}}function Sv(x){if(d=x.length){for(var d,w=0,k=x[0],A;++wd?1:x>=d?0:NaN}function D2(x){return x.length===1&&(x=O2(x)),{left:function(d,w,k,A){for(k==null&&(k=0),A==null&&(A=d.length);k>>1;x(d[O],w)<0?k=O+1:A=O}return k},right:function(d,w,k,A){for(k==null&&(k=0),A==null&&(A=d.length);k>>1;x(d[O],w)>0?A=O:k=O+1}return k}}}function O2(x){return function(d,w){return Iv(x(d),w)}}D2(Iv);function kv(x){for(var d=x.length,w,k=-1,A=0,O,$;++k=0;)for($=x[d],w=$.length;--w>=0;)O[--A]=$[w];return O}var dc=1e9,yf=-dc;function z2(x,d,w,k){function A(oe,pe){return x<=oe&&oe<=w&&d<=pe&&pe<=k}function O(oe,pe,he,we){var ye=0,Ie=0;if(oe==null||(ye=$(oe,he))!==(Ie=$(pe,he))||Z(oe,pe)<0^he>0)do we.point(ye===0||ye===3?x:w,ye>1?k:d);while((ye=(ye+he+4)%4)!==Ie);else we.point(pe[0],pe[1])}function $(oe,pe){return er(oe[0]-x)0?0:3:er(oe[0]-w)0?2:1:er(oe[1]-d)0?1:0:pe>0?3:2}function s(oe,pe){return Z(oe.x,pe.x)}function Z(oe,pe){var he=$(oe,1),we=$(pe,1);return he!==we?he-we:he===0?pe[1]-oe[1]:he===1?oe[0]-pe[0]:he===2?oe[1]-pe[1]:pe[0]-oe[0]}return function(oe){var pe=oe,he=Ev(),we,ye,Ie,Tt,gt,Mt,Le,Qe,Et,ut,yt,_t={point:It,lineStart:At,lineEnd:Xt,polygonStart:gi,polygonEnd:ti};function It(Jt,Bt){A(Jt,Bt)&&pe.point(Jt,Bt)}function Oe(){for(var Jt=0,Bt=0,Ri=ye.length;Btk&&(Dt-Oi)*(k-Wt)>(Ni-Wt)*(x-Oi)&&++Jt:Ni<=k&&(Dt-Oi)*(k-Wt)<(Ni-Wt)*(x-Oi)&&--Jt;return Jt}function gi(){pe=he,we=[],ye=[],yt=!0}function ti(){var Jt=Oe(),Bt=yt&&Jt,Ri=(we=kv(we)).length;(Bt||Ri)&&(oe.polygonStart(),Bt&&(oe.lineStart(),O(null,null,1,oe),oe.lineEnd()),Ri&&Tv(we,s,Jt,O,oe),oe.polygonEnd()),pe=oe,we=ye=Ie=null}function At(){_t.point=bt,ye&&ye.push(Ie=[]),ut=!0,Et=!1,Le=Qe=NaN}function Xt(){we&&(bt(Tt,gt),Mt&&Et&&he.rejoin(),we.push(he.result())),_t.point=It,Et&&pe.lineEnd()}function bt(Jt,Bt){var Ri=A(Jt,Bt);if(ye&&Ie.push([Jt,Bt]),ut)Tt=Jt,gt=Bt,Mt=Ri,ut=!1,Ri&&(pe.lineStart(),pe.point(Jt,Bt));else if(Ri&&Et)pe.point(Jt,Bt);else{var Rt=[Le=Math.max(yf,Math.min(dc,Le)),Qe=Math.max(yf,Math.min(dc,Qe))],pi=[Jt=Math.max(yf,Math.min(dc,Jt)),Bt=Math.max(yf,Math.min(dc,Bt))];R2(Rt,pi,x,d,w,k)?(Et||(pe.lineStart(),pe.point(Rt[0],Rt[1])),pe.point(pi[0],pi[1]),Ri||pe.lineEnd(),yt=!1):Ri&&(pe.lineStart(),pe.point(Jt,Bt),yt=!1)}Le=Jt,Qe=Bt,Et=Ri}return _t}}var Ud=ma();function N2(x,d){var w=d[0],k=d[1],A=[yn(w),-_n(w),0],O=0,$=0;Ud.reset();for(var s=0,Z=x.length;s=0?1:-1,It=_t*yt,Oe=It>zi,gi=Ie*Et;if(Ud.add(ru(gi*_t*yn(It),Tt*ut+gi*_n(It))),O+=Oe?yt+_t*fs:yt,Oe^we>=w^Le>=w){var ti=df(su(he),su(Mt));Bd(ti);var At=df(A,ti);Bd(At);var Xt=(Oe^yt>=0?-1:1)*ol(At[2]);(k>Xt||k===Xt&&(ti[0]||ti[1]))&&($+=Oe^yt>=0?1:-1)}}return(O<-ln||Omc&&(mc=x),dxf&&(xf=d)}ma();function Cv(x,d,w,k){return function(A,O){var $=d(O),s=A.invert(k[0],k[1]),Z=Ev(),oe=d(Z),pe=!1,he,we,ye,Ie={point:Tt,lineStart:Mt,lineEnd:Le,polygonStart:function(){Ie.point=Qe,Ie.lineStart=Et,Ie.lineEnd=ut,we=[],he=[]},polygonEnd:function(){Ie.point=Tt,Ie.lineStart=Mt,Ie.lineEnd=Le,we=kv(we);var yt=N2(he,s);we.length?(pe||(O.polygonStart(),pe=!0),Tv(we,U2,yt,w,O)):yt&&(pe||(O.polygonStart(),pe=!0),O.lineStart(),w(null,null,1,O),O.lineEnd()),pe&&(O.polygonEnd(),pe=!1),we=he=null},sphere:function(){O.polygonStart(),O.lineStart(),w(null,null,1,O),O.lineEnd(),O.polygonEnd()}};function Tt(yt,_t){var It=A(yt,_t);x(yt=It[0],_t=It[1])&&O.point(yt,_t)}function gt(yt,_t){var It=A(yt,_t);$.point(It[0],It[1])}function Mt(){Ie.point=gt,$.lineStart()}function Le(){Ie.point=Tt,$.lineEnd()}function Qe(yt,_t){ye.push([yt,_t]);var It=A(yt,_t);oe.point(It[0],It[1])}function Et(){oe.lineStart(),ye=[]}function ut(){Qe(ye[0][0],ye[0][1]),oe.lineEnd();var yt=oe.clean(),_t=Z.result(),It,Oe=_t.length,gi,ti,At;if(ye.pop(),he.push(ye),ye=null,!!Oe){if(yt&1){if(ti=_t[0],(gi=ti.length-1)>0){for(pe||(O.polygonStart(),pe=!0),O.lineStart(),It=0;It1&&yt&2&&_t.push(_t.pop().concat(_t.shift())),we.push(_t.filter(F2))}}return Ie}}function F2(x){return x.length>1}function U2(x,d){return((x=x.x)[0]<0?x[1]-hs-ln:hs-x[1])-((d=d.x)[0]<0?d[1]-hs-ln:hs-d[1])}const Pv=Cv(function(){return!0},j2,G2,[-zi,-hs]);function j2(x){var d=NaN,w=NaN,k=NaN,A;return{lineStart:function(){x.lineStart(),A=1},point:function(O,$){var s=O>0?zi:-zi,Z=er(O-d);er(Z-zi)0?hs:-hs),x.point(k,w),x.lineEnd(),x.lineStart(),x.point(s,w),x.point(O,w),A=0):k!==s&&Z>=zi&&(er(d-k)ln?A2((yn(d)*(O=_n(k))*yn(w)-yn(k)*(A=_n(d))*yn(x))/(A*O*$)):(d+k)/2}function G2(x,d,w,k){var A;if(x==null)A=w*hs,k.point(-zi,A),k.point(0,A),k.point(zi,A),k.point(zi,0),k.point(zi,-A),k.point(0,-A),k.point(-zi,-A),k.point(-zi,0),k.point(-zi,A);else if(er(x[0]-d[0])>ln){var O=x[0]0,A=er(w)>ln;function O(pe,he,we,ye){L2(ye,x,d,we,pe,he)}function $(pe,he){return _n(pe)*_n(he)>w}function s(pe){var he,we,ye,Ie,Tt;return{lineStart:function(){Ie=ye=!1,Tt=1},point:function(gt,Mt){var Le=[gt,Mt],Qe,Et=$(gt,Mt),ut=k?Et?0:oe(gt,Mt):Et?oe(gt+(gt<0?zi:-zi),Mt):0;if(!he&&(Ie=ye=Et)&&pe.lineStart(),Et!==ye&&(Qe=Z(he,Le),(!Qe||gf(he,Qe)||gf(Le,Qe))&&(Le[0]+=ln,Le[1]+=ln,Et=$(Le[0],Le[1]))),Et!==ye)Tt=0,Et?(pe.lineStart(),Qe=Z(Le,he),pe.point(Qe[0],Qe[1])):(Qe=Z(he,Le),pe.point(Qe[0],Qe[1]),pe.lineEnd()),he=Qe;else if(A&&he&&k^Et){var yt;!(ut&we)&&(yt=Z(Le,he,!0))&&(Tt=0,k?(pe.lineStart(),pe.point(yt[0][0],yt[0][1]),pe.point(yt[1][0],yt[1][1]),pe.lineEnd()):(pe.point(yt[1][0],yt[1][1]),pe.lineEnd(),pe.lineStart(),pe.point(yt[0][0],yt[0][1])))}Et&&(!he||!gf(he,Le))&&pe.point(Le[0],Le[1]),he=Le,ye=Et,we=ut},lineEnd:function(){ye&&pe.lineEnd(),he=null},clean:function(){return Tt|(Ie&&ye)<<1}}}function Z(pe,he,we){var ye=su(pe),Ie=su(he),Tt=[1,0,0],gt=df(ye,Ie),Mt=pf(gt,gt),Le=gt[0],Qe=Mt-Le*Le;if(!Qe)return!we&&pe;var Et=w*Mt/Qe,ut=-w*Le/Qe,yt=df(Tt,gt),_t=mf(Tt,Et),It=mf(gt,ut);Nd(_t,It);var Oe=yt,gi=pf(_t,Oe),ti=pf(Oe,Oe),At=gi*gi-ti*(pf(_t,_t)-1);if(!(At<0)){var Xt=ou(At),bt=mf(Oe,(-gi-Xt)/ti);if(Nd(bt,_t),bt=zd(bt),!we)return bt;var Jt=pe[0],Bt=he[0],Ri=pe[1],Rt=he[1],pi;Bt0^bt[1]<(er(bt[0]-Jt)zi^(Jt<=bt[0]&&bt[0]<=Bt)){var Wt=mf(Oe,(-gi+Xt)/ti);return Nd(Wt,_t),[bt,zd(Wt)]}}}function oe(pe,he){var we=k?x:zi-x,ye=0;return pe<-we?ye|=1:pe>we&&(ye|=2),he<-we?ye|=4:he>we&&(ye|=8),ye}return Cv($,s,O,k?[0,-x]:[-zi,x-zi])}function Lv(x){return function(d){var w=new jd;for(var k in x)w[k]=x[k];return w.stream=d,w}}function jd(){}jd.prototype={constructor:jd,point:function(x,d){this.stream.point(x,d)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Rv(x,d,w){var k=d[1][0]-d[0][0],A=d[1][1]-d[0][1],O=x.clipExtent&&x.clipExtent();x.scale(150).translate([0,0]),O!=null&&x.clipExtent(null),C2(w,x.stream(Av));var $=Av.result(),s=Math.min(k/($[1][0]-$[0][0]),A/($[1][1]-$[0][1])),Z=+d[0][0]+(k-s*($[1][0]+$[0][0]))/2,oe=+d[0][1]+(A-s*($[1][1]+$[0][1]))/2;return O!=null&&x.clipExtent(O),x.scale(s*150).translate([Z,oe])}function q2(x,d,w){return Rv(x,[[0,0],d],w)}var Dv=16,Z2=_n(30*vo);function Ov(x,d){return+d?W2(x,d):X2(x)}function X2(x){return Lv({point:function(d,w){d=x(d,w),this.stream.point(d[0],d[1])}})}function W2(x,d){function w(k,A,O,$,s,Z,oe,pe,he,we,ye,Ie,Tt,gt){var Mt=oe-k,Le=pe-A,Qe=Mt*Mt+Le*Le;if(Qe>4*d&&Tt--){var Et=$+we,ut=s+ye,yt=Z+Ie,_t=ou(Et*Et+ut*ut+yt*yt),It=ol(yt/=_t),Oe=er(er(yt)-1)d||er((Mt*Xt+Le*bt)/Qe-.5)>.3||$*we+s*ye+Z*Ie2?bt[2]%360*vo:0,At()):[oe*ga,pe*ga,he*ga]},Oe.precision=function(bt){return arguments.length?(yt=Ov(ti,ut=bt*bt),Xt()):ou(ut)},Oe.fitExtent=function(bt,Jt){return Rv(Oe,bt,Jt)},Oe.fitSize=function(bt,Jt){return q2(Oe,bt,Jt)};function At(){ye=yv(we=P2(oe,pe,he),d);var bt=d(s,Z);return O=k-bt[0]*w,$=A+bt[1]*w,Xt()}function Xt(){return _t=It=null,Oe}return function(){return d=x.apply(this,arguments),Oe.invert=d.invert&&gi,At()}}function zv(x){return function(d,w){var k=_n(d),A=_n(w),O=x(k*A);return[O*A*yn(d),O*yn(w)]}}function Nv(x){return function(d,w){var k=ou(d*d+w*w),A=x(k),O=yn(A),$=_n(A);return[ru(d*O,k*$),ol(k&&w*O/k)]}}var J2=zv(function(x){return ou(2/(1+x))});J2.invert=Nv(function(x){return 2*ol(x/2)});var Bv=zv(function(x){return(x=dv(x))&&x/yn(x)});Bv.invert=Nv(function(x){return x});function Q2(){return H2(Bv).scale(79.4188).clipAngle(179.999)}function Fv(x,d){return[x,d]}Fv.invert=Fv;var eI=Object.defineProperty,lu=(x,d)=>eI(x,"name",{value:d,configurable:!0}),{BufferOp:tI,GeoJSONReader:iI,GeoJSONWriter:nI}=M2;function gc(x,d,w){w=w||{};var k=w.units||"kilometers",A=w.steps||8;if(!x)throw new Error("geojson is required");if(typeof w!="object")throw new Error("options must be an object");if(typeof A!="number")throw new Error("steps must be an number");if(d===void 0)throw new Error("radius is required");if(A<=0)throw new Error("steps must be greater than 0");var O=[];switch(x.type){case"GeometryCollection":return uc(x,function($){var s=_c($,d,k,A);s&&O.push(s)}),yo(O);case"FeatureCollection":return cs(x,function($){var s=_c($,d,k,A);s&&cs(s,function(Z){Z&&O.push(Z)})}),yo(O)}return _c(x,d,k,A)}lu(gc,"buffer");function _c(x,d,w,k){var A=x.properties||{},O=x.type==="Feature"?x.geometry:x;if(O.type==="GeometryCollection"){var $=[];return uc(x,function(Tt){var gt=_c(Tt,d,w,k);gt&&$.push(gt)}),yo($)}var s=Uv(O),Z={type:O.type,coordinates:Gd(O.coordinates,s)},oe=new iI,pe=oe.read(Z),he=Hh(ac(d,w),"meters"),we=tI.bufferOp(pe,he,k),ye=new nI;if(we=ye.write(we),!Vd(we.coordinates)){var Ie={type:we.type,coordinates:$d(we.coordinates,s)};return _o(Ie,A)}}lu(_c,"bufferFeature");function Vd(x){return Array.isArray(x[0])?Vd(x[0]):isNaN(x[0])}lu(Vd,"coordsIsNaN");function Gd(x,d){return typeof x[0]!="object"?d(x):x.map(function(w){return Gd(w,d)})}lu(Gd,"projectCoords");function $d(x,d){return typeof x[0]!="object"?d.invert(x):x.map(function(w){return $d(w,d)})}lu($d,"unprojectCoords");function Uv(x){var d=uf(x).geometry.coordinates,w=[-d[0],-d[1]];return Q2().rotate(w).scale(yr)}lu(Uv,"defineProjection");var rI=Object.defineProperty,oI=(x,d)=>rI(x,"name",{value:d,configurable:!0});function qd(x,d,w={}){const k=w.steps||64,A=w.properties?w.properties:!Array.isArray(x)&&x.type==="Feature"&&x.properties?x.properties:{},O=[];for(let $=0;$sI(x,"name",{value:d,configurable:!0}),lI=m2;function Zd(x){const d={type:"FeatureCollection",features:[]};if(x.type==="Feature"&&(x.geometry.type==="Point"||x.geometry.type==="MultiPoint"))throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");const w=lI(x,!1);for(let k=0;kuI(x,"name",{value:d,configurable:!0});function jv(x,d,w){if(x.geometry.type!=="Polygon")throw new Error("The input feature must be a Polygon");w===void 0&&(w=1);var k=x.geometry.coordinates,A=[],O={};if(w){for(var $=[],s=0;s=1||gi<=0||ti>=1||ti<=0)){var At=Oe,Xt=!O[At];Xt&&(O[At]=!0),d?A.push(d(Oe,Mt,Le,ut,yt,gi,Qe,Et,_t,It,ti,Xt)):A.push(Oe)}}}function gt(Mt,Le){var Qe=k[Mt][Le],Et=k[Mt][Le+1],ut,yt,_t,It;return Qe[0]oe[Dt.isect].coord?-1:1});for(var _t=[];Mt.length>0;){var It=Mt.pop(),Oe=It.isect,gi=It.parent,ti=It.winding,At=_t.length,Xt=[oe[Oe].coord],bt=Oe;if(oe[Oe].ringAndEdge1Walkable)var Jt=oe[Oe].ringAndEdge1,Bt=oe[Oe].nxtIsectAlongRingAndEdge1;else var Jt=oe[Oe].ringAndEdge2,Bt=oe[Oe].nxtIsectAlongRingAndEdge2;for(;!cu(oe[Oe].coord,oe[Bt].coord);){Xt.push(oe[Bt].coord);for(var Ri=void 0,Le=0;Le1)for(var Dt=0;Dt"u"&&(d=!0),x.length!=3)throw new Error("This function requires an array of three points [x,y]");var w=(x[1][0]-x[0][0])*(x[2][1]-x[0][1])-(x[1][1]-x[0][1])*(x[2][0]-x[0][0]);return w>=0==d}vr(yc,"isConvex");function Zv(x){for(var d=0,w=0;w{k.properties.drawOption=w,k.properties.complete=!0,this.geojson_point.features.push(k)}):d.type==="LineString"||d.type==="MultiLineString"?Os(d,k=>{k.properties.drawOption=w,k.properties.complete=!0,this.geojson_line.features.push(k)}):(d.type==="Polygon"||d.type==="MultiPolygon")&&Os(d,k=>{k.properties.drawOption=w,k.properties.complete=!0,this.geojson_polygon.features.push(k)}),this.repaint()}_onMousedown(d){const w=[[d.point.x-2,d.point.y-2],[d.point.x+2,d.point.y+2]],k=this._map.queryRenderedFeatures(w,{layers:["MapTools_point"]});if(k.length>0){this.isActive=!0;const A=k[0].properties;d.originalEvent.button===2&&A.type==="01"?A.type==="01"&&(A.source==="geojson_line"&&this.geojson_line.features[A.source_fea_index].geometry.coordinates.length>2?(this.temp_line.geometry.coordinates.length==2&&A.source_coord_index==this.geojson_line.features[A.source_fea_index].geometry.coordinates.length-1&&(this.temp_line.geometry.coordinates[0]=this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates[this.geojson_line.features[A.source_fea_index].geometry.coordinates.length-2],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]})),this.geojson_line.features[A.source_fea_index].geometry.coordinates.splice(A.source_coord_index,1),this.repaint()):A.source==="geojson_polygon"&&this.geojson_polygon.features[A.source_fea_index].geometry.coordinates[A.source_geometry_index].length>4&&(this.temp_line.geometry.coordinates.length==3&&A.source_coord_index==this.geojson_polygon.features[A.source_fea_index].geometry.coordinates[A.source_geometry_index].length-2&&(this.temp_line.geometry.coordinates[0]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[A.source_geometry_index][this.geojson_polygon.features[A.source_fea_index].geometry.coordinates[A.source_geometry_index].length-3],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]})),this.geojson_polygon.features[A.source_fea_index].geometry.coordinates[A.source_geometry_index].splice(A.source_coord_index,1),this.repaint())):d.originalEvent.button===0&&(A.type==="02"&&(A.source==="geojson_line"?(this.geojson_line.features[A.source_fea_index].geometry.coordinates.splice(A.source_coord_index,0,[d.lngLat.lng,d.lngLat.lat]),this.repaint()):A.source==="geojson_polygon"&&(this.geojson_polygon.features[A.source_fea_index].geometry.coordinates[A.source_geometry_index].splice(A.source_coord_index,0,[d.lngLat.lng,d.lngLat.lat]),this.repaint())),this._map.dragPan.disable(),this.draging_point=A)}}_onMouseup(d){if(this.draging_point!=null){const w=this._callback.Mouseup;w&&(this.draging_point.source==="geojson_point"?w(this.mode,this.drawOption,this.geojson_point.features[this.geojson_point.features.length-1].geometry):this.draging_point.source==="geojson_line"?w(this.mode,this.drawOption,this.geojson_line.features[this.geojson_line.features.length-1].geometry):this.draging_point.source==="geojson_polygon"&&w(this.mode,this.drawOption,this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry)),this.draging_point=null,this._map.dragPan.enable(),this.isActive=!1}}_onClick(d){this.mode!==""&&(window.clearTimeout(this.timeId),this.timeId=window.setTimeout(()=>{if(this.click_x=d.lngLat.lng,this.click_y=d.lngLat.lat,this.temp_line.geometry.coordinates[0]=[d.lngLat.lng,d.lngLat.lat],this.mode==="point")this.geojson_point.features.push(Xn([d.lngLat.lng,d.lngLat.lat],{drawOption:this.drawOption})),(!this.drawOption||!this.drawOption.multiple)&&this.complate(),this.repaint();else if(this.mode==="line")this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates.push([d.lngLat.lng,d.lngLat.lat]),this.repaint();else if(this.mode==="polygon"){const w=this.geojson_polygon.features[this.geojson_polygon.features.length-1];w.geometry.coordinates[0].length==0?w.geometry.coordinates[0].push([d.lngLat.lng,d.lngLat.lat],[d.lngLat.lng,d.lngLat.lat]):w.geometry.coordinates[0].splice(w.geometry.coordinates[0].length-1,0,[d.lngLat.lng,d.lngLat.lat]),this.repaint()}},250))}_onMousemove(d){if(this.draging_point!=null){this.draging_point.source==="geojson_point"?(this.geojson_point.features[this.draging_point.source_fea_index].geometry.coordinates=[d.lngLat.lng,d.lngLat.lat],this.repaint()):this.draging_point.source==="geojson_line"?(this.geojson_line.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_coord_index]=[d.lngLat.lng,d.lngLat.lat],this.repaint()):this.draging_point.source==="geojson_polygon"&&(this.draging_point.source_coord_index===0||this.draging_point.source_coord_index===this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index].length-1?(this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][0]=[d.lngLat.lng,d.lngLat.lat],this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index].length-1]=[d.lngLat.lng,d.lngLat.lat]):this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][this.draging_point.source_coord_index]=[d.lngLat.lng,d.lngLat.lat],this.repaint());return}if(this.mode!==""){if(this._map.getCanvas().style.cursor="crosshair",this.tooltip)this.tooltip.setLngLat([d.lngLat.lng,d.lngLat.lat]);else{const w=document.createElement("div");w.style.backgroundColor="#FFFFFF",w.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",w.style.borderRadius="8px",w.style.height="32px",w.style.lineHeight="32px",w.style.fontSize="13px",w.style.padding="0 8px",this.mode==="point"&&(!this.drawOption||!this.drawOption.multiple)?(w.innerHTML="单击结束",w.style.width="68px",this.tooltip=new Rr.Marker({element:w,offset:[40,0]}).setLngLat([d.lngLat.lng,d.lngLat.lat]).addTo(this._map)):(w.innerHTML="单击鼠标开始,双击结束",w.style.width="159px",this.tooltip=new Rr.Marker({element:w,offset:[100,0]}).setLngLat([d.lngLat.lng,d.lngLat.lat]).addTo(this._map))}if(this.temp_line.geometry.coordinates.length>0){if(this.mode==="line")this.temp_line.geometry.coordinates[1]=[d.lngLat.lng,d.lngLat.lat],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]});else if(this.mode==="polygon")this.temp_line.geometry.coordinates[1]=[d.lngLat.lng,d.lngLat.lat],this.temp_line.geometry.coordinates[2]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0][0],this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0].length<=3?this.temp_line.geometry.coordinates[3]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0][1]:this.temp_line.geometry.coordinates.length==4&&this.temp_line.geometry.coordinates.pop(),this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]});else if(this.mode==="rect")this.temp_line.geometry.coordinates[1]=[this.temp_line.geometry.coordinates[0][0],d.lngLat.lat],this.temp_line.geometry.coordinates[2]=[d.lngLat.lng,d.lngLat.lat],this.temp_line.geometry.coordinates[3]=[d.lngLat.lng,this.temp_line.geometry.coordinates[0][1]],this.temp_line.geometry.coordinates[4]=this.temp_line.geometry.coordinates[0],this._map.getSource("MapTools_temp_line").setData(this.temp_line);else if(this.mode==="circle"){const w=Jh(this.temp_line.geometry.coordinates[0],[d.lngLat.lng,d.lngLat.lat]),k=qd(this.temp_line.geometry.coordinates[0],w);this.temp_line.geometry.coordinates[1]=[d.lngLat.lng,d.lngLat.lat],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line,k]})}}}}_onDblClick(d){if(window.clearTimeout(this.timeId),this.dblclick_x=d.lngLat.lng,this.dblclick_y=d.lngLat.lat,this.mode==="point")this.geojson_point.features.push(Xn([d.lngLat.lng,d.lngLat.lat]));else if(this.mode==="line")this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates.push([d.lngLat.lng,d.lngLat.lat]);else if(this.mode==="polygon"){const A=this.geojson_polygon.features[this.geojson_polygon.features.length-1];A.geometry.coordinates[0].length==0?A.geometry.coordinates[0].push([d.lngLat.lng,d.lngLat.lat],[d.lngLat.lng,d.lngLat.lat]):A.geometry.coordinates[0].splice(A.geometry.coordinates[0].length-1,0,[d.lngLat.lng,d.lngLat.lat])}else if(this.mode==="rect"){if(isNaN(this.click_x)||isNaN(this.click_y)||this.click_x==this.dblclick_x||this.click_y==this.dblclick_y)return;const A=this.geojson_polygon.features[this.geojson_polygon.features.length-1];A.geometry.coordinates[0][0]=[this.click_x,this.click_y],A.geometry.coordinates[0][1]=[this.click_x,this.dblclick_y],A.geometry.coordinates[0][2]=[this.dblclick_x,this.dblclick_y],A.geometry.coordinates[0][3]=[this.dblclick_x,this.click_y],A.geometry.coordinates[0][4]=[this.click_x,this.click_y]}else if(this.mode==="circle"){if(isNaN(this.click_x)||isNaN(this.click_y))return;const A=Jh([this.click_x,this.click_y],[this.dblclick_x,this.dblclick_y]),O=qd([this.click_x,this.click_y],A);this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry=O.geometry,this.geojson_polygon.features[this.geojson_polygon.features.length-1].properties.radius=A}const w=this.geojson_line.features[this.geojson_line.features.length-1];w&&w.geometry.coordinates.length<2?this.geojson_line.features.pop():w&&w.properties.complete==!1&&(w.properties.complete=!0);const k=this.geojson_polygon.features[this.geojson_polygon.features.length-1];k&&k.geometry.coordinates[0].length<4?this.geojson_polygon.features.pop():k&&k.properties.complete==!1&&(k.properties.complete=!0),window.setTimeout(()=>{this._map&&this._map.doubleClickZoom.enable()},0),this.repaint(),this.complate()}complate(){const d=this._callback.complate;d&&(this.mode==="point"?d(this.mode,this.drawOption,this.geojson_point.features[this.geojson_point.features.length-1].geometry):this.mode==="line"?d(this.mode,this.drawOption,this.geojson_line.features[this.geojson_line.features.length-1].geometry):(this.mode==="polygon"||this.mode==="rect"||this.mode==="circle")&&(this.geojson_polygon.features.length||console.log("请正确画"),d(this.mode,this.drawOption,this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry))),this._map.getCanvas().style.cursor="",this.temp_line.geometry.coordinates=[],this._map.getSource("MapTools_temp_line").setData(this.temp_line),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.click_x=Number.NaN,this.click_y=Number.NaN,this.move_x=Number.NaN,this.move_y=Number.NaN,this.dblclick_x=Number.NaN,this.dblclick_y=Number.NaN,this.mode="",this.isActive=!1}repaint(){const d=[];for(let w=0;w{Ds(w,(A,O)=>{const $=Xn(A,{source:"geojson_point",source_fea_index:k,source_coord_index:O,type:"01"});if(d.push($),w.properties.drawOption&&w.properties.drawOption.buffer&&w.properties.drawOption.buffer>0){const s=gc(w,w.properties.drawOption.buffer,{units:"kilometers"});d.push(s)}if(w.properties.drawOption&&w.properties.drawOption.delete){const s=document.createElement("div");s.style.backgroundColor="#FFFFFF",s.style.padding="5px 8px",s.style["border-radius"]="4px",s.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",s.style.fontSize="12px";const Z=document.createElement("a");Z.href="javascript:void(0)",Z.innerHTML="删除",Z.onclick=(function(pe){return(function(){this.delPoint(pe)}).bind(this)}).bind(this)(k),s.appendChild(Z);const oe=new Rr.Marker({element:s,offset:[0,20]}).setLngLat(w.geometry.coordinates).addTo(this._map);this.markers.push(oe)}})}),cs(this.geojson_line,(w,k)=>{if(w.geometry.coordinates.length>=2){if(d.push(w),w.properties.drawOption&&w.properties.drawOption.buffer&&w.properties.drawOption.buffer>0)if(Zd(w).features.length>0){const O=av(w);cs(O,$=>{const s=gc($,w.properties.drawOption.buffer,{units:"kilometers"});d.push(s)})}else{const O=gc(w,w.properties.drawOption.buffer,{units:"kilometers"});d.push(O)}else if(w.properties.drawOption&&w.properties.drawOption.distance){let A=0;Ds(w,(O,$)=>{A+=$==0?0:Jh(O,w.geometry.coordinates[$-1]);const s=document.createElement("div");if(s.style.backgroundColor=this.options.markerBackgroundColor,s.style.border="solid 1px #D1D1D1",s.style.padding="3px",s.style["border-radius"]="5px",$==0)s.innerHTML="起点";else if($==w.geometry.coordinates.length-1&&w.properties.complete==!0){s.innerHTML=`总长 ${A.toLocaleString()}千米  `;const oe=document.createElement("a");oe.className="btn",oe.style.width="150px",oe.href="javascript:void(0)",oe.innerHTML="删除",oe.onclick=(function(pe){return(function(){this.delLine(pe)}).bind(this)}).bind(this)(k),s.appendChild(oe)}else s.innerHTML=`${A.toLocaleString()}千米`;const Z=new Rr.Marker({element:s,offset:[0,20]}).setLngLat(O).addTo(this._map);this.markers.push(Z)})}if(w.properties.drawOption&&w.properties.drawOption.delete&&!w.properties.drawOption.distance&&w.properties.complete==!0){const A=document.createElement("div");A.style.backgroundColor="#FFFFFF",A.style.padding="5px 8px",A.style["border-radius"]="4px",A.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",A.style.fontSize="12px";const O=document.createElement("a");O.href="javascript:void(0)",O.className="delIcon",O.innerHTML="删除",O.onclick=(function(Z){return(function(){this.delLine(Z)}).bind(this)}).bind(this)(k),A.appendChild(O);const $=w.geometry.coordinates[w.geometry.coordinates.length-1],s=new Rr.Marker({element:A,offset:[0,20]}).setLngLat($).addTo(this._map);this.markers.push(s)}Ds(w,(A,O)=>{let $=Xn(A,{source:"geojson_line",source_fea_index:k,source_coord_index:O,type:"01"});if(d.push($),O>0){const s=(A[0]+w.geometry.coordinates[O-1][0])/2,Z=(A[1]+w.geometry.coordinates[O-1][1])/2;$=Xn([s,Z],{source:"geojson_line",source_fea_index:k,source_coord_index:O,type:"02"}),d.push($)}})}}),cs(this.geojson_polygon,(w,k)=>{if(w.geometry.coordinates[0].length>=4){const A=this.makevalid(w);if(d.push(A),w.properties.drawOption&&w.properties.drawOption.buffer&&w.properties.drawOption.buffer>0){const O=gc(A,w.properties.drawOption.buffer,{units:"kilometers"});d.push(O)}if(w.properties.mode!="circle")for(let O=0;O0){const Z=(w.geometry.coordinates[O][$][0]+w.geometry.coordinates[O][$-1][0])/2,oe=(w.geometry.coordinates[O][$][1]+w.geometry.coordinates[O][$-1][1])/2;s=Xn([Z,oe],{source:"geojson_polygon",source_fea_index:k,source_geometry_index:O,source_coord_index:$,type:"02"}),d.push(s)}}if(w.properties.drawOption&&w.properties.drawOption.area&&w.properties.complete==!0){const O=document.createElement("div");O.style.backgroundColor=this.options.markerBackgroundColor,O.style.border="solid 1px #D1D1D1",O.style.padding="3px",O.style["border-radius"]="5px";const $=kd(w)/1e3/1e3;O.innerHTML=`${$.toLocaleString()}平方千米  `;const s=document.createElement("a");s.href="javascript:void(0)",s.innerHTML="删除",s.onclick=(function(pe){return(function(){this.delPolygon(pe)}).bind(this)}).bind(this)(k),O.appendChild(s);const Z=uf(w).geometry.coordinates,oe=new Rr.Marker({element:O,offset:[-20,-10]}).setLngLat(Z).addTo(this._map);this.markers.push(oe)}if(w.properties.drawOption&&w.properties.drawOption.delete&&!w.properties.drawOption.area&&w.properties.complete==!0){const O=document.createElement("div");O.style.backgroundColor=this.options.markerBackgroundColor,O.style.border="solid 1px #D1D1D1",O.style.padding="3px",O.style["border-radius"]="5px";const $=document.createElement("a");$.href="javascript:void(0)",$.innerHTML="删除",$.onclick=(function(oe){return(function(){this.delPolygon(oe)}).bind(this)}).bind(this)(k),O.appendChild($);const s=uf(w).geometry.coordinates,Z=new Rr.Marker({element:O,offset:[0,20]}).setLngLat(s).addTo(this._map);this.markers.push(Z)}}}),this._map.getSource("MapTools_geojson").setData(yo(d))}delPoint(d){this.geojson_point.features.splice(d,1),this.repaint()}delLine(d){this.geojson_line.features.splice(d,1),this.repaint()}delPolygon(d){this.geojson_polygon.features.splice(d,1),this.repaint()}clean(){this.geojson_point.features.length=0,this.geojson_line.features.length=0,this.geojson_polygon.features.length=0,this.completeCallback=null,this._map.getCanvas().style.cursor="",this.temp_line.geometry.coordinates=[],this._map.getSource("MapTools_temp_line").setData(this.temp_line),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.click_x=Number.NaN,this.click_y=Number.NaN,this.move_x=Number.NaN,this.move_y=Number.NaN,this.dblclick_x=Number.NaN,this.dblclick_y=Number.NaN,window.setTimeout(()=>{this._map.doubleClickZoom.enable()},0),this.repaint(),this.mode="",this.isActive=!1}getAll(){return{point:this.geojson_point.features,line:this.geojson_line.features,polygon:this.geojson_polygon.features}}makevalid(d){if(d=nv(d),Zd(d).features.length<1)return d;const k=Wv(d),A=[];return cs(k,$=>{A.push($.geometry.coordinates)}),Sd(A)}}const fI={PI:3.141592653589793,x_pi:3.141592653589793*3e3/180,delta:function(x,d){var w=6378245,k=.006693421622965943,A=this.transformLat(d-105,x-35),O=this.transformLon(d-105,x-35),$=x/180*this.PI,s=Math.sin($);s=1-k*s*s;var Z=Math.sqrt(s);return A=A*180/(w*(1-k)/(s*Z)*this.PI),O=O*180/(w/Z*Math.cos($)*this.PI),{lat:A,lon:O}},gcj_encrypt:function(x,d){if(this.outOfChina(x,d))return{lat:x,lon:d};var w=this.delta(x,d);return{lat:x+w.lat,lon:d+w.lon}},gcj_decrypt:function(x,d){if(this.outOfChina(x,d))return{lat:x,lon:d};var w=this.delta(x,d);return{lat:x-w.lat,lon:d-w.lon}},gcj_decrypt_exact:function(x,d){for(var w=.01,k=1e-9,A=w,O=w,$=x-A,s=d-O,Z=x+A,oe=d+O,pe,he,we=0;;){pe=($+Z)/2,he=(s+oe)/2;var ye=this.gcj_encrypt(pe,he);if(A=ye.lat-x,O=ye.lon-d,Math.abs(A)0?Z=pe:$=pe,O>0?oe=he:s=he,++we>1e4))break}return{lat:pe,lon:he}},bd_encrypt:function(x,d){var w=d,k=x,A=Math.sqrt(w*w+k*k)+2e-5*Math.sin(k*this.x_pi),O=Math.atan2(k,w)+3e-6*Math.cos(w*this.x_pi);return bdLon=A*Math.cos(O)+.0065,bdLat=A*Math.sin(O)+.006,{lat:bdLat,lon:bdLon}},bd_decrypt:function(x,d){var w=d-.0065,k=x-.006,A=Math.sqrt(w*w+k*k)-2e-5*Math.sin(k*this.x_pi),O=Math.atan2(k,w)-3e-6*Math.cos(w*this.x_pi),$=A*Math.cos(O),s=A*Math.sin(O);return{lat:s,lon:$}},mercator_encrypt:function(x,d){var w=d*2003750834e-2/180,k=Math.log(Math.tan((90+x)*this.PI/360))/(this.PI/180);return k=k*2003750834e-2/180,{lat:k,lon:w}},mercator_decrypt:function(x,d){var w=d/2003750834e-2*180,k=x/2003750834e-2*180;return k=180/this.PI*(2*Math.atan(Math.exp(k*this.PI/180))-this.PI/2),{lat:k,lon:w}},outOfChina:function(x,d){return d<72.004||d>137.8347||x<.8293||x>55.8271},transformLat:function(x,d){var w=-100+2*x+3*d+.2*d*d+.1*x*d+.2*Math.sqrt(Math.abs(x));return w+=(20*Math.sin(6*x*this.PI)+20*Math.sin(2*x*this.PI))*2/3,w+=(20*Math.sin(d*this.PI)+40*Math.sin(d/3*this.PI))*2/3,w+=(160*Math.sin(d/12*this.PI)+320*Math.sin(d*this.PI/30))*2/3,w},transformLon:function(x,d){var w=300+x+2*d+.1*x*x+.1*x*d+.1*Math.sqrt(Math.abs(x));return w+=(20*Math.sin(6*x*this.PI)+20*Math.sin(2*x*this.PI))*2/3,w+=(20*Math.sin(x*this.PI)+40*Math.sin(x/3*this.PI))*2/3,w+=(150*Math.sin(x/12*this.PI)+300*Math.sin(x/30*this.PI))*2/3,w}},Gr={};return Gr.name="WebGIS SDK",Gr.version=Gr.Version=L1,Gr.MapStyle=dg,Gr.map=P1,Gr.ZoomControl=R1,Gr.FullScreenControl=D1,Gr.CompassControl=O1,Gr.ScalelineControl=z1,Gr.Popup=N1,Gr.MapTools=hI,Gr.Transforms=fI,Gr._defaultMap=Rr,Gr}();