Files
FixIt/assets/lib/mapbox-gl/mapbox-gl.min.js
T
2021-12-21 00:41:50 +08:00

8 lines
824 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Minified by jsDelivr using Terser v5.3.5.
* Original file: /npm/mapbox-gl@2.3.1/dist/mapbox-gl.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mapboxgl=e()}(this,(function(){"use strict";var t,e,i;function r(r,n){if(t)if(e){var o="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/api/#transpiling-v2'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s),i=n(s),"undefined"!=typeof window&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=n;else t=n}return r(0,(function(t){var e="2.3.1",i=r;function r(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=r,this.p2x=i,this.p2y=r}r.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},r.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},r.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},r.prototype.solveCurveX=function(t,e){var i,r,n,o,s;for(void 0===e&&(e=1e-6),n=t,s=0;s<8;s++){if(o=this.sampleCurveX(n)-t,Math.abs(o)<e)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=o/a}if((n=t)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-t)<e)return n;t>o?i=n:r=n,n=.5*(r-i)+i}return n},r.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var n=o;function o(t,e){this.x=t,this.y=e}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(t){return t instanceof o?t:Array.isArray(t)?new o(t[0],t[1]):t};var s="undefined"!=typeof self?self:{};const a=Math.pow(2,53)-1,l=Math.PI/180,c=180/Math.PI;function h(t){return t*l}const u=[[0,0],[1,0],[1,1],[0,1]];function d(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 p(t,e,r,n){const o=new i(t,e,r,n);return function(t){return o.solve(t)}}const f=p(.25,.1,.25,1);function m(t,e,i){return Math.min(i,Math.max(e,t))}function _(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function g(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let o=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(o=t),n[s]=e,0==--r&&i(o,n)}))}))}function y(t){const e=[];for(const i in t)e.push(t[i]);return e}function x(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let v=1;function b(){return v++}function w(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function T(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function E(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 S(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function I(t,e){return-1!==t.indexOf(e,t.length-e.length)}function A(t,e,i){const r={};for(const n in t)r[n]=e.call(i||this,t[n],n,t);return r}function C(t,e,i){const r={};for(const n in t)e.call(i||this,t[n],n,t)&&(r[n]=t[n]);return r}function M(t){return Array.isArray(t)?t.map(M):"object"==typeof t&&t?A(t,M):t}const z={};function k(t){z[t]||("undefined"!=typeof console&&console.warn(t),z[t]=!0)}function P(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function D(t){let e=0;for(let i,r,n=0,o=t.length,s=o-1;n<o;s=n++)i=t[n],r=t[s],e+=(r.x-i.x)*(i.y+r.y);return e}function L(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function R(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const o=r||n;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let B,F,O,U=null;function V(t){if(null==U){const e=t.navigator?t.navigator.userAgent:null;U=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return U}function N(t){try{const e=s[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}const G={now:()=>void 0!==O?O:s.performance.now(),setNow(t){O=t},restoreNow(){O=void 0},frame(t){const e=s.requestAnimationFrame(t);return{cancel:()=>s.cancelAnimationFrame(e)}},getImageData(t,e=0){const i=s.document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return i.width=t.width,i.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:t=>(B||(B=s.document.createElement("a")),B.href=t,B.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==F&&(F=s.matchMedia("(prefers-reduced-motion: reduce)")),F.matches)}};let Z;const q={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==Z){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Z=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){Z=t}}return Z},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},j={supported:!1,testSupport:function(t){!W&&X&&(H?K(t):$=t)}};let $,X,W=!1,H=!1;function K(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,X),t.isContextLost())return;j.supported=!0}catch(t){}t.deleteTexture(e),W=!0}s.document&&(X=s.document.createElement("img"),X.onload=function(){$&&K($),$=null,H=!0},X.onerror=function(){W=!0,$=null},X.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Y="01",J="NO_ACCESS_TOKEN";function Q(t){return 0===t.indexOf("mapbox:")}function tt(t){return q.API_URL_REGEX.test(t)}const et=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function it(t){const e=t.match(et);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 rt(t){const e=t.params.length?"?"+t.params.join("&"):"";return`${t.protocol}://${t.authority}${t.path}${e}`}function nt(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class ot{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const e=nt(q.ACCESS_TOKEN);let i="";return i=e&&e.u?s.btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):q.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${i}`:"mapbox.eventData:"+i}fetchEventData(){const t=N("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=s.localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const r=s.localStorage.getItem(i);r&&(this.anonId=r)}catch(t){k("Unable to read from LocalStorage")}}saveEventData(){const t=N("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{s.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){k("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,i,r,n){if(!q.EVENTS_URL)return;const o=it(q.EVENTS_URL);o.params.push("access_token="+(n||q.ACCESS_TOKEN||""));const s={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:e,skuId:Y,userId:this.anonId},a=i?x(s,i):s,l={url:rt(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=It(l,(t=>{this.pendingRequest=null,r(t),this.saveEventData(),this.processRequests(n)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const st=new class extends ot{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){q.EVENTS_URL&&q.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>Q(t)||tt(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=nt(q.ACCESS_TOKEN),i=e?e.u:q.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;E(this.anonId)||(this.anonId=w(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;if(!r)return this.processRequests();this.postEvent(n,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),t)}},at=st.postTurnstileEvent.bind(st),lt=new class extends ot{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,q.EVENTS_URL&&(i||q.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(J)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),E(this.anonId)||(this.anonId=w()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},ct=lt.postMapLoadEvent.bind(lt),ht=new class extends ot{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!q.API_URL||!q.SESSION_PATH)return;const n=it(q.API_URL+q.SESSION_PATH);n.params.push("sku="+(e||"")),n.params.push("access_token="+(r||q.ACCESS_TOKEN||""));const o={url:rt(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=At(o,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,q.SESSION_PATH&&q.API_URL&&(i||q.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(J)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},ut=ht.getSessionAPI.bind(ht),dt=new Set,pt="mapbox-tiles";let ft,mt,_t=500,gt=50;function yt(){s.caches&&!ft&&(ft=s.caches.open(pt))}function xt(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}let vt=1/0;const bt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(bt);class wt extends Error{constructor(t,e,i){401===e&&tt(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Tt=L()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,Et=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Tt())&&!/^\w+:/.test(i))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new s.AbortController,r=new s.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Tt(),signal:i.signal});let n=!1,o=!1;const a=(l=r.url).indexOf("sku=")>0&&tt(l);var l;"json"===t.type&&r.headers.set("Accept","application/json");const c=(i,n,l)=>{if(o)return;if(i&&"SecurityError"!==i.message&&k(i),n&&l)return h(n);const c=Date.now();s.fetch(r).then((i=>{if(i.ok){const t=a?i.clone():null;return h(i,t,c)}return e(new wt(i.statusText,i.status,t.url))})).catch((t=>{20!==t.code&&e(new Error(t.message))}))},h=(i,a,l)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{o||(a&&l&&function(t,e,i){if(yt(),!ft)return;const r={status:e.status,statusText:e.statusText,headers:new s.Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const n=R(e.headers.get("Cache-Control")||"");n["no-store"]||(n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-i<42e4||function(t,e){if(void 0===mt)try{new Response(new ReadableStream),mt=!0}catch(t){mt=!1}mt?e(t.body):t.blob().then(e)}(e,(e=>{const i=new s.Response(e,r);yt(),ft&&ft.then((e=>e.put(xt(t.url),i))).catch((t=>k(t.message)))})))}(r,a,l),n=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{o||e(new Error(t.message))}))};return a?function(t,e){if(yt(),!ft)return e(null);const i=xt(t.url);ft.then((t=>{t.match(i).then((r=>{const n=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=R(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(r);t.delete(i),n&&t.put(i,r.clone()),e(null,r,n)})).catch(e)})).catch(e)}(r,c):c(null,null),{cancel:()=>{o=!0,n||i.abort()}}}(t,e);if(L()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new s.XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else e(new wt(i.statusText,i.status,t.url))},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},St=function(t,e){return Et(x(t,{type:"arrayBuffer"}),e)},It=function(t,e){return Et(x(t,{method:"POST"}),e)},At=function(t,e){return Et(x(t,{method:"GET"}),e)};function Ct(t){const e=s.document.createElement("a");return e.href=t,e.protocol===s.document.location.protocol&&e.host===s.document.location.host}const Mt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let zt,kt;zt=[],kt=0;const Pt=function(t,e){if(j.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),kt>=q.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return zt.push(i),i}kt++;let i=!1;const r=()=>{if(!i)for(i=!0,kt--;zt.length&&kt<q.MAX_PARALLEL_IMAGE_REQUESTS;){const t=zt.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=Pt(e,i).cancel)}},n=St(t,((t,i,n,o)=>{r(),t?e(t):i&&(s.createImageBitmap?function(t,e){const i=new s.Blob([new Uint8Array(t)],{type:"image/png"});s.createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,n,o))):function(t,e){const i=new s.Image,r=s.URL;i.onload=()=>{e(null,i),r.revokeObjectURL(i.src),i.onload=null,s.requestAnimationFrame((()=>{i.src=Mt}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new s.Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?r.createObjectURL(n):Mt}(i,((t,i)=>e(t,i,n,o))))}));return{cancel:()=>{n.cancel(),r()}}};function Dt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Lt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class Rt{constructor(t,e={}){x(this,e),this.type=t}}class Bt extends Rt{constructor(t,e={}){super("error",x({error:t},e))}}class Ft{on(t,e){return this._listeners=this._listeners||{},Dt(t,e,this._listeners),this}off(t,e){return Lt(t,e,this._listeners),Lt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Dt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Rt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)Lt(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(x(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof Bt&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var Ot={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},fog:{type:"fog"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{},sky:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_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:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},fog:{range:{type:"array",default:[.5,10],minimum:-20,maximum:20,length:2,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:.1,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number","property-type":"data-constant",default:1,minimum:0,maximum:1e3,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},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:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_sky:{"sky-type":{type:"enum",values:{gradient:{},atmosphere:{}},default:"atmosphere",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{type:"array",value:"number",length:2,units:"degrees",minimum:[0,0],maximum:[360,180],transition:!1,requires:[{"sky-type":"atmosphere"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{type:"number",requires:[{"sky-type":"atmosphere"}],default:10,minimum:0,maximum:100,transition:!1,"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:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{type:"number",requires:[{"sky-type":"gradient"}],default:90,minimum:0,maximum:180,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient":{type:"color",default:["interpolate",["linear"],["sky-radial-progress"],.8,"#87ceeb",1,"white"],transition:!1,requires:[{"sky-type":"gradient"}],expression:{interpolated:!0,parameters:["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};class Ut{constructor(t,e,i,r){this.message=(t?t+": ":"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Vt(t){const e=t.value;return e?[new Ut(t.key,e,"constants have been deprecated as of v8")]:[]}function Nt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function Gt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Zt(t){if(Array.isArray(t))return t.map(Zt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Zt(t[i]);return e}return Gt(t)}class qt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class jt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new jt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(t+" not found in scope.")}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const $t={kind:"null"},Xt={kind:"number"},Wt={kind:"string"},Ht={kind:"boolean"},Kt={kind:"color"},Yt={kind:"object"},Jt={kind:"value"},Qt={kind:"collator"},te={kind:"formatted"},ee={kind:"resolvedImage"};function ie(t,e){return{kind:"array",itemType:t,N:e}}function re(t){if("array"===t.kind){const e=re(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const ne=[$t,Xt,Wt,Ht,Kt,te,Yt,ie(Jt),ee];function oe(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!oe(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of ne)if(!oe(t,e))return null}return`Expected ${re(t)} but found ${re(e)} instead.`}function se(t,e){return e.some((e=>e.kind===t.kind))}function ae(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function le(t){var e={exports:{}};return t(e,e.exports),e.exports}var ce=le((function(t,e){var i={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 r(t){return(t=Math.round(t))<0?0:t>255?255:t}function n(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function s(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==u.length)return null;d=o(u.pop());case"rgb":return 3!==u.length?null:[n(u[0]),n(u[1]),n(u[2]),d];case"hsla":if(4!==u.length)return null;d=o(u.pop());case"hsl":if(3!==u.length)return null;var p=(parseFloat(u[0])%360+360)%360/360,f=o(u[1]),m=o(u[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*s(g,_,p+1/3)),r(255*s(g,_,p)),r(255*s(g,_,p-1/3)),d];default:return null}}return null}}catch(t){}}));class he{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof he)return t;if("string"!=typeof t)return;const e=ce.parseCSSColor(t);return e?new he(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}he.black=new he(0,0,0,1),he.white=new he(1,1,1,1),he.transparent=new he(0,0,0,0),he.red=new he(1,0,0,1),he.blue=new he(0,0,1,1);class ue{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class de{constructor(t,e,i,r,n){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n}}class pe{constructor(t){this.sections=t}static fromString(t){return new pe([new de(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof pe?t:pe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class fe{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new fe({name:t,available:!1}):null}serialize(){return["image",this.name]}}function me(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function _e(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof he)return!0;if(t instanceof ue)return!0;if(t instanceof pe)return!0;if(t instanceof fe)return!0;if(Array.isArray(t)){for(const e of t)if(!_e(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!_e(t[e]))return!1;return!0}return!1}function ge(t){if(null===t)return $t;if("string"==typeof t)return Wt;if("boolean"==typeof t)return Ht;if("number"==typeof t)return Xt;if(t instanceof he)return Kt;if(t instanceof ue)return Qt;if(t instanceof pe)return te;if(t instanceof fe)return ee;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=ge(e);if(i){if(i===t)continue;i=Jt;break}i=t}return ie(i||Jt,e)}return Yt}function ye(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof he||t instanceof pe||t instanceof fe?t.toString():JSON.stringify(t)}class xe{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!_e(t[1]))return e.error("invalid value");const i=t[1];let r=ge(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new xe(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof he?["rgba"].concat(this.value.toArray()):this.value instanceof pe?this.value.serialize():this.value}}class ve{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const be={string:Wt,number:Xt,boolean:Ht,object:Yt};class we{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,o;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in be)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=be[i],r++}else n=Jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],r++}i=ie(n,o)}else i=be[n];const o=[];for(;r<t.length;r++){const i=e.parse(t[r],r,Jt);if(!i)return null;o.push(i)}return new we(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!oe(this.type,ge(i)))return i;if(e===this.args.length-1)throw new ve(`Expected value to be of type ${re(this.type)}, but found ${re(ge(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}class Te{constructor(t){this.type=te,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const o=t[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,Xt),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,ie(Wt)),!i))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,Kt),!s))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=s}else{const o=e.parse(t[i],1,Jt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Te(r)}evaluate(t){return new pe(this.sections.map((e=>{const i=e.content.evaluate(t);return ge(i)===ee?new de("",i,null,null,null):new de(ye(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Ee{constructor(t){this.type=ee,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Wt);return i?new Ee(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=fe.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Se={"to-boolean":Ht,"to-color":Kt,"to-number":Xt,"to-string":Wt};class Ie{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Se[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,Jt);if(!r)return null;n.push(r)}return new Ie(r,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof he)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:me(e[0],e[1],e[2],e[3]),!i))return new he(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ve(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new ve(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?pe.fromString(ye(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?fe.fromString(ye(this.args[0].evaluate(t))):ye(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Te([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ee(this.args[0]).serialize();const t=["to-"+this.type.kind];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Ae=["Unknown","Point","LineString","Polygon"];class Ce{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ae[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=he.parse(t)),e}}class Me{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=Me.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,o]of s){a=new Je(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,o=a.parse(i,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(r)&&r.length!==s.length)a.error(`Expected ${r.length} arguments, but found ${s.length} instead.`);else{for(let t=0;t<s.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=s[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new Me(i,n,o,s)}}if(1===s.length)e.errors.push(...a.errors);else{const i=(s.length?s:o).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(re).join(", ")})`:`(${re(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(re(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){Me.definitions=e;for(const i in e)t[i]=Me}}class ze{constructor(t,e,i){this.type=Qt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Ht);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Ht);if(!n)return null;let o=null;return i.locale&&(o=e.parse(i.locale,1,Wt),!o)?null:new ze(r,n,o)}evaluate(t){return new ue(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const ke=8192;function Pe(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function De(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Le(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*ke),Math.round(r*n*ke)]}function Re(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Be(t,e){let i=!1;for(let s=0,a=e.length;s<a;s++){const a=e[s];for(let e=0,s=a.length;e<s-1;e++){if(Re(t,a[e],a[e+1]))return!1;(n=a[e])[1]>(r=t)[1]!=(o=a[e+1])[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function Fe(t,e){for(let i=0;i<e.length;i++)if(Be(t,e[i]))return!0;return!1}function Oe(t,e,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(t[0]-i[0])*o-n*(t[1]-i[1]),a=(e[0]-i[0])*o-n*(e[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Ue(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(a=[(s=c[i+1])[0]-(o=c[i])[0],s[1]-o[1]])[0]*(l=[(n=e)[0]-(r=t)[0],n[1]-r[1]])[1]-a[1]*l[0]&&Oe(r,n,o,s)&&Oe(o,s,r,n))return!0;var r,n,o,s,a,l;return!1}function Ve(t,e){for(let i=0;i<t.length;++i)if(!Be(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(Ue(t[i],t[i+1],e))return!1;return!0}function Ne(t,e){for(let i=0;i<e.length;i++)if(Ve(t,e[i]))return!0;return!1}function Ge(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=[];for(let r=0;r<t[n].length;r++){const s=Le(t[n][r],i);Pe(e,s),o.push(s)}r.push(o)}return r}function Ze(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=Ge(t[n],e,i);r.push(o)}return r}function qe(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}Pe(e,t)}function je(t,e,i,r){const n=Math.pow(2,r.z)*ke,o=[r.x*ke,r.y*ke],s=[];for(const r of t)for(const t of r){const r=[t.x+o[0],t.y+o[1]];qe(r,e,i,n),s.push(r)}return s}function $e(t,e,i,r){const n=Math.pow(2,r.z)*ke,o=[r.x*ke,r.y*ke],s=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Pe(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const r of t)qe(r,e,i,n)}var a;return s}class Xe{constructor(t,e){this.type=Ht,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(_e(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Xe(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Xe(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Xe(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=Ge(e.coordinates,r,n),s=je(t.geometry(),i,r,n);if(!De(i,r))return!1;for(const t of s)if(!Be(t,o))return!1}if("MultiPolygon"===e.type){const o=Ze(e.coordinates,r,n),s=je(t.geometry(),i,r,n);if(!De(i,r))return!1;for(const t of s)if(!Fe(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const o=Ge(e.coordinates,r,n),s=$e(t.geometry(),i,r,n);if(!De(i,r))return!1;for(const t of s)if(!Ve(t,o))return!1}if("MultiPolygon"===e.type){const o=Ze(e.coordinates,r,n),s=$e(t.geometry(),i,r,n);if(!De(i,r))return!1;for(const t of s)if(!Ne(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function We(t){if(t instanceof Me){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Xe)return!1;let e=!0;return t.eachChild((t=>{e&&!We(t)&&(e=!1)})),e}function He(t){if(t instanceof Me&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!He(t)&&(e=!1)})),e}function Ke(t,e){if(t instanceof Me&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ke(t,e)&&(i=!1)})),i}class Ye{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Ye(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Je{constructor(t,e=[],i,r=new jt,n=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new we(e,[t]):"coerce"===i?new Ie(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof xe)&&"resolvedImage"!==r.type.kind&&Qe(r)){const e=new Ce;try{r=new xe(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new Je(this.registry,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new qt(i,t))}checkSubtype(t,e){const i=oe(t,e);return i&&this.error(i),i}}function Qe(t){if(t instanceof Ye)return Qe(t.boundExpression);if(t instanceof Me&&"error"===t.name)return!1;if(t instanceof ze)return!1;if(t instanceof Xe)return!1;const e=t instanceof Ie||t instanceof we;let i=!0;return t.eachChild((t=>{i=e?i&&Qe(t):i&&t instanceof xe})),!!i&&We(t)&&Ke(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script"])}function ti(t,e){const i=t.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;o=a+1}else{if(!(r>e))throw new ve("Input is not a number.");s=a-1}return 0}class ei{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,Xt);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const o=1===i?-1/0:t[i],s=t[i+1],a=i,l=i+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new ei(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[ti(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}function ii(t,e,i){return t*(1-i)+e*i}var ri=Object.freeze({__proto__:null,number:ii,color:function(t,e,i){return new he(ii(t.r,e.r,i),ii(t.g,e.g,i),ii(t.b,e.b,i),ii(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>ii(t,e[r],i)))}});const ni=.95047,oi=1.08883,si=4/29,ai=6/29,li=3*ai*ai,ci=Math.PI/180,hi=180/Math.PI;function ui(t){return t>.008856451679035631?Math.pow(t,1/3):t/li+si}function di(t){return t>ai?t*t*t:li*(t-si)}function pi(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function fi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function mi(t){const e=fi(t.r),i=fi(t.g),r=fi(t.b),n=ui((.4124564*e+.3575761*i+.1804375*r)/ni),o=ui((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-ui((.0193339*e+.119192*i+.9503041*r)/oi)),alpha:t.a}}function _i(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*di(e),i=ni*di(i),r=oi*di(r),new he(pi(3.2404542*i-1.5371385*e-.4985314*r),pi(-.969266*i+1.8760108*e+.041556*r),pi(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function gi(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const yi={forward:mi,reverse:_i,interpolate:function(t,e,i){return{l:ii(t.l,e.l,i),a:ii(t.a,e.a,i),b:ii(t.b,e.b,i),alpha:ii(t.alpha,e.alpha,i)}}},xi={forward:function(t){const{l:e,a:i,b:r}=mi(t),n=Math.atan2(r,i)*hi;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*ci,i=t.c;return _i({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:gi(t.h,e.h,i),c:ii(t.c,e.c,i),l:ii(t.l,e.l,i),alpha:ii(t.alpha,e.alpha,i)}}};var vi=Object.freeze({__proto__:null,lab:yi,hcl:xi});class bi{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,n){let o=0;if("exponential"===t.name)o=wi(e,t.base,r,n);else if("linear"===t.name)o=wi(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;o=new i(s[0],s[1],s[2],s[3]).solve(wi(e,1,r,n))}return o}static parse(t,e){let[i,r,n,...o]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error("Unknown interpolation type "+String(r[0]),1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,Xt),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Kt:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<o.length;t+=2){const i=o[t],r=o[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new bi(a,i,r,n,s):e.error(`Type ${re(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const o=ti(e,r),s=bi.interpolationFactor(this.interpolation,r,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?ri[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?xi.reverse(xi.interpolate(xi.forward(a),xi.forward(l),s)):yi.reverse(yi.interpolate(yi.forward(a),yi.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function wi(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}class Ti{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}const o=r&&n.some((t=>oe(r,t.type)));return new Ti(o?Jt:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof fe&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class Ei{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=e.parse(t[r+1],r+1);if(!o)return null;i.push([n,o])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Ei(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,i]of this.bindings)t.push(e,i.serialize());return t.push(this.result.serialize()),t}}class Si{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Xt),r=e.parse(t[2],2,ie(e.expectedType||Jt));return i&&r?new Si(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new ve(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new ve(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ve(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ii{constructor(t,e){this.type=Ht,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Jt),r=e.parse(t[2],2,Jt);return i&&r?se(i.type,[Ht,Wt,Xt,$t,Jt])?new Ii(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${re(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!ae(e,["boolean","string","number","null"]))throw new ve(`Expected first argument to be of type boolean, string, number or null, but found ${re(ge(e))} instead.`);if(!ae(i,["string","array"]))throw new ve(`Expected second argument to be of type array or string, but found ${re(ge(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Ai{constructor(t,e,i){this.type=Xt,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Jt),r=e.parse(t[2],2,Jt);if(!i||!r)return null;if(!se(i.type,[Ht,Wt,Xt,$t,Jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${re(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Xt);return n?new Ai(i,r,n):null}return new Ai(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!ae(e,["boolean","string","number","null"]))throw new ve(`Expected first argument to be of type boolean, string, number or null, but found ${re(ge(e))} instead.`);if(!ae(i,["string","array"]))throw new ve(`Expected second argument to be of type array or string, but found ${re(ge(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ci{constructor(t,e,i,r,n,o){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},o=[];for(let s=2;s<t.length-1;s+=2){let a=t[s];const l=t[s+1];Array.isArray(a)||(a=[a]);const c=e.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ge(t)))return null}else i=ge(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=o.length}const h=e.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=e.parse(t[1],1,Jt);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Ci(i,r,s,n,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ge(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const n=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?n(r[0]):r.map(n)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Mi{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const o=e.parse(t[n],n,Ht);if(!o)return null;const s=e.parse(t[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=e.parse(t[t.length-1],t.length-1,i);return n?new Mi(i,r,n):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class zi{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Jt),r=e.parse(t[2],2,Xt);if(!i||!r)return null;if(!se(i.type,[ie(Jt),Wt,Jt]))return e.error(`Expected first argument to be of type array or string, but found ${re(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Xt);return n?new zi(i.type,i,r,n):null}return new zi(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!ae(e,["string","array"]))throw new ve(`Expected first argument to be of type array or string, but found ${re(ge(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ki(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Pi(t,e,i,r){return 0===r.compare(e,i)}function Di(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=Ht,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,Jt);if(!o)return null;if(!ki(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${re(o.type)}'.`);let s=e.parse(t[2],2,Jt);if(!s)return null;if(!ki(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${re(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${re(o.type)}' and '${re(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new we(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new we(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Qt),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=ge(o),i=ge(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ve(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=ge(o),i=ge(s);if("string"!==t.kind||"string"!==i.kind)return e(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):e(n,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const Li=Di("==",(function(t,e,i){return e===i}),Pi),Ri=Di("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!Pi(0,e,i,r)})),Bi=Di("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),Fi=Di(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),Oi=Di("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),Ui=Di(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class Vi{constructor(t,e,i,r,n){this.type=Wt,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Xt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,Wt),!n))return null;let o=null;if(r.currency&&(o=e.parse(r.currency,1,Wt),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,Xt),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,Xt),!a)?null:new Vi(i,n,o,s,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Ni{constructor(t){this.type=Xt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${re(i.type)} instead.`):new Ni(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ve(`Expected value to be of type string or array, but found ${re(ge(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Gi={"==":Li,"!=":Ri,">":Fi,"<":Bi,">=":Ui,"<=":Oi,array:we,at:Si,boolean:we,case:Mi,coalesce:Ti,collator:ze,format:Te,image:Ee,in:Ii,"index-of":Ai,interpolate:bi,"interpolate-hcl":bi,"interpolate-lab":bi,length:Ni,let:Ei,literal:xe,match:Ci,number:we,"number-format":Vi,object:we,slice:zi,step:ei,string:we,"to-boolean":Ie,"to-color":Ie,"to-number":Ie,"to-string":Ie,var:Ye,within:Xe};function Zi(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const o=n?n.evaluate(t):1,s=me(e,i,r,o);if(s)throw new ve(s);return new he(e/255*o,i/255*o,r/255*o,o)}function qi(t,e){return t in e}function ji(t,e){const i=e[t];return void 0===i?null:i}function $i(t){return{type:t}}function Xi(t){return{result:"success",value:t}}function Wi(t){return{result:"error",value:t}}function Hi(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Ki(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Yi(t){return!!t.expression&&t.expression.interpolated}function Ji(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Qi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function tr(t){return t}function er(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),o=t.type||(Yi(e)?"exponential":"interval");if(i&&((t=Nt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],he.parse(t[1])]))),t.default=he.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!vi[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,a,l;if("exponential"===o)s=or;else if("interval"===o)s=nr;else if("categorical"===o){s=rr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=sr}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,er(i[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:bi.interpolationFactor.bind(void 0,o),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>or({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:bi.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?ir(t.default,e.default):s(t,e,n,a,l)}}}function ir(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function rr(t,e,i,r,n){return ir(typeof i===n?r[i]:void 0,t.default,e.default)}function nr(t,e,i){if("number"!==Ji(i))return ir(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=ti(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function or(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Ji(i))return ir(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const o=ti(t.stops.map((t=>t[0])),i),s=function(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=ri[e.type]||tr;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=vi[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function sr(t,e,i){return"color"===e.type?i=he.parse(i):"formatted"===e.type?i=pe.fromString(i.toString()):"resolvedImage"===e.type?i=fe.fromString(i.toString()):Ji(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),ir(i,t.default,e.default)}Me.register(Gi,{error:[{kind:"error"},[Wt],(t,[e])=>{throw new ve(e.evaluate(t))}],typeof:[Wt,[Jt],(t,[e])=>re(ge(e.evaluate(t)))],"to-rgba":[ie(Xt,4),[Kt],(t,[e])=>e.evaluate(t).toArray()],rgb:[Kt,[Xt,Xt,Xt],Zi],rgba:[Kt,[Xt,Xt,Xt,Xt],Zi],has:{type:Ht,overloads:[[[Wt],(t,[e])=>qi(e.evaluate(t),t.properties())],[[Wt,Yt],(t,[e,i])=>qi(e.evaluate(t),i.evaluate(t))]]},get:{type:Jt,overloads:[[[Wt],(t,[e])=>ji(e.evaluate(t),t.properties())],[[Wt,Yt],(t,[e,i])=>ji(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Jt,[Wt],(t,[e])=>ji(e.evaluate(t),t.featureState||{})],properties:[Yt,[],t=>t.properties()],"geometry-type":[Wt,[],t=>t.geometryType()],id:[Jt,[],t=>t.id()],zoom:[Xt,[],t=>t.globals.zoom],"heatmap-density":[Xt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xt,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Xt,[],t=>t.globals.skyRadialProgress||0],accumulated:[Jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xt,$i(Xt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Xt,$i(Xt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Xt,overloads:[[[Xt,Xt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xt],(t,[e])=>-e.evaluate(t)]]},"/":[Xt,[Xt,Xt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xt,[Xt,Xt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xt,[],()=>Math.LN2],pi:[Xt,[],()=>Math.PI],e:[Xt,[],()=>Math.E],"^":[Xt,[Xt,Xt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xt,[Xt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xt,[Xt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xt,[Xt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xt,[Xt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xt,[Xt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xt,[Xt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xt,[Xt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xt,[Xt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xt,[Xt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xt,[Xt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xt,$i(Xt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Xt,$i(Xt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Xt,[Xt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xt,[Xt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Xt,[Xt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Xt,[Xt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ht,[Wt,Jt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Ht,[Jt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ht,[Wt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Ht,[Wt,Jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Ht,[Jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Ht,[Wt,Jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Ht,[Jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Ht,[Wt,Jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Ht,[Jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Ht,[Wt,Jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Ht,[Jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Ht,[Jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ht,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ht,[ie(Wt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Ht,[ie(Jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ht,[Wt,ie(Jt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ht,[Wt,ie(Jt)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Ht,overloads:[[[Ht,Ht],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[$i(Ht),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Ht,overloads:[[[Ht,Ht],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[$i(Ht),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Ht,[Ht],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ht,[Wt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Wt,[Wt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Wt,[Wt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Wt,$i(Jt),(t,e)=>e.map((e=>ye(e.evaluate(t)))).join("")],"resolved-locale":[Wt,[Qt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class ar{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Ce,this._defaultValue=e?function(t){return"color"===t.type&&Qi(t.default)?new he(0,0,0,0):"color"===t.type?he.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ve(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function lr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Gi}function cr(t,e){const i=new Je(Gi,[],e?function(t){const e={color:Kt,string:Wt,number:Xt,enum:Wt,boolean:Ht,formatted:te,resolvedImage:ee};return"array"===t.type?ie(e[t.value]||Jt,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Xi(new ar(r,e)):Wi(i.errors)}class hr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!He(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}}class ur{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!He(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}interpolationFactor(t,e,i){return this.interpolationType?bi.interpolationFactor(this.interpolationType,t,e,i):0}}function dr(t,e){if("error"===(t=cr(t,e)).result)return t;const i=t.value.expression,r=We(i);if(!r&&!Hi(e))return Wi([new qt("","data expressions not supported")]);const n=Ke(i,["zoom"]);if(!n&&!Ki(e))return Wi([new qt("","zoom expressions not supported")]);const o=fr(i);return o||n?o instanceof qt?Wi([o]):o instanceof bi&&!Yi(e)?Wi([new qt("",'"interpolate" expressions cannot be used with this property')]):Xi(o?new ur(r?"camera":"composite",t.value,o.labels,o instanceof bi?o.interpolation:void 0):new hr(r?"constant":"source",t.value)):Wi([new qt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class pr{constructor(t,e){this._parameters=t,this._specification=e,Nt(this,er(this._parameters,this._specification))}static deserialize(t){return new pr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function fr(t){let e=null;if(t instanceof Ei)e=fr(t.result);else if(t instanceof Ti){for(const i of t.args)if(e=fr(i),e)break}else(t instanceof ei||t instanceof bi)&&t.input instanceof Me&&"zoom"===t.input.name&&(e=t);return e instanceof qt||t.eachChild((t=>{const i=fr(t);i instanceof qt?e=i:!e&&i?e=new qt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new qt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function mr(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,s=t.styleSpec;let a=[];const l=Ji(i);if("object"!==l)return[new Ut(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(n[l])h=n[l];else if(r[l])h=qr;else if(n["*"])h=n["*"];else{if(!r["*"]){a.push(new Ut(e,i[t],`unknown property "${t}"`));continue}h=qr}a=a.concat(h({key:(e?e+".":e)+t,value:i[t],valueSpec:c,style:o,styleSpec:s,object:i,objectKey:t},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new Ut(e,i,`missing required property "${t}"`));return a}function _r(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,o=t.key,s=t.arrayElementValidator||qr;if("array"!==Ji(e))return[new Ut(o,e,`array expected, ${Ji(e)} found`)];if(i.length&&e.length!==i.length)return[new Ut(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new Ut(o,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum};n.$version<7&&(a.function=i.function),"object"===Ji(i.value)&&(a=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(s({array:e,arrayIndex:t,value:e[t],valueSpec:a,style:r,styleSpec:n,key:`${o}[${t}]`}));return l}function gr(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Ji(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new Ut(e,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===Ji(r.minimum)&&(n=r.minimum[t.arrayIndex]),i<n)return[new Ut(e,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===Ji(r.maximum)&&(n=r.maximum[t.arrayIndex]),i>n)return[new Ut(e,i,`${i} is greater than the maximum value ${n}`)]}return[]}function yr(t){const e=t.valueSpec,i=Gt(t.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Ji(t.value.stops)&&"array"===Ji(t.value.stops[0])&&"object"===Ji(t.value.stops[0][0]),h=mr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new Ut(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(_r({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Ji(r)&&0===r.length&&e.push(new Ut(t.key,r,"array must have at least one stop")),e},default:function(t){return qr({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new Ut(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new Ut(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Yi(t.valueSpec)&&h.push(new Ut(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Hi(t.valueSpec)?h.push(new Ut(t.key,t.value,"property functions not supported")):a&&!Ki(t.valueSpec)&&h.push(new Ut(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new Ut(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==Ji(r))return[new Ut(a,r,`array expected, ${Ji(r)} found`)];if(2!==r.length)return[new Ut(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Ji(r[0]))return[new Ut(a,r,`object expected, ${Ji(r[0])} found`)];if(void 0===r[0].zoom)return[new Ut(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Ut(a,r,"object stop key must have value")];if(o&&o>Gt(r[0].zoom))return[new Ut(a,r[0].zoom,"stop zoom values must appear in ascending order")];Gt(r[0].zoom)!==o&&(o=Gt(r[0].zoom),n=void 0,s={}),i=i.concat(mr({key:a+"[0]",value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:gr,value:d}}))}else i=i.concat(d({key:a+"[0]",value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return lr(Zt(r[1]))?i.concat([new Ut(a+"[1]",r[1],"expressions are not allowed in function stops.")]):i.concat(qr({key:a+"[1]",value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function d(t,o){const a=Ji(t.value),l=Gt(t.value),c=null!==t.value?t.value:o;if(r){if(a!==r)return[new Ut(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Ut(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return Hi(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ut(t.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new Ut(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new Ut(t.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Ut(t.key,c,"integer expected, found "+l)]}}function xr(t){const e=("property"===t.expressionContext?dr:cr)(Zt(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new Ut(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new Ut(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!He(i))return[new Ut(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!He(i))return[new Ut(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ke(i,["zoom","feature-state"]))return[new Ut(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!We(i))return[new Ut(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function vr(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Gt(i))&&n.push(new Ut(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Gt(i))&&n.push(new Ut(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function br(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!br(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const wr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Tr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};br(t)||(t=Ir(t));const e=cr(t,wr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:Sr(t)}}function Er(t,e){return t<e?-1:t>e?1:0}function Sr(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(Sr(t[e]))return!0;return!1}function Ir(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?Ar(t[1],t[2],"=="):"!="===e?zr(Ar(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?Ar(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Ir))):"all"===e?["all"].concat(t.slice(1).map(Ir)):"none"===e?["all"].concat(t.slice(1).map(Ir).map(zr)):"in"===e?Cr(t[1],t.slice(2)):"!in"===e?zr(Cr(t[1],t.slice(2))):"has"===e?Mr(t[1]):"!has"===e?zr(Mr(t[1])):"within"!==e||t;var i}function Ar(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 Cr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Er)]]:["filter-in-small",t,["literal",e]]}}function Mr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function zr(t){return["!",t]}function kr(t){return br(Zt(t.value))?xr(Nt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Pr(t)}function Pr(t){const e=t.value,i=t.key;if("array"!==Ji(e))return[new Ut(i,e,`array expected, ${Ji(e)} found`)];const r=t.styleSpec;let n,o=[];if(e.length<1)return[new Ut(i,e,"filter array must have at least 1 element")];switch(o=o.concat(vr({key:i+"[0]",value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Gt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Gt(e[1])&&o.push(new Ut(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new Ut(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Ji(e[1]),"string"!==n&&o.push(new Ut(i+"[1]",e[1],`string expected, ${n} found`)));for(let s=2;s<e.length;s++)n=Ji(e[s]),"$type"===Gt(e[1])?o=o.concat(vr({key:`${i}[${s}]`,value:e[s],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new Ut(`${i}[${s}]`,e[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)o=o.concat(Pr({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Ji(e[1]),2!==e.length?o.push(new Ut(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new Ut(i+"[1]",e[1],`string expected, ${n} found`));break;case"within":n=Ji(e[1]),2!==e.length?o.push(new Ut(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new Ut(i+"[1]",e[1],`object expected, ${n} found`))}return o}function Dr(t,e){const i=t.key,r=t.style,n=t.styleSpec,o=t.value,s=t.objectKey,a=n[`${e}_${t.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===e&&l&&a[l[1]]&&a[l[1]].transition)return qr({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=t.valueSpec||a[s];if(!c)return[new Ut(i,o,`unknown property "${s}"`)];let h;if("string"===Ji(o)&&Hi(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new Ut(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===s&&r&&!r.glyphs&&u.push(new Ut(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&Qi(Zt(o))&&"identity"===Gt(o.type)&&u.push(new Ut(i,o,'"text-font" does not support identity functions'))),u.concat(qr({key:t.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:s}))}function Lr(t){return Dr(t,"paint")}function Rr(t){return Dr(t,"layout")}function Br(t){let e=[];const i=t.value,r=t.key,n=t.style,o=t.styleSpec;i.type||i.ref||e.push(new Ut(r,i,'either "type" or "ref" is required'));let s=Gt(i.type);const a=Gt(i.ref);if(i.id){const o=Gt(i.id);for(let s=0;s<t.arrayIndex;s++){const t=n.layers[s];Gt(t.id)===o&&e.push(new Ut(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new Ut(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{Gt(e.id)===a&&(t=e)})),t?t.ref?e.push(new Ut(r,i.ref,"ref cannot reference another ref layer")):s=Gt(t.type):e.push(new Ut(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const t=n.sources&&n.sources[i.source],o=t&&Gt(t.type);t?"vector"===o&&"raster"===s?e.push(new Ut(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?e.push(new Ut(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new Ut(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&t.lineMetrics||e.push(new Ut(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ut(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Ut(r,i.source,`source "${i.source}" not found`))}else e.push(new Ut(r,i,'missing required property "source"'));return e=e.concat(mr({key:r,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>qr({key:r+".type",value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:kr,layout:t=>mr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Rr(Nt({layerType:s},t))}}),paint:t=>mr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Lr(Nt({layerType:s},t))}})}})),e}function Fr(t){const e=t.value,i=t.key,r=Ji(e);return"string"!==r?[new Ut(i,e,`string expected, ${r} found`)]:[]}const Or={promoteId:function({key:t,value:e}){if("string"===Ji(e))return Fr({key:t,value:e});{const i=[];for(const r in e)i.push(...Fr({key:`${t}.${r}`,value:e[r]}));return i}}};function Ur(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style;if(!e.type)return[new Ut(i,e,'"type" is required')];const o=Gt(e.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=mr({key:i,value:e,valueSpec:r["source_"+o.replace("-","_")],style:t.style,styleSpec:r,objectElementValidators:Or}),s;case"geojson":if(s=mr({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:Or}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;s.push(...xr({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),s.push(...xr({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return mr({key:i,value:e,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return mr({key:i,value:e,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new Ut(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return vr({key:i+".type",value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function Vr(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let o=[];const s=Ji(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Ut("light",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?qr({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?qr({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new Ut(t,e[t],`unknown property "${t}"`)])}return o}function Nr(t){const e=t.value,i=t.key,r=t.style,n=t.styleSpec,o=n.terrain;let s=[];const a=Ji(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Ut("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const i=t.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?qr({key:t,value:e[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?qr({key:t,value:e[t],valueSpec:o[t],style:r,styleSpec:n}):[new Ut(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],n=t&&Gt(t.type);t?"raster-dem"!==n&&s.push(new Ut(i,e.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):s.push(new Ut(i,e.source,`source "${e.source}" not found`))}else s.push(new Ut(i,e,'terrain is missing required property "source"'));return s}function Gr(t){const e=t.value,i=t.style,r=t.styleSpec,n=r.fog;let o=[];const s=Ji(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Ut("fog",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?qr({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):n[t]?qr({key:t,value:e[t],valueSpec:n[t],style:i,styleSpec:r}):[new Ut(t,e[t],`unknown property "${t}"`)])}return o}const Zr={"*":()=>[],array:_r,boolean:function(t){const e=t.value,i=t.key,r=Ji(e);return"boolean"!==r?[new Ut(i,e,`boolean expected, ${r} found`)]:[]},number:gr,color:function(t){const e=t.key,i=t.value,r=Ji(i);return"string"!==r?[new Ut(e,i,`color expected, ${r} found`)]:null===ce.parseCSSColor(i)?[new Ut(e,i,`color expected, "${i}" found`)]:[]},constants:Vt,enum:vr,filter:kr,function:yr,layer:Br,object:mr,source:Ur,light:Vr,terrain:Nr,fog:Gr,string:Fr,formatted:function(t){return 0===Fr(t).length?[]:xr(t)},resolvedImage:function(t){return 0===Fr(t).length?[]:xr(t)}};function qr(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Qi(Gt(e))?yr(t):i.expression&&lr(Zt(e))?xr(t):i.type&&Zr[i.type]?Zr[i.type](t):mr(Nt({},t,{valueSpec:i.type?r[i.type]:i}))}function jr(t){const e=t.value,i=t.key,r=Fr(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Ut(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Ut(i,e,'"glyphs" url must include a "{range}" token'))),r}function $r(t,e=Ot){let i=[];return i=i.concat(qr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:jr,"*":()=>[]}})),t.constants&&(i=i.concat(Vt({key:"constants",value:t.constants,style:t,styleSpec:e}))),Xr(i)}function Xr(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Wr(t){return function(...e){return Xr(t.apply(this,e))}}$r.source=Wr(Ur),$r.light=Wr(Vr),$r.terrain=Wr(Nr),$r.fog=Wr(Gr),$r.layer=Wr(Br),$r.filter=Wr(kr),$r.paintProperty=Wr(Lr),$r.layoutProperty=Wr(Rr);const Hr=$r,Kr=Hr.light,Yr=Hr.fog,Jr=Hr.paintProperty,Qr=Hr.layoutProperty;function tn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new Bt(new Error(r.message))),i=!0;return i}var en=rn;function rn(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var s=n[3+o],a=n[3+o+1];r.push(s===a?null:n.subarray(s,a))}var l=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var h=i/e*t;this.min=-h,this.max=t+h}rn.prototype.insert=function(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},rn.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},rn.prototype._insertCell=function(t,e,i,r,n,o){this.cells[n].push(o)},rn.prototype.query=function(t,e,i,r,n){var o=this.min,s=this.max;if(t<=o&&e<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,i,r,this._queryCell,a,{},n),a},rn.prototype._queryCell=function(t,e,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var d=l[u];if(void 0===s[d]){var p=4*d;(a?a(h[p+0],h[p+1],h[p+2],h[p+3]):t<=h[p+2]&&e<=h[p+3]&&i>=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},rn.prototype._forEachCell=function(t,e,i,r,n,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,t,e,i,r,f,o,s,a))return}},rn.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},rn.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},rn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(e+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=e,s=0;s<t.length;s++){var a=t[s];n[3+s]=o,n.set(a,o),o+=a.length}return n[3+t.length]=o,n.set(this.keys,o),n[3+t.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const{ImageData:nn,ImageBitmap:on}=s,sn={};function an(t,e,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),sn[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}an("Object",Object),en.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},en.deserialize=function(t){return new en(t.buffer)},an("Grid",en),an("Color",he),an("Error",Error),an("ResolvedImage",fe),an("StylePropertyFunction",pr),an("StyleExpression",ar,{omit:["_evaluator"]}),an("ZoomDependentExpression",ur),an("ZoomConstantExpression",hr),an("CompoundExpression",Me,{omit:["_evaluate"]});for(const t in Gi)Gi[t]._classRegistryKey||an("Expression_"+t,Gi[t]);function ln(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function cn(t){return on&&t instanceof on}function hn(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(ln(t)||cn(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof nn)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(hn(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class");const n=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const i in t){if(!t.hasOwnProperty(i))continue;if(sn[r].omit.indexOf(i)>=0)continue;const o=t[i];n[i]=sn[r].shallow.indexOf(i)>=0?o:hn(o,e)}t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof t)}function un(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ln(t)||cn(t)||ArrayBuffer.isView(t)||t instanceof nn)return t;if(Array.isArray(t))return t.map(un);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=sn[e];if(!i)throw new Error("can't deserialize unregistered class "+e);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const n=t[i];r[i]=sn[e].shallow.indexOf(i)>=0?n:un(n)}return r}throw new Error("can't deserialize object of type "+typeof t)}class dn{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const pn=t=>t>=1536&&t<=1791,fn=t=>t>=1872&&t<=1919,mn=t=>t>=2208&&t<=2303,_n=t=>t>=11904&&t<=12031,gn=t=>t>=12032&&t<=12255,yn=t=>t>=12272&&t<=12287,xn=t=>t>=12288&&t<=12351,vn=t=>t>=12352&&t<=12447,bn=t=>t>=12448&&t<=12543,wn=t=>t>=12544&&t<=12591,Tn=t=>t>=12704&&t<=12735,En=t=>t>=12736&&t<=12783,Sn=t=>t>=12784&&t<=12799,In=t=>t>=12800&&t<=13055,An=t=>t>=13056&&t<=13311,Cn=t=>t>=13312&&t<=19903,Mn=t=>t>=19968&&t<=40959,zn=t=>t>=40960&&t<=42127,kn=t=>t>=42128&&t<=42191,Pn=t=>t>=44032&&t<=55215,Dn=t=>t>=63744&&t<=64255,Ln=t=>t>=64336&&t<=65023,Rn=t=>t>=65040&&t<=65055,Bn=t=>t>=65072&&t<=65103,Fn=t=>t>=65104&&t<=65135,On=t=>t>=65136&&t<=65279,Un=t=>t>=65280&&t<=65519;function Vn(t){for(const e of t)if(Zn(e.charCodeAt(0)))return!0;return!1}function Nn(t){for(const e of t)if(!Gn(e.charCodeAt(0)))return!1;return!0}function Gn(t){return!(pn(t)||fn(t)||mn(t)||Ln(t)||On(t))}function Zn(t){return!(746!==t&&747!==t&&(t<4352||!(Tn(t)||wn(t)||Bn(t)&&!(t>=65097&&t<=65103)||Dn(t)||An(t)||_n(t)||En(t)||!(!xn(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Cn(t)||Mn(t)||In(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||Pn(t)||vn(t)||yn(t)||(t=>t>=12688&&t<=12703)(t)||gn(t)||Sn(t)||bn(t)&&12540!==t||!(!Un(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Fn(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||Rn(t)||(t=>t>=19904&&t<=19967)(t)||zn(t)||kn(t))))}function qn(t){return!(Zn(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||xn(t)||bn(t)||(t=>t>=57344&&t<=63743)(t)||Bn(t)||Fn(t)||Un(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function jn(t){return t>=1424&&t<=2303||Ln(t)||On(t)}function $n(t,e){return!(!e&&jn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function Xn(t){for(const e of t)if(jn(e.charCodeAt(0)))return!0;return!1}const Wn="deferred",Hn="loading",Kn="loaded";let Yn=null,Jn="unavailable",Qn=null;const to=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(Jn="error"),Yn&&Yn(t)};function eo(){io.fire(new Rt("pluginStateChange",{pluginStatus:Jn,pluginURL:Qn}))}const io=new Ft,ro=function(){return Jn},no=function(){if(Jn!==Wn||!Qn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Jn=Hn,eo(),Qn&&St({url:Qn},(t=>{t?to(t):(Jn=Kn,eo())}))},oo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Jn===Kn||null!=oo.applyArabicShaping,isLoading:()=>Jn===Hn,setState(t){Jn=t.pluginStatus,Qn=t.pluginURL},isParsed:()=>null!=oo.applyArabicShaping&&null!=oo.processBidirectionalText&&null!=oo.processStyledBidirectionalText,getPluginURL:()=>Qn};class so{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new dn,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!$n(i.charCodeAt(0),e))return!1;return!0}(t,oo.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class ao{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Qi(t))return new pr(t,e);if(lr(t)){const i=dr(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=he.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class lo{constructor(t){this.property=t,this.value=new ao(t,void 0)}transitioned(t,e){return new ho(this.property,this.value,e,x({},t.transition,this.transition),t.now)}untransitioned(){return new ho(this.property,this.value,null,{},0)}}class co{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return M(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new lo(this._values[t].property)),this._values[t].value=new ao(this._values[t].property,null===e?void 0:M(e))}getTransition(t){return M(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new lo(this._values[t].property)),this._values[t].transition=M(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[e+"-transition"]=r)}return t}transitioned(t,e){const i=new uo(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new uo(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ho{constructor(t,e,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=t,this.value=e,this.begin=n+o,this.end=this.begin+s,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(t,e,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,i),n,d(s))}}return n}}class uo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new mo(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class po{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return M(this._values[t].value)}setValue(t,e){this._values[t]=new ao(this._values[t].property,null===e?void 0:M(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new mo(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}}class fo{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class mo{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class _o{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=ri[this.specification.type];return r?r(t,e,i):t}}class go{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new fo(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new fo(this,{kind:"constant",value:void 0},t.parameters);const r=ri[this.specification.type];return r?new fo(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,n,o){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,o)}}class yo extends go{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new fo(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),o="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,e);return new fo(this,{kind:"constant",value:s},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new fo(this,{kind:"constant",value:i},e)}return new fo(this,t.expression,e)}evaluate(t,e,i,r,n,o){if("source"===t.kind){const s=t.evaluate(e,i,r,n,o);return this._calculate(s,s,s,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class xo{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new so(Math.floor(e.zoom-1),e)),t.expression.evaluate(new so(Math.floor(e.zoom),e)),t.expression.evaluate(new so(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class vo{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class bo{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new ao(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new lo(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}function wo(t,e){return 256*(t=m(Math.floor(t),0,255))+m(Math.floor(e),0,255)}an("DataDrivenProperty",go),an("DataConstantProperty",_o),an("CrossFadedDataDrivenProperty",yo),an("CrossFadedProperty",xo),an("ColorRampProperty",vo);const To={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Eo{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class So{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Io(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=To[t.type].BYTES_PER_ELEMENT,o=i=Ao(i,Math.max(e,n)),s=t.components||1;return r=Math.max(r,n),i+=n*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Ao(i,Math.max(r,e)),alignment:e}}function Ao(t,e){return Math.ceil(t/e)*e}class Co extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Co.prototype.bytesPerElement=4,an("StructArrayLayout2i4",Co);class Mo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,t}}Mo.prototype.bytesPerElement=8,an("StructArrayLayout4i8",Mo);class zo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o,s)}emplace(t,e,i,r,n,o,s,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,t}}zo.prototype.bytesPerElement=12,an("StructArrayLayout2i4ub1f12",zo);class ko extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}ko.prototype.bytesPerElement=8,an("StructArrayLayout2f8",ko);class Po extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,o,s,a,l,c)}emplace(t,e,i,r,n,o,s,a,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=s,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Po.prototype.bytesPerElement=20,an("StructArrayLayout10ui20",Po);class Do extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,o,s,a)}emplace(t,e,i,r,n,o,s,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}Do.prototype.bytesPerElement=16,an("StructArrayLayout8ui16",Do);class Lo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,n,o,s,a,l,c,h,u)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}Lo.prototype.bytesPerElement=24,an("StructArrayLayout4i4ui4i24",Lo);class Ro extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}Ro.prototype.bytesPerElement=12,an("StructArrayLayout3f12",Ro);class Bo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Bo.prototype.bytesPerElement=4,an("StructArrayLayout1ul4",Bo);class Fo extends So{_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(t,e,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,o,s,a,l,c)}emplace(t,e,i,r,n,o,s,a,l,c,h){const u=16*t,d=8*t;return this.int16[u+0]=e,this.int16[u+1]=i,this.float32[d+1]=r,this.float32[d+2]=n,this.float32[d+3]=o,this.float32[d+4]=s,this.int16[u+10]=a,this.uint32[d+6]=l,this.uint16[u+14]=c,this.uint16[u+15]=h,t}}Fo.prototype.bytesPerElement=32,an("StructArrayLayout2i4f1i1ul2ui32",Fo);class Oo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,t}}Oo.prototype.bytesPerElement=12,an("StructArrayLayout2i2i2i12",Oo);class Uo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n)}emplace(t,e,i,r,n,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,t}}Uo.prototype.bytesPerElement=16,an("StructArrayLayout2f1f2i16",Uo);class Vo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,t}}Vo.prototype.bytesPerElement=12,an("StructArrayLayout2ub2f12",Vo);class No extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}No.prototype.bytesPerElement=6,an("StructArrayLayout3ui6",No);class Go extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=n,this.uint32[x+2]=o,this.uint32[x+3]=s,this.uint32[x+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[x+10]=_,this.int16[y+22]=g,t}}Go.prototype.bytesPerElement=48,an("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Go);class Zo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const A=this.length;return this.resize(A+1),this.emplace(A,t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,A){const C=32*t,M=16*t;return this.int16[C+0]=e,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=n,this.int16[C+4]=o,this.int16[C+5]=s,this.int16[C+6]=a,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=_,this.uint16[C+16]=g,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[M+12]=E,this.float32[M+13]=S,this.float32[M+14]=I,this.float32[M+15]=A,t}}Zo.prototype.bytesPerElement=64,an("StructArrayLayout8i15ui1ul3f64",Zo);class qo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}qo.prototype.bytesPerElement=4,an("StructArrayLayout1f4",qo);class jo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}jo.prototype.bytesPerElement=6,an("StructArrayLayout3i6",jo);class $o extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,t}}$o.prototype.bytesPerElement=12,an("StructArrayLayout1ul3ui12",$o);class Xo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Xo.prototype.bytesPerElement=4,an("StructArrayLayout2ui4",Xo);class Wo extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Wo.prototype.bytesPerElement=2,an("StructArrayLayout1ui2",Wo);class Ho extends So{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,t}}Ho.prototype.bytesPerElement=16,an("StructArrayLayout4f16",Ho);class Ko extends Eo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.float32[this._pos4+1]}get y1(){return this._structArray.float32[this._pos4+2]}get x2(){return this._structArray.float32[this._pos4+3]}get y2(){return this._structArray.float32[this._pos4+4]}get padding(){return this._structArray.int16[this._pos2+10]}get featureIndex(){return this._structArray.uint32[this._pos4+6]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+14]}get bucketIndex(){return this._structArray.uint16[this._pos2+15]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}Ko.prototype.size=32;class Yo extends Fo{get(t){return new Ko(this,t)}}an("CollisionBoxArray",Yo);class Jo extends Eo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Jo.prototype.size=48;class Qo extends Go{get(t){return new Jo(this,t)}}an("PlacedSymbolArray",Qo);class ts extends Eo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textOffset0(){return this._structArray.float32[this._pos4+13]}get textOffset1(){return this._structArray.float32[this._pos4+14]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+15]}}ts.prototype.size=64;class es extends Zo{get(t){return new ts(this,t)}}an("SymbolInstanceArray",es);class is extends qo{getoffsetX(t){return this.float32[1*t+0]}}an("GlyphOffsetArray",is);class rs extends jo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}an("SymbolLineVertexArray",rs);class ns extends Eo{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]}}ns.prototype.size=12;class os extends $o{get(t){return new ns(this,t)}}an("FeatureIndexArray",os);class ss extends Eo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ss.prototype.size=4;class as extends Xo{get(t){return new ss(this,t)}}an("FillExtrusionCentroidArray",as);const ls=Io([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),cs=Io([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var hs=le((function(t){t.exports=function(t,e){var i,r,n,o,s,a,l,c;for(r=t.length-(i=3&t.length),n=e,s=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}})),us=le((function(t){t.exports=function(t,e){for(var i,r=t.length,n=e^r,o=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&t.charCodeAt(o+2))<<16;case 2:n^=(255&t.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),ds=hs,ps=us;ds.murmur3=hs,ds.murmur2=ps;class fs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(ms(t)),this.positions.push(e,i,r)}getPositions(t){const e=ms(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return _s(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new fs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ms(t){const e=+t;return!isNaN(e)&&e<=a?e:ds(String(t))}function _s(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(t[o]<n);do{s--}while(t[s]>n);if(o>=s)break;gs(t,o,s),gs(e,3*o,3*s),gs(e,3*o+1,3*s+1),gs(e,3*o+2,3*s+2)}s-i<r-s?(_s(t,e,i,s),i=s+1):(_s(t,e,s+1,r),r=s)}}function gs(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}an("FeaturePositionMap",fs);class ys{constructor(t,e){this.gl=t.gl,this.location=e}}class xs extends ys{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class vs extends ys{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class bs extends ys{constructor(t,e){super(t,e),this.current=he.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const ws=new Float32Array(16),Ts=new Float32Array(9);function Es(t){return[wo(255*t.r,255*t.g),wo(255*t.b,255*t.a)]}class Ss{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>"u_"+t)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new bs(t,e):new xs(t,e)}}class Is{constructor(t,e){this.uniformNames=e.map((t=>"u_"+t)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new vs(t,e):new xs(t,e)}}class As{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:"a_"+t,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n){const o=this.paintVertexArray.length,s=this.expression.evaluate(new so(0),e,{},r,[],n);this.paintVertexArray.resize(t),this._setPaintValue(o,t,s)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){const r=Es(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Cs{constructor(t,e,i,r,n,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:"a_"+t,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,r,n){const o=this.expression.evaluate(new so(this.zoom),e,{},r,[],n),s=this.expression.evaluate(new so(this.zoom+1),e,{},r,[],n),a=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(a,t,o,s)}updatePaintArray(t,e,i,r){const n=this.expression.evaluate({zoom:this.zoom},i,r),o=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,n,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=Es(i),o=Es(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=m(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new xs(t,e)}}class Ms{constructor(t,e,i,r,n,o,s){this.expression=t,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=s,this.paintVertexAttributes=("array"===i?cs:ls).members;for(let t=0;t<e.length;++t);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],n)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:o,max:s}=i,a=r[n],l=r[o],c=r[s];if(a&&l&&c)for(let i=t;i<e;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(t,e,i,r){t.emplace(e,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class zs{constructor(t,e,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const o=t.paint.get(n);if(!(o instanceof fo&&Hi(o.property.specification)))continue;const s=Ds(n,t.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h,d="line-dasharray"===String(n)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||d)if("source"===a.kind||d||u){const i=Bs(n,l,"source");this.binders[n]=u?new Ms(a,s,l,c,e,i,t.id):new As(a,s,l,i),r.push("/a_"+n)}else{const t=Bs(n,l,"composite");this.binders[n]=new Cs(a,s,l,c,e,t),r.push("/z_"+n)}else this.binders[n]=u?new Is(a.value,s):new Ss(a.value,s,l),r.push("/u_"+n)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof As||e instanceof Cs?e.maxValue:0}populatePaintArrays(t,e,i,r,n){for(const o in this.binders){const s=this.binders[o];(s instanceof As||s instanceof Cs||s instanceof Ms)&&s.populatePaintArray(t,e,i,r,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Is&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n){let o=!1;for(const s in t){const a=e.getPositions(s);for(const e of a){const a=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof As||l instanceof Cs||l instanceof Ms)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,a,t[s],n),o=!0}}}}return o}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Ss||i instanceof Is)&&t.push(...i.uniformNames.map((t=>"#define HAS_UNIFORM_"+t)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof As||i instanceof Cs||i instanceof Ms)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ss||i instanceof Is||i instanceof Cs)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Ss||n instanceof Is||n instanceof Cs)for(const o of n.uniformNames)if(e[o]){const s=n.getBinding(t,e[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:o}of e)this.binders[n].setUniform(o,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof Ms){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof As||i instanceof Cs)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof As||i instanceof Cs||i instanceof Ms)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof As||e instanceof Cs||e instanceof Ms)&&e.destroy()}}}class ks{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new zs(r,e,i);this.needsUpload=!1,this._featureMap=new fs,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,o);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Ps={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function Ds(t,e){return Ps[t]||[t.replace(e+"-","").replace(/-/g,"_")]}const Ls={"line-pattern":{source:Po,composite:Po},"fill-pattern":{source:Po,composite:Po},"fill-extrusion-pattern":{source:Po,composite:Po},"line-dasharray":{source:Do,composite:Do}},Rs={color:{source:ko,composite:Ho},number:{source:qo,composite:ko}};function Bs(t,e,i){const r=Ls[t];return r&&r[i]||Rs[e][i]}an("ConstantBinder",Ss),an("CrossFadedConstantBinder",Is),an("SourceExpressionBinder",As),an("CrossFadedCompositeBinder",Ms),an("CompositeExpressionBinder",Cs),an("ProgramConfiguration",zs,{omit:["_buffers"]}),an("ProgramConfigurationSet",ks);const Fs="-transition";class Os extends Ft{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=(t=t).metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new po(e.layout)),e.paint)){this._transitionablePaint=new co(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new mo(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(Qr,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return I(t,Fs)?this._transitionablePaint.getTransition(t.slice(0,-Fs.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Jr,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(I(t,Fs))return this._transitionablePaint.setTransition(t.slice(0,-Fs.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,o,s)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),C(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&tn(this,t.call(Hr,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:Ot,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof fo&&Hi(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Us=Io([{name:"a_pos",components:2,type:"Int16"}],4),{members:Vs}=Us;class Ns{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let n=this.segments[this.segments.length-1];return t>Ns.MAX_VERTEX_ARRAY_LENGTH&&k(`Max vertices per segment is ${Ns.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!n||n.vertexLength+t>Ns.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new Ns([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}Ns.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,an("SegmentVector",Ns);var Gs=8192;const Zs=Math.pow(2,14)-1,qs=-Zs-1;function js(t){const e=Gs/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],n=Math.round(i.x*e),o=Math.round(i.y*e);i.x=m(n,qs,Zs),i.y=m(o,qs,Zs),(n<i.x||n>i.x+1||o<i.y||o>i.y+1)&&k("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function $s(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?js(t):[]}}function Xs(t,e,i,r,n){t.emplaceBack(2*e+(r+1)/2,2*i+(n+1)/2)}class Ws{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Co,this.indexArray=new No,this.segments=new Ns,this.programConfigurations=new ks(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],n=[];let o=null;"circle"===r.type&&(o=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=$s(e,t);if(!this.layers[0]._featureFilter.filter(new so(this.zoom),l,i))continue;const c=o?o.evaluate(l,{},i):void 0,h={id:r,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:js(e),patterns:{},sortKey:c};n.push(h)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r,a=t[o].feature;this.addFeature(r,n,o,i),e.featureIndex.insert(a,n,o,s,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Vs),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=Gs||r<0||r>=Gs)continue;const n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=n.vertexLength;Xs(this.layoutVertexArray,i,r,-1,-1),Xs(this.layoutVertexArray,i,r,1,-1),Xs(this.layoutVertexArray,i,r,1,1),Xs(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+3,o+2),n.vertexLength+=4,n.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function Hs(t,e){for(let i=0;i<t.length;i++)if(na(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(na(t,e[i]))return!0;return!!Qs(t,e)}function Ks(t,e,i){return!!na(t,e)||!!ea(e,t,i)}function Ys(t,e){if(1===t.length)return ra(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(na(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(ra(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Qs(t,e[i]))return!0;return!1}function Js(t,e,i){if(t.length>1){if(Qs(t,e))return!0;for(let r=0;r<e.length;r++)if(ea(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(ea(t[r],e,i))return!0;return!1}function Qs(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(ta(r,n,e[t],e[t+1]))return!0}return!1}function ta(t,e,i,r){return P(t,i,r)!==P(e,i,r)&&P(t,e,i)!==P(t,e,r)}function ea(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(ia(t,e[i-1],e[i])<r)return!0;return!1}function ia(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function ra(t,e){let i,r,n,o=!1;for(let s=0;s<t.length;s++){i=t[s];for(let t=0,s=i.length-1;t<i.length;s=t++)r=i[t],n=i[s],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function na(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const o=t[r],s=t[n];o.y>e.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function oa(t,e,i,r,o){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&o>=n.y)return!0;const s=[new n(e,i),new n(e,o),new n(r,o),new n(r,i)];if(t.length>2)for(const e of s)if(na(t,e))return!0;for(let e=0;e<t.length-1;e++)if(sa(t[e],t[e+1],s))return!0;return!1}function sa(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const o=P(t,e,i[0]);return o!==P(t,e,i[1])||o!==P(t,e,i[2])||o!==P(t,e,i[3])}function aa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function la(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ca(t,e,i,r,o){if(!e[0]&&!e[1])return t;const s=n.convert(e)._mult(o);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(s));return a}function ha(t,e,i,r){const o=n.convert(t)._mult(r);return"viewport"===e&&o._rotate(-i),o}an("CircleBucket",Ws,{omit:["layers"]});const ua=new bo({"circle-sort-key":new go(Ot.layout_circle["circle-sort-key"])});var da={paint:new bo({"circle-radius":new go(Ot.paint_circle["circle-radius"]),"circle-color":new go(Ot.paint_circle["circle-color"]),"circle-blur":new go(Ot.paint_circle["circle-blur"]),"circle-opacity":new go(Ot.paint_circle["circle-opacity"]),"circle-translate":new _o(Ot.paint_circle["circle-translate"]),"circle-translate-anchor":new _o(Ot.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new _o(Ot.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new _o(Ot.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new go(Ot.paint_circle["circle-stroke-width"]),"circle-stroke-color":new go(Ot.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new go(Ot.paint_circle["circle-stroke-opacity"])}),layout:ua},pa="undefined"!=typeof Float32Array?Float32Array:Array;function fa(){var t=new pa(9);return pa!=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 ma(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 _a(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*a+b*u+w*m,t[1]=x*n+v*l+b*d+w*_,t[2]=x*o+v*c+b*p+w*g,t[3]=x*s+v*h+b*f+w*y,t[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,t[5]=x*n+v*l+b*d+w*_,t[6]=x*o+v*c+b*p+w*g,t[7]=x*s+v*h+b*f+w*y,t[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,t[9]=x*n+v*l+b*d+w*_,t[10]=x*o+v*c+b*p+w*g,t[11]=x*s+v*h+b*f+w*y,t[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,t[13]=x*n+v*l+b*d+w*_,t[14]=x*o+v*c+b*p+w*g,t[15]=x*s+v*h+b*f+w*y,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var ga=_a;function ya(){var t=new pa(3);return pa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function xa(t){return Math.hypot(t[0],t[1],t[2])}function va(t,e,i){var r=new pa(3);return r[0]=t,r[1]=e,r[2]=i,r}function ba(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function wa(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function Ta(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function Ea(t,e){var i=e[0],r=e[1],n=e[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function Sa(t,e,i){var r=i[0],n=i[1],o=i[2],s=e[0],a=e[1],l=e[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,d=n*u-o*h,p=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,t[0]=s+(c*=m)+(d*=2),t[1]=a+h+p,t[2]=l+u+f,t}var Ia,Aa=ba,Ca=wa,Ma=xa;function za(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,t[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,t[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,t[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,t}function ka(){var t=new pa(4);return pa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Pa(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Da(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+s*a,t[1]=n*l+o*a,t[2]=o*l-n*a,t[3]=s*l-r*a,t}function La(t,e,i){const r=za([],[t.x,t.y,e,1],i);return new n(r[0]/r[3],r[1]/r[3])}ya(),Ia=new pa(4),pa!=Float32Array&&(Ia[0]=0,Ia[1]=0,Ia[2]=0,Ia[3]=0),ya(),va(1,0,0),va(0,1,0),ka(),ka(),fa();const Ra=va(0,0,0),Ba=va(0,0,1);function Fa(t,e){const i=ya();return Ra[2]=e,t.intersectsPlane(Ra,Ba,i),new n(i[0],i[1])}class Oa extends Ws{}function Ua(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Va(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const n=Ua({},{width:e,height:i},r);Na(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=n.data}function Na(t,e,i,r,n,o){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*o,h=((r.y+l)*e.width+r.x)*o;for(let t=0;t<n.width*o;t++)a[h+t]=s[c+t]}return e}an("HeatmapBucket",Oa,{omit:["layers"]});class Ga{constructor(t,e){Ua(this,t,1,e)}resize(t){Va(this,t,1)}clone(){return new Ga({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Na(t,e,i,r,n,1)}}class Za{constructor(t,e){Ua(this,t,4,e)}resize(t){Va(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Za({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Na(t,e,i,r,n,4)}}an("AlphaImage",Ga),an("RGBAImage",Za);var qa={paint:new bo({"heatmap-radius":new go(Ot.paint_heatmap["heatmap-radius"]),"heatmap-weight":new go(Ot.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _o(Ot.paint_heatmap["heatmap-intensity"]),"heatmap-color":new vo(Ot.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _o(Ot.paint_heatmap["heatmap-opacity"])})};function ja(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new Za({width:i,height:r}),o=(i,r,o)=>{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];o(n,s,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)o(0,e,t/(i-1));return n}var $a={paint:new bo({"hillshade-illumination-direction":new _o(Ot.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new _o(Ot.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new _o(Ot.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new _o(Ot.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new _o(Ot.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new _o(Ot.paint_hillshade["hillshade-accent-color"])})};const Xa=Io([{name:"a_pos",components:2,type:"Int16"}],4),{members:Wa}=Xa;var Ha=Ya,Ka=Ya;function Ya(t,e,i){i=i||2;var r,n,o,s,a,l,c,h=e&&e.length,u=h?e[0]*i:t.length,d=Ja(t,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(h&&(d=function(t,e,i,r){var n,o,s,a=[];for(n=0,o=e.length;n<o;n++)(s=Ja(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1))===s.next&&(s.steiner=!0),a.push(cl(s));for(a.sort(ol),n=0;n<a.length;n++)sl(a[n],i),i=Qa(i,i.next);return i}(t,e,d,i)),t.length>80*i){r=o=t[0],n=s=t[1];for(var f=i;f<u;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?1/c:0}return tl(d,p,i,r,n,c),p}function Ja(t,e,i,r,n){var o,s;if(n===wl(t,e,i,r)>0)for(o=e;o<i;o+=r)s=xl(o,t[o],t[o+1],s);else for(o=i-r;o>=e;o-=r)s=xl(o,t[o],t[o+1],s);return s&&pl(s,s.next)&&(vl(s),s=s.next),s}function Qa(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!pl(r,r.next)&&0!==dl(r.prev,r,r.next))r=r.next;else{if(vl(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function tl(t,e,i,r,n,o,s){if(t){!s&&o&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=ll(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,o,s,a,l,c=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,r=i,a=0,e=0;e<c&&(a++,r=r.nextZ);e++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1)}(n)}(t,r,n,o);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,o?il(t,r,n,o):el(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),vl(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?tl(t=rl(Qa(t),e,i),e,i,r,n,o,2):2===s&&nl(t,e,i,r,n,o):tl(Qa(t),e,i,r,n,o,1);break}}}function el(t){var e=t.prev,i=t,r=t.next;if(dl(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(hl(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&dl(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function il(t,e,i,r){var n=t.prev,o=t,s=t.next;if(dl(n,o,s)>=0)return!1;for(var a=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,l=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,c=ll(n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,e,i,r),h=ll(a,l,e,i,r),u=t.prevZ,d=t.nextZ;u&&u.z>=c&&d&&d.z<=h;){if(u!==t.prev&&u!==t.next&&hl(n.x,n.y,o.x,o.y,s.x,s.y,u.x,u.y)&&dl(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,d!==t.prev&&d!==t.next&&hl(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&dl(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;u&&u.z>=c;){if(u!==t.prev&&u!==t.next&&hl(n.x,n.y,o.x,o.y,s.x,s.y,u.x,u.y)&&dl(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;d&&d.z<=h;){if(d!==t.prev&&d!==t.next&&hl(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&dl(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function rl(t,e,i){var r=t;do{var n=r.prev,o=r.next.next;!pl(n,o)&&fl(n,r,r.next,o)&&gl(n,o)&&gl(o,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(o.i/i),vl(r),vl(r.next),r=t=o),r=r.next}while(r!==t);return Qa(r)}function nl(t,e,i,r,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&ul(s,a)){var l=yl(s,a);return s=Qa(s,s.next),l=Qa(l,l.next),tl(s,e,i,r,n,o),void tl(l,e,i,r,n,o)}a=a.next}s=s.next}while(s!==t)}function ol(t,e){return t.x-e.x}function sl(t,e){if(e=function(t,e){var i,r=e,n=t.x,o=t.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===s)return i;var l,c=i,h=i.x,u=i.y,d=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&hl(o<u?n:s,o,h,u,o<u?s:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),gl(r,t)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&al(i,r)))&&(i=r,d=l)),r=r.next}while(r!==c);return i}(t,e)){var i=yl(e,t);Qa(e,e.next),Qa(i,i.next)}}function al(t,e){return dl(t.prev,t,e.prev)<0&&dl(e.next,t,t.next)<0}function ll(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function cl(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function hl(t,e,i,r,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(r-a)-(i-s)*(e-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function ul(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&fl(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(gl(t,e)&&gl(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(dl(t.prev,t,e.prev)||dl(t,e.prev,e))||pl(t,e)&&dl(t.prev,t,t.next)>0&&dl(e.prev,e,e.next)>0)}function dl(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function pl(t,e){return t.x===e.x&&t.y===e.y}function fl(t,e,i,r){var n=_l(dl(t,e,i)),o=_l(dl(t,e,r)),s=_l(dl(i,r,t)),a=_l(dl(i,r,e));return n!==o&&s!==a||!(0!==n||!ml(t,i,e))||!(0!==o||!ml(t,r,e))||!(0!==s||!ml(i,t,r))||!(0!==a||!ml(i,e,r))}function ml(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 _l(t){return t>0?1:t<0?-1:0}function gl(t,e){return dl(t.prev,t,t.next)<0?dl(t,e,t.next)>=0&&dl(t,t.prev,e)>=0:dl(t,e,t.prev)<0||dl(t,t.next,e)<0}function yl(t,e){var i=new bl(t.i,t.x,t.y),r=new bl(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function xl(t,e,i,r){var n=new bl(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function vl(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 bl(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function wl(t,e,i,r){for(var n=0,o=e,s=i-r;o<i;o+=r)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}function Tl(t,e,i,r,n){El(t,e,i||0,r||t.length-1,n||Il)}function El(t,e,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);El(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(r,Math.floor(e+(o-s)*l/o+c)),n)}var h=t[e],u=i,d=r;for(Sl(t,i,e),n(t[r],h)>0&&Sl(t,i,r);u<d;){for(Sl(t,u,d),u++,d--;n(t[u],h)<0;)u++;for(;n(t[d],h)>0;)d--}0===n(t[i],h)?Sl(t,i,d):Sl(t,++d,r),d<=e&&(i=d+1),e<=d&&(r=d-1)}}function Sl(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Il(t,e){return t<e?-1:t>e?1:0}function Al(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,o;for(let e=0;e<i;e++){const i=D(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[e]]):n.push(t[e]))}if(n&&r.push(n),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Tl(r[t],e,1,r[t].length-1,Cl),r[t]=r[t].slice(0,e));return r}function Cl(t,e){return e.area-t.area}function Ml(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(t+"-pattern");e.isConstant()||(n=!0);const o=e.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function zl(t,e,i,r,n){const o=n.patternDependencies;for(const s of e){const e=s.paint.get(t+"-pattern").value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),a=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[s.id]={min:t,mid:a,max:l}}}return i}Ya.deviation=function(t,e,i,r){var n=e&&e.length,o=Math.abs(wl(t,0,n?e[0]*i:t.length,i));if(n)for(var s=0,a=e.length;s<a;s++)o-=Math.abs(wl(t,e[s]*i,s<a-1?e[s+1]*i:t.length,i));var l=0;for(s=0;s<r.length;s+=3){var c=r[s]*i,h=r[s+1]*i,u=r[s+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Ya.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,n=0;n<t.length;n++){for(var o=0;o<t[n].length;o++)for(var s=0;s<e;s++)i.vertices.push(t[n][o][s]);n>0&&i.holes.push(r+=t[n-1].length)}return i},Ha.default=Ka;class kl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Co,this.indexArray=new No,this.indexArray2=new Xo,this.programConfigurations=new ks(t.layers,t.zoom),this.segments=new Ns,this.segments2=new Ns,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Ml("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=$s(o,t);if(!this.layers[0]._featureFilter.filter(new so(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i,e.availableImages):void 0,u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:js(o),patterns:{},sortKey:h};n.push(u)}r&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=zl("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{});e.featureIndex.insert(t[o].feature,n,o,s,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Wa),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,n){for(const t of Al(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),n.push(e[0].x),n.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),n.push(e[t].x),n.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const s=Ha(n,o);for(let t=0;t<s.length;t+=3)this.indexArray.emplaceBack(r+s[t],r+s[t+1],r+s[t+2]);i.vertexLength+=e,i.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}}an("FillBucket",kl,{omit:["layers","patternFeatures"]});const Pl=new bo({"fill-sort-key":new go(Ot.layout_fill["fill-sort-key"])});var Dl={paint:new bo({"fill-antialias":new _o(Ot.paint_fill["fill-antialias"]),"fill-opacity":new go(Ot.paint_fill["fill-opacity"]),"fill-color":new go(Ot.paint_fill["fill-color"]),"fill-outline-color":new go(Ot.paint_fill["fill-outline-color"]),"fill-translate":new _o(Ot.paint_fill["fill-translate"]),"fill-translate-anchor":new _o(Ot.paint_fill["fill-translate-anchor"]),"fill-pattern":new yo(Ot.paint_fill["fill-pattern"])}),layout:Pl};const Ll=Io([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Rl=Io([{name:"a_centroid_pos",components:2,type:"Uint16"}]),{members:Bl}=Ll;var Fl=Ol;function Ol(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(Ul,this,e)}function Ul(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Vl(t){for(var e,i,r=0,n=0,o=t.length,s=o-1;n<o;s=n++)r+=((i=t[s]).x-(e=t[n]).x)*(e.y+i.y);return r}Ol.types=["Unknown","Point","LineString","Polygon"],Ol.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,o=0,s=0,a=0,l=[];t.pos<i;){if(o<=0){var c=t.readVarint();r=7&c,o=c>>3}if(o--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new n(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},Ol.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=t.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},Ol.prototype.toGeoJSON=function(t,e,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=Ol.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,n=[],o=0;o<e;o++){var s=Vl(t[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(i&&n.push(i),i=[t[o]]):i.push(t[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d};var Nl=Gl;function Gl(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Zl,this,e),this.length=this._features.length}function Zl(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function ql(t,e,i){if(3===t){var r=new Nl(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}Gl.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 Fl(this._pbf,e,this.extent,this._keys,this._values)};var jl={VectorTile:function(t,e){this.layers=t.readFields(ql,{},e)},VectorTileFeature:Fl,VectorTileLayer:Nl};const $l=jl.VectorTileFeature.types,Xl=Math.pow(2,13);function Wl(t,e,i,r,n,o,s,a){t.emplaceBack((e<<1)+s,(i<<1)+o,(Math.floor(r*Xl)<<1)+n,Math.round(a))}class Hl{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(t.x,t.y),this.max=new n(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);let i=!!this.borders;const r=this.min,n=this.max;t.x<r.x?(r.x=t.x,i=!0):t.x>n.x&&(n.x=t.x,i=!0),t.y<r.y?(r.y=t.y,i=!0):t.y>n.y&&(n.y=t.y,i=!0),((0===t.x||t.x===Gs)&&t.x===e.x)!=((0===t.y||t.y===Gs)&&t.y===e.y)&&this.processBorderOverlap(t,e),i&&this.checkBorderIntersection(t,e)}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,ii(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>Gs!=t.x>Gs&&this.addBorderIntersection(1,ii(e.y,t.y,(Gs-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,ii(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>Gs!=t.y>Gs&&this.addBorderIntersection(3,ii(e.x,t.x,(Gs-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];e<i[0]&&(i[0]=e),e>i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class Kl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Mo,this.centroidVertexArray=new as,this.indexArray=new No,this.programConfigurations=new ks(t.layers,t.zoom),this.segments=new Ns,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i){this.features=[],this.hasPattern=Ml("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<<t.z)*2));return 80150034*e/(e*e+1)/Gs/(1<<t.z)}(i);for(const{feature:r,id:n,index:o,sourceLayerIndex:s}of t){const t=this.layers[0]._featureFilter.needGeometry,a=$s(r,t);if(!this.layers[0]._featureFilter.filter(new so(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:s,index:o,geometry:t?a.geometry:js(r),properties:r.properties,type:r.type,patterns:{}},c=this.layoutVertexArray.length;this.hasPattern?this.features.push(zl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,o,i,{}),e.featureIndex.insert(r,l.geometry,o,s,this.index,c)}this.sortBorders()}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}this.sortBorders()}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Bl),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Rl.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r,n){const o=this.enableTerrain&&t.properties&&"Polygon"===$l[t.type]?new Hl:null;for(const i of Al(e,500)){let e=0,r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);if(0===i.length||(s=i[0]).every((t=>t.x<=0))||s.every((t=>t.x>=Gs))||s.every((t=>t.y<=0))||s.every((t=>t.y>=Gs)))continue;for(let t=0;t<i.length;t++){const n=i[t];if(0===n.length)continue;e+=n.length;let s=0;o&&o.startRing(n[0]);for(let t=0;t<n.length;t++){const e=n[t];if(t>=1){const i=n[t-1];if(!Yl(e,i)){o&&o.append(e,i),r.vertexLength+4>Ns.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=e.sub(i)._perp(),n=t.x/(Math.abs(t.x)+Math.abs(t.y)),a=t.y>0?1:0,l=i.dist(e);s+l>32768&&(s=0),Wl(this.layoutVertexArray,e.x,e.y,n,a,0,0,s),Wl(this.layoutVertexArray,e.x,e.y,n,a,0,1,s),s+=l,Wl(this.layoutVertexArray,i.x,i.y,n,a,0,0,s),Wl(this.layoutVertexArray,i.x,i.y,n,a,0,1,s);const c=r.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>Ns.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==$l[t.type])continue;const n=[],a=[],l=r.vertexLength;for(let t=0;t<i.length;t++){const e=i[t];if(0!==e.length){e!==i[0]&&a.push(n.length/2);for(let t=0;t<e.length;t++){const i=e[t];Wl(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),n.push(i.x),n.push(i.y),o&&o.currentPolyCount.top++}}}const c=Ha(n,a);for(let t=0;t<c.length;t+=3)this.indexArray.emplaceBack(l+c[t],l+c[t+2],l+c[t+1]);r.primitiveLength+=c.length/3,r.vertexLength+=e}var s;if(o&&o.polyCount.length>0){if(o.borders){o.vertexArrayOffset=this.centroidVertexArray.length;const t=o.borders,e=this.featuresOnBorder.push(o)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(o.borders?void 0:o.centroid(),o)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,n;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(o++,r,n)}}}function Yl(t,e){return t.x===e.x&&(t.x<0||t.x>Gs)||t.y===e.y&&(t.y<0||t.y>Gs)}an("FillExtrusionBucket",Kl,{omit:["layers","features"]}),an("PartMetadata",Hl);var Jl={paint:new bo({"fill-extrusion-opacity":new _o(Ot["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new go(Ot["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _o(Ot["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _o(Ot["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new yo(Ot["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new go(Ot["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new go(Ot["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _o(Ot["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Ql(t,e){return t.x*e.x+t.y*e.y}function tc(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const o=e[i],s=t[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=Ql(a,a),u=Ql(a,l),d=Ql(l,l),p=Ql(c,a),f=Ql(c,l),m=h*d-u*u,_=(d*p-u*f)/m,g=(h*f-u*p)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}function ec(t){const e=new n(t[0],t[1]);return e.z=t[2],e}function ic(t,e,i,r,n,o,s,a){const l=s*n.getElevationAt(t,e,!0,!0),c=0!==o[0],h=c?0===o[1]?s*(o[0]/7-450):s*function(t,e,i){const r=Math.floor(e[0]/8),n=Math.floor(e[1]/8),o=10*(e[0]-8*r),s=10*(e[1]-8*n),a=t.getElevationAt(r,n,!0,!0),l=t.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),h=Math.floor(.5*(s*l-1)),u=t.tileCoordToPixel(r,n),d=2*c+1,p=2*h+1,f=function(t,e,i,r,n){return[t.getElevationAtPixel(e,i,!0),t.getElevationAtPixel(e+n,i,!0),t.getElevationAtPixel(e,i+n,!0),t.getElevationAtPixel(e+r,i+n,!0)]}(t,u.x-c,u.y-h,d,p),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/d),x=Math.min(.25,.5*l*g/p);return a+Math.max(y*o,x*s)}(n,o,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}const rc=Io([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:nc}=rc,oc=Io([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:sc}=oc,ac=jl.VectorTileFeature.types,lc=Math.cos(Math.PI/180*37.5);class cc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new zo,this.layoutVertexArray2=new ko,this.indexArray=new No,this.programConfigurations=new ks(t.layers,t.zoom),this.segments=new Ns,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Ml("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),n=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=$s(e,t);if(!this.layers[0]._featureFilter.filter(new so(this.zoom),l,i))continue;const c=r?r.evaluate(l,{},i):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:js(e),patterns:{},sortKey:c};n.push(h)}r&&n.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:o,featureIndex:s}=e,a=this.addConstantDashes(o);for(const r of n){const{geometry:n,index:l,sourceLayerIndex:c}=r;if(a&&this.addFeatureDashes(r,o),this.hasPattern){const t=zl("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,l,i,o.positions);s.insert(t[l].feature,n,l,c,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)e=!0;else{const e=n.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a,l,c,h,u;if("constant"===n.kind){const t=n.value;if(!t)continue;s=t.other||t.to,a=t.to,l=t.from}else s=n.evaluate({zoom:i-1},t),a=n.evaluate({zoom:i},t),l=n.evaluate({zoom:i+1},t);"constant"===o.kind?c=h=u=o.value:(c=o.evaluate({zoom:i-1},t),h=o.evaluate({zoom:i},t),u=o.evaluate({zoom:i+1},t)),e.addDash(s,c),e.addDash(a,h),e.addDash(l,u);const d=e.getKey(s,c),p=e.getKey(a,h),f=e.getKey(l,u);t.patterns[r.id]={min:d,mid:p,max:f}}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,sc)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,nc),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n){const o=this.layers[0].layout,s=o.get("line-join").evaluate(t,{}),a=o.get("line-cap").evaluate(t,{}),l=o.get("line-miter-limit"),c=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,s,a,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}addLine(t,e,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===ac[e.type];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l<a-1&&t[l].equals(t[l+1]);)l++;if(a<(s?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let u,d,p,f,m;this.e1=this.e2=-1,s&&(u=t[a-2],m=t[l].sub(u)._unit()._perp());for(let e=l;e<a;e++){if(p=e===a-1?s?t[l+1]:void 0:t[e+1],p&&t[e].equals(p))continue;m&&(f=m),u&&(d=u),u=t[e],m=p?p.sub(u)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<lc&&d&&p,w=f.x*m.y-f.y*m.x>0;if(b&&e>l){const t=u.dist(d);if(t>2*c){const e=u.sub(u.sub(d)._mult(c/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,f,0,0,h),d=e}}const T=d&&p;let E=T?i:s?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),d&&this.updateDistance(d,u),"miter"===E)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(d&&this.addCurrentVertex(u,f,e,i,h),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}p&&this.addCurrentVertex(u,m,-e,-i,h)}else if("butt"===E)this.addCurrentVertex(u,_,0,0,h);else if("square"===E){const t=d?1:-1;d||this.addCurrentVertex(u,_,t,t,h),this.addCurrentVertex(u,_,0,0,h),d&&this.addCurrentVertex(u,_,t,t,h)}else"round"===E&&(d&&(this.addCurrentVertex(u,f,0,0,h),this.addCurrentVertex(u,f,1,1,h,!0)),p&&(this.addCurrentVertex(u,m,-1,-1,h,!0),this.addCurrentVertex(u,m,0,0,h)));if(b&&e<a-1){const t=u.dist(p);if(t>2*c){const e=u.add(p.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,m,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,n,o=!1){const s=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,o,!1,i,n),this.addHalfVertex(t,s,a,o,!0,-r,n)}addHalfVertex({x:t,y:e},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}an("LineBucket",cc,{omit:["layers","patternFeatures"]});const hc=new bo({"line-cap":new go(Ot.layout_line["line-cap"]),"line-join":new go(Ot.layout_line["line-join"]),"line-miter-limit":new _o(Ot.layout_line["line-miter-limit"]),"line-round-limit":new _o(Ot.layout_line["line-round-limit"]),"line-sort-key":new go(Ot.layout_line["line-sort-key"])});var uc={paint:new bo({"line-opacity":new go(Ot.paint_line["line-opacity"]),"line-color":new go(Ot.paint_line["line-color"]),"line-translate":new _o(Ot.paint_line["line-translate"]),"line-translate-anchor":new _o(Ot.paint_line["line-translate-anchor"]),"line-width":new go(Ot.paint_line["line-width"]),"line-gap-width":new go(Ot.paint_line["line-gap-width"]),"line-offset":new go(Ot.paint_line["line-offset"]),"line-blur":new go(Ot.paint_line["line-blur"]),"line-dasharray":new yo(Ot.paint_line["line-dasharray"]),"line-pattern":new yo(Ot.paint_line["line-pattern"]),"line-gradient":new vo(Ot.paint_line["line-gradient"])}),layout:hc};const dc=new class extends go{possiblyEvaluate(t,e){return e=new so(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=x({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(uc.paint.properties["line-width"].specification);function pc(t,e){return e>0?e+2*t:t}dc.useIntegerZoom=!0;const fc=Io([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),mc=Io([{name:"a_projected_pos",components:3,type:"Float32"}],4);Io([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const _c=Io([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),gc=Io([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Io([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{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 yc=Io([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),xc=Io([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Io([{name:"triangle",components:3,type:"Uint16"}]),Io([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Io([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Io([{type:"Float32",name:"offsetX"}]),Io([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var vc=24;const bc=128;function wc(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new so(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let o=n;for(;o<e.length&&e[o]<t+1;)o++;o=Math.min(e.length-1,o);const s=e[n],a=e[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new so(s)),maxSize:i.evaluate(new so(a)),interpolationType:r}}}function Tc(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/bc:"composite"===t.kind?ii(r/bc,n/bc,i):e}function Ec(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=t,a=n?m(bi.interpolationFactor(n,e,o,s),0,1):0;"camera"===t.kind?r=ii(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var Sc=Object.freeze({__proto__:null,getSizeData:wc,evaluateSizeForFeature:Tc,evaluateSizeForZoom:Ec,SIZE_PACK_FACTOR:bc});function Ic(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),oo.applyArabicShaping&&(t=oo.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Ac={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Cc=function(t,e,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},Mc=function(t,e,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,n),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;t[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m},zc=kc;function kc(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}kc.Varint=0,kc.Fixed64=1,kc.Bytes=2,kc.Fixed32=5;var Pc=4294967296,Dc=1/Pc,Lc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Rc(t){return t.type===kc.Bytes?t.readVarint()+t.pos:t.pos+1}function Bc(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Fc(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function Oc(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function Uc(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function Vc(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function Nc(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function Gc(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function Zc(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function qc(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function jc(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function $c(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Xc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Wc(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Hc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Kc(t,e,i){1===t&&i.readMessage(Yc,e)}function Yc(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Jc,{});e.push({id:t,bitmap:new Ga({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}}function Jc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Qc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,o=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:o,fill:e/(n*o)||0}}kc.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,t(n,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Xc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Hc(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Xc(this.buf,this.pos)+Xc(this.buf,this.pos+4)*Pc;return this.pos+=8,t},readSFixed64:function(){var t=Xc(this.buf,this.pos)+Hc(this.buf,this.pos+4)*Pc;return this.pos+=8,t},readFloat:function(){var t=Cc(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Cc(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return Bc(t,r,e);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return Bc(t,r,e);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return Bc(t,r,e);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return Bc(t,r,e);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return Bc(t,r,e);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return Bc(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Lc?function(t,e,i){return Lc.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var o,s,a,l=t[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=t[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=t[n+2],128==(192&(o=t[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=t[n+2],a=t[n+3],128==(192&(o=t[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==kc.Bytes)return t.push(this.readVarint(e));var i=Rc(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==kc.Bytes)return t.push(this.readSVarint());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==kc.Bytes)return t.push(this.readBoolean());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==kc.Bytes)return t.push(this.readFloat());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==kc.Bytes)return t.push(this.readDouble());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==kc.Bytes)return t.push(this.readFixed32());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==kc.Bytes)return t.push(this.readSFixed32());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==kc.Bytes)return t.push(this.readFixed64());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==kc.Bytes)return t.push(this.readSFixed64());var e=Rc(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===kc.Varint)for(;this.buf[this.pos++]>127;);else if(e===kc.Bytes)this.pos=this.readVarint()+this.pos;else if(e===kc.Fixed32)this.pos+=4;else{if(e!==kc.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Wc(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Wc(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Wc(this.buf,-1&t,this.pos),Wc(this.buf,Math.floor(t*Dc),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Wc(this.buf,-1&t,this.pos),Wc(this.buf,Math.floor(t*Dc),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&Fc(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Mc(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Mc(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&Fc(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,kc.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Oc,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Uc,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Gc,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Vc,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Nc,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Zc,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,qc,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,jc,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,$c,e)},writeBytesField:function(t,e){this.writeTag(t,kc.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,kc.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,kc.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,kc.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,kc.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,kc.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,kc.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,kc.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,kc.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,kc.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class th{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class eh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:o,h:s}=Qc(n),a=new Za({width:o||1,height:s||1});for(const e in t){const r=t[e],n=i[e].paddedRect;Za.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,o=n.x+1,s=n.y+1,l=i.data.width,c=i.data.height;Za.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),Za.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),Za.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),Za.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),Za.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),e[r]=new th(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}an("ImagePosition",th),an("ImageAtlas",eh);const ih={horizontal:1,vertical:2,horizontalOnly:3},rh=-17;class nh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new nh;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new nh;return e.imageName=t,e}}class oh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new oh;for(let r=0;r<t.sections.length;r++){const n=t.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,e)}return i}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=function(t){let e="";for(let i=0;i<t.length;i++){const r=t.charCodeAt(i+1)||null,n=t.charCodeAt(i-1)||null;e+=r&&qn(r)&&!Ac[t[i+1]]||n&&qn(n)&&!Ac[t[i-1]]||!Ac[t[i]]?t[i]:Ac[t[i]]}return e}(this.text)}trim(){let t=0;for(let e=0;e<this.text.length&&ah[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let i=this.text.length-1;i>=0&&i>=t&&ah[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new oh;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(nh.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(i)}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void k("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(nh.forImage(e)),this.sectionIndex.push(this.sections.length-1)):k("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function sh(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=oh.fromFeature(t,n);let g;u===ih.vertical&&_.verticalizePunctuation();const{processBidirectionalText:y,processStyledBidirectionalText:x}=oo;if(y&&1===_.sections.length){g=[];const t=y(_.toString(),fh(_,c,o,e,r,p,f));for(const e of t){const t=new oh;t.text=e,t.sections=_.sections;for(let i=0;i<e.length;i++)t.sectionIndex.push(0);g.push(t)}}else if(x){g=[];const t=x(_.text,_.sectionIndex,fh(_,c,o,e,r,p,f));for(const e of t){const t=new oh;t.text=e[0],t.sectionIndex=e[1],t.sections=_.sections,g.push(t)}}else g=function(t,e){const i=[],r=t.text;let n=0;for(const r of e)i.push(t.substring(n,r)),n=r;return n<r.length&&i.push(t.substring(n,r.length)),i}(_,fh(_,c,o,e,r,p,f));const v=[],b={positionedLines:v,text:_.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:u,iconsInText:!1,verticalizable:!1};return function(t,e,i,r,n,o,s,a,l,c,h,u){let d=0,p=rh,f=0,m=0;const _="right"===a?1:"left"===a?0:.5;let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*vc,x={positionedGlyphs:[],lineOffset:0};t.positionedLines[g]=x;const v=x.positionedGlyphs;let b=0;if(!s.length()){p+=o,++g;continue}for(let o=0;o<s.length();o++){const f=s.getSection(o),m=s.getSectionIndex(o),_=s.getCharCode(o);let g=0,x=null,w=null,T=null,E=vc;const S=!(l===ih.horizontal||!h&&!Zn(_)||h&&(ah[_]||(y=_,pn(y)||fn(y)||mn(y)||Ln(y)||On(y))));if(f.imageName){const e=r[f.imageName];if(!e)continue;T=f.imageName,t.iconsInText=t.iconsInText||!0,w=e.paddedRect;const i=e.displaySize;f.scale=f.scale*vc/u,x={width:i[0],height:i[1],left:1,top:-3,advance:S?i[1]:i[0],localGlyph:!1},g=a+(vc-i[1]*f.scale),E=x.advance;const o=S?i[0]*f.scale-vc*n:i[1]*f.scale-vc*n;o>0&&o>b&&(b=o)}else{const t=i[f.fontStack],r=t&&t[_];if(r&&r.rect)w=r.rect,x=r.metrics;else{const t=e[f.fontStack],i=t&&t[_];if(!i)continue;x=i.metrics}g=(n-f.scale)*vc}S?(t.verticalizable=!0,v.push({glyph:_,imageName:T,x:d,y:p+g,vertical:S,scale:f.scale,localGlyph:x.localGlyph,fontStack:f.fontStack,sectionIndex:m,metrics:x,rect:w}),d+=E*f.scale+c):(v.push({glyph:_,imageName:T,x:d,y:p+g,vertical:S,scale:f.scale,localGlyph:x.localGlyph,fontStack:f.fontStack,sectionIndex:m,metrics:x,rect:w}),d+=x.advance*f.scale+c)}0!==v.length&&(f=Math.max(d-c,f),_h(v,0,v.length-1,_,b)),d=0;const w=o*n+b;x.lineOffset=Math.max(b,a),p+=w,m=Math.max(w,m),++g}var y;const x=p-rh,{horizontalAlign:v,verticalAlign:b}=mh(s);(function(t,e,i,r,n,o,s,a,l){const c=(e-i)*n;let h=0;h=o!==s?-a*r-rh:(-r*l+.5)*s;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(t.positionedLines,_,v,b,f,m,o,x,n.length),t.top+=-b*x,t.bottom=t.top+x,t.left+=-v*f,t.right=t.left+f}(b,e,i,r,g,s,a,l,u,c,d,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(v)&&b}const ah={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},lh={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function ch(t,e,i,r,n,o){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*vc/o+n:0}{const r=i[e.fontStack],o=r&&r[t];return o?o.metrics.advance*e.scale+n:0}}function hh(t,e,i,r){const n=Math.pow(t-e,2);return r?t<e?n/2:2*n:n+Math.abs(i)*i}function uh(t,e,i){let r=0;return 10===t&&(r-=1e4),i&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function dh(t,e,i,r,n,o){let s=null,a=hh(e,i,n,o);for(const t of r){const r=hh(e-t.x,i,n,o)+t.badness;r<=a&&(s=t,a=r)}return{index:t,x:e,priorBreak:s,badness:a}}function ph(t){return t?ph(t.priorBreak).concat(t.index):[]}function fh(t,e,i,r,n,o,s){if("point"!==o)return[];if(!t)return[];const a=[],l=function(t,e,i,r,n,o){let s=0;for(let i=0;i<t.length();i++){const a=t.getSection(i);s+=ch(t.getCharCode(i),a,r,n,e,o)}return s/Math.max(1,Math.ceil(s/i))}(t,e,i,r,n,s),c=t.text.indexOf("")>=0;let h=0;for(let i=0;i<t.length();i++){const o=t.getSection(i),d=t.getCharCode(i);if(ah[d]||(h+=ch(d,o,r,n,e,s)),i<t.length()-1){const e=!((u=d)<11904||!(Tn(u)||wn(u)||Bn(u)||Dn(u)||An(u)||_n(u)||En(u)||xn(u)||Cn(u)||Mn(u)||In(u)||Un(u)||vn(u)||yn(u)||gn(u)||Sn(u)||bn(u)||Rn(u)||kn(u)||zn(u)));(lh[d]||e||o.imageName)&&a.push(dh(i+1,h,l,a,uh(d,t.getCharCode(i+1),e&&c),!1))}}var u;return ph(dh(t.length(),h,l,a,0,!0))}function mh(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function _h(t,e,i,r,n){if(!r&&!n)return;const o=t[i],s=(t[i].x+o.metrics.advance*o.scale)*r;for(let r=e;r<=i;r++)t[r].x-=s,t[r].y+=n}function gh(t,e,i){const{horizontalAlign:r,verticalAlign:n}=mh(i),o=e[0]-t.displaySize[0]*r,s=e[1]-t.displaySize[1]*n;return{image:t,top:s,bottom:s+t.displaySize[1],left:o,right:o+t.displaySize[0]}}function yh(t,e,i,r,n,o){const s=t.image;let a;if(s.content){const t=s.content,e=s.pixelRatio||1;a=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e]}const l=e.left*o,c=e.right*o;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,u=p+s.displaySize[0]);const f=e.top*o,m=e.bottom*o;return"height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):(h=n[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{image:s,top:h,right:u,bottom:d,left:p,collisionPadding:a}}class xh extends n{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new xh(this.x,this.y,this.angle,this.segment)}}function vh(t,e,i,r,n){if(void 0===e.segment)return!0;let o=e,s=e.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=t[s].dist(o),o=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const e=t[s],i=t[s+1];if(!i)return!1;let o=t[s-1].angleTo(e)-e.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=e.dist(i)}return!0}function bh(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function wh(t,e,i){return t?.6*e*i:0}function Th(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Eh(t,e,i,r,n,o){const s=wh(i,n,o),a=Th(i,r)*o;let l=0;const c=bh(t)/2;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=ii(r.x,n.x,h),d=ii(r.y,n.y,h),p=new xh(u,d,n.angleTo(r),i);return p._round(),!s||vh(t,p,a,s,e)?p:void 0}l+=o}}function Sh(t,e,i,r,n,o,s,a,l){const c=wh(r,o,s),h=Th(r,n),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u<e/4&&(e=u+e/4),Ih(t,d?e/2*a%e:(h/2+2*o)*s*a%e,e,c,i,u,d,!1,l)}function Ih(t,e,i,r,n,o,s,a,l){const c=o/2,h=bh(t);let u=0,d=e-i,p=[];for(let e=0;e<t.length-1;e++){const s=t[e],a=t[e+1],f=s.dist(a),m=a.angleTo(s);for(;d+i<u+f;){d+=i;const _=(d-u)/f,g=ii(s.x,a.x,_),y=ii(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&d-c>=0&&d+c<=h){const i=new xh(g,y,m,e);i._round(),r&&!vh(t,i,o,r,n)||p.push(i)}}u+=f}return a||p.length||s||(p=Ih(t,u/2,i,r,n,o,s,!0,l)),p}function Ah(t,e,i,r,o){const s=[];for(let a=0;a<t.length;a++){const l=t[a];let c;for(let t=0;t<l.length-1;t++){let a=l[t],h=l[t+1];a.x<e&&h.x<e||(a.x<e?a=new n(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x<e&&(h=new n(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y<i&&h.y<i||(a.y<i?a=new n(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round():h.y<i&&(h=new n(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round()),a.x>=r&&h.x>=r||(a.x>=r?a=new n(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x>=r&&(h=new n(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y>=o&&h.y>=o||(a.y>=o?a=new n(a.x+(o-a.y)/(h.y-a.y)*(h.x-a.x),o)._round():h.y>=o&&(h=new n(a.x+(o-a.y)/(h.y-a.y)*(h.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(h)))))}}return s}an("Anchor",xh);var Ch=kh,Mh=kh,zh=1e20;function kh(t,e,i,r,n,o){this.fontSize=t||24,this.buffer=void 0===e?3:e,this.cutoff=r||.25,this.fontFamily=n||"sans-serif",this.fontWeight=o||"normal",this.radius=i||8;var s=this.size=this.fontSize+2*this.buffer,a=s+2*this.buffer;this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=s,this.ctx=this.canvas.getContext("2d"),this.ctx.font=this.fontWeight+" "+this.fontSize+"px "+this.fontFamily,this.ctx.textAlign="left",this.ctx.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a),this.useMetrics=void 0!==this.ctx.measureText("A").actualBoundingBoxLeft,this.middle=Math.round(s/2*(navigator.userAgent.indexOf("Gecko/")>=0?1.2:1))}function Ph(t,e,i,r,n,o){for(var s=0;s<e;s++)Dh(t,s,e,i,r,n,o);for(var a=0;a<i;a++)Dh(t,a*e,1,e,r,n,o)}function Dh(t,e,i,r,n,o,s){var a,l,c,h;for(o[0]=0,s[0]=-zh,s[1]=zh,a=0;a<r;a++)n[a]=t[e+a*i];for(a=1,l=0,c=0;a<r;a++){do{c=(n[a]-n[h=o[l]]+a*a-h*h)/(a-h)/2}while(c<=s[l]&&--l>-1);o[++l]=a,s[l]=c,s[l+1]=zh}for(a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;t[e+a*i]=n[h=o[l]]+(a-h)*(a-h)}}kh.prototype._draw=function(t,e){var i,r,n,o,s,a,l,c,h,u=this.ctx.measureText(t),d=u.width,p=2*this.buffer;e&&this.useMetrics?(s=Math.floor(u.actualBoundingBoxAscent),c=this.buffer+Math.ceil(u.actualBoundingBoxAscent),a=this.buffer,l=this.buffer,i=(r=Math.min(this.size,Math.ceil(u.actualBoundingBoxRight-u.actualBoundingBoxLeft)))+p,n=(o=Math.min(this.size-a,Math.ceil(u.actualBoundingBoxAscent+u.actualBoundingBoxDescent)))+p,this.ctx.textBaseline="alphabetic"):(i=r=this.size,n=o=this.size,s=19*this.fontSize/24,a=l=0,c=this.middle,this.ctx.textBaseline="middle"),r&&o&&(this.ctx.clearRect(l,a,r,o),this.ctx.fillText(t,this.buffer,c),h=this.ctx.getImageData(l,a,r,o));var f=new Uint8ClampedArray(i*n);return function(t,e,i,r,n,o,s){o.fill(zh,0,e*i),s.fill(0,0,e*i);for(var a=(e-r)/2,l=0;l<n;l++)for(var c=0;c<r;c++){var h=(l+a)*e+c+a,u=t.data[4*(l*r+c)+3]/255;if(1===u)o[h]=0,s[h]=zh;else if(0===u)o[h]=zh,s[h]=0;else{var d=Math.max(0,.5-u),p=Math.max(0,u-.5);o[h]=d*d,s[h]=p*p}}}(h,i,n,r,o,this.gridOuter,this.gridInner),Ph(this.gridOuter,i,n,this.f,this.v,this.z),Ph(this.gridInner,i,n,this.f,this.v,this.z),function(t,e,i,r,n,o,s){for(var a=0;a<e*i;a++){var l=Math.sqrt(r[a])-Math.sqrt(n[a]);t[a]=Math.round(255-255*(l/o+s))}}(f,i,n,this.gridOuter,this.gridInner,this.radius,this.cutoff),{data:f,metrics:{width:r,height:o,sdfWidth:i,sdfHeight:n,top:s,left:0,advance:d}}},kh.prototype.draw=function(t){return this._draw(t,!1).data},kh.prototype.drawWithMetrics=function(t){return this._draw(t,!0)},Ch.default=Mh;const Lh={none:0,ideographs:1,all:2};class Rh{constructor(t,e,i){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});g(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const o=Math.floor(e/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:t,id:e,glyph:n});let s=r.requests[o];s||(s=r.requests[o]=[],Rh.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[o]=!0}for(const i of s)i(t,e);delete r.requests[o]}))),s.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:n}of i)(t[e]||(t[e]={}))[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Lh.none&&(this.localGlyphMode===Lh.all?!!this.localFontFamily:!!this.localFontFamily&&(Mn(t)||Pn(t)||vn(t)||bn(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(i))return;let n=t.tinySDF;if(!n){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),n=t.tinySDF=new Rh.TinySDF(48,6,16,.25,r,i)}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const{data:o,metrics:s}=n.drawWithMetrics(String.fromCharCode(i)),{sdfWidth:a,sdfHeight:l,width:c,height:h,left:u,top:d,advance:p}=s;return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new Ga({width:a,height:l},o),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}function Bh(t,e,i,r){const o=[],s=t.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,h=t.right-t.left,u=t.bottom-t.top,d=s.stretchX||[[0,l]],p=s.stretchY||[[0,c]],f=(t,e)=>t+e[1]-e[0],m=d.reduce(f,0),_=p.reduce(f,0),g=l-m,y=c-_;let x=0,v=m,b=0,w=_,T=0,E=g,S=0,I=y;if(s.content&&r){const t=s.content;x=Fh(d,0,t[0]),b=Fh(p,0,t[1]),v=Fh(d,t[0],t[2]),w=Fh(p,t[1],t[3]),T=t[0]-x,S=t[1]-b,E=t[2]-t[0]-v,I=t[3]-t[1]-w}const A=(r,o,l,c)=>{const d=Uh(r.stretch-x,v,h,t.left),p=Vh(r.fixed-T,E,r.stretch,m),f=Uh(o.stretch-b,w,u,t.top),g=Vh(o.fixed-S,I,o.stretch,_),y=Uh(l.stretch-x,v,h,t.left),A=Vh(l.fixed-T,E,l.stretch,m),C=Uh(c.stretch-b,w,u,t.top),M=Vh(c.fixed-S,I,c.stretch,_),z=new n(d,f),k=new n(y,f),P=new n(y,C),D=new n(d,C),L=new n(p/a,g/a),R=new n(A/a,M/a),B=e*Math.PI/180;if(B){const t=Math.sin(B),e=Math.cos(B),i=[e,-t,t,e];z._matMult(i),k._matMult(i),D._matMult(i),P._matMult(i)}const F=r.stretch+r.fixed,O=o.stretch+o.fixed;return{tl:z,tr:k,bl:D,br:P,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+O,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:R,minFontScaleX:E/a/h,minFontScaleY:I/a/u,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const t=Oh(d,g,m),e=Oh(p,y,_);for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)o.push(A(r,e[t],n,e[t+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function Fh(t,e,i){let r=0;for(const n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function Oh(t,e,i){const r=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+1,stretch:i}),r}function Uh(t,e,i,r){return t/e*i+r}function Vh(t,e,i,r){return t-e*i/r}Rh.loadGlyphRange=function(t,e,i,r,n){const o=256*e,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),bt.Glyphs);St(a,((t,e)=>{if(t)n(t);else if(e){const t={};for(const i of function(t){return new zc(t).readFields(Kc,[])}(e))t[i.id]=i;n(null,t)}}))},Rh.TinySDF=Ch;class Nh{constructor(t=[],e=Gh){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1),o=e[r];const s=r+1;if(s<this.length&&i(e[s],o)<0&&(r=s,o=e[s]),i(o,n)>=0)break;e[t]=o,t=r}e[t]=n}}function Gh(t,e){return t<e?-1:t>e?1:0}function Zh(t,e=1,i=!1){let r=1/0,o=1/0,s=-1/0,a=-1/0;const l=t[0];for(let t=0;t<l.length;t++){const e=l[t];(!t||e.x<r)&&(r=e.x),(!t||e.y<o)&&(o=e.y),(!t||e.x>s)&&(s=e.x),(!t||e.y>a)&&(a=e.y)}const c=Math.min(s-r,a-o);let h=c/2;const u=new Nh([],qh);if(0===c)return new n(r,o);for(let e=r;e<s;e+=c)for(let i=o;i<a;i+=c)u.push(new jh(e+h,i+h,h,t));let d=function(t){let e=0,i=0,r=0;const n=t[0];for(let t=0,o=n.length,s=o-1;t<o;s=t++){const o=n[t],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,e+=3*l}return new jh(i/e,r/e,0,t)}(t),p=u.length;for(;u.length;){const r=u.pop();(r.d>d.d||!d.d)&&(d=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-d.d<=e||(h=r.h/2,u.push(new jh(r.p.x-h,r.p.y-h,h,t)),u.push(new jh(r.p.x+h,r.p.y-h,h,t)),u.push(new jh(r.p.x-h,r.p.y+h,h,t)),u.push(new jh(r.p.x+h,r.p.y+h,h,t)),p+=4)}return i&&(console.log("num probes: "+p),console.log("best distance: "+d.d)),d.p}function qh(t,e){return e.max-t.max}function jh(t,e,i,r){this.p=new n(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;n<e.length;n++){const o=e[n];for(let e=0,n=o.length,s=n-1;e<n;s=e++){const n=o[e],a=o[s];n.y>t.y!=a.y>t.y&&t.x<(a.x-n.x)*(t.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,ia(t,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const $h=Number.POSITIVE_INFINITY;function Xh(t,e){return e[1]!==$h?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Wh(t,e,i,r,n,o,s,a){t.createArrays(),t.tilePixelRatio=Gs/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const l=t.layers[0].layout,c=t.layers[0]._unevaluatedLayout._values,h={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;h.compositeTextSizes=[c["text-size"].possiblyEvaluate(new so(e),s),c["text-size"].possiblyEvaluate(new so(i),s)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;h.compositeIconSizes=[c["icon-size"].possiblyEvaluate(new so(e),s),c["icon-size"].possiblyEvaluate(new so(i),s)]}h.layoutTextSize=c["text-size"].possiblyEvaluate(new so(a+1),s),h.layoutIconSize=c["icon-size"].possiblyEvaluate(new so(a+1),s),h.textMaxSize=c["text-size"].possiblyEvaluate(new so(18),s);const u="map"===l.get("text-rotation-alignment")&&"point"!==l.get("symbol-placement"),d=l.get("text-keep-upright"),p=l.get("text-size");for(const o of t.features){const a=l.get("text-font").evaluate(o,{},s).join(","),c=p.evaluate(o,{},s),f=h.layoutTextSize.evaluate(o,{},s),m=(h.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),_=o.text;let g,y=[0,0];if(_){const r=_.toString(),h=l.get("text-letter-spacing").evaluate(o,{},s)*vc,p=l.get("text-line-height").evaluate(o,{},s)*vc,g=Nn(r)?h:0,x=l.get("text-anchor").evaluate(o,{},s),v=l.get("text-variable-anchor");if(!v){const t=l.get("text-radial-offset").evaluate(o,{},s);y=t?Xh(x,[t*vc,$h]):l.get("text-offset").evaluate(o,{},s).map((t=>t*vc))}let b=u?"center":l.get("text-justify").evaluate(o,{},s);const w=l.get("symbol-placement"),T="point"===w?l.get("text-max-width").evaluate(o,{},s)*vc:0,E=()=>{t.allowVerticalPlacement&&Vn(r)&&(m.vertical=sh(_,e,i,n,a,T,p,x,"left",g,y,ih.vertical,!0,w,f,c))};if(!u&&v){const t="auto"===b?v.map((t=>Hh(t))):[b];let r=!1;for(let o=0;o<t.length;o++){const s=t[o];if(!m.horizontal[s])if(r)m.horizontal[s]=m.horizontal[0];else{const t=sh(_,e,i,n,a,T,p,"center",s,g,y,ih.horizontal,!1,w,f,c);t&&(m.horizontal[s]=t,r=1===t.positionedLines.length)}}E()}else{"auto"===b&&(b=Hh(x));const t=sh(_,e,i,n,a,T,p,x,b,g,y,ih.horizontal,!1,w,f,c);t&&(m.horizontal[b]=t),E(),Vn(r)&&u&&d&&(m.vertical=sh(_,e,i,n,a,T,p,x,b,g,y,ih.vertical,!1,w,f,c))}}let x=!1;if(o.icon&&o.icon.name){const e=r[o.icon.name];e&&(g=gh(n[o.icon.name],l.get("icon-offset").evaluate(o,{},s),l.get("icon-anchor").evaluate(o,{},s)),x=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&k("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==l.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const v=Qh(m.horizontal)||m.vertical;t.iconsInText||(t.iconsInText=!!v&&v.iconsInText),(v||g)&&Kh(t,o,m,g,r,h,f,0,y,x,s)}o&&t.generateCollisionDebugBuffers(a,t.collisionBoxArray)}function Hh(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 Kh(t,e,i,r,n,o,s,a,l,c,u){let d=o.textMaxSize.evaluate(e,{},u);void 0===d&&(d=s);const p=t.layers[0].layout,f=p.get("icon-offset").evaluate(e,{},u),m=Qh(i.horizontal),_=s/24,g=t.tilePixelRatio*d/24,y=t.tilePixelRatio*p.get("symbol-spacing"),x=p.get("text-padding")*t.tilePixelRatio,v=p.get("icon-padding")*t.tilePixelRatio,b=h(p.get("text-max-angle")),w="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),T="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),E=p.get("symbol-placement"),S=y/2,I=p.get("icon-text-fit");let A;r&&"none"!==I&&(t.allowVerticalPlacement&&i.vertical&&(A=yh(r,i.vertical,I,p.get("icon-text-fit-padding"),f,_)),m&&(r=yh(r,m,I,p.get("icon-text-fit-padding"),f,_)));const C=(a,h)=>{h.x<0||h.x>=Gs||h.y<0||h.y>=Gs||function(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=t.addToLineVertexArray(e,i);let S,I,A,C,M,z,P,D=0,L=0,R=0,B=0,F=-1,O=-1;const U={};let V=ds(""),N=0,G=0;if(void 0===a._unevaluatedLayout.getValue("text-radial-offset")?[N,G]=a.layout.get("text-offset").evaluate(x,{},w).map((t=>t*vc)):(N=a.layout.get("text-radial-offset").evaluate(x,{},w)*vc,G=$h),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(p)z=eu(t),s&&(P=eu(s));else{const i=a.layout.get("text-rotate").evaluate(x,{},w)+90;A=tu(l,e,c,h,u,t,d,i),s&&(C=tu(l,e,c,h,u,s,_,i))}}if(n){const i=a.layout.get("icon-rotate").evaluate(x,{},w),r="none"!==a.layout.get("icon-text-fit"),o=Bh(n,i,b,r),d=s?Bh(s,i,b,r):void 0;I=tu(l,e,c,h,u,n,_,i),D=4*o.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[bc*a.layout.get("icon-size").evaluate(x,{},w)],f[0]>Yh&&k(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')):"composite"===p.kind&&(f=[bc*v.compositeIconSizes[0].evaluate(x,{},w),bc*v.compositeIconSizes[1].evaluate(x,{},w)],(f[0]>Yh||f[1]>Yh)&&k(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')),t.addSymbols(t.icon,o,f,y,g,x,!1,e,E.lineStartIndex,E.lineLength,-1,w),F=t.icon.placedSymbolArray.length-1,d&&(L=4*d.length,t.addSymbols(t.icon,d,f,y,g,x,ih.vertical,e,E.lineStartIndex,E.lineLength,-1,w),O=t.icon.placedSymbolArray.length-1)}for(const i in r.horizontal){const n=r.horizontal[i];S||(V=ds(n.text),p?M=eu(n):S=tu(l,e,c,h,u,n,d,a.layout.get("text-rotate").evaluate(x,{},w)));const s=1===n.positionedLines.length;if(R+=Jh(t,e,n,o,a,p,x,f,E,r.vertical?ih.horizontal:ih.horizontalOnly,s?Object.keys(r.horizontal):[i],U,F,v,w),s)break}r.vertical&&(B+=Jh(t,e,r.vertical,o,a,p,x,f,E,ih.vertical,["vertical"],U,O,v,w));let Z=-1;const q=(t,e)=>t?Math.max(t,e):e;Z=q(M,Z),Z=q(z,Z),Z=q(P,Z);const j=Z>-1?1:0;j&&(Z*=T/vc),t.glyphOffsetArray.length>=hu.MAX_GLYPHS&&k("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical||-1,F,O,V,void 0!==S?S:t.collisionBoxArray.length,void 0!==S?S+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,C||t.collisionBoxArray.length,C?C+1:t.collisionBoxArray.length,c,R,B,D,L,j,0,N,G,Z)}(t,h,a,i,r,n,A,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,x,w,l,0,v,T,f,e,o,c,u,s)};if("line"===E)for(const n of Ah(e.geometry,0,0,Gs,Gs)){const e=Sh(n,y,b,i.vertical||m,r,24,g,t.overscaling,Gs);for(const i of e){const e=m;e&&iu(t,e.text,S,i)||C(n,i)}}else if("line-center"===E){for(const t of e.geometry)if(t.length>1){const e=Eh(t,b,i.vertical||m,r,24,g);e&&C(t,e)}}else if("Polygon"===e.type)for(const t of Al(e.geometry,0)){const e=Zh(t,16);C(t[0],new xh(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)C(t,new xh(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)C([e],new xh(e.x,e.y,0))}const Yh=32640;function Jh(t,e,i,r,o,s,a,l,c,h,u,d,p,f,m){const _=function(t,e,i,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const r of t.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let u=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,_=r.metrics.advance*r.scale/2;if(l&&e.verticalizable){const e=(r.scale-1)*vc,i=(vc-r.metrics.width*r.scale)/2;f=t.lineOffset/2-(r.imageName?-i:e)}if(r.imageName){const t=a[r.imageName];d=t.sdf,p=t.pixelRatio,u=1/p}const g=o?[r.x+_,r.y]:[0,0];let y=o?[0,0]:[r.x+_+i[0],r.y+i[1]-f],x=[0,0];m&&(x=y,y=[0,0]);const v=(r.metrics.left-u)*r.scale-_+y[0],b=(-r.metrics.top-u)*r.scale+y[1],w=v+s.w*r.scale/(p*(r.localGlyph?2:1)),T=b+s.h*r.scale/(p*(r.localGlyph?2:1)),E=new n(v,b),S=new n(w,b),I=new n(v,T),A=new n(w,T);if(m){const t=new n(-_,_-rh),e=-Math.PI/2,i=12-_,o=new n(22-i,-(r.imageName?i:0)),s=new n(...x);E._rotateAround(e,t)._add(o)._add(s),S._rotateAround(e,t)._add(o)._add(s),I._rotateAround(e,t)._add(o)._add(s),A._rotateAround(e,t)._add(o)._add(s)}if(c){const t=Math.sin(c),e=Math.cos(c),i=[e,-t,t,e];E._matMult(i),S._matMult(i),I._matMult(i),A._matMult(i)}const C=new n(0,0),M=new n(0,0);h.push({tl:E,tr:S,bl:I,br:A,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:C,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return h}(0,i,l,o,s,a,r,t.allowVerticalPlacement),g=t.textSizeData;let y=null;"source"===g.kind?(y=[bc*o.layout.get("text-size").evaluate(a,{},m)],y[0]>Yh&&k(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')):"composite"===g.kind&&(y=[bc*f.compositeTextSizes[0].evaluate(a,{},m),bc*f.compositeTextSizes[1].evaluate(a,{},m)],(y[0]>Yh||y[1]>Yh)&&k(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')),t.addSymbols(t.text,_,y,l,s,a,h,e,c.lineStartIndex,c.lineLength,p,m);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*_.length}function Qh(t){for(const e in t)return t[e];return null}function tu(t,e,i,r,o,s,a,l){let c=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],c-=f[1],p+=f[2],u+=f[3]),l){const t=new n(d,c),e=new n(p,c),i=new n(d,u),r=new n(p,u),o=h(l);t._rotate(o),e._rotate(o),i._rotate(o),r._rotate(o),d=Math.min(t.x,e.x,i.x,r.x),p=Math.max(t.x,e.x,i.x,r.x),c=Math.min(t.y,e.y,i.y,r.y),u=Math.max(t.y,e.y,i.y,r.y)}return t.emplaceBack(e.x,e.y,d,c,p,u,a,i,r,o),t.length-1}function eu(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 iu(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const ru=jl.VectorTileFeature.types,nu=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ou(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(Yh,Math.round(a[0])):0,f=a?Math.min(Yh,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function su(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function au(t){for(const e of t.sections)if(Xn(e.text))return!0;return!1}class lu{constructor(t){this.layoutVertexArray=new Lo,this.indexArray=new No,this.programConfigurations=t,this.segments=new Ns,this.dynamicLayoutVertexArray=new Ro,this.opacityVertexArray=new Bo,this.placedSymbolArray=new Qo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,mc.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,nu,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}an("SymbolBuffers",lu);class cu{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Ns,this.collisionVertexArray=new Vo,this.collisionVertexArrayExt=new Ro}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,_c.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,gc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}an("CollisionBuffers",cu);class hu{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ma([]),this.placementViewportMatrix=ma([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=wc(this.zoom,e["text-size"]),this.iconSizeData=wc(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>ih[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new lu(new ks(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new lu(new ks(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new is,this.lineVertexArray=new rs,this.symbolInstances=new es}calculateGlyphDependencies(t,e,i,r,n){for(let o=0;o<t.length;o++)if(e[t.charCodeAt(o)]=!0,(i||r)&&n){const i=Ac[t.charAt(o)];i&&(e[i.charCodeAt(0)]=!0)}}populate(t,e,i){const r=this.layers[0],n=r.layout,o=n.get("text-font"),s=n.get("text-field"),a=n.get("icon-image"),l=("constant"!==s.value.kind||s.value.value instanceof pe&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),c="constant"!==a.value.kind||!!a.value.value||Object.keys(a.parameters).length>0,h=n.get("symbol-sort-key");if(this.features=[],!l&&!c)return;const u=e.iconDependencies,d=e.glyphDependencies,p=e.availableImages,f=new so(this.zoom);for(const{feature:e,id:s,index:a,sourceLayerIndex:m}of t){const t=r._featureFilter.needGeometry,_=$s(e,t);if(!r._featureFilter.filter(f,_,i))continue;let g,y;if(t||(_.geometry=js(e)),l){const t=r.getValueAndResolveTokens("text-field",_,i,p),e=pe.factory(t);au(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ro()||this.hasRTLText&&oo.isParsed())&&(g=Ic(e,r,_))}if(c){const t=r.getValueAndResolveTokens("icon-image",_,i,p);y=t instanceof fe?t:fe.fromString(t)}if(!g&&!y)continue;const x=this.sortFeaturesByKey?h.evaluate(_,{},i):void 0;if(this.features.push({id:s,text:g,icon:y,index:a,sourceLayerIndex:m,geometry:_.geometry,properties:e.properties,type:ru[e.type],sortKey:x}),y&&(u[y.name]=!0),g){const t=o.evaluate(_,{},i).join(","),e="map"===n.get("text-rotation-alignment")&&"point"!==n.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(ih.vertical)>=0;for(const i of g.sections)if(i.image)u[i.image.name]=!0;else{const r=Vn(g.toString()),n=i.fontStack||t,o=d[n]=d[n]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,r)}}}"line"===n.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function o(e){r.push(t[e]),n++}function s(t,e,n){const o=i[t];return delete i[t],i[e]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(t,i,n){const o=e[i];return delete e[i],e[t]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){o(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in e&&i[p]!==e[f]){const t=a(p,f,u),n=s(p,f,r[t].geometry);delete e[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[t].geometry=null}else p in i?s(p,f,u):f in e?a(p,f,u):(o(c),e[p]=n-1,i[f]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let r=t.segment+1;r<e.length;r++)n[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=n[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,n,o,s,a,l,c,h,u){const d=t.indexArray,p=t.layoutVertexArray,f=t.segments.prepareSegment(4*e.length,p,d,this.canOverlap?o.sortKey:void 0),m=this.glyphOffsetArray.length,_=f.vertexLength,g=this.allowVerticalPlacement&&s===ih.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let r=0;r<e.length;r++){const{tl:n,tr:s,bl:l,br:c,tex:h,pixelOffsetTL:m,pixelOffsetBR:_,minFontScaleX:x,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=e[r],E=f.vertexLength,S=b[1];ou(p,a.x,a.y,n.x,S+n.y,h.x,h.y,i,w,m.x,m.y,x,v),ou(p,a.x,a.y,s.x,S+s.y,h.x+h.w,h.y,i,w,_.x,m.y,x,v),ou(p,a.x,a.y,l.x,S+l.y,h.x,h.y+h.h,i,w,m.x,_.y,x,v),ou(p,a.x,a.y,c.x,S+c.y,h.x+h.w,h.y+h.h,i,w,_.x,_.y,x,v),su(t.dynamicLayoutVertexArray,a,g),d.emplaceBack(E,E+1,E+2),d.emplaceBack(E+1,E+2,E+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),r!==e.length-1&&T===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(p.length,o,o.index,{},u,y&&y[T])}t.placedSymbolArray.emplaceBack(a.x,a.y,m,this.glyphOffsetArray.length-m,_,l,c,a.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,h)}_commitLayoutVertex(t,e,i,r,n){t.emplaceBack(e.x,e.y,i,r,Math.round(n.x),Math.round(n.y))}_addCollisionDebugVertices(t,e,i,r,o){const s=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),a=s.vertexLength,l=o.anchorX,c=o.anchorY;for(let t=0;t<4;t++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(e,-t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,t.padding),i.collisionVertexArrayExt.emplaceBack(e,-t.padding,t.padding),this._commitLayoutVertex(i.layoutVertexArray,r,l,c,new n(t.x1,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,l,c,new n(t.x2,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,l,c,new n(t.x2,t.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,l,c,new n(t.x1,t.y2)),s.vertexLength+=4;const h=i.indexArray;h.emplaceBack(a,a+1),h.emplaceBack(a+1,a+2),h.emplaceBack(a+2,a+3),h.emplaceBack(a+3,a),s.primitiveLength+=4}_addTextDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(t,o,e,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.anchorPoint,o)}}_addIconDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(t,e,s);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.anchorPoint,o)}}generateCollisionDebugBuffers(t,e){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new cu(Oo,yc.members,Xo),this.iconCollisionBox=new cu(Oo,yc.members,Xo);const i=Ec(this.iconSizeData,t),r=Ec(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(t,e,i,r){const n=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),o=Tc(this.textSizeData,t,n)/vc;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),n=Tc(this.iconSizeData,t,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(t,o,e,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(t,e,i,r,n){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(t,e,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(t,e){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Ec(this.iconSizeData,t),r=Ec(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,e,i,r,n,o,s,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,padding:e.padding,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=o;e<s;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const s=this.symbolInstances.get(t);r.push(0|Math.round(e*s.anchorX+i*s.anchorY)),n.push(s.featureIndex)}return o.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),o}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}an("SymbolBucket",hu,{omit:["layers","collisionBoxArray","features","compareText"]}),hu.MAX_GLYPHS=65535,hu.addDynamicAttributes=su;const uu=new bo({"symbol-placement":new _o(Ot.layout_symbol["symbol-placement"]),"symbol-spacing":new _o(Ot.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _o(Ot.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new go(Ot.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _o(Ot.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _o(Ot.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new _o(Ot.layout_symbol["icon-ignore-placement"]),"icon-optional":new _o(Ot.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _o(Ot.layout_symbol["icon-rotation-alignment"]),"icon-size":new go(Ot.layout_symbol["icon-size"]),"icon-text-fit":new _o(Ot.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _o(Ot.layout_symbol["icon-text-fit-padding"]),"icon-image":new go(Ot.layout_symbol["icon-image"]),"icon-rotate":new go(Ot.layout_symbol["icon-rotate"]),"icon-padding":new _o(Ot.layout_symbol["icon-padding"]),"icon-keep-upright":new _o(Ot.layout_symbol["icon-keep-upright"]),"icon-offset":new go(Ot.layout_symbol["icon-offset"]),"icon-anchor":new go(Ot.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _o(Ot.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _o(Ot.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _o(Ot.layout_symbol["text-rotation-alignment"]),"text-field":new go(Ot.layout_symbol["text-field"]),"text-font":new go(Ot.layout_symbol["text-font"]),"text-size":new go(Ot.layout_symbol["text-size"]),"text-max-width":new go(Ot.layout_symbol["text-max-width"]),"text-line-height":new go(Ot.layout_symbol["text-line-height"]),"text-letter-spacing":new go(Ot.layout_symbol["text-letter-spacing"]),"text-justify":new go(Ot.layout_symbol["text-justify"]),"text-radial-offset":new go(Ot.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _o(Ot.layout_symbol["text-variable-anchor"]),"text-anchor":new go(Ot.layout_symbol["text-anchor"]),"text-max-angle":new _o(Ot.layout_symbol["text-max-angle"]),"text-writing-mode":new _o(Ot.layout_symbol["text-writing-mode"]),"text-rotate":new go(Ot.layout_symbol["text-rotate"]),"text-padding":new _o(Ot.layout_symbol["text-padding"]),"text-keep-upright":new _o(Ot.layout_symbol["text-keep-upright"]),"text-transform":new go(Ot.layout_symbol["text-transform"]),"text-offset":new go(Ot.layout_symbol["text-offset"]),"text-allow-overlap":new _o(Ot.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new _o(Ot.layout_symbol["text-ignore-placement"]),"text-optional":new _o(Ot.layout_symbol["text-optional"])});var du={paint:new bo({"icon-opacity":new go(Ot.paint_symbol["icon-opacity"]),"icon-color":new go(Ot.paint_symbol["icon-color"]),"icon-halo-color":new go(Ot.paint_symbol["icon-halo-color"]),"icon-halo-width":new go(Ot.paint_symbol["icon-halo-width"]),"icon-halo-blur":new go(Ot.paint_symbol["icon-halo-blur"]),"icon-translate":new _o(Ot.paint_symbol["icon-translate"]),"icon-translate-anchor":new _o(Ot.paint_symbol["icon-translate-anchor"]),"text-opacity":new go(Ot.paint_symbol["text-opacity"]),"text-color":new go(Ot.paint_symbol["text-color"],{runtimeType:Kt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new go(Ot.paint_symbol["text-halo-color"]),"text-halo-width":new go(Ot.paint_symbol["text-halo-width"]),"text-halo-blur":new go(Ot.paint_symbol["text-halo-blur"]),"text-translate":new _o(Ot.paint_symbol["text-translate"]),"text-translate-anchor":new _o(Ot.paint_symbol["text-translate-anchor"])}),layout:uu};class pu{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:$t,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}an("FormatSectionOverride",pu,{omit:["defaultValue"]});class fu extends Os{constructor(t){super(t,du)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||lr(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new hu(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of du.paint.overridableProperties){if(!fu.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new pu(e),r=new ar(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new hr("source",r):new ur("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new fo(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&fu.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=du.paint.properties[e];let n=!1;const o=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof pe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof xe&&ge(e.value)===te?o(e.value.sections):e instanceof Te?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(t){return new zs(this,t)}}var mu={paint:new bo({"background-color":new _o(Ot.paint_background["background-color"]),"background-pattern":new xo(Ot.paint_background["background-pattern"]),"background-opacity":new _o(Ot.paint_background["background-opacity"])})},_u={paint:new bo({"raster-opacity":new _o(Ot.paint_raster["raster-opacity"]),"raster-hue-rotate":new _o(Ot.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _o(Ot.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _o(Ot.paint_raster["raster-brightness-max"]),"raster-saturation":new _o(Ot.paint_raster["raster-saturation"]),"raster-contrast":new _o(Ot.paint_raster["raster-contrast"]),"raster-resampling":new _o(Ot.paint_raster["raster-resampling"]),"raster-fade-duration":new _o(Ot.paint_raster["raster-fade-duration"])})};class gu extends Os{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var yu={paint:new bo({"sky-type":new _o(Ot.paint_sky["sky-type"]),"sky-atmosphere-sun":new _o(Ot.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new _o(Ot.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new _o(Ot.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new _o(Ot.paint_sky["sky-gradient-radius"]),"sky-gradient":new vo(Ot.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new _o(Ot.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new _o(Ot.paint_sky["sky-atmosphere-color"]),"sky-opacity":new _o(Ot.paint_sky["sky-opacity"])})};function xu(t,e,i){const r=va(0,0,1),n=Pa(ka());return function(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l-o*a,t[1]=n*l+s*a,t[2]=o*l+r*a,t[3]=s*l-n*a}(n,n,i?-h(t)+Math.PI:h(t)),Da(n,n,-h(e)),Sa(r,r,n),Ea(r,r)}const vu={circle:class extends Os{constructor(t){super(t,da)}createBucket(t){return new Ws(t)}queryRadius(t){const e=t;return aa("circle-radius",this,e)+aa("circle-stroke-width",this,e)+la(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,o,s,a){const l="map"===this.paint.get("circle-pitch-alignment");if(l&&t.queryGeometry.isAboveHorizon)return!1;const c=ha(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),h=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),u=l?h*t.pixelToTileUnitsFactor:h;for(const e of r)for(const i of e){const e=i.add(c),r=a&&o.elevation?o.elevation.exaggeration()*a.getElevationAt(e.x,e.y,!0):0,n=l?e:La(e,r,s),h=l?t.tilespaceRays.map((t=>Fa(t,r))):t.queryGeometry.screenGeometry;let d=u;const p=za([],[i.x,i.y,r,1],s);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?d*=p[3]/o.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(d*=o.cameraToCenterDistance/p[3]),Ks(h,n,d))return!0}return!1}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new zs(this,t)}},heatmap:class extends Os{createBucket(t){return new Oa(t)}constructor(t){super(t,qa),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ja({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new zs(this,t)}},hillshade:class extends Os{constructor(t){super(t,$a)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new zs(this,t)}},fill:class extends Os{constructor(t){super(t,Dl)}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 zs(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new kl(t)}queryRadius(){return la(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,o){return!t.queryGeometry.isAboveHorizon&&Ys(ca(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Os{constructor(t){super(t,Jl)}createBucket(t){return new Kl(t)}queryRadius(){return la(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 zs(this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l,c){const h=ha(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,i),d=this.paint.get("fill-extrusion-base").evaluate(e,i),p=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1;if(f){const e=t.tile.getBucket(this).centroidVertexArray,i=c+1;if(i<e.length){const t=e.get(i);p[0]=t.a_centroid_pos0,p[1]=t.a_centroid_pos1}}if(0===p[0]&&1===p[1])return!1;const _=function(t,e,i,r,o,s,a,l,c){return s?function(t,e,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+r.x,d=c.y+r.y,f=ic(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,za(u,u,n),u[3]=Math.max(u[3],1e-5);const m=ec([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,za(u,u,n),u[3]=Math.max(u[3],1e-5);const _=ec([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(t,e,i,r,o,s,a,l,c):function(t,e,i,r,o){const s=[],a=[],l=o[8]*e,c=o[9]*e,h=o[10]*e,u=o[11]*e,d=o[8]*i,p=o[9]*i,f=o[10]*i,m=o[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=o[0]*e+o[4]*a+o[12],g=o[1]*e+o[5]*a+o[13],y=o[2]*e+o[6]*a+o[14],x=o[3]*e+o[7]*a+o[15],v=_+l,b=g+c,w=y+h,T=Math.max(x+u,1e-5),E=_+d,S=g+p,I=y+f,A=Math.max(x+m,1e-5),C=new n(v/T,b/T);C.z=w/T,t.push(C);const M=new n(E/A,S/A);M.z=I/A,i.push(M)}s.push(t),a.push(i)}return[s,a]}(t,e,i,r,o)}(r,d,u,h,a,f?l:null,p,m,s.center.lat),g=t.queryGeometry;return function(t,e,i){let r=1/0;Ys(i,e)&&(r=tc(i,e[0]));for(let n=0;n<e.length;n++){const o=e[n],s=t[n];for(let t=0;t<o.length-1;t++){const e=o[t],n=[e,o[t+1],s[t+1],s[t],e];Hs(i,n)&&(r=Math.min(r,tc(i,n)))}}return r!==1/0&&r}(_[0],_[1],g.isPointQuery()?g.screenBounds:g.screenGeometry)}},line:class extends Os{constructor(t){super(t,uc),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof ei,this.gradientVersion=(this.gradientVersion+1)%a}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=dc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new cc(t)}getProgramIds(){const t=this.paint.get("line-dasharray"),e=this.paint.get("line-pattern").constantOr(1),i=this.paint.get("line-gradient");return[e?"linePattern":t?"lineSDF":i?"lineGradient":"line"]}getProgramConfiguration(t){return new zs(this,t)}queryRadius(t){const e=t,i=pc(aa("line-width",this,e),aa("line-gap-width",this,e)),r=aa("line-offset",this,e);return i/2+Math.abs(r)+la(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,o,s){if(t.queryGeometry.isAboveHorizon)return!1;const a=ca(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),l=t.pixelToTileUnitsFactor/2*pc(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[],r=new n(0,0);for(let n=0;n<t.length;n++){const o=t[n],s=[];for(let t=0;t<o.length;t++){const i=o[t-1],n=o[t],a=o[t+1],l=0===t?r:n.sub(i)._unit()._perp(),c=t===o.length-1?r:a.sub(n)._unit()._perp(),h=l._add(c)._unit();h._mult(1/(h.x*c.x+h.y*c.y)),s.push(h._mult(e)._add(n))}i.push(s)}return i}(r,c*t.pixelToTileUnitsFactor)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(na(t,n[e]))return!0;if(Js(t,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}},symbol:fu,background:class extends Os{constructor(t){super(t,mu)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Os{constructor(t){super(t,_u)}getProgramIds(){return["raster"]}},sky:class extends Os{constructor(t){super(t,yu),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=ja({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}}getCenter(t,e){const i=this.paint.get("sky-type");if("atmosphere"===i){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=t.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&k("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?xu(o.azimuthal,90-o.polar,e):xu(i[0],90-i[1],e)}if("gradient"===i){const t=this.paint.get("sky-gradient-center");return xu(t[0],90-t[1],e)}}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}}},{HTMLImageElement:bu,HTMLCanvasElement:wu,HTMLVideoElement:Tu,ImageData:Eu,ImageBitmap:Su}=s;class Iu{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:n}=t,o=!(this.size&&this.size[0]===r&&this.size[1]===n||i),{context:s}=this,{gl:a}=s;if(this.useMipmap=Boolean(e&&e.useMipmap),a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!e||!1!==e.premultiply)),o)this.size=[r,n],t instanceof bu||t instanceof wu||t instanceof Tu||t instanceof Eu||Su&&t instanceof Su?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,t):a.texImage2D(a.TEXTURE_2D,0,this.format,r,n,0,this.format,a.UNSIGNED_BYTE,t.data);else{const{x:e,y:o}=i||{x:0,y:0};t instanceof bu||t instanceof wu||t instanceof Tu||t instanceof Eu||Su&&t instanceof Su?a.texSubImage2D(a.TEXTURE_2D,0,e,o,a.RGBA,a.UNSIGNED_BYTE,t):a.texSubImage2D(a.TEXTURE_2D,0,e,o,r,n,a.RGBA,a.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&a.generateMipmap(a.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),t!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Au{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Mu?new Mu(t.lng,t.lat):Mu.convert(t),this}setSouthWest(t){return this._sw=t instanceof Mu?new Mu(t.lng,t.lat):Mu.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof Mu)r=t,n=t;else{if(!(t instanceof Au))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Au.convert(t)):this.extend(Mu.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Mu(r.lng,r.lat),this._ne=new Mu(n.lng,n.lat)),this}getCenter(){return new Mu((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 Mu(this.getWest(),this.getNorth())}getSouthEast(){return new Mu(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Mu.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof Au?t:new Au(t)}}const Cu=6371008.8;class Mu{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Mu(_(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Cu*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Au(new Mu(this.lng-i,this.lat-e),new Mu(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Mu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Mu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Mu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const zu=2*Math.PI*Cu;function ku(t){return zu*Math.cos(t*Math.PI/180)}function Pu(t){return(180+t)/360}function Du(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Lu(t,e){return t/ku(e)}function Ru(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Bu(t,e){return t*ku(Ru(e))}class Fu{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Mu.convert(t);return new Fu(Pu(i.lng),Du(i.lat),Lu(e,i.lat))}toLngLat(){return new Mu(360*this.x-180,Ru(this.y))}toAltitude(){return Bu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/zu*(t=Ru(this.y),1/Math.cos(t*Math.PI/180));var t}}class Ou{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new Ga({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const i=this.getKey(t,e);return this.positions[i]}trim(){const t=this.width,e=this.height=T(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let o=0,s=t[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(r+1);if(s.isDash){const t=r-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=t[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return k("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&(k("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const i=this.width/s,o=this.getDashRanges(t,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===e?.5*i:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}an("LineAtlas",Ou);class Uu{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}const Vu=s.performance;function Nu(t){const e=t?t.url.toString():void 0;return Vu.getEntriesByName(e)}class Gu{constructor(){this.tasks={},this.taskQueue=[],S(["process"],this),this.invoker=new Uu(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){L();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){L();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<e&&(e=r.priority,t=i)}if(null===t)return null;const i=this.taskQueue[t];return this.taskQueue.splice(t,1),i}remove(){this.invoker.remove()}}function Zu(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 qu{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=Xu(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=(n=this.y,o=this.z,s=Zu(256*(r=this.x),256*(n=Math.pow(2,o)-n-1),o),a=Zu(256*(r+1),256*(n+1),o),s[0]+","+s[1]+","+a[0]+","+a[1]);var r,n,o,s,a;const l=function(t,e,i){let r,n="";for(let o=t;o>0;o--)r=1<<o-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String("tms"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",l).replace("{bbox-epsg-3857}",i)}getTilePoint(t){const e=Math.pow(2,this.z);return new n((t.x*e-this.x)*Gs,(t.y*e-this.y)*Gs)}getTileVec3(t){const e=Math.pow(2,this.z);return va((t.x*e-this.x)*Gs,(t.y*e-this.y)*Gs,Bu(t.z,t.y))}toString(){return`${this.z}/${this.x}/${this.y}`}}class ju{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Xu(t,e.z,e.z,e.x,e.y)}}class $u{constructor(t,e,i,r,n){this.overscaledZ=t,this.wrap=e,this.canonical=new qu(i,+r,+n),this.key=0===e&&t===i?this.canonical.key:Xu(e,t,i,r,n)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new $u(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new $u(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Xu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Xu(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new $u(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new $u(e,this.wrap,e,i,r),new $u(e,this.wrap,e,i+1,r),new $u(e,this.wrap,e,i,r+1),new $u(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new $u(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new $u(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ju(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Fu(t.x-this.wrap,t.y))}getTileVec3(t){return this.canonical.getTileVec3(new Fu(t.x-this.wrap,t.y,t.z))}}function Xu(t,e,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return t&&i<22&&(s+=o*o*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*s+i)+(e-i)}an("CanonicalTileID",qu),an("OverscaledTileID",$u,{omit:["projMatrix"]});class Wu{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}class Hu{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}var Ku=Io([{name:"a_pos",type:"Int16",components:2}]);class Yu{constructor(t,e,i){this.tileID=t,this.uid=b(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;e<G.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}loadVectorData(t,e,i){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof hu){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof hu&&e.hasRTLText){this.hasRTLText=!0,oo.isLoading()||oo.isLoaded()||"deferred"!==ro()||no();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new Yo}unloadVectorData(){for(const t in this.buckets)this.buckets[t].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.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Iu(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Iu(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Iu(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Tr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let e=0;e<o.length;e++){const r=o.feature(e);if(s.needGeometry){const t=$s(r,!0);if(!s.filter(new so(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!s.filter(new so(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),d=new Hu(r,a,l,c,u);d.tile=h,t.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=R(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const i=this.latestFeatureIndex.loadVTLayers();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const n=this.buckets[r],o=n.layers[0].sourceLayer||"_geojsonTileLayer",s=i[o],a=t[o];if(!s||!a||0===Object.keys(a).length)continue;n.update(a,s,this.imageAtlas&&this.imageAtlas.patternPositions||{});const l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(n)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<G.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=G.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}clearQueryDebugViz(){}}class Ju{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},x(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=x({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),x(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},x(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class Qu{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function td(t,e,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<t[s]||i[s]>e[s])return null}else{const a=1/r[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function ed(t,e,i,r,n,o,s,a,l,c,h){const u=r-t,d=n-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-t,T=c[1]-e,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const I=T*p-E*d,A=E*u-w*p,C=w*d-T*u,M=(h[0]*I+h[1]*A+h[2]*C)*b;return M<0||S+M>1?null:(f*I+m*A+_*C)*b}function id(t,e,i){return(t-e)/(i-e)}function rd(t,e,i,r,n,o,s,a,l){const c=1<<i,h=o-r,u=s-n,d=(t+1)/c*h+r,p=(e+0)/c*u+n,f=(e+1)/c*u+n;a[0]=(t+0)/c*h+r,a[1]=p,l[0]=d,l[1]=f}class nd{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),i=[];let r=Math.ceil(Math.pow(2,e));const n=1/r,o=(t,e,i,r,n)=>{const o=r?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;n[0]=t*i,n[1]=a,n[2]=s,n[3]=l};let s=new Qu(r);const a=[];for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),n,!1,a);const i=sd(a[0],a[1],t),l=sd(a[2],a[1],t),c=sd(a[2],a[3],t),h=sd(a[0],a[3],t);s.minimums.push(Math.min(i,l,c,h)),s.maximums.push(Math.max(i,l,c,h)),s.leaves.push(1)}for(i.push(s),r/=2;r>=1;r/=2){const t=i[i.length-1];s=new Qu(r);for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),2,!0,a);const i=t.getElevation(a[0],a[1]),n=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),c=t.getElevation(a[0],a[3]),h=t.isLeaf(a[0],a[1]),u=t.isLeaf(a[2],a[1]),d=t.isLeaf(a[2],a[3]),p=t.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=h&&u&&d&&p;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0)}i.push(s)}return i}(this.dem),i=e.length-1,r=e[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(e,0,0,i,0)}raycastRoot(t,e,i,r,n,o,s=1){return td([t,e,-100],[i,r,this.maximums[0]*s],n,o)}raycast(t,e,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,i,r,n,o,s);if(null==a)return null;const l=[],c=[],h=[],u=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){rd(f,m,_,t,e,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=sd(l,d,this.dem)*s,x=sd(c,d,this.dem)*s,v=sd(c,g,this.dem)*s,b=sd(l,g,this.dem)*s,w=ed(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,o),T=ed(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const t=Ta([],n,o,p);if(od(y,x,b,v,id(t[0],h[0],u[0]),id(t[1],h[1],u[1]))>=t[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){rd((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],_+1,t,e,i,r,h,u),h[2]=-100,u[2]=this.maximums[this.childOffsets[a]+d]*s;const p=td(h,u,n,o);if(null!=p){const t=p;l[d]=t;let e=!1;for(let i=0;i<g&&!e;i++)t>=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t<g;t++){const e=c[t];d.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:_+1})}}return null}_addNode(t,e,i){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,i,r,n){if(1===t[r].isLeaf(e,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=t[o];let a,l=0;for(let t=0;t<this._siblingOffset.length;t++){const r=2*e+this._siblingOffset[t][0],n=2*i+this._siblingOffset[t][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),h=this._addNode(o.min,o.max,c);c&&(l|=1<<t),a||(a=h)}for(let r=0;r<this._siblingOffset.length;r++)l&1<<r||this._construct(t,2*e+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,a+r)}}function od(t,e,i,r,n,o){return ii(ii(t,i,o),ii(e,r,o),n)}function sd(t,e,i){const r=i.dim,n=m(t*r-.5,0,r-1),o=m(e*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return od(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const ad={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class ld{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,i,r=!1,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return k(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const o=this.dim=e.height-2;if(this.data=new Uint32Array(e.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let t=0;t<o;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(o,t)]=this.data[this._idx(o-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,o)]=this.data[this._idx(t,o-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(o,-1)]=this.data[this._idx(o-1,0)],this.data[this._idx(-1,o)]=this.data[this._idx(0,o-1)],this.data[this._idx(o,o)]=this.data[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new nd(this)}get(t,e,i=!1){const r=new Uint8Array(this.data.buffer);i&&(t=m(t,-1,this.dim),e=m(e,-1,this.dim));const n=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(r[n],r[n+1],r[n+2])}static getUnpackVector(t){return ad[t]}get unpackVector(){return ad[this.encoding]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=ld.getUnpackVector(e);let n=Math.floor((t+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new Za({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e<s;e++)for(let i=r;i<n;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+l)]}onDeserialize(){this._tree&&(this._tree.dem=this)}}an("DEMData",ld),an("DemMinMaxQuadTree",nd,{omit:["dem"]});class cd{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class hd{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}hd.ReadOnly=!1,hd.ReadWrite=!0,hd.disabled=new hd(519,hd.ReadOnly,[0,1]);const ud=7680;class dd{constructor(t,e,i,r,n,o){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}dd.disabled=new dd({func:519,mask:0},0,0,ud,ud,ud);class pd{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}pd.Replace=[1,0],pd.disabled=new pd(pd.Replace,he.transparent,[!1,!1,!1,!1]),pd.unblended=new pd(pd.Replace,he.transparent,[!0,!0,!0,!0]),pd.alphaBlended=new pd([1,771],he.transparent,[!0,!0,!0,!0]);const fd=1029,md=2305;class _d{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}_d.disabled=new _d(!1,fd,md),_d.backCCW=new _d(!0,fd,md),_d.backCW=new _d(!0,fd,2304),_d.frontCW=new _d(!0,1028,2304),_d.frontCCW=new _d(!0,1028,md);class gd extends Ft{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new cd(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ju}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return y(this._tiles).map((t=>t.tileID)).sort(yd).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,o=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(yd).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)return t.state="errored",void(404!==r.status?this._source.fire(new Bt(r,{tile:t})):this.update(this.transform));t.timeAdded=G.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Rt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,n=Math.floor(i*r*5),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(o)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new $u(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=this._updateRetainedTiles(r);if(xd(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=G.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-gd.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[r]=i}const o=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(n[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&e[r.key]){n[t]=i.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e])}for(const t in n)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,n);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t[t.length-1].overscaledZ,n=t[0].overscaledZ,o=Math.max(n-gd.maxOverzooming,this._source.minzoom),s=Math.max(n+gd.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,s,e);for(const r of t){let t=this._tiles[r.key];if(t.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let n=t.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t&&(e[o.key]=o,n=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);return i||(e=new Yu(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))),e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Rt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._cache.reset()}tilesIn(t,e,i){const r=[],n=this.transform;if(!n)return r;for(const o in this._tiles){const s=this._tiles[o];if(i&&s.clearQueryDebugViz(),s.holdingForFade())continue;const a=t.containsTile(s,n,e);a&&r.push(a)}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(xd(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=G.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function yd(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 xd(t){return"raster"===t||"image"===t||"video"===t}gd.maxOverzooming=10,gd.maxUnderzooming=3;class vd{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const r=i||t.findDEMTileFor(e);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<e.canonical.z-o.canonical.z;return new vd(r,r.tileSize/Gs/s,[(e.canonical.x/s-o.canonical.x)*n.dim,(e.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(t,e){const i=e*this._scale+this._offset[1],r=Math.floor(t*this._scale+this._offset[0]),o=Math.floor(i);return new n(r,o)}getElevationAt(t,e,i,r){const n=t*this._scale+this._offset[0],o=e*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?ii(ii(l.get(s,a,r),l.get(s,a+1,r),o-a),ii(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(t,e,i){return this._dem.get(t,e,!!i)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Lu(1,t)*this._dem.stride}}class bd{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new en(Gs,16,0),this.featureIndexArray=new os,this.promoteId=e}insert(t,e,i,r,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const a=this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<Gs&&r[1]<Gs&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new jl.VectorTile(new zc(this.rawTileData)).layers,this.sourceLayerCoder=new Wu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},o=Tr(n.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>oa(s.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Td);let h=null;a.elevation&&c.length>0&&(h=vd.create(a.elevation,this.tileID));const u={};let d;for(let a=0;a<c.length;a++){const l=c[a];if(l===d)continue;d=l;const p=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(u,p,o,n.layers,n.availableImages,e,i,r,((e,i,r,n=0)=>(f||(f=js(e)),i.queryIntersectsFeature(s,e,r,f,this.z,t.transform,t.pixelPosMatrix,h,n))))}return u}loadMatchingFeature(t,e,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(r&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(r,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=$s(m,!0);if(!i.filter(new so(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new so(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e<p.length;e++){const i=p[e];if(r&&r.indexOf(i)<0)continue;const h=o[i];if(!h)continue;let u={};void 0!==_&&a&&(u=a.getState(h.sourceLayer||"_geojsonTileLayer",_));const f=x({},s[i]);f.paint=wd(f.paint,h.paint,m,u,n),f.layout=wd(f.layout,h.layout,m,u,n);const g=!l||l(m,h,u,d);if(!g)continue;const y=new Hu(m,this.z,this.x,this.y,_);y.layer=f;let v=t[i];void 0===v&&(v=t[i]=[]),v.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=Tr(n);for(const n of t)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}}function wd(t,e,i,r,n){return A(t,((t,o)=>{const s=e instanceof mo?e.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function Td(t,e){return e-t}an("FeatureIndex",bd,{omit:["rawTileData","sourceLayerCoder"]});class Ed{constructor(t){const e={},i=[];for(const r in t){const n=t[r],o=e[r]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,s={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(s),o[t]={rect:s,metrics:e.metrics}}}const{w:r,h:n}=Qc(i),o=new Ga({width:r||1,height:n||1});for(const i in t){const r=t[i];for(const t in r){const n=r[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=e[i][t].rect,a=n.metrics.localGlyph?2:1;Ga.copy(n.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},n.bitmap)}}this.image=o,this.positions=e}}an("GlyphAtlas",Ed);class Sd{constructor(t){this.tileID=new $u(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile}parse(t,e,i,r,n){this.status="parsing",this.data=t,this.collisionBoxArray=new Yo;const o=new Wu(Object.keys(t.layers).sort()),s=new bd(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Ou(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},h=e.familiesBySource[this.source];for(const e in h){const r=t.layers[e];if(!r)continue;let n=!1,l=!1;for(const t of h[e])"symbol"===t[0].type?n=!0:l=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&k(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const u=o.encode(e),d=[];for(let t=0;t<r.length;t++){const i=r.feature(t),n=s.getId(i,e);d.push({feature:i,id:n,index:t,sourceLayerIndex:u})}for(const t of h[e]){const e=t[0];void 0!==this.isSymbolTile&&"symbol"===e.type!==this.isSymbolTile||e.minzoom&&this.zoom<Math.floor(e.minzoom)||e.maxzoom&&this.zoom>=e.maxzoom||"none"!==e.visibility&&(Id(t,this.zoom,i),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:u,sourceID:this.source,enableTerrain:this.enableTerrain})).populate(d,c,this.tileID.canonical),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let u,d,p,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=A(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{u||(u=t,d=e,v.call(this))}),void 0,!1,m):d={};const g=Object.keys(c.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{u||(u=t,p=e,v.call(this))}),void 0,!1,m):p={};const x=Object.keys(c.patternDependencies);function v(){if(u)return n(u);if(d&&p&&f){const t=new Ed(d),e=new eh(p,f);for(const r in a){const n=a[r];n instanceof hu?(Id(n.layers,this.zoom,i),Wh(n,d,t.positions,p,e.iconPositions,this.showCollisionBoxes,this.tileID.canonical,this.tileZoom)):n.hasPattern&&(n instanceof cc||n instanceof kl||n instanceof Kl)&&(Id(n.layers,this.zoom,i),n.addFeatures(c,this.tileID.canonical,e.patternPositions))}this.status="done",n(null,{buckets:y(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?p:null,glyphPositions:this.returnDependencies?t.positions:null})}}x.length?r.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{u||(u=t,f=e,v.call(this))}),void 0,!1,m):f={},v.call(this)}}function Id(t,e,i){const r=new so(e);for(const e of t)e.recalculate(r,i)}class Ad{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){const[t,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const t of n.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((t=>t!==r)),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function Cd(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},(e=>{const r=St(t.request,((t,r,n,o)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new jl.VectorTile(new zc(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),e()}}),e)}t.ARRAY_TYPE=pa,t.AUTH_ERR_MSG=J,t.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},S(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=L()?t:s,this.scheduler=new Gu}send(t,e,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=V(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:hn(e,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||L()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(un(e.error)):i(null,un(e.data)))}else{const i=V(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?hn(e):null,data:hn(r,i)},i)}:t=>{},n=un(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,n,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],n.source)[t[1]](n,r)}else r(new Error("Could not find function "+e.type))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=qu,t.Color=he,t.ColorMode=pd,t.CullFaceMode=_d,t.DEMData=ld,t.DataConstantProperty=_o,t.DedupedRequest=Ad,t.DepthMode=hd,t.EXTENT=Gs,t.Elevation=class{getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const r=this._source();if(!r)return e;if(t.y<0||t.y>1)return e;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(t.x),a=t.x-s,l=new $u(n,s,n,Math.floor(a*o),Math.floor(t.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return e;const h=c.dem,u=1<<c.tileID.canonical.z,d=(a*u-c.tileID.canonical.x)*h.dim,p=(t.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(d),m=Math.floor(p);return(i?this.exaggeration():1)*ii(ii(h.get(f,m),h.get(f,m+1),p-m),ii(h.get(f+1,m),h.get(f+1,m+1),p-m),d-f)}getAtTileOffset(t,e,i){const r=1<<t.canonical.z;return this.getAtPointOrZero(new Fu(t.wrap+(t.canonical.x+e/Gs)/r,(t.canonical.y+i/Gs)/r))}getForTilePoints(t,e,i,r){const n=vd.create(this,t,r);return!!n&&(e.forEach((t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<<t.canonical.z-r.canonical.z;let o=t.canonical.x/n-r.canonical.x,s=t.canonical.y/n-r.canonical.y,a=0;for(let e=0;e<t.canonical.z-r.canonical.z&&!i.leaves[a];e++){o*=2,s*=2;const t=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+t,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},t.ErrorEvent=Bt,t.EvaluationParameters=so,t.Event=Rt,t.Evented=Ft,t.GlyphManager=Rh,t.ImagePosition=th,t.LineAtlas=Ou,t.LngLat=Mu,t.LngLatBounds=Au,t.LocalGlyphMode=Lh,t.MAX_SAFE_INTEGER=a,t.MercatorCoordinate=Fu,t.ONE_EM=vc,t.OverscaledTileID=$u,t.Properties=bo,t.RGBAImage=Za,t.RequestManager=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Y,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!Q(t))return t;const i=it(t);return i.path="/styles/v1"+i.path,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Q(t))return t;const i=it(t);return i.path="/fonts/v1"+i.path,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!Q(t))return t;const i=it(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const n=it(t);return Q(t)?(n.path=`/styles/v1${n.path}/sprite${e}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${e}${i}`,rt(n))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Q(t))return t;const r=it(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${j.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${q.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${q.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||q.ACCESS_TOKEN;return q.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push("sku="+this._skuToken),this._makeAPIURL(r,n)}canonicalizeTileURL(t,e){const i=it(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(`/${q.RASTER_URL_PREFIX}/`,""):r+="tiles/"+i.path.replace(`/${q.TILE_URL_VERSION}/`,"");let n=i.params;return e&&(n=n.filter((t=>!t.match(/^access_token=/)))),n.length&&(r+="?"+n.join("&")),r}canonicalizeTileset(t,e){const i=!!e&&Q(e),r=[];for(const e of t.tiles||[])tt(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=it(q.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!q.REQUIRE_ACCESS_TOKEN)return rt(t);if(e=e||q.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error("An API access token is required to use Mapbox GL. "+i);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+i)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push("access_token="+(e||"")),rt(t)}},t.ResourceType=bt,t.SegmentVector=Ns,t.SourceCache=gd,t.StencilMode=dd,t.StructArrayLayout1ui2=Wo,t.StructArrayLayout2f1f2i16=Uo,t.StructArrayLayout2i4=Co,t.StructArrayLayout2ui4=Xo,t.StructArrayLayout3f12=Ro,t.StructArrayLayout3ui6=No,t.StructArrayLayout4i8=Mo,t.Texture=Iu,t.Tile=Yu,t.Transitionable=co,t.Uniform1f=xs,t.Uniform1i=class extends ys{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends ys{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends ys{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=vs,t.UniformColor=bs,t.UniformMatrix3f=class extends ys{constructor(t,e){super(t,e),this.current=Ts}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},t.UniformMatrix4f=class extends ys{constructor(t,e){super(t,e),this.current=ws}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=ju,t.ValidationError=Ut,t.VectorTileWorkerSource=class extends Ft{constructor(t,e,i,r,n){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=n||Cd,this.loading={},this.loaded={},this.deduped=new Ad(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Sd(t);o.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),e(s);const c=a.rawData,h={};a.expires&&(h.expires=a.expires),a.cacheControl&&(h.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new jl.VectorTile(new zc(c));const u=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const o={};if(n){const t=Nu(r);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,x({rawTileData:c.slice(0)},i,h,o))}))};this.isSpriteLoaded?u():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(u,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):u()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(t,e){const i=this.loaded,r=t.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain;const s=(t,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),e(t,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}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()}},t.WritingMode=ih,t.ZoomHistory=dn,t.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t},t.addDynamicAttributes=su,t.altitudeFromMercatorZ=Bu,t.asyncAll=g,t.bezier=p,t.bindAll=S,t.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=_(r-1,-1,t.length-1),o=_(r+1,-1,t.length-1),s=t[r],a=t[o],l=t[n].sub(s).unit(),c=a.sub(s).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*e/Math.sin(h/2));i.push(s.add(u))}return i},t.cacheEntryPossiblyAdded=function(t){vt++,vt>gt&&(t.getActor().send("enforceCacheSizeLimit",_t),vt=0)},t.clamp=m,t.clearTileCache=function(t){const e=s.caches.delete(pt);t&&e.catch(t).then((()=>t()))},t.clipLine=Ah,t.clone=function(t){var e=new pa(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.clone$1=function(t){var e=new pa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$2=M,t.collisionCircleLayout=xc,t.config=q,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},t.create=ya,t.create$1=function(){var t=new pa(16);return pa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$2=fa,t.createExpression=cr,t.createFilter=Tr,t.createLayout=Io,t.createStyleLayer=function(t){return"custom"===t.type?new gu(t):new vu[t.type](t)},t.cross=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=n*l-o*a,t[1]=o*s-r*l,t[2]=r*a-n*s,t},t.degToRad=h,t.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},t.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.dot$1=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.ease=f,t.easeCubicInOut=d,t.emitValidationErrors=tn,t.endsWith=I,t.enforceCacheSizeLimit=function(t){yt(),ft&&ft.then((e=>{e.keys().then((i=>{for(let r=0;r<i.length-t;r++)e.delete(i[r])}))}))},t.evaluateSizeForFeature=Tc,t.evaluateSizeForZoom=Ec,t.evaluateVariableOffset=Xh,t.evented=io,t.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},t.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},t.exported=G,t.exported$1=j,t.extend=x,t.filterObject=C,t.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},t.fromQuat=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return t[0]=1-u-f,t[1]=h+g,t[2]=d-_,t[3]=0,t[4]=h-g,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+_,t[9]=p-m,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.fromRotation=function(t,e){var i=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.furthestTileCorner=function(t){const e=Math.round((t+45+360)%360/90)%4;return u[e]},t.getAABBPointSquareDist=function(t,e,i){let r=0;for(let n=0;n<2;++n){const o=i?i[n]:0;t[n]>o&&(r+=(t[n]-o)*(t[n]-o)),e[n]<o&&(r+=(o-e[n])*(o-e[n]))}return r},t.getAnchorAlignment=mh,t.getAnchorJustification=Hh,t.getBounds=function(t){let e=1/0,i=1/0,r=-1/0,o=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),o=Math.max(o,n.y);return{min:new n(e,i),max:new n(r,o)}},t.getImage=Pt,t.getJSON=function(t,e){return Et(x(t,{type:"json"}),e)},t.getMapSessionAPI=ut,t.getPerformanceMeasurement=Nu,t.getRTLTextPluginStatus=ro,t.getReferrer=Tt,t.getVideo=function(t,e){const i=s.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=s.document.createElement("source");Ct(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}return{cancel:()=>{}}},t.identity=ma,t.identity$1=Pa,t.invert=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,S=h*_-d*f,I=h*g-p*f,A=u*_-d*m,C=u*g-p*m,M=d*g-p*_,z=y*M-x*C+v*A+b*I-w*S+T*E;return z?(t[0]=(a*M-l*C+c*A)*(z=1/z),t[1]=(n*C-r*M-o*A)*z,t[2]=(m*T-_*w+g*b)*z,t[3]=(d*w-u*T-p*b)*z,t[4]=(l*I-s*M-c*S)*z,t[5]=(i*M-n*I+o*S)*z,t[6]=(_*v-f*T-g*x)*z,t[7]=(h*T-d*v+p*x)*z,t[8]=(s*C-a*I+c*E)*z,t[9]=(r*I-i*C-o*E)*z,t[10]=(f*w-m*v+g*y)*z,t[11]=(u*v-h*w-p*y)*z,t[12]=(a*S-s*A-l*E)*z,t[13]=(i*A-r*S+n*E)*z,t[14]=(m*x-f*b-_*y)*z,t[15]=(h*b-u*x+d*y)*z,t):null},t.isMapAuthenticated=function(t){return dt.has(t)},t.isMapboxURL=Q,t.latFromMercatorY=Ru,t.len=Ma,t.length=xa,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=Cd,t.makeRequest=Et,t.mercatorXfromLng=Pu,t.mercatorYfromLat=Du,t.mercatorZfromAltitude=Lu,t.mul=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.mul$1=ga,t.mul$2=Ca,t.multiply=_a,t.multiply$1=wa,t.nextPowerOfTwo=T,t.normalize=Ea,t.normalize$1=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=r*s,t[2]=n*s,t[3]=o*s,t},t.number=ii,t.ortho=function(t,e,i,r,n,o,s){var a=1/(e-i),l=1/(r-n),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(s+o)*c,t[15]=1,t},t.pbf=zc,t.perspective=function(t,e,i,r,n){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(o=1/(r-n)),t[14]=2*n*r*o):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i},t.plugin=oo,t.pointGeometry=n,t.polygonIntersectsBox=oa,t.polygonIntersectsPolygon=Hs,t.polygonizeBounds=function(t,e,i=0,r=!0){const o=new n(i,i),s=t.sub(o),a=e.add(o),l=[s,new n(a.x,s.y),a,new n(s.x,a.y)];return r&&l.push(s),l},t.posAttributes=Ku,t.postMapLoadEvent=ct,t.postTurnstileEvent=at,t.potpack=Qc,t.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.radToDeg=function(t){return t*c},t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.registerForPluginStateChange=function(t){return t({pluginStatus:Jn,pluginURL:Qn}),io.on("pluginStateChange",t),t},t.removeAuthState=function(t){dt.delete(t)},t.renderColorRamp=ja,t.rotateX=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+c*r,t[5]=s*n+h*r,t[6]=a*n+u*r,t[7]=l*n+d*r,t[8]=c*n-o*r,t[9]=h*n-s*r,t[10]=u*n-a*r,t[11]=d*n-l*r,t},t.rotateX$1=Da,t.rotateY=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n-c*r,t[1]=s*n-h*r,t[2]=a*n-u*r,t[3]=l*n-d*r,t[8]=o*r+c*n,t[9]=s*r+h*n,t[10]=a*r+u*n,t[11]=l*r+d*n,t},t.rotateZ=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+c*r,t[1]=s*n+h*r,t[2]=a*n+u*r,t[3]=l*n+d*r,t[4]=c*n-o*r,t[5]=h*n-s*r,t[6]=u*n-a*r,t[7]=d*n-l*r,t},t.rotateZ$1=function(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+n*a,t[1]=n*l-r*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},t.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},t.scale$1=function(t,e,i){var r=i[0],n=i[1],o=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.scale$2=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},t.scaleAndAdd=Ta,t.setCacheLimits=function(t,e){_t=t,gt=e},t.setRTLTextPlugin=function(t,e,i=!1){if(Jn===Wn||Jn===Hn||Jn===Kn)throw new Error("setRTLTextPlugin cannot be called multiple times.");Qn=G.resolveURL(t),Jn=Wn,Yn=e,eo(),i||no()},t.smoothstep=function(t,e,i){return(i=m((i-t)/(e-t),0,1))*i*(3-2*i)},t.spec=Ot,t.storeAuthState=function(t,e){e?dt.add(t):dt.delete(t)},t.sub=Aa,t.subtract=ba,t.symbolSize=Sc,t.transformMat3=function(t,e,i){var r=e[0],n=e[1],o=e[2];return t[0]=r*i[0]+n*i[3]+o*i[6],t[1]=r*i[1]+n*i[4]+o*i[7],t[2]=r*i[2]+n*i[5]+o*i[8],t},t.transformMat4=za,t.transformMat4$1=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,t[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,t},t.transformQuat=Sa,t.translate=function(t,e,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=d,t[10]=p,t[11]=f,t[12]=r*m+a*_+u*g+e[12],t[13]=n*m+l*_+d*g+e[13],t[14]=o*m+c*_+p*g+e[14],t[15]=s*m+h*_+f*g+e[15]),t},t.triggerPluginCompletionEvent=to,t.uniqueId=b,t.validateCustomStyleLayer=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateFog=Yr,t.validateLight=Kr,t.validateStyle=Hr,t.values=y,t.vectorTile=jl,t.version=e,t.warnOnce=k,t.window=s,t.wrap=_})),r(0,(function(t){function e(t){const i=typeof t;if("number"===i||"boolean"===i||"string"===i||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const r of t)i+=e(r)+",";return i+"]"}const r=Object.keys(t).sort();let n="{";for(let i=0;i<r.length;i++)n+=`${JSON.stringify(r[i])}:${e(t[r[i]])},`;return n+"}"}function i(i){let r="";for(const n of t.refProperties)r+="/"+e(i[n]);return r}class r{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.createStyleLayer(i);e._featureFilter=t.createFilter(e.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=function(t,e){const r={};for(let n=0;n<t.length;n++){const o=e&&e[t[n].id]||i(t[n]);e&&(e[t[n].id]=o);let s=r[o];s||(s=r[o]=[]),s.push(t[n])}const n=[];for(const t in r)n.push(r[t]);return n}(t.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(e)}}}const{ImageBitmap:n}=t.window;class o{loadTile(e,i){const{uid:r,encoding:o,rawImageData:s,padding:a,buildQuadTree:l}=e,c=n&&s instanceof n?this.getImageData(s,a):s;i(null,new t.DEMData(r,c,o,a<1,l))}getImageData(e,i){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-i,-i,e.width+2*i,e.height+2*i);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:r.width,height:r.height},r.data)}}var s=function t(e,i){var r,n=e&&e.type;if("FeatureCollection"===n)for(r=0;r<e.features.length;r++)t(e.features[r],i);else if("GeometryCollection"===n)for(r=0;r<e.geometries.length;r++)t(e.geometries[r],i);else if("Feature"===n)t(e.geometry,i);else if("Polygon"===n)a(e.coordinates,i);else if("MultiPolygon"===n)for(r=0;r<e.coordinates.length;r++)a(e.coordinates[r],i);return e};function a(t,e){if(0!==t.length){l(t[0],e);for(var i=1;i<t.length;i++)l(t[i],!e)}}function l(t,e){for(var i=0,r=0,n=t.length,o=n-1;r<n;o=r++)i+=(t[r][0]-t[o][0])*(t[o][1]+t[r][1]);i>=0!=!!e&&t.reverse()}const c=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class h{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return c.call(this,t,e,i)}}class u{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new h(this._features[t])}}var d=t.vectorTile.VectorTileFeature,p=f;function f(t,e){this.options=e||{},this.features=t,this.length=t.length}function m(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}f.prototype.feature=function(t){return new m(this.features[t],this.options.extent)},m.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i<e.length;i++){for(var r=e[i],n=[],o=0;o<r.length;o++)n.push(new t.pointGeometry(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},m.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<t.length;o++)for(var s=t[o],a=0;a<s.length;a++){var l=s[a];e=Math.min(e,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[e,r,i,n]},m.prototype.toGeoJSON=d.prototype.toGeoJSON;var _=y,g=p;function y(e){var i=new t.pbf;return function(t,e){for(var i in t.layers)e.writeMessage(3,x,t.layers[i])}(e,i),i.finish()}function x(t,e){var i;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<t.length;i++)r.feature=t.feature(i),e.writeMessage(2,v,r);var n=r.keys;for(i=0;i<n.length;i++)e.writeStringField(3,n[i]);var o=r.values;for(i=0;i<o.length;i++)e.writeMessage(4,S,o[i])}function v(t,e){var i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,b,t),e.writeVarintField(3,i.type),e.writeMessage(4,E,i)}function b(t,e){var i=t.feature,r=t.keys,n=t.values,o=t.keycache,s=t.valuecache;for(var a in i.properties){var l=o[a];void 0===l&&(r.push(a),o[a]=l=r.length-1),e.writeVarint(l);var c=i.properties[a],h=typeof c;"string"!==h&&"boolean"!==h&&"number"!==h&&(c=JSON.stringify(c));var u=h+":"+c,d=s[u];void 0===d&&(n.push(c),s[u]=d=n.length-1),e.writeVarint(d)}}function w(t,e){return(e<<3)+(7&t)}function T(t){return t<<1^t>>31}function E(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,s=i.length,a=0;a<s;a++){var l=i[a],c=1;1===r&&(c=l.length),e.writeVarint(w(1,c));for(var h=3===r?l.length-1:l.length,u=0;u<h;u++){1===u&&1!==r&&e.writeVarint(w(2,h-1));var d=l[u].x-n,p=l[u].y-o;e.writeVarint(T(d)),e.writeVarint(T(p)),n+=d,o+=p}3===r&&e.writeVarint(w(7,1))}}function S(t,e){var i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}function I(t,e,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;A(t,e,s,r,n,o%2),I(t,e,i,r,s-1,o+1),I(t,e,i,s+1,n,o+1)}function A(t,e,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);A(t,e,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o)}const s=e[2*i+o];let a=r,l=n;for(C(t,e,r,i),e[2*n+o]>s&&C(t,e,r,n);a<l;){for(C(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*r+o]===s?C(t,e,r,l):(l++,C(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function C(t,e,i,r){M(t,i,r),M(e,2*i,2*r),M(e,2*i+1,2*r+1)}function M(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function z(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}_.fromVectorTileJs=y,_.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new p(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return y({layers:i})},_.GeoJSONWrapper=g;const k=t=>t[0],P=t=>t[1];class D{constructor(t,e=k,i=P,r=64,n=Float64Array){this.nodeSize=r,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(t.length),a=this.coords=new n(2*t.length);for(let r=0;r<t.length;r++)s[r]=r,a[2*r]=e(t[r]),a[2*r+1]=i(t[r]);I(s,a,r,0,s.length-1,0)}range(t,e,i,r){return function(t,e,i,r,n,o,s){const a=[0,t.length-1,0],l=[];let c,h;for(;a.length;){const u=a.pop(),d=a.pop(),p=a.pop();if(d-p<=s){for(let s=p;s<=d;s++)c=e[2*s],h=e[2*s+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(t[s]);continue}const f=Math.floor((p+d)/2);c=e[2*f],h=e[2*f+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(t[f]);const m=(u+1)%2;(0===u?i<=c:r<=h)&&(a.push(p),a.push(f-1),a.push(m)),(0===u?n>=c:o>=h)&&(a.push(f+1),a.push(d),a.push(m))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,n,o){const s=[0,t.length-1,0],a=[],l=n*n;for(;s.length;){const c=s.pop(),h=s.pop(),u=s.pop();if(h-u<=o){for(let n=u;n<=h;n++)z(e[2*n],e[2*n+1],i,r)<=l&&a.push(t[n]);continue}const d=Math.floor((u+h)/2),p=e[2*d],f=e[2*d+1];z(p,f,i,r)<=l&&a.push(t[d]);const m=(c+1)%2;(0===c?i-n<=p:r-n<=f)&&(s.push(u),s.push(d-1),s.push(m)),(0===c?i+n>=p:r+n>=f)&&(s.push(d+1),s.push(h),s.push(m))}return a}(this.ids,this.coords,t,e,i,this.nodeSize)}}const L={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},R=Math.fround||(B=new Float32Array(1),t=>(B[0]=+t,B[0]));var B;class F{constructor(t){this.options=j(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:n}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;let s=[];for(let e=0;e<t.length;e++)t[e].geometry&&s.push(U(t[e],e));this.trees[r+1]=new D(s,$,X,n,Float32Array),e&&console.timeEnd(o);for(let t=r;t>=i;t--){const i=+Date.now();s=this._cluster(s,t),this.trees[t]=new D(s,$,X,n,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,s.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,o],e),s=this.getClusters([-180,r,n,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(G(i),Z(o),G(n),Z(r)),l=[];for(const t of a){const e=s.points[t];l.push(e.numPoints?V(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[e];if(!o)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o.x,o.y,s),l=[];for(const e of a){const i=n.points[e];i.parentId===t&&l.push(i.numPoints?V(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((e-a)/n,l,(e+1+a)/n,c),r.points,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.points,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.points,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(t,o.cluster_id,i,r,n):n<r?n++:t.push(e),t.length===i)break}return n}_addTileFeatures(t,e,i,r,n,o){for(const s of t){const t=e[s],a=t.numPoints;let l,c,h;if(a)l=N(t),c=t.x,h=t.y;else{const e=this.points[t.index];l=e.properties,c=G(e.geometry.coordinates[0]),h=Z(e.geometry.coordinates[1])}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;a?d=t.id:this.options.generateId?d=t.index:this.points[t.index].id&&(d=this.points[t.index].id),void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(+t,this.options.maxZoom+1))}_cluster(t,e){const i=[],{radius:r,extent:n,reduce:o,minPoints:s}=this.options,a=r/(n*Math.pow(2,e));for(let r=0;r<t.length;r++){const n=t[r];if(n.zoom<=e)continue;n.zoom=e;const l=this.trees[e+1],c=l.within(n.x,n.y,a),h=n.numPoints||1;let u=h;for(const t of c){const i=l.points[t];i.zoom>e&&(u+=i.numPoints||1)}if(u>=s){let t=n.x*h,s=n.y*h,a=o&&h>1?this._map(n,!0):null;const d=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,s+=r.y*c,r.parentId=d,o&&(a||(a=this._map(n,!0)),o(a,this._map(r)))}n.parentId=d,i.push(O(t/u,s/u,d,u,a))}else if(i.push(n),u>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?j({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?j({},r):r}}function O(t,e,i,r,n){return{x:R(t),y:R(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function U(t,e){const[i,r]=t.geometry.coordinates;return{x:R(G(i)),y:R(Z(r)),zoom:1/0,index:e,parentId:-1}}function V(t){return{type:"Feature",id:t.id,properties:N(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),q(t.y)]}};var e}function N(t){const e=t.numPoints,i=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return j(j({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function G(t){return t/360+.5}function Z(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function j(t,e){for(const i in e)t[i]=e[i];return t}function $(t){return t.x}function X(t){return t.y}function W(t,e,i,r){for(var n,o=r,s=i-e>>1,a=i-e,l=t[e],c=t[e+1],h=t[i],u=t[i+1],d=e+3;d<i;d+=3){var p=H(t[d],t[d+1],l,c,h,u);if(p>o)n=d,o=p;else if(p===o){var f=Math.abs(d-s);f<a&&(n=d,a=f)}}o>r&&(n-e>3&&W(t,e,n,r),t[n+2]=o,i-n>3&&W(t,n,i,r))}function H(t,e,i,r,n,o){var s=n-i,a=o-r;if(0!==s||0!==a){var l=((t-i)*s+(e-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return(s=t-i)*s+(a=e-r)*a}function K(t,e,i,r){var n={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)Y(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r<e.length;r++)Y(t,e[r]);else if("MultiPolygon"===i)for(r=0;r<e.length;r++)for(var n=0;n<e[r].length;n++)Y(t,e[r][n])}(n),n}function Y(t,e){for(var i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function J(t,e,i,r){if(e.geometry){var n=e.geometry.coordinates,o=e.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),a=[],l=e.id;if(i.promoteId?l=e.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)Q(n,a);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)Q(n[c],a);else if("LineString"===o)tt(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<n.length;c++)tt(n[c],a=[],s,!1),t.push(K(l,"LineString",a,e.properties));return}et(n,a,s,!1)}else if("Polygon"===o)et(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<e.geometry.geometries.length;c++)J(t,{id:l,geometry:e.geometry.geometries[c],properties:e.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var h=[];et(n[c],h,s,!0),a.push(h)}}t.push(K(l,o,a,e.properties))}}function Q(t,e){e.push(it(t[0])),e.push(rt(t[1])),e.push(0)}function tt(t,e,i,r){for(var n,o,s=0,a=0;a<t.length;a++){var l=it(t[a][0]),c=rt(t[a][1]);e.push(l),e.push(c),e.push(0),a>0&&(s+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var h=e.length-3;e[2]=1,W(e,0,h,i),e[h+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function et(t,e,i,r){for(var n=0;n<t.length;n++){var o=[];tt(t[n],o,i,r),e.push(o)}}function it(t){return t/360+.5}function rt(t){var e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function nt(t,e,i,r,n,o,s,a){if(r/=e,o>=(i/=e)&&s<r)return t;if(s<i||o>=r)return null;for(var l=[],c=0;c<t.length;c++){var h=t[c],u=h.geometry,d=h.type,p=0===n?h.minX:h.minY,f=0===n?h.maxX:h.maxY;if(p>=i&&f<r)l.push(h);else if(!(f<i||p>=r)){var m=[];if("Point"===d||"MultiPoint"===d)ot(u,m,i,r,n);else if("LineString"===d)st(u,m,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===d)lt(u,m,i,r,n,!1);else if("Polygon"===d)lt(u,m,i,r,n,!0);else if("MultiPolygon"===d)for(var _=0;_<u.length;_++){var g=[];lt(u[_],g,i,r,n,!0),g.length&&m.push(g)}if(m.length){if(a.lineMetrics&&"LineString"===d){for(_=0;_<m.length;_++)l.push(K(h.id,d,m[_],h.tags));continue}"LineString"!==d&&"MultiLineString"!==d||(1===m.length?(d="LineString",m=m[0]):d="MultiLineString"),"Point"!==d&&"MultiPoint"!==d||(d=3===m.length?"Point":"MultiPoint"),l.push(K(h.id,d,m,h.tags))}}}return l.length?l:null}function ot(t,e,i,r,n){for(var o=0;o<t.length;o+=3){var s=t[o+n];s>=i&&s<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function st(t,e,i,r,n,o,s){for(var a,l,c=at(t),h=0===n?ht:ut,u=t.start,d=0;d<t.length-3;d+=3){var p=t[d],f=t[d+1],m=t[d+2],_=t[d+3],g=t[d+4],y=0===n?p:f,x=0===n?_:g,v=!1;s&&(a=Math.sqrt(Math.pow(p-_,2)+Math.pow(f-g,2))),y<i?x>i&&(l=h(c,p,f,_,g,i),s&&(c.start=u+a*l)):y>r?x<r&&(l=h(c,p,f,_,g,r),s&&(c.start=u+a*l)):ct(c,p,f,m),x<i&&y>=i&&(l=h(c,p,f,_,g,i),v=!0),x>r&&y<=r&&(l=h(c,p,f,_,g,r),v=!0),!o&&v&&(s&&(c.end=u+a*l),e.push(c),c=at(t)),s&&(u+=a)}var b=t.length-3;p=t[b],f=t[b+1],m=t[b+2],(y=0===n?p:f)>=i&&y<=r&&ct(c,p,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&ct(c,c[0],c[1],c[2]),c.length&&e.push(c)}function at(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function lt(t,e,i,r,n,o){for(var s=0;s<t.length;s++)st(t[s],e,i,r,n,o,!1)}function ct(t,e,i,r){t.push(e),t.push(i),t.push(r)}function ht(t,e,i,r,n,o){var s=(o-e)/(r-e);return t.push(o),t.push(i+(n-i)*s),t.push(1),s}function ut(t,e,i,r,n,o){var s=(o-i)/(n-i);return t.push(e+(r-e)*s),t.push(o),t.push(1),s}function dt(t,e){for(var i=[],r=0;r<t.length;r++){var n,o=t[r],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=pt(o.geometry,e);else if("MultiLineString"===s||"Polygon"===s){n=[];for(var a=0;a<o.geometry.length;a++)n.push(pt(o.geometry[a],e))}else if("MultiPolygon"===s)for(n=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(pt(o.geometry[a][c],e));n.push(l)}i.push(K(o.id,s,n,o.tags))}return i}function pt(t,e){var i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(var r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function ft(t,e){if(t.transformed)return t;var i,r,n,o=1<<t.z,s=t.x,a=t.y;for(i=0;i<t.features.length;i++){var l=t.features[i],c=l.geometry,h=l.type;if(l.geometry=[],1===h)for(r=0;r<c.length;r+=2)l.geometry.push(mt(c[r],c[r+1],e,o,s,a));else for(r=0;r<c.length;r++){var u=[];for(n=0;n<c[r].length;n+=2)u.push(mt(c[r][n],c[r][n+1],e,o,s,a));l.geometry.push(u)}}return t.transformed=!0,t}function mt(t,e,i,r,n,o){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-o))]}function _t(t,e,i,r,n){for(var o=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<t.length;a++){s.numFeatures++,gt(s,t[a],o,n);var l=t[a].minX,c=t[a].minY,h=t[a].maxX,u=t[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),h>s.maxX&&(s.maxX=h),u>s.maxY&&(s.maxY=u)}return s}function gt(t,e,i,r){var n=e.geometry,o=e.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)yt(s,n,t,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)yt(s,n[a],t,i,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)yt(s,c[a],t,i,!0,0===a)}if(s.length){var h=e.tags||null;if("LineString"===o&&r.lineMetrics){for(var u in h={},e.tags)h[u]=e.tags[u];h.mapbox_clip_start=n.start/n.size,h.mapbox_clip_end=n.end/n.size}var d={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:h};null!==e.id&&(d.id=e.id),t.features.push(d)}}function yt(t,e,i,r,n,o){var s=r*r;if(r>0&&e.size<(n?s:r))i.numPoints+=e.length/3;else{for(var a=[],l=0;l<e.length;l+=3)(0===r||e[l+2]>s)&&(i.numSimplified++,a.push(e[l]),a.push(e[l+1])),i.numPoints++;n&&function(t,e){for(var i=0,r=0,n=t.length,o=n-2;r<n;o=r,r+=2)i+=(t[r]-t[o])*(t[r+1]+t[o+1]);if(i>0===e)for(r=0,n=t.length;r<n/2;r+=2){var s=t[r],a=t[r+1];t[r]=t[n-2-r],t[r+1]=t[n-1-r],t[n-2-r]=s,t[n-1-r]=a}}(a,o),t.push(a)}}function xt(t,e){var i=(e=this.options=function(t,e){for(var i in e)t[i]=e[i];return t}(Object.create(this.options),e)).debug;if(i&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)J(i,t.features[r],e,r);else J(i,"Feature"===t.type?t:{geometry:t},e);return i}(t,e);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(r=function(t,e){var i=e.buffer/e.extent,r=t,n=nt(t,1,-1-i,i,0,-1,2,e),o=nt(t,1,1-i,2+i,0,-1,2,e);return(n||o)&&(r=nt(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=dt(n,1).concat(r)),o&&(r=r.concat(dt(o,-1)))),r}(r,e)).length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function vt(t,e,i){return 32*((1<<t)*i+e)+t}function bt(t,e){const i=t.tileID.canonical;if(!this._geoJSONIndex)return e(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return e(null,null);const n=new u(r.features);let o=_(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),e(null,{vectorTile:n,rawData:o.buffer})}xt.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},xt.prototype.splitTile=function(t,e,i,r,n,o,s){for(var a=[t,e,i,r],l=this.options,c=l.debug;a.length;){r=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();var h=1<<e,u=vt(e,i,r),d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=_t(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(d.source=t,n){if(e===l.maxZoom||e===n)continue;var f=1<<n-e;if(i!==Math.floor(o/f)||r!==Math.floor(s/f))continue}else if(e===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==t.length){c>1&&console.time("clipping");var m,_,g,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,x=nt(t,h,i-b,i+T,0,d.minX,d.maxX,l),v=nt(t,h,i+w,i+E,0,d.minX,d.maxX,l),t=null,x&&(m=nt(x,h,r-b,r+T,1,d.minY,d.maxY,l),_=nt(x,h,r+w,r+E,1,d.minY,d.maxY,l),x=null),v&&(g=nt(v,h,r-b,r+T,1,d.minY,d.maxY,l),y=nt(v,h,r+w,r+E,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(m||[],e+1,2*i,2*r),a.push(_||[],e+1,2*i,2*r+1),a.push(g||[],e+1,2*i+1,2*r),a.push(y||[],e+1,2*i+1,2*r+1)}}},xt.prototype.getTile=function(t,e,i){var r=this.options,n=r.extent,o=r.debug;if(t<0||t>24)return null;var s=1<<t,a=vt(t,e=(e%s+s)%s,i);if(this.tiles[a])return ft(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,h=e,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[vt(c,h,u)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,h,u),o>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ft(this.tiles[a],n):null):null};class wt extends t.VectorTileWorkerSource{constructor(t,e,i,r,n){super(t,e,i,r,bt),n&&(this.loadGeoJSON=n)}loadData(e,i){const r=e&&e.request,n=r&&r.collectResourceTiming;this.loadGeoJSON(e,((o,a)=>{if(o||!a)return i(o);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{s(a,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=a.features.filter((t=>i.value.evaluate({zoom:0},t)));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new F(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[o,s]=i[e],a=t.createExpression(s),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);r[e]=a.value,n[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(o,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)o.accumulated=t[e],t[e]=n[e].evaluate(o,s)},e}(e)).load(a.features):function(t,e){return new xt(t,e)}(a,e.geojsonVtOptions)}catch(o){return i(o)}this.loaded={};const l={};if(n){const i=t.getPerformanceMeasurement(r);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class Tt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded=!1,this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:wt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded=i;for(const r in this.workerSources[e]){const n=this.workerSources[e][r];for(const e in n)n[e]instanceof t.VectorTileWorkerSource&&(n[e].isSpriteLoaded=i,n[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const r=this.workerSources[t][i];for(const t in r)r[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,r){const n=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;this.getWorkerSource(e,i.type,i.source).loadTile(n,r)}loadDEMTile(e,i,r){const n=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(n,r)}reloadTile(e,i,r){const n=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;this.getWorkerSource(e,i.type,i.source).reloadTile(n,r)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error("RTL Text Plugin failed to import scripts from "+e),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][i]||(this.workerSources[t][e][i]=new this.workerSourceTypes[e]({send:(e,i,r,n,o,s)=>{this.actor.send(e,i,r,t,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded)),this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new o),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Tt(self)),Tt})),r(0,(function(t){var e=i;function i(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===r[e=t&&t.failIfMajorPerformanceCaveat]&&(r[e]=function(t){var e,r=function(t){var e=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,e.getContext("webgl",r)||e.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{e=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!e||r.isContextLost())&&(r.shaderSource(e,"void main() {}"),r.compileShader(e),!0===r.getShaderParameter(e,r.COMPILE_STATUS))}(e)),r[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var r={};function n(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!n(t[i],e[i]))return!1;return!0}return t===e}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const o={create:function(e,i,r){const n=t.window.document.createElement(e);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n},createNS:function(e,i){return t.window.document.createElementNS(e,i)}},s=t.window.document&&t.window.document.documentElement.style,a=s&&void 0!==s.userSelect?"userSelect":"WebkitUserSelect";let l;o.disableDrag=function(){s&&a&&(l=s[a],s[a]="none")},o.enableDrag=function(){s&&a&&(s[a]=l)},o.setTransform=function(t,e){t.style.transform=e};let c=!1;try{const e=Object.defineProperty({},"passive",{get(){c=!0}});t.window.addEventListener("test",e,e),t.window.removeEventListener("test",e,e)}catch(t){c=!1}o.addEventListener=function(t,e,i,r={}){t.addEventListener(e,i,"passive"in r&&c?r:r.capture)},o.removeEventListener=function(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r&&c?r:r.capture)};const h=function(e){e.preventDefault(),e.stopPropagation(),t.window.removeEventListener("click",h,!0)};function u(e,i,r){const n=e.offsetWidth===i.width?1:e.offsetWidth/i.width;return new t.pointGeometry((r.clientX-i.left)*n,(r.clientY-i.top)*n)}o.suppressClick=function(){t.window.addEventListener("click",h,!0),t.window.setTimeout((()=>{t.window.removeEventListener("click",h,!0)}),0)},o.mousePos=function(t,e){const i=t.getBoundingClientRect();return u(t,i,e)},o.touchPos=function(t,e){const i=t.getBoundingClientRect(),r=[];for(let n=0;n<e.length;n++)r.push(u(t,i,e[n]));return r},o.mouseButton=function(e){return void 0!==t.window.InstallTrigger&&2===e.button&&e.ctrlKey&&t.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button},o.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};class d{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(e,i,r){const n=t.dot(i,this.dir);if(Math.abs(n)<1e-6)return!1;const o=t.dot(t.sub(t.create(),e,this.pos),i)/n,s=t.scaleAndAdd(t.create(),this.pos,this.dir,o);return t.copy(r,s),!0}}class p{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(e,i,r){const n=Math.pow(2,r),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const o=t.transformMat4([],r,e),s=1/o[3]/i*n;return t.mul(o,o,[s,s,1/o[3],s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.sub([],o[e[0]],o[e[1]]),r=t.sub([],o[e[2]],o[e[1]]),n=t.normalize([],t.cross([],i,r)),s=-t.dot(n,o[e[1]]);return n.concat(s)}));return new p(o,s)}}class f{constructor(e,i){this.min=e,this.max=i,this.center=t.scale([],t.add([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],r=t.clone(this.min),n=t.clone(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new f(r,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}intersects(e){const i=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let r=!0;for(let n=0;n<e.planes.length;n++){const o=e.planes[n];let s=0;for(let e=0;e<i.length;e++)s+=t.dot$1(o,i[e])>=0;if(0===s)return 0;s!==i.length&&(r=!1)}if(r)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[t]-this.min[t])return 0}return 1}}function m(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class _ extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(e,i){const r={};for(const i of e){this.images[i]||this.fire(new t.Event("styleimagemissing",{id:i}));const e=this.images[i];e?r[i]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.warnOnce(`Image "${i}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,r)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new t.ImagePosition(i,r);this.patterns[e]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.Texture(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.potpack(e),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,o=i.y+1,s=this.images[e].data,a=s.width,l=s.height;t.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),t.RGBAImage.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),t.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),t.RGBAImage.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),t.RGBAImage.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];m(t)&&this.updateImage(e,t)}}}const g=new t.Properties({anchor:new t.DataConstantProperty(t.spec.light.anchor),position:new class{constructor(){this.specification=t.spec.light.position}possiblyEvaluate(e,i){return function([e,i,r]){const n=t.degToRad(i+90),o=t.degToRad(r);return{x:e*Math.cos(n)*Math.sin(o),y:e*Math.sin(n)*Math.sin(o),z:e*Math.cos(o),azimuthal:i,polar:r}}(e.expression.evaluate(i))}interpolate(e,i,r){return{x:t.number(e.x,i.x,r),y:t.number(e.y,i.y,r),z:t.number(e.z,i.z,r),azimuthal:t.number(e.azimuthal,i.azimuthal,r),polar:t.number(e.polar,i.polar,r)}}},color:new t.DataConstantProperty(t.spec.light.color),intensity:new t.DataConstantProperty(t.spec.light.intensity)}),y="-transition";class x extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(g),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.validateLight,e,i))for(const i in e){const r=e[i];t.endsWith(i,y)?this._transitionable.setTransition(i.slice(0,-y.length),r):this._transitionable.setValue(i,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}const v=new t.Properties({source:new t.DataConstantProperty(t.spec.terrain.source),exaggeration:new t.DataConstantProperty(t.spec.terrain.exaggeration)}),b="-transition";class w extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(v),this.set(e),this._transitioning=this._transitionable.untransitioned()}get(){return this._transitionable.serialize()}set(e){for(const i in e){const r=e[i];t.endsWith(i,b)?this._transitionable.setTransition(i.slice(0,-b.length),r):this._transitionable.setValue(i,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}}function T(e,i,r,n){const o=t.smoothstep(45,65,r),[s,a]=E(e,n),l=t.length(i);let c=1-Math.min(1,Math.exp((l-s)/(a-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*o*e.alpha}function E(t,e){const i=.5/Math.tan(.5*e);return[t.range[0]+i,t.range[1]+i]}const S=new t.Properties({range:new t.DataConstantProperty(t.spec.fog.range),color:new t.DataConstantProperty(t.spec.fog.color),"horizon-blend":new t.DataConstantProperty(t.spec.fog["horizon-blend"])}),I="-transition";class A extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(S),this.set(e),this._transitioning=this._transitionable.untransitioned()}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e){if(!this._validate(t.validateFog,e))for(const i in e){const r=e[i];t.endsWith(i,I)?this._transitionable.setTransition(i.slice(0,-I.length),r):this._transitionable.setValue(i,r)}}getOpacity(e){const i=this.properties&&this.properties.get("color")||1;return t.smoothstep(45,65,e)*i.a}getOpacityAtLatLng(e,i){return function(e,i,r){const n=t.MercatorCoordinate.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0,s=[n.x,n.y,o];return t.transformMat4$1(s,s,r.mercatorFogMatrix),T(e,s,r.pitch,r._fov)}(this.state,e,i)}getFovAdjustedRange(t){return E(this.state,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}class C{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t.uniqueId();const r=this.workerPool.acquire(this.id);for(let t=0;t<r.length;t++){const e=new C.Actor(r[t],i,this.id);e.name="Worker "+t,this.actors.push(e)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,i,r){t.asyncAll(this.actors,((t,r)=>{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function M(e,i,r){return i*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}C.Actor=t.Actor;class z{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map((t=>r.pointCoordinate3D(t))),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(e,i){let r,n;if(e instanceof t.pointGeometry||"number"==typeof e[0]){const o=t.pointGeometry.convert(e);r=[t.pointGeometry.convert(e)],n=i.isPointAboveHorizon(o)}else{const o=t.pointGeometry.convert(e[0]),s=t.pointGeometry.convert(e[1]);r=[o,s],n=t.polygonizeBounds(o,s).every((t=>i.isPointAboveHorizon(t)))}return new z(r,i.getCameraPoint(),n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],n=t.polygonizeBounds(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<r.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),t.bufferConvexPolygon(n,e)}containsTile(e,i,r){const n=e.queryPadding+1,o=r?this._bufferedCameraMercator(n,i).map((t=>e.tileID.getTilePoint(t))):this._bufferedScreenMercator(n,i).map((t=>e.tileID.getTilePoint(t))),s=this.screenGeometryMercator.map((t=>e.tileID.getTileVec3(t))),a=s.map((e=>new t.pointGeometry(e[0],e[1]))),l=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),c=e.tileID.getTileVec3(l),h=s.map((e=>{const i=t.sub(e,e,c);return t.normalize(i,i),new d(c,i)})),u=M(e,1,i.zoom);if(t.polygonIntersectsBox(o,0,0,t.EXTENT,t.EXTENT))return{queryGeometry:this,tilespaceGeometry:a,tilespaceRays:h,bufferedTilespaceGeometry:o,bufferedTilespaceBounds:(p=t.getBounds(o),p.min.x=t.clamp(p.min.x,0,t.EXTENT),p.min.y=t.clamp(p.min.y,0,t.EXTENT),p.max.x=t.clamp(p.max.x,0,t.EXTENT),p.max.y=t.clamp(p.max.y,0,t.EXTENT),p),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:u};var p}_bufferedScreenMercator(t,e){const i=k(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{const r=this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=k(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{const r=this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._cameraRaycastCache[i]=r,r}}}function k(t){return 100*t|0}function P(e,i,r){const n=function(n,o){if(n)return r(n);if(o){const n=t.pick(t.extend(o,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(n.vectorLayers=o.vector_layers,n.vectorLayerIds=n.vectorLayers.map((t=>t.id))),n.tiles=i.canonicalizeTileset(n,e.url),r(null,n)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url),t.ResourceType.Source),n):t.exported.frame((()=>n(null,e)))}class D{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),n=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x<o&&e.y>=n&&e.y<s}}class L{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const R={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class B{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=e.attributes[n.name];void 0!==o&&t.vertexAttribPointer(o,n.components,t[R[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class F{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class O extends F{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class U extends F{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class V extends F{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class N extends F{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class G extends F{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Z extends F{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class q extends F{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class j extends F{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class $ extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class X extends F{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class W extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class H extends F{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class K extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Y extends F{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class J extends F{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Q extends F{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class tt extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class et extends F{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class it extends F{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class rt extends F{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class nt extends F{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ot extends F{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class st extends F{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class at extends F{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class lt extends F{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class ct extends F{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ht extends F{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ut extends F{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class dt extends F{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class pt extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class ft extends F{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class mt extends F{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class _t extends mt{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class gt extends mt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,this.attachment(),e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class yt extends gt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class xt{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const n=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new _t(t,n),r&&(this.depthAttachment=new gt(t,n))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class vt{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new O(this),this.clearDepth=new U(this),this.clearStencil=new V(this),this.colorMask=new N(this),this.depthMask=new G(this),this.stencilMask=new Z(this),this.stencilFunc=new q(this),this.stencilOp=new j(this),this.stencilTest=new $(this),this.depthRange=new X(this),this.depthTest=new W(this),this.depthFunc=new H(this),this.blend=new K(this),this.blendFunc=new Y(this),this.blendColor=new J(this),this.blendEquation=new Q(this),this.cullFace=new tt(this),this.cullFaceSide=new et(this),this.frontFace=new it(this),this.program=new rt(this),this.activeTexture=new nt(this),this.viewport=new ot(this),this.bindFramebuffer=new st(this),this.bindRenderbuffer=new at(this),this.bindTexture=new lt(this),this.bindVertexBuffer=new ct(this),this.bindElementBuffer=new ht(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ut(this),this.pixelStoreUnpack=new dt(this),this.pixelStoreUnpackPremultiplyAlpha=new pt(this),this.pixelStoreUnpackFlipY=new ft(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new L(this,t,e)}createVertexBuffer(t,e,i){return new B(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i){return new xt(this,t,e,i)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(e){n(e.blendFunction,t.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class bt extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},i),t.extend(this,t.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=P(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new D(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=t.exported.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(n,t.ResourceType.Tile),((r,n,o,s)=>{if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:o,expires:s});const r=this.map.painter.context,a=r.gl;e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0}):(e.texture=new t.Texture(r,n,a.RGBA,{useMipmap:!0}),e.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST),r.extTextureFilterAnisotropic&&a.texParameterf(a.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax)),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),i(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let wt;var Tt=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Et extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((r,n)=>{this._loaded=!0,r?this.fire(new t.ErrorEvent(r)):n&&(this.image=n,e&&(this.coordinates=e),i&&i(),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}setCoordinates(e){this.coordinates=e;const i=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),o=Math.max(o,t.y);const s=Math.max(n-i,o-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((i+n)/2*l),Math.floor((r+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const r=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new t.StructArrayLayout4i8,this._boundsArray.emplaceBack(r[0].x,r[0].y,0,0),this._boundsArray.emplaceBack(r[1].x,r[1].y,t.EXTENT,0),this._boundsArray.emplaceBack(r[3].x,r[3].y,0,t.EXTENT),this._boundsArray.emplaceBack(r[2].x,r[2].y,t.EXTENT,t.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Tt.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new t.Texture(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const St={vector:class extends t.Evented{constructor(e,i,r,n){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(i,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=P(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new D(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t();const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles();this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(n.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",n,o.bind(this));else if(e.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const i=t.loadVectorTile.call({deduped:this._deduped},n,((t,i)=>{t||!i?o.call(this,t):(n.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);e.request={cancel:i}}function o(r,n){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:bt,"raster-dem":class extends bt{constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,o,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap&&(null==wt&&(wt=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),wt),r=1-(o.width-t.prevPowerOfTwo(o.width))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?o:t.exported.getImageData(o,r),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded"}},geojson:class extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=t.extend({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.EXTENT,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new t.Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(e.request=this.map._requestManager.transformRequest(t.exported.resolveURL(i),t.ResourceType.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(i),this._pendingLoad=this.actor.send(this.type+".loadData",e,((e,i)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(e.resourceTiming=i.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,i){const r=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(r,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,n)=>(delete e.request,e.unloadVectorData(),e.aborted?i(null):t?i(t):(e.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Et{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError("sources."+this.id,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Tt.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Et,canvas:class extends Et{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+e,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+e,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError("sources."+e,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+e,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+e,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,Tt.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(i,this.canvas,r.RGBA,{premultiply:!0});for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}},It=function(e,i,r,n){const o=new St[i.type](e,i,r,n);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],o),o};function At(e,i){const r=t.identity([]);return t.scale$1(r,r,[.5*e.width,.5*-e.height,1]),t.translate(r,r,[1,-1,0]),t.multiply(r,r,e.calculateProjMatrix(i.toUnwrapped()))}function Ct(t,e,i,r,n,o,s,a=!1){const l=t.tilesIn(r,s,a);l.sort(zt);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,n,o,At(t.transform,r.tile.tileID),a)});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in t){const r=t[i],n=o[i]=o[i]||{},s=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function Mt(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const o=i[t],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,e))}return r}function zt(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function kt(){return null!=$n.workerClass?new $n.workerClass:new t.window.Worker($n.workerUrl)}const Pt="mapboxgl_preloaded_worker_pool";class Dt{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Dt.workerCount;)this.workers.push(new kt);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Pt]}numActive(){return Object.keys(this.active).length}}let Lt;function Rt(){return Lt||(Lt=new Dt),Lt}function Bt(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function Ft(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Bt(t[i],e[t[i].ref]));return t}Dt.workerCount=2;const Ot={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog"};function Ut(t,e,i){i.push({command:Ot.addSource,args:[t,e[t]]})}function Vt(t,e,i){e.push({command:Ot.removeSource,args:[t]}),i[t]=!0}function Nt(t,e,i,r){Vt(t,i,r),Ut(t,e,i)}function Gt(t,e,i){let r;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;return!0}function Zt(t,e,i,r,o,s){let a;for(a in e=e||{},t=t||{})t.hasOwnProperty(a)&&(n(t[a],e[a])||i.push({command:s,args:[r,a,e[a],o]}));for(a in e)e.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(n(t[a],e[a])||i.push({command:s,args:[r,a,e[a],o]}))}function qt(t){return t.id}function jt(t,e){return t[e.id]=e,t}class $t{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.clamp(e,0,1);let i=1,r=this._distances[i];const n=e*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,s=this._distances[o],a=r-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Xt{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(t,e,i,r,n,o){this.circleCells[n].push(o)}_query(t,e,i,r,n,o){if(i<0||t>this.width||r<0||e>this.height)return!n&&[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let t=0;t<this.boxKeys.length;t++)s.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];s.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}return o?s.filter(o):s}return this._forEachCell(t,e,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(t,e,i,r,n){const o=t-i,s=t+i,a=e-i,l=e+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(t,e,i,r,n){return this._query(t,e,i,r,!1,n)}hitTest(t,e,i,r,n){return this._query(t,e,i,r,!0,n)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(t<=n[c+2]&&e<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const t=n[h],e=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const t=this.bboxes;for(const e of h)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const t=this.circles;for(const e of u)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return o.push(!0),!0}}}_forEachCell(t,e,i,r,n,o,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,o){const s=r-t,a=n-e,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}function Wt(e,i,r,n,o){const s=t.create$1();return i?(t.scale$1(s,s,[1/o,1/o,1]),r||t.rotateZ(s,s,n.angle)):t.multiply(s,n.labelPlaneMatrix,e),s}function Ht(e,i,r,n,o){if(i){const i=t.clone$1(e);return t.scale$1(i,i,[o,o,1]),r||t.rotateZ(i,i,-n.angle),i}return n.glCoordMatrix}function Kt(e,i,r=0){const n=[e.x,e.y,r,1];r?t.transformMat4(n,n,i):ae(n,n,i);const o=n[3];return{point:new t.pointGeometry(n[0]/o,n[1]/o),signedDistanceFromCamera:o}}function Yt(t,e){return Math.min(.5+t/e*.5,1.5)}function Jt(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function Qt(e,i,r,n,o,s,a,l,c){const h=n?e.textSizeData:e.iconSizeData,u=t.evaluateSizeForZoom(h,r.transform.zoom),d=[256/r.width*2+1,256/r.height*2+1],p=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;p.clear();const f=e.lineVertexArray,m=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,_=r.transform.width/r.transform.height;let g=!1;for(let n=0;n<m.length;n++){const y=m.get(n);if(y.hidden||y.writingMode===t.WritingMode.vertical&&!g){se(y.numGlyphs,p);continue}g=!1;const x=c?c({x:y.anchorX,y:y.anchorY}):0,v=[y.anchorX,y.anchorY,x,1];if(t.transformMat4(v,v,i),!Jt(v,d)){se(y.numGlyphs,p);continue}const b=Yt(r.transform.cameraToCenterDistance,v[3]),w=t.evaluateSizeForFeature(h,u,y),T=a?w/b:w*b,E=new t.pointGeometry(y.anchorX,y.anchorY),S=Kt(E,o,x);if(S.signedDistanceFromCamera<=0){se(y.numGlyphs,p);continue}const I=S.point;let A={};const C=a?null:c,M=ie(y,T,!1,l,i,o,s,e.glyphOffsetArray,f,p,I,E,A,_,C);g=M.useVertical,C&&M.needsFlipping&&(A={}),(M.notEnoughRoom||g||M.needsFlipping&&ie(y,T,!0,l,i,o,s,e.glyphOffsetArray,f,p,I,E,A,_,C).notEnoughRoom)&&se(y.numGlyphs,p)}n?e.text.dynamicLayoutVertexBuffer.updateData(p):e.icon.dynamicLayoutVertexBuffer.updateData(p)}function te(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=a.glyphStartIndex+a.numGlyphs,f=a.lineStartIndex,m=a.lineStartIndex+a.lineLength,_=e.getoffsetX(a.glyphStartIndex),g=e.getoffsetX(p-1),y=ne(t*_,i,r,n,o,s,a.segment,f,m,l,c,h,u,d,!0);if(!y)return null;const x=ne(t*g,i,r,n,o,s,a.segment,f,m,l,c,h,u,d,!0);return x?{first:y,last:x}:null}function ee(e,i,r,n){return e===t.WritingMode.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(e===t.WritingMode.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function ie(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=i/24,g=e.lineOffsetX*_,y=e.lineOffsetY*_;let x;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,i=e.lineStartIndex,o=e.lineStartIndex+e.lineLength,h=te(_,l,g,y,r,u,d,e,c,s,p,m);if(!h)return{notEnoughRoom:!0};const v=Kt(h.first.point,a).point,b=Kt(h.last.point,a).point;if(n&&!r){const t=ee(e.writingMode,v,b,f);if(t)return t}x=[h.first];for(let n=e.glyphStartIndex+1;n<t-1;n++)x.push(ne(_*l.getoffsetX(n),g,y,r,u,d,e.segment,i,o,c,s,p,m));x.push(h.last)}else{if(n&&!r){const i=Kt(d,o).point,r=e.lineStartIndex+e.segment+1,n=new t.pointGeometry(c.getx(r),c.gety(r)),s=Kt(n,o),a=s.signedDistanceFromCamera>0?s.point:re(d,n,i,1,o),l=ee(e.writingMode,i,a,f);if(l)return l}const i=ne(_*l.getoffsetX(e.glyphStartIndex),g,y,r,u,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,s,p,m);if(!i)return{notEnoughRoom:!0};x=[i]}for(const e of x)t.addDynamicAttributes(h,e.point,e.angle);return{}}function re(t,e,i,r,n,o){const s=t.add(t.sub(e)._unit()),a=Kt(s,n,o?o(s):0).point,l=i.sub(a);return i.add(l._mult(r/l.mag()))}function ne(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=n?e-i:e+i;let g=_>0?1:-1,y=0;n&&(g*=-1,y=Math.PI),g<0&&(y+=Math.PI);let x=g>0?l+a:l+a+1,v=o,b=o,w=0,T=0;const E=Math.abs(_),S=[],I=[];let A=s;const C=()=>{const e=x-g;return 0===w?s:new t.pointGeometry(h.getx(e),h.gety(e))},M=()=>re(C(),A,b,E-w+1,u,p);for(;w+T<=E;){if(x+=g,x<l||x>=c)return null;if(b=v,S.push(v),f&&I.push(A||C()),v=d[x],void 0===v){A=new t.pointGeometry(h.getx(x),h.gety(x));const e=Kt(A,u,p?p(A):0);v=e.signedDistanceFromCamera>0?d[x]=e.point:M()}else A=null;w+=T,T=b.dist(v)}m&&p&&(A=A||new t.pointGeometry(h.getx(x),h.gety(x)),d[x]=v=void 0===d[x]?v:M(),T=b.dist(v));const z=(E-w)/T,k=v.sub(b),P=k.mult(z)._add(b);r&&P._add(k._unit()._perp()._mult(r*g));const D=y+Math.atan2(v.y-b.y,v.x-b.x);return S.push(P),f&&(A=A||new t.pointGeometry(h.getx(x),h.gety(x)),I.push(function(e,i,r){const n=1-r;return new t.pointGeometry(e.x*n+i.x*r,e.y*n+i.y*r)}(I.length>0?I[I.length-1]:A,A,z))),{point:P,angle:D,path:S,tilePath:I}}const oe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function se(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(oe,3*t)}}function ae(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const le=100;class ce{constructor(t,e,i=new Xt(t.width+200,t.height+200,25),r=new Xt(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+le,this.screenBottomBoundary=t.height+le,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,i,r,n,o,s){const a=this.projectAndGetPerspectiveRatio(o,e.anchorPointX,e.anchorPointY,e.elevation,e.tileID),l=n*a.perspectiveRatio,c=(e.x1*t+i.x-e.padding)*l+a.point.x,h=(e.y1*t+i.y-e.padding)*l+a.point.y,u=(e.x2*t+i.x+e.padding)*l+a.point.x,d=(e.y2*t+i.y+e.padding)*l+a.point.y,p=a.perspectiveRatio<=.55||a.aboveHorizon;return!this.isInsideGrid(c,h,u,d)||!r&&this.grid.hitTest(c,h,u,d,s)||p?{box:[],offscreen:!1}:{box:[c,h,u,d],offscreen:this.isOffscreen(c,h,u,d)}}placeCollisionCircles(e,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],_=this.transform.elevation,g=_?t=>_.getAtTileOffset(f,t.x,t.y):t=>0,y=new t.pointGeometry(i.anchorX,i.anchorY),x=g(y),v=this.projectAndGetPerspectiveRatio(s,y.x,y.y,x,f),{perspectiveRatio:b}=v,w=(h?o/b:o*b)/t.ONE_EM,T=Kt(y,a,x).point,E=v.signedDistanceFromCamera>0?te(w,n,i.lineOffsetX*w,i.lineOffsetY*w,!1,T,y,i,r,a,{},_&&!h?g:null,h&&!!_):null;let S=!1,I=!1,A=!0;if(E&&!v.aboveHorizon){const i=.5*d*b+p,r=new t.pointGeometry(-100,-100),n=new t.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new $t,s=E.first,a=E.last;let h=[];for(let t=s.path.length-1;t>=1;t--)h.push(s.path[t]);for(let t=1;t<a.path.length;t++)h.push(a.path[t]);const f=2.5*i;if(l){const t=h.map(_?(t,e)=>{const i=g(e<s.path.length-1?s.tilePath[s.path.length-1-e]:a.tilePath[e-s.path.length+2]);return Kt(t,l,i)}:t=>Kt(t,l));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let y=[];if(h.length>0){const e=h[0].clone(),i=h[0].clone();for(let t=1;t<h.length;t++)e.x=Math.min(e.x,h[t].x),e.y=Math.min(e.y,h[t].y),i.x=Math.max(i.x,h[t].x),i.y=Math.max(i.y,h[t].y);y=e.x>=r.x&&i.x<=n.x&&e.y>=r.y&&i.y<=n.y?[h]:i.x<r.x||e.x>n.x||i.y<r.y||e.y>n.y?[]:t.clipLine([h],r.x,r.y,n.x,n.y)}for(const t of y){o.reset(t,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t<r;t++){const n=t/Math.max(r-1,1),s=o.lerp(n),a=s.x+le,l=s.y+le;m.push(a,l,i,0);const h=a-i,d=l-i,p=a+i,f=l+i;if(A=A&&this.isOffscreen(h,d,p,f),I=I||this.isInsideGrid(h,d,p,f),!e&&this.grid.hitTestCircle(a,l,i,u)&&(S=!0,!c))return{circles:[],offscreen:!1,collisionDetected:S}}}}return{circles:!c&&S||!I?[]:m,offscreen:A,collisionDetected:S}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of e){const e=new t.pointGeometry(a.x+le,a.y+le);r=Math.min(r,e.x),n=Math.min(n,e.y),o=Math.max(o,e.x),s=Math.max(s,e.y),i.push(e)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const e of a){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new t.pointGeometry(e.x1,e.y1),new t.pointGeometry(e.x2,e.y1),new t.pointGeometry(e.x2,e.y2),new t.pointGeometry(e.x1,e.y2)];t.polygonIntersectsPolygon(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,e,i,r,n){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n){const o=e?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let e=0;e<t.length;e+=4)o.insertCircle(s,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(e,i,r,n,o){const s=[i,r,n||0,1];let a=!1;if(n||this.transform.pitch>0){t.transformMat4(s,s,e);let l=!1;this.fogState&&o&&(l=function(e,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return t.transformMat4$1(l,l,a),T(e,l,s.pitch,s._fov)}(this.fogState,i,r,n||0,o.toUnwrapped(),this.transform)>.9),a=s[2]>s[3]||l}else ae(s,s,e);return{point:new t.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+le,(-s[1]/s[3]+1)/2*this.transform.height+le),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/s[3]*.5,1.5),signedDistanceFromCamera:s[3],aboveHorizon:a}}isOffscreen(t,e,i,r){return i<le||t>=this.screenRightBoundary||r<le||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const e=t.identity([]);return t.translate(e,e,[-100,-100,0]),e}}class he{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class ue{constructor(t,e,i,r,n){this.text=new he(t?t.text:null,e,i,n),this.icon=new he(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class de{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class pe{constructor(){this.invProjMatrix=t.create$1(),this.viewportMatrix=t.create$1(),this.circles=[]}}class fe{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class me{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function _e(e,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*i,c=-(a-.5)*r,h=t.evaluateVariableOffset(e,n);return new t.pointGeometry(l+h[0]*o,c+h[1]*o)}function ge(e,i,r,n,o){const s=new t.pointGeometry(e,i);return r&&s._rotate(n?o:-o),s}class ye{constructor(t,e,i,r,n){this.transform=t.clone(),this.collisionIndex=new ce(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new me(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=r.collisionBoxArray,l=o.layers[0].layout,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/t.EXTENT,u=this.transform.calculateProjMatrix(r.tileID.toUnwrapped()),d="map"===l.get("text-pitch-alignment"),p="map"===l.get("text-rotation-alignment"),f=M(r,1,this.transform.zoom),m=Wt(u,d,p,this.transform,f);let _=null;if(d){const e=Ht(u,d,p,this.transform,f);_=t.multiply([],this.transform.labelPlaneMatrix,e)}this.retainedQueryData[o.bucketInstanceId]=new fe(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const g={bucket:o,layout:l,posMatrix:u,textLabelPlaneMatrix:m,labelToScreenMatrix:_,scale:c,textPixelRatio:h,holdingForFade:r.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:g})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:g})}attemptAnchorPlacement(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=[u.textOffset0,u.textOffset1],x=_e(t,i,r,y,n),v=this.collisionIndex.placeCollisionBox(n,e,ge(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(p.getSymbolInstanceIconSize(g,this.transform.zoom,d),m,ge(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:n,prevAnchor:e},this.markUsedJustification(p,t,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[u.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(e,i,r){const{bucket:n,layout:o,posMatrix:s,textLabelPlaneMatrix:a,labelToScreenMatrix:l,textPixelRatio:c,holdingForFade:h,collisionBoxArray:u,partiallyEvaluatedTextSize:d,partiallyEvaluatedIconSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),_=o.get("icon-optional"),g=o.get("text-allow-overlap"),y=o.get("icon-allow-overlap"),x="map"===o.get("text-rotation-alignment"),v="map"===o.get("text-pitch-alignment"),b="none"!==o.get("icon-text-fit"),w="viewport-y"===o.get("symbol-z-order"),T=g&&(y||!n.hasIconData()||_),E=y&&(g||!n.hasTextData()||m);!n.collisionArrays&&u&&n.deserializeCollisionBoxes(u),r&&n.updateCollisionDebugBuffers(this.transform.zoom,u);const S=(e,u,w)=>{if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new de(!1,!1,!1));let S=!1,I=!1,A=!0,C=null,M={box:null,offscreen:null},z={box:null,offscreen:null},k=null,P=null,D=null,L=0,R=0,B=0;w.textFeatureIndex?L=w.textFeatureIndex:e.useRuntimeCollisionCircles&&(L=e.featureIndex),w.verticalTextFeatureIndex&&(R=w.verticalTextFeatureIndex);const F=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,t.anchorPointX,t.anchorPointY):0)},O=w.textBox;if(O){F(O);const i=i=>{let r=t.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},r=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&w.verticalTextBox){for(const e of n.writingModes)if(e===t.WritingMode.vertical?(M=r(),z=M):M=i(),M&&M.box&&M.box.length)break}else M=i()};if(o.get("text-variable-anchor")){let a=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];a.indexOf(t.anchor)>0&&(a=a.filter((e=>e!==t.anchor)),a.unshift(t.anchor))}const l=(t,i,r)=>{const o=n.getSymbolInstanceTextSize(d,e,this.transform.zoom,u),l=(t.x2-t.x1)*o+2*t.padding,h=(t.y2-t.y1)*o+2*t.padding,m=b&&!y?i:null;m&&F(m);let _={box:[],offscreen:!1};const w=g?2*a.length:a.length;for(let i=0;i<w;++i){const g=this.attemptAnchorPlacement(a[i%a.length],t,l,h,o,x,v,c,s,f,i>=a.length,e,u,n,r,m,d,p);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){S=!0,C=g.shift;break}}return _};r((()=>l(O,w.iconBox,t.WritingMode.horizontal)),(()=>{const i=w.verticalTextBox;return i&&F(i),n.allowVerticalPlacement&&!(M&&M.box&&M.box.length)&&e.numVerticalGlyphVertices>0&&i?l(i,w.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),M&&(S=M.box,A=M.offscreen);const h=i(M&&M.box);if(!S&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,h))}}else{const o=(i,r)=>{const o=n.getSymbolInstanceTextSize(d,e,this.transform.zoom,u),a=this.collisionIndex.placeCollisionBox(o,i,new t.pointGeometry(0,0),g,c,s,f.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(n,r,e),this.placedOrientations[e.crossTileID]=r),a};r((()=>o(O,t.WritingMode.horizontal)),(()=>{const i=w.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?(F(i),o(i,t.WritingMode.vertical)):{box:null,offscreen:null}})),i(M&&M.box&&M.box.length)}}if(k=M,S=k&&k.box&&k.box.length>0,A=k&&k.offscreen,e.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),c=t.evaluateSizeForFeature(n.textSizeData,d,i),h=o.get("text-padding");P=this.collisionIndex.placeCollisionCircles(g,i,n.lineVertexArray,n.glyphOffsetArray,c,s,a,l,r,v,f.predicate,e.collisionCircleDiameter,h,this.retainedQueryData[n.bucketInstanceId].tileID),S=g||P.circles.length>0&&!P.collisionDetected,A=A&&P.offscreen}if(w.iconFeatureIndex&&(B=w.iconFeatureIndex),w.iconBox){const e=e=>{F(e);const i=b&&C?ge(C.x,C.y,x,v,this.transform.angle):new t.pointGeometry(0,0),r=n.getSymbolInstanceIconSize(p,this.transform.zoom,u);return this.collisionIndex.placeCollisionBox(r,e,i,y,c,s,f.predicate)};z&&z.box&&z.box.length&&w.verticalIconBox?(D=e(w.verticalIconBox),I=D.box.length>0):(D=e(w.iconBox),I=D.box.length>0),A=A&&D.offscreen}const U=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,V=_||0===e.numIconVertices;if(U||V?V?U||(I=I&&S):S=I&&S:I=S=I&&S,S&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,o.get("text-ignore-placement"),n.bucketInstanceId,z&&z.box&&R?R:L,f.ID),I&&D&&this.collisionIndex.insertCollisionBox(D.box,o.get("icon-ignore-placement"),n.bucketInstanceId,B,f.ID),P&&(S&&this.collisionIndex.insertCollisionCircles(P.circles,o.get("text-ignore-placement"),n.bucketInstanceId,L,f.ID),r)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new pe);for(let t=0;t<P.circles.length;t+=4)e.circles.push(P.circles[t+0]),e.circles.push(P.circles[t+1]),e.circles.push(P.circles[t+2]),e.circles.push(P.collisionDetected?1:0)}this.placements[e.crossTileID]=new de(S||T,I||E,A||n.justReloaded),i[e.crossTileID]=!0};if(w){const t=n.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];S(n.symbolInstances.get(i),i,n.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)S(n.symbolInstances.get(t),t,n.collisionArrays[t]);if(r&&n.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[n.bucketInstanceId];t.invert(e.invProjMatrix,s),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}n.justReloaded=!1}markUsedJustification(e,i,r,n){let o;o=n===t.WritingMode.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.getAnchorJustification(i)];const s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const t of s)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,o=i===t.WritingMode.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},o=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=n[t];o?(this.opacities[t]=new ue(o,r,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new ue(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new ue(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,o=new ue(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),a=n.get("icon-allow-overlap"),l=n.get("text-variable-anchor"),c="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),u="none"!==n.get("icon-text-fit"),d=new ue(null,0,s&&(a||!e.hasIconData()||n.get("icon-optional")),a&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const p=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:a,crossTileID:f}=n;let m=this.opacities[f];i[f]?m=o:m||(m=d,this.opacities[f]=m),i[f]=!0;const _=n.numIconVertices>0,g=this.placedOrientations[n.crossTileID],y=g===t.WritingMode.vertical,x=g===t.WritingMode.horizontal||g===t.WritingMode.horizontalOnly;if(s>0||a>0){const t=Ae(m.text);p(e.text,s,y?Ce:t),p(e.text,a,x?Ce:t);const i=m.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,g);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(e,"left",n,o),this.markUsedOrientation(e,o,n))}if(_){const t=Ae(m.icon),i=!(u&&n.verticalPlacedIconSymbolIndex&&y);n.placedIconSymbolIndex>=0&&(p(e.icon,n.numIconVertices,i?t:Ce),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=m.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(p(e.icon,n.numVerticalIconVertices,i?Ce:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=m.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[r];if(i){let r=new t.pointGeometry(0,0);if(i.textBox||i.verticalTextBox){let t=!0;if(l){const e=this.variableOffsets[f];e?(r=_e(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):t=!1}i.textBox&&xe(e.textCollisionBox.collisionVertexArray,m.text.placed,!t||y,r.x,r.y),i.verticalTextBox&&xe(e.textCollisionBox.collisionVertexArray,m.text.placed,!t||x,r.x,r.y)}const n=Boolean(!x&&i.verticalIconBox);i.iconBox&&xe(e.iconCollisionBox.collisionVertexArray,m.icon.placed,n,u?r.x:0,u?r.y:0),i.verticalIconBox&&xe(e.iconCollisionBox.collisionVertexArray,m.icon.placed,!n,u?r.x:0,u?r.y:0)}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function xe(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const ve=Math.pow(2,25),be=Math.pow(2,24),we=Math.pow(2,17),Te=Math.pow(2,16),Ee=Math.pow(2,9),Se=Math.pow(2,8),Ie=Math.pow(2,1);function Ae(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*ve+e*be+i*we+e*Te+i*Ee+e*Se+i*Ie+e}const Ce=0;class Me{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(o,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<o.length;)if(e.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class ze{constructor(t,e,i,r,n,o,s,a){this.placement=new ye(t,n,o,s,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,i,r){const n=t.exported.now(),o=()=>{const e=t.exported.now()-n;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=n)&&(!t.maxzoom||t.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Me(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const ke=512/t.EXTENT/2;class Pe{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(e,i){const r=ke/Math.pow(2,i.canonical.z-this.tileID.canonical.z);return{x:Math.floor((i.canonical.x*t.EXTENT+e.anchorX)*r),y:Math.floor((i.canonical.y*t.EXTENT+e.anchorY)*r)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const o=t.get(n);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,e);for(const t of s)if(Math.abs(t.coord.x-a.x)<=r&&Math.abs(t.coord.y-a.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,o.crossTileID=t.crossTileID;break}}}}class De{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Le{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,r)}else{const o=n[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Pe(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class Re{constructor(){this.layerIndexes={},this.crossTileIDs=new De,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Le);let n=!1;const o={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(n=!0),o[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(n=!0),n}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Be=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Fe=t.pick(Ot,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog"]),Oe=t.pick(Ot,["setCenter","setZoom","setBearing","setPitch"]),Ue=function(){const e={},i=t.spec.$version;for(const r in t.spec.$root){const n=t.spec.$root[r];if(n.required){let t=null;t="version"===r?i:"array"===n.type?[]:{},null!=t&&(e[r]=t)}}return e}(),Ve={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ne extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new C(Rt(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,i.localFontFamily?t.LocalGlyphMode.all:i.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new t.LineAtlas(256,512),this.crossTileSymbolIndex=new Re,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=Ne.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r._sourceCaches){const e=r._sourceCaches[t],i=e.getSource().type;"vector"!==i&&"geojson"!==i||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,i.accessToken);const n=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(n,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Ue,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(e,i){if(i&&Be(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=e;for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const r=Ft(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let e of r)e=t.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(this.stylesheet.light),this.stylesheet.terrain&&this._createTerrain(this.stylesheet.terrain),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}_loadSprite(e){this._spriteRequest=function(e,i,r){let n,o,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,n=e,h())})),c=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,o=e,h())}));function h(){if(s)r(s);else if(n&&o){const e=t.exported.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p}=n[r],f=new t.RGBAImage({width:o,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[r]={data:f,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.getSource(e.source);if(!i)return;const r=e.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Ve[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const n=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,n)}}for(const e in r){const i=this._sourceCaches[e];r[e]!==i.used&&i.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(e){if(this._checkLoaded(),Be(this,t.validateStyle(e)))return!1;(e=t.clone$2(e)).layers=Ft(e.layers);const i=function(t,e){if(!t)return[{command:Ot.setStyle,args:[e]}];let i=[];try{if(!n(t.version,e.version))return[{command:Ot.setStyle,args:[e]}];n(t.center,e.center)||i.push({command:Ot.setCenter,args:[e.center]}),n(t.zoom,e.zoom)||i.push({command:Ot.setZoom,args:[e.zoom]}),n(t.bearing,e.bearing)||i.push({command:Ot.setBearing,args:[e.bearing]}),n(t.pitch,e.pitch)||i.push({command:Ot.setPitch,args:[e.pitch]}),n(t.sprite,e.sprite)||i.push({command:Ot.setSprite,args:[e.sprite]}),n(t.glyphs,e.glyphs)||i.push({command:Ot.setGlyphs,args:[e.glyphs]}),n(t.transition,e.transition)||i.push({command:Ot.setTransition,args:[e.transition]}),n(t.light,e.light)||i.push({command:Ot.setLight,args:[e.light]}),n(t.fog,e.fog)||i.push({command:Ot.setFog,args:[e.fog]});const r={},o=[];!function(t,e,i,r){let o;for(o in e=e||{},t=t||{})t.hasOwnProperty(o)&&(e.hasOwnProperty(o)||Vt(o,i,r));for(o in e)e.hasOwnProperty(o)&&(t.hasOwnProperty(o)?n(t[o],e[o])||("geojson"===t[o].type&&"geojson"===e[o].type&&Gt(t,e,o)?i.push({command:Ot.setGeoJSONSourceData,args:[o,e[o].data]}):Nt(o,e,i,r)):Ut(o,e,i))}(t.sources,e.sources,o,r);const s=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:Ot.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&r[a.source]&&(i.push({command:Ot.setTerrain,args:[void 0]}),a=void 0),i=i.concat(o),n(a,e.terrain)||i.push({command:Ot.setTerrain,args:[e.terrain]}),function(t,e,i){e=e||[];const r=(t=t||[]).map(qt),o=e.map(qt),s=t.reduce(jt,{}),a=e.reduce(jt,{}),l=r.slice(),c=Object.create(null);let h,u,d,p,f,m,_;for(h=0,u=0;h<r.length;h++)d=r[h],a.hasOwnProperty(d)?u++:(i.push({command:Ot.removeLayer,args:[d]}),l.splice(l.indexOf(d,u),1));for(h=0,u=0;h<o.length;h++)d=o[o.length-1-h],l[l.length-1-h]!==d&&(s.hasOwnProperty(d)?(i.push({command:Ot.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-u),1)):u++,m=l[l.length-h],i.push({command:Ot.addLayer,args:[a[d],m]}),l.splice(l.length-h,0,d),c[d]=!0);for(h=0;h<o.length;h++)if(d=o[h],p=s[d],f=a[d],!c[d]&&!n(p,f))if(n(p.source,f.source)&&n(p["source-layer"],f["source-layer"])&&n(p.type,f.type)){for(_ in Zt(p.layout,f.layout,i,d,null,Ot.setLayoutProperty),Zt(p.paint,f.paint,i,d,null,Ot.setPaintProperty),n(p.filter,f.filter)||i.push({command:Ot.setFilter,args:[d,f.filter]}),n(p.minzoom,f.minzoom)&&n(p.maxzoom,f.maxzoom)||i.push({command:Ot.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Zt(p[_],f[_],i,d,_.slice(6),Ot.setPaintProperty):n(p[_],f[_])||i.push({command:Ot.setLayerProperty,args:[d,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Zt(p[_],f[_],i,d,_.slice(6),Ot.setPaintProperty):n(p[_],f[_])||i.push({command:Ot.setLayerProperty,args:[d,_,f[_]]}))}else i.push({command:Ot.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],i.push({command:Ot.addLayer,args:[f,m]})}(s,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:Ot.setStyle,args:[e]}]}return i}(this.serialize(),e).filter((t=>!(t.command in Oe)));if(0===i.length)return!1;const r=i.filter((t=>!(t.command in Fe)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((t=>t.command)).join(", ")}.`);return i.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=e,!0}addImage(e,i){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=It(e,i,this.dispatcher,this);n.setEventedParent(this,(()=>({isSourceLoaded:this.loaded(),source:n.serialize(),sourceId:e})));const o=i=>{const r=(i?"symbol:":"other:")+e,o=this._sourceCaches[r]=new t.SourceCache(r,n,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[e]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const i=this.getSource(e);if(void 0===i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(e);for(const e of r)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===e.type){if(Be(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(n,e.source),e=t.clone$2(e),e=t.extend(e,{source:n})),this._validate(t.validateStyle.layer,"layers."+n,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[n]&&o.source&&a&&"custom"!==o.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!n(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.validateStyle.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.clone$2(i),this._updateLayer(o)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){return t.clone$2(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?n(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,o),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?n(s.getPaintProperty(i),r)||(s.setPaintProperty(i,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,o=this.getSource(r);if(void 0===o)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&n)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(r);for(const t of a)t.setFeatureState(n,e.id,i)}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.getSource(r);if(void 0===n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.type,s="vector"===o?e.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(r);for(const t of a)t.removeFeatureState(s,e.id,i)}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.getSource(i);if(void 0!==n){if("vector"!==n.type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(e(o)){i[o]=n;for(const e of t){const t=e[o];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(e(s))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<o)break;n.push(e),r.pop()}else for(const e of t){const t=e[s];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(e,i,r){i&&i.filter&&this._validate(t.validateStyle.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=i&&i.layers?i.layers.some((t=>{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=z.createFromScreenPoints(e,r);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;i.layers&&!n[e]||o.push(Ct(this._sourceCaches[t],this._layers,this._serializedLayers,a,i,r,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(t,e,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(zt);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],n=r[t];n.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of n)e.push(t)}}for(const e in a)a[e].forEach((r=>{const n=r.feature,o=i(t[e]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateStyle.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this._getSourceCaches(e);let n=[];for(const t of r)n=n.concat(Mt(t,i));return n}addSourceType(t,e,i){return Ne.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Ne.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const t in e)if(!n(e[t],r[t])){o=!0;break}if(!o)return;const s={now:t.exported.now(),transition:t.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(s)}getTerrain(){return this.terrain?this.terrain.get():null}setTerrain(e){if(this._checkLoaded(),!e)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if("object"==typeof e.source){const i="terrain-dem-src";this.addSource(i,e.source),e=t.clone$2(e),e=t.extend(e,{source:i})}if(!this._validate(t.validateStyle.terrain,"terrain",e)){if(this.terrain){const i=this.terrain,r=i.get();for(const o in e)if(!n(e[o],r[o])){i.set(e),this.stylesheet.terrain=e;const r={now:t.exported.now(),transition:t.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r);break}}else this._createTerrain(e);this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}}_createFog(e){const i=this.fog=new A(e);this.stylesheet.fog=e;const r={now:t.exported.now(),transition:t.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,r=i.get();for(const o in e)if(!n(e[o],r[o])){i.set(e),this.stylesheet.fog=e;const r={now:t.exported.now(),transition:t.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r);break}}else this._createFog(e);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(e){const i=this.terrain=new w(e);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const r={now:t.exported.now(),transition:t.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_validate(e,i,r,n,o={}){return(!o||!1!==o.validate)&&Be(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:r,styleSpec:t.spec},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,i,r,n,o=!1){let s=!1,a=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new ze(e,this._order,o,i,r,n,this.placement,this.fog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}}Ne.getSourceType=function(t){return St[t]},Ne.setSourceType=function(t,e){St[t]=e},Ne.registerForPluginStateChange=t.registerForPluginStateChange;var Ge="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",Ze="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let qe={},je={};qe=He("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef TERRAIN\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;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) {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));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat 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);}float prevElevation(vec2 apos) {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);}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_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))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {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);return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),je=He("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const $e=He("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nhighp 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;}","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),Xe=Ge;var We={background:He("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:He("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:He("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);vec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:He("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:He("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec3 pos=vec3(floor(a_pos*0.5)+extrude,elevation(floor(a_pos*0.5)));gl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:He("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:He("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 vec2 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_anchor_pos,elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=u_matrix*vec4(a_pos,elevation(a_pos),1.0);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:He("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(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:He("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);}"),fill:He("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:He("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:He("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:He("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:He("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;varying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;\n#ifdef TERRAIN\nvec2 centroid_pos=a_centroid_pos;bool flat_roof=centroid_pos.x !=0.0;float ele=elevation(pos_nx.xy);float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);gl_Position=u_matrix*vec4(pos,1);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:He("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;\n#ifdef TERRAIN\nvec2 centroid_pos=a_centroid_pos;bool flat_roof=centroid_pos.x !=0.0;float ele=elevation(pos_nx.xy);float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);\n#else\nvec3 p=vec3(pos_nx.xy,z);gl_Position=u_matrix*vec4(p,1);\n#endif\nvec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:He("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:He("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;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:He("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),lineGradient:He("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:He("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),lineSDF:He("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dash_from\n#pragma mapbox: initialize mediump vec4 dash_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);vec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dash_from\n#pragma mapbox: initialize mediump vec4 dash_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float widthA=dash_from.z*fromScale;float widthB=dash_to.z*toScale;float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*(tileZoomRatio/widthA)/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*(tileZoomRatio/widthB)/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);v_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:He("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(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:He("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float h=elevation(a_pos);vec4 projectedPoint=u_matrix*vec4(a_pos,h,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),h,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h,1.0);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));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));}"),symbolSDF:He("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float h=elevation(a_pos);vec4 projectedPoint=u_matrix*vec4(a_pos,h,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),h,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h,1.0);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:He("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float h=elevation(a_pos);vec4 projectedPoint=u_matrix*vec4(a_pos,h,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),h,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h,1.0);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrainRaster:He("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:He("#ifdef GL_ES\nprecision highp float;\n#endif\nvec4 pack_depth(float ndc_z) {float depth=ndc_z*0.5+0.5;const vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:He("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Ze),skyboxGradient:He("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform lowp 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));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Ze),skyboxCapture:He("\nvarying 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;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;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);}")};function He(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=t.match(n),a=e.match(n),l=Ge.match(n);let c=a?a.concat(s):s;i||(qe.staticUniforms&&(c=qe.staticUniforms.concat(c)),je.staticUniforms&&(c=je.staticUniforms.concat(c))),c&&(c=c.concat(l));const h={};return{fragmentSource:t=t.replace(r,((t,e,i,r,n)=>(h[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return h[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:o,staticUniforms:c}}class Ke{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,o,s,a){this.context=t;let l=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!l&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(l=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!l&&this.boundIndexBuffer===n&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===s&&this.boundDynamicVertexBuffer2===a?(t.bindVertexArrayOES.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind()):this.freshBind(e,i,r,n,o,s,a)}freshBind(t,e,i,r,n,o,s){let a;const l=t.numAttributes,c=this.context,h=c.gl;if(c.extVertexArrayObject)this.vao&&this.destroy(),this.vao=c.extVertexArrayObject.createVertexArrayOES(),c.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s;else{a=c.currentNumAttributes||0;for(let t=l;t<a;t++)h.disableVertexAttribArray(t)}e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);o&&o.enableAttributes(h,t),s&&s.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Ye(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.MercatorCoordinate(0,n/r).toLngLat().lat,new t.MercatorCoordinate(0,(n+1)/r).toLngLat().lat]}function Je(e,i,r,n,o,s,a){const l=e.context,c=l.gl,h=r.fbo;if(!h)return;e.prepareDrawTile(i);const u=e.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment.get());const d=((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:Ye(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:o,u_accent:s}})(e,r,n,e.terrain?i.projMatrix:null);e.prepareDrawProgram(l,u,i.toUnwrapped()),u.draw(l,c.TRIANGLES,o,s,a,t.CullFaceMode.disabled,d,n.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments)}function Qe(e,i,r){if(!i.needsDEMTextureUpload)return;const n=e.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new t.Texture(n,s,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function ti(e,i,r,n,o,s){const a=e.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),Qe(e,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const h=c.dim;a.activeTexture.set(l.TEXTURE0);let u=i.fbo;if(!u){const e=new t.Texture(a,{width:h,height:h,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),u=i.fbo=a.createFramebuffer(h,h,!0),u.colorAttachment.set(e.texture)}a.bindFramebuffer.set(u.framebuffer),a.viewport.set([0,0,h,h]),e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,t.CullFaceMode.disabled,((e,i)=>{const r=i.stride,n=t.create$1();return t.ortho(n,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(n,n,[0,-t.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}const ei=(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image0:new t.Uniform1i(e,i.u_image0),u_skirt_height:new t.Uniform1f(e,i.u_skirt_height)}),ii=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),ri=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,n){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:n,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},ni={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function oi(e,i,r,n,o){const s=e.context,a=s.gl;let l,c;const h=e.options.showTerrainWireframe?2:0,u=(t,i)=>{if(c===t)return;const r=[ni[t]];i&&r.push(ni[h]),l=e.useProgram("terrainRaster",null,r),c=t},d=e.colorModeForRenderPass(),p=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);ri.update(o);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(h?[!1,!0]:[!1]).forEach((h=>{c=-1;const _=h?a.LINES:a.TRIANGLES,[g,y]=h?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),b=t.StencilMode.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];v=T,null!=(x=w)&&null!=v&&x.hasData()&&v.hasData()&&null!=x.demTexture&&null!=v.demTexture&&x.tileID.key!==v.tileID.key&&ri.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const E=ri.getMorphValuesForProxy(c.key),S=E?1:0;let I;E&&(I={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:t.easeCubicInOut(E.phase)}});const A=ii(c.projMatrix,si(c.canonical,f.renderWorldCopies)?m/10:m);u(S,h),i.setupElevationDraw(n,l,I),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,_,p,b,d,t.CullFaceMode.backCCW,A,"terrain_raster",i.gridBuffer,g,y)}var x,v}))}function si(t,e){const i=1<<t.z;return!e&&(0===t.x||t.x===i-1)||0===t.y||t.y===i-1}const ai=t=>({u_matrix:t});function li(e,i,r,n,o){if(o>0){const s=t.exported.now(),a=(s-e.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),h=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),d=u&&e.refreshedUponExpiration?1:t.clamp(u?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class ci extends t.SourceCache{constructor(t){const e=It("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new C(Rt(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,r){if(e.freezeTileCoverage)return;this.transform=e;const n=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new t.Tile(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i}),{});for(const t in this._tiles)t in n||(this.freeFBO(t),this._tiles[t].state="unloaded",delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class hi extends t.OverscaledTileID{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class ui extends t.Elevation{constructor(e,i){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=function(e){const i=new t.StructArrayLayout4i8,r=new t.StructArrayLayout3ui6,n=131;i.reserve(17161),r.reserve(33800);const o=t.EXTENT/128,s=t.EXTENT+o/2,a=s+o;for(let e=-o;e<a;e+=o)for(let r=-o;r<a;r+=o){const n=r<0||r>s||e<0||e>s?24575:0,o=t.clamp(Math.round(r),0,t.EXTENT),a=t.clamp(Math.round(e),0,t.EXTENT);i.emplaceBack(o+n,a,o,a)}const l=(t,e)=>{const i=e*n+t;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)})),[i,r,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(r,Tt.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=t.SegmentVector.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new ci(i.map),this.orthoMatrix=t.create$1(),t.ortho(this.orthoMatrix,0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(e,i,r){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const n=e.terrain.properties;this.sourceCache=e._getSourceCache(n.get("source")),this._exaggeration=n.get("exaggeration");const o=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.sourceCache.getSource().tileSize/128,r=this.proxySourceCache.getSource().tileSize;this.sourceCache.update(i,e*r,!0),this._findCoveringTileCache[this.sourceCache.id]={}};this.sourceCache.usedForTerrain||(this._findCoveringTileCache[this.sourceCache.id]={},this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),i.updateElevation(!r),this._findCoveringTileCache[this.proxySourceCache.id]={},this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map((t=>{const e=i.getTileByID(t).tileID;return e.projMatrix=r.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new t.pointGeometry(r.x,r.y);e.sort(((e,i)=>{if(i.overscaledZ-e.overscaledZ)return i.overscaledZ-e.overscaledZ;const r=new t.pointGeometry(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),o=new t.pointGeometry(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=n.mult(1<<e.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(r)-s.distSqr(o)}))}(n,this.painter),this._previousZoom=r.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((t=>{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const i=s[t];if(!i.used)continue;if(i!==this.sourceCache&&(this._findCoveringTileCache[i.id]={}),this._setupProxiedCoordsForOrtho(i,e[t],o),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map((t=>new hi(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),Qe(this.painter,r,n))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const n=t.tileID.canonical,o=Math.pow(2,e.tileID.canonical.z-n.z),s=r||"";return i["u_dem_tl"+s]=[n.x*o%1,n.y*o%1],i["u_dem_scale"+s]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,i=e.gl;e.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),n={width:1,height:1,data:new Uint8Array(t.DEMData.pack(r,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new t.Texture(e,n,i.RGBA,{premultiply:!1}),o}setupElevationDraw(e,i,r){const n=this.painter.context,o=n.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),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 a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();let l=null,c=null,h=1;if(r&&r.morphing&&this._useVertexMorphing){const t=r.morphing.srcDemTile,i=r.morphing.dstDemTile;h=r.morphing.phase,t&&i&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(c=t),this._prepareDemTileUniforms(e,i,s)&&(l=i))}if(c&&l?(n.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),n.activeTexture.set(o.TEXTURE4),c.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=h):(l=this.terrainTileForTile[e.tileID.key],n.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(e,l,s)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST)),r&&r.useDepthForOcclusion&&(n.activeTexture.set(o.TEXTURE3),this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height]),r&&r.useMeterToDem&&l){const e=(1<<l.tileID.canonical.z)*t.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=e}r&&r.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=r.labelPlaneMatrixInv),i.setTerrainUniformValues(n,s)}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=()=>{r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),this.renderingToTexture=!1},a=this._drapedRenderBatches.shift();let l=[];const c=i.style.order;let h=0;for(let u=0;u<o.length;u++){const d=o[u],p=n.getTileByID(d.proxyTileKey),f=n.proxyCachedFBO[d.key]?n.proxyCachedFBO[d.key][e]:void 0;let m,_;if(m=this.currentFBO=void 0!==f?n.renderCache[f]:this.pool[h++],p.texture=m.tex,void 0===f||m.dirty){r.bindFramebuffer.set(m.fb.framebuffer),this.renderedToTile=!1,m.dirty&&(r.clear({color:t.Color.transparent}),m.dirty=!1);for(let t=a.start;t<=a.end;++t){const e=i.style._layers[c[t]];if(e.isHidden(i.transform.zoom))continue;const n=i.style._getLayerSourceCache(e),o=n?this.proxyToSource[d.key][n.id]:[d];if(!o)continue;const s=o;r.viewport.set([0,0,m.fb.width,m.fb.height]),_!==(n?n.id:null)&&(this._setupStencil(o,e,n),_=n?n.id:null),i.renderLayer(i,n,e,s)}m.dirty=this.renderedToTile,this.renderedToTile&&l.push(p.tileID),5===h&&(h=0,l.length>0&&(s(),oi(i,this,n,l,this._updateTimestamp),this.renderingToTexture=!0,l=[]))}else l.push(p.tileID)}return s(),l.length>0&&oi(i,this,n,l,this._updateTimestamp),a.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,n=0,o=!1;for(let s=0;s<e;++s){const e=t._layers[t.order[s]];this._style.isLayerDraped(e)?(o&&++r,++n):o||(o=!0,i=e.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter((t=>t.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const n=r.tileID,o=Math.pow(2,n.overscaledZ),{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,h=a/o,u=(a+1)/o;return{minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,t,e,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,i=e.gl,r=this.drapeBufferSize;e.activeTexture.set(i.TEXTURE0);const n=new t.Texture(e,{width:r[0],height:r[1],data:null},i.RGBA);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=e.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(n.texture),o.depthAttachment=new yt(e,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some((t=>{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),n=!!r&&1!==r.t,o=e.hasTransition();return"custom"!==e.type&&!i&&(n||o)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof bt){t=!0;break}if(t)for(let t=0;t<this._style.order.length;++t){const e=this._style._layers[this._style.order[t]],i=e.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(e);if("raster"!==e.type||i||!r)continue;const n=e.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][r.id];if(e)for(const t of e){const e=li(r.getTile(t),r.findLoadedParent(t,0),r,this.painter.transform,n);(1!==e.opacity||0!==e.mix)&&this._clearRenderCacheForTile(r.id,t)}}}}_setupDrapedRenderBatches(){const t=this._style.order,e=t.length;if(0===e)return;const i=[];let r,n=0,o=this._style._layers[t[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<e;)o=this._style._layers[t[n]];for(;n<e;++n){const e=this._style._layers[t[n]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._drapedRenderBatches=i}_setupRenderCache(t){const e=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,e.renderCache.length>e.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i<t.length;++i){const r=Object.values(t[i]);e.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(e.getTileByID(o.key),void 0!==e.proxyCachedFBO[o.key]){const i=t[o.key],n=this.proxyToSource[o.key];let s=0;for(const t in n){const e=n[t],o=i[t];if(!o||o.length!==e.length||e.some(((e,i)=>e!==o[i]||r[t]&&r[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[o.key])e.renderCache[e.proxyCachedFBO[o.key][t]].dirty=s<0||s!==Object.values(i).length}else for(let t=0;t<this._drapedRenderBatches.length;++t){const i=this._drapedRenderBatches[t];let r=e.renderCachePool.pop();void 0===r&&e.renderCache.length<50&&(r=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==r&&(void 0===e.proxyCachedFBO[o.key]&&(e.proxyCachedFBO[o.key]={}),e.proxyCachedFBO[o.key][i.start]=r,e.renderCache[r].dirty=!0)}}this._tilesDirty={}}_setupStencil(t,e,i){if(!i||!this._sourceTilesOverlap[i.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,n=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let o;if(e.isTileClipped())o=t.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,e.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(e,i){const r=this.painter,n=this.painter.context,o=n.gl;r._tileClippingMaskIDs={},n.setColorMode(t.ColorMode.disabled),n.setDepthMode(t.DepthMode.disabled);const s=r.useProgram("clippingMask");for(const a of e){const e=r._tileClippingMaskIDs[a.key]=--i;s.draw(n,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,ai(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(e){const i=this.painter.transform;if(e.x<0||e.x>i.width||e.y<0||e.y>i.height)return null;const r=[e.x,e.y,1,1];t.transformMat4(r,r,i.pixelMatrixInverse),t.scale$2(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=t.mercatorZfromAltitude(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=t.subtract([],r.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const e=this.painter,i=e.context,r=this.proxySourceCache,n=Math.ceil(e.width),o=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const e=i.gl,r=i.createFramebuffer(n,o,!0);i.activeTexture.set(e.TEXTURE0);const s=new t.Texture(i,{width:n,height:o,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,n,o);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,n,o]),function(e,i,r,n){const o=e.context,s=o.gl;o.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of n){const n=r.getTile(e),c=ii(e.projMatrix,0);i.setupElevationDraw(n,a),a.draw(o,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(e,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof Et)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;e<n.length;e++){const o=n[e],s=this._findTileCoveringTileID(o,t);if(s){const e=this._createProxiedId(o,s,i[o.key]&&i[o.key][t.id]);r.push(e),this.proxyToSource[o.key][t.id]=[e]}}let o=!1;for(let n=0;n<e.length;n++){const s=t.getTile(e[n]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const e=this.proxyToSource[a.tileID.key][t.id],n=this._createProxiedId(a.tileID,s,i[a.tileID.key]&&i[a.tileID.key][t.id]);e?e.splice(e.length-1,0,n):this.proxyToSource[a.tileID.key][t.id]=[n],r.push(n),o=!0}}this._sourceTilesOverlap[t.id]=o}_setupProxiedCoordsForImageSource(e,i,r){if(!e.getSource().loaded())return;const n=this.proxiedCoords[e.id]=[],o=this.proxyCoords,s=e.getSource(),a=new t.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(t.MercatorCoordinate.fromLngLat).reduce(((t,e)=>(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,i)=>{const r=e.wrap+e.canonical.x/(1<<e.canonical.z),n=e.canonical.y/(1<<e.canonical.z),o=t.EXTENT/(1<<e.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return r+o<s+l.min.x||r>s+l.max.x||n+o<a+l.min.y||n>a+l.max.y};for(let t=0;t<o.length;t++){const s=o[t];for(let t=0;t<i.length;t++){const o=e.getTile(i[t]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,r[s.key]&&r[s.key][e.id]),l=this.proxyToSource[s.key][e.id];l?l.push(a):this.proxyToSource[s.key][e.id]=[a],n.push(a)}}}_createProxiedId(e,i,r){let n=this.orthoMatrix;if(r){const t=r.find((t=>t.key===i.tileID.key));if(t)return t}if(i.tileID.key!==e.key){const r=e.canonical.z-i.tileID.canonical.z;let o,s,a;n=t.create$1();const l=i.tileID.wrap-e.wrap<<e.overscaledZ;r>0?(o=t.EXTENT>>r,s=o*((i.tileID.canonical.x<<r)-e.canonical.x+l),a=o*((i.tileID.canonical.y<<r)-e.canonical.y)):(o=t.EXTENT<<-r,s=t.EXTENT*(i.tileID.canonical.x-(e.canonical.x+l<<-r)),a=t.EXTENT*(i.tileID.canonical.y-(e.canonical.y<<-r))),t.ortho(n,0,o,0,o,0,1),t.translate(n,n,[s,a,0])}return new hi(i.tileID,e.key,n)}_findTileCoveringTileID(e,i){let r=i.getTile(e);if(r&&r.hasData())return r;const n=this._findCoveringTileCache[i.id],o=n[e.key];if(r=o?i.getTileByID(o):null,r&&r.hasData()||null===o)return r;let s=r?r.tileID:e,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const n=i.getSource().maxzoom;if(e.canonical.z>=n){const r=e.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,i.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,n,e.canonical.x>>r,e.canonical.y>>r)):0!==r&&(a=n,s=new t.OverscaledTileID(a,e.wrap,n,e.canonical.x>>r,e.canonical.y>>r))}s.key!==e.key&&(c.push(s.key),r=i.getTile(s))}const h=t=>{c.forEach((e=>{n[e]=t})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&h(r.tileID.key);const t=s.calculateScaledKey(a);if(r=i.getTileByID(t),r&&r.hasData())break;const e=n[t];if(null===e)break;void 0===e?c.push(t):r=i.getTileByID(e)}return h(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(t){this.renderedToTile||(this.renderedToTile=!0)}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i,r,n;const o=new t.StructArrayLayout2ui4,s=131;for(r=1;r<129;r++){for(i=1;i<129;i++)n=r*s+i,o.emplaceBack(n,n+1),o.emplaceBack(n,n+s),o.emplaceBack(n+1,n+s),128===r&&o.emplaceBack(n+s,n+s+1);o.emplaceBack(n+1,n+1+s)}return o}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function di(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class pi{static cacheKey(t,e,i){let r=`${t}${i?i.cacheKey:""}`;for(const t of e)r+="/"+t;return r}constructor(e,i,r,n,o,s){const a=e.gl;this.program=a.createProgram();const l=di(r.staticAttributes),c=n?n.getBinderAttributes():[],h=l.concat(c),u=r.staticUniforms?di(r.staticUniforms):[],d=n?n.getBinderUniforms():[],p=u.concat(d),f=[];for(const t of p)f.indexOf(t)<0&&f.push(t);let m=n?n.defines():[];m=m.concat(s.map((t=>"#define "+t)));const _=m.concat($e.fragmentSource,Xe,je.fragmentSource,r.fragmentSource).join("\n"),g=m.concat($e.vertexSource,Xe,je.vertexSource,qe.vertexSource,r.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,_),a.compileShader(y),a.attachShader(this.program,y);const x=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(x,g),a.compileShader(x),a.attachShader(this.program,x),this.attributes={};const v={};this.numAttributes=h.length;for(let t=0;t<this.numAttributes;t++)h[t]&&(a.bindAttribLocation(this.program,t,h[t]),this.attributes[h[t]]=t);a.linkProgram(this.program),a.deleteShader(x),a.deleteShader(y);for(let t=0;t<f.length;t++){const e=f[t];if(e&&!v[e]){const t=a.getUniformLocation(this.program,e);t&&(v[e]=t)}}this.fixedUniforms=o(e,v),this.binderUniforms=n?n.getUniforms(e,v):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((e,i)=>({u_dem:new t.Uniform1i(e,i.u_dem),u_dem_prev:new t.Uniform1i(e,i.u_dem_prev),u_dem_unpack:new t.Uniform4f(e,i.u_dem_unpack),u_dem_tl:new t.Uniform2f(e,i.u_dem_tl),u_dem_scale:new t.Uniform1f(e,i.u_dem_scale),u_dem_tl_prev:new t.Uniform2f(e,i.u_dem_tl_prev),u_dem_scale_prev:new t.Uniform1f(e,i.u_dem_scale_prev),u_dem_size:new t.Uniform1f(e,i.u_dem_size),u_dem_lerp:new t.Uniform1f(e,i.u_dem_lerp),u_exaggeration:new t.Uniform1f(e,i.u_exaggeration),u_depth:new t.Uniform1i(e,i.u_depth),u_depth_size_inv:new t.Uniform2f(e,i.u_depth_size_inv),u_meter_to_dem:new t.Uniform1f(e,i.u_meter_to_dem),u_label_plane_matrix_inv:new t.UniformMatrix4f(e,i.u_label_plane_matrix_inv)}))(e,v)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((e,i)=>({u_fog_matrix:new t.UniformMatrix4f(e,i.u_fog_matrix),u_fog_range:new t.Uniform2f(e,i.u_fog_range),u_fog_color:new t.Uniform4f(e,i.u_fog_color),u_fog_horizon_blend:new t.Uniform1f(e,i.u_fog_horizon_blend),u_fog_temporal_offset:new t.Uniform1f(e,i.u_fog_temporal_offset)}))(e,v))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(o);for(const t in this.fixedUniforms)this.fixedUniforms[t].set(s[t]);p&&p.setUniforms(t,this.binderUniforms,u,{zoom:d});const g={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[e];for(const i of h.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new Ke)).bind(t,this,l,p?p.getPaintVertexBuffers():[],c,i.vertexOffset,f,m),_.drawElements(e,i.primitiveLength*g,_.UNSIGNED_SHORT,i.primitiveOffset*g*2)}}}function fi(t,e,i){const r=1/M(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const mi=(e,i,r,n)=>{const o=i.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.create$2();"viewport"===o.properties.get("anchor")&&(t.fromRotation(l,-i.transform.angle),t.transformMat3(a,a,l));const c=o.properties.get("color");return{u_matrix:e,u_lightpos:a,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+r,u_opacity:n}},_i=(e,i,r,n,o,s,a)=>t.extend(mi(e,i,r,n),fi(s,i,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),gi=t=>({u_matrix:t}),yi=(e,i,r,n)=>t.extend(gi(e),fi(r,i,n)),xi=(t,e)=>({u_matrix:t,u_world:e}),vi=(e,i,r,n,o)=>t.extend(yi(e,i,r,n),{u_world:o}),bi=(e,i,r,n)=>{const o=e.transform;let s;if("map"===n.paint.get("circle-pitch-alignment")){const t=M(r,1,o.zoom);s=[t,t]}else s=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_matrix:e.translatePosMatrix(i.projMatrix,r,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:s}},wi=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},Ti=(e,i,r)=>{const n=t.EXTENT/r.tileSize;return{u_matrix:e,u_camera_to_center_distance:i.cameraToCenterDistance,u_extrude_scale:[i.pixelsToGLUnits[0]/n,i.pixelsToGLUnits[1]/n]}},Ei=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Si=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:M(e,1,i),u_intensity:r}),Ii=(e,i,r,n)=>{const o=e.transform;return{u_matrix:ki(e,i,r,n),u_ratio:1/M(i,1,o.zoom),u_device_pixel_ratio:t.exported.devicePixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Ai=(e,i,r,n,o)=>t.extend(Ii(e,i,r,n),{u_image:0,u_image_height:o}),Ci=(e,i,r,n,o)=>{const s=e.transform,a=zi(i,s);return{u_matrix:ki(e,i,r,o),u_texsize:i.imageAtlasTexture.size,u_ratio:1/M(i,1,s.zoom),u_device_pixel_ratio:t.exported.devicePixelRatio,u_image:0,u_scale:[a,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Mi=(e,i,r,n,o)=>{const s=zi(i,e.transform);return t.extend(Ii(e,i,r,o),{u_texsize:i.lineAtlasTexture.size,u_scale:[s,n.fromScale,n.toScale],u_image:0,u_mix:n.t})};function zi(t,e){return 1/M(t,1,e.tileZoom)}function ki(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Pi=(t,e,i,r,n)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Di(n.paint.get("raster-hue-rotate"))};var o,s};function Di(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Li=(t,e,i,r,n,o,s,a,l,c)=>{const h=n.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},Ri=(e,i,r,n,o,s,a,l,c,h,u)=>{const{cameraToCenterDistance:d,_pitch:p}=o.transform;return t.extend(Li(e,i,r,n,o,s,a,l,c,h),{u_gamma_scale:n?d*Math.cos(o.terrain?0:p):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+u})},Bi=(e,i,r,n,o,s,a,l,c,h)=>t.extend(Ri(e,i,r,n,o,s,a,l,!0,c,!0),{u_texsize_icon:h,u_texture_icon:1}),Fi=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),Oi=(e,i,r,n,o,s)=>t.extend(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),o=i.imageManager.getPattern(t.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/M(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(n,s,r,o),{u_matrix:e,u_opacity:i}),Ui={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmapTexture:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_image:new t.Uniform1i(e,i.u_image),u_image_height:new t.Uniform1f(e,i.u_image_height)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),lineSDF:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_image:new t.Uniform1i(e,i.u_image),u_scale:new t.Uniform3f(e,i.u_scale),u_mix:new t.Uniform1f(e,i.u_mix)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,i.u_buffer_scale),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrainRaster:ei,terrainDepth:ei,skybox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_cubemap:new t.Uniform1i(e,i.u_cubemap),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_center_direction:new t.Uniform3f(e,i.u_center_direction),u_radius:new t.Uniform1f(e,i.u_radius),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxCapture:(e,i)=>({u_matrix_3f:new t.UniformMatrix3f(e,i.u_matrix_3f),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_sun_intensity:new t.Uniform1f(e,i.u_sun_intensity),u_color_tint_r:new t.Uniform4f(e,i.u_color_tint_r),u_color_tint_m:new t.Uniform4f(e,i.u_color_tint_m),u_luminance:new t.Uniform1f(e,i.u_luminance)})};let Vi;function Ni(e,i,r,n,o,s,a){const l=e.context,c=l.gl,h=e.useProgram("collisionBox"),u=[];let d=0,p=0;for(let f=0;f<n.length;f++){const m=n[f],_=i.getTile(m),g=_.getBucket(r);if(!g)continue;let y=m.projMatrix;0===o[0]&&0===o[1]||(y=e.translatePosMatrix(m.projMatrix,_,o,s));const x=a?g.textCollisionBox:g.iconCollisionBox,v=g.collisionCircleArray;if(v.length>0){const i=t.create$1(),r=y;t.mul$1(i,g.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul$1(i,i,g.placementViewportMatrix),u.push({circleArray:v,circleOffset:p,transform:r,invTransform:i}),d+=v.length/4,p=d}x&&(e.terrain&&e.terrain.setupElevationDraw(_,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,Ti(y,e.transform,_),r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,e.transform.zoom,null,x.collisionVertexBuffer,x.collisionVertexBufferExt))}if(!a||!u.length)return;const f=e.useProgram("collisionCircle"),m=new t.StructArrayLayout2f1f2i16;m.resize(4*d),m._trim();let _=0;for(const t of u)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],o=t.circleArray[i+2],s=t.circleArray[i+3];m.emplace(_++,r,n,o,s,0),m.emplace(_++,r,n,o,s,1),m.emplace(_++,r,n,o,s,2),m.emplace(_++,r,n,o,s,3)}(!Vi||Vi.length<2*d)&&(Vi=function(e){const i=2*e,r=new t.StructArrayLayout3ui6;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(d));const g=l.createIndexBuffer(Vi,!0),y=l.createVertexBuffer(m,t.collisionCircleLayout.members,!0);for(const i of u){const n={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(x=e.transform).cameraToCenterDistance,u_viewport_size:[x.width,x.height]};f.draw(l,c.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,n,r.id,y,g,t.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,e.transform.zoom,null,null,null)}var x;y.destroy(),g.destroy()}const Gi=t.identity(new Float32Array(16));function Zi(e,i,r,n,o,s){const{horizontalAlign:a,verticalAlign:l}=t.getAnchorAlignment(e),c=-(a-.5)*i,h=-(l-.5)*r,u=t.evaluateVariableOffset(e,n);return new t.pointGeometry((c/o+u[0])*s,(h/o+u[1])*s)}function qi(e,i,r,n,o,s,a,l,c,h,u,d){const p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,_={};f.clear();for(let m=0;m<p.length;m++){const g=p.get(m),y=e.allowVerticalPlacement&&!g.placedOrientation,x=g.hidden||!g.crossTileID||y?null:n[g.crossTileID];if(x){const n=new t.pointGeometry(g.anchorX,g.anchorY),p=d(n),m=Kt(n,r?l:a,p),y=Yt(s.cameraToCenterDistance,m.signedDistanceFromCamera);let v=o.evaluateSizeForFeature(e.textSizeData,h,g)*y/t.ONE_EM;r&&(v*=e.tilePixelRatio/c);const{width:b,height:w,anchor:T,textOffset:E,textScale:S}=x,I=Zi(T,b,w,E,S,v),A=r?Kt(n.add(I),a,p).point:m.point.add(i?I.rotate(-s.angle):I),C=e.allowVerticalPlacement&&g.placedOrientation===t.WritingMode.vertical?Math.PI/2:0;for(let e=0;e<g.numGlyphs;e++)t.addDynamicAttributes(f,A,C);u&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:A,angle:C})}else se(g.numGlyphs,f)}if(u){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const r=i.get(e);if(r.hidden)se(r.numGlyphs,m);else{const i=_[e];if(i)for(let e=0;e<r.numGlyphs;e++)t.addDynamicAttributes(m,i.shiftedAnchor,i.angle);else se(r.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function ji(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function $i(e,i,r,n,o,s,a,l,c,h,u,d){const p=e.context,f=p.gl,m=e.transform,_="map"===l,g="map"===c,y=_&&"point"!==r.layout.get("symbol-placement"),x=_&&!g&&!y,v=void 0!==r.layout.get("symbol-sort-key").constantOr(1);let b=!1;const w=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),T=r.layout.get("text-variable-anchor"),E=[],S=e.terrain&&g?["PITCH_WITH_MAP_TERRAIN"]:null;for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c)continue;const u=o?c.text:c.icon;if(!u||!u.segments.get().length)continue;const d=u.programConfigurations.get(r.id),p=o||c.sdfIcons,w=o?c.textSizeData:c.iconSizeData,I=g||0!==m.pitch,A=e.useProgram(ji(p,o,c),d,S),C=t.evaluateSizeForZoom(w,m.zoom);let z,k,P,D,L=[0,0],R=null;if(o){if(k=n.glyphAtlasTexture,P=f.LINEAR,z=n.glyphAtlasTexture.size,c.iconsInText){L=n.imageAtlasTexture.size,R=n.imageAtlasTexture;const t="composite"===w.kind||"camera"===w.kind;D=I||e.options.rotating||e.options.zooming||t?f.LINEAR:f.NEAREST}}else{const t=1!==r.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;k=n.imageAtlasTexture,P=p||e.options.rotating||e.options.zooming||t||I?f.LINEAR:f.NEAREST,z=n.imageAtlasTexture.size}const B=M(n,1,e.transform.zoom),F=Wt(l.projMatrix,g,_,e.transform,B),O=e.terrain&&g&&y?t.invert(new Float32Array(16),F):Gi,U=Ht(l.projMatrix,g,_,e.transform,B),V=T&&c.hasTextData(),N="none"!==r.layout.get("icon-text-fit")&&V&&c.hasIconData();if(y){const t=m.elevation;Qt(c,l.projMatrix,e,o,F,U,g,h,t?e=>t.getAtTileOffset(l,e.x,e.y):null)}const G=e.translatePosMatrix(l.projMatrix,n,s,a),Z=y||o&&T||N?Gi:F,q=e.translatePosMatrix(U,n,s,a,!0),j=p&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let $;$=p?c.iconsInText?Bi(w.kind,C,x,g,e,G,Z,q,z,L):Ri(w.kind,C,x,g,e,G,Z,q,o,z,!0):Li(w.kind,C,x,g,e,G,Z,q,o,z);const X={program:A,buffers:u,uniformValues:$,atlasTexture:k,atlasTextureIcon:R,atlasInterpolation:P,atlasInterpolationIcon:D,isSDF:p,hasHalo:j,tile:n,labelPlaneMatrixInv:O};if(v&&c.canOverlap){b=!0;const e=u.segments.get();for(const i of e)E.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:X})}else E.push({segments:u.segments,sortKey:0,state:X})}b&&E.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of E){const i=t.state;if(e.terrain&&e.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!0,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),p.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Xi(i.buffers,t.segments,r,e,i.program,w,u,d,n)),n.u_is_halo=0}Xi(i.buffers,t.segments,r,e,i.program,w,u,d,i.uniformValues)}}function Xi(e,i,r,n,o,s,a,l,c){const h=n.context;o.draw(h,h.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,r.id,e.layoutVertexBuffer,e.indexBuffer,i,r.paint,n.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Wi(e,i,r,n,o,s,a){const l=e.context.gl,c=r.paint.get("fill-pattern"),h=c&&c.constantOr(1),u=r.getCrossfadeParameters();let d,p,f,m,_;a?(p=h&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=l.LINES):(p=h?"fillPattern":"fill",d=l.TRIANGLES);for(const g of n){const n=i.getTile(g);if(h&&!n.patternsLoaded())continue;const y=n.getBucket(r);if(!y)continue;e.prepareDrawTile(g);const x=y.programConfigurations.get(r.id),v=e.useProgram(p,x);h&&(e.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),x.updatePaintBuffers(u));const b=c.constantOr(null);if(b&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const w=e.translatePosMatrix(g.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===p&&h?vi(w,e,u,n,t):xi(w,t)}else m=y.indexBuffer,_=y.segments,f=h?yi(w,e,u,n):gi(w);e.prepareDrawProgram(e.context,v,g.toUnwrapped()),v.draw(e.context,d,o,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,f,r.id,y.layoutVertexBuffer,m,_,r.paint,e.transform.zoom,x)}}function Hi(e,i,r,n,o,s,a){const l=e.context,c=l.gl,h=r.paint.get("fill-extrusion-pattern"),u=h.constantOr(1),d=r.getCrossfadeParameters(),p=r.paint.get("fill-extrusion-opacity");for(const f of n){const n=i.getTile(f),m=n.getBucket(r);if(!m)continue;const _=m.programConfigurations.get(r.id),g=e.useProgram(u?"fillExtrusionPattern":"fillExtrusion",_);if(e.terrain){const t=e.terrain;if(!m.enableTerrain)continue;if(t.setupElevationDraw(n,g,{useMeterToDem:!0}),Ki(l,i,f,m,r,t),!m.centroidVertexBuffer){const t=g.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}u&&(e.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),_.updatePaintBuffers(d));const y=h.constantOr(null);if(y&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[y.to.toString()],i=t.patternPositions[y.from.toString()];e&&i&&_.setConstantPatternPositions(e,i)}const x=e.translatePosMatrix(f.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),v=r.paint.get("fill-extrusion-vertical-gradient"),b=u?_i(x,e,v,p,f,d,n):mi(x,e,v,p);e.prepareDrawProgram(l,g,f.toUnwrapped()),g.draw(l,l.gl.TRIANGLES,o,s,a,t.CullFaceMode.backCCW,b,r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,r.paint,e.transform.zoom,_,e.terrain?m.centroidVertexBuffer:null)}}function Ki(e,i,r,n,o,s){const a=[e=>{let i=e.canonical.x-1,r=e.wrap;return i<0&&(i=(1<<e.canonical.z)-1,r--),new t.OverscaledTileID(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>{let i=e.canonical.x+1,r=e.wrap;return i===1<<e.canonical.z&&(i=0,r++),new t.OverscaledTileID(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],l=t=>{const e=i.getSource().maxzoom,r=t=>{const e=i.getTileByID(t);if(e&&e.hasData())return e.getBucket(o)};let n,s,a;return(t.overscaledZ===t.canonical.z||t.overscaledZ>=e)&&(n=r(t.key)),t.overscaledZ>=e&&(s=r(t.calculateScaledKey(t.overscaledZ+1))),t.overscaledZ>e&&(a=r(t.calculateScaledKey(t.overscaledZ-1))),n||s||a},c=[0,0,0],h=(e,i)=>(c[0]=Math.min(e.min.y,i.min.y),c[1]=Math.max(e.max.y,i.max.y),c[2]=t.EXTENT-i.min.x>e.max.x?i.min.x-t.EXTENT:e.max.x,c),u=(e,i)=>(c[0]=Math.min(e.min.x,i.min.x),c[1]=Math.max(e.max.x,i.max.x),c[2]=t.EXTENT-i.min.y>e.max.y?i.min.y-t.EXTENT:e.max.y,c),d=[(t,e)=>h(t,e),(t,e)=>h(e,t),(t,e)=>u(t,e),(t,e)=>u(e,t)],p=new t.pointGeometry(0,0);let f,m,_;const g=(e,i,n,o,a)=>{const l=[[o?n:e,o?e:n,0],[o?n:i,o?i:n,0]],c=a<0?t.EXTENT+a:a,h=[o?c:(e+i)/2,o?(e+i)/2:c,0];return 0===n&&a<0||0!==n&&a>0?s.getForTilePoints(_,[h],!0,m):l.push(h),s.getForTilePoints(r,l,!0,f),Math.max(l[0][2],l[1][2],h[2])/s.exaggeration()};for(let e=0;e<4;e++){const i=n.borders[e];if(0===i.length&&(n.borderDone[e]=!0),n.borderDone[e])continue;const o=_=a[e](r),c=l(o);if(!c||!c.enableTerrain)continue;if(m=s.findDEMTileFor(o),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(r);if(!t||!t.dem)return;f=t}const h=(e<2?1:5)-e,u=c.borders[h];let y=0;for(let r=0;r<i.length;r++){const o=n.featuresOnBorder[i[r]],s=o.borders[e];let a;for(;y<u.length&&(a=c.featuresOnBorder[u[y]],!(a.borders[h][1]>s[0]+3));)c.borderDone[h]||c.encodeCentroid(void 0,a,!1),y++;if(a&&y<u.length){const i=y;let r=0;for(;!(a.borders[h][0]>s[1]-3)&&(r++,++y!==u.length);)a=c.featuresOnBorder[u[y]];if(a=c.featuresOnBorder[u[i]],o.intersectsCount()>1||a.intersectsCount()>1||1!==r){1!==r&&(y=i),n.encodeCentroid(void 0,o,!1),c.borderDone[h]||c.encodeCentroid(void 0,a,!1);continue}const l=d[e](o,a),f=e%2?t.EXTENT-1:0;p.x=g(l[0],Math.min(t.EXTENT-1,l[1]),f,e<2,l[2]),p.y=0,n.encodeCentroid(p,o,!1),c.borderDone[h]||c.encodeCentroid(p,a,!1)}else n.encodeCentroid(void 0,o,!1)}n.borderDone[e]=n.needsCentroidUpdate=!0,c.borderDone[h]||(c.borderDone[h]=c.needsCentroidUpdate=!0)}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(e)}const Yi=new t.Color(1,0,0,1),Ji=new t.Color(0,1,0,1),Qi=new t.Color(0,0,1,1),tr=new t.Color(1,0,1,1),er=new t.Color(0,1,1,1);function ir(t,e,i,r){nr(t,0,e+i/2,t.transform.width,i,r)}function rr(t,e,i,r){nr(t,e-i/2,0,i,t.transform.height,r)}function nr(e,i,r,n,o,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,n*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function or(e,i,r){const n=e.context,o=n.gl,s=r.projMatrix,a=e.useProgram("debug"),l=i.getTileByID(r.key);e.terrain&&e.terrain.setupElevationDraw(l,a);const c=t.DepthMode.disabled,h=t.StencilMode.disabled,u=e.colorModeForRenderPass(),d="$debug";n.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a.draw(n,o.LINE_STRIP,c,h,u,t.CullFaceMode.disabled,Ei(s,t.Color.red),d,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);const p=l.latestRawTileData,f=Math.floor((p&&p.byteLength||0)/1024),m=i.getTile(r).tileSize,_=512/Math.min(m,512)*(r.overscaledZ/e.transform.zoom)*.5;let g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=" => "+r.overscaledZ),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${f}kb`),a.draw(n,o.TRIANGLES,c,h,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Ei(s,t.Color.transparent,_),d,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments)}const sr=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ar}=sr;function lr(t,e,i,r){t.emplaceBack(e,i,r)}class cr{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,lr(this.vertexArray,-1,-1,1),lr(this.vertexArray,1,-1,1),lr(this.vertexArray,-1,1,1),lr(this.vertexArray,1,1,1),lr(this.vertexArray,-1,-1,-1),lr(this.vertexArray,1,-1,-1),lr(this.vertexArray,-1,1,-1),lr(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=e.createVertexBuffer(this.vertexArray,ar),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function hr(e,i,r,n,o,s){const a=e.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=((t,e,i,r,n)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(t.fromMat4([],n),o,h,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const ur={symbol:function(e,i,r,n,o){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,i,r,n,o,s,a){const l=i.transform,c="map"===o,h="map"===s;for(const o of e){const e=n.getTile(o),s=e.getBucket(r);if(!s||!s.text||!s.text.segments.get().length)continue;const u=t.evaluateSizeForZoom(s.textSizeData,l.zoom),d=M(e,1,i.transform.zoom),p=Wt(o.projMatrix,h,c,i.transform,d),f="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(u){const i=Math.pow(2,l.zoom-e.tileID.overscaledZ),r=l.elevation;qi(s,c,h,a,t.symbolSize,l,p,o.projMatrix,i,u,f,r?t=>r.getAtTileOffset(o,t.x,t.y):t=>0)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&$i(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,a),0!==r.paint.get("text-opacity").constantOr(1)&&$i(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(Ni(e,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Ni(e,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,h=c.gl,u=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),d=t.StencilMode.disabled,p=e.colorModeForRenderPass(),f=[];for(let o=0;o<n.length;o++){const s=n[o],a=i.getTile(s),c=a.getBucket(r);if(!c)continue;const h=c.programConfigurations.get(r.id),u=wi(r),d={programConfiguration:h,program:e.useProgram("circle",h,u),layoutVertexBuffer:c.layoutVertexBuffer,indexBuffer:c.indexBuffer,uniformValues:bi(e,s,a,r),tile:a};if(l){const e=c.segments.get();for(const i of e)f.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:d})}else f.push({segments:c.segments,sortKey:0,state:d})}l&&f.sort(((t,e)=>t.sortKey-e.sortKey));for(const i of f){const{programConfiguration:n,program:o,layoutVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:f}=i.state,m=i.segments;e.terrain&&e.terrain.setupElevationDraw(f,o,{useDepthForOcclusion:!0}),e.prepareDrawProgram(c,o,f.tileID.toUnwrapped()),o.draw(c,h.TRIANGLES,u,d,p,t.CullFaceMode.disabled,l,r.id,s,a,m,r.paint,e.transform.zoom,n)}},heatmap:function(e,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,s=o.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer);else{const o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const n=t.gl;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width/4,e.height/4,0,n.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,o,n)}}(o,e,r),o.clear({color:t.Color.transparent});for(let c=0;c<n.length;c++){const h=n[c];if(i.hasRenderableParent(h))continue;const u=i.getTile(h),d=u.getBucket(r);if(!d)continue;const p=d.programConfigurations.get(r.id),f=e.useProgram("heatmap",p),{zoom:m}=e.transform;e.terrain&&e.terrain.setupElevationDraw(u,f),e.prepareDrawProgram(o,f,h.toUnwrapped()),f.draw(o,s.TRIANGLES,t.DepthMode.disabled,a,l,t.CullFaceMode.disabled,Si(h.projMatrix,u,m,r.paint.get("heatmap-intensity")),r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,e.transform.zoom,p)}o.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,i){const r=e.context,n=r.gl,o=i.heatmapFbo;if(!o)return;r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new t.Texture(r,i.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,n.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,((e,i,r,n)=>{const o=t.create$1();t.ortho(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(e,i),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=r.paint.get("line-dasharray"),h=c.constantOr(1),u=r.layout.get("line-cap"),d=r.paint.get("line-pattern"),p=d.constantOr(1),f=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),_=p?"linePattern":h?"lineSDF":f?"lineGradient":"line",g=e.context,y=g.gl;for(const o of n){const n=i.getTile(o);if(p&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;e.prepareDrawTile(o);const x=s.programConfigurations.get(r.id),v=e.useProgram(_,x),b=d.constantOr(null);if(b&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const w=c.constantOr(null),T=u.constantOr(null);if(!p&&w&&T&&n.lineAtlas){const t=n.lineAtlas,e=t.getDash(w.to,T),i=t.getDash(w.from,T);e&&i&&x.setConstantPatternPositions(e,i)}const E=e.terrain?o.projMatrix:null,S=p?Ci(e,n,r,m,E):h?Mi(e,n,r,m,E):f?Ai(e,n,r,E,s.lineClipsArray.length):Ii(e,n,r,E);if(p)g.activeTexture.set(y.TEXTURE0),n.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),x.updatePaintBuffers(m);else if(h)g.activeTexture.set(y.TEXTURE0),n.lineAtlasTexture.bind(y.LINEAR,y.REPEAT),x.updatePaintBuffers(m);else if(f){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-o.canonical.z):1;l=t.clamp(t.nextPowerOfTwo(s.maxLineLength/t.EXTENT*1024*n),256,g.maxTextureSize)}n.gradient=t.renderColorRamp({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new t.Texture(g,n.gradient,y.RGBA),n.version=r.gradientVersion,a=n.texture}g.activeTexture.set(y.TEXTURE0),a.bind(r.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}e.prepareDrawProgram(g,v,o.toUnwrapped()),v.draw(g,y.TRIANGLES,a,e.stencilModeForClipping(o),l,t.CullFaceMode.disabled,S,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,x,s.layoutVertexBuffer2)}},fill:function(e,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const o=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);Wi(e,i,r,n,o,a,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const o=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);Wi(e,i,r,n,o,a,!0)}},"fill-extrusion":function(e,i,r,n){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))Hi(e,i,r,n,s,t.StencilMode.disabled,t.ColorMode.disabled),Hi(e,i,r,n,s,e.stencilModeFor3D(),e.colorModeForRenderPass());else{const o=e.colorModeForRenderPass();Hi(e,i,r,n,s,t.StencilMode.disabled,o)}}},hillshade:function(e,i,r,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const o=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,h]="translucent"!==e.renderPass||l?[{},n]:e.stencilConfigForOverlap(n);for(const n of h){const o=i.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===e.renderPass)ti(e,o,r,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):c[n.overscaledZ];Je(e,n,o,r,s,t,a)}}o.viewport.set([0,0,e.width,e.height])},raster:function(e,i,r,n,o,s){if("translucent"!==e.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!n.length)return;const a=e.context,l=a.gl,c=i.getSource(),h=e.useProgram("raster"),u=e.colorModeForRenderPass(),d=e.terrain&&e.terrain.renderingToTexture,[p,f]=c instanceof Et||d?[{},n]:e.stencilConfigForOverlap(n),m=f[f.length-1].overscaledZ,_=!e.options.moving;for(const n of f){const o=d?t.DepthMode.disabled:e.depthModeForSublayer(n.overscaledZ-m,1===r.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=n.toUnwrapped(),g=i.getTile(n);if(d&&(!g||!g.hasData()))continue;const y=d?n.projMatrix:e.transform.calculateProjMatrix(f,_),x=e.terrain&&d?e.terrain.stencilModeForRTTOverlap(n):p[n.overscaledZ],v=s?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(v);const b=i.findLoadedParent(n,0),w=li(g,b,i,e.transform,v);let T,E;e.terrain&&e.terrain.prepareDrawTile(n);const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE,l.LINEAR_MIPMAP_NEAREST),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE,l.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE,l.LINEAR_MIPMAP_NEAREST);const I=Pi(y,E||[0,0],T||1,w,r);e.prepareDrawProgram(a,h,f),c instanceof Et?h.draw(a,l.TRIANGLES,o,t.StencilMode.disabled,u,t.CullFaceMode.disabled,I,r.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments):h.draw(a,l.TRIANGLES,o,x,u,t.CullFaceMode.disabled,I,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments)}},background:function(e,i,r,n){const o=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,h=c.tileSize,u=r.paint.get("background-pattern");if(e.isPatternMissing(u))return;const d=!u&&1===o.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===d?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),_=e.useProgram(u?"backgroundPattern":"background"),g=n||c.coveringTiles({tileSize:h});u&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));const y=r.getCrossfadeParameters();for(const i of g){const c=i.toUnwrapped(),d=n?i.projMatrix:e.transform.calculateProjMatrix(c);e.prepareDrawTile(i);const g=u?Oi(d,s,e,u,{tileID:i,tileSize:h},y):Fi(d,s,o);e.prepareDrawProgram(a,_,c),_.draw(a,l.TRIANGLES,f,p,m,t.CullFaceMode.disabled,g,r.id,e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments)}},sky:function(e,i,r){const n=r.paint.get("sky-opacity");if(0===n)return;const o=e.context,s=r.paint.get("sky-type"),a=new t.DepthMode(o.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?r.needsSkyboxCapture(e)&&(function(e,i,r,n){const o=e.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!1),i.skyboxGeometry=new cr(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(e,!0),c=e.useProgram("skyboxCapture"),h=new Float64Array(16);t.identity(h),t.rotateY(h,h,.5*-Math.PI),hr(o,i,c,h,l,0),t.identity(h),t.rotateY(h,h,.5*Math.PI),hr(o,i,c,h,l,1),t.identity(h),t.rotateX(h,h,.5*-Math.PI),hr(o,i,c,h,l,2),t.identity(h),t.rotateX(h,h,.5*Math.PI),hr(o,i,c,h,l,3),t.identity(h),hr(o,i,c,h,l,4),t.identity(h),t.rotateY(h,h,Math.PI),hr(o,i,c,h,l,5),o.viewport.set([0,0,e.width,e.height])}(e,r),r.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,i,r,n,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const h=((t,e,i,r,n)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(e,!1),0,n,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,a,n,l):"gradient"===s&&"sky"===e.renderPass&&function(e,i,r,n,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new cr(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new t.Texture(s,i.colorRamp,a.RGBA)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=((e,i,r,n,o)=>({u_matrix:e,u_color_ramp:0,u_center_direction:i,u_radius:t.degToRad(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(e,!1),i.paint.get("sky-gradient-radius"),n,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,a,n,l)},debug:function(t,e,i){for(let r=0;r<i.length;r++)or(t,e,i[r])},custom:function(e,i,r){const n=e.context,o=r.implementation;if("offscreen"===e.renderPass){const t=o.prerender;t&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),t.call(o,n.gl,e.transform.customLayerMatrix()),n.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(t.StencilMode.disabled);const i="3d"===o.renderingMode?new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,t.DepthMode.ReadOnly);n.setDepthMode(i),o.render(n.gl,e.transform.customLayerMatrix()),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}};class dr{constructor(e,i){this.context=new vt(e),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=t.SourceCache.maxUnderzooming+t.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Re,this.gpuTimers={},this.frameCounter=0}updateTerrain(t,e){const i=!!t&&!!t.terrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new ui(this,t));const r=this._terrain;this.transform.elevation=i?r:null,r.update(t,this.transform,e)}_updateFog(t){const e=t.fog;if(!e||e.getOpacity(this.transform.pitch)<1||e.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=e.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,i){if(this.width=e*t.exported.devicePixelRatio,this.height=i*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const n=new t.StructArrayLayout4i8;n.emplaceBack(0,0,0,0),n.emplaceBack(t.EXTENT,0,t.EXTENT,0),n.emplaceBack(0,t.EXTENT,0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.rasterBoundsBuffer=e.createVertexBuffer(n,Tt.members),this.rasterBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const o=new t.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout1ui2;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,{width:1,height:1,data:new Uint8Array([0,0,0,0])},e.gl.RGBA),this.identityMat=t.create$1();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now())}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.create$1();t.ortho(r,0,this.width,this.height,0,0,1),t.scale$1(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,i.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,ai(r),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,i,r){if(!(i&&this.currentStencilSource!==i.id&&e.isTileClipped()&&r&&r.length))return;this.currentStencilSource=i.id;const n=this.context,o=n.gl;this.nextStencilID+r.length>256&&this.clearStencil(),n.setColorMode(t.ColorMode.disabled),n.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const i=this._tileClippingMaskIDs[e.key]=this.nextStencilID++;s.draw(n,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},i,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,ai(e.projMatrix),"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new t.StencilMode({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const i=this.context.gl;return new t.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){const i=this.context.gl,r=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=r[r.length-1].overscaledZ,o=r[0].overscaledZ-n+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let r=0;r<o;r++)e[r+n]=new t.StencilMode({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[e,r]}return[{[n]:t.StencilMode.disabled},r]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new t.ColorMode([e.CONSTANT_COLOR,e.ONE],new t.Color(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?t.ColorMode.unblended:t.ColorMode.alphaBlended}depthModeForSublayer(e,i,r){if(!this.opaquePassEnabledForLayer())return t.DepthMode.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new t.DepthMode(r||this.context.gl.LEQUAL,i,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(t.exported.now()),this.imageManager.beginFrame();const r=this.style.order,n=this.style._sourceCaches;for(const t in n){const e=n[t];e.used&&e.prepare(this.context)}const o={},s={},a={};for(const t in n){const e=n[t];o[t]=e.getVisibleCoordinates(),s[t]=o[t].slice().reverse(),a[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<r.length;t++)if(this.style._layers[r[t]].is3D()){this.opaquePassCutoff=t;break}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),!t.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const t of r){const i=this.style._layers[t],r=e._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?s[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}this.depthRangeFor3D=[0,1-(e.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let l=t.Color.transparent;if(this.style.fog&&(l=this.style.fog.properties.get("color")),this.context.clear({color:i.showOverdrawInspector?t.Color.black:l,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky())continue;const n=i?s[i.id]:void 0;this._renderTileClippingMasks(t,i,n),this.renderLayer(this,i,t,n)}if(this.renderPass="sky",this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);t.isSky()&&this.renderLayer(this,i,t,i?s[i.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(t)){if(t.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const n=i?("symbol"===t.type?a:s)[i.id]:void 0;this._renderTileClippingMasks(t,i,i?o[i.id]:void 0),this.renderLayer(this,i,t,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let i=null;t.values(this.style._layers).forEach((t=>{const r=e._getLayerSourceCache(t);r&&!t.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom<r.getSource().maxzoom)&&(i=r)})),i&&this.options.showTileBoundaries&&ur.debug(this,i,i.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;ir(t,t.transform.height-(e.top||0),3,Yi),ir(t,e.bottom||0,3,Ji),rr(t,e.left||0,3,Qi),rr(t,t.transform.width-(e.right||0),3,tr);const i=t.transform.centerPoint;!function(t,e,i,r){nr(t,e-1,i-10,2,20,r),nr(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,er)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%t.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(t.window.performance.now()),this.saveCanvasCopy())}renderLayer(t,e,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),ur[i.type](t,e,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),e[i]=o}return e}translatePosMatrix(e,i,r,n,o){if(!r[0]&&!r[1])return e;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e]}const a=[o?r[0]:M(i,r[0],this.transform.zoom),o?r[1]:M(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return t.translate(l,e,a),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=pi.cacheKey(t,n,e);return this.cache[o]||(this.cache[o]=new pi(this.context,t,We[t],e,Ui[t],n)),this.cache[o]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(t){this.terrain&&this.terrain.prepareDrawTile(t)}prepareDrawProgram(t,e,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch);0!==n&&e.setFogUniformValues(t,((t,e,i,r)=>{const n=e.properties.get("color"),o=t.frameCounter/1e3%1,s=[n.r/n.a,n.g/n.a,n.b/n.a,r];return{u_fog_matrix:i?t.transform.calculateFogTileMatrix(i):t.identityMat,u_fog_range:e.getFovAdjustedRange(t.transform._fov),u_fog_color:s,u_fog_horizon_blend:e.properties.get("horizon-blend"),u_fog_temporal_offset:o}})(this,r,i,n))}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}}class pr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),n=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new pr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function fr(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function mr(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]}function _r(e,i){const r=fr(e,3);t.fromQuat(e,i),mr(e,3,r)}function gr(t,e){mr(t,3,[e[0],e[1],e[2],1])}function yr(e,i){const r=t.identity$1([]);return t.rotateZ$1(r,r,-i),t.rotateX$1(r,r,-e),r}function xr(e,i){const r=[e[0],e[1],0],n=[i[0],i[1],0];if(t.length(r)>=1e-15){const e=t.normalize([],r);t.scale(n,e,t.dot(n,e)),i[0]=n[0],i[1]=n[1]}const o=t.cross([],i,e);if(t.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return yr(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class vr{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){this._position=this._renderWorldCopies?function(e){if(!e)return;const i=Array.isArray(e)?new t.MercatorCoordinate(e[0],e[1],e[2]):e;return i.x=t.wrap(i.x,0,1),i}(e):e}lookAtPoint(e,i){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,n=this.position,o=t.MercatorCoordinate.fromLngLat(e,r),s=[o.x-n.x,o.y-n.y,o.z-n.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=xr(s,i)}setPitchBearing(e,i){this.orientation=yr(t.degToRad(e),t.degToRad(-i))}}class br{constructor(e,i){this._transform=t.identity([]),this._orientation=t.identity$1([]),i&&(this._orientation=i,_r(this._transform,this._orientation)),e&&gr(this._transform,e)}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const t=fr(this._transform,3);return[t[0],t[1],t[2]]}set position(t){gr(this._transform,t)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,_r(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=yr(t,e),_r(this._transform,this._orientation)}forward(){const t=fr(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=fr(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=fr(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(e,i){const r=new Float64Array(16);return t.invert(r,this.getWorldToCamera(e,i)),r}getWorldToCameraPosition(e,i,r){const n=this.position;t.scale(n,n,-e);const o=new Float64Array(16);return t.fromScaling(o,[r,r,r]),t.translate(o,o,n),o[10]*=i,o}getWorldToCamera(e,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return t.conjugate(n,this._orientation),t.scale(o,o,-e),t.fromQuat(r,n),t.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(e,i,r,n){const o=new Float64Array(16);return t.perspective(o,e,i,r,n),o}getDistanceToElevation(e){const i=0===e?0:t.mercatorZfromAltitude(e,this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new br([...this.position],[...this.orientation])}}class wr{constructor(e,i,r,n,o){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new pr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._camera=new br,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._horizonShift=.1}clone(){const t=new wr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._cameraZoom=this._cameraZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,t?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(t){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),t&&this._constrainCameraAltitude(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(1,this.center.lat)*this.cameraWorldSize}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const i=-t.wrap(e,-180,180)*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+o*a,t[1]=n*l+s*a,t[2]=r*-a+o*l,t[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const e=this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(this.center),-1);return-1===e?(this._cameraZoom=null,!1):(this._centerAltitude=e,!0)}_updateCameraOnTerrain(){const e=this.cameraToCenterDistance/this.worldSize,i=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat);this._cameraZoom=this._zoomFromMercatorZ(i+e)}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<i.length;s++){const a=new t.pointGeometry(i[s][0]*this.width,r+i[s][1]*(this.height-r)),l=e.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCenterElevation()?this._updateCameraOnTerrain():this._cameraZoom=null:this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._cameraZoom||!this._elevation)return;const e=this._cameraZoom,i=this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(this.center)),r=t.mercatorZfromAltitude(i,this.center.lat),n=this._mercatorZfromZoom(e),o=this._mercatorZfromZoom(this._maxZoom),s=Math.max(n-r,o);this._setZoom(this._zoomFromMercatorZ(s))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(e){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let r;r=e.z<this._camera.position[2]?[i.x,i.y,i.z]:[e.x,e.y,e.z];const n=t.length(t.sub([],this._camera.position,r));return t.clamp(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let i=!1;if(e.orientation&&!t.exactEquals(e.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(e.orientation)),e.position){const r=[e.position.x,e.position.y,e.position.z];t.exactEquals$1(r,this._camera.position)||(this._setCameraPosition(r),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,i=new vr;return i.position=new t.MercatorCoordinate(e[0],e[1],e[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this._renderWorldCopies,i}_setCameraOrientation(e){if(!t.length$1(e))return!1;t.normalize$1(e,e);const i=t.transformQuat([],[0,0,-1],e),r=t.transformQuat([],[0,-1,0],e);if(r[2]<0)return!1;const n=xr(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(e){const i=this.zoomScale(this.minZoom)*this.tileSize,r=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;e[2]=t.clamp(e[2],n/r,n/i),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const i=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies){const r=this.pointCoordinate(new t.pointGeometry(0,0)),n=this.pointCoordinate(new t.pointGeometry(this.width,0)),o=this.pointCoordinate(new t.pointGeometry(this.width,this.height)),s=this.pointCoordinate(new t.pointGeometry(0,this.height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new t.UnwrappedTileID(r,e))}return i}coveringTiles(e){let i=this.coveringZoomLevel(e);const r=i,n=this.elevation&&!e.isTerrainDEM;if(void 0!==e.minzoom&&i<e.minzoom)return[];void 0!==e.maxzoom&&i>e.maxzoom&&(i=e.maxzoom);const o=t.MercatorCoordinate.fromLngLat(this.center),s=1<<i,a=[s*o.x,s*o.y,0],l=p.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i),c=this.pointCoordinate(this.getCameraPoint()),h=s*t.mercatorZfromAltitude(1,this.center.lat),u=this._camera.position[2]/t.mercatorZfromAltitude(1,this.center.lat),d=[s*c.x,s*c.y,u],m=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),_=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation?i:0,g=e.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,y=e.isTerrainDEM?-g:this._elevation?this._elevation.getMinElevationBelowMSL():0,x=t=>({aabb:new f([t*s,0,y],[(t+1)*s,s,g]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),v=[],b=[],w=i,T=e.reparseOverscaled?r:i,E=t=>{if(!this._elevation||!t.tileID)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=A(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},S=t=>t*t,I=S((u-this._centerAltitude)*h),A=t=>{if(t.zoom<_)return!0;if(t.zoom===w)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const e=t.aabb.distanceX(d),i=t.aabb.distanceY(d);let r=I;n&&(r=S(t.aabb.distanceZ(d)*h));const o=e*e+i*i+r;return o<S((1<<w-t.zoom)*m*((t,e)=>{if(e*S(.707)<t)return 1;const i=Math.sqrt(e/t);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(r,I),o))};if(this._renderWorldCopies)for(let t=1;t<=3;t++)v.push(x(-t)),v.push(x(t));for(v.push(x(0));v.length>0;){const r=v.pop(),o=r.x,s=r.y;let c=r.fullyVisible;if(!c){const t=r.aabb.intersects(l);if(0===t)continue;c=2===t}if(r.zoom!==w&&A(r))for(let e=0;e<4;e++){const i=(o<<1)+e%2,a=(s<<1)+(e>>1),l={aabb:r.aabb.quadrant(e),zoom:r.zoom+1,x:i,y:a,wrap:r.wrap,fullyVisible:c,tileID:void 0,shouldSplit:void 0};n&&(l.tileID=new t.OverscaledTileID(r.zoom+1===w?T:r.zoom+1,r.wrap,r.zoom+1,i,a),E(l)),v.push(l)}else{const n=r.zoom===w?T:r.zoom;if(e.minzoom&&e.minzoom>n)continue;const l=a[0]-(.5+o+(r.wrap<<r.zoom))*(1<<i-r.zoom),c=a[1]-.5-s,h=r.tileID?r.tileID:new t.OverscaledTileID(n,r.wrap,r.zoom,o,s);b.push({tileID:h,distanceSq:l*l+c*c})}}if(this.fogCullDistSq){const e=this.fogCullDistSq;b.splice(0,b.length,...b.filter((i=>{const r=[0,0,0,1],o=[t.EXTENT,t.EXTENT,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());t.transformMat4(r,r,s),t.transformMat4(o,o,s);const a=t.getAABBPointSquareDist(r,o);if(0===a)return!0;let l=!1;const c=this.horizonLineFromTop();if(a>e&&0!==c){const e=this.calculateProjMatrix(i.tileID.toUnwrapped());let r;n&&this._elevation&&(r=this._elevation.getMinMaxForTile(i.tileID)),r||(r={min:y,max:g});const o=t.furthestTileCorner(this.bearing),s=[o[0]*t.EXTENT,o[1]*t.EXTENT,r.max];t.transformMat4$1(s,s,e),l=(1-s[1])*this.height*.5<c}return a<e||l})))}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.pointGeometry(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(i)*this.worldSize)}unproject(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}setLocationAtPoint(e,i){const r=this.pointCoordinate(i),n=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),s=new t.MercatorCoordinate(o.x-(r.x-n.x),o.y-(r.y-n.y));this.center=this.coordinateLocation(s),this._renderWorldCopies&&(this.center=this.center.wrap())}setLocation(t){this.center=this.coordinateLocation(t),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t){return this._coordinatePoint(this.locationCoordinate(t),!1)}locationPoint3D(t){return this._coordinatePoint(this.locationCoordinate(t),!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e){return t.MercatorCoordinate.fromLngLat(e)}coordinateLocation(t){return t.toLngLat()}pointRayIntersection(e,i){const r=null!=i?i:this._centerAltitude,n=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.transformMat4(n,n,this.pixelMatrixInverse),t.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];t.scale$2(n,n,1/n[3]),t.scale$2(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(e){const i=[e.x,e.y,0,1],r=[e.x,e.y,1,1];return t.transformMat4(i,i,this.pixelMatrixInverse),t.transformMat4(r,r,this.pixelMatrixInverse),t.scale$2(i,i,1/i[3]),t.scale$2(r,r,1/r[3]),i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,r[2]=t.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,t.scale$2(i,i,1/this.worldSize),t.scale$2(r,r,1/this.worldSize),new d([i[0],i[1],i[2]],t.normalize([],t.sub([],r,i)))}rayIntersectionCoordinate(e){const{p0:i,p1:r,t:n}=e,o=t.mercatorZfromAltitude(i[2],this._center.lat),s=t.mercatorZfromAltitude(r[2],this._center.lat);return new t.MercatorCoordinate(t.number(i[0],r[0],n)/this.worldSize,t.number(i[1],r[1],n)/this.worldSize,t.number(o,s,n))}pointCoordinate(e){const i=this.horizonLineFromTop(!1),r=new t.pointGeometry(e.x,Math.max(i,e.y));return this.rayIntersectionCoordinate(this.pointRayIntersection(r))}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);const i=this.elevation;let r=this.elevation.pointCoordinate(e);if(r)return new t.MercatorCoordinate(r[0],r[1],r[2]);let n=0,o=this.horizonLineFromTop();if(e.y>o)return this.pointCoordinate(e);const s=.02*o,a=e.clone();for(let e=0;e<10&&o-n>s;e++){a.y=t.number(n,o,.66);const e=i.pointCoordinate(a);e?(o=a.y,r=e):n=a.y}return r?new t.MercatorCoordinate(r[0],r[1],r[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){if(this.elevation)return!this.elevation.pointCoordinate(t);{const e=this.horizonLineFromTop();return t.y<e}}_coordinatePoint(e,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,n=[e.x*this.worldSize,e.y*this.worldSize,r+e.toAltitude(),1];return t.transformMat4(n,n,this.pixelMatrix),n[3]>0?new t.pointGeometry(n[0]/n[3],n[1]/n[3]):new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}getBounds(){return this._terrainEnabled()?this._getBounds3D():(new t.LngLatBounds).extend(this.pointLocation(new t.pointGeometry(this._edgeInsets.left,this._edgeInsets.top))).extend(this.pointLocation(new t.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top))).extend(this.pointLocation(new t.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom))).extend(this.pointLocation(new t.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom)))}_getBounds3D(){const e=this.elevation,i=e.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});i.min*=e.exaggeration(),i.max*=e.exaggeration();const r=this.horizonLineFromTop();return[new t.pointGeometry(0,r),new t.pointGeometry(this.width,r),new t.pointGeometry(this.width,this.height),new t.pointGeometry(0,this.height)].reduce(((t,e)=>t.extend(this.coordinateLocation(this.rayIntersectionCoordinate(this.pointRayIntersection(e,i.min)))).extend(this.coordinateLocation(this.rayIntersectionCoordinate(this.pointRayIntersection(e,i.max))))),new t.LngLatBounds)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-.97*e;return t?Math.max(0,i):i}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new t.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(e,i){const r=e.canonical,n=i/this.zoomScale(r.z),o=r.x+Math.pow(2,r.z)*e.wrap,s=t.identity(new Float64Array(16));return t.translate(s,s,[o*n,r.y*n,0]),t.scale$1(s,s,[n/t.EXTENT,n/t.EXTENT,1]),s}calculateFogTileMatrix(e){const i=e.key,r=this._fogTileMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(e,this.cameraWorldSize);return t.multiply(n,this.worldToFogMatrix,n),r[i]=new Float32Array(n),r[i]}calculateProjMatrix(e,i=!1){const r=e.key,n=i?this._alignedProjMatrixCache:this._projMatrixCache;if(n[r])return n[r];const o=this.calculatePosMatrix(e,this.worldSize);return t.multiply(o,i?this.alignedProjMatrix:this.projMatrix,o),n[r]=new Float32Array(o),n[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const i=this._camera.position,r=this._camera.forward();if(i[2]<=0||r[2]>=0)return;const n=t.mercatorZfromAltitude(1,this._center.lat);i[2]/=n,r[2]/=n,t.normalize(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=t.scaleAndAdd([],i,r,o),n=new t.MercatorCoordinate(e[0],e[1],t.mercatorZfromAltitude(e[2],t.latFromMercatorY(e[1]))),s=this._camera.position,a=n.z+t.length([n.x-s[0],n.y-s[1],n.z-s[2]]);this._cameraZoom=this._zoomFromMercatorZ(a),this._centerAltitude=n.toAltitude(),this._center=n.toLngLat(),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const i=e.getAtPointOrZero(this._camera.mercatorPosition),r=this._minimumHeightOverTerrain()*Math.cos(t.degToRad(this._maxPitch)),n=t.mercatorZfromAltitude(i,this._center.lat),o=this._camera.position[2]-n;if(o<r){const e=t.MercatorCoordinate.fromLngLat(this._center,this._centerAltitude),i=this._camera.mercatorPosition,n=[e.x-i.x,e.y-i.y,e.z-i.z],s=t.length(n);n[2]-=r-o;const a=t.length(n);if(0===a)return;t.scale(n,n,s/a),this._camera.position=[e.x-n[0],e.y-n[1],e.z-n[2]],this._camera.orientation=xr(n,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e,i,r,n,o=-90,s=90,a=-180,l=180;const c=this.size,h=this._unmodified;if(this.latRange){const i=this.latRange;o=t.mercatorYfromLat(i[1])*this.worldSize,s=t.mercatorYfromLat(i[0])*this.worldSize,e=s-o<c.y?c.y/(s-o):0}if(this.lngRange){const e=this.lngRange;a=t.mercatorXfromLng(e[0])*this.worldSize,l=t.mercatorXfromLng(e[1])*this.worldSize,i=l-a<c.x?c.x/(l-a):0}const u=this.point,d=Math.max(i||0,e||0);if(d)return this.center=this.unproject(new t.pointGeometry(i?(l+a)/2:u.x,e?(s+o)/2:u.y)),this.zoom+=this.scaleZoom(d),this._unmodified=h,void(this._constraining=!1);if(this.latRange){const t=u.y,e=c.y/2;t-e<o&&(n=o+e),t+e>s&&(n=s-e)}if(this.lngRange){const t=u.x,e=c.x/2;t-e<a&&(r=a+e),t+e>l&&(r=l-e)}void 0===r&&void 0===n||(this.center=this.unproject(new t.pointGeometry(void 0!==r?r:u.x,void 0!==n?n:u.y))),this._constrainCameraAltitude(),this._unmodified=h,this._constraining=!1}_minZoomForBounds(){const e=(t,e)=>Math.log2(t/(this.tileSize*Math.abs(e[1]-e[0])));let i=0;if(this.latRange){const r=this.latRange;i=e(this.height,[t.mercatorYfromLat(r[0]),t.mercatorYfromLat(r[1])])}let r=0;if(this.lngRange){const i=this.lngRange;r=e(this.width,[t.mercatorXfromLng(i[0]),t.mercatorXfromLng(i[1])])}return Math.max(i,r)}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;const i=this.pixelsPerMeter;this._updateCameraState();const r=Math.PI/2+this._pitch,n=this.fovAboveCenter,o=this.elevation?this.elevation.getMinElevationBelowMSL()*i:0,s=(this._camera.position[2]*this.worldSize-o)/Math.cos(this._pitch),a=Math.sin(n)*s/Math.sin(t.clamp(Math.PI-r-n,.01,Math.PI-.01)),l=this.point,c=l.x,h=l.y,u=Math.cos(Math.PI/2-this._pitch)*a+s,d=Math.min(1.01*u,s*(1/this._horizonShift)),p=this.height/50,f=this._camera.getWorldToCamera(this.worldSize,i),m=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,p,d);m[8]=2*-e.x/this.width,m[9]=2*e.y/this.height;let _=t.mul$1([],m,f);this.mercatorMatrix=t.scale$1([],_,[this.worldSize,this.worldSize,this.worldSize/i]),this.projMatrix=_,this.invProjMatrix=t.invert(new Float64Array(16),this.projMatrix);const g=new Float32Array(16);t.identity(g),t.scale$1(g,g,[1,-1,1]),t.rotateX(g,g,this._pitch),t.rotateZ(g,g,this.angle);const y=t.perspective(new Float32Array(16),this._fov,this.width/this.height,p,d),x=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;y[8]=2*-e.x/this.width,y[9]=2*(e.y+x)/this.height,this.skyboxMatrix=t.multiply(g,y,g);const v=this.width%2/2,b=this.height%2/2,w=Math.cos(this.angle),T=Math.sin(this.angle),E=c-Math.round(c)+w*v+T*b,S=h-Math.round(h)+w*b+T*v,I=new Float64Array(_);if(t.translate(I,I,[E>.5?E-1:E,S>.5?S-1:S,0]),this.alignedProjMatrix=I,_=t.create$1(),t.scale$1(_,_,[this.width/2,-this.height/2,1]),t.translate(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=t.create$1(),t.scale$1(_,_,[1,-1,1]),t.translate(_,_,[-1,-1,0]),t.scale$1(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),_=t.invert(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._projMatrixCache={},this._alignedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height,o=[e,e,i];t.scale(o,o,n),t.scale(r,r,-1),t.multiply$1(r,r,o);const s=t.create$1();t.translate(s,s,r),t.scale$1(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,i,n)}_updateCameraState(){if(!this.height)return;this._camera.setPitchBearing(this._pitch,this.angle);const e=this._camera.forward(),i=this.cameraToCenterDistance,r=this.point,n=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)-t.mercatorZfromAltitude(this._centerAltitude,this.center.lat),o=this.cameraToCenterDistance/n;this._camera.position=[r.x/this.worldSize-e[0]*i/o,r.y/this.worldSize-e[1]*i/o,t.mercatorZfromAltitude(this._centerAltitude,this._center.lat)+-e[2]*i/o]}_translateCameraConstrained(e){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=e[2];let n=1;r>0&&(n=Math.min((i-this._camera.position[2])/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,n),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat),s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,i,a),this._pitch=t.clamp(r,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(n,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=new t.MercatorCoordinate(e[0],e[1],e[2]).toLngLat(),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!!this._elevation}isHorizonVisibleForPoints(e,i){const r=Math.min(e.x,i.x),n=Math.max(e.x,i.x),o=Math.min(e.y,i.y),s=Math.max(e.y,i.y),a=[new t.pointGeometry(r,o),new t.pointGeometry(n,s),new t.pointGeometry(r,s),new t.pointGeometry(n,o)],l=this._renderWorldCopies?-3:0,c=this._renderWorldCopies?4:1;for(const t of a){const e=this.pointRayIntersection(t);if(e.t<0)return!0;const i=this.rayIntersectionCoordinate(e);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.isHorizonVisibleForPoints(new t.pointGeometry(0,0),new t.pointGeometry(this.width,this.height))}zoomDeltaToMovement(e,i){const r=t.length(t.sub([],this._camera.position,e)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}}class Tr{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,300),i=!1)};return()=>(i=!0,r||n(),r)}(this._updateHashUnthrottled.bind(this))}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return t.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(e){const i=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=this._map.getBearing(),c=this._map.getPitch();let h="";if(h+=e?`/${s}/${a}/${r}`:`${r}/${a}/${s}`,(l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+="/"+Math.round(c)),this._hashName){const e=this._hashName;let i=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(i=!0,`${r}=${h}`):t})).filter((t=>t));return i||r.push(`${e}=${h}`),"#"+r.join("&")}return"#"+h}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}const Er={linearity:.3,easing:t.bezier(0,0,.3,1)},Sr=t.extend({deceleration:2500,maxSpeed:1400},Er),Ir=t.extend({deceleration:20,maxSpeed:1400},Er),Ar=t.extend({deceleration:1e3,maxSpeed:360},Er),Cr=t.extend({deceleration:1e3,maxSpeed:90},Er);class Mr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=kr(i.pan.mag(),r,t.extend({},Sr,e||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,zr(n,o)}if(i.zoom){const t=kr(i.zoom,r,Ir);n.zoom=this._map.transform.zoom+t.amount,zr(n,t)}if(i.bearing){const e=kr(i.bearing,r,Ar);n.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),zr(n,e)}if(i.pitch){const t=kr(i.pitch,r,Cr);n.pitch=this._map.transform.pitch+t.amount,zr(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),t.extend(n,{noMoveStart:!0})}}function zr(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function kr(e,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=t.clamp(e*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class Pr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r,n={}){const s=o.mousePos(i.getCanvasContainer(),r),a=i.unproject(s);super(e,t.extend({point:s,lngLat:a,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class Dr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r){const n="touchend"===e?r.changedTouches:r.touches,s=o.touchPos(i.getCanvasContainer(),n),a=s.map((t=>i.unproject(t))),l=s.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:s,point:l,lngLats:a,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}}class Lr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Rr{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Lr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new Pr(t.type,this._map,t))}mouseup(t){this._map.fire(new Pr(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new Pr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Pr(t.type,this._map,t))}mouseover(t){this._map.fire(new Pr(t.type,this._map,t))}mouseout(t){this._map.fire(new Pr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Dr(t.type,this._map,t))}touchmove(t){this._map.fire(new Dr(t.type,this._map,t))}touchend(t){this._map.fire(new Dr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Dr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Br{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Pr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Pr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new Pr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Fr{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(o.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=o.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),a=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(o.setTransform(this._box,`translate(${n}px,${a}px)`),this._box.style.width=s-n+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,n=i;if(this.reset(),o.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(o.remove(this._box),this._box=null),o.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function Or(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class Ur{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Or(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Or(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Vr{constructor(t){this.singleTap=new Ur(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Nr{constructor(){this._zoomIn=new Vr({numTouches:1,numTaps:2}),this._zoomOut=new Vr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Gr={0:1,2:2};class Zr{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=o.mouseButton(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),function(t,e){const i=Gr[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&o.mouseButton(t)===this._eventButton&&(this._moved&&o.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qr extends Zr{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class jr extends Zr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class $r extends Zr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class Xr{constructor(t){this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.pointGeometry(0,0)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const n=Or(r,i),o=new t.pointGeometry(0,0),s=new t.pointGeometry(0,0);let a=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(o._add(e),s._add(e.sub(i)),a++,n[t]=e)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wr{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,n]=this._firstTwoTouches,o=Hr(i,e,r),s=Hr(i,e,n);if(!o||!s)return;const a=this._aroundCenter?null:o.add(s).div(2);return this._move([o,s],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,s=Hr(i,e,r),a=Hr(i,e,n);s&&a||(this._active&&o.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Hr(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Kr(t,e){return Math.log(t/e)/Math.LN2}class Yr extends Wr{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Kr(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Kr(this._distance,i),pinchAround:e}}}function Jr(t,e){return 180*t.angleWith(e)/Math.PI}class Qr extends Wr{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Jr(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Jr(t,this._startVector);return Math.abs(i)<e}}function tn(t){return Math.abs(t.y)>Math.abs(t.x)}class en extends Wr{reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(t){this._lastPoints=t,tn(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return tn(t)&&tn(e)&&o}}const rn={panStep:100,bearingStep:15,pitchStep:10};class nn{constructor(){const t=rn;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:on,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function on(t){return t*(2-t)}const sn=4.000244140625;class an{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(e){if(!this.isEnabled())return;let i=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%sn==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=o.mousePos(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform,i=()=>e._terrainEnabled()?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>sn?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),i=o(e);s=t.number(n,r,i),e<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.bezier(o,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}reset(){this._active=!1}}class ln{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class cn{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class hn{constructor(){this._tap=new Vr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class un{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("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 dn{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class pn{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("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 fn=t=>t.zoom||t.drag||t.pitch||t.rotate;class mn extends t.Event{}class _n{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,i){const r=t.sub([],i,e);this.radius=t.length(r[2]<0?t.div([],r,this.constants):[r[0],r[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$2(e,e,this.constants);const i=t.scale([],e,this.radius);if(i[2]>0){const e=t.scale([],[0,0,1],t.dot(i,[0,0,1])),r=t.scale([],t.normalize([],[i[0],i[1],0]),this.radius),n=t.add([],i,t.scale([],t.sub([],t.add([],r,e),i),2));i[0]=n[0],i[1]=n[1]}return i}}function gn(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class yn{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Mr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new _n,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,i,r]of this._listeners)o.addEventListener(e,i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,i,r]of this._listeners)o.removeEventListener(e,i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new Rr(e,t));const r=e.boxZoom=new Fr(e,t);this._add("boxZoom",r);const n=new Nr,o=new cn;e.doubleClickZoom=new ln(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new hn;this._add("tapDragZoom",s);const a=e.touchPitch=new en;this._add("touchPitch",a);const l=new jr(t),c=new $r(t);e.dragRotate=new dn(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new qr(t),u=new Xr(t);e.dragPan=new un(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new Qr,p=new Yr;e.touchZoomRotate=new pn(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Br(e));const f=e.scrollZoom=new an(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new nn;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(fn(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,t.type+"Window")}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,n={needsRenderFrame:!1},s={},a={},l=t.touches?this._getMapTouches(t.touches):void 0,c=l?o.touchPos(this._el,l):i?void 0:o.mousePos(this._el,t);for(const{handlerName:i,handler:o,allowed:h}of this._handlers){if(!o.isEnabled())continue;let u;this._blockedByActive(a,h,i)?o.reset():o[e||t.type]&&(u=o[e||t.type](t,c,l),this.mergeHandlerResult(n,s,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||o.isActive())&&(a[i]=o)}const h={};for(const t in this._previousActiveHandlers)a[t]||(h[t]=r);this._previousActiveHandlers=a,(Object.keys(h).length||gn(n))&&(this._changes.push([n,s,h]),this._triggerRenderFrame()),(Object.keys(a).length||gn(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,n,o){if(!r)return;t.extend(e,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.aroundCoord&&(e.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.extend(i,o),t.extend(r,s);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const n=this._map,o=n.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!gn(e)){const t=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",t!==o.zoom&&this._map._update(!0)}if(!gn(e))return this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:p}=e;void 0!==p&&(u=p),(t=>i.drag&&!this._eventsInProgress.drag)()&&u&&(this._dragOrigin=s(o.pointCoordinate3D(u)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),u=u||n.transform.centerPoint,c&&(o.bearing+=c),h&&(o.pitch+=h),o._updateCameraState();const f=[0,0,0];if(a){const t=o.screenPointToMercatorRay(u),e=o.screenPointToMercatorRay(u.sub(a)),i=this._trackingEllipsoid.projectRay(t.dir),r=this._trackingEllipsoid.projectRay(e.dir);f[0]=r[0]-i[0],f[1]=r[1]-i[1]}const m=o.zoom,_=[0,0,0];if(l){const e=s(d||o.pointCoordinate3D(u)),i={dir:t.normalize([],t.sub([],e,o._camera.position))},r=o.screenPointToMercatorRay(o.centerPoint);if(i.dir[2]<0){const n=t.altitudeFromMercatorZ(e[2],e[1]),a=o.rayIntersectionCoordinate(o.pointRayIntersection(o.centerPoint,n)),c=o.zoomDeltaToMovement(s(a),l)*(r.dir[2]/i.dir[2]);t.scale(_,i.dir,c)}else if(o._terrainEnabled()){const r=o.zoomDeltaToMovement(e,l);t.scale(_,i.dir,r)}}const g=t.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const n=fn(this._eventsInProgress),o=fn(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[t+"start"]=i),this._eventsInProgress[t]=e[t]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,a[t+"end"]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=fn(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;e?(i(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:l})):(this._map.fire(new t.Event("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new t.Event(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new mn("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class xn extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(e,i){e=t.LngLatBounds.convert(e);const r=i&&i.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,i)}_extendCameraOptions(e){const i={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=t.extend({padding:i,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t}}return e.padding=t.extend(i,e.padding),e}_cameraForBoxAndBearing(e,i,r,n){const o=this._extendCameraOptions(n),s=this.transform,a=s.padding,l=s.project(t.LngLat.convert(e)),c=s.project(t.LngLat.convert(i)),h=l.rotate(-t.degToRad(r)),u=c.rotate(-t.degToRad(r)),d=new t.pointGeometry(Math.max(h.x,u.x),Math.max(h.y,u.y)),p=new t.pointGeometry(Math.min(h.x,u.x),Math.min(h.y,u.y)),f=d.sub(p),m=(s.width-(a.left+a.right+o.padding.left+o.padding.right))/f.x,_=(s.height-(a.top+a.bottom+o.padding.top+o.padding.bottom))/f.y;if(_<0||m<0)return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const g=Math.min(s.scaleZoom(s.scale*Math.min(m,_)),o.maxZoom),y="number"==typeof o.offset.x?new t.pointGeometry(o.offset.x,o.offset.y):t.pointGeometry.convert(o.offset),x=new t.pointGeometry((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(r*Math.PI/180),v=y.add(x).mult(s.scale/s.zoomScale(g));return{center:s.unproject(l.add(c).div(2).sub(v)),zoom:g,bearing:r}}_cameraForBox(e,i,r,n,o){const s=this._extendCameraOptions(o);r=r||0,n=n||0,e=t.LngLat.convert(e),i=t.LngLat.convert(i);const a=this.transform.clone();a.padding=s.padding;const l=this.getFreeCameraOptions(),c=new t.LngLat(.5*(e.lng+i.lng),.5*(e.lat+i.lat)),h=.5*(r+n);if(a._camera.position[2]<t.mercatorZfromAltitude(h,c.lat))return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(c),a.setFreeCameraOptions(l);const u=t.MercatorCoordinate.fromLngLat(e),d=t.MercatorCoordinate.fromLngLat(i),m=a.pointRayIntersection(a.centerPoint,h),_=[(g=a.rayIntersectionCoordinate(m)).x,g.y,g.z];var g;const y=a.screenPointToMercatorRay(a.centerPoint);let x,v=0;do{const i=Math.floor(a.zoom),o=1<<i,s=Math.min(o*u.x,o*d.x),l=Math.min(o*u.y,o*d.y),c=Math.max(o*u.x,o*d.x),h=Math.max(o*u.y,o*d.y),m=new f([s,l,r],[c,h,n]),g=p.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,i);if(2!==m.intersects(g)){x&&(a._camera.position=t.scaleAndAdd([],a._camera.position,y.dir,-x),a._updateStateFromCamera());break}const v=t.sub([],a._camera.position,_);x=.5*t.length(v),a._camera.position=t.scaleAndAdd([],a._camera.position,y.dir,x);try{a._updateStateFromCamera()}catch(e){return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}_raycastElevationBox(e,i){const r=this.transform.elevation;if(!r)return;const n=new t.pointGeometry(e.x,i.y),o=new t.pointGeometry(i.x,e.y),s=r.pointCoordinate(e);if(!s)return;const a=r.pointCoordinate(i);if(!a)return;const l=r.pointCoordinate(n);if(!l)return;const c=r.pointCoordinate(o);if(!c)return;const h=new t.MercatorCoordinate(s[0],s[1]).toLngLat(),u=new t.MercatorCoordinate(a[0],a[1]).toLngLat(),d=new t.MercatorCoordinate(l[0],l[1]).toLngLat(),p=new t.MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(h.lng,Math.min(u.lng,Math.min(d.lng,p.lng))),m=Math.min(h.lat,Math.min(u.lat,Math.min(d.lat,p.lat))),_=Math.max(h.lng,Math.max(u.lng,Math.max(d.lng,p.lng))),g=Math.max(h.lat,Math.max(u.lat,Math.max(d.lat,p.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),x=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new t.LngLat(f,m),maxLngLat:new t.LngLat(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(e,i,r,n,o){let s,a,l,c;const h=t.pointGeometry.convert(e),u=t.pointGeometry.convert(i),d=this._raycastElevationBox(h,u);if(d)s=d.minLngLat,a=d.maxLngLat,l=d.minAltitude,c=d.maxAltitude;else{if(this.transform.isHorizonVisibleForPoints(h,u))return this;s=this.transform.pointLocation(h),a=this.transform.pointLocation(u)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(t.pointGeometry.convert(e)),this.transform.pointLocation(t.pointGeometry.convert(i)),r,n):this._cameraForBox(s,a,l,c,n),n,o)}_fitInternal(e,i,r){return e?(delete(i=t.extend(e,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(e,i){this.stop();const r=this.transform;let n=!1,o=!1,s=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(n=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=t.LngLat.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(o=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(s=!0,r.pitch=+e.pitch),null==e.padding||r.isPaddingEqual(e.padding)||(r.padding=e.padding),this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),n&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),o&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),s&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i))}getFreeCameraOptions(){return this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,i){this.stop();const r=this.transform,n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(e);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),a&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),c&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),l&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i)),this}easeTo(e,i){this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||!e.essential&&t.exported.prefersReducedMotion)&&(e.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?+e.zoom:n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:s,u="padding"in e?e.padding:r.padding,d=t.pointGeometry.convert(e.offset);let p=r.centerPoint.add(d);const f=r.pointLocation(p),m=t.LngLat.convert(e.center||f);this._normalizeCenter(m);const _=r.project(f),g=r.project(m).sub(_),y=r.zoomScale(l-n);let x,v;e.around&&(x=t.LngLat.convert(e.around),v=r.locationPoint(x));const b={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||l!==n,this._rotating=this._rotating||o!==c,this._pitching=this._pitching||h!==s,this._padding=!r.isPaddingEqual(u),this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,b),this._ease((e=>{if(this._zooming&&(r.zoom=t.number(n,l,e)),this._rotating&&(r.bearing=t.number(o,c,e)),this._pitching&&(r.pitch=t.number(s,h,e)),this._padding&&(r.interpolatePadding(a,u,e),p=r.centerPoint.add(d)),x)r.setLocationAtPoint(x,v);else{const t=r.zoomScale(r.zoom-n),i=l>n?Math.min(2,y):Math.max(.5,y),o=Math.pow(i,1-e),s=r.unproject(_.add(g.mult(e*o)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?s.wrap():s,p)}this._fireMoveEvents(i)}),(t=>{r.recenterOnTerrain(),this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:s,u="padding"in e?e.padding:r.padding,d=r.zoomScale(l-n),p=t.pointGeometry.convert(e.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),_=t.LngLat.convert(e.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=e.curve;const v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function E(t){const e=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}const A=E(0);let C=function(t){return I(A)/I(A+x*t)},M=function(t){return v*((I(A)*(S(e=A+x*t)/I(e))-S(A))/T)/w;var e},z=(E(1)-A)/x;if(Math.abs(w)<1e-6||!isFinite(z)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,i);const t=b<v?-1:1;z=Math.abs(Math.log(b/v))/x,M=function(){return 0},C=function(e){return Math.exp(t*x*e)}}return e.duration="duration"in e?+e.duration:1e3*z/("screenSpeed"in e?+e.screenSpeed/x:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==s,this._padding=!r.isPaddingEqual(u),this._prepareEase(i,!1),this._ease((e=>{const d=e*z,m=1/C(d);r.zoom=1===e?l:n+r.scaleZoom(m),this._rotating&&(r.bearing=t.number(o,c,e)),this._pitching&&(r.pitch=t.number(s,h,e)),this._padding&&(r.interpolatePadding(a,u,e),f=r.centerPoint.add(p));const x=1===e?_:r.unproject(g.add(y.mult(M(d))).mult(m));r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,f),r._updateCenterElevation(),this._fireMoveEvents(i)}),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)<r&&(e-=360),Math.abs(e+360-i)<r&&(e+=360),e}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}}class vn{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=o.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o.create("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){o.remove(this._container),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(t,e){const i=this._map._getUIString("AttributionControl."+e);t.title=i,t.setAttribute("aria-label",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const r=i.reduce(((t,e,r)=>(e.value&&(t+=`${e.key}=${e.value}${r<i.length-1?"&":""}`),t)),"?");e.href=`${t.config.FEEDBACK_URL}/${r}${this._map._hash?this._map._hash.getHashString(!0):""}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style._sourceCaches;for(const i in e){const r=e[i];if(r.used){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,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 bn{constructor(){t.bindAll(["_updateLogo"],this),t.bindAll(["_updateCompact"],this)}onAdd(t){this._map=t,this._container=o.create("div","mapboxgl-ctrl");const e=o.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){o.remove(this._container),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class wn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Tn(e,i,r){if(e=new t.LngLat(e.lng,e.lat),i){const n=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-r.center.lng)/360),a=r.locationPoint(e).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)<a&&(l||Math.abs(n.lng-r.center.lng)<s)?e=n:r.locationPoint(o).distSqr(i)<a&&(l||Math.abs(o.lng-r.center.lng)<s)&&(e=o)}for(;Math.abs(e.lng-r.center.lng)>180;){const t=r.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}const En={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Sn(t,e,i){const r=t.classList;for(const t in En)r.remove(`mapboxgl-${i}-anchor-${t}`);r.add(`mapboxgl-${i}-anchor-${e}`)}class In extends t.Evented{constructor(e,i){if(super(),(e instanceof t.window.HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,e&&e.element)this._element=e.element,this._offset=t.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=o.create("div"),this._element.setAttribute("aria-label","Map marker");const i=o.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",r+"px"),i.setAttributeNS(null,"width",n+"px"),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const s=o.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const a=o.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"fill-rule","nonzero");const l=o.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of c){const e=o.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const h=o.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=o.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=o.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=o.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=o.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=o.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const _=o.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#000000"),_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962");const g=o.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(_),m.appendChild(g),a.appendChild(l),a.appendChild(h),a.appendChild(d),a.appendChild(f),a.appendChild(m),i.appendChild(a),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=t.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),Sn(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),o.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_evaluateOpacity(){const t=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(t))return void this._clearFadeTimer();const e=this._map.unproject(t);let i=!1;if(this._map.getTerrain()){const t=this._map.getFreeCameraOptions();if(t.position){const r=t.position.toLngLat();i=r.distanceTo(e)<.9*r.distanceTo(this._lngLat)}}const r=(1-this._map._queryFogOpacity(e))*(i?.2:1);this._element.style.opacity=""+r,this._popup&&this._popup._setOpacity(""+r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(t){const e=this._map.transform;return!!t&&t.x>=0&&t.x<e.width&&t.y>=0&&t.y<e.height}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=Tn(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._transformedOffset());let e="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?e=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(e=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),this._map._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&o.setTransform(this._element,`${En[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${e}`),!this._map.getTerrain()&&!this._map.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const t=this._map.transform,e=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&e._rotate(t.angle),"map"===this._pitchAlignment&&(e.y*=Math.cos(t._pitch)),e}getOffset(){return this._offset}setOffset(e){return this._offset=t.pointGeometry.convert(e),this._update(),this}_onMove(e){if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class An{constructor(t){this.jumpTo(t)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const i=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const Cn={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm"},{HTMLImageElement:Mn,HTMLElement:zn,ImageBitmap:kn}=t.window,Pn={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,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function Dn(t){t.parentNode&&t.parentNode.removeChild(t)}const Ln={showCompass:!0,showZoom:!0,visualizePitch:!1};class Rn{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new jr({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new $r({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener(i,"mousedown",this.mousedown),o.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),o.addEventListener(i,"touchmove",this.touchmove),o.addEventListener(i,"touchend",this.touchend),o.addEventListener(i,"touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),o.disableDrag()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;o.removeEventListener(t,"mousedown",this.mousedown),o.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),o.removeEventListener(t,"touchmove",this.touchmove),o.removeEventListener(t,"touchend",this.touchend),o.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){o.enableDrag(),o.removeEventListener(t.window,"mousemove",this.mousemove),o.removeEventListener(t.window,"mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),o.mousePos(this.element,e)),o.addEventListener(t.window,"mousemove",this.mousemove),o.addEventListener(t.window,"mouseup",this.mouseup)}mousemove(t){this.move(t,o.mousePos(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const Bn={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Fn,On=0,Un=!1;const Vn={maxWidth:100,unit:"metric"};function Nn(t,e,i){const r=i&&i.maxWidth||100,n=t._container.clientHeight/2,o=t.unproject([0,n]),s=t.unproject([r,n]),a=o.distanceTo(s);if(i&&"imperial"===i.unit){const i=3.2808*a;i>5280?Gn(e,r,i/5280,t._getUIString("ScaleControl.Miles"),t):Gn(e,r,i,t._getUIString("ScaleControl.Feet"),t)}else i&&"nautical"===i.unit?Gn(e,r,a/1852,t._getUIString("ScaleControl.NauticalMiles"),t):a>=1e3?Gn(e,r,a/1e3,t._getUIString("ScaleControl.Kilometers"),t):Gn(e,r,a,t._getUIString("ScaleControl.Meters"),t)}function Gn(t,e,i,r,n){const o=function(t){const e=Math.pow(10,(""+Math.floor(t)).length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i),s=o/i;n._requestDomTask((()=>{t.style.width=e*s+"px",t.innerHTML=`${o}&nbsp;${r}`}))}const Zn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},qn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function jn(e){if(e){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));return{center:new t.pointGeometry(0,0),top:new t.pointGeometry(0,e),"top-left":new t.pointGeometry(i,i),"top-right":new t.pointGeometry(-i,i),bottom:new t.pointGeometry(0,-e),"bottom-left":new t.pointGeometry(i,-i),"bottom-right":new t.pointGeometry(-i,-i),left:new t.pointGeometry(e,0),right:new t.pointGeometry(-e,0)}}if(e instanceof t.pointGeometry||Array.isArray(e)){const i=t.pointGeometry.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.pointGeometry.convert(e.center||[0,0]),top:t.pointGeometry.convert(e.top||[0,0]),"top-left":t.pointGeometry.convert(e["top-left"]||[0,0]),"top-right":t.pointGeometry.convert(e["top-right"]||[0,0]),bottom:t.pointGeometry.convert(e.bottom||[0,0]),"bottom-left":t.pointGeometry.convert(e["bottom-left"]||[0,0]),"bottom-right":t.pointGeometry.convert(e["bottom-right"]||[0,0]),left:t.pointGeometry.convert(e.left||[0,0]),right:t.pointGeometry.convert(e.right||[0,0])}}return jn(new t.pointGeometry(0,0))}const $n={version:t.version,supported:e,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends xn{constructor(e){if(null!=(e=t.extend({},Pn,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new wr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._renderTaskQueue=new wn,this._domRenderTaskQueue=new wn,this._controls=[],this._markers=[],this._mapId=t.uniqueId(),this._locale=t.extend({},Cn,e.locale),this._clickTolerance=e.clickTolerance,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new An(0),this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof zn))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new yn(this,e),this._hash=e.hash&&new Tr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.attributionControl&&this.addControl(new vn({customAttribution:e.customAttribution})),this._logoControl=new bn,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(e.dataType+"data",e))})),this.on("dataloading",(e=>{this.fire(new t.Event(e.dataType+"dataloading",e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}resize(e){const i=this._containerDimensions(),r=i[0],n=i[1];this._resizeCanvas(r,n),this.transform.resize(r,n),this.painter.resize(r,n);const o=!this._moving;return o&&(this.stop(),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e))),this.fire(new t.Event("resize",e)),o&&this.fire(new t.Event("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.pointGeometry.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const o=this.getLayer(e)?this.queryRenderedFeatures(n.point,{layers:[e]}):[];o.length?r||(r=!0,i.call(this,new Pr(t,this,n.originalEvent,{features:o}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{(this.getLayer(e)?this.queryRenderedFeatures(n.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new Pr(t,this,n.originalEvent)))},o=e=>{r&&(r=!1,i.call(this,new Pr(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const n=this._delegatedListeners[t];for(let t=0;t<n.length;t++){const r=n[t];if(r.layer===e&&r.listener===i){for(const t in r.delegates)this.off(t,r.delegates[t]);return n.splice(t,1),this}}})(),this)}queryRenderedFeatures(e,i){return this.style?(void 0!==i||void 0===e||e instanceof t.pointGeometry||Array.isArray(e)||(i=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],i=i||{},this.transform)):[]}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(e,i){return!1!==(i=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(e,i))}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove(),delete this.style),t&&(this.style=new Ne(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ne(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.normalizeStyleURL(e),n=this._requestManager.transformRequest(r,t.ResourceType.Style);t.getJSON(n,((e,r)=>{e?this.fire(new t.ErrorEvent(e)):r&&this._updateDiff(r,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.warnOnce("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style._getSourceCaches(e);if(0!==i.length)return i.every((t=>t.loaded()));this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`)))}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof Mn||kn&&i instanceof kn){const{width:l,height:c,data:h}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},h),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else{if(void 0===i.width||void 0===i.height)return this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:l,height:c,data:h}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(h)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof Mn||kn&&i instanceof kn?t.exported.getImageData(i):i,{width:o,height:s,data:a}=n;return void 0===o||void 0===s?this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))):o!==r.data.width||s!==r.data.height?this.fire(new t.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(r.data.replace(a,!(i instanceof Mn||kn&&i instanceof kn)),void this.style.updateImage(e,r))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,r)=>{i(e,r instanceof Mn?t.exported.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}queryTerrainElevation(e,i){const r=this.transform.elevation;return r?(i=t.extend({},{exaggerated:!0},i),r.getAtPoint(t.MercatorCoordinate.fromLngLat(e),null,i.exaggerated)):null}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.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 t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=o.create("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=o.create("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=o.create("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const i=this._containerDimensions();this._resizeCanvas(i[0],i[1]);const r=this._controlContainer=o.create("div","mapboxgl-control-container",t),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{n[t]=o.create("div","mapboxgl-ctrl-"+t,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,i){const r=t.exported.devicePixelRatio||1;this._canvas.width=r*e,this._canvas.height=r*i,this._canvas.style.width=e+"px",this._canvas.style.height=i+"px"}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const i=t.extend({},e.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",i)||this._canvas.getContext("experimental-webgl",i);r?(t.storeAuthState(r,!0),this.painter=new dr(r,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.isMoving()&&this.loaded()?t():this._domRenderTaskQueue.add(t)}_render(e){let i;const r=this.painter.context.extTimerQuery,n=t.exported.now();this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i));let o=this._updateAverageElevation(n);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;let s=!1;const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=t.exported.now();this.style.zoomHistory.update(e,i);const r=new t.EvaluationParameters(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(s=!0,this._crossFadingFactor=n),this.style.update(r)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform)),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const e=t.exported.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const n=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:n}))}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||o;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(o=this._updateAverageElevation(n,!0)),o)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate()),this}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const n=Math.abs(e-r);if(n>1)this._averageElevation.easeTo(r,t,300);else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof bn&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.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/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(t),e.canvasCopies.map(n),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const n=t.length/4;for(let o=0;o<e.length;o++){const s=e[o];let a=0;for(let e=0;e<s.length;e+=4)s[e]===t[e]&&s[e+1]===t[e+1]&&s[e+2]===t[e+2]&&s[e+3]===t[e+3]&&(a+=1);r+=(i[o+2]-i[o+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),void 0!==t.window&&(t.window.removeEventListener("resize",this._onWindowResize,!1),t.window.removeEventListener("orientationchange",this._onWindowResize,!1),t.window.removeEventListener("online",this._onWindowOnline,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),Dn(this._canvasContainer),Dn(this._controlContainer),Dn(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),t.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new t.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=t.exported.frame((t=>{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},Ln,e),this._container=o.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),o.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),o.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=o.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Rn(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){o.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=o.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){const i=this._map._getUIString("NavigationControl."+e);t.title=i,t.setAttribute("aria-label",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({},Bn,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(e){var i;return this._map=e,this._container=o.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),i=this._setupUI,void 0!==Fn?i(Fn):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>{Fn="denied"!==t.state,i(Fn)})):(Fn=!!t.window.navigator.geolocation,i(Fn)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),o.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,On=0,Un=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,n=this._map.getBearing(),o=t.extend({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([100,t]),r=e.distanceTo(i)/100,n=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=n+"px",this._circleElement.style.height=n+"px"}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Un)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o.create("button","mapboxgl-ctrl-geolocate",this._container),o.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o.create("div","mapboxgl-user-location-dot"),this._userLocationDotMarker=new In(this._dotElement),this._circleElement=o.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new In({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}trigger(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":On--,Un=!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 t.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 t.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("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),On++,On>1?(e={maximumAge:6e5,timeout:0},Un=!0):(e=this.options.positionOptions,Un=!1),this._geolocationWatchID=t.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else t.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),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:vn,ScaleControl:class{constructor(e){this.options=t.extend({},Vn,e),t.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Nn(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=o.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){o.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,Nn(this._map,this._container,this.options)}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=o.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){o.remove(this._controlContainer),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o.create("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden",!0),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.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()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(Zn),e),t.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&o.remove(this._content),this._container&&(o.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const i=t.window.document.createDocumentFragment(),r=t.window.document.createElement("body");let n;for(r.innerHTML=e;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=o.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=o.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(t){this._update(t.point)}_onMouseMove(t){this._update(t.point)}_onDrag(t){this._update(t.point)}_update(t){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(this._container||(this._container=o.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=o.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((t=>this._container.classList.add(t))),this._trackPointer&&this._container.classList.add("mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Tn(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let i=this.options.anchor;const r=jn(this.options.offset);if(!i){const t=this._container.offsetWidth,n=this._container.offsetHeight;let o;o=e.y+r.bottom.y<n?["top"]:e.y>this._map.transform.height-n?["bottom"]:[],e.x<t/2?o.push("left"):e.x>this._map.transform.width-t/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}const n=e.add(r[i]).round();this._map._requestDomTask((()=>{this._container&&i&&(o.setTransform(this._container,`${En[i]} translate(${n.x}px,${n.y}px)`),Sn(this._container,i,"popup"))}))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(qn);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._content&&(this._content.style.opacity=t),this._tip&&(this._tip.style.opacity=t)}},Marker:In,Style:Ne,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.pointGeometry,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:vr,Evented:t.Evented,config:t.config,prewarm:function(){Rt().acquire(Pt)},clearPrewarmedResources:function(){const t=Lt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Pt),Lt=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 t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Dt.workerCount},set workerCount(t){Dt.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return $n})),i}));
//# sourceMappingURL=/sm/f059bf80335bb2c03163852fe54c7f15caaf32c682efbb25340bddd3042dbe9e.map