@mapcreator/mapcreator-gl 0.0.0-access-token.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.html +128 -0
- package/dist/lib/lib.js +2 -0
- package/dist/lib/lib.js.LICENSE.txt +6 -0
- package/dist/lib/lib.js.map +1 -0
- package/dist/lib/style.css +2 -0
- package/dist/lib/style.css.map +1 -0
- package/package.json +84 -0
- package/readme.md +29 -0
package/dist/lib/lib.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see lib.js.LICENSE.txt */
|
|
2
|
+
var t={31:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')},428:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},460:function(t,e,i){var r={"./da_DK/frElections2022.json":3988,"./da_DK/fullscreen.json":3743,"./da_DK/geoLocation.json":6028,"./da_DK/placeholder.json":31,"./da_DK/search.json":7550,"./da_DK/usElectionsFixedPopup.json":1554,"./da_DK/usElectionsUpdater.json":1803,"./de_DE/frElections2022.json":2554,"./de_DE/fullscreen.json":5513,"./de_DE/geoLocation.json":9134,"./de_DE/placeholder.json":4309,"./de_DE/search.json":7864,"./de_DE/usElectionsFixedPopup.json":2768,"./de_DE/usElectionsUpdater.json":1241,"./en_GB/frElections2022.json":1648,"./en_GB/fullscreen.json":4883,"./en_GB/geoLocation.json":6160,"./en_GB/placeholder.json":6915,"./en_GB/search.json":5794,"./en_GB/usElectionsFixedPopup.json":5158,"./en_GB/usElectionsUpdater.json":5055,"./es_ES/frElections2022.json":5508,"./es_ES/fullscreen.json":7919,"./es_ES/geoLocation.json":428,"./es_ES/placeholder.json":9983,"./es_ES/search.json":7694,"./es_ES/usElectionsFixedPopup.json":8130,"./es_ES/usElectionsUpdater.json":7915,"./fr_FR/frElections2022.json":2968,"./fr_FR/fullscreen.json":7435,"./fr_FR/geoLocation.json":8440,"./fr_FR/placeholder.json":7739,"./fr_FR/search.json":7242,"./fr_FR/usElectionsFixedPopup.json":3134,"./fr_FR/usElectionsUpdater.json":3655,"./it_IT/frElections2022.json":9510,"./it_IT/fullscreen.json":1053,"./it_IT/geoLocation.json":9842,"./it_IT/placeholder.json":4745,"./it_IT/search.json":4652,"./it_IT/usElectionsFixedPopup.json":6852,"./it_IT/usElectionsUpdater.json":5485,"./nl_NL/frElections2022.json":6140,"./nl_NL/fullscreen.json":2903,"./nl_NL/geoLocation.json":6532,"./nl_NL/placeholder.json":2199,"./nl_NL/search.json":6246,"./nl_NL/usElectionsFixedPopup.json":9034,"./nl_NL/usElectionsUpdater.json":1427};function n(t){var e=o(t);return i(e)}function o(t){if(!i.o(r,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r[t]}n.keys=function(){return Object.keys(r)},n.resolve=o,t.exports=n,n.id=460},1053:function(t){t.exports=JSON.parse('{"goBack":"Indietro","notice":"Usa due dita per muovere la mappa"}')},1241:function(t){t.exports=JSON.parse('{"loadingSettings":"Einstellungen werden geladen","errorLoadingSettings":"Fehler beim Laden der Einstellungen","loadCandidates":"Kandidat-Daten werden geladen","errorLoadingCandidates":"Fehler beim Laden der Kandidat-Daten","loadingResults":"Ergebnisse werden geladen","errorLoadingResults":"Fehler beim Laden der Ergebnisse","updatedOn":"Aktualisiert am {date} um {time}","checkingForData":"Neue Daten werden abgerufen in: {time}"}')},1427:function(t){t.exports=JSON.parse('{"loadingSettings":"Instellingen aan het laden","errorLoadingSettings":"Fout bij het laden van de instellingen","loadCandidates":"Kandidaat data aan het laden","errorLoadingCandidates":"Fout bij het laden van kandidaat data","loadingResults":"Resultaten aan het laden","errorLoadingResults":"Fout bij het laden van de resultaten","updatedOn":"Geüpdatet op {date} om {time}","checkingForData":"Controleren op nieuwe data over: {time}"}')},1554:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Stemmer","reporting":"{percentage}% optalt","ev":"VM","electoralVotes":"Valgmænd","unknown":"Ukendt","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},1648:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for { interpolate }","allResults":"All results","candidateList":"Candidate list"}')},1803:function(t){t.exports=JSON.parse('{"loadingSettings":"Henter indstillinger","errorLoadingSettings":"Fejl i indstillinger","loadCandidates":"Henter data om kandidat","errorLoadingCandidates":"Fejl i kandidatens data","loadingResults":"Henter resultat","errorLoadingResults":"Fejl i resultater","updatedOn":"Opdateret {date} kl. {time}","checkingForData":"Opdaterer resultat om: {time}"}')},2199:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')},2264:function(t){t.exports=function(){var t={},e={};function i(i,r,n){if(e[i]=n,"index"===i){var o="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",s={};return e.shared(s),e.index(t,s),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),t}}return i("shared",["exports"],(function(t){function e(t,e,i,r){return new(i||(i=Promise))((function(n,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n;function o(){if(n)return r;function t(t,e){this.x=t,this.y=e}return n=1,r=t,t.prototype={clone:function(){return new t(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}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},r}"function"==typeof SuppressedError&&SuppressedError;var s,a,l=i(o()),c=function(){if(a)return s;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return a=1,s=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},s}(),h=i(c);let u,d;function p(){return null==u&&(u="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),u}function f(){if(null==d&&(d=!1,p())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<t*t;i++){const r=4*i;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%t,Math.floor(i/t),1,1)}const i=e.getImageData(0,0,t,t).data;for(let e=0;e<t*t*4;e++)if(e%4!=3&&i[e]!==e){d=!0;break}}}return d||!1}var m=1e-6,g="undefined"!=typeof Float32Array?Float32Array:Array;function _(){var t=new g(9);return g!=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 y(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 x(){var t=new g(3);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function v(t){return Math.hypot(t[0],t[1],t[2])}function b(t,e,i){var r=new g(3);return r[0]=t,r[1]=e,r[2]=i,r}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var w,T=v;function S(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 P(){var t=new g(4);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function M(){var t=new g(2);return g!=Float32Array&&(t[0]=0,t[1]=0),t}function I(t,e){var i=new g(2);return i[0]=t,i[1]=e,i}x(),w=new g(4),g!=Float32Array&&(w[0]=0,w[1]=0,w[2]=0,w[3]=0),x(),b(1,0,0),b(0,1,0),P(),P(),_(),M();const C=8192;function A(t,e,i,r){return e*(C/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))*2**r}function E(t,e){return(t%e+e)%e}function k(t,e,i){return t*(1-i)+e*i}function z(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 L(t,e,i,r){const n=new h(t,e,i,r);return t=>n.solve(t)}const D=L(.25,.1,.25,1);function R(t,e,i){return Math.min(i,Math.max(e,t))}function F(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function B(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let O=1;function j(t,e,i){const r={};for(const i in t)r[i]=e.call(this,t[i],i,t);return r}function N(t,e,i){const r={};for(const i in t)e.call(this,t[i],i,t)&&(r[i]=t[i]);return r}function V(t){return Array.isArray(t)?t.map(V):"object"==typeof t&&t?j(t,V):t}const U={};function Z(t){U[t]||("undefined"!=typeof console&&console.warn(t),U[t]=!0)}function $(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function G(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function W(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const H="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function X(t,i,r,n,o){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const s=null==e?void 0:e.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(n*o*4);if(yield e.copyTo(l,function(t,e,i,r,n){const o=4*Math.max(1,0),s=(Math.max(0,i)-i)*r*4+o,a=4*r,l=Math.max(0,e),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+n)-c},layout:[{offset:s,stride:a}]}}(t,i,r,n,o)),a)for(let t=0;t<l.length;t+=4){const e=l[t];l[t]=l[t+2],l[t+2]=e}return l}finally{e.close()}}))}let K,Y;function J(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function Q(t){return t/Math.PI*180}const tt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},et={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},it="AbortError";function rt(){return new Error(it)}const nt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ot(t){return nt.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const st="global-dispatcher";class at extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const lt=()=>G(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(t,i){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=ot(t.url);if(e)return e(t,i);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:st},i)}if(!(/^file:/.test(r=t.url)||/^file:/.test(lt())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,i){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:lt(),signal:i.signal});let r,n;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{r=yield fetch(e)}catch(e){throw new at(0,e.message,t.url,new Blob)}if(!r.ok){const e=yield r.blob();throw new at(r.status,r.statusText,t.url,e)}n="arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text();const o=yield n;if(i.signal.aborted)throw rt();return{data:o,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}}))}(t,i);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:st},i)}var r;return function(t,e){return new Promise(((i,r)=>{var n;const o=new XMLHttpRequest;o.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(o.responseType="arraybuffer");for(const e in t.headers)o.setRequestHeader(e,t.headers[e]);"json"===t.type&&(o.responseType="text",(null===(n=t.headers)||void 0===n?void 0:n.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===t.credentials,o.onerror=()=>{r(new Error(o.statusText))},o.onload=()=>{if(!e.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let e=o.response;if("json"===t.type)try{e=JSON.parse(o.response)}catch(t){return void r(t)}i({data:e,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const e=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});r(new at(o.status,o.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{o.abort(),r(rt())})),o.send(t.body)}))}(t,i)};function ht(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function ut(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function dt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class pt{constructor(t,e={}){B(this,e),this.type=t}}class ft extends pt{constructor(t,e={}){super("error",B({error:t},e))}}class mt{on(t,e){return this._listeners=this._listeners||{},ut(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return dt(t,e,this._listeners),dt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ut(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new pt(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)dt(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(B(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof ft&&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 gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},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:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,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:{}},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_background:{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"]},"property-type":"data-constant"},"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",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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:{},"viewport-glyph":{},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"]},"property-type":"data-constant"},"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-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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":{}}},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},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}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],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"]},"property-type":"cross-faded"},"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"}},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"}}};const _t=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function yt(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return _t.forEach((t=>{t in e&&(i[t]=e[t])})),i}function xt(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(!xt(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(!xt(t[i],e[i]))return!1;return!0}return t===e}function vt(t,e){t.push(e)}function bt(t,e,i){vt(i,{command:"addSource",args:[t,e[t]]})}function wt(t,e,i){vt(e,{command:"removeSource",args:[t]}),i[t]=!0}function Tt(t,e,i,r){wt(t,i,r),bt(t,e,i)}function St(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!xt(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!xt(t[i][r],e[i][r]))return!1;return!0}function Pt(t,e,i,r,n,o){t=t||{},e=e||{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(xt(t[s],e[s])||i.push({command:o,args:[r,s,e[s],n]}));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(xt(t[s],e[s])||i.push({command:o,args:[r,s,e[s],n]}))}function Mt(t){return t.id}function It(t,e){return t[e.id]=e,t}class Ct{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function At(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Et extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class kt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new kt(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 zt={kind:"null"},Lt={kind:"number"},Dt={kind:"string"},Rt={kind:"boolean"},Ft={kind:"color"},Bt={kind:"projectionDefinition"},Ot={kind:"object"},jt={kind:"value"},Nt={kind:"collator"},Vt={kind:"formatted"},Ut={kind:"padding"},Zt={kind:"resolvedImage"},$t={kind:"variableAnchorOffsetCollection"};function Gt(t,e){return{kind:"array",itemType:t,N:e}}function qt(t){if("array"===t.kind){const e=qt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Wt=[zt,Lt,Dt,Rt,Ft,Bt,Vt,Ot,Gt(jt),Ut,Zt,$t];function Ht(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ht(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 Wt)if(!Ht(t,e))return null}return`Expected ${qt(t)} but found ${qt(e)} instead.`}function Xt(t,e){return e.some((e=>e.kind===t.kind))}function Kt(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 Yt(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Jt=.96422,Qt=.82521,te=4/29,ee=6/29,ie=3*ee*ee,re=ee*ee*ee,ne=Math.PI/180,oe=180/Math.PI;function se(t){return(t%=360)<0&&(t+=360),t}function ae([t,e,i,r]){let n,o;const s=ce((.2225045*(t=le(t))+.7168786*(e=le(e))+.0606169*(i=le(i)))/1);t===e&&e===i?n=o=s:(n=ce((.4360747*t+.3850649*e+.1430804*i)/Jt),o=ce((.0139322*t+.0971045*e+.7141733*i)/Qt));const a=116*s-16;return[a<0?0:a,500*(n-s),200*(s-o),r]}function le(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ce(t){return t>re?Math.pow(t,1/3):t/ie+te}function he([t,e,i,r]){let n=(t+16)/116,o=isNaN(e)?n:n+e/500,s=isNaN(i)?n:n-i/200;return n=1*de(n),o=Jt*de(o),s=Qt*de(s),[ue(3.1338561*o-1.6168667*n-.4906146*s),ue(-.9787684*o+1.9161415*n+.033454*s),ue(.0719453*o-.2289914*n+1.4052427*s),r]}function ue(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function de(t){return t>ee?t*t*t:ie*(t-te)}function pe(t){return parseInt(t.padEnd(2,t),16)/255}function fe(t,e){return me(e?t/100:t,0,1)}function me(t,e,i){return Math.min(Math.max(e,t),i)}function ge(t){return!t.some(Number.isNaN)}const _e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function ye(t,e,i){return t+i*(e-t)}function xe(t,e,i){return t.map(((t,r)=>ye(t,e[r],i)))}class ve{constructor(t,e,i,r=1,n=!0){this.r=t,this.g=e,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static parse(t){if(t instanceof ve)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=_e[t];if(e){const[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[pe(t.slice(i,i+=e)),pe(t.slice(i,i+=e)),pe(t.slice(i,i+=e)),pe(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,r,n,o,s,a,l,c,h,u,d]=e,p=[n||" ",a||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[r,s,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[me(+i/e,0,1),me(+o/e,0,1),me(+l/e,0,1),u?fe(+u,d):1];if(ge(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,r,n,o,s,a,l,c]=i,h=[r||" ",o||" ",a].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,me(+n,0,100),me(+s,0,100),l?fe(+l,c):1];if(ge(t))return function([t,e,i,r]){function n(r){const n=(r+t/30)%12,o=e*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(n-3,9-n,1))}return t=se(t),e/=100,i/=100,[n(0),n(8),n(4),r]}(t)}}}(t);return e?new ve(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[t/n,e/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,r,n]=ae(t),o=Math.sqrt(i*i+r*r);return[Math.round(1e4*o)?se(Math.atan2(r,i)*oe):NaN,o,e,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ae(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}static interpolate(t,e,i,r="rgb"){switch(r){case"rgb":{const[r,n,o,s]=xe(t.rgb,e.rgb,i);return new ve(r,n,o,s,!1)}case"hcl":{const[r,n,o,s]=t.hcl,[a,l,c,h]=e.hcl;let u,d;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?u=NaN:(u=a,1!==o&&0!==o||(d=l)):(u=r,1!==c&&0!==c||(d=n));else{let t=a-r;a>r&&t>180?t-=360:a<r&&r-a>180&&(t+=360),u=r+i*t}const[p,f,m,g]=function([t,e,i,r]){return t=isNaN(t)?0:t*ne,he([i,Math.cos(t)*e,Math.sin(t)*e,r])}([u,null!=d?d:ye(n,l,i),ye(o,c,i),ye(s,h,i)]);return new ve(p,f,m,g,!1)}case"lab":{const[r,n,o,s]=he(xe(t.lab,e.lab,i));return new ve(r,n,o,s,!1)}}}}ve.black=new ve(0,0,0,1),ve.white=new ve(1,1,1,1),ve.transparent=new ve(0,0,0,0),ve.red=new ve(1,0,0,1);class be{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}}const we=["bottom","center","top"];class Te{constructor(t,e,i,r,n,o){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=o}}class Se{constructor(t){this.sections=t}static fromString(t){return new Se([new Te(t,null,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 Se?t:Se.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Pe{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Pe)return t;if("number"==typeof t)return new Pe([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Pe(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new Pe(xe(t.values,e.values,i))}}class Me{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Ie=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ce{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ce)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){const i=t[e],r=t[e+1];if("string"!=typeof i||!Ie.has(i))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new Ce(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){const r=t.values,n=e.values;if(r.length!==n.length)throw new Me(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const o=[];for(let t=0;t<r.length;t+=2){if(r[t]!==n[t])throw new Me(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${r[t]}, to[${t}]: ${n[t]}`);o.push(r[t]);const[e,s]=r[t+1],[a,l]=n[t+1];o.push([ye(e,a,i),ye(s,l,i)])}return new Ce(o)}}class Ae{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ae({name:t,available:!1}):null}}class Ee{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}static interpolate(t,e,i){return new Ee(t,e,i)}static parse(t){return t instanceof Ee?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new Ee(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new Ee(t.from,t.to,t.transition):"string"==typeof t?new Ee(t,t,1):void 0}}function ke(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 ze(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ee||t instanceof ve||t instanceof be||t instanceof Se||t instanceof Pe||t instanceof Ce||t instanceof Ae)return!0;if(Array.isArray(t)){for(const e of t)if(!ze(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!ze(t[e]))return!1;return!0}return!1}function Le(t){if(null===t)return zt;if("string"==typeof t)return Dt;if("boolean"==typeof t)return Rt;if("number"==typeof t)return Lt;if(t instanceof ve)return Ft;if(t instanceof Ee)return Bt;if(t instanceof be)return Nt;if(t instanceof Se)return Vt;if(t instanceof Pe)return Ut;if(t instanceof Ce)return $t;if(t instanceof Ae)return Zt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Le(e);if(i){if(i===t)continue;i=jt;break}i=t}return Gt(i||jt,e)}return Ot}function De(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ve||t instanceof Ee||t instanceof Se||t instanceof Pe||t instanceof Ce||t instanceof Ae?t.toString():JSON.stringify(t)}class Re{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(!ze(t[1]))return e.error("invalid value");const i=t[1];let r=Le(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 Re(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Fe={string:Dt,number:Lt,boolean:Rt,object:Ot};class Be{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 Fe)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=Fe[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=Gt(n,o)}else{if(!Fe[n])throw new Error(`Types doesn't contain name = ${n}`);i=Fe[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 Be(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Ht(this.type,Le(i)))return i;if(e===this.args.length-1)throw new Me(`Expected value to be of type ${qt(this.type)}, but found ${qt(Le(i))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Oe={"to-boolean":Rt,"to-color":Ft,"to-number":Lt,"to-string":Dt};class je{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(!Oe[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Oe[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 je(r,n)}evaluate(t){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(t));case"color":{let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof ve)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 rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ke(e[0],e[1],e[2],e[3]),!i))return new ve(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Me(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const r=Pe.parse(e);if(r)return r}throw new Me(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const r=Ce.parse(e);if(r)return r}throw new Me(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{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 Me(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Se.fromString(De(this.args[0].evaluate(t)));case"resolvedImage":return Ae.fromString(De(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return De(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ne=["Unknown","Point","LineString","Polygon"];class Ve{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?Ne[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]=ve.parse(t)),e}}class Ue{constructor(t,e,i=[],r,n=new kt,o=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=o,this.expectedType=r,this._isConstant=e}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 Be(e,[t]):"coerce"===i?new je(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("projectionDefinition"!==t.kind||"string"!==n.kind&&"array"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind)if("padding"!==t.kind||"value"!==n.kind&&"number"!==n.kind&&"array"!==n.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==n.kind&&"array"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Re)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const e=new Ve;try{r=new Re(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 Ue(this.registry,this._isConstant,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Et(i,t))}checkSubtype(t,e){const i=Ht(t,e);return i&&this.error(i),i}}class Ze{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 Ze(i,r):null}outputDefined(){return this.result.outputDefined()}}class $e{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 $e(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}}class Ge{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,Lt),r=e.parse(t[2],2,Gt(e.expectedType||jt));return i&&r?new Ge(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Me(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new Me(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Me(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class qe{constructor(t,e){this.type=Rt,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?Xt(i.type,[Rt,Dt,Lt,zt,jt])?new qe(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Kt(e,["boolean","string","number","null"]))throw new Me(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Le(e))} instead.`);if(!Kt(i,["string","array"]))throw new Me(`Expected second argument to be of type array or string, but found ${qt(Le(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class We{constructor(t,e,i){this.type=Lt,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(!Xt(i.type,[Rt,Dt,Lt,zt,jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Lt);return n?new We(i,r,n):null}return new We(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Kt(e,["boolean","string","number","null"]))throw new Me(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Le(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),Kt(i,["string"])){const t=i.indexOf(e,r);return-1===t?-1:[...i.slice(0,t)].length}if(Kt(i,["array"]))return i.indexOf(e,r);throw new Me(`Expected second argument to be of type array or string, but found ${qt(Le(i))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class He{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,Le(t)))return null}else i=Le(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 He(i,r,s,n,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(Le(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()}}class Xe{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,Rt);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);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new Xe(i,r,n)}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()}}class Ke{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,Lt);if(!i||!r)return null;if(!Xt(i.type,[Gt(jt),Dt,jt]))return e.error(`Expected first argument to be of type array or string, but found ${qt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Lt);return n?new Ke(i.type,i,r,n):null}return new Ke(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),Kt(e,["string"]))return[...e].slice(i,r).join("");if(Kt(e,["array"]))return e.slice(i,r);throw new Me(`Expected first argument to be of type array or string, but found ${qt(Le(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Ye(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 Me("Input is not a number.");s=a-1}return 0}class Je{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,Lt);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 Je(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[Ye(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()))}}function Qe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ti,ei,ii=function(){if(ei)return ti;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return ei=1,ti=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},ti}(),ri=Qe(ii);class ni{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,i,r){let n=0;if("exponential"===t.name)n=oi(e,t.base,i,r);else if("linear"===t.name)n=oi(e,1,i,r);else if("cubic-bezier"===t.name){const o=t.controlPoints;n=new ri(o[0],o[1],o[2],o[3]).solve(oi(e,1,i,r))}return n}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,Lt),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Ft: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 Yt(a,Lt)||Yt(a,Bt)||Yt(a,Ft)||Yt(a,Ut)||Yt(a,$t)||Yt(a,Gt(Lt))?new ni(a,i,r,n,s):e.error(`Type ${qt(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=Ye(e,r),s=ni.interpolationFactor(this.interpolation,r,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return ye(a,l,s);case"color":return ve.interpolate(a,l,s);case"padding":return Pe.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Ce.interpolate(a,l,s);case"array":return xe(a,l,s);case"projectionDefinition":return Ee.interpolate(a,l,s)}case"interpolate-hcl":return ve.interpolate(a,l,s,"hcl");case"interpolate-lab":return ve.interpolate(a,l,s,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function oi(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)}const si={color:ve.interpolate,number:ye,padding:Pe.interpolate,variableAnchorOffsetCollection:Ce.interpolate,array:xe};class ai{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=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)}if(!i)throw new Error("No output type");const o=r&&n.some((t=>Ht(r,t.type)));return new ai(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 Ae&&!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()))}}function li(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 ci(t,e,i,r){return 0===r.compare(e,i)}function hi(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=Rt,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(!li(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${qt(o.type)}'.`);let s=e.parse(t[2],2,jt);if(!s)return null;if(!li(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${qt(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${qt(o.type)}' and '${qt(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Be(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Be(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,Nt),!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=Le(o),i=Le(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Me(`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=Le(o),i=Le(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}}}const ui=hi("==",(function(t,e,i){return e===i}),ci),di=hi("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!ci(0,e,i,r)})),pi=hi("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),fi=hi(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),mi=hi("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),gi=hi(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class _i{constructor(t,e,i){this.type=Nt,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,Rt);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Rt);if(!n)return null;let o=null;return i.locale&&(o=e.parse(i.locale,1,Dt),!o)?null:new _i(r,n,o)}evaluate(t){return new be(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}}class yi{constructor(t,e,i,r,n){this.type=Dt,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,Lt);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,Dt),!n))return null;let o=null;if(r.currency&&(o=e.parse(r.currency,1,Dt),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,Lt),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,Lt),!a)?null:new yi(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}}class xi{constructor(t){this.type=Vt,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,Lt),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,Gt(Dt)),!i))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,Ft),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!we.includes(o["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=e.parse(o["vertical-align"],1,Dt),!a)return null}const l=r[r.length-1];l.scale=t,l.font=i,l.textColor=s,l.verticalAlign=a}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,verticalAlign:null})}}return new xi(r)}evaluate(t){return new Se(this.sections.map((e=>{const i=e.content.evaluate(t);return Le(i)===Zt?new Te("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Te(De(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.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),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}}class vi{constructor(t){this.type=Zt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Dt);return i?new vi(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Ae.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class bi{constructor(t){this.type=Lt,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 ${qt(i.type)} instead.`):new bi(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 Me(`Expected value to be of type string or array, but found ${qt(Le(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const wi=8192;function Ti(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*wi),Math.round(r*n*wi)]}function Si(t,e){const i=Math.pow(2,e.z);return[(n=(t[0]/wi+e.x)/i,360*n-180),(r=(t[1]/wi+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function Pi(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 Mi(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Ii(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 Ci(t,e,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-n[1]*o[0]&&!(!Di(t,e,i,r)||!Di(i,r,t,e));var n,o}function Ai(t,e,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(Ci(t,e,r[i],r[i+1]))return!0;return!1}function Ei(t,e,i=!1){let r=!1;for(const a of e)for(let e=0;e<a.length-1;e++){if(Ii(t,a[e],a[e+1]))return i;(o=a[e])[1]>(n=t)[1]!=(s=a[e+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}var n,o,s;return r}function ki(t,e){for(const i of e)if(Ei(t,i))return!0;return!1}function zi(t,e){for(const i of t)if(!Ei(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Ai(t[i],t[i+1],e))return!1;return!0}function Li(t,e){for(const i of e)if(zi(t,i))return!0;return!1}function Di(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 Ri(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=Ti(t[n][r],i);Pi(e,s),o.push(s)}r.push(o)}return r}function Fi(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=Ri(t[n],e,i);r.push(o)}return r}function Bi(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}Pi(e,t)}function Oi(t,e,i,r){const n=Math.pow(2,r.z)*wi,o=[r.x*wi,r.y*wi],s=[];for(const r of t)for(const t of r){const r=[t.x+o[0],t.y+o[1]];Bi(r,e,i,n),s.push(r)}return s}function ji(t,e,i,r){const n=Math.pow(2,r.z)*wi,o=[r.x*wi,r.y*wi],s=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Pi(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)Bi(r,e,i,n)}var a;return s}class Ni{constructor(t,e){this.type=Rt,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(ze(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const i of e.features){const{type:e,coordinates:r}=i.geometry;"Polygon"===e&&t.push(r),"MultiPolygon"===e&&t.push(...r)}if(t.length)return new Ni(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Ni(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Ni(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=Ri(e.coordinates,r,n),s=Oi(t.geometry(),i,r,n);if(!Mi(i,r))return!1;for(const t of s)if(!Ei(t,o))return!1}if("MultiPolygon"===e.type){const o=Fi(e.coordinates,r,n),s=Oi(t.geometry(),i,r,n);if(!Mi(i,r))return!1;for(const t of s)if(!ki(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=Ri(e.coordinates,r,n),s=ji(t.geometry(),i,r,n);if(!Mi(i,r))return!1;for(const t of s)if(!zi(t,o))return!1}if("MultiPolygon"===e.type){const o=Fi(e.coordinates,r,n),s=ji(t.geometry(),i,r,n);if(!Mi(i,r))return!1;for(const t of s)if(!Li(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Vi=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){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._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--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);const o=r+1;if(o<this.length&&i(e[o],e[r])<0&&(r=o),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}};function Ui(t,e,i=0,r=t.length-1,n=$i){for(;r>i;){if(r-i>600){const 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);Ui(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(r,Math.floor(e+(o-s)*l/o+c)),n)}const o=t[e];let s=i,a=r;for(Zi(t,i,e),n(t[r],o)>0&&Zi(t,i,r);s<a;){for(Zi(t,s,a),s++,a--;n(t[s],o)<0;)s++;for(;n(t[a],o)>0;)a--}0===n(t[i],o)?Zi(t,i,a):(a++,Zi(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Zi(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function $i(t,e){return t<e?-1:t>e?1:0}function Gi(t,e){if(t.length<=1)return[t];const i=[];let r,n;for(const e of t){const t=Wi(e);0!==t&&(e.area=Math.abs(t),void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e]):r.push(e))}if(r&&i.push(r),e>1)for(let t=0;t<i.length;t++)i[t].length<=e||(Ui(i[t],e,1,i[t].length-1,qi),i[t]=i[t].slice(0,e));return i}function qi(t,e){return e.area-t.area}function Wi(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}const Hi=1/298.257223563,Xi=Hi*(2-Hi),Ki=Math.PI/180;class Yi{constructor(t){const e=6378.137*Ki*1e3,i=Math.cos(t*Ki),r=1/(1-Xi*(1-i*i)),n=Math.sqrt(r);this.kx=e*n*i,this.ky=e*n*r*(1-Xi)}distance(t,e){const i=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(t,e){let i,r,n,o,s=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],c=t[a][1],h=this.wrap(t[a+1][0]-l)*this.kx,u=(t[a+1][1]-c)*this.ky,d=0;0===h&&0===u||(d=(this.wrap(e[0]-l)*this.kx*h+(e[1]-c)*this.ky*u)/(h*h+u*u),d>1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=this.wrap(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;p<s&&(s=p,i=l,r=c,n=a,o=d)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,o))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function Ji(t,e){return e[0]-t[0]}function Qi(t){return t[1]-t[0]+1}function tr(t,e){return t[1]>=t[0]&&t[1]<e}function er(t,e){if(t[0]>t[1])return[null,null];const i=Qi(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];const r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function ir(t,e){if(!tr(e,t.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)Pi(i,t[r]);return i}function rr(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const t of i)Pi(e,t);return e}function nr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function or(t,e,i){if(!nr(t)||!nr(e))return NaN;let r=0,n=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(n=t[1]-e[3]),t[3]<e[1]&&(n=e[1]-t[3]),i.distance([0,0],[r,n])}function sr(t,e,i){const r=i.pointOnLine(e,t);return i.distance(t,r.point)}function ar(t,e,i,r,n){const o=Math.min(sr(t,[i,r],n),sr(e,[i,r],n)),s=Math.min(sr(i,[t,e],n),sr(r,[t,e],n));return Math.min(o,s)}function lr(t,e,i,r,n){if(!tr(e,t.length)||!tr(r,i.length))return 1/0;let o=1/0;for(let s=e[0];s<e[1];++s){const e=t[s],a=t[s+1];for(let t=r[0];t<r[1];++t){const r=i[t],s=i[t+1];if(Ci(e,a,r,s))return 0;o=Math.min(o,ar(e,a,r,s,n))}}return o}function cr(t,e,i,r,n){if(!tr(e,t.length)||!tr(r,i.length))return NaN;let o=1/0;for(let s=e[0];s<=e[1];++s)for(let e=r[0];e<=r[1];++e)if(o=Math.min(o,n.distance(t[s],i[e])),0===o)return o;return o}function hr(t,e,i){if(Ei(t,e,!0))return 0;let r=1/0;for(const n of e){const e=n[0],o=n[n.length-1];if(e!==o&&(r=Math.min(r,sr(t,[o,e],i)),0===r))return r;const s=i.pointOnLine(n,t);if(r=Math.min(r,i.distance(t,s.point)),0===r)return r}return r}function ur(t,e,i,r){if(!tr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Ei(t[r],i,!0))return 0;let n=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],s=t[o+1];for(const t of i)for(let i=0,o=t.length,a=o-1;i<o;a=i++){const o=t[a],l=t[i];if(Ci(e,s,o,l))return 0;n=Math.min(n,ar(e,s,o,l,r))}}return n}function dr(t,e){for(const i of t)for(const t of i)if(Ei(t,e,!0))return!0;return!1}function pr(t,e,i,r=1/0){const n=rr(t),o=rr(e);if(r!==1/0&&or(n,o,i)>=r)return r;if(Mi(n,o)){if(dr(t,e))return 0}else if(dr(e,t))return 0;let s=1/0;for(const r of t)for(let t=0,n=r.length,o=n-1;t<n;o=t++){const n=r[o],a=r[t];for(const t of e)for(let e=0,r=t.length,o=r-1;e<r;o=e++){const r=t[o],l=t[e];if(Ci(n,a,r,l))return 0;s=Math.min(s,ar(n,a,r,l,i))}}return s}function fr(t,e,i,r,n,o){if(!o)return;const s=or(ir(r,o),n,i);s<e&&t.push([s,o,[0,0]])}function mr(t,e,i,r,n,o,s){if(!o||!s)return;const a=or(ir(r,o),ir(n,s),i);a<e&&t.push([a,o,s])}function gr(t,e,i,r,n=1/0){let o=Math.min(r.distance(t[0],i[0][0]),n);if(0===o)return o;const s=new Vi([[0,[0,t.length-1],[0,0]]],Ji),a=rr(i);for(;s.length>0;){const n=s.pop();if(n[0]>=o)continue;const l=n[1],c=e?50:100;if(Qi(l)<=c){if(!tr(l,t.length))return NaN;if(e){const e=ur(t,l,i,r);if(isNaN(e)||0===e)return e;o=Math.min(o,e)}else for(let e=l[0];e<=l[1];++e){const n=hr(t[e],i,r);if(o=Math.min(o,n),0===o)return 0}}else{const i=er(l,e);fr(s,o,r,t,a,i[0]),fr(s,o,r,t,a,i[1])}}return o}function _r(t,e,i,r,n,o=1/0){let s=Math.min(o,n.distance(t[0],i[0]));if(0===s)return s;const a=new Vi([[0,[0,t.length-1],[0,i.length-1]]],Ji);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],h=e?50:100,u=r?50:100;if(Qi(l)<=h&&Qi(c)<=u){if(!tr(l,t.length)&&tr(c,i.length))return NaN;let o;if(e&&r)o=lr(t,l,i,c,n),s=Math.min(s,o);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(o=sr(i[t],e,n),s=Math.min(s,o),0===s)return s}else if(!e&&r){const e=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=sr(t[i],e,n),s=Math.min(s,o),0===s)return s}else o=cr(t,l,i,c,n),s=Math.min(s,o)}else{const o=er(l,e),h=er(c,r);mr(a,s,n,t,i,o[0],h[0]),mr(a,s,n,t,i,o[0],h[1]),mr(a,s,n,t,i,o[1],h[0]),mr(a,s,n,t,i,o[1],h[1])}}return s}function yr(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class xr{constructor(t,e){this.type=Lt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ze(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new xr(e,e.features.map((t=>yr(t.geometry))).flat());if("Feature"===e.type)return new xr(e,yr(e.geometry));if("type"in e&&"coordinates"in e)return new xr(e,yr(e))}return e.error("'distance' 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=t.geometry(),r=i.flat().map((e=>Si([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const n=new Yi(r[0][1]);let o=1/0;for(const t of e){switch(t.type){case"Point":o=Math.min(o,_r(r,!1,[t.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,_r(r,!1,t.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,gr(r,!1,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map((e=>Si([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const n=new Yi(r[0][1]);let o=1/0;for(const t of e){switch(t.type){case"Point":o=Math.min(o,_r(r,!0,[t.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,_r(r,!0,t.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,gr(r,!0,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const i=t.geometry();if(0===i.length||0===i[0].length)return NaN;const r=Gi(i,0).map((e=>e.map((e=>e.map((e=>Si([e.x,e.y],t.canonical))))))),n=new Yi(r[0][0][0][1]);let o=1/0;for(const t of e)for(const e of r){switch(t.type){case"Point":o=Math.min(o,gr([t.coordinates],!1,e,n,o));break;case"LineString":o=Math.min(o,gr(t.coordinates,!0,e,n,o));break;case"Polygon":o=Math.min(o,pr(e,t.coordinates,n,o))}if(0===o)return o}return o}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const vr={"==":ui,"!=":di,">":fi,"<":pi,">=":gi,"<=":mi,array:Be,at:Ge,boolean:Be,case:Xe,coalesce:ai,collator:_i,format:xi,image:vi,in:qe,"index-of":We,interpolate:ni,"interpolate-hcl":ni,"interpolate-lab":ni,length:bi,let:Ze,literal:Re,match:He,number:Be,"number-format":yi,object:Be,slice:Ke,step:Je,string:Be,"to-boolean":je,"to-color":je,"to-number":je,"to-string":je,var:$e,within:Ni,distance:xr};class br{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}static parse(t,e){const i=t[0],r=br.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 Ue(e.registry,Mr,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 br(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(qt).join(", ")})`:`(${qt(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(qt(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){br.definitions=e;for(const i in e)t[i]=br}}function wr(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=ke(e,i,r,o);if(s)throw new Me(s);return new ve(e/255,i/255,r/255,o,!1)}function Tr(t,e){return t in e}function Sr(t,e){const i=e[t];return void 0===i?null:i}function Pr(t){return{type:t}}function Mr(t){if(t instanceof $e)return Mr(t.boundExpression);if(t instanceof br&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Ni)return!1;if(t instanceof xr)return!1;const e=t instanceof je||t instanceof Be;let i=!0;return t.eachChild((t=>{i=e?i&&Mr(t):i&&t instanceof Re})),!!i&&Ir(t)&&Ar(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ir(t){if(t instanceof br){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 Ni)return!1;if(t instanceof xr)return!1;let e=!0;return t.eachChild((t=>{e&&!Ir(t)&&(e=!1)})),e}function Cr(t){if(t instanceof br&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Cr(t)&&(e=!1)})),e}function Ar(t,e){if(t instanceof br&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ar(t,e)&&(i=!1)})),i}function Er(t){return{result:"success",value:t}}function kr(t){return{result:"error",value:t}}function zr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Lr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Dr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Fr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Br(t){return t}function Or(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||(Dr(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?ve.parse:Pe.parse;(t=At({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(s=t.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${t.colorSpace}"`);var s;let a,l,c;if("exponential"===o)a=Ur;else if("interval"===o)a=Vr;else if("categorical"===o){a=Nr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Zr}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,Or(i[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:ni.interpolationFactor.bind(void 0,o),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Ur({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:ni.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?jr(t.default,e.default):a(t,e,n,l,c)}}}function jr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,r,n){return jr(typeof i===n?r[i]:void 0,t.default,e.default)}function Vr(t,e,i){if("number"!==Rr(i))return jr(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=Ye(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function Ur(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Rr(i))return jr(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=Ye(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],c=si[e.type]||Br;return"function"==typeof a.evaluate?{evaluate(...e){const i=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return c(i,r,s,t.colorSpace)}}:c(a,l,s,t.colorSpace)}function Zr(t,e,i){switch(e.type){case"color":i=ve.parse(i);break;case"formatted":i=Se.fromString(i.toString());break;case"resolvedImage":i=Ae.fromString(i.toString());break;case"padding":i=Pe.parse(i);break;default:Rr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return jr(i,t.default,e.default)}br.register(vr,{error:[{kind:"error"},[Dt],(t,[e])=>{throw new Me(e.evaluate(t))}],typeof:[Dt,[jt],(t,[e])=>qt(Le(e.evaluate(t)))],"to-rgba":[Gt(Lt,4),[Ft],(t,[e])=>{const[i,r,n,o]=e.evaluate(t).rgb;return[255*i,255*r,255*n,o]}],rgb:[Ft,[Lt,Lt,Lt],wr],rgba:[Ft,[Lt,Lt,Lt,Lt],wr],has:{type:Rt,overloads:[[[Dt],(t,[e])=>Tr(e.evaluate(t),t.properties())],[[Dt,Ot],(t,[e,i])=>Tr(e.evaluate(t),i.evaluate(t))]]},get:{type:jt,overloads:[[[Dt],(t,[e])=>Sr(e.evaluate(t),t.properties())],[[Dt,Ot],(t,[e,i])=>Sr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[jt,[Dt],(t,[e])=>Sr(e.evaluate(t),t.featureState||{})],properties:[Ot,[],t=>t.properties()],"geometry-type":[Dt,[],t=>t.geometryType()],id:[jt,[],t=>t.id()],zoom:[Lt,[],t=>t.globals.zoom],"heatmap-density":[Lt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Lt,[],t=>t.globals.lineProgress||0],accumulated:[jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Lt,Pr(Lt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Lt,Pr(Lt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Lt,overloads:[[[Lt,Lt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Lt],(t,[e])=>-e.evaluate(t)]]},"/":[Lt,[Lt,Lt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Lt,[Lt,Lt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Lt,[],()=>Math.LN2],pi:[Lt,[],()=>Math.PI],e:[Lt,[],()=>Math.E],"^":[Lt,[Lt,Lt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Lt,[Lt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Lt,[Lt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Lt,[Lt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Lt,[Lt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Lt,[Lt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Lt,[Lt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Lt,[Lt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Lt,[Lt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Lt,Pr(Lt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Lt,Pr(Lt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Lt,[Lt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Lt,[Lt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Lt,[Lt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Lt,[Lt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Rt,[Dt,jt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Rt,[jt],(t,[e])=>t.id()===e.value],"filter-type-==":[Rt,[Dt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Rt,[Dt,jt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Rt,[jt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Rt,[jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Rt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Rt,[Gt(Dt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Rt,[Gt(jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Rt,[Dt,Gt(jt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Rt,[Dt,Gt(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:Rt,overloads:[[[Rt,Rt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Pr(Rt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Rt,overloads:[[[Rt,Rt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Pr(Rt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Rt,[Rt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Rt,[Dt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Dt,[Dt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Dt,[Dt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Dt,Pr(jt),(t,e)=>e.map((e=>De(e.evaluate(t)))).join("")],"resolved-locale":[Dt,[Nt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class $r{constructor(t,e){var i;this.expression=t,this._warningHistory={},this._evaluator=new Ve,this._defaultValue=e?"color"===(i=e).type&&Fr(i.default)?new ve(0,0,0,0):"color"===i.type?ve.parse(i.default)||null:"padding"===i.type?Pe.parse(i.default)||null:"variableAnchorOffsetCollection"===i.type?Ce.parse(i.default)||null:"projectionDefinition"===i.type?Ee.parse(i.default)||null:void 0===i.default?null:i.default: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 Me(`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 Gr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in vr}function qr(t,e){const i=new Ue(vr,Mr,[],e?function(t){const e={color:Ft,string:Dt,number:Lt,enum:Dt,boolean:Rt,formatted:Vt,padding:Ut,projectionDefinition:Bt,resolvedImage:Zt,variableAnchorOffsetCollection:$t};return"array"===t.type?Gt(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?Er(new $r(r,e)):kr(i.errors)}class Wr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Cr(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 Hr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Cr(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?ni.interpolationFactor(this.interpolationType,t,e,i):0}}function Xr(t,e){const i=qr(t,e);if("error"===i.result)return i;const r=i.value.expression,n=Ir(r);if(!n&&!zr(e))return kr([new Et("","data expressions not supported")]);const o=Ar(r,["zoom"]);if(!o&&!Lr(e))return kr([new Et("","zoom expressions not supported")]);const s=Yr(r);return s||o?s instanceof Et?kr([s]):s instanceof ni&&!Dr(e)?kr([new Et("",'"interpolate" expressions cannot be used with this property')]):Er(s?new Hr(n?"camera":"composite",i.value,s.labels,s instanceof ni?s.interpolation:void 0):new Wr(n?"constant":"source",i.value)):kr([new Et("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Kr{constructor(t,e){this._parameters=t,this._specification=e,At(this,Or(this._parameters,this._specification))}static deserialize(t){return new Kr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Yr(t){let e=null;if(t instanceof Ze)e=Yr(t.result);else if(t instanceof ai){for(const i of t.args)if(e=Yr(i),e)break}else(t instanceof Je||t instanceof ni)&&t.input instanceof br&&"zoom"===t.input.name&&(e=t);return e instanceof Et||t.eachChild((t=>{const i=Yr(t);i instanceof Et?e=i:!e&&i?e=new Et("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Et("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Jr(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(!Jr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const Qr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function tn(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Jr(t)||(t=nn(t));const e=qr(t,Qr);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:rn(t)}}function en(t,e){return t<e?-1:t>e?1:0}function rn(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(rn(t[e]))return!0;return!1}function nn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?on(t[1],t[2],"=="):"!="===e?ln(on(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?on(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(nn))):"all"===e?["all"].concat(t.slice(1).map(nn)):"none"===e?["all"].concat(t.slice(1).map(nn).map(ln)):"in"===e?sn(t[1],t.slice(2)):"!in"===e?ln(sn(t[1],t.slice(2))):"has"===e?an(t[1]):"!has"!==e||ln(an(t[1]));var i}function on(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 sn(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(en)]]:["filter-in-small",t,["literal",e]]}}function an(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ln(t){return["!",t]}function cn(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${cn(i)},`;return`${e}]`}const i=Object.keys(t).sort();let r="{";for(let e=0;e<i.length;e++)r+=`${JSON.stringify(i[e])}:${cn(t[i[e]])},`;return`${r}}`}function hn(t){let e="";for(const i of _t)e+=`/${cn(t[i])}`;return e}function un(t){const e=t.value;return e?[new Ct(t.key,e,"constants have been deprecated as of v8")]:[]}function dn(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function pn(t){if(Array.isArray(t))return t.map(pn);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=pn(t[i]);return e}return dn(t)}function fn(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,s=t.styleSpec,a=t.validateSpec;let l=[];const c=Rr(i);if("object"!==c)return[new Ct(e,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0],h=r[c]||r["*"];let u;if(n[c])u=n[c];else if(r[c])u=a;else if(n["*"])u=n["*"];else{if(!r["*"]){l.push(new Ct(e,i[t],`unknown property "${t}"`));continue}u=a}l=l.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:h,style:o,styleSpec:s,object:i,objectKey:t,validateSpec:a},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new Ct(e,i,`missing required property "${t}"`));return l}function mn(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,o=t.key,s=t.arrayElementValidator||t.validateSpec;if("array"!==Rr(e))return[new Ct(o,e,`array expected, ${Rr(e)} found`)];if(i.length&&e.length!==i.length)return[new Ct(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new Ct(o,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===Rr(i.value)&&(a=i.value);let l=[];for(let i=0;i<e.length;i++)l=l.concat(s({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:n,key:`${o}[${i}]`}));return l}function gn(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Rr(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new Ct(e,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new Ct(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new Ct(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function _n(t){const e=t.valueSpec,i=dn(t.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Rr(t.value.stops)&&"array"===Rr(t.value.stops[0])&&"object"===Rr(t.value.stops[0][0]),h=fn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new Ct(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(mn({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Rr(r)&&0===r.length&&e.push(new Ct(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new Ct(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new Ct(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Dr(t.valueSpec)&&h.push(new Ct(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!zr(t.valueSpec)?h.push(new Ct(t.key,t.value,"property functions not supported")):a&&!Lr(t.valueSpec)&&h.push(new Ct(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new Ct(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==Rr(r))return[new Ct(a,r,`array expected, ${Rr(r)} found`)];if(2!==r.length)return[new Ct(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Rr(r[0]))return[new Ct(a,r,`object expected, ${Rr(r[0])} found`)];if(void 0===r[0].zoom)return[new Ct(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Ct(a,r,"object stop key must have value")];if(o&&o>dn(r[0].zoom))return[new Ct(a,r[0].zoom,"stop zoom values must appear in ascending order")];dn(r[0].zoom)!==o&&(o=dn(r[0].zoom),n=void 0,s={}),i=i.concat(fn({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:gn,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return Gr(pn(r[1]))?i.concat([new Ct(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,o){const a=Rr(t.value),l=dn(t.value),c=null!==t.value?t.value:o;if(r){if(a!==r)return[new Ct(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 Ct(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 zr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ct(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 Ct(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new Ct(t.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Ct(t.key,c,`integer expected, found ${l}`)]}}function yn(t){const e=("property"===t.expressionContext?Xr:qr)(pn(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new Ct(`${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 Ct(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&&!Cr(i))return[new Ct(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Cr(i))return[new Ct(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ar(i,["zoom","feature-state"]))return[new Ct(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Ir(i))return[new Ct(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function xn(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(dn(i))&&n.push(new Ct(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(dn(i))&&n.push(new Ct(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function vn(t){return Jr(pn(t.value))?yn(At({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):bn(t)}function bn(t){const e=t.value,i=t.key;if("array"!==Rr(e))return[new Ct(i,e,`array expected, ${Rr(e)} found`)];const r=t.styleSpec;let n,o=[];if(e.length<1)return[new Ct(i,e,"filter array must have at least 1 element")];switch(o=o.concat(xn({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),dn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===dn(e[1])&&o.push(new Ct(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new Ct(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Rr(e[1]),"string"!==n&&o.push(new Ct(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let s=2;s<e.length;s++)n=Rr(e[s]),"$type"===dn(e[1])?o=o.concat(xn({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 Ct(`${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(bn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Rr(e[1]),2!==e.length?o.push(new Ct(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new Ct(`${i}[1]`,e[1],`string expected, ${n} found`))}return o}function wn(t,e){const i=t.key,r=t.validateSpec,n=t.style,o=t.styleSpec,s=t.value,a=t.objectKey,l=o[`${e}_${t.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===e&&c&&l[c[1]]&&l[c[1]].transition)return r({key:i,value:s,valueSpec:o.transition,style:n,styleSpec:o});const h=t.valueSpec||l[a];if(!h)return[new Ct(i,s,`unknown property "${a}"`)];let u;if("string"===Rr(s)&&zr(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(s)))return[new Ct(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const d=[];return"symbol"===t.layerType&&("text-field"===a&&n&&!n.glyphs&&d.push(new Ct(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Fr(pn(s))&&"identity"===dn(s.type)&&d.push(new Ct(i,s,'"text-font" does not support identity functions'))),d.concat(r({key:t.key,value:s,valueSpec:h,style:n,styleSpec:o,expressionContext:"property",propertyType:e,propertyKey:a}))}function Tn(t){return wn(t,"paint")}function Sn(t){return wn(t,"layout")}function Pn(t){let e=[];const i=t.value,r=t.key,n=t.style,o=t.styleSpec;i.type||i.ref||e.push(new Ct(r,i,'either "type" or "ref" is required'));let s=dn(i.type);const a=dn(i.ref);if(i.id){const o=dn(i.id);for(let s=0;s<t.arrayIndex;s++){const t=n.layers[s];dn(t.id)===o&&e.push(new Ct(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 Ct(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{dn(e.id)===a&&(t=e)})),t?t.ref?e.push(new Ct(r,i.ref,"ref cannot reference another ref layer")):s=dn(t.type):e.push(new Ct(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const t=n.sources&&n.sources[i.source],o=t&&dn(t.type);t?"vector"===o&&"raster"===s?e.push(new Ct(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s?e.push(new Ct(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?e.push(new Ct(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new Ct(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 Ct(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ct(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Ct(r,i.source,`source "${i.source}" not found`))}else e.push(new Ct(r,i,'missing required property "source"'));return e=e.concat(fn({key:r,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:vn,layout:t=>fn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Sn(At({layerType:s},t))}}),paint:t=>fn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Tn(At({layerType:s},t))}})}})),e}function Mn(t){const e=t.value,i=t.key,r=Rr(e);return"string"!==r?[new Ct(i,e,`string expected, ${r} found`)]:[]}const In={promoteId:function({key:t,value:e}){if("string"===Rr(e))return Mn({key:t,value:e});{const i=[];for(const r in e)i.push(...Mn({key:`${t}.${r}`,value:e[r]}));return i}}};function Cn(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style,o=t.validateSpec;if(!e.type)return[new Ct(i,e,'"type" is required')];const s=dn(e.type);let a;switch(s){case"vector":case"raster":return a=fn({key:i,value:e,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:In,validateSpec:o}),a;case"raster-dem":return a=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,n=t.styleSpec,o=n.source_raster_dem,s=t.style;let a=[];const l=Rr(r);if(void 0===r)return a;if("object"!==l)return a.push(new Ct("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===dn(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!c&&h.includes(e)?a.push(new Ct(e,r[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):o[e]?a=a.concat(t.validateSpec({key:e,value:r[e],valueSpec:o[e],validateSpec:t.validateSpec,style:s,styleSpec:n})):a.push(new Ct(e,r[e],`unknown property "${e}"`));return a}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:o}),a;case"geojson":if(a=fn({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:o,objectElementValidators:In}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...yn({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),a.push(...yn({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return fn({key:i,value:e,valueSpec:r.source_video,style:n,validateSpec:o,styleSpec:r});case"image":return fn({key:i,value:e,valueSpec:r.source_image,style:n,validateSpec:o,styleSpec:r});case"canvas":return[new Ct(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return xn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function An(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let o=[];const s=Rr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Ct("light",e,`object expected, ${s} found`)]),o;for(const s in e){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:s,value:e[s],valueSpec:i.transition,validateSpec:t.validateSpec,style:n,styleSpec:i}):r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new Ct(s,e[s],`unknown property "${s}"`)])}return o}function En(t){const e=t.value,i=t.styleSpec,r=i.sky,n=t.style,o=Rr(e);if(void 0===e)return[];if("object"!==o)return[new Ct("sky",e,`object expected, ${o} found`)];let s=[];for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],style:n,styleSpec:i}):[new Ct(o,e[o],`unknown property "${o}"`)]);return s}function kn(t){const e=t.value,i=t.styleSpec,r=i.terrain,n=t.style;let o=[];const s=Rr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Ct("terrain",e,`object expected, ${s} found`)]),o;for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new Ct(s,e[s],`unknown property "${s}"`)]);return o}function zn(t){let e=[];const i=t.value,r=t.key;if(Array.isArray(i)){const n=[],o=[];for(const s in i)i[s].id&&n.includes(i[s].id)&&e.push(new Ct(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),n.push(i[s].id),i[s].url&&o.includes(i[s].url)&&e.push(new Ct(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),e=e.concat(fn({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Mn({key:r,value:i})}const Ln={"*":()=>[],array:mn,boolean:function(t){const e=t.value,i=t.key,r=Rr(e);return"boolean"!==r?[new Ct(i,e,`boolean expected, ${r} found`)]:[]},number:gn,color:function(t){const e=t.key,i=t.value,r=Rr(i);return"string"!==r?[new Ct(e,i,`color expected, ${r} found`)]:ve.parse(String(i))?[]:[new Ct(e,i,`color expected, "${i}" found`)]},constants:un,enum:xn,filter:vn,function:_n,layer:Pn,object:fn,source:Cn,light:An,sky:En,terrain:kn,projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style,o=Rr(e);if(void 0===e)return[];if("object"!==o)return[new Ct("projection",e,`object expected, ${o} found`)];let s=[];for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],style:n,styleSpec:i}):[new Ct(o,e[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(t){const e=t.key;let i=t.value;i=i instanceof String?i.valueOf():i;const r=Rr(i);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(i)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(i)?["array","string"].includes(r)?[]:[new Ct(e,i,`projection expected, invalid type "${r}" found`)]:[new Ct(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Mn,formatted:function(t){return 0===Mn(t).length?[]:yn(t)},resolvedImage:function(t){return 0===Mn(t).length?[]:yn(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Rr(i)){if(i.length<1||i.length>4)return[new Ct(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let o=0;o<i.length;o++)n=n.concat(t.validateSpec({key:`${e}[${o}]`,value:i[o],validateSpec:t.validateSpec,valueSpec:r}));return n}return gn({key:e,value:i,valueSpec:{}})},variableAnchorOffsetCollection:function(t){const e=t.key,i=t.value,r=Rr(i),n=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new Ct(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let o=[];for(let r=0;r<i.length;r+=2)o=o.concat(xn({key:`${e}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),o=o.concat(mn({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return o},sprite:zn};function Dn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=Dn,i.expression&&Fr(dn(e))?_n(t):i.expression&&Gr(pn(e))?yn(t):i.type&&Ln[i.type]?Ln[i.type](t):fn(At({},t,{valueSpec:i.type?r[i.type]:i}))}function Rn(t){const e=t.value,i=t.key,r=Mn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Ct(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Ct(i,e,'"glyphs" url must include a "{range}" token'))),r}function Fn(t,e=gt){let i=[];return i=i.concat(Dn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Dn,objectElementValidators:{glyphs:Rn,"*":()=>[]}})),t.constants&&(i=i.concat(un({key:"constants",value:t.constants}))),On(i)}function Bn(t){return function(e){return t({...e,validateSpec:Dn})}}function On(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function jn(t){return function(...e){return On(t.apply(this,e))}}Fn.source=jn(Bn(Cn)),Fn.sprite=jn(Bn(zn)),Fn.glyphs=jn(Bn(Rn)),Fn.light=jn(Bn(An)),Fn.sky=jn(Bn(En)),Fn.terrain=jn(Bn(kn)),Fn.layer=jn(Bn(Pn)),Fn.filter=jn(Bn(vn)),Fn.paintProperty=jn(Bn(Tn)),Fn.layoutProperty=jn(Bn(Sn));const Nn=Fn,Vn=Nn.light,Un=Nn.sky,Zn=Nn.paintProperty,$n=Nn.layoutProperty;function Gn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new ft(new Error(r.message))),i=!0;return i}class qn{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(let t=0;t<this.d*this.d;t++){const e=n[3+t],i=n[3+t+1];r.push(e===i?null:n.subarray(e,i))}const o=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],o),this.bboxes=n.subarray(o),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const n=i/e*t;this.min=-n,this.max=t+n}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,n,o){this.cells[n].push(o)}query(t,e,i,r,n,o){const s=this.min,a=this.max;if(o||t<=s&&e<=s&&a<=i&&a<=r&&!n)return Array.prototype.slice.call(this.keys);{const o=[];return this._forEachCell(t,e,i,r,this._queryCell,o,{},n),o}}_queryCell(t,e,i,r,n,o,s,a){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===s[u]){const l=4*u;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(s[u]=!0,o.push(n[u])):s[u]=!1}}}}_forEachCell(t,e,i,r,n,o,s,a){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&n.call(this,t,e,i,r,c,o,s,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=n,r.set(i,n),n+=i.length}return r[3+t.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+t.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new qn(t.buffer)}}const Wn={};function Hn(t,e,i={}){if(Wn[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Wn[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Hn("Object",Object),Hn("TransferableGridIndex",qn),Hn("Color",ve),Hn("Error",Error),Hn("AJAXError",at),Hn("ResolvedImage",Ae),Hn("StylePropertyFunction",Kr),Hn("StyleExpression",$r,{omit:["_evaluator"]}),Hn("ZoomDependentExpression",Hr),Hn("ZoomConstantExpression",Wr),Hn("CompoundExpression",br,{omit:["_evaluate"]});for(const t in vr)vr[t]._classRegistryKey||Hn(`Expression_${t}`,vr[t]);function Xn(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Kn(t){return t.$name||t.constructor._classRegistryKey}function Yn(t){return!function(t){if(null===t||"object"!=typeof t)return!1;const e=Kn(t);return!(!e||"Object"===e)}(t)&&(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||t instanceof Blob||t instanceof Error||Xn(t)||W(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function Jn(t,e){if(Yn(t))return(Xn(t)||W(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(Jn(r,e));return i}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const i=Kn(t);if(!i)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!Wn[i])throw new Error(`${i} is not registered.`);const{klass:r}=Wn[i],n=r.serialize?r.serialize(t,e):{};if(r.serialize){if(e&&n===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in t){if(!t.hasOwnProperty(r))continue;if(Wn[i].omit.indexOf(r)>=0)continue;const o=t[r];n[r]=Wn[i].shallow.indexOf(r)>=0?o:Jn(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"!==i&&(n.$name=i),n}function Qn(t){if(Yn(t))return t;if(Array.isArray(t))return t.map(Qn);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Kn(t)||"Object";if(!Wn[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Wn[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]=Wn[e].shallow.indexOf(i)>=0?n:Qn(n)}return r}class to{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 eo={"Latin-1 Supplement":t=>t>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function io(t){for(const e of t)if(lo(e.charCodeAt(0)))return!0;return!1}function ro(t){for(const e of t)if(!so(e.charCodeAt(0)))return!1;return!0}function no(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const oo=no(["Arab","Dupl","Mong","Ougr","Syrc"]);function so(t){return!oo.test(String.fromCodePoint(t))}const ao=no(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function lo(t){return!(746!==t&&747!==t&&(t<4352||!(eo["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||eo["CJK Compatibility"](t)||eo["CJK Strokes"](t)||!(!eo["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||eo["Enclosed CJK Letters and Months"](t)||eo["Ideographic Description Characters"](t)||eo.Kanbun(t)||eo.Katakana(t)&&12540!==t||!(!eo["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!eo["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||eo["Vertical Forms"](t)||eo["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||ao.test(String.fromCodePoint(t)))))}function co(t){return!(lo(t)||function(t){return!!(eo["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||eo["General Punctuation"](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)||eo["Letterlike Symbols"](t)||eo["Number Forms"](t)||eo["Miscellaneous Technical"](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)||eo["Control Pictures"](t)&&9251!==t||eo["Optical Character Recognition"](t)||eo["Enclosed Alphanumerics"](t)||eo["Geometric Shapes"](t)||eo["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||eo["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||eo["CJK Symbols and Punctuation"](t)||eo.Katakana(t)||eo["Private Use Area"](t)||eo["CJK Compatibility Forms"](t)||eo["Small Form Variants"](t)||eo["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ho=no(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function uo(t){return ho.test(String.fromCodePoint(t))}function po(t,e){return!(!e&&uo(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||eo.Khmer(t))}function fo(t){for(const e of t)if(uo(e.charCodeAt(0)))return!0;return!1}const mo=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(mo.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,i){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,r=new Promise((t=>{this.loadScriptResolve=t}));i(e);const n=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([r,n]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class go{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 to,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!po(i.charCodeAt(0),e))return!1;return!0}(t,"loaded"===mo.getRTLTextPluginStatus())}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 _o{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Fr(t))return new Kr(t,e);if(Gr(t)){const i=Xr(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"color"===e.type&&"string"==typeof t?i=ve.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?i=Ce.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(i=Ee.parse(t)):i=Pe.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 yo{constructor(t){this.property=t,this.value=new _o(t,void 0)}transitioned(t,e){return new vo(this.property,this.value,e,B({},t.transition,this.transition),t.now)}untransitioned(){return new vo(this.property,this.value,null,{},0)}}class xo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return V(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new yo(this._values[t].property)),this._values[t].value=new _o(this._values[t].property,null===e?void 0:V(e))}getTransition(t){return V(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new yo(this._values[t].property)),this._values[t].transition=V(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 bo(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 bo(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class vo{constructor(t,e,i,r,n){this.property=t,this.value=e,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,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,z(s))}}return n}}class bo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new So(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 wo{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return V(this._values[t].value)}setValue(t,e){this._values[t]=new _o(this._values[t].property,null===e?void 0:V(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 So(this._properties);for(const n of Object.keys(this._values)){const o="text-letter-spacing"===n?B({},t,{zoom:Math.floor(t.zoom)}):t;r._values[n]=this._values[n].possiblyEvaluate(o,e,i)}return r}}class To{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 So{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Po{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=si[this.specification.type];return r?r(t,e,i):t}}class Mo{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new To(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 To(this,{kind:"constant",value:void 0},t.parameters);const r=si[this.specification.type];if(r){const n=r(t.value.value,e.value.value,i);return new To(this,{kind:"constant",value:n},t.parameters)}return t}evaluate(t,e,i,r,n,o){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,o)}}class Io extends Mo{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new To(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 To(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 To(this,{kind:"constant",value:i},e)}return new To(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}:{from:i,to:e}}interpolate(t){return t}}class Co{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 go(Math.floor(e.zoom-1),e)),t.expression.evaluate(new go(Math.floor(e.zoom),e)),t.expression.evaluate(new go(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 Ao{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Eo{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 _o(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new yo(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Hn("DataDrivenProperty",Mo),Hn("DataConstantProperty",Po),Hn("CrossFadedDataDrivenProperty",Io),Hn("CrossFadedProperty",Co),Hn("ColorRampProperty",Ao);const ko="-transition";class zo extends mt{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.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new wo(e.layout)),e.paint)){this._transitionablePaint=new xo(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 So(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($n,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(ko)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Zn,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(ko))return this._transitionablePaint.setTransition(t.slice(0,-11),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){}_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),N(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)&&Gn(this,t.call(Nn,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:gt,style:{glyphs:!0,sprite:!0}}))}is3D(){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 To&&zr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Lo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Do{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 Ro{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 Fo(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=Lo[t.type].BYTES_PER_ELEMENT,o=i=Bo(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:Bo(i,Math.max(r,e)),alignment:e}}function Bo(t,e){return Math.ceil(t/e)*e}class Oo extends Ro{_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}}Oo.prototype.bytesPerElement=4,Hn("StructArrayLayout2i4",Oo);class jo extends Ro{_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,Hn("StructArrayLayout3i6",jo);class No extends Ro{_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}}No.prototype.bytesPerElement=8,Hn("StructArrayLayout4i8",No);class Vo extends Ro{_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}}Vo.prototype.bytesPerElement=12,Hn("StructArrayLayout2i4i12",Vo);class Uo extends Ro{_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=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=o,this.uint8[l+7]=s,t}}Uo.prototype.bytesPerElement=8,Hn("StructArrayLayout2i4ub8",Uo);class Zo extends Ro{_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}}Zo.prototype.bytesPerElement=8,Hn("StructArrayLayout2f8",Zo);class $o extends Ro{_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}}$o.prototype.bytesPerElement=20,Hn("StructArrayLayout10ui20",$o);class Go extends Ro{_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}}Go.prototype.bytesPerElement=24,Hn("StructArrayLayout4i4ui4i24",Go);class qo extends Ro{_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}}qo.prototype.bytesPerElement=12,Hn("StructArrayLayout3f12",qo);class Wo extends Ro{_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}}Wo.prototype.bytesPerElement=4,Hn("StructArrayLayout1ul4",Wo);class Ho extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,n,o,s,a,l)}emplace(t,e,i,r,n,o,s,a,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=o,this.int16[h+5]=s,this.uint32[u+3]=a,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}Ho.prototype.bytesPerElement=20,Hn("StructArrayLayout6i1ul2ui20",Ho);class Xo extends Ro{_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}}Xo.prototype.bytesPerElement=12,Hn("StructArrayLayout2i2i2i12",Xo);class Ko extends Ro{_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}}Ko.prototype.bytesPerElement=16,Hn("StructArrayLayout2f1f2i16",Ko);class Yo extends Ro{_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,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=16*t,l=4*t,c=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=o,this.int16[c+7]=s,t}}Yo.prototype.bytesPerElement=16,Hn("StructArrayLayout2ub2f2i16",Yo);class Jo extends Ro{_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}}Jo.prototype.bytesPerElement=6,Hn("StructArrayLayout3ui6",Jo);class Qo extends Ro{_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){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g)}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]=g,this.int16[y+22]=_,t}}Qo.prototype.bytesPerElement=48,Hn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Qo);class ts extends Ro{_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,S,P,M,I,C){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,S,P,M,I,C)}emplace(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P,M,I,C,A){const E=34*t,k=17*t;return this.int16[E+0]=e,this.int16[E+1]=i,this.int16[E+2]=r,this.int16[E+3]=n,this.int16[E+4]=o,this.int16[E+5]=s,this.int16[E+6]=a,this.int16[E+7]=l,this.uint16[E+8]=c,this.uint16[E+9]=h,this.uint16[E+10]=u,this.uint16[E+11]=d,this.uint16[E+12]=p,this.uint16[E+13]=f,this.uint16[E+14]=m,this.uint16[E+15]=g,this.uint16[E+16]=_,this.uint16[E+17]=y,this.uint16[E+18]=x,this.uint16[E+19]=v,this.uint16[E+20]=b,this.uint16[E+21]=w,this.uint16[E+22]=T,this.uint32[k+12]=S,this.float32[k+13]=P,this.float32[k+14]=M,this.uint16[E+30]=I,this.uint16[E+31]=C,this.float32[k+16]=A,t}}ts.prototype.bytesPerElement=68,Hn("StructArrayLayout8i15ui1ul2f2ui1f68",ts);class es extends Ro{_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}}es.prototype.bytesPerElement=4,Hn("StructArrayLayout1f4",es);class is extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(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.uint16[6*t+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}is.prototype.bytesPerElement=12,Hn("StructArrayLayout1ui2f12",is);class rs extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(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=4*t;return this.uint32[2*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,t}}rs.prototype.bytesPerElement=8,Hn("StructArrayLayout1ul2ui8",rs);class ns extends Ro{_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}}ns.prototype.bytesPerElement=4,Hn("StructArrayLayout2ui4",ns);class os extends Ro{_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}}os.prototype.bytesPerElement=2,Hn("StructArrayLayout1ui2",os);class ss extends Ro{_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}}ss.prototype.bytesPerElement=16,Hn("StructArrayLayout4f16",ss);class as extends Do{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}as.prototype.size=20;class ls extends Ho{get(t){return new as(this,t)}}Hn("CollisionBoxArray",ls);class cs extends Do{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]}}cs.prototype.size=48;class hs extends Qo{get(t){return new cs(this,t)}}Hn("PlacedSymbolArray",hs);class us extends Do{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 textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get angle(){return this._structArray.float32[this._pos4+16]}set angle(t){this._structArray.float32[this._pos4+16]=t}}us.prototype.size=68;class ds extends ts{get(t){return new us(this,t)}}Hn("SymbolInstanceArray",ds);class ps extends es{getoffsetX(t){return this.float32[1*t+0]}}Hn("GlyphOffsetArray",ps);class fs 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]}}Hn("SymbolLineVertexArray",fs);class ms extends Do{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}ms.prototype.size=12;class gs extends is{get(t){return new ms(this,t)}}Hn("TextAnchorOffsetArray",gs);class _s extends Do{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]}}_s.prototype.size=8;class ys extends rs{get(t){return new _s(this,t)}}Hn("FeatureIndexArray",ys);class xs extends Oo{}class vs extends Oo{}class bs extends Oo{}class ws extends Vo{}class Ts extends Uo{}class Ss extends Zo{}class Ps extends $o{}class Ms extends Go{}class Is extends qo{}class Cs extends Wo{}class As extends Xo{}class Es extends Yo{}class ks extends Jo{}class zs extends ns{}const Ls=Fo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ds}=Ls;class Rs{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,e,i,r){const n=this.segments[this.segments.length-1];return t>Rs.MAX_VERTEX_ARRAY_LENGTH&&Z(`Max vertices per segment is ${Rs.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Rs.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Rs.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(e,i,r):n}createNewSegment(t,e,i){const r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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 Rs([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function Fs(t,e){return 256*(t=R(Math.floor(t),0,255))+R(Math.floor(e),0,255)}Rs.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Hn("SegmentVector",Rs);const Bs=Fo([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Os,js,Ns,Vs={exports:{}},Us={exports:{}},Zs={exports:{}},$s=function(){if(Ns)return Vs.exports;Ns=1;var t=(Os||(Os=1,Us.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.exports),e=(js||(js=1,Zs.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}),Zs.exports);return Vs.exports=t,Vs.exports.murmur3=t,Vs.exports.murmur2=e,Vs.exports}(),Gs=i($s);class qs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Ws(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Ws(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 Hs(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new qs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Ws(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Gs(String(t))}function Hs(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;Xs(t,o,s),Xs(e,3*o,3*s),Xs(e,3*o+1,3*s+1),Xs(e,3*o+2,3*s+2)}s-i<r-s?(Hs(t,e,i,s),i=s+1):(Hs(t,e,s+1,r),r=s)}}function Xs(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Hn("FeaturePositionMap",qs);class Ks{constructor(t,e){this.gl=t.gl,this.location=e}}class Ys extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Js extends Ks{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 Qs extends Ks{constructor(t,e){super(t,e),this.current=ve.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 ta=new Float32Array(16);function ea(t){return[Fs(255*t.r,255*t.g),Fs(255*t.b,255*t.a)]}class ia{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 Qs(t,e):new Ys(t,e)}}class ra{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.tlbr,this.patternTo=t.tlbr}setUniform(t,e,i,r){const n="u_pattern_to"===r?this.patternTo:"u_pattern_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"===i.substr(0,9)?new Js(t,e):new Ys(t,e)}}class na{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 go(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=ea(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 oa{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 go(this.zoom),e,{},r,[],n),s=this.expression.evaluate(new go(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=ea(i),o=ea(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=R(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Ys(t,e)}}class sa{constructor(t,e,i,r,n,o){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=o,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}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.zoomInPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],a.tl[0],a.tl[1],a.br[0],a.br[1],l.pixelRatio,a.pixelRatio),this.zoomOutPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],c.tl[0],c.tl[1],c.br[0],c.br[1],l.pixelRatio,c.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Bs.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Bs.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class aa{constructor(t,e,i){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 To&&zr(o.property.specification)))continue;const s=ca(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;if("constant"===a.kind)this.binders[n]=u?new ra(a.value,s):new ia(a.value,s,l),r.push(`/u_${n}`);else if("source"===a.kind||u){const i=ha(n,l,"source");this.binders[n]=u?new sa(a,l,c,e,i,t.id):new na(a,s,l,i),r.push(`/a_${n}`)}else{const t=ha(n,l,"composite");this.binders[n]=new oa(a,s,l,c,e,t),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof na||e instanceof oa?e.maxValue:0}populatePaintArrays(t,e,i,r,n){for(const o in this.binders){const s=this.binders[o];(s instanceof na||s instanceof oa||s instanceof sa)&&s.populatePaintArray(t,e,i,r,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof ra&&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 na||l instanceof oa||l instanceof sa)&&!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 ia||i instanceof ra)&&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 na||i instanceof oa)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof sa)for(let e=0;e<Bs.members.length;e++)t.push(Bs.members[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof ia||i instanceof ra||i instanceof oa)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 ia||n instanceof ra||n instanceof oa)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 sa){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof na||i instanceof oa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof na||i instanceof oa||i instanceof sa)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof na||e instanceof oa||e instanceof sa)&&e.destroy()}}}class la{constructor(t,e,i=()=>!0){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new aa(r,e,i);this.needsUpload=!1,this._featureMap=new qs,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()}}function ca(t,e){return{"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"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function ha(t,e,i){const r={color:{source:Zo,composite:ss},number:{source:es,composite:Zo}},n=function(t){return{"line-pattern":{source:Ps,composite:Ps},"fill-pattern":{source:Ps,composite:Ps},"fill-extrusion-pattern":{source:Ps,composite:Ps}}[t]}(t);return n&&n[i]||r[e][i]}Hn("ConstantBinder",ia),Hn("CrossFadedConstantBinder",ra),Hn("SourceExpressionBinder",na),Hn("CrossFadedCompositeBinder",sa),Hn("CompositeExpressionBinder",oa),Hn("ProgramConfiguration",aa,{omit:["_buffers"]}),Hn("ProgramConfigurationSet",la);const ua=Math.pow(2,14)-1,da=-ua-1;function pa(t){const e=C/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=R(n,da,ua),i.y=R(o,da,ua),(n<i.x||n>i.x+1||o<i.y||o>i.y+1)&&Z("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function fa(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?pa(t):[]}}const ma=-32768;function ga(t,e,i,r,n){t.emplaceBack(ma+8*e+r,ma+8*i+n)}class _a{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 vs,this.indexArray=new ks,this.segments=new Rs,this.programConfigurations=new la(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,s=!1,a="heatmap"===r.type;if("circle"===r.type){const t=r;o=t.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===t.paint.get("circle-pitch-alignment")}const l=a?e.subdivisionGranularity.circle:1;for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=fa(e,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),c,i))continue;const h=s?o.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:pa(e),patterns:{},sortKey:h};n.push(u)}s&&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,l),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,Ds),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,n=1){let o;switch(n){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=C||r<0||r>=C)continue;const n=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,t.sortKey),a=n.vertexLength;for(let t=0;t<s;t++)for(let e=0;e<s;e++)ga(this.layoutVertexArray,i,r,o[e],o[t]);for(let t=0;t<s-1;t++)for(let e=0;e<s-1;e++){const i=a+t*s+e,r=a+(t+1)*s+e;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=s*s,n.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function ya(t,e){for(let i=0;i<t.length;i++)if(Ia(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ia(t,e[i]))return!0;return!!wa(t,e)}function xa(t,e,i){return!!Ia(t,e)||!!Sa(e,t,i)}function va(t,e){if(1===t.length)return Ma(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(Ia(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(Ma(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(wa(t,e[i]))return!0;return!1}function ba(t,e,i){if(t.length>1){if(wa(t,e))return!0;for(let r=0;r<e.length;r++)if(Sa(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Sa(t[r],e,i))return!0;return!1}function wa(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 $(t,i,r)!==$(e,i,r)&&$(t,e,i)!==$(t,e,r)}function Sa(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(Pa(t,e[i-1],e[i])<r)return!0;return!1}function Pa(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 Ma(t,e){for(let i=0;i<t.length;i++)if(Ia(t[i],e))return!0;return!1}function Ia(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 Ca(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=$(t,e,i[0]);return o!==$(t,e,i[1])||o!==$(t,e,i[2])||o!==$(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 Ea(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ka(t,e,i,r,n){if(!e[0]&&!e[1])return t;const o=l.convert(e)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(o));return s}let za,La;Hn("CircleBucket",_a,{omit:["layers"]});var Da={get paint(){return La=La||new Eo({"circle-radius":new Mo(gt.paint_circle["circle-radius"]),"circle-color":new Mo(gt.paint_circle["circle-color"]),"circle-blur":new Mo(gt.paint_circle["circle-blur"]),"circle-opacity":new Mo(gt.paint_circle["circle-opacity"]),"circle-translate":new Po(gt.paint_circle["circle-translate"]),"circle-translate-anchor":new Po(gt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Po(gt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Po(gt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Mo(gt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Mo(gt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Mo(gt.paint_circle["circle-stroke-opacity"])})},get layout(){return za=za||new Eo({"circle-sort-key":new Mo(gt.layout_circle["circle-sort-key"])})}};class Ra extends zo{constructor(t){super(t,Da)}createBucket(t){return new _a(t)}queryRadius(t){const e=t;return Aa("circle-radius",this,e)+Aa("circle-stroke-width",this,e)+Ea(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){const l=ka(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,o),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e,i,r){return t.map((t=>Fa(t,e,i,r)))}(l,n,s,a),d=h?c*o:c;for(const t of r)for(const e of t){const t=h?e:Fa(e,n,s,a);let i=d;const r=n.projectTileCoordinates(e.x,e.y,s,a).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r),xa(u,t,i))return!0}return!1}}function Fa(t,e,i,r){const n=e.projectTileCoordinates(t.x,t.y,i,r).point;return new l((.5*n.x+.5)*e.width,(.5*-n.y+.5)*e.height)}class Ba extends _a{}let Oa;Hn("HeatmapBucket",Ba,{omit:["layers"]});var ja={get paint(){return Oa=Oa||new Eo({"heatmap-radius":new Mo(gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Mo(gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Po(gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ao(gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Po(gt.paint_heatmap["heatmap-opacity"])})}};function Na(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. expected: ${n.length} but got: ${e*i*r}`)}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=Na({},{width:e,height:i},r);Ua(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 Ua(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;if(s===a)throw new Error("srcData equals dstData, so image is already copied");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}class Za{constructor(t,e){Na(this,t,1,e)}resize(t){Va(this,t,1)}clone(){return new Za({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ua(t,e,i,r,n,1)}}class $a{constructor(t,e){Na(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 $a({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ua(t,e,i,r,n,4)}}function Ga(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new $a({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const 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}Hn("AlphaImage",Za),Hn("RGBAImage",$a);const qa="big-fb";class Wa extends zo{createBucket(t){return new Ba(t)}constructor(t){super(t,ja),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ga({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(qa)&&this.heatmapFbos.delete(qa)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}}let Ha;var Xa={get paint(){return Ha=Ha||new Eo({"hillshade-illumination-direction":new Po(gt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Po(gt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Po(gt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Po(gt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Po(gt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Po(gt.paint_hillshade["hillshade-accent-color"])})}};class Ka extends zo{constructor(t){super(t,Xa)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}}const Ya=Fo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ja}=Ya;function Qa(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 tl(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}function el(t,e,i,r,n){let o;if(n===function(t,e,i,r){let n=0;for(let o=e,s=i-r;o<i;o+=r)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}(t,e,i,r)>0)for(let n=e;n<i;n+=r)o=Tl(n/r|0,t[n],t[n+1],o);else for(let n=i-r;n>=e;n-=r)o=Tl(n/r|0,t[n],t[n+1],o);return o&&_l(o,o.next)&&(Sl(o),o=o.next),o}function il(t,e){if(!t)return t;e||(e=t);let i,r=t;do{if(i=!1,r.steiner||!_l(r,r.next)&&0!==gl(r.prev,r,r.next))r=r.next;else{if(Sl(r),r=e=r.prev,r===r.next)break;i=!0}}while(i||r!==e);return e}function rl(t,e,i,r,n,o,s){if(!t)return;!s&&o&&function(t,e,i,r){let n=t;do{0===n.z&&(n.z=ul(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){let e,i=1;do{let r,n=t;t=null;let o=null;for(e=0;n;){e++;let s=n,a=0;for(let t=0;t<i&&(a++,s=s.nextZ,s);t++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(e>1)}(n)}(t,r,n,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?ol(t,r,n,o):nl(t))e.push(l.i,t.i,c.i),Sl(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?rl(t=sl(il(t),e),e,i,r,n,o,2):2===s&&al(t,e,i,r,n,o):rl(il(t),e,i,r,n,o,1);break}}}function nl(t){const e=t.prev,i=t,r=t.next;if(gl(e,i,r)>=0)return!1;const n=e.x,o=i.x,s=r.x,a=e.y,l=i.y,c=r.y,h=Math.min(n,o,s),u=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&fl(n,a,o,l,s,c,f.x,f.y)&&gl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ol(t,e,i,r){const n=t.prev,o=t,s=t.next;if(gl(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(h,u,d),m=Math.max(a,l,c),g=Math.max(h,u,d),_=ul(p,f,e,i,r),y=ul(m,g,e,i,r);let x=t.prevZ,v=t.nextZ;for(;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&fl(a,h,l,u,c,d,x.x,x.y)&&gl(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&fl(a,h,l,u,c,d,v.x,v.y)&&gl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&fl(a,h,l,u,c,d,x.x,x.y)&&gl(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&fl(a,h,l,u,c,d,v.x,v.y)&&gl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function sl(t,e){let i=t;do{const r=i.prev,n=i.next.next;!_l(r,n)&&yl(r,i,i.next,n)&&bl(r,n)&&bl(n,r)&&(e.push(r.i,i.i,n.i),Sl(i),Sl(i.next),i=t=n),i=i.next}while(i!==t);return il(i)}function al(t,e,i,r,n,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&ml(s,t)){let a=wl(s,t);return s=il(s,s.next),a=il(a,a.next),rl(s,e,i,r,n,o,0),void rl(a,e,i,r,n,o,0)}t=t.next}s=s.next}while(s!==t)}function ll(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function cl(t,e){const i=function(t,e){let i=e;const r=t.x,n=t.y;let o,s=-1/0;if(_l(t,i))return i;do{if(_l(t,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=r&&t>s&&(s=t,o=i.x<i.next.x?i:i.next,t===r))return o}i=i.next}while(i!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;i=o;do{if(r>=i.x&&i.x>=l&&r!==i.x&&pl(n<c?r:s,n,l,c,n<c?s:r,n,i.x,i.y)){const e=Math.abs(n-i.y)/(r-i.x);bl(i,t)&&(e<h||e===h&&(i.x>o.x||i.x===o.x&&hl(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const r=wl(i,t);return il(r,r.next),il(i,i.next)}function hl(t,e){return gl(t.prev,t,e.prev)<0&&gl(e.next,t,t.next)<0}function ul(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function dl(t){let 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 pl(t,e,i,r,n,o,s,a){return(n-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(r-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function fl(t,e,i,r,n,o,s,a){return!(t===s&&e===a)&&pl(t,e,i,r,n,o,s,a)}function ml(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&yl(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(bl(t,e)&&bl(e,t)&&function(t,e){let i=t,r=!1;const 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)&&(gl(t.prev,t,e.prev)||gl(t,e.prev,e))||_l(t,e)&&gl(t.prev,t,t.next)>0&&gl(e.prev,e,e.next)>0)}function gl(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function _l(t,e){return t.x===e.x&&t.y===e.y}function yl(t,e,i,r){const n=vl(gl(t,e,i)),o=vl(gl(t,e,r)),s=vl(gl(i,r,t)),a=vl(gl(i,r,e));return n!==o&&s!==a||!(0!==n||!xl(t,i,e))||!(0!==o||!xl(t,r,e))||!(0!==s||!xl(i,t,r))||!(0!==a||!xl(i,e,r))}function xl(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 vl(t){return t>0?1:t<0?-1:0}function bl(t,e){return gl(t.prev,t,t.next)<0?gl(t,e,t.next)>=0&&gl(t,t.prev,e)>=0:gl(t,e,t.prev)<0||gl(t,t.next,e)<0}function wl(t,e){const i=Pl(t.i,t.x,t.y),r=Pl(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 Tl(t,e,i,r){const n=Pl(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 Sl(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 Pl(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ml{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class Il{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}Il.noSubdivision=new Il({fill:new Ml(0,0),line:new Ml(0,0),tile:new Ml(0,0),stencil:new Ml(0,0),circle:1}),Hn("SubdivisionGranularityExpression",Ml),Hn("SubdivisionGranularitySetting",Il);const Cl=-32768,Al=32767;class El{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=C/t,this._canonical=e}_getKey(t,e){return(t+=32768)<<16|(e+=32768)}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(t),r=0|Math.round(e),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const i=[];for(let r=0;r<e.length;r+=3){const n=e[r],o=e[r+1],s=e[r+2],a=t[2*n],l=t[2*n+1];(t[2*o]-a)*(t[2*s+1]-l)-(t[2*o+1]-l)*(t[2*s]-a)>0?(i.push(n),i.push(s),i.push(o)):(i.push(n),i.push(o),i.push(s))}return i}(this._vertexBuffer,t);const e=[],i=t.length;for(let r=0;r<i;r+=3){const i=[t[r+0],t[r+1],t[r+2]],n=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]];let o=1/0,s=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){const e=n[2*t],i=n[2*t+1];o=Math.min(o,e),a=Math.max(a,e),s=Math.min(s,i),l=Math.max(l,i)}if(o===a||s===l)continue;const c=Math.floor(o/this._granularityCellSize),h=Math.ceil(a/this._granularityCellSize),u=Math.floor(s/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(c!==h||u!==d)for(let t=u;t<d;t++){const r=this._scanlineGenerateVertexRingForCellRow(t,n,i);Ll(this._vertexBuffer,r,e)}else e.push(...i)}return e}_scanlineGenerateVertexRingForCellRow(t,e,i){const r=t*this._granularityCellSize,n=r+this._granularityCellSize,o=[];for(let t=0;t<3;t++){const s=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],c=e[(2*(t+1)+1)%6],h=e[2*(t+2)%6],u=e[(2*(t+2)+1)%6],d=l-s,p=c-a,f=0===d,m=0===p,g=(r-a)/p,_=(n-a)/p,y=Math.min(g,_),x=Math.max(g,_);if(!m&&(y>=1||x<=0)||m&&(a<r||a>n)){c>=r&&c<=n&&o.push(i[(t+1)%3]);continue}!m&&y>0&&o.push(this._vertexToIndex(s+d*y,a+p*y));const v=s+d*Math.max(y,0),b=s+d*Math.min(x,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,b),!m&&x<1&&o.push(this._vertexToIndex(s+d*x,a+p*x)),(m||c>=r&&c<=n)&&o.push(i[(t+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(o,s,a,l,c,h,u,b,r,n)}return o}_generateIntraEdgeVertices(t,e,i,r,n,o,s){const a=r-e,l=n-i,c=0===l,h=c?Math.min(e,r):Math.min(o,s),u=c?Math.max(e,r):Math.max(o,s),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(u/this._granularityCellSize)-1;if(c?e<r:o<s)for(let r=d;r<=p;r++){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}else for(let r=p;r>=d;r--){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}}_generateInterEdgeVertices(t,e,i,r,n,o,s,a,l,c){const h=n-i,u=o-r,d=s-n,p=(l-n)/d,f=(c-n)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+u*m;let y=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const b=0===d;if(b&&(s===l||s===c))return;if(b||m>=1||g<=0){const t=i-s,r=o+(e-o)*Math.min((l-s)/t,(c-s)/t);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,v=a<r}const w=h>0?c:l;if(v)for(let e=y;e<=x;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,w));else for(let e=x;e>=y;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,w))}_generateOutline(t){const e=[];for(const i of t){const t=zl(i,this._granularity,!0),r=this._pointArrayToIndices(t),n=[];for(let t=1;t<r.length;t++)n.push(r[t-1]),n.push(r[t]);e.push(n)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){const i=t[e+1];i===Cl&&(t[e+1]=-32767),i===Al&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,r,n,o){r>n!=(o===Cl)?(t.push(e),t.push(i),t.push(this._vertexToIndex(r,o)),t.push(i),t.push(this._vertexToIndex(n,o)),t.push(this._vertexToIndex(r,o))):(t.push(i),t.push(e),t.push(this._vertexToIndex(r,o)),t.push(this._vertexToIndex(n,o)),t.push(i),t.push(this._vertexToIndex(r,o)))}_fillPoles(t,e,i){const r=this._vertexBuffer,n=C,o=t.length;for(let s=2;s<o;s+=3){const o=t[s-2],a=t[s-1],l=t[s],c=r[2*o],h=r[2*o+1],u=r[2*a],d=r[2*a+1],p=r[2*l],f=r[2*l+1];e&&(0===h&&0===d&&this._generatePoleQuad(t,o,a,c,u,Cl),0===d&&0===f&&this._generatePoleQuad(t,a,l,u,p,Cl),0===f&&0===h&&this._generatePoleQuad(t,l,o,p,c,Cl)),i&&(h===n&&d===n&&this._generatePoleQuad(t,o,a,c,u,Al),d===n&&f===n&&this._generatePoleQuad(t,a,l,u,p,Al),f===n&&h===n&&this._generatePoleQuad(t,l,o,p,c,Al))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:r}=function(t){const e=[],i=[];for(const r of t)if(0!==r.length){r!==t[0]&&e.push(i.length/2);for(let t=0;t<r.length;t++)i.push(r[t].x),i.push(r[t].y)}return{flattened:i,holeIndices:e}}(t);let n;this._initializeVertices(i);try{const t=function(t,e,i=2){const r=e&&e.length,n=r?e[0]*i:t.length;let o=el(t,0,n,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(r&&(o=function(t,e,i,r){const n=[];for(let i=0,o=e.length;i<o;i++){const s=el(t,e[i]*r,i<o-1?e[i+1]*r:t.length,r,!1);s===s.next&&(s.steiner=!0),n.push(dl(s))}n.sort(ll);for(let t=0;t<n.length;t++)i=cl(n[t],i);return i}(t,e,o,i)),t.length>80*i){a=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=i;o<n;o+=i){const i=t[o],n=t[o+1];i<a&&(a=i),n<l&&(l=n),i>e&&(e=i),n>r&&(r=n)}c=Math.max(e-a,r-l),c=0!==c?32767/c:0}return rl(o,s,i,a,l,c,0),s}(i,r),e=this._convertIndices(i,t);n=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let o=[];return e&&(o=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_convertIndices(t,e){const i=[];for(let r=0;r<e.length;r++)i.push(this._vertexToIndex(t[2*e[r]],t[2*e[r]+1]));return i}_pointArrayToIndices(t){const e=[];for(let i=0;i<t.length;i++){const r=t[i];e.push(this._vertexToIndex(r.x,r.y))}return e}}function kl(t,e,i,r=!0){return new El(i,e).subdividePolygonInternal(t,r)}function zl(t,e,i=!1){if(!t||t.length<1)return[];if(t.length<2)return[];const r=t[0],n=t[t.length-1],o=i&&(r.x!==n.x||r.y!==n.y);if(e<2)return o?[...t,t[0]]:[...t];const s=Math.floor(C/e),a=[];a.push(new l(t[0].x,t[0].y));const c=t.length,h=o?c:c-1;for(let e=0;e<h;e++){const i=t[e],r=e<c-1?t[e+1]:t[0],n=i.x,o=i.y,h=r.x,u=r.y,d=n!==h,p=o!==u;if(!d&&!p)continue;const f=h-n,m=u-o,g=Math.abs(f),_=Math.abs(m);let y=n,x=o;for(;;){const t=f>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,e=m>0?(Math.floor(x/s)+1)*s:(Math.ceil(x/s)-1)*s,i=Math.abs(y-t),r=Math.abs(x-e),n=Math.abs(y-h),o=Math.abs(x-u),c=d?i/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((n<=i||!d)&&(o<=r||!p))break;if(c<v&&d||!p){y=t,x+=m*c;const e=new l(y,Math.round(x));a[a.length-1].x===e.x&&a[a.length-1].y===e.y||a.push(e)}else{y+=f*v,x=e;const t=new l(Math.round(y),x);a[a.length-1].x===t.x&&a[a.length-1].y===t.y||a.push(t)}}const v=new l(h,u);a[a.length-1].x===v.x&&a[a.length-1].y===v.y||a.push(v)}return a}function Ll(t,e,i){if(0===e.length)throw new Error("Subdivision vertex ring is empty.");let r=0,n=t[2*e[0]];for(let i=1;i<e.length;i++){const o=t[2*e[i]];o<n&&(n=o,r=i)}const o=e.length;let s=r,a=(s+1)%o;for(;;){const r=s-1>=0?s-1:o-1,n=(a+1)%o,l=t[2*e[r]],c=t[2*e[n]],h=t[2*e[s]],u=t[2*e[s]+1],d=t[2*e[a]+1];let p=!1;if(l<c)p=!0;else if(l>c)p=!1;else{const i=d-u,o=-(t[2*e[a]]-h),s=u<d?1:-1;((l-h)*i+(t[2*e[r]+1]-u)*o)*s>((c-h)*i+(t[2*e[n]+1]-u)*o)*s&&(p=!0)}if(p){const t=e[r],n=e[s],l=e[a];t!==n&&t!==l&&n!==l&&i.push(l,n,t),s--,s<0&&(s=o-1)}else{const t=e[n],r=e[s],l=e[a];t!==r&&t!==l&&r!==l&&i.push(l,r,t),a++,a>=o&&(a=0)}if(r===n)break}}function Dl(t,e,i,r,n,o,s,a,l){const c=n.length/2,h=s&&a&&l;if(c<Rs.MAX_VERTEX_ARRAY_LENGTH){const u=e.prepareSegment(c,i,r),d=u.vertexLength;for(let t=0;t<o.length;t+=3)r.emplaceBack(d+o[t],d+o[t+1],d+o[t+2]);let p,f;u.vertexLength+=c,u.primitiveLength+=o.length/3,h&&(f=s.prepareSegment(c,i,a),p=f.vertexLength,f.vertexLength+=c);for(let e=0;e<n.length;e+=2)t(n[e],n[e+1]);if(h)for(let t=0;t<l.length;t++){const e=l[t];for(let t=1;t<e.length;t+=2)a.emplaceBack(p+e[t-1],p+e[t]);f.primitiveLength+=e.length/2}}else!function(t,e,i,r,n,o){const s=[];for(let t=0;t<r.length/2;t++)s.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=2;u<n.length;u+=3){const d=n[u-2],p=n[u-1],f=n[u];let m=s[d]<l,g=s[p]<l,_=s[f]<l;c.vertexLength+((m?1:0)+(g?1:0)+(_?1:0))>Rs.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,m=!0,g=!0,_=!0,h=0);const y=Rl(s,r,o,a,d,m,c),x=Rl(s,r,o,a,p,g,c),v=Rl(s,r,o,a,f,_,c);i.emplaceBack(h+y-l,h+x-l,h+v-l),c.primitiveLength++}}(e,i,r,n,o,t),h&&function(t,e,i,r,n,o){const s=[];for(let t=0;t<r.length/2;t++)s.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=0;u<n.length;u++){const d=n[u];for(let p=1;p<n[u].length;p+=2){const n=d[p-1],u=d[p];let f=s[n]<l,m=s[u]<l;c.vertexLength+((f?1:0)+(m?1:0))>Rs.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,f=!0,m=!0,h=0);const g=Rl(s,r,o,a,n,f,c),_=Rl(s,r,o,a,u,m,c);i.emplaceBack(h+g-l,h+_-l),c.primitiveLength++}}}(s,i,a,n,l,t),e.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Rl(t,e,i,r,n,o,s){if(o){const o=r.count;return i(e[2*n],e[2*n+1]),t[n]=r.count,r.count++,s.vertexLength++,o}return t[n]}class Fl{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 bs,this.indexArray=new ks,this.indexArray2=new zs,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.segments2=new Rs,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qa("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=fa(s,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:pa(s),patterns:{},sortKey:u};o.push(d)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=tl("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{},e.subdivisionGranularity);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 r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ja),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,o){for(const t of Gi(e,500)){const e=kl(t,r,o.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;Dl(((t,e)=>{i.emplaceBack(t,e)}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}}let Bl,Ol;Hn("FillBucket",Fl,{omit:["layers","patternFeatures"]});var jl={get paint(){return Ol=Ol||new Eo({"fill-antialias":new Po(gt.paint_fill["fill-antialias"]),"fill-opacity":new Mo(gt.paint_fill["fill-opacity"]),"fill-color":new Mo(gt.paint_fill["fill-color"]),"fill-outline-color":new Mo(gt.paint_fill["fill-outline-color"]),"fill-translate":new Po(gt.paint_fill["fill-translate"]),"fill-translate-anchor":new Po(gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Io(gt.paint_fill["fill-pattern"])})},get layout(){return Bl=Bl||new Eo({"fill-sort-key":new Mo(gt.layout_fill["fill-sort-key"])})}};class Nl extends zo{constructor(t){super(t,jl)}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 Fl(t)}queryRadius(){return Ea(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return va(ka(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}}const Vl=Fo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ul=Fo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Zl}=Vl;var $l,Gl,ql,Wl,Hl,Xl,Kl,Yl={};function Jl(){if(Gl)return $l;Gl=1;var t=o();function e(t,e,r,n,o){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=o,t.readFields(i,this,e)}function i(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 r(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}return $l=e,e.types=["Unknown","Point","LineString","Polygon"],e.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var i,r=e.readVarint()+e.pos,n=1,o=0,s=0,a=0,l=[];e.pos<r;){if(o<=0){var c=e.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==n)throw new Error("unknown command "+n);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.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]},e.prototype.toGeoJSON=function(t,i,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+l)/a-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+c)/a)*Math.PI/180))-90]}}switch(this.type){case 1:var p=[];for(o=0;o<h.length;o++)p[o]=h[o][0];d(h=p);break;case 2:for(o=0;o<h.length;o++)d(h[o]);break;case 3:for(h=function(t){var e=t.length;if(e<=1)return[t];for(var i,n,o=[],s=0;s<e;s++){var a=r(t[s]);0!==a&&(void 0===n&&(n=a<0),n===a<0?(i&&o.push(i),i=[t[s]]):i.push(t[s]))}return i&&o.push(i),o}(h),o=0;o<h.length;o++)for(s=0;s<h[o].length;s++)d(h[o][s])}1===h.length?h=h[0]:u="Multi"+u;var f={type:"Feature",geometry:{type:u,coordinates:h},properties:this.properties};return"id"in this&&(f.id=this.id),f},$l}function Ql(){if(Wl)return ql;Wl=1;var t=Jl();function e(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(i,this,e),this.length=this._features.length}function i(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))}return ql=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},ql}function tc(){return Kl||(Kl=1,Yl.VectorTile=function(){if(Xl)return Hl;Xl=1;var t=Ql();function e(e,i,r){if(3===e){var n=new t(r,r.readVarint()+r.pos);n.length&&(i[n.name]=n)}}return Hl=function(t,i){this.layers=t.readFields(e,{},i)},Hl}(),Yl.VectorTileFeature=Jl(),Yl.VectorTileLayer=Ql()),Yl}var ec=i(tc());const ic=ec.VectorTileFeature.types,rc=Math.pow(2,13);function nc(t,e,i,r,n,o,s,a){t.emplaceBack(e,i,2*Math.floor(r*rc)+s,n*rc*2,o*rc*2,Math.round(a))}class oc{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 ws,this.centroidVertexArray=new xs,this.indexArray=new ks,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=Qa("fill-extrusion",this.layers,e);for(const{feature:r,id:n,index:o,sourceLayerIndex:s}of t){const t=this.layers[0]._featureFilter.needGeometry,a=fa(r,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:s,index:o,geometry:t?a.geometry:pa(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(tl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,o,i,{},e.subdivisionGranularity),e.featureIndex.insert(r,l.geometry,o,s,this.index,!0)}}addFeatures(t,e,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,r.index,e,i,t.subdivisionGranularity)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Zl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ul.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,n,o){for(const i of Gi(e,500)){const e={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(e,r,t,i,o);const s=this.layoutVertexArray.length-n,a=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t<s;t++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}processPolygon(t,e,i,r,n){if(r.length<1)return;if(lc(r[0]))return;for(const e of r)0!==e.length&&sc(t,e);const o={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=n.fill.getGranularityForZoomLevel(e.z),a="Polygon"===ic[i.type];for(const t of r){if(0===t.length)continue;if(lc(t))continue;const e=zl(t,s,a);this._generateSideFaces(e,o)}if(!a)return;const l=kl(r,e,s,!1),c=this.layoutVertexArray;Dl(((t,e)=>{nc(c,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let r=1;r<t.length;r++){const n=t[r],o=t[r-1];if(ac(n,o))continue;e.segment.vertexLength+4>Rs.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=n.sub(o)._perp()._unit(),a=o.dist(n);i+a>32768&&(i=0),nc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,i),nc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,i),i+=a,nc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),nc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}}function sc(t,e){for(let i=0;i<e.length;i++){const r=e[i];i===e.length-1&&e[0].x===r.x&&e[0].y===r.y||(t.x+=r.x,t.y+=r.y,t.sampleCount++)}}function ac(t,e){return t.x===e.x&&(t.x<0||t.x>C)||t.y===e.y&&(t.y<0||t.y>C)}function lc(t){return t.every((t=>t.x<0))||t.every((t=>t.x>C))||t.every((t=>t.y<0))||t.every((t=>t.y>C))}let cc;Hn("FillExtrusionBucket",oc,{omit:["layers","features"]});var hc={get paint(){return cc=cc||new Eo({"fill-extrusion-opacity":new Po(gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Po(gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Po(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Io(gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Mo(gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Po(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class uc extends zo{constructor(t){super(t,hc)}createBucket(t){return new oc(t)}queryRadius(){return Ea(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,pixelPosMatrix:s}){const a=ka(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,o),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e){const i=[];for(const r of t){const t=[r.x,r.y,0,1];S(t,t,e),i.push(new l(t[0]/t[3],t[1]/t[3]))}return i}(a,s),d=function(t,e,i,r){const n=[],o=[],s=r[8]*e,a=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const n of e){const e=n.x,o=n.y,m=r[0]*e+r[4]*o+r[12],g=r[1]*e+r[5]*o+r[13],_=r[2]*e+r[6]*o+r[14],y=r[3]*e+r[7]*o+r[15],x=_+c,v=y+h,b=m+u,w=g+d,T=_+p,S=y+f,P=new l((m+s)/v,(g+a)/v);P.z=x/v,t.push(P);const M=new l(b/S,w/S);M.z=T/S,i.push(M)}n.push(t),o.push(i)}return[n,o]}(r,h,c,s);return function(t,e,i){let r=1/0;va(i,e)&&(r=pc(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];ya(i,n)&&(r=Math.min(r,pc(i,n)))}}return r!==1/0&&r}(d[0],d[1],u)}}function dc(t,e){return t.x*e.x+t.y*e.y}function pc(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=dc(a,a),u=dc(a,l),d=dc(l,l),p=dc(c,a),f=dc(c,l),m=h*d-u*u,g=(d*p-u*f)/m,_=(h*f-u*p)/m,y=r.z*(1-g-_)+n.z*g+o.z*_;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}}const fc=Fo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:mc}=fc,gc=Fo([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:_c}=gc,yc=ec.VectorTileFeature.types,xc=Math.cos(Math.PI/180*37.5),vc=Math.pow(2,14)/.5;class bc{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 Ts,this.layoutVertexArray2=new Ss,this.indexArray=new ks,this.programConfigurations=new la(t.layers,t.zoom),this.segments=new Rs,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qa("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),o=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=fa(e,t);if(!this.layers[0]._featureFilter.filter(new go(this.zoom),c,i))continue;const h=n?r.evaluate(c,{},i):void 0,u={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:pa(e),patterns:{},sortKey:h};o.push(u)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=tl("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{},e.subdivisionGranularity);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 r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}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,_c)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,mc),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&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap"),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,h,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}addLine(t,e,i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=zl(t,s?a.line.getGranularityForZoomLevel(s.z):1),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 l="Polygon"===yc[e.type];let c=t.length;for(;c>=2&&t[c-1].equals(t[c-2]);)c--;let h=0;for(;h<c-1&&t[h].equals(t[h+1]);)h++;if(c<(l?3:2))return;"bevel"===i&&(n=1.05);const u=this.overscaling<=16?15*C/(512*this.overscaling):0,d=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let p,f,m,g,_;this.e1=this.e2=-1,l&&(p=t[c-2],_=t[h].sub(p)._unit()._perp());for(let e=h;e<c;e++){if(m=e===c-1?l?t[h+1]:void 0:t[e+1],m&&t[e].equals(m))continue;_&&(g=_),p&&(f=p),p=t[e],_=m?m.sub(p)._unit()._perp():g,g=g||_;let s=g.add(_);0===s.x&&0===s.y||s._unit();const a=g.x*_.x+g.y*_.y,y=s.x*_.x+s.y*_.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<xc&&f&&m,w=g.x*_.y-g.y*_.x>0;if(b&&e>h){const t=p.dist(f);if(t>2*u){const e=p.sub(p.sub(f)._mult(u/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,d),f=e}}const T=f&&m;let S=T?i:l?"butt":r;if(T&&"round"===S&&(x<o?S="miter":x<=2&&(S="fakeround")),"miter"===S&&x>n&&(S="bevel"),"bevel"===S&&(x>2&&(S="flipbevel"),x<n&&(S="miter")),f&&this.updateDistance(f,p),"miter"===S)s._mult(x),this.addCurrentVertex(p,s,0,0,d);else if("flipbevel"===S){if(x>100)s=_.mult(-1);else{const t=x*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(f&&this.addCurrentVertex(p,g,e,i,d),"fakeround"===S){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+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)))}const r=_.sub(g)._mult(i)._add(g)._unit()._mult(w?-1:1);this.addHalfVertex(p,r.x,r.y,!1,w,0,d)}}m&&this.addCurrentVertex(p,_,-e,-i,d)}else if("butt"===S)this.addCurrentVertex(p,s,0,0,d);else if("square"===S){const t=f?1:-1;this.addCurrentVertex(p,s,t,t,d)}else"round"===S&&(f&&(this.addCurrentVertex(p,g,0,0,d),this.addCurrentVertex(p,g,1,1,d,!0)),m&&(this.addCurrentVertex(p,_,-1,-1,d,!0),this.addCurrentVertex(p,_,0,0,d)));if(b&&e<c-1){const t=p.dist(m);if(t>2*u){const e=p.add(m.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,_,0,0,d),p=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),this.distance>vc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,n,o))}addHalfVertex({x:t,y:e},i,r,n,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(vc-1):this.scaledDistance);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)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let wc,Tc;Hn("LineBucket",bc,{omit:["layers","patternFeatures"]});var Sc={get paint(){return Tc=Tc||new Eo({"line-opacity":new Mo(gt.paint_line["line-opacity"]),"line-color":new Mo(gt.paint_line["line-color"]),"line-translate":new Po(gt.paint_line["line-translate"]),"line-translate-anchor":new Po(gt.paint_line["line-translate-anchor"]),"line-width":new Mo(gt.paint_line["line-width"]),"line-gap-width":new Mo(gt.paint_line["line-gap-width"]),"line-offset":new Mo(gt.paint_line["line-offset"]),"line-blur":new Mo(gt.paint_line["line-blur"]),"line-dasharray":new Co(gt.paint_line["line-dasharray"]),"line-pattern":new Io(gt.paint_line["line-pattern"]),"line-gradient":new Ao(gt.paint_line["line-gradient"])})},get layout(){return wc=wc||new Eo({"line-cap":new Po(gt.layout_line["line-cap"]),"line-join":new Mo(gt.layout_line["line-join"]),"line-miter-limit":new Po(gt.layout_line["line-miter-limit"]),"line-round-limit":new Po(gt.layout_line["line-round-limit"]),"line-sort-key":new Mo(gt.layout_line["line-sort-key"])})}};class Pc extends Mo{possiblyEvaluate(t,e){return e=new go(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=B({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}let Mc;class Ic extends zo{constructor(t){super(t,Sc),this.gradientVersion=0,Mc||(Mc=new Pc(Sc.paint.properties["line-width"].specification),Mc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Je,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Mc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new bc(t)}queryRadius(t){const e=t,i=Cc(Aa("line-width",this,e),Aa("line-gap-width",this,e)),r=Aa("line-offset",this,e);return i/2+Math.abs(r)+Ea(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o}){const s=ka(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,o),a=o/2*Cc(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=[];for(let r=0;r<t.length;r++){const n=t[r],o=[];for(let t=0;t<n.length;t++){const i=n[t-1],r=n[t],s=n[t+1],a=0===t?new l(0,0):r.sub(i)._unit()._perp(),c=t===n.length-1?new l(0,0):s.sub(r)._unit()._perp(),h=a._add(c)._unit(),u=h.x*c.x+h.y*c.y;0!==u&&h._mult(1/u),o.push(h._mult(e)._add(r))}i.push(o)}return i}(r,c*o)),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(Ia(t,n[e]))return!0;if(ba(t,n,i))return!0}return!1}(s,r,a)}isTileClipped(){return!0}}function Cc(t,e){return e>0?e+2*t:t}const Ac=Fo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ec=Fo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Fo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kc=Fo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Fo([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const zc=Fo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Lc=Fo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Fo([{name:"triangle",components:3,type:"Uint16"}]),Fo([{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"}]),Fo([{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"},{type:"Float32",name:"angle"}]),Fo([{type:"Float32",name:"offsetX"}]),Fo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Fo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Dc={debnames:"Jacob Marisplein",logLineStrings(t,e,i){let r=40265318;for(let t=0;t<e.z;t++)r/=2;const n=e.x*r-20132659,o=20132659-e.y*r,s=r/8192;let a="SELECT 'SRID=33013;MULTILINESTRING(";for(let e=0;e<t.length;e++){const i=t[e];a=`${a}(`;for(let t=0;t<i.length;t++)a=`${a+(i[t].x*s+n)} ${o-i[t].y*s}`,t<i.length-1&&(a=`${a},`);a=`${a})`,e<t.length-1&&(a=`${a},`)}a=`${a})'::geometry`,void 0!==i&&console.log(i),console.log(a)},logPoints(t,e){let i=40265318;for(let t=0;t<e.z;t++)i/=2;const r=e.x*i-20132659,n=20132659-e.y*i,o=i/8192;let s="SELECT 'SRID=33013;MULTIPOINT(";for(let e=0;e<t.length;e++)s=`${s+(t[e].x*o+r)} ${n-t[e].y*o}`,e<t.length-1&&(s=`${s},`);s=`${s})'::geometry`,console.log(s)},logPoint(t,e,i){let r=40265318;for(let t=0;t<e.z;t++)r/=2;const n=e.x*r-20132659,o=20132659-e.y*r,s=r/8192;void 0!==i&&console.log(i),console.log(`SELECT 'SRID=33013;POINT(${t.x*s+n} ${o-t.y*s})'::geometry`)}};function Rc(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Fc(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()),mo.applyArabicShaping&&(t=mo.applyArabicShaping(t)),t}(t.text,e,i)})),t}function Bc(t,e){function i(t,e){const i=e?t[0]:t[t.length-1];return`${i.x}:${i.y}`}function r(t){function e(e){const r=i(t,e),n=s.get(r);o[n]=[],s.delete(r)}e(!0),e(!1)}function n(t,e,i){t!==e&&(s.set(t,i),s.set(e,i))}const o=[],s=new Map;t.lines.forEach((t=>{let a=i(t,!0),l=i(t,!1);const c=s.get(a),h=s.get(l);if(void 0!==c&&void 0!==h&&c!==h){const s=o[c],u=o[h],d=i(s,!0)===a,p=i(u,!0)===l;if(e||!d&&p){r(s),r(u),d&&s.reverse(),p||u.reverse();const e=s.concat(t.slice(1),u.slice(1));a=i(e,!0),l=i(e,!1),o[c]=e,n(a,l,c)}else o.push(t)}else if(void 0!==c||void 0!==h){const s=void 0!==c,u=void 0!==c?c:h,d=o[u],p=i(d,!0)===(void 0!==c?a:l);let f;r(d),s===!p?f=s?d.concat(t.slice(1)):t.concat(d.slice(1)):e?(s&&t.reverse(),p||d.reverse(),f=t.concat(d.slice(1))):(f=d,o.push(t)),a=i(f,!0),l=i(f,!1),o[u]=f,n(a,l,u)}else n(a,l,o.push(t)-1)}));const a=t.feature;return a.geometry=o.filter((t=>t.length>0)),a}const Oc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var jc,Nc,Vc,Uc=24,Zc={};function $c(){return jc||(jc=1,Zc.read=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)},Zc.write=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}function Gc(){if(Vc)return Nc;Vc=1,Nc=e;var t=$c();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,r=1/i,n="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(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 l(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function c(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function h(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function u(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function d(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function p(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function f(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function m(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function g(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function _(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function y(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function x(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.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=_(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=x(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_(this.buf,this.pos)+_(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=_(this.buf,this.pos)+x(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},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 s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return s(t,r,e);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return s(t,r,e);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return s(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&&n?function(t,e,i){return n.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,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var r=o(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(i));return t},readPackedSVarint:function(t){if(this.type!==e.Bytes)return t.push(this.readSVarint());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==e.Bytes)return t.push(this.readBoolean());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==e.Bytes)return t.push(this.readFloat());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==e.Bytes)return t.push(this.readDouble());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed32());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed32());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed64());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed64());var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readSFixed64());return t},skip:function(t){var i=7&t;if(i===e.Varint)for(;this.buf[this.pos++]>127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);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),y(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),y(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),y(this.buf,-1&t,this.pos),y(this.buf,Math.floor(t*r),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),y(this.buf,-1&t,this.pos),y(this.buf,Math.floor(t*r),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&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,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&&a(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,i,r){this.writeTag(t,e.Bytes),this.writeRawMessage(i,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,g,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Nc}var qc=i(Gc());const Wc=3;function Hc(t,e,i){1===t&&i.readMessage(Xc,e)}function Xc(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Kc,{});e.push({id:t,bitmap:new Za({width:n+2*Wc,height:o+2*Wc},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}}function Kc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Yc=Wc;function Jc(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}}const Qc=1;class th{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:o,textFitWidth:s,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i,this.textFitWidth=s,this.textFitHeight=a}get tl(){return[this.paddedRect.x+Qc,this.paddedRect.y+Qc]}get br(){return[this.paddedRect.x+this.paddedRect.w-Qc,this.paddedRect.y+this.paddedRect.h-Qc]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*Qc)/this.pixelRatio,(this.paddedRect.h-2*Qc)/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}=Jc(n),a=new $a({width:o||1,height:s||1});for(const e in t){const r=t[e],n=i[e].paddedRect;$a.copy(r.data,a,{x:0,y:0},{x:n.x+Qc,y:n.y+Qc},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,o=n.x+Qc,s=n.y+Qc,l=i.data.width,c=i.data.height;$a.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),$a.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),$a.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),$a.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),$a.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*Qc,h:n.data.height+2*Qc};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})}}var ih;Hn("ImagePosition",th),Hn("ImageAtlas",eh),t.W=void 0,(ih=t.W||(t.W={}))[ih.none=0]="none",ih[ih.horizontal=1]="horizontal",ih[ih.vertical=2]="vertical",ih[ih.horizontalOnly=3]="horizontalOnly";const rh=-17;class nh{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,e,i){const r=new nh;return r.scale=t||1,r.fontStack=e,r.verticalAlign=i||"bottom",r}static forImage(t,e){const i=new nh;return i.imageName=t,i.verticalAlign=e||"bottom",i}}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&&co(r)&&!Oc[t[i+1]]||n&&co(n)&&!Oc[t[i-1]]||!Oc[t[i]]?t[i]:Oc[t[i]]}return e}(this.text)}trim(){let t=0;for(let e=0;e<this.text.length&&lh[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let i=this.text.length-1;i>=0&&i>=t&&lh[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)}getMaxImageSize(t){let e=0,i=0;for(let r=0;r<this.length();r++){const n=this.getSection(r);if(n.imageName){const r=t[n.imageName];if(!r)continue;const o=r.displaySize;e=Math.max(e,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:e,maxImageHeight:i}}addTextSection(t,e){this.text+=t.text,this.sections.push(nh.forText(t.scale,t.fontStack||e,t.verticalAlign));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 Z("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(nh.forImage(e,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):Z("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){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}function ah(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const g=oh.fromFeature(e,o);let _;d===t.W.vertical&&g.verticalizePunctuation();const{processBidirectionalText:y,processStyledBidirectionalText:x}=mo;if(y&&1===g.sections.length){_=[];const t=y(g.toString(),gh(g,h,s,i,n,f));for(const e of t){const t=new oh;t.text=e,t.sections=g.sections;for(let i=0;i<e.length;i++)t.sectionIndex.push(0);_.push(t)}}else if(x){_=[];const t=x(g.text,g.sectionIndex,gh(g,h,s,i,n,f));for(const e of t){const t=new oh;t.text=e[0],t.sectionIndex=e[1],t.sections=g.sections,_.push(t)}}else _=sh(g,gh(g,h,s,i,n,f));const v=[],b={positionedLines:v,text:g.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:d,iconsInText:!1,verticalizable:!1};return function(t,e,i,r,n,o,s,a,l,c,h,u){let d=0,p=0,f=0,m=0;const g="right"===a?1:"left"===a?0:.5,_=Uc/u;let y=0;for(const s of n){s.trim();const n=s.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[y]=a;const u=a.positionedGlyphs;let x=0;if(!s.length()){p+=o,++y;continue}const v=yh(r,s,_);for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o),g=vh(l,h,m);let y;if(a.imageName){if(t.iconsInText=!0,a.scale=a.scale*_,y=wh(a,g,n,v,r),!y)continue;x=Math.max(x,y.imageOffset)}else if(y=bh(a,m,g,v,e,i),!y)continue;const{rect:b,metrics:w,baselineOffset:T}=y;u.push({glyph:m,imageName:a.imageName,x:d,y:p+T+rh,vertical:g,scale:a.scale,fontStack:a.fontStack,sectionIndex:f,metrics:w,rect:b}),g?(t.verticalizable=!0,d+=(a.imageName?w.advance:Uc)*a.scale+c):d+=w.advance*a.scale+c}0!==u.length&&(f=Math.max(d-c,f),Th(u,0,u.length-1,g)),d=0,a.lineOffset=Math.max(x,(n-1)*Uc);const b=o*n+x;p+=b,m=Math.max(b,m),++y}const{horizontalAlign:x,verticalAlign:v}=_h(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*s+.5*s;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(t.positionedLines,g,x,v,f,m,o,p,n.length),t.top+=-v*p,t.bottom=t.top+p,t.left+=-x*f,t.right=t.left+f}(b,i,r,n,_,a,l,c,d,h,p,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(v)&&b}const lh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},ch={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hh={40:!0};function uh(t,e,i,r,n,o){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*Uc/o+n:0}{const r=i[e.fontStack],o=r&&r[t];return o?o.metrics.advance*e.scale+n:0}}function dh(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 ph(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 fh(t,e,i,r,n,o){let s=null,a=dh(e,i,n,o);for(const t of r){const r=dh(e-t.x,i,n,o)+t.badness;r<=a&&(s=t,a=r)}return{index:t,x:e,priorBreak:s,badness:a}}function mh(t){return t?mh(t.priorBreak).concat(t.index):[]}function gh(t,e,i,r,n,o){if(!t)return[];const s=[],a=function(t,e,i,r,n,o){let s=0;for(let i=0;i<t.length();i++){const a=t.getSection(i);s+=uh(t.getCharCode(i),a,r,n,e,o)}return s/Math.max(1,Math.ceil(s/i))}(t,e,i,r,n,o),l=t.text.indexOf("")>=0;let c=0;for(let i=0;i<t.length();i++){const u=t.getSection(i),d=t.getCharCode(i);if(lh[d]||(c+=uh(d,u,r,n,e,o)),i<t.length()-1){const e=!((h=d)<11904)&&(!!eo["CJK Compatibility Forms"](h)||!!eo["CJK Compatibility"](h)||!!eo["CJK Strokes"](h)||!!eo["CJK Symbols and Punctuation"](h)||!!eo["Enclosed CJK Letters and Months"](h)||!!eo["Halfwidth and Fullwidth Forms"](h)||!!eo["Ideographic Description Characters"](h)||!!eo["Vertical Forms"](h)||ao.test(String.fromCodePoint(h)));(ch[d]||e||u.imageName||i!==t.length()-2&&hh[t.getCharCode(i+1)])&&s.push(fh(i+1,c,a,s,ph(d,t.getCharCode(i+1),e&&l),!1))}}var h;return mh(fh(t.length(),c,a,s,0,!0))}function _h(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 yh(t,e,i){const r=e.getMaxScale()*Uc,{maxImageWidth:n,maxImageHeight:o}=e.getMaxImageSize(t),s=Math.max(r,o*i);return{verticalLineContentWidth:Math.max(r,n*i),horizontalLineContentHeight:s}}function xh(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function vh(e,i,r){return!(e===t.W.horizontal||!i&&!lo(r)||i&&(lh[r]||(n=r,/\p{sc=Arab}/u.test(String.fromCodePoint(n)))));var n}function bh(t,e,i,r,n,o){const s=o[t.fontStack],a=function(t,e,i,r){if(t&&t.rect)return t;const n=e[i.fontStack],o=n&&n[r];return o?{rect:null,metrics:o.metrics}:null}(s&&s[e],n,t,e);if(null===a)return null;let l;if(i)l=r.verticalLineContentWidth-t.scale*Uc;else{const e=xh(t.verticalAlign);l=(r.horizontalLineContentHeight-t.scale*Uc)*e}return{rect:a.rect,metrics:a.metrics,baselineOffset:l}}function wh(t,e,i,r,n){const o=n[t.imageName];if(!o)return null;const s=o.paddedRect,a=o.displaySize,l={width:a[0],height:a[1],left:Qc,top:-3,advance:e?a[1]:a[0]};let c;if(e)c=r.verticalLineContentWidth-a[1]*t.scale;else{const e=xh(t.verticalAlign);c=(r.horizontalLineContentHeight-a[1]*t.scale)*e}return{rect:s,metrics:l,baselineOffset:c,imageOffset:(e?a[0]:a[1])*t.scale-Uc*i}}function Th(t,e,i,r){if(0===r)return;const n=t[i],o=(t[i].x+n.metrics.advance*n.scale)*r;for(let r=e;r<=i;r++)t[r].x-=o}function Sh(t,e,i){const{horizontalAlign:r,verticalAlign:n}=_h(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 Ph(t){var e,i;let r=t.left,n=t.top,o=t.right-r,s=t.bottom-n;const a=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",l=null!==(i=t.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",c=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&o/s<c||"proportional"===a){const t=Math.ceil(s*c);r*=t/o,o=t}}else if("proportional"===a&&"stretchOnly"===l&&0!==c&&o/s>c){const t=Math.ceil(o/c);n*=t/s,s=t}return{x1:r,y1:n,x2:r+o,y2:n+s}}function Mh(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}}const Ih=255,Ch=128,Ah=Ih*Ch;function Eh(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new go(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 go(s)),maxSize:i.evaluate(new go(a)),interpolationType:r}}}function kh(t,e,i){let r="never";const n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}const zh=ec.VectorTileFeature.types,Lh=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Dh(t,e,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(Ah,Math.round(a[0])):0,f=a?Math.min(Ah,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 Rh(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 Fh(t){for(const e of t.sections)if(fo(e.text))return!0;return!1}class Bh{constructor(t){this.layoutVertexArray=new Ms,this.indexArray=new ks,this.programConfigurations=t,this.segments=new Rs,this.dynamicLayoutVertexArray=new Is,this.opacityVertexArray=new Cs,this.hasVisibleVertices=!1,this.placedSymbolArray=new hs}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,Ac.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Ec.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Lh,!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())}}Hn("SymbolBuffers",Bh);class Oh{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Rs,this.collisionVertexArray=new Es}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,kc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Hn("CollisionBuffers",Oh);class jh{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Eh(this.zoom,i["text-size"]),this.iconSizeData=Eh(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap="never"!==kh(r,"text-overlap","text-allow-overlap")||"never"!==kh(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.W[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Bh(new la(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bh(new la(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ps,this.lineVertexArray=new fs,this.symbolInstances=new ds,this.textAnchorOffsets=new gs}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=Oc[t.charAt(o)];i&&(e[i.charCodeAt(0)]=!0)}}populate(e,i,r){const n=this.layers[0],o=n.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Se&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new go(this.zoom);let g=!1;for(const{feature:i,id:a,index:l,sourceLayerIndex:_}of e){const e=n._featureFilter.needGeometry,y=fa(i,e);if(!n._featureFilter.filter(m,y,r))continue;let x,v;if(e||(y.geometry=pa(i)),c){const t=n.getValueAndResolveTokens("text-field",y,r,f),e=Se.factory(t),i=this.hasRTLText=this.hasRTLText||Fh(e);(!i||"unavailable"===mo.getRTLTextPluginStatus()||i&&mo.isParsed())&&(x=Fc(e,n,y))}if(h){const t=n.getValueAndResolveTokens("icon-image",y,r,f);v=t instanceof Ae?t:Ae.fromString(t),v&&(g=!0)}if(!(x&&x.toString()||v))continue;const b=this.sortFeaturesByKey?u.evaluate(y,{},r):void 0;if(this.features.push({id:a,text:x,icon:v,index:l,sourceLayerIndex:_,geometry:y.geometry,properties:i.properties,type:zh[i.type],sortKey:b}),v&&(d[v.name]=!0),x){const e=s.evaluate(y,{},r).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.W.vertical)>=0;for(const t of x.sections)if(t.image)d[t.image.name]=!0;else{const r=io(x.toString()),n=t.fontStack||e,o=p[n]=p[n]||{};this.calculateGlyphDependencies(t.text,o,i,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(t,e){const i={};t.forEach((t=>{const e=t.text?t.text.toString():"nn>";let r=i[e];void 0===r&&(r={feature:t,lines:[]},i[e]=r),t.geometry.forEach((t=>r.lines.push(t)))}));const r=[];for(const t in i)r.push(Bc(i[t],e));return r}(this.features,!g),this.features.forEach((t=>{var e;t.geometry.forEach((t=>{t.len=Rc(t)})),t.geometry.sort(((t,e)=>e.len-t.len)),t.text instanceof Se&&(null===(e=t.text)||void 0===e?void 0:e.toString())===Dc.debnames&&Dc.logLineStrings(t.geometry,r)}))),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(e,i,r,n,o,s,a,l,c,h,u,d){const p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*i.length,f,p,this.canOverlap?s.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&a===t.W.vertical?Math.PI/2:0,x=s.text&&s.text.sections;for(let t=0;t<i.length;t++){const{tl:n,tr:o,bl:a,br:c,tex:h,pixelOffsetTL:u,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=i[t],S=m.vertexLength,P=b[1];Dh(f,l.x,l.y,n.x,P+n.y,h.x,h.y,r,w,u.x,u.y,_,v),Dh(f,l.x,l.y,o.x,P+o.y,h.x+h.w,h.y,r,w,g.x,u.y,_,v),Dh(f,l.x,l.y,a.x,P+a.y,h.x,h.y+h.h,r,w,u.x,g.y,_,v),Dh(f,l.x,l.y,c.x,P+c.y,h.x+h.w,h.y+h.h,r,w,g.x,g.y,_,v),Rh(e.dynamicLayoutVertexArray,l,y),p.emplaceBack(S,S+2,S+1),p.emplaceBack(S+1,S+2,S+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),t!==i.length-1&&T===i[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(f.length,s,s.index,{},d,x&&x[T])}e.placedSymbolArray.emplaceBack(l.x,l.y,g,this.glyphOffsetArray.length-g,_,c,h,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],a,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,r,n,o){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,n,Math.round(o.x),Math.round(o.y))}addCollisionDebugVertices(t,e,i,r,n,o,s){const a=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),c=a.vertexLength,h=n.layoutVertexArray,u=n.collisionVertexArray,d=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(h,u,o,d,p,new l(t,e)),this._addCollisionDebugVertex(h,u,o,d,p,new l(i,e)),this._addCollisionDebugVertex(h,u,o,d,p,new l(i,r)),this._addCollisionDebugVertex(h,u,o,d,p,new l(t,r)),a.vertexLength+=4;const f=n.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),a.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let n=t;n<e;n++){const t=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Oh(As,zc.members,zs),this.iconCollisionBox=new Oh(As,zc.members,zs);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_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,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,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,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,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+2,e+1),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)}}}let Nh,Vh;Hn("SymbolBucket",jh,{omit:["layers","collisionBoxArray","features","compareText"]}),jh.MAX_GLYPHS=65535,jh.addDynamicAttributes=Rh;var Uh={get paint(){return Vh=Vh||new Eo({"icon-opacity":new Mo(gt.paint_symbol["icon-opacity"]),"icon-color":new Mo(gt.paint_symbol["icon-color"]),"icon-halo-color":new Mo(gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Mo(gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Mo(gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Po(gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Po(gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Mo(gt.paint_symbol["text-opacity"]),"text-color":new Mo(gt.paint_symbol["text-color"],{runtimeType:Ft,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Mo(gt.paint_symbol["text-halo-color"]),"text-halo-width":new Mo(gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Mo(gt.paint_symbol["text-halo-blur"]),"text-translate":new Po(gt.paint_symbol["text-translate"]),"text-translate-anchor":new Po(gt.paint_symbol["text-translate-anchor"])})},get layout(){return Nh=Nh||new Eo({"symbol-placement":new Po(gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Po(gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Po(gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Mo(gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Po(gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Po(gt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Po(gt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Po(gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Po(gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Po(gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Mo(gt.layout_symbol["icon-size"]),"icon-text-fit":new Po(gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Po(gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Mo(gt.layout_symbol["icon-image"]),"icon-rotate":new Mo(gt.layout_symbol["icon-rotate"]),"icon-padding":new Mo(gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Po(gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Mo(gt.layout_symbol["icon-offset"]),"icon-anchor":new Mo(gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Po(gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Po(gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Po(gt.layout_symbol["text-rotation-alignment"]),"text-field":new Mo(gt.layout_symbol["text-field"]),"text-font":new Mo(gt.layout_symbol["text-font"]),"text-size":new Mo(gt.layout_symbol["text-size"]),"text-max-width":new Mo(gt.layout_symbol["text-max-width"]),"text-line-height":new Po(gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Mo(gt.layout_symbol["text-letter-spacing"]),"text-justify":new Mo(gt.layout_symbol["text-justify"]),"text-radial-offset":new Mo(gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Po(gt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Mo(gt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Mo(gt.layout_symbol["text-anchor"]),"text-max-angle":new Po(gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Po(gt.layout_symbol["text-writing-mode"]),"text-rotate":new Mo(gt.layout_symbol["text-rotate"]),"text-padding":new Po(gt.layout_symbol["text-padding"]),"text-keep-upright":new Po(gt.layout_symbol["text-keep-upright"]),"text-transform":new Mo(gt.layout_symbol["text-transform"]),"text-offset":new Mo(gt.layout_symbol["text-offset"]),"text-allow-overlap":new Po(gt.layout_symbol["text-allow-overlap"]),"text-overlap":new Po(gt.layout_symbol["text-overlap"]),"text-ignore-placement":new Po(gt.layout_symbol["text-ignore-placement"]),"text-optional":new Po(gt.layout_symbol["text-optional"])})}};class Zh{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:zt,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}}Hn("FormatSectionOverride",Zh,{omit:["defaultValue"]});class $h extends zo{constructor(t){super(t,Uh)}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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"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()||Gr(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new jh(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Uh.paint.overridableProperties){if(!$h.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Zh(e),r=new $r(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Wr("source",r):new Hr("composite",r,e.value.zoomStops),this.paint._values[t]=new To(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&$h.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Uh.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 Se)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof Re&&Le(e.value)===Vt?o(e.value.sections):e instanceof xi?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}}let Gh;var qh={get paint(){return Gh=Gh||new Eo({"background-color":new Po(gt.paint_background["background-color"]),"background-pattern":new Co(gt.paint_background["background-pattern"]),"background-opacity":new Po(gt.paint_background["background-opacity"])})}};class Wh extends zo{constructor(t){super(t,qh)}}let Hh;var Xh={get paint(){return Hh=Hh||new Eo({"raster-opacity":new Po(gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Po(gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Po(gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Po(gt.paint_raster["raster-brightness-max"]),"raster-saturation":new Po(gt.paint_raster["raster-saturation"]),"raster-contrast":new Po(gt.paint_raster["raster-contrast"]),"raster-resampling":new Po(gt.paint_raster["raster-resampling"]),"raster-fade-duration":new Po(gt.paint_raster["raster-fade-duration"])})}};class Kh extends zo{constructor(t){super(t,Xh)}}class Yh extends zo{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Jh{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Qh={once:!0};function tu(t,e,i,r,n){const o=[];for(let s=0;s<t.length;s++){const a=t[s];let c;for(let t=0;t<a.length-1;t++){let s=a[t],h=a[t+1];s.x<e&&h.x<e||(s.x<e?s=new l(e,s.y+(e-s.x)/(h.x-s.x)*(h.y-s.y))._round():h.x<e&&(h=new l(e,s.y+(e-s.x)/(h.x-s.x)*(h.y-s.y))._round()),s.y<i&&h.y<i||(s.y<i?s=new l(s.x+(i-s.y)/(h.y-s.y)*(h.x-s.x),i)._round():h.y<i&&(h=new l(s.x+(i-s.y)/(h.y-s.y)*(h.x-s.x),i)._round()),s.x>=r&&h.x>=r||(s.x>=r?s=new l(r,s.y+(r-s.x)/(h.x-s.x)*(h.y-s.y))._round():h.x>=r&&(h=new l(r,s.y+(r-s.x)/(h.x-s.x)*(h.y-s.y))._round()),s.y>=n&&h.y>=n||(s.y>=n?s=new l(s.x+(n-s.y)/(h.y-s.y)*(h.x-s.x),n)._round():h.y>=n&&(h=new l(s.x+(n-s.y)/(h.y-s.y)*(h.x-s.x),n)._round()),c&&s.equals(c[c.length-1])||(c=[s],o.push(c)),c.push(h)))))}}return o}const eu=6371008.8;class iu{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 iu(F(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 eu*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof iu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new iu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new iu(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 ru=2*Math.PI*eu;function nu(t){return ru*Math.cos(t*Math.PI/180)}function ou(t){return(180+t)/360}function su(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function au(t,e){return t/nu(e)}function lu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function cu(t,e){return t*nu(lu(e))}class hu{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=iu.convert(t);return new hu(ou(i.lng),su(i.lat),au(e,i.lat))}toLngLat(){return new iu(360*this.x-180,lu(this.y))}toAltitude(){return cu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ru*(t=lu(this.y),1/Math.cos(t*Math.PI/180));var t}}function uu(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 du{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,i))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=mu(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(o=this.y,s=this.z,a=uu(256*(n=this.x),256*(o=Math.pow(2,s)-o-1),s),l=uu(256*(n+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,o,s,a,l;const c=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}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*C,(t.y*e-this.y)*C)}toString(){return`${this.z}/${this.x}/${this.y}`}}class pu{constructor(t,e){this.wrap=t,this.canonical=e,this.key=mu(t,e.z,e.z,e.x,e.y)}}class fu{constructor(t,e,i,r,n){if(this.terrainRttPosMatrix32f=null,t<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new du(i,+r,+n),this.key=mu(e,t,i,r,n)}clone(){return new fu(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new fu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?mu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):mu(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 fu(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 fu(e,this.wrap,e,i,r),new fu(e,this.wrap,e,i+1,r),new fu(e,this.wrap,e,i,r+1),new fu(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 fu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new fu(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 pu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new hu(t.x-this.wrap,t.y))}}function mu(t,e,i,r,n){(t*=2)<0&&(t=-1*t-1);const o=1<<i;return(o*o*t+o*n+r).toString(36)+i.toString(36)+e.toString(36)}Hn("CanonicalTileID",du),Hn("OverscaledTileID",fu,{omit:["terrainRttPosMatrix32f"]});class gu{constructor(t,e,i,r=1,n=1,o=1,s=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void Z(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=r,this.greenFactor=n,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;t<a;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(a,t)]=this.data[this._idx(a-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,a)]=this.data[this._idx(t,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<a;t++)for(let e=0;e<a;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return this.unpack(i[r],i[r+1],i[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_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)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}getPixels(){return new $a({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)]}}Hn("DEMData",gu);class _u{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){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class yu{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}}class xu{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new qn(C,16,0),this.grid3D=new qn(C,16,0),this.featureIndexArray=new ys,this.promoteId=e}insert(t,e,i,r,n,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=o?this.grid3D: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]<C&&r[1]<C&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ec.VectorTile(new qc(this.rawTileData)).layers,this.sourceLayerCoder=new _u(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){var n;this.loadVTLayers();const o=null!==(n=t.params)&&void 0!==n?n:{},s=C/t.tileSize/t.scale,a=tn(o.filter),c=t.queryGeometry,h=t.queryPadding*s,u=bu(c),d=this.grid.query(u.minX-h,u.minY-h,u.maxX+h,u.maxY+h,null,o.skipGeoCheck),p=bu(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-h,p.minY-h,p.maxX+h,p.maxY+h,((e,i,r,n)=>function(t,e,i,r,n){for(const o of t)if(e<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new l(e,i),new l(e,n),new l(r,n),new l(r,i)];if(t.length>2)for(const e of o)if(Ia(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Ca(t[e],t[e+1],o))return!0;return!1}(t.cameraQueryGeometry,e-h,i-h,r+h,n+h)));for(const t of f)d.push(t);d.sort(wu);const m={};let g;for(let n=0;n<d.length;n++){const l=d[n];if(l===g)continue;g=l;const h=this.featureIndexArray.get(l);let u=null;this.loadMatchingFeature(m,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,a,o.layers,o.availableImages,e,i,r,((e,i,r)=>(u||(u=pa(e)),o.skipGeoCheck||i.queryIntersectsFeature({queryGeometry:c,feature:e,featureState:r,geometry:u,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))))}return m}loadMatchingFeature(t,e,i,r,n,o,s,a,l,c,h){const u=this.bucketLayerIDs[e];if(o&&!u.some((t=>o.has(t))))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(n.needGeometry){const t=fa(p,!0);if(!n.filter(new go(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new go(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let e=0;e<u.length;e++){const i=u[e];if(o&&!o.has(i))continue;const n=a[i];if(!n)continue;let d={};f&&c&&(d=c.getState(n.sourceLayer||"_geojsonTileLayer",f));const m=B({},l[i]);m.paint=vu(m.paint,n.paint,p,d,s),m.layout=vu(m.layout,n.layout,p,d,s);const g=!h||h(p,n,d);if(!g)continue;const _=new yu(p,this.z,this.x,this.y,f);_.layer=m;let y=t[i];void 0===y&&(y=t[i]=[]),y.push({featureIndex:r,feature:_,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=tn(n);for(const n of t)this.loadMatchingFeature(l,i,r,n,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){var i;let r=t.id;return this.promoteId&&(r=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(i=t.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(r=Number(t.properties.cluster_id))),r}}function vu(t,e,i,r,n){return j(t,((t,o)=>{const s=e instanceof So?e.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function bu(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of t)e=Math.min(e,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return{minX:e,minY:i,maxX:r,maxY:n}}function wu(t,e){return e-t}Hn("FeatureIndex",xu,{omit:["rawTileData","sourceLayerCoder"]});class Tu extends l{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new Tu(this.x,this.y,this.angle,this.segment)}}Hn("Anchor",Tu);class Su{constructor(t){this.curDist=0,this.totalDistance=0,this.segm=-1,this.cs=t}travelRouteAbsolute(t){return this.segm=-1,this.travelRouteRelative(t)}travelRouteRelative(t){let e;this.segm<1&&(e=this.cs[0],this.segm=1,this.curDist=0,this.totalDistance=0);let i=this.cs[this.segm-1];this.curDist=this.curDist+t,this.totalDistance=this.totalDistance+t;let r=this.curDist;if(t<0)for(0===r&&(e=i);r<0&&this.segm>1;){const t=this.cs[this.segm-2],n=i.dist(t);r+=n,this.curDist+=n,this.segm--,i=t,e=t}for(;r>0&&this.segm<this.cs.length;){const t=this.cs[this.segm],n=i.dist(t);if(n<r)r-=n,this.curDist-=n,this.segm++,i=t,e=t;else{const o=r/n;e=new l(i.x+(t.x-i.x)*o,i.y+(t.y-i.y)*o),r=0}}return r>0&&(e=this.cs[this.cs.length-1]),r<=0?e:null}angleOfCurrentSegm(){return this.cs[this.segm].angleTo(this.cs[this.segm-1])}}function Pu(t,e,i,r,n){if(void 0===e.segment||0===i)return!0;let o=e,s=e.segment+1,a=0;for(;a>-i/2&&(s--,!(s<0));)a-=t[s].dist(o),o=t[s];s=Math.max(s,0),a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const e=t[s-1],i=t[s],o=t[s+1];if(!o)break;let h=e.angleTo(i)-i.angleTo(o);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:h}),c+=h;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=i.dist(o)}return!0}function Mu(t,e,i){return t?.6*e*i:0}function Iu(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Cu(t,e,i,r,n,o){const s=Mu(i,n,o),a=Iu(i,r)*o;let l=0;const c=Rc(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=si.number(r.x,n.x,h),d=si.number(r.y,n.y,h),p=new Tu(u,d,n.angleTo(r),i);return p._round(),!s||Pu(t,p,a,s,e)?p:void 0}l+=o}}function Au(t,e,i,r,n,o,s,a,l,c,h){var u;const d=Mu(r,o,s),p=Iu(r,n)*s,f=p/4,m=Rc(t),g=(null===(u=null==r?void 0:r.text)||void 0===u?void 0:u.toString())===Dc.debnames;function _(e,r,n,o){if(e.x>=0&&e.x<l&&e.y>=0&&e.y<l&&n-f>=0&&n+f<=m){const n=new Tu(e.x,e.y,o,r);if(n._round(),!d||Pu(t,n,p,d,i))return b.push(n),!0;g&&Dc.logPoint(n,c,"Skipped anchor")}return!1}let y=Math.floor((m-e)/(p+e));y<=0&&(y=1),h&&(y=1),y>1&&(e=(m-y*p)/(y+1));const x=1===y?m/2:(e+p)/2;let v=x;g&&Dc.logLineStrings([t],c,`debnames anchorCount=${y}, spacing=${e}, firstAnchorOffset=${x}, lineLength=${m}, labelLength=${p}`);const b=[],w=new Su(t);for(;b.length<y;){const t=w.travelRouteRelative(v);if(!t)break;_(t,w.segm-1,w.totalDistance,w.angleOfCurrentSegm())?(v=e,w.travelRouteRelative(p)):v=2}if(0===b.length)for(g&&Dc.logLineStrings(t,c,`no anchors found, search back from ${x}`),w.travelRouteAbsolute(x);0===b.length;){const t=w.travelRouteRelative(-2);if(!t)break;_(t,w.segm-1,w.totalDistance,w.angleOfCurrentSegm())}return b}const Eu=Qc;function ku(t,e,i,r){const n=[],o=t.image,s=o.pixelRatio,a=o.paddedRect.w-2*Eu,c=o.paddedRect.h-2*Eu;let h={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const u=o.stretchX||[[0,a]],d=o.stretchY||[[0,c]],p=(t,e)=>t+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),g=a-f,_=c-m;let y=0,x=f,v=0,b=m,w=0,T=g,S=0,P=_;if(o.content&&r){const e=o.content,i=e[2]-e[0],r=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(h=Ph(t)),y=zu(u,0,e[0]),v=zu(d,0,e[1]),x=zu(u,e[0],e[2]),b=zu(d,e[1],e[3]),w=e[0]-y,S=e[1]-v,T=i-x,P=r-b}const M=h.x1,I=h.y1,C=h.x2-M,A=h.y2-I,E=(t,r,n,a)=>{const c=Du(t.stretch-y,x,C,M),h=Ru(t.fixed-w,T,t.stretch,f),u=Du(r.stretch-v,b,A,I),d=Ru(r.fixed-S,P,r.stretch,m),p=Du(n.stretch-y,x,C,M),g=Ru(n.fixed-w,T,n.stretch,f),_=Du(a.stretch-v,b,A,I),E=Ru(a.fixed-S,P,a.stretch,m),k=new l(c,u),z=new l(p,u),L=new l(p,_),D=new l(c,_),R=new l(h/s,d/s),F=new l(g/s,E/s),B=e*Math.PI/180;if(B){const t=Math.sin(B),e=Math.cos(B),i=[e,-t,t,e];k._matMult(i),z._matMult(i),D._matMult(i),L._matMult(i)}const O=t.stretch+t.fixed,j=r.stretch+r.fixed;return{tl:k,tr:z,bl:D,br:L,tex:{x:o.paddedRect.x+Eu+O,y:o.paddedRect.y+Eu+j,w:n.stretch+n.fixed-O,h:a.stretch+a.fixed-j},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:T/s/C,minFontScaleY:P/s/A,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const t=Lu(u,g,f),e=Lu(d,_,m);for(let i=0;i<t.length-1;i++){const r=t[i],o=t[i+1];for(let t=0;t<e.length-1;t++)n.push(E(r,e[t],o,e[t+1]))}}else n.push(E({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:c+1}));return n}function zu(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 Lu(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+Eu,stretch:i}),r}function Du(t,e,i,r){return t/e*i+r}function Ru(t,e,i,r){return t-e*i/r}class Fu{constructor(t,e,i,r,n,o,s,a,c,h,u,d=[0,0],p="center"){var f;if(this.boxStartIndex=t.length,c){let t=o.top,e=o.bottom;const i=o.collisionPadding;i&&(t-=i[1],e+=i[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const{x1:c,x2:m,y1:g,y2:_}=u?function(t,e,i=[0,0],r="center"){const n=t.right-t.left,o=t.bottom-t.top,{horizontalAlign:s,verticalAlign:a}=_h(r),l=i[0]+e[0]-n*s,c=i[1]+e[1]-o*a;return{x1:l,y1:c,x2:l+e[2]-e[0],y2:c+e[3]-e[1]}}(o,u,d,p):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom},y=(null===(f=o.image)||void 0===f?void 0:f.content)&&(o.image.textFitWidth||o.image.textFitHeight)?Ph(o):{x1:c,y1:g,x2:m,y2:_};y.y1=y.y1*s-a[0],y.y2=y.y2*s+a[2],y.x1=y.x1*s-a[3],y.x2=y.x2*s+a[1];const x=o.collisionPadding;if(x&&(y.x1-=x[0]*s,y.y1-=x[1]*s,y.x2+=x[2]*s,y.y2+=x[3]*s),h){const t=new l(y.x1,y.y1),e=new l(y.x2,y.y1),i=new l(y.x1,y.y2),r=new l(y.x2,y.y2),n=h*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),y.x1=Math.min(t.x,e.x,i.x,r.x),y.x2=Math.max(t.x,e.x,i.x,r.x),y.y1=Math.min(t.y,e.y,i.y,r.y),y.y2=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,y.x1,y.y1,y.x2,y.y2,i,r,n)}this.boxEndIndex=t.length}}class Bu{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){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._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--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);const o=r+1;if(o<this.length&&i(e[o],e[r])<0&&(r=o),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}}function Ou(t,e=1,i=!1){let r=1/0,n=1/0,o=-1/0,s=-1/0;const a=t[0];for(let t=0;t<a.length;t++){const e=a[t];(!t||e.x<r)&&(r=e.x),(!t||e.y<n)&&(n=e.y),(!t||e.x>o)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const c=Math.min(o-r,s-n);let h=c/2;const u=new Bu([],ju);if(0===c)return new l(r,n);for(let e=r;e<o;e+=c)for(let i=n;i<s;i+=c)u.push(new Nu(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 Nu(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 Nu(r.p.x-h,r.p.y-h,h,t)),u.push(new Nu(r.p.x+h,r.p.y-h,h,t)),u.push(new Nu(r.p.x-h,r.p.y+h,h,t)),u.push(new Nu(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 ju(t,e){return e.max-t.max}function Nu(t,e,i,r){this.p=new l(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,Pa(t,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Vu;t.aB=void 0,(Vu=t.aB||(t.aB={}))[Vu.center=1]="center",Vu[Vu.left=2]="left",Vu[Vu.right=3]="right",Vu[Vu.top=4]="top",Vu[Vu.bottom=5]="bottom",Vu[Vu["top-left"]=6]="top-left",Vu[Vu["top-right"]=7]="top-right",Vu[Vu["bottom-left"]=8]="bottom-left",Vu[Vu["bottom-right"]=9]="bottom-right";const Uu=7,Zu=Number.POSITIVE_INFINITY;function $u(t,e){return e[1]!==Zu?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-Uu;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+Uu}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.SQRT2;switch(t){case"top-right":case"top-left":r=n-Uu;break;case"bottom-right":case"bottom-left":r=-n+Uu;break;case"bottom":r=-e+Uu;break;case"top":r=e-Uu}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 Gu(t,e,i){var r;const n=t.layout,o=null===(r=n.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(e,{},i);if(o){const t=o.values,e=[];for(let i=0;i<t.length;i+=2){const r=e[i]=t[i],n=t[i+1].map((t=>t*Uc));r.startsWith("top")?n[1]-=Uu:r.startsWith("bottom")&&(n[1]+=Uu),e[i+1]=n}return new Ce(e)}const s=n.get("text-variable-anchor");if(s){let r;r=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[n.get("text-radial-offset").evaluate(e,{},i)*Uc,Zu]:n.get("text-offset").evaluate(e,{},i).map((t=>t*Uc));const o=[];for(const t of s)o.push(t,$u(t,r));return new Ce(o)}return null}function qu(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 Wu(e,i,r,n,o,s,a,l,c,h,u,d){var p;let f=s.textMaxSize.evaluate(i,{});void 0===f&&(f=a);const m=e.layers[0].layout,g=m.get("icon-offset").evaluate(i,{},u),_=Xu(r.horizontal),y=a/24,x=e.tilePixelRatio*y,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*m.get("symbol-spacing"),T=m.get("text-padding")*e.tilePixelRatio,S=function(t,e,i,r=1){const n=t.get("icon-padding").evaluate(e,{},i),o=n&&n.values;return[o[0]*r,o[1]*r,o[2]*r,o[3]*r]}(m,i,u,e.tilePixelRatio),P=m.get("text-max-angle")/180*Math.PI,M="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),I="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),A=m.get("symbol-placement"),E=w/2,k=m.get("icon-text-fit");let z;n&&"none"!==k&&(e.allowVerticalPlacement&&r.vertical&&(z=Mh(n,r.vertical,k,m.get("icon-text-fit-padding"),g,y)),_&&(n=Mh(n,_,k,m.get("icon-text-fit-padding"),g,y)));const L=u?d.line.getGranularityForZoomLevel(u.z):1,D=(l,d)=>{d.x<0||d.x>=C||d.y<0||d.y>=C||function(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P){const M=e.addToLineVertexArray(i,r);let I,C,A,E,k=0,z=0,L=0,D=0,R=-1,F=-1;const B={};let O=Gs("");if(e.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},S)+90;A=new Fu(c,i,h,u,d,n.vertical,p,f,m,t),a&&(E=new Fu(c,i,h,u,d,a,_,y,m,t))}if(o){const r=b.properties["icon-collision-box"],n=l.layout.get("icon-anchor").evaluate(b,{},S),s=l.layout.get("icon-rotate").evaluate(b,{}),p="none"!==l.layout.get("icon-text-fit"),f=ku(o,s,T,p),m=a?ku(a,s,T,p):void 0;C=new Fu(c,i,h,u,d,o,_,y,!1,s,r,v,n),k=4*f.length;const g=e.iconSizeData;let P=null;"source"===g.kind?(P=[Ch*l.layout.get("icon-size").evaluate(b,{})],P[0]>Ah&&Z(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ih}. Reduce your "icon-size".`)):"composite"===g.kind&&(P=[Ch*w.compositeIconSizes[0].evaluate(b,{},S),Ch*w.compositeIconSizes[1].evaluate(b,{},S)],(P[0]>Ah||P[1]>Ah)&&Z(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ih}. Reduce your "icon-size".`)),e.addSymbols(e.icon,f,P,v,x,b,t.W.none,i,M.lineStartIndex,M.lineLength,-1,S),R=e.icon.placedSymbolArray.length-1,m&&(z=4*m.length,e.addSymbols(e.icon,m,P,v,x,b,t.W.vertical,i,M.lineStartIndex,M.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1)}const j=Object.keys(n.horizontal);for(const r of j){const o=n.horizontal[r];if(!I){O=Gs(o.text);const t=l.layout.get("text-rotate").evaluate(b,{},S);I=new Fu(c,i,h,u,d,o,p,f,m,t)}const a=1===o.positionedLines.length;if(L+=Hu(e,i,o,s,l,m,b,g,M,n.vertical?t.W.horizontal:t.W.horizontalOnly,a?j:[r],B,R,w,S),a)break}n.vertical&&(D+=Hu(e,i,n.vertical,s,l,m,b,g,M,t.W.vertical,["vertical"],B,F,w,S));const N=I?I.boxStartIndex:e.collisionBoxArray.length,V=I?I.boxEndIndex:e.collisionBoxArray.length,U=A?A.boxStartIndex:e.collisionBoxArray.length,$=A?A.boxEndIndex:e.collisionBoxArray.length,G=C?C.boxStartIndex:e.collisionBoxArray.length,q=C?C.boxEndIndex:e.collisionBoxArray.length,W=E?E.boxStartIndex:e.collisionBoxArray.length,H=E?E.boxEndIndex:e.collisionBoxArray.length;let X=-1;const K=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=K(I,X),X=K(A,X),X=K(C,X),X=K(E,X);const Y=X>-1?1:0;Y&&(X*=P/Uc),e.glyphOffsetArray.length>=jh.MAX_GLYPHS&&Z("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const J=Gu(l,b,S),[Q,tt]=function(e,i){const r=e.length,n=null==i?void 0:i.values;if((null==n?void 0:n.length)>0)for(let i=0;i<n.length;i+=2){const r=n[i+1];e.emplaceBack(t.aB[n[i]],r[0],r[1])}return[r,e.length]}(e.textAnchorOffsets,J);e.symbolInstances.emplaceBack(i.x,i.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,R,F,O,N,V,U,$,G,q,W,H,h,L,D,k,z,Y,0,p,X,Q,tt,i.angle)}(e,d,l,r,n,o,z,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,x,[T,T,T,T],M,c,b,S,I,g,i,s,h,u,a)};if("line"===A)for(const t of tu(i.geometry,0,0,C,C)){const o=zl(t,L),s=Au(o,w,P,r.vertical||_,n,24,v,0,C,u,e.layerIds[0].endsWith("-abbr"));for(const t of s)_&&Ku(e,_.text,E,t)||D(o,t);(null===(p=null==_?void 0:_.text)||void 0===p?void 0:p.toString())===Dc.debnames&&(Dc.logLineStrings(tu(i.geometry,0,0,C,C),u),Dc.logPoints(s,u))}else if("line-center"===A){for(const t of i.geometry)if(t.length>1){const e=zl(t,L),i=Cu(e,P,r.vertical||_,n,24,v);i&&D(e,i)}}else if("Polygon"===i.type)for(const t of Gi(i.geometry,0)){const e=Ou(t,16);D(zl(t[0],L,!0),new Tu(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry){const e=zl(t,L);D(e,new Tu(e[0].x,e[0].y,0))}else if("Point"===i.type)for(const t of i.geometry)for(const e of t)D([e],new Tu(e.x,e.y,0))}function Hu(t,e,i,r,n,o,s,a,c,h,u,d,p,f,m){const g=function(t,e,i,r,n,o,s,a){const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const r of t.positionedGlyphs){if(!r.rect)continue;const o=r.rect||{};let u=Yc+1,d=!0,p=1,f=0;const m=(n||a)&&r.vertical,g=r.metrics.advance*r.scale/2;if(a&&e.verticalizable&&(f=t.lineOffset/2-(r.imageName?-(Uc-r.metrics.width*r.scale)/2:(r.scale-1)*Uc)),r.imageName){const t=s[r.imageName];d=t.sdf,p=t.pixelRatio,u=Qc/p}const _=n?[r.x+g,r.y]:[0,0];let y=n?[0,0]:[r.x+g+i[0],r.y+i[1]-f],x=[0,0];m&&(x=y,y=[0,0]);const v=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-u)*r.scale-g+y[0],w=(-r.metrics.top-u)*r.scale+y[1],T=b+o.w/v*r.scale/p,S=w+o.h/v*r.scale/p,P=new l(b,w),M=new l(T,w),I=new l(b,S),C=new l(T,S);if(m){const t=new l(-g,g-rh),e=-Math.PI/2,i=Uc/2-g,n=new l(5-rh-i,-(r.imageName?i:0)),o=new l(...x);P._rotateAround(e,t)._add(n)._add(o),M._rotateAround(e,t)._add(n)._add(o),I._rotateAround(e,t)._add(n)._add(o),C._rotateAround(e,t)._add(n)._add(o)}if(c){const t=Math.sin(c),e=Math.cos(c),i=[e,-t,t,e];P._matMult(i),M._matMult(i),I._matMult(i),C._matMult(i)}const A=new l(0,0),E=new l(0,0);h.push({tl:P,tr:M,bl:I,br:C,tex:o,writingMode:e.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:A,pixelOffsetBR:E,minFontScaleX:0,minFontScaleY:0})}return h}(0,i,a,n,o,s,r,t.allowVerticalPlacement),_=t.textSizeData;let y=null;"source"===_.kind?(y=[Ch*n.layout.get("text-size").evaluate(s,{})],y[0]>Ah&&Z(`${t.layerIds[0]}: Value for "text-size" is >= ${Ih}. Reduce your "text-size".`)):"composite"===_.kind&&(y=[Ch*f.compositeTextSizes[0].evaluate(s,{},m),Ch*f.compositeTextSizes[1].evaluate(s,{},m)],(y[0]>Ah||y[1]>Ah)&&Z(`${t.layerIds[0]}: Value for "text-size" is >= ${Ih}. Reduce your "text-size".`)),t.addSymbols(t.text,g,y,a,o,s,h,e,c.lineStartIndex,c.lineLength,p,m);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function Xu(t){for(const e in t)return t[e];return null}function Ku(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 Yu=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Ju{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Yu[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Ju(s,o,n,t)}constructor(t,e=64,i=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const n=Yu.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Qu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=t&&a<=i&&c>=e&&c<=r&&l.push(n[s])}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=t&&p<=i&&f>=e&&f<=r&&l.push(n[d]),(0===c?t<=p:e<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)rd(n[2*i],n[2*i+1],t,e)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];rd(p,f,t,e)<=l&&a.push(r[d]),(0===c?t-i<=p:e-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?t+i>=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Qu(t,e,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;td(t,e,s,r,n,o),Qu(t,e,i,r,s-1,1-o),Qu(t,e,i,s+1,n,1-o)}function td(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);td(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(ed(t,e,r,i),e[2*n+o]>s&&ed(t,e,r,n);a<l;){for(ed(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*r+o]===s?ed(t,e,r,l):(l++,ed(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function ed(t,e,i,r){id(t,i,r),id(e,2*i,2*r),id(e,2*i+1,2*r+1)}function id(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function rd(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}var nd;t.cn=void 0,(nd=t.cn||(t.cn={})).create="create",nd.load="load",nd.fullLoad="fullLoad";let od=null,sd=[];const ad=1e3/60,ld="loadTime",cd="fullLoadTime",hd={mark(t){performance.mark(t)},frame(t){const e=t;null!=od&&sd.push(e-od),od=e},clearMetrics(){od=null,sd=[],performance.clearMeasures(ld),performance.clearMeasures(cd);for(const e in t.cn)performance.clearMarks(t.cn[e])},getPerformanceMetrics(){performance.measure(ld,t.cn.create,t.cn.load),performance.measure(cd,t.cn.create,t.cn.fullLoad);const e=performance.getEntriesByName(ld)[0].duration,i=performance.getEntriesByName(cd)[0].duration,r=sd.length,n=1/(sd.reduce(((t,e)=>t+e),0)/r/1e3),o=sd.filter((t=>t>ad)).reduce(((t,e)=>t+(e-ad)/ad),0);return{loadTime:e,fullLoadTime:i,fps:n,percentDroppedFrames:o/(r+o)*100,totalFrames:r}}};t.$=function(t,e,i,r){const n=e.y-t.y,o=e.x-t.x,s=r.y-i.y,a=r.x-i.x,c=s*o-a*n;if(0===c)return null;const h=(a*(t.y-i.y)-s*(t.x-i.x))/c;return new l(t.x+h*o,t.y+h*n)},t.A=g,t.B=si,t.C=go,t.D=Po,t.E=mt,t.F=Un,t.G=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return q},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Jh((()=>this.process())),this.subscription=J(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=G(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}sendAsync(t,e){return new Promise(((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=e?J(e.signal,"abort",(()=>{null==o||o.unsubscribe(),delete this.resolveRejects[n];const e={id:n,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)}),Qh):null;this.resolveRejects[n]={resolve:t=>{null==o||o.unsubscribe(),i(t)},reject:t=>{null==o||o.unsubscribe(),r(t)}};const s=[],a=Object.assign(Object.assign({},t),{id:n,sourceMapId:this.mapId,origin:location.origin,data:Jn(t.data,s)});this.target.postMessage(a,{transfer:s})}))}receive(t){const e=t.data,i=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];const t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(G(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,i){return e(this,void 0,void 0,(function*(){if("<response>"===i.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(i.error?e.reject(Qn(i.error)):e.resolve(Qn(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Qn(i.data),r=new AbortController;this.abortControllers[t]=r;try{const n=yield this.messageHandlers[i.type](i.sourceMapId,e,r);this.completeTask(t,null,n)}catch(e){this.completeTask(t,e)}}))}completeTask(t,e,i){const r=[];delete this.abortControllers[t];const n={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?Jn(e):null,data:Jn(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},t.I=th,t.J=st,t.K=R,t.L=function(){var t=new g(16);return g!=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.M=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.N=function(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?R(ni.interpolationFactor(n,e,o,s),0,1):0;"camera"===t.kind?r=si.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}},t.O=function(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/Ch:"composite"===t.kind?si.number(r/Ch,n/Ch,i):e},t.P=l,t.Q=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],g=e[14],_=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,S=h*m-u*f,P=h*g-d*f,M=h*_-p*f,I=u*g-d*m,C=u*_-p*m,A=d*_-p*g,E=y*A-x*C+v*I+b*M-w*P+T*S;return E?(t[0]=(a*A-l*C+c*I)*(E=1/E),t[1]=(n*C-r*A-o*I)*E,t[2]=(m*T-g*w+_*b)*E,t[3]=(d*w-u*T-p*b)*E,t[4]=(l*M-s*A-c*P)*E,t[5]=(i*A-n*M+o*P)*E,t[6]=(g*v-f*T-_*x)*E,t[7]=(h*T-d*v+p*x)*E,t[8]=(s*C-a*M+c*S)*E,t[9]=(r*M-i*C-o*S)*E,t[10]=(f*w-m*v+_*y)*E,t[11]=(u*v-h*w-p*y)*E,t[12]=(a*P-s*I-l*S)*E,t[13]=(i*I-r*P+n*S)*E,t[14]=(m*x-f*b-g*y)*E,t[15]=(h*b-u*x+d*y)*E,t):null},t.R=$a,t.S=M,t.T=xo,t.U=function(t){return Math.hypot(t[0],t[1])},t.V=function(t){return t[0]=0,t[1]=0,t},t.X=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},t.Y=Rh,t.Z=S,t._=e,t.a=nt,t.a$=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.a0=tu,t.a1=ya,t.a2=y,t.a3=function(t,e,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],g=i[1],_=i[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+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*g+u*_+e[12],t[13]=n*m+l*g+d*_+e[13],t[14]=o*m+c*g+p*_+e[14],t[15]=s*m+h*g+f*_+e[15]),t},t.a4=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of t)e=Math.min(e,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return[e,i,r,n]},t.a5=Uc,t.a6=function(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],g=e[13],_=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*g,t[2]=x*o+v*c+b*p+w*_,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*g,t[6]=x*o+v*c+b*p+w*_,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*g,t[10]=x*o+v*c+b*p+w*_,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*g,t[14]=x*o+v*c+b*p+w*_,t[15]=x*s+v*h+b*f+w*y,t},t.a7=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.a8=iu,t.a9=su,t.aA=function(t,e,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const o=n?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(o){const t=Math.sin(o),e=Math.cos(o);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[n?i[0]:A(e,i[0],t.zoom,t.detailLevel),n?i[1]:A(e,i[1],t.zoom,t.detailLevel)]},t.aC=kh,t.aD=qu,t.aE=_h,t.aF=Ju,t.aG=Fo,t.aH=Il,t.aI=xs,t.aJ=Rs,t.aK=ks,t.aL=F,t.aM=Q,t.aN=cu,t.aO=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},t.aP=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.aQ=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=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.aS=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.aT=function(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},t.aU=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.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=pu,t.aX=mu,t.aY=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.aZ=function(t){var e=new g(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.a_=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.aa=ou,t.ab=p,t.ac=f,t.ad=X,t.ae=fu,t.af=C,t.ag=hu,t.ah=25,t.ai=du,t.aj=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const i of t){const t=window.document.createElement("source");ht(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))},t.ak=Ct,t.al=function(){return O++},t.am=ls,t.an=jh,t.ao=tn,t.ap=fa,t.aq=yu,t.ar=function(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},t.as=function(t){return t*Math.PI/180},t.at=function(t){return Math.pow(2,t)},t.au=85.051129,t.av=au,t.aw=function(t){return Math.log(t)/Math.LN2},t.ax=function(t){var e=t[0],i=t[1];return e*e+i*i},t.ay=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i},t.az=A,t.b=W,t.b$=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.b0=function(){const t=new Float32Array(16);return y(t),t},t.b1=function(){const t=new Float64Array(16);return y(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,i){const r=new Float64Array(4);return function(t,e,i,r){var n=.5*Math.PI/180;e*=n,i*=n,r*=n;var o=Math.sin(e),s=Math.cos(e),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);t[0]=o*l*h-s*a*c,t[1]=s*a*h+o*l*c,t[2]=s*l*c-o*a*h,t[3]=s*l*h+o*a*c}(r,t,e-90,i),r},t.b4=function(t,e,i,r){var n,o,s,a,l,c=e[0],h=e[1],u=e[2],d=e[3],p=i[0],f=i[1],g=i[2],_=i[3];return(o=c*p+h*f+u*g+d*_)<0&&(o=-o,p=-p,f=-f,g=-g,_=-_),1-o>m?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),t[0]=a*c+l*p,t[1]=a*h+l*f,t[2]=a*u+l*g,t[3]=a*d+l*_,t},t.b5=function(t){const e=new Float64Array(9);var i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x;u=(n=(r=t)[0])*(l=n+n),d=(o=r[1])*l,f=(s=r[2])*l,m=s*(c=o+o),_=(a=r[3])*l,y=a*c,x=a*(h=s+s),(i=e)[0]=1-(p=o*c)-(g=s*h),i[3]=d-x,i[6]=f+y,i[1]=d+x,i[4]=1-u-g,i[7]=m-_,i[2]=f-y,i[5]=m+_,i[8]=1-u-p;const v=Q(-Math.asin(R(e[2],-1,1)));let b,w;return Math.hypot(e[5],e[8])<.001?(b=0,w=-Q(Math.atan2(e[3],e[4]))):(b=Q(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),w=Q(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:b,pitch:v+90,bearing:w}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=ve,t.b8=Ys,t.b9=Cl,t.bA=function(t){if("custom"===t.type)return new Yh(t);switch(t.type){case"background":return new Wh(t);case"circle":return new Ra(t);case"fill":return new Nl(t);case"fill-extrusion":return new uc(t);case"heatmap":return new Wa(t);case"hillshade":return new Ka(t);case"line":return new Ic(t);case"raster":return new Kh(t);case"symbol":return new $h(t)}},t.bB=V,t.bC=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!xt(t.version,e.version))return[{command:"setStyle",args:[e]}];xt(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),xt(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),xt(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),xt(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),xt(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),xt(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),xt(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),xt(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),xt(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),xt(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),xt(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),xt(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),xt(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const r={},n=[];!function(t,e,i,r){let n;for(n in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)||wt(n,i,r));for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)?xt(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&St(t,e,n)?vt(i,{command:"setGeoJSONSourceData",args:[n,e[n].data]}):Tt(n,e,i,r)):bt(n,e,i))}(t.sources,e.sources,n,r);const o=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):o.push(t)})),i=i.concat(n),function(t,e,i){e=e||[];const r=(t=t||[]).map(Mt),n=e.map(Mt),o=t.reduce(It,{}),s=e.reduce(It,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p;for(let t=0,e=0;t<r.length;t++)c=r[t],Object.prototype.hasOwnProperty.call(s,c)?e++:(vt(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,e),1));for(let t=0,e=0;t<n.length;t++)c=n[n.length-1-t],a[a.length-1-t]!==c&&(Object.prototype.hasOwnProperty.call(o,c)?(vt(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-e),1)):e++,d=a[a.length-t],vt(i,{command:"addLayer",args:[s[c],d]}),a.splice(a.length-t,0,c),l[c]=!0);for(let t=0;t<n.length;t++)if(c=n[t],h=o[c],u=s[c],!l[c]&&!xt(h,u))if(xt(h.source,u.source)&&xt(h["source-layer"],u["source-layer"])&&xt(h.type,u.type)){for(p in Pt(h.layout,u.layout,i,c,null,"setLayoutProperty"),Pt(h.paint,u.paint,i,c,null,"setPaintProperty"),xt(h.filter,u.filter)||vt(i,{command:"setFilter",args:[c,u.filter]}),xt(h.minzoom,u.minzoom)&&xt(h.maxzoom,u.maxzoom)||vt(i,{command:"setLayerZoomRange",args:[c,u.minzoom,u.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Pt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):xt(h[p],u[p])||vt(i,{command:"setLayerProperty",args:[c,p,u[p]]}));for(p in u)Object.prototype.hasOwnProperty.call(u,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Pt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):xt(h[p],u[p])||vt(i,{command:"setLayerProperty",args:[c,p,u[p]]}))}else vt(i,{command:"removeLayer",args:[c]}),d=a[a.lastIndexOf(c)+1],vt(i,{command:"addLayer",args:[u,d]})}(o,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i},t.bD=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.bE=function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],i[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(e).length!==Object.keys(i).length)return!1;for(const r in e)if(!t(e[r],i[r]))return!1;return!0}return e===i},t.bF=j,t.bG=N,t.bH=function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)for(let r=0;r<4;r++)if(t[i][r]!==e[i][r])return!1;return!0},t.bI=class extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.bJ=Qs,t.bK=class extends Ks{constructor(t,e){super(t,e),this.current=ta}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.bL=Js,t.bM=class extends Ks{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.bN=class extends Ks{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.bO=_,t.bP=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.bQ=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.bR=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.bS=class extends Ko{},t.bT=Lc,t.bU=class extends Jo{},t.bV=qa,t.bW=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.bX=Ga,t.bY=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.bZ=class extends No{},t.b_=class extends os{},t.ba=Al,t.bb=Ml,t.bc=k,t.bd=z,t.be=Ee,t.bf=function(t,e,i,r,n){return k(r,n,R((t-e)/(i-e),0,1))},t.bg=E,t.bh=function(){return new Float64Array(3)},t.bi=function(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},t.bj=T,t.bk=function(){return new Float64Array(4)},t.bl=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bm=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bn=function(t,e,i,r){var n=[],o=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},t.bo=v,t.bp=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.bq=function(t,e){const i=E(t,360),r=E(e,360),n=r-i,o=r>i?n-360:n+360;return Math.abs(n)<Math.abs(o)?n:o},t.br=function(t){return t[0]=0,t[1]=0,t[2]=0,t},t.bs=function(t,e,i,r){const n=Math.sqrt(t*t+e*e),o=Math.sqrt(i*i+r*r);t/=n,e/=n,i/=o,r/=o;const s=Math.acos(t*i+e*r);return-e*i+t*r>0?s:-s},t.bt=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bu=eu,t.bv=function(t,e){const i=E(t,2*Math.PI),r=E(e,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))},t.bw=function(){const t={},e=gt.$version;for(const i in gt.$root){const r=gt.$root[i];if(r.required){let n=null;n="version"===i?e:"array"===r.type?[]:{},null!=n&&(t[i]=n)}}return t},t.bx=to,t.by=lt,t.bz=function(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]=yt(t[i],e[t[i].ref]));return t},t.c=rt,t.c0=function(t,e){var i=t[0],r=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],g=t[13],_=t[14],y=t[15],x=e[0],v=e[1],b=e[2],w=e[3],T=e[4],S=e[5],P=e[6],M=e[7],I=e[8],C=e[9],A=e[10],E=e[11],k=e[12],z=e[13],L=e[14],D=e[15];return Math.abs(i-x)<=m*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(r-v)<=m*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=m*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=m*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(a-S)<=m*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(l-P)<=m*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(c-M)<=m*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-I)<=m*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(u-C)<=m*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(d-A)<=m*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(p-E)<=m*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(f-k)<=m*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(g-z)<=m*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-L)<=m*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(y-D)<=m*Math.max(1,Math.abs(y),Math.abs(D))},t.c1=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.c2=t=>"symbol"===t.type,t.c3=t=>"circle"===t.type,t.c4=t=>"heatmap"===t.type,t.c5=t=>"line"===t.type,t.c6=t=>"fill"===t.type,t.c7=t=>"fill-extrusion"===t.type,t.c8=t=>"hillshade"===t.type,t.c9=t=>"raster"===t.type,t.cA=bc,t.cB=Fl,t.cC=oc,t.cD=ec,t.cE=qc,t.cF=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cG=function(t,i,r,n,o){return e(this,void 0,void 0,(function*(){if(f())try{return yield X(t,i,r,n,o)}catch(t){}return function(t,e,i,r,n){const o=t.width,s=t.height;K&&Y||(K=new OffscreenCanvas(o,s),Y=K.getContext("2d",{willReadFrequently:!0})),K.width=o,K.height=s,Y.drawImage(t,0,0,o,s);const a=Y.getImageData(e,i,r,n);return Y.clearRect(0,0,o,s),a.data}(t,i,r,n,o)}))},t.cH=gu,t.cI=i,t.cJ=o,t.cK=tc,t.cL=Gc,t.cM=mo,t.ca=t=>"background"===t.type,t.cb=t=>"custom"===t.type,t.cc=L,t.cd=function(t,e,i){const r=I(e.x-i.x,e.y-i.y),n=I(t.x-i.x,t.y-i.y);var o,s;return Q(Math.atan2(r[0]*n[1]-r[1]*n[0],(o=r)[0]*(s=n)[0]+o[1]*s[1]))},t.ce=D,t.cf=function(t,e){return et[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.cg=function(t,e){return tt[e]&&"touches"in t},t.ch=function(t){return tt[t]||et[t]},t.ci=function(t,e,i){var 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},t.cj=function(t,e){const{x:i,y:r}=hu.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)},t.ck=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.cl=class extends jo{},t.cm=hd,t.co=function(t){return t.message===it},t.cp=function(t,e,i,r,n,o){const s=Se.fromString(t),a=oh.fromFeature(s,e);return sh(a,gh(a,i*Uc,r*Uc,o,{},n))},t.cq=at,t.cr=function(t,e){nt.REGISTERED_PROTOCOLS[t]=e},t.cs=function(t){delete nt.REGISTERED_PROTOCOLS[t]},t.ct=qr,t.cu=function(t,e){const i={};for(let r=0;r<t.length;r++){const n=e&&e[t[r].id]||hn(t[r]);e&&(e[t[r].id]=n);let o=i[n];o||(o=i[n]=[]),o.push(t[r])}const r=[];for(const t in i)r.push(i[t]);return r},t.cv=Hn,t.cw=_u,t.cx=xu,t.cy=eh,t.cz=function(e){var i,r,n,o,s;e.bucket.createArrays(),e.bucket.tilePixelRatio=C/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const a=e.bucket.layers[0],l=a.layout,c=a.metadata,h=a._unevaluatedLayout._values,u={layoutIconSize:h["icon-size"].possiblyEvaluate(new go(e.bucket.zoom+1),e.canonical),layoutTextSize:h["text-size"].possiblyEvaluate(new go(e.bucket.zoom+1),e.canonical),textMaxSize:h["text-size"].possiblyEvaluate(new go(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;u.compositeTextSizes=[h["text-size"].possiblyEvaluate(new go(t),e.canonical),h["text-size"].possiblyEvaluate(new go(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;u.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new go(t),e.canonical),h["icon-size"].possiblyEvaluate(new go(i),e.canonical)]}const d=l.get("text-line-height")*Uc,p="viewport"!==l.get("text-rotation-alignment")&&"point"!==l.get("symbol-placement"),f=l.get("text-keep-upright"),m=l.get("text-size");for(const h of e.bucket.features){const g=l.get("text-font").evaluate(h,{},e.canonical).join(","),_=m.evaluate(h,{},e.canonical),y=u.layoutTextSize.evaluate(h,{},e.canonical),x=u.layoutIconSize.evaluate(h,{},e.canonical),v={horizontal:{},vertical:void 0},b=h.text;let w,T=[0,0];if(b){const r=b.toString(),n=null!==(i=null==c?void 0:c["text-letter-spacing-correction"])&&void 0!==i?i:0,o=(l.get("text-letter-spacing").evaluate(h,{},e.canonical)+n)*Uc,s=ro(r)?o:0,u=l.get("text-anchor").evaluate(h,{},e.canonical),m=Gu(a,h,e.canonical);if(!m){const t=l.get("text-radial-offset").evaluate(h,{},e.canonical);T=t?$u(u,[t*Uc,Zu]):l.get("text-offset").evaluate(h,{},e.canonical).map((t=>t*Uc))}let x=p?"center":l.get("text-justify").evaluate(h,{},e.canonical);const w="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(h,{},e.canonical)*Uc:1/0,S=()=>{e.bucket.allowVerticalPlacement&&io(r)&&(v.vertical=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,"left",s,T,t.W.vertical,!0,y,_))};if(!p&&m){const i=new Set;if("auto"===x)for(let t=0;t<m.values.length;t+=2)i.add(qu(m.values[t]));else i.add(x);let r=!1;for(const n of i)if(!v.horizontal[n])if(r)v.horizontal[n]=v.horizontal[0];else{const i=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,"center",n,s,T,t.W.horizontal,!1,y,_);i&&(v.horizontal[n]=i,r=1===i.positionedLines.length)}S()}else{"auto"===x&&(x=qu(u));const i=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,x,s,T,t.W.horizontal,!1,y,_);i&&(v.horizontal[x]=i),S(),io(r)&&p&&f&&(v.vertical=ah(b,e.glyphMap,e.glyphPositions,e.imagePositions,g,w,d,u,x,s,T,t.W.vertical,!1,y,_))}}let S=!1;if(h.icon&&h.icon.name){const t=e.imageMap[h.icon.name];if(t){w=Sh(e.imagePositions[h.icon.name],l.get("icon-offset").evaluate(h,{},e.canonical),l.get("icon-anchor").evaluate(h,{},e.canonical)),S=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=S:e.bucket.sdfIcons!==S&&Z("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer");const i=null!==(n=null===(r=h.properties)||void 0===r?void 0:r["icon-rotate"])&&void 0!==n?n:l.get("icon-rotate").constantOr(1),a=null!==(s=null===(o=h.properties)||void 0===o?void 0:o["icon-size"])&&void 0!==s?s:l.get("icon-size").constantOr(1);t.pixelRatio===e.bucket.pixelRatio&&0===i&&1===a||(e.bucket.iconsNeedLinear=!0)}}const P=Xu(v.horizontal)||v.vertical;e.bucket.iconsInText=!!P&&P.iconsInText,(P||w)&&Wu(e.bucket,h,v,w,e.imageMap,u,y,x,T,S,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},t.d=ht,t.e=B,t.f=t=>e(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw 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.`)}})),t.g=ot,t.h=t=>new Promise(((e,i)=>{const r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=H}))},r.onerror=()=>i(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 Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):H})),t.i=G,t.j=(t,e)=>ct(B(t,{type:"json"}),e),t.k=ft,t.l=pt,t.m=ct,t.n=(t,e)=>ct(B(t,{type:"arrayBuffer"}),e),t.o=function(t){return new qc(t).readFields(Hc,[])},t.p=Jc,t.q=Za,t.r=Eo,t.s=J,t.t=Vn,t.u=eo,t.v=gt,t.w=Z,t.x=Gn,t.y=Nn,t.z=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}}})),i("worker",["./shared"],(function(t){class e{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,i){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.bA(i);e._featureFilter=t.ao(e.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=t.cu(Object.values(this._layerConfigs),this.keyCache);for(const t of r){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)}}}class i{constructor(e){const i={},r=[];for(const t in e){const n=e[t],o=i[t]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),o[t]={rect:i,metrics:e.metrics}}}const{w:n,h:o}=t.p(r),s=new t.q({width:n||1,height:o||1});for(const r in e){const n=e[r];for(const e in n){const o=n[+e];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[r][e].rect;t.q.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}t.cv("GlyphAtlas",i);class r{constructor(e){this.tileID=new t.ae(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,r,o,s,a){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.am;const l=new t.cw(Object.keys(e.layers).sort()),c=new t.cx(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:o,subdivisionGranularity:a},d=r.familiesBySource[this.source];for(const i in d){const r=e.layers[i];if(!r)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let t=0;t<r.length;t++){const e=r.feature(t),n=c.getId(e,i);a.push({feature:e,id:n,index:t,sourceLayerIndex:s})}for(const e of d[i]){const i=e[0];i.source!==this.source&&t.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.minzoom&&this.zoom<Math.floor(i.minzoom)||i.maxzoom&&this.zoom>=i.maxzoom||"none"!==i.visibility&&(n(e,this.zoom,o),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map((t=>t.id))))}}const p=t.bF(u.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const t=new AbortController;this.inFlightDependencies.push(t),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const m=Object.keys(u.iconDependencies);let g=Promise.resolve({});if(m.length){const t=new AbortController;this.inFlightDependencies.push(t),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},t)}const _=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(_.length){const t=new AbortController;this.inFlightDependencies.push(t),y=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[x,v,b]=yield Promise.all([f,g,y]),w=new i(x),T=new t.cy(v,b);for(const e in h){const i=h[e];i instanceof t.an?(n(i.layers,this.zoom,o),t.cz({bucket:i,glyphMap:x,glyphPositions:w.positions,imageMap:v,imagePositions:T.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):i.hasPattern&&(i instanceof t.cA||i instanceof t.cB||i instanceof t.cC)&&(n(i.layers,this.zoom,o),i.addFeatures(u,this.tileID.canonical,T.patternPositions))}return this.status="done",{buckets:Object.values(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:w.image,imageAtlas:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?v:null,glyphPositions:this.returnDependencies?w.positions:null}}))}}function n(e,i,r){const n=new t.C(i);for(const t of e)t.recalculate(n,r)}class o{constructor(t,e,i){this.actor=t,this.layerIndex=e,this.availableImages=i,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const r=yield t.n(e.request,i);try{return{vectorTile:new t.cD.VectorTile(new t.cE(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires}}catch(t){const i=new Uint8Array(r.data);let n=`Unable to parse the tile at ${e.request.url}, `;throw n+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.message}`,new Error(n)}}))}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid,n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.cF(e.request),o=new r(e);this.loading[i]=o;const s=new AbortController;o.abort=s;try{const r=yield this.loadVectorTile(e,s);if(delete this.loading[i],!r)return null;const a=r.rawData,l={};r.expires&&(l.expires=r.expires),r.cacheControl&&(l.cacheControl=r.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}o.vectorTile=r.vectorTile;const h=o.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);this.loaded[i]=o,this.fetching[i]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const e=yield h;return t.e({rawTileData:a.slice(0)},e,l,c)}finally{delete this.fetching[i]}}catch(t){throw delete this.loading[i],o.status="done",this.loaded[i]=o,t}}))}reloadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[i];if(r.showCollisionBoxes=e.showCollisionBoxes,"parsing"===r.status){const n=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:e,cacheControl:r,resourceTiming:s}=this.fetching[i];delete this.fetching[i],o=t.e({rawTileData:e.slice(0)},n,r,s)}else o=n;return o}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){const t=this.loading,i=e.uid;t&&t[i]&&t[i].abort&&(t[i].abort.abort(),delete t[i])}))}removeTile(e){return t._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]}))}}class s{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:i,encoding:r,rawImageData:n,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=e,c=n.width+2,h=n.height+2,u=t.b(n)?new t.R({width:c,height:h},yield t.cG(n,-1,-1,c,h)):n,d=new t.cH(i,u,r,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d}))}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}var a,l,c=function(){if(l)return a;function t(t,i){if(0!==t.length){e(t[0],i);for(var r=1;r<t.length;r++)e(t[r],!i)}}function e(t,e){for(var i=0,r=0,n=0,o=t.length,s=o-1;n<o;s=n++){var a=(t[n][0]-t[s][0])*(t[s][1]+t[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}return l=1,a=function e(i,r){var n,o=i&&i.type;if("FeatureCollection"===o)for(n=0;n<i.features.length;n++)e(i.features[n],r);else if("GeometryCollection"===o)for(n=0;n<i.geometries.length;n++)e(i.geometries[n],r);else if("Feature"===o)e(i.geometry,r);else if("Polygon"===o)t(i.coordinates,r);else if("MultiPolygon"===o)for(n=0;n<i.coordinates.length;n++)t(i.coordinates[n],r);return i}}(),h=t.cI(c);const u=t.cD.VectorTileFeature.prototype.toGeoJSON;class d{constructor(e){this._feature=e,this.extent=t.af,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.P(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.P(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return u.call(this,t,e,i)}}class p{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.af,this.length=e.length,this._features=e}feature(t){return new d(this._features[t])}}var f,m,g,_={exports:{}},y=function(){if(g)return _.exports;g=1;var e=t.cL(),i=function(){if(m)return f;m=1;var e=t.cJ(),i=t.cK().VectorTileFeature;function r(t,e){this.options=e||{},this.features=t,this.length=t.length}function n(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}return f=r,r.prototype.feature=function(t){return new n(this.features[t],this.options.extent)},n.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i<t.length;i++){for(var r=t[i],n=[],o=0;o<r.length;o++)n.push(new e(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},n.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]},n.prototype.toGeoJSON=i.prototype.toGeoJSON,f}();function r(t){var i=new e;return function(t,e){for(var i in t.layers)e.writeMessage(3,n,t.layers[i])}(t,i),i.finish()}function n(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,o,r);var n=r.keys;for(i=0;i<n.length;i++)e.writeStringField(3,n[i]);var s=r.values;for(i=0;i<s.length;i++)e.writeMessage(4,h,s[i])}function o(t,e){var i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,s,t),e.writeVarintField(3,i.type),e.writeMessage(4,c,i)}function s(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=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),o[a]=c=r.length-1),e.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,d=s[u];void 0===d&&(n.push(l),s[u]=d=n.length-1),e.writeVarint(d)}}}function a(t,e){return(e<<3)+(7&t)}function l(t){return t<<1^t>>31}function c(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,s=i.length,c=0;c<s;c++){var h=i[c],u=1;1===r&&(u=h.length),e.writeVarint(a(1,u));for(var d=3===r?h.length-1:h.length,p=0;p<d;p++){1===p&&1!==r&&e.writeVarint(a(2,d-1));var f=h[p].x-n,m=h[p].y-o;e.writeVarint(l(f)),e.writeVarint(l(m)),n+=f,o+=m}3===r&&e.writeVarint(a(7,1))}}function h(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))}return _.exports=r,_.exports.fromVectorTileJs=r,_.exports.fromGeojsonVt=function(t,e){e=e||{};var n={};for(var o in t)n[o]=new i(t[o].features,e),n[o].name=o,n[o].version=e.version,n[o].extent=e.extent;return r({layers:n})},_.exports.GeoJSONWrapper=i,_.exports}(),x=t.cI(y);const v={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},b=Math.fround||(w=new Float32Array(1),t=>(w[0]=+t,w[0]));var w;const T=3,S=5,P=6;class M{constructor(t){this.options=Object.assign(Object.create(v),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:r}=this.options;e&&console.time("total time");const n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;const o=[];for(let e=0;e<t.length;e++){const i=t[e];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,s=b(A(r)),a=b(E(n));o.push(s,a,1/0,e,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[r+1]=this._createTree(o);e&&console.timeEnd(n);for(let t=r;t>=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+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(A(i),E(o),A(n),E(r)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+S]>1?I(l,e,this.clusterProps):this.points[l[e+T]])}return c}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.data;if(e*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+S]>1?I(o,i,this.clusterProps):this.points[o[i+T]])}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.data,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-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}_createTree(e){const i=new t.aF(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)i.add(e[t],e[t+1]);return i.finish(),i.data=e,i}_addTileFeatures(t,e,i,r,n,o){for(const s of t){const t=s*this.stride,a=e[t+S]>1;let l,c,h;if(a)l=C(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+T]];l=i.properties;const[r,n]=i.geometry.coordinates;c=A(r),h=E(n)}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;d=a||this.options.generateId?e[t+T]:this.points[e[t+T]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=e)continue;a[i+2]=e;const r=a[i],h=a[i+1],u=t.within(a[i],a[i+1],s),d=a[i+S];let p=d;for(const t of u){const i=t*c;a[i+2]>e&&(p+=a[i+S])}if(p>d&&p>=o){let t,o=r*d,s=h*d,f=-1;const m=(i/c<<5)+(e+1)+this.points.length;for(const r of u){const l=r*c;if(a[l+2]<=e)continue;a[l+2]=e;const h=a[l+S];o+=a[l]*h,s+=a[l+1]*h,a[l+4]=m,n&&(t||(t=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(t)),n(t,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let t=0;t<c;t++)l.push(a[i+t]);if(p>1)for(const t of u){const i=t*c;if(!(a[i+2]<=e)){a[i+2]=e;for(let t=0;t<c;t++)l.push(a[i+t])}}}}return l}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+S]>1){const r=this.clusterProps[t[e+P]];return i?Object.assign({},r):r}const r=this.points[t[e+T]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function I(t,e,i){return{type:"Feature",id:t[e+T],properties:C(t,e,i),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),k(t[e+1])]}};var r}function C(t,e,i){const r=t[e+S],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=t[e+P],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+T],point_count:r,point_count_abbreviated:n})}function A(t){return t/360+.5}function E(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 k(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function z(t,e,i,r){let n=r;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let r=e+3;r<i;r+=3){const e=L(t[r],t[r+1],l,c,h,u);if(e>n)s=r,n=e;else if(e===n){const t=Math.abs(r-o);t<a&&(s=r,a=t)}}n>r&&(s-e>3&&z(t,e,s,r),t[s+2]=n,i-s>3&&z(t,s,i,r))}function L(t,e,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const 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,a=e-r,s*s+a*a}function D(t,e,i,r){const n={id:null==t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)R(n,i);else if("Polygon"===e)R(n,i[0]);else if("MultiLineString"===e)for(const t of i)R(n,t);else if("MultiPolygon"===e)for(const t of i)R(n,t[0]);return n}function R(t,e){for(let 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 F(t,e,i,r){if(!e.geometry)return;const n=e.geometry.coordinates;if(n&&0===n.length)return;const o=e.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);let a=[],l=e.id;if(i.promoteId?l=e.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)B(n,a);else if("MultiPoint"===o)for(const t of n)B(t,a);else if("LineString"===o)O(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(const i of n)a=[],O(i,a,s,!1),t.push(D(l,"LineString",a,e.properties));return}j(n,a,s,!1)}else if("Polygon"===o)j(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const n of e.geometry.geometries)F(t,{id:l,geometry:n,properties:e.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of n){const e=[];j(t,e,s,!0),a.push(e)}}t.push(D(l,o,a,e.properties))}function B(t,e){e.push(N(t[0]),V(t[1]),0)}function O(t,e,i,r){let n,o,s=0;for(let i=0;i<t.length;i++){const a=N(t[i][0]),l=V(t[i][1]);e.push(a,l,0),i>0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=e.length-3;e[2]=1,z(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function j(t,e,i,r){for(let n=0;n<t.length;n++){const o=[];O(t[n],o,i,r),e.push(o)}}function N(t){return t/360+.5}function V(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 U(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;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===n?e.minX:e.minY,c=0===n?e.maxX:e.maxY;if(s>=i&&c<r){l.push(e);continue}if(c<i||s>=r)continue;let h=[];if("Point"===o||"MultiPoint"===o)Z(t,h,i,r,n);else if("LineString"===o)$(t,h,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)q(t,h,i,r,n,!1);else if("Polygon"===o)q(t,h,i,r,n,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];q(e,t,i,r,n,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(D(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(D(e.id,o,h,e.tags))}}return l.length?l:null}function Z(t,e,i,r,n){for(let o=0;o<t.length;o+=3){const s=t[o+n];s>=i&&s<=r&&W(e,t[o],t[o+1],t[o+2])}}function $(t,e,i,r,n,o,s){let a=G(t);const l=0===n?H:X;let c,h,u=t.start;for(let d=0;d<t.length-3;d+=3){const p=t[d],f=t[d+1],m=t[d+2],g=t[d+3],_=t[d+4],y=0===n?p:f,x=0===n?g:_;let v=!1;s&&(c=Math.sqrt(Math.pow(p-g,2)+Math.pow(f-_,2))),y<i?x>i&&(h=l(a,p,f,g,_,i),s&&(a.start=u+c*h)):y>r?x<r&&(h=l(a,p,f,g,_,r),s&&(a.start=u+c*h)):W(a,p,f,m),x<i&&y>=i&&(h=l(a,p,f,g,_,i),v=!0),x>r&&y<=r&&(h=l(a,p,f,g,_,r),v=!0),!o&&v&&(s&&(a.end=u+c*h),e.push(a),a=G(t)),s&&(u+=c)}let d=t.length-3;const p=t[d],f=t[d+1],m=0===n?p:f;m>=i&&m<=r&&W(a,p,f,t[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&W(a,a[0],a[1],a[2]),a.length&&e.push(a)}function G(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function q(t,e,i,r,n,o){for(const s of t)$(s,e,i,r,n,o,!1)}function W(t,e,i,r){t.push(e,i,r)}function H(t,e,i,r,n,o){const s=(o-e)/(r-e);return W(t,o,i+(n-i)*s,1),s}function X(t,e,i,r,n,o){const s=(o-i)/(n-i);return W(t,e+(r-e)*s,o,1),s}function K(t,e){const i=[];for(let r=0;r<t.length;r++){const n=t[r],o=n.type;let s;if("Point"===o||"MultiPoint"===o||"LineString"===o)s=Y(n.geometry,e);else if("MultiLineString"===o||"Polygon"===o){s=[];for(const t of n.geometry)s.push(Y(t,e))}else if("MultiPolygon"===o){s=[];for(const t of n.geometry){const i=[];for(const r of t)i.push(Y(r,e));s.push(i)}}i.push(D(n.id,o,s,n.tags))}return i}function Y(t,e){const i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(let r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function J(t,e){if(t.transformed)return t;const i=1<<t.z,r=t.x,n=t.y;for(const o of t.features){const t=o.geometry,s=o.type;if(o.geometry=[],1===s)for(let s=0;s<t.length;s+=2)o.geometry.push(Q(t[s],t[s+1],e,i,r,n));else for(let s=0;s<t.length;s++){const a=[];for(let o=0;o<t[s].length;o+=2)a.push(Q(t[s][o],t[s][o+1],e,i,r,n));o.geometry.push(a)}}return t.transformed=!0,t}function Q(t,e,i,r,n,o){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-o))]}function tt(t,e,i,r,n){const o=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)et(s,e,o,n);return s}function et(t,e,i,r){const n=e.geometry,o=e.type,s=[];if(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),"Point"===o||"MultiPoint"===o)for(let e=0;e<n.length;e+=3)s.push(n[e],n[e+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)it(s,n,t,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(let e=0;e<n.length;e++)it(s,n[e],t,i,"Polygon"===o,0===e);else if("MultiPolygon"===o)for(let e=0;e<n.length;e++){const r=n[e];for(let e=0;e<r.length;e++)it(s,r[e],t,i,!0,0===e)}if(s.length){let i=e.tags||null;if("LineString"===o&&r.lineMetrics){i={};for(const t in e.tags)i[t]=e.tags[t];i.mapbox_clip_start=n.start/n.size,i.mapbox_clip_end=n.end/n.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:i};null!==e.id&&(a.id=e.id),t.features.push(a)}}function it(t,e,i,r,n,o){const s=r*r;if(r>0&&e.size<(n?s:r))return void(i.numPoints+=e.length/3);const a=[];for(let t=0;t<e.length;t+=3)(0===r||e[t+2]>s)&&(i.numSimplified++,a.push(e[t],e[t+1])),i.numPoints++;n&&function(t,e){let i=0;for(let e=0,r=t.length,n=r-2;e<r;n=e,e+=2)i+=(t[e]-t[n])*(t[e+1]+t[n+1]);if(i>0===e)for(let e=0,i=t.length;e<i/2;e+=2){const r=t[e],n=t[e+1];t[e]=t[i-2-e],t[e+1]=t[i-1-e],t[i-2-e]=r,t[i-1-e]=n}}(a,o),t.push(a)}const rt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class nt{constructor(t,e){const i=(e=this.options=function(t,e){for(const i in e)t[i]=e[i];return t}(Object.create(rt),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.");let r=function(t,e){const i=[];if("FeatureCollection"===t.type)for(let r=0;r<t.features.length;r++)F(i,t.features[r],e,r);else F(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){const i=e.buffer/e.extent;let r=t;const n=U(t,1,-1-i,i,0,-1,2,e),o=U(t,1,1-i,2+i,0,-1,2,e);return(n||o)&&(r=U(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=K(n,1).concat(r)),o&&(r=r.concat(K(o,-1)))),r}(r,e),r.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)))}splitTile(t,e,i,r,n,o,s){const a=[t,e,i,r],l=this.options,c=l.debug;for(;a.length;){r=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();const h=1<<e,u=ot(e,i,r);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=tt(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"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(d.source=t,null==n){if(e===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===n)continue;if(null!=n){const t=n-e;if(i!==o>>t||r!==s>>t)continue}}if(d.source=null,0===t.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,y=null,x=null,v=null,b=U(t,h,i-p,i+m,0,d.minX,d.maxX,l),w=U(t,h,i+f,i+g,0,d.minX,d.maxX,l);t=null,b&&(_=U(b,h,r-p,r+m,1,d.minY,d.maxY,l),y=U(b,h,r+f,r+g,1,d.minY,d.maxY,l),b=null),w&&(x=U(w,h,r-p,r+m,1,d.minY,d.maxY,l),v=U(w,h,r+f,r+g,1,d.minY,d.maxY,l),w=null),c>1&&console.timeEnd("clipping"),a.push(_||[],e+1,2*i,2*r),a.push(y||[],e+1,2*i,2*r+1),a.push(x||[],e+1,2*i+1,2*r),a.push(v||[],e+1,2*i+1,2*r+1)}}getTile(t,e,i){t=+t,e=+e,i=+i;const r=this.options,{extent:n,debug:o}=r;if(t<0||t>24)return null;const s=1<<t,a=ot(t,e=e+s&s-1,i);if(this.tiles[a])return J(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",t,e,i);let l,c=t,h=e,u=i;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[ot(c,h,u)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?J(this.tiles[a],n):null):null}}function ot(t,e,i){return 32*((1<<t)*i+e)+t}function st(t,e){return e?t.properties[e]:t.id}function at(t,e){if(null==t)return!0;if("Feature"===t.type)return null!=st(t,e);if("FeatureCollection"===t.type){const i=new Set;for(const r of t.features){const t=st(r,e);if(null==t)return!1;if(i.has(t))return!1;i.add(t)}return!0}return!1}function lt(t,e){const i=new Map;if(null==t);else if("Feature"===t.type)i.set(st(t,e),t);else for(const r of t.features)i.set(st(r,e),r);return i}class ct extends o{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const i=this._geoJSONIndex.getTile(t.z,t.x,t.y);if(!i)return null;const r=new p(i.features);let n=x(r);return 0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),{vectorTile:r,rawData:n.buffer}}))}loadData(e){return t._(this,void 0,void 0,(function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const r=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.cF(e.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest),this._geoJSONIndex=e.cluster?new M(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.ct(s),l=t.ct("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((yield this._pendingData).features):(n=yield this._pendingData,new nt(n,e.geojsonVtOptions)),this.loaded={};const i={};if(r){const t=r.finish();t&&(i.resourceTiming={},i.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}return i}catch(e){if(delete this._pendingRequest,t.co(e))return{abandoned:!0};throw e}var n}))}getData(){return t._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded;return e&&e[t.uid]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){let r=yield this.loadGeoJSON(e,i);if(delete this._pendingRequest,"object"!=typeof r)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(h(r,!0),e.filter){const i=t.ct(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 n=r.features.filter((t=>i.value.evaluate({zoom:0},t)));r={type:"FeatureCollection",features:n}}return r}))}loadGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){const{promoteId:r}=e;if(e.request){const n=yield t.j(e.request,i);return this._dataUpdateable=at(n.data,r)?lt(n.data,r):void 0,n.data}if("string"==typeof e.data)try{const t=JSON.parse(e.data);return this._dataUpdateable=at(t,r)?lt(t,r):void 0,t}catch(t){throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}if(!e.dataDiff)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${e.source}`);return function(t,e,i){var r,n,o,s;if(e.removeAll&&t.clear(),e.remove)for(const i of e.remove)t.delete(i);if(e.add)for(const r of e.add){const e=st(r,i);null!=e&&t.set(e,r)}if(e.update)for(const i of e.update){let e=t.get(i.id);if(null==e)continue;const a=!i.removeAllProperties&&((null===(r=i.removeProperties)||void 0===r?void 0:r.length)>0||(null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0);if((i.newGeometry||i.removeAllProperties||a)&&(e=Object.assign({},e),t.set(i.id,e),a&&(e.properties=Object.assign({},e.properties))),i.newGeometry&&(e.geometry=i.newGeometry),i.removeAllProperties)e.properties={};else if((null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0)for(const t of i.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0)for(const{key:t,value:r}of i.addOrUpdateProperties)e.properties[t]=r}}(this._dataUpdateable,e.dataDiff,r),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(e){return t._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset)}}class ht{constructor(e){this.self=e,this.actor=new t.H(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=t.cr,this.self.removeProtocol=t.cs,this.self.registerRTLTextPlugin=e=>{t.cM.setMethods(e)},this.actor.registerMessageHandler("LDT",((t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e))),this.actor.registerMessageHandler("RDT",((e,i)=>t._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,i.source).removeTile(i)})))),this.actor.registerMessageHandler("GCEZ",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterExpansionZoom(i)})))),this.actor.registerMessageHandler("GCC",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterChildren(i)})))),this.actor.registerMessageHandler("GCL",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterLeaves(i)})))),this.actor.registerMessageHandler("LD",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e))),this.actor.registerMessageHandler("GD",((t,e)=>this._getWorkerSource(t,e.type,e.source).getData())),this.actor.registerMessageHandler("LT",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e))),this.actor.registerMessageHandler("RT",((t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e))),this.actor.registerMessageHandler("AT",((t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e))),this.actor.registerMessageHandler("RMT",((t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e))),this.actor.registerMessageHandler("RS",((e,i)=>t._(this,void 0,void 0,(function*(){if(!this.workerSources[e]||!this.workerSources[e][i.type]||!this.workerSources[e][i.type][i.source])return;const t=this.workerSources[e][i.type][i.source];delete this.workerSources[e][i.type][i.source],void 0!==t.removeSource&&t.removeSource(i)})))),this.actor.registerMessageHandler("RM",(e=>t._(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e]})))),this.actor.registerMessageHandler("SR",((e,i)=>t._(this,void 0,void 0,(function*(){this.referrer=i})))),this.actor.registerMessageHandler("SRPS",((t,e)=>this._syncRTLPluginState(t,e))),this.actor.registerMessageHandler("IS",((e,i)=>t._(this,void 0,void 0,(function*(){this.self.importScripts(i)})))),this.actor.registerMessageHandler("SI",((t,e)=>this._setImages(t,e))),this.actor.registerMessageHandler("UL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(i.layers,i.removedIds)})))),this.actor.registerMessageHandler("SL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(i)}))))}_setImages(e,i){return t._(this,void 0,void 0,(function*(){this.availableImages[e]=i;for(const t in this.workerSources[e]){const r=this.workerSources[e][t];for(const t in r)r[t].availableImages=i}}))}_syncRTLPluginState(e,i){return t._(this,void 0,void 0,(function*(){return yield t.cM.syncState(i,this.self.importScripts)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let i=this.layerIndexes[t];return i||(i=this.layerIndexes[t]=new e),i}_getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={sendAsync:(e,i)=>(e.targetMapId=t,this.actor.sendAsync(e,i))};switch(e){case"vector":this.workerSources[t][e][i]=new o(r,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][i]=new ct(r,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][i]=new this.externalWorkerSourceTypes[e](r,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][i]}_getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new s),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new ht(self)),ht})),i("index",["exports","./shared"],(function(t,e){var i="5.4.0-mc.6";function r(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let n,o;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(t,i,r){const n=requestAnimationFrame((t=>{o(),i(t)})),{unsubscribe:o}=e.s(t.signal,"abort",(()=>{o(),cancelAnimationFrame(n),r(e.c())}),!1)},frameAsync(t){return new Promise(((e,i)=>{this.frame(t,e,i)}))},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(n||(n=document.createElement("a")),n.href=t,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)}};class a{static testProp(t){if(!a.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in a.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){a.docStyle&&a.selectProp&&(a.userSelect=a.docStyle[a.selectProp],a.docStyle[a.selectProp]="none")}static enableDrag(){a.docStyle&&a.selectProp&&(a.docStyle[a.selectProp]=a.userSelect)}static setTransform(t,e){t.style[a.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",a.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",a.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",a.suppressClickInternal,!0)}),0)}static getScale(t,e){const i=t.getBoundingClientRect();return{x:(i.width/t.offsetWidth||1)*e,y:(i.height/t.offsetHeight||1)*e,boundingClientRect:i}}static getPoint(t,i,r){const n=i.boundingClientRect;return new e.P((r.clientX-n.left)/i.x-t.clientLeft,(r.clientY-n.top)/i.y-t.clientTop)}static mousePos(t,e,i){const r=a.getScale(t,i);return a.getPoint(t,r,e)}static touchPos(t,e,i){const r=[],n=a.getScale(t,i);for(let i=0;i<e.length;i++)r.push(a.getPoint(t,n,e[i]));return r}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const e=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),i=e.querySelectorAll("script");for(const t of i)t.remove();return a.clean(e),e.innerHTML}static isPossiblyDangerous(t,e){const i=e.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!i.includes("javascript:")&&!i.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const e=t.children;for(const t of e)a.removeAttributes(t),a.clean(t)}static removeAttributes(t){for(const{name:e,value:i}of t.attributes)a.isPossiblyDangerous(e,i)&&t.removeAttribute(e)}}a.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,a.selectProp=a.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),a.transformProp=a.testProp(["transform","WebkitTransform"]);const l={supported:!1,testSupport:function(t){!u&&h&&(d?p(t):c=t)}};let c,h,u=!1,d=!1;function p(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,h),t.isContextLost())return;l.supported=!0}catch(t){}t.deleteTexture(e),u=!0}var f;"undefined"!=typeof document&&(h=document.createElement("img"),h.onload=()=>{c&&p(c),c=null,d=!0},h.onerror=()=>{u=!0,c=null},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let i,r,n,o;t.resetRequestQueue=()=>{i=[],r=0,n=0,o={}},t.addThrottleControl=t=>{const e=n++;return o[e]=t,e},t.removeThrottleControl=t=>{delete o[t],a()},t.getImage=(t,r,n=!0)=>new Promise(((o,s)=>{l.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"}),i.push({abortController:r,requestParameters:t,supportImageRefresh:n,state:"queued",onError:t=>{s(t)},onSuccess:t=>{o(t)}}),a()}));const s=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:i,supportImageRefresh:n,onError:o,onSuccess:s,abortController:l}=t,h=!1===n&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0));r++;const u=h?c(i,l):e.m(i,l);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?e.f(d):e.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(e){delete t.abortController,o(e)}finally{r--,a()}var d})),a=()=>{const t=(()=>{for(const t of Object.keys(o))if(o[t]())return!0;return!1})()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=r;e<t&&i.length>0;e++){const t=i.shift();t.abortController.signal.aborted?e--:s(t)}},c=(t,i)=>new Promise(((r,n)=>{const o=new Image,s=t.url,a=t.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!e.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{o.src="",n(e.c())})),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,r({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||n(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."))},o.src=s}))}(f||(f={})),f.resetRequestQueue();class m{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function g(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:r,url:n}of t){const t=`${r}${n}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:r,url:n}))}}return e}function _(t,e,i){try{const r=new URL(t);return r.pathname+=`${e}${i}`,r.toString()}catch(e){throw new Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function y(t,i,r,n){return e._(this,void 0,void 0,(function*(){const o=g(t),a=r>1?"@2x":"",l={},c={};for(const{id:t,url:r}of o){const o=i.transformRequest(_(r,a,".json"),"SpriteJSON");l[t]=e.j(o,n);const s=i.transformRequest(_(r,a,".png"),"SpriteImage");c[t]=f.getImage(s,n)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(t,i){return e._(this,void 0,void 0,(function*(){const e={};for(const r in t){e[r]={};const n=s.getImageCanvasContext((yield i[r]).data),o=(yield t[r]).data;for(const t in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,id:g}=o[t];e[r][t]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:n},id:g}}}return e}))}(l,c)}))}class x{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,i,r){const{width:n,height:o}=t,s=!(this.size&&this.size[0]===n&&this.size[1]===o||r),{context:a}=this,{gl:l}=a;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[n,o],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,n,o,0,this.format,l.UNSIGNED_BYTE,t.data);else{const{x:i,y:s}=r||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,i,s,n,o,l.RGBA,l.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault()}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}}function v(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class b extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({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,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,i){let r=!0;const n=i.data||i.spriteData;return this._validateStretch(i.stretchX,n&&n.width)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,n&&n.height)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.k(new Error(`Image "${t}" 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){if(!t)return!0;if(4!==t.length)return!1;const i=e.spriteData,r=i&&i.width||e.data.width,n=i&&i.height||e.data.height;return!(t[0]<0||r<t[0]||t[1]<0||n<t[1]||t[2]<0||r<t[2]||t[3]<0||n<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,e,i=!0){const r=this.getImage(t);if(i&&(r.data.width!==e.data.width||r.data.height!==e.data.height))throw new Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=r.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){return new Promise(((e,i)=>{let r=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(r=!1);this.isLoaded()||r?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){const i={};for(const r of t){let t=this.getImage(r);t||(this.fire(new e.l("styleimagemissing",{id:r})),t=this.getImage(r)),t?i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${r}" 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.`)}return i}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const i=this.patterns[t],r=this.getImage(t);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 e.I(i,r);this.patterns[t]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new x(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:r}=e.p(t),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],r=i.x+1,o=i.y+1,s=this.getImage(t).data,a=s.width,l=s.height;e.R.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),e.R.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),e.R.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),e.R.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),e.R.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 i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),v(t)&&this.updateImage(i,t)}}}const w=1e20;function T(t,e,i,r,n,o,s,a,l){for(let c=e;c<e+r;c++)S(t,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)S(t,c*o+e,1,r,s,a,l)}function S(t,e,i,r,n,o,s){o[0]=0,s[0]=-1e20,s[1]=w,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=o[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;t[e+a*i]=n[r]+c*c}}class P{constructor(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}}setURL(t){this.url=t}getGlyphs(t){return e._(this,void 0,void 0,(function*(){const e=[];for(const i in t)for(const r of t[i])e.push(this._getAndCacheGlyphsPromise(i,r));const i=yield Promise.all(e),r={};for(const{stack:t,id:e,glyph:n}of i)r[t]||(r[t]={}),r[t][e]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};return r}))}getGlyphMap(t,e){const i=e.map((e=>{var i;return{id:e,glyph:null===(i=this.entries[t])||void 0===i?void 0:i.glyphs[e]}})),r={[t]:{}};for(const{id:e,glyph:n}of i)r[t][e]=n&&{metrics:n.metrics};return r}_getAndCacheGlyphsPromise(t,i){return e._(this,void 0,void 0,(function*(){let e=this.entries[t];e||(e=this.entries[t]={glyphs:{},requests:{},ranges:{}});let r=e.glyphs[i];if(void 0!==r)return{stack:t,id:i,glyph:r};if(r=this._tinySDF(e,t,i),r)return e.glyphs[i]=r,{stack:t,id:i,glyph:r};const n=Math.floor(i/256);if(256*n>65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[n])return{stack:t,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[n]){const i=P.loadGlyphRange(t,n,this.url,this.requestManager);e.requests[n]=i}const o=yield e.requests[n];for(const t in o)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=o[+t]);return e.ranges[n]=!0,{stack:t,id:i,glyph:o[i]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(t))||e.u["CJK Unified Ideographs"](t)||e.u["Hangul Syllables"](t)||e.u.Hiragana(t)||e.u.Katakana(t)||e.u["CJK Symbols and Punctuation"](t)||e.u["Halfwidth and Fullwidth Forms"](t))}_tinySDF(t,i,r){const n=this.localIdeographFontFamily;if(!n)return;if(!this._doesCharSupportLocalGlyph(r))return;let o=t.tinySDF;if(!o){let e="400";/bold/i.test(i)?e="900":/medium/i.test(i)?e="500":/light/i.test(i)&&(e="200"),o=t.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:n,fontWeight:e})}const s=o.draw(String.fromCharCode(r));return{id:r,bitmap:new e.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(t,i,r,n){return e._(this,void 0,void 0,(function*(){const o=256*i,s=o+255,a=n.transformRequest(r.replace("{fontstack}",t).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield e.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const t of e.o(l.data))c[t.id]=t;return c}))},P.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(w,0,u),g.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)_[r]=0,g[r]=w;else{const t=.5-i;_[r]=t>0?t*t:0,g[r]=t<0?t*t:0}}T(_,0,0,c,h,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(_[t])-Math.sqrt(g[t]);d[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return p}};class M{constructor(){this.specification=e.v.light.position}possiblyEvaluate(t,i){return e.z(t.expression.evaluate(i))}interpolate(t,i,r){return{x:e.B.number(t.x,i.x,r),y:e.B.number(t.y,i.y,r),z:e.B.number(t.z,i.z,r)}}}let I;class C extends e.E{constructor(t){super(),I=I||new e.r({anchor:new e.D(e.v.light.anchor),position:new M,color:new e.D(e.v.light.color),intensity:new e.D(e.v.light.intensity)}),this._transitionable=new e.T(I),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.t,t,i))for(const e in t){const i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&e.x(this,t.call(e.y,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.v}))}}const A=new e.r({"sky-color":new e.D(e.v.sky["sky-color"]),"horizon-color":new e.D(e.v.sky["horizon-color"]),"fog-color":new e.D(e.v.sky["fog-color"]),"fog-ground-blend":new e.D(e.v.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.v.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.v.sky["atmosphere-blend"])});class E extends e.E{constructor(t){super(),this._transitionable=new e.T(A),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.C(0))}setSky(t,i={}){if(!this._validate(e.F,t,i)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const e in t){const i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r={}){return!1!==(null==r?void 0:r.validate)&&e.x(this,t.call(e.y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class k{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}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.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){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 e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let n=0,o=t[n];for(let e=0;e<this.width;e++){e/o.right>1&&(o=t[++n]);const i=Math.abs(e-o.left),s=Math.abs(e-o.right),a=Math.min(i,s);this.data[r+e]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(t,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return e.w("LineAtlas out of space"),null;let o=0;for(let e=0;e<t.length;e++)o+=t[e];if(0!==o){const e=this.width/o,n=this.getDashRanges(t,this.width,e);i?this.addRoundDash(n,e,r):this.addRegularDash(n)}const s={y:(this.nextRow+r+.5)/this.height,height:2*r/this.height,width:o};return this.nextRow+=n,this.dirty=!0,s}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}const z="maplibre_preloaded_worker_pool";class L{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<L.workerCount;)this.workers.push(new Worker(e.a.WORKER_URL));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[z]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(s.hardwareConcurrency/2);let R,F;function B(){return R||(R=new L),R}L.workerCount=e.G(globalThis)?Math.max(Math.min(D,3),1):1;class O{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let t=0;t<r.length;t++){const n=new e.H(r[t],i);n.name=`Worker ${t}`,this.actors.push(n)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,e){const i=[];for(const r of this.actors)i.push(r.sendAsync({type:t,data:e}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((t=>{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e)}}function j(){return F||(F=new O(B(),e.J),F.registerMessageHandler("GR",((t,i,r)=>e.m(i,r)))),F}class N{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(t){if(1===this.points.length)return this.points[0];t=e.K(t,0,1);let i=1,r=this._distances[i];const n=t*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))}}function V(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class U{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,s){if(i<0||t>this.width||r<0||e>this.height)return[];const a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)a.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];a.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,a,{hitTest:n,overlapMode:o,seenUids:{box:{},circle:{}}},s);return a}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,n,o){return this._query(t,e,i,r,!0,n,o).length>0}hitTestCircle(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!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(t,e,i,r,n,o,s,a){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(t<=n[u+2]&&e<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!a||a(d))&&(!c||!V(h,d.overlapMode))&&(o.push({key:d,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const d=this.circleCells[n];if(null!==d){const n=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!a||a(d))&&(!c||!V(h,d.overlapMode))){const t=n[u],e=n[u+1],i=n[u+2];if(o.push({key:d,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,o,s,a){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(r))&&!V(h,r.overlapMode))return o.push(!0),!0}}const d=this.circleCells[n];if(null!==d){const t=this.circles;for(const e of d)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!V(h,r.overlapMode))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 Z(t,i,n){const o=e.L();if(!t){const{vecSouth:t,vecEast:e}=G(i),n=r();n[0]=e[0],n[1]=e[1],n[2]=t[0],n[3]=t[1],s=n,(d=(l=(a=n)[0])*(u=a[3])-(h=a[2])*(c=a[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),o[0]=n[0],o[1]=n[1],o[4]=n[2],o[5]=n[3]}var s,a,l,c,h,u,d;return e.M(o,o,[1/n,1/n,1]),o}function $(t,i,r,n){if(t){const t=e.L();if(!i){const{vecSouth:e,vecEast:i}=G(r);t[0]=i[0],t[1]=i[1],t[4]=e[0],t[5]=e[1]}return e.M(t,t,[n,n,1]),t}return r.pixelsToClipSpaceMatrix}function G(t){const i=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),n=Math.cos(t.pitchInRadians),o=Math.cos(t.bearingInRadians),s=Math.sin(t.bearingInRadians),a=e.S();a[0]=-o*n*r-s*i,a[1]=-s*n*r+o*i;const l=e.U(a);l<1e-9?e.V(a):e.X(a,a,1/l);const c=e.S();c[0]=o*n*i-s*r,c[1]=s*n*i+o*r;const h=e.U(c);return h<1e-9?e.V(c):e.X(c,c,1/h),{vecEast:c,vecSouth:a}}function q(t,i,r,n){let o;n?(o=[t,i,n(t,i),1],e.Z(o,o,r)):(o=[t,i,0,1],ct(o,o,r));const s=o[3];return{point:new e.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function W(t,e){return.5+t/e*.5}function H(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function X(t,i,r,n,o,s,a,l,c,h,u,d,p){const f=r?t.textSizeData:t.iconSizeData,m=e.N(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();const y=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b=!1;for(let r=0;r<x.length;r++){const w=x.get(r);if(w.hidden||w.writingMode===e.W.vertical&&!b){lt(w.numGlyphs,_);continue}b=!1;const T=new e.P(w.anchorX,w.anchorY),S={getElevation:p,pitchedLabelPlaneMatrix:n,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:T,unwrappedTileID:c,width:h,height:u,translation:d},P=rt(w.anchorX,w.anchorY,S);if(!H(P.point,g)){lt(w.numGlyphs,_);continue}const M=W(i.transform.cameraToCenterDistance,P.signedDistanceFromCamera),I=e.O(f,m,w),C=s?I*i.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/M:I*M,A=J({projectionContext:S,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:C,flip:!1,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l});b=A.useVertical,(A.notEnoughRoom||b||A.needsFlipping&&J({projectionContext:S,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:C,flip:!0,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l}).notEnoughRoom)&<(w.numGlyphs,_)}r?t.text.dynamicLayoutVertexBuffer.updateData(_):t.icon.dynamicLayoutVertexBuffer.updateData(_)}function K(t,e,i,r,n,o,s,a){const l=o.glyphStartIndex+o.numGlyphs,c=o.lineStartIndex,h=o.lineStartIndex+o.lineLength,u=e.getoffsetX(o.glyphStartIndex),d=e.getoffsetX(l-1),p=st(t*u,i,r,n,o.segment,c,h,a,s);if(!p)return null;const f=st(t*d,i,r,n,o.segment,c,h,a,s);return f?a.projectionCache.anyProjectionOccluded?null:{first:p,last:f}:null}function Y(t,i,r,n){return t===e.W.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(t===e.W.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function J(t){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=t,d=o/24,p=n.lineOffsetX*d,f=n.lineOffsetY*d;let m;if(n.numGlyphs>1){const t=n.glyphStartIndex+n.numGlyphs,e=n.lineStartIndex,o=n.lineStartIndex+n.lineLength,c=K(d,l,p,f,s,n,u,i);if(!c)return{notEnoughRoom:!0};const g=it(c.first.point.x,c.first.point.y,i,r),_=it(c.last.point.x,c.last.point.y,i,r);if(a&&!s){const t=Y(n.writingMode,g,_,h);if(t)return t}m=[c.first];for(let r=n.glyphStartIndex+1;r<t-1;r++)m.push(st(d*l.getoffsetX(r),p,f,s,n.segment,e,o,i,u));m.push(c.last)}else{if(a&&!s){const t=et(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,o=n.lineStartIndex+n.segment+1,s=new e.P(i.lineVertexArray.getx(o),i.lineVertexArray.gety(o)),a=et(s.x,s.y,i),l=a.signedDistanceFromCamera>0?a.point:Q(i.tileAnchorPoint,s,t,1,i),c=it(t.x,t.y,i,r),u=it(l.x,l.y,i,r),d=Y(n.writingMode,c,u,h);if(d)return d}const t=st(d*l.getoffsetX(n.glyphStartIndex),p,f,s,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,u);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[t]}for(const t of m)e.Y(c,t.point,t.angle);return{}}function Q(t,e,i,r,n){const o=t.add(t.sub(e)._unit()),s=et(o.x,o.y,n).point,a=i.sub(s);return i.add(a._mult(r/a.mag()))}function tt(t,i,r){const n=i.projectionCache;if(n.projections[t])return n.projections[t];const o=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),s=et(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return n.projections[t]=s.point,n.anyProjectionOccluded=n.anyProjectionOccluded||s.isOccluded,s.point;const a=t-r.direction;return Q(0===r.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function et(t,e,i){const r=t+i.translation[0],n=e+i.translation[1];let o;return i.pitchWithMap?(o=q(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function it(t,i,r,n){if(r.pitchWithMap){const o=[t,i,0,1];return e.Z(o,o,n),r.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],r.unwrappedTileID,r.getElevation).point}return{x:t/r.width*2-1,y:i/r.height*2-1}}function rt(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function nt(t,e,i){return t._unit()._perp()._mult(e*i)}function ot(t,i,r,n,o,s,a,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const h=r.add(i);if(t+c.direction<n||t+c.direction>=o)return l.projectionCache.offsets[t]=h,h;const u=tt(t+c.direction,l,c),d=nt(u.sub(r),a,c.direction),p=r.add(d),f=u.add(d);return l.projectionCache.offsets[t]=e.$(s,h,p,f)||h,l.projectionCache.offsets[t]}function st(t,e,i,r,n,o,s,a,l){const c=r?t-e:t+e;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,p=h>0?o+n:o+n+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=et(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,y=0,x=0;const v=Math.abs(c),b=[];let w;for(;y+x<=v;){if(p+=h,p<o||p>=s)return null;y+=x,_=g,m=f;const t={absOffsetX:v,direction:h,distanceFromAnchor:y,previousVertex:_};if(g=tt(p,a,t),0===i)b.push(_),w=g.sub(_);else{let e;const r=g.sub(_);e=0===r.mag()?nt(tt(p+h,a,t).sub(g),i,h):nt(r,i,h),m||(m=_.add(e)),f=ot(p,e,g,o,s,m,i,a,t),b.push(m),w=f.sub(m)}x=w.mag()}const T=w._mult((v-y)/x)._add(m||_),S=u+Math.atan2(g.y-_.y,g.x-_.x);return b.push(T),{point:T,angle:l?S:0,path:b}}const at=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function lt(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(at,3*t)}}function ct(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 ht=100;class ut{constructor(t,e=[],i=1,r=new U(t.width+200,t.height+200,25),n=new U(t.width+200,t.height+200,25)){this.transform=t,this.grid=r,this.ignoredGrid=n,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+ht,this.screenBottomBoundary=t.height+ht,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6;for(let t=0;t<e.length;t++){const r=e[t];this.grid.insert(`label-free-area-${t}`,r[0]/i+ht,r[1]/i+ht,r[2]/i+ht,r[3]/i+ht)}}placeCollisionBox(t,e,i,r,n,o,s,a,l,c,h,u){const d=this.projectAndGetPerspectiveRatio(t.anchorPointX+a[0],t.anchorPointY+a[1],n,c,u),p=i*d.perspectiveRatio;let f;if(o||s)f=this._projectCollisionBox(t,p,r,n,o,s,a,d,c,h,u);else{const e=d.x+(h?h.x*p:0),i=d.y+(h?h.y*p:0);f={allPointsOccluded:!1,box:[e+t.x1*p,i+t.y1*p,e+t.x2*p,i+t.y2*p]}}const[m,g,_,y]=f.box,x=o?f.allPointsOccluded:d.isOccluded;let v=x;return v||(v=d.perspectiveRatio<this.perspectiveRatioCutoff),v||(v=!this.isInsideGrid(m,g,_,y)),v||"always"!==e&&this.grid.hitTest(m,g,_,y,e,l)?{box:[m,g,_,y],placeable:!1,offscreen:!1,occluded:x}:{box:[m,g,_,y],placeable:!0,offscreen:this.isOffscreen(m,g,_,y),occluded:x}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],g=new e.P(i.anchorX,i.anchorY),_=this.getPerspectiveRatio(g.x,g.y,s,f),y=(c?o*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,s)/_:o*_)/e.a5,x={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:r,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:p},v=K(y,n,i.lineOffsetX*y,i.lineOffsetY*y,!1,i,!1,x);let b=!1,w=!1,T=!0;if(v){const i=.5*u*_+d,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new N,s=v.first,a=v.last;let p=[];for(let t=s.path.length-1;t>=1;t--)p.push(s.path[t]);for(let t=1;t<a.path.length;t++)p.push(a.path[t]);const f=2.5*i;if(c){const t=this.projectPathToScreenSpace(p,x);p=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let g=[];if(p.length>0){const t=p[0].clone(),i=p[0].clone();for(let e=1;e<p.length;e++)t.x=Math.min(t.x,p[e].x),t.y=Math.min(t.y,p[e].y),i.x=Math.max(i.x,p[e].x),i.y=Math.max(i.y,p[e].y);g=t.x>=r.x&&i.x<=n.x&&t.y>=r.y&&i.y<=n.y?[p]:i.x<r.x||t.x>n.x||i.y<r.y||t.y>n.y?[]:e.a0([p],r.x,r.y,n.x,n.y)}for(const e of g){o.reset(e,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let e=0;e<r;e++){const n=e/Math.max(r-1,1),s=o.lerp(n),a=s.x+ht,c=s.y+ht;m.push(a,c,i,0);const u=a-i,d=c-i,p=a+i,f=c+i;if(T=T&&this.isOffscreen(u,d,p,f),w=w||this.isInsideGrid(u,d,p,f),"always"!==t&&this.grid.hitTestCircle(a,c,i,t,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||_<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}projectPathToScreenSpace(t,i){const r=function(t,i){const r=e.L();return e.Q(r,i.pitchedLabelPlaneMatrix),t.map((t=>{const e=q(t.x,t.y,r,i.getElevation),n=i.transform.projectTileCoordinates(e.point.x,e.point.y,i.unwrappedTileID,i.getElevation);return n.point.x=(.5*n.point.x+.5)*i.width,n.point.y=(.5*-n.point.y+.5)*i.height,n}))}(t,i);return function(t){let e=0,i=0,r=0,n=0;for(let o=0;o<t.length;o++)t[o].isOccluded?(r=o+1,n=0):(n++,n>i&&(i=n,e=r));return t.slice(e,e+i)}(r)}queryRenderedSymbols(t){if(0===t.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 t){const t=new e.P(a.x+ht,a.y+ht);r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),i.push(t)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const t of a){const r=t.key;if(void 0===r.bucketInstanceId||void 0===r.featureIndex)continue;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.a1(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,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:e};for(let e=0;e<t.length;e+=4)s.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,i,r,n,o){if(o){let r;n?(r=[t,i,n(t,i),1],e.Z(r,r,o)):(r=[t,i,0,1],ct(r,r,o));const s=r[3];return{x:(r[0]/s+1)/2*this.transform.width+ht,y:(-r[1]/s+1)/2*this.transform.height+ht,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s*.5,isOccluded:!1,signedDistanceFromCamera:s}}{const e=this.transform.projectTileCoordinates(t,i,r,n);return{x:(e.point.x+1)/2*this.transform.width+ht,y:(1-e.point.y)/2*this.transform.height+ht,perspectiveRatio:.5+this.transform.cameraToCenterDistance/e.signedDistanceFromCamera*.5,isOccluded:e.isOccluded,signedDistanceFromCamera:e.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,r){const n=this.transform.projectTileCoordinates(t,e,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(t,e,i,r){return i<ht||t>=this.screenRightBoundary||r<ht||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=e.a2([]);return e.a3(t,t,[-100,-100,0]),t}_projectCollisionBox(t,i,r,n,o,s,a,l,c,h,u){let d=1,p=0,f=0,m=1;const g=t.anchorPointX+a[0],_=t.anchorPointY+a[1];if(s&&!o){const t=this.projectAndGetPerspectiveRatio(g+1,_,n,c,u),e=t.x-l.x,i=Math.atan((t.y-l.y)/e)+(e<0?Math.PI:0),r=Math.sin(i),o=Math.cos(i);d=o,p=r,f=-r,m=o}else if(!s&&o){const t=G(this.transform);d=t.vecEast[0],p=t.vecEast[1],f=t.vecSouth[0],m=t.vecSouth[1]}let y=l.x,x=l.y,v=i;o&&(y=g,x=_,v=Math.pow(2,-(this.transform.zoom-r.overscaledZ)),v*=this.transform.getPitchedTextCorrection(g,_,n),h||(v*=e.K(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(y+=d*h.x*v+f*h.y*v,x+=p*h.x*v+m*h.y*v);const b=t.x1*v,w=t.x2*v,T=(b+w)/2,S=t.y1*v,P=t.y2*v,M=(S+P)/2,I=[{offsetX:b,offsetY:S},{offsetX:T,offsetY:S},{offsetX:w,offsetY:S},{offsetX:w,offsetY:M},{offsetX:w,offsetY:P},{offsetX:T,offsetY:P},{offsetX:b,offsetY:P},{offsetX:b,offsetY:M}];let C=[];for(const{offsetX:t,offsetY:i}of I)C.push(new e.P(y+d*t+f*i,x+p*t+m*i));let A=!1;if(o){const t=C.map((t=>this.projectAndGetPerspectiveRatio(t.x,t.y,n,c,u)));A=t.some((t=>!t.isOccluded)),C=t.map((t=>new e.P(t.x,t.y)))}else A=!0;return{box:e.a4(C),allPointsOccluded:!A}}}function dt(t,i){const r=e.L();return e.a3(r,r,[1,1,0]),e.M(r,r,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?e.a6(r,r,t.calculatePosMatrix(i.toUnwrapped())):r}function pt(t,e,i,r,n,o,s){var a;const l=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,e,t.id),c=o.maxPitchScaleFactor(),h=t.tilesIn(r,c,l,null==n?void 0:n.skipGeoCheck);h.sort(ft);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,n,o,c,dt(t.transform,r.tileID),s?(t,e)=>s(r.tileID,t,e):void 0)});return function(t,e){for(const i in t)for(const r of t[i])mt(r,e);return t}(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}(u),t)}function ft(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 mt(t,e){const i=t.feature,r=e.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}function gt(t,i,r){const{glyphCircles:n,placedBoxes:o,anchorAngles:s,variableAnchors:a}=t.style.placement,l=i.bucketInstanceId,c=r.featureIndex;if(l in n&&c in n[l]){const t=n[l][c],i=s[l][c];let o=0;r.feature.paths=[],t.forEach((t=>{let n=[];const s=t.length/4;for(let e=0;e<s;e++)n.push(t[4*e]-ht),n.push(t[4*e+1]-ht);const a=n.length/2;if(n[0]>n[n.length-2]){const t=[];for(let e=1;e<=a;e++)t.push(n[2*(a-e)]),t.push(n[2*(a-e)+1]);n=t}if(1===a){const t=i[o],s=new e.P(n[0],n[1]);let a=new e.P(n[0]-20,n[1]),l=new e.P(n[0]+20,n[1]);a=a.rotateAround(t,s),l=l.rotateAround(t,s),r.feature.paths.push([a.x,a.y,l.x,l.y])}else{const t=_t(n[2],n[3],n[0],n[1],20);void 0!==t&&(n[0]=t.x,n[1]=t.y);const e=n.length,i=_t(n[e-4],n[e-3],n[e-2],n[e-1],20);void 0!==i&&(n[e-2]=i.x,n[e-1]=i.y),r.feature.paths.push(n)}o++}))}if(l in o&&c in o[l]){const t=o[l][c];r.feature.iconBoxes=[],r.feature.textBoxes=[],t.forEach((t=>{const{purpose:e,coords:i}=t;("icon"===e?r.feature.iconBoxes:r.feature.textBoxes).push(i.map((t=>t-ht)))}))}if(l in s&&c in s[l]){const t=s[l][c];r.feature.angles=[],t.forEach((t=>{r.feature.angles.push(180*t/Math.PI)}))}l in a&&c in a[l]&&(r.feature["placement-anchor"]=a[l][c])}function _t(t,e,i,r,n){if(t===i&&e===r)return;const o=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-r,2)),s=(n+o)/o;return{x:t+(i-t)*s,y:e+(r-e)*s}}function yt(t,i,r){return e._(this,void 0,void 0,(function*(){let n=t;if(t.url?n=(yield e.j(i.transformRequest(t.url,"Source"),r)).data:yield s.frameAsync(r),!n)return null;const o=e.a7(e.e(n,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(o.vectorLayerIds=n.vector_layers.map((t=>t.id))),o}))}class xt{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(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 e.a8?new e.a8(t.lng,t.lat):e.a8.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.a8?new e.a8(t.lng,t.lat):e.a8.convert(t),this}extend(t){const i=this._sw,r=this._ne;let n,o;if(t instanceof e.a8)n=t,o=t;else{if(!(t instanceof xt))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(xt.convert(t)):this.extend(e.a8.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.a8.convert(t)):this;if(n=t._sw,o=t._ne,!n||!o)return this}return i||r?(i.lng=Math.min(n.lng,i.lng),i.lat=Math.min(n.lat,i.lat),r.lng=Math.max(o.lng,r.lng),r.lat=Math.max(o.lat,r.lat)):(this._sw=new e.a8(n.lng,n.lat),this._ne=new e.a8(o.lng,o.lat)),this}getCenter(){return new e.a8((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 e.a8(this.getWest(),this.getNorth())}getSouthEast(){return new e.a8(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:i,lat:r}=e.a8.convert(t);let n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){return t instanceof xt?t:t?new xt(t):t}static fromLngLat(t,i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*t.lat);return new xt(new e.a8(t.lng-n,t.lat-r),new e.a8(t.lng+n,t.lat+r))}adjustAntiMeridian(){const t=new e.a8(this._sw.lng,this._sw.lat),i=new e.a8(this._ne.lng,this._ne.lat);return new xt(t,t.lng>i.lng?new e.a8(i.lng+360,i.lat):i)}}class vt{constructor(t,e,i){this.bounds=xt.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||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(t){const i=Math.pow(2,t.z),r=Math.floor(e.aa(this.bounds.getWest())*i),n=Math.floor(e.a9(this.bounds.getNorth())*i),o=Math.ceil(e.aa(this.bounds.getEast())*i),s=Math.ceil(e.a9(this.bounds.getSouth())*i);return t.x>=r&&t.x<o&&t.y>=n&&t.y<s}}class bt extends e.E{constructor(t,i,r,n){if(super(),this.id=t,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,e.e(this,e.a7(i,["url","scheme","tileSize","promoteId"])),this._options=e.e({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)}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield yt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t&&(e.e(this,t),t.bounds&&(this.tileBounds=new vt(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new e.k(t))}}))}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.abort(),t(),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.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),i={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i}}))}else t.actor=this.dispatcher.getActor(),r="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class wt extends e.E{constructor(t,i,r,n){super(),this.id=t,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=e.e({type:"raster"},i),e.e(this,e.a7(i,["url","scheme","tileSize"]))}load(){return e._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield yt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(e.e(this,i),i.bounds&&(this.tileBounds=new vt(i.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this.fire(new e.k(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme);t.abortController=new AbortController;try{const i=yield f.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const e=this.map.painter.context,r=e.gl,n=i.data;t.texture=this.map.painter.getTileTexture(n.width),t.texture?t.texture.update(n,{useMipmap:!0}):(t.texture=new x(e,n,r.RGBA,{useMipmap:!0}),t.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class Tt extends wt{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield f.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const n=e.b(r)&&e.ab()?r:yield this.readImageNow(r),o={type:this.type,uid:t.uid,source:this.id,rawImageData:n,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:o});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0}t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.ac()){const i=t.width+2,r=t.height+2;try{return new e.R({width:i,height:r},yield e.ad(t,-1,-1,i,r))}catch(t){}}return s.getImageData(t,1)}))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.ae(t.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.ae(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new e.ae(t.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.ae(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(t){return e._(this,void 0,void 0,(function*(){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",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}class St extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=e.e({},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,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&e.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=e.e({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:e.af,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:e.af,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(t){return t*(e.af/this.tileSize)}load(){return e._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}getData(){return e._(this,void 0,void 0,(function*(){const t=e.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getCoordinatesFromGeometry(t){return"GeometryCollection"===t.type?t.geometries.map((t=>t.coordinates)).flat(1/0):t.coordinates.flat(1/0)}getBounds(){return e._(this,void 0,void 0,(function*(){const t=new xt,e=yield this.getData();let i;switch(e.type){case"FeatureCollection":i=e.features.map((t=>this.getCoordinatesFromGeometry(t.geometry))).flat(1/0);break;case"Feature":i=this.getCoordinatesFromGeometry(e.geometry);break;default:i=this.getCoordinatesFromGeometry(e)}if(0==i.length)return t;for(let e=0;e<i.length-1;e+=2)t.extend([i[e],i[e+1]]);return t}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(void 0!==t.clusterRadius&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,e,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}_updateWorkerData(t){return e._(this,void 0,void 0,(function*(){const i=e.e({type:this.type},this.workerOptions);t?i.dataDiff=t:"string"==typeof this._data?(i.request=this.map._requestManager.transformRequest(s.resolveURL(this._data),"Source"),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new e.l("dataloading",{dataType:"source"}));try{const t=yield this.actor.sendAsync({type:"LD",data:i});if(this._pendingLoads--,this._removed||t.abandoned)return void this.fire(new e.l("dataabort",{dataType:"source"}));let r=null;t.resourceTiming&&t.resourceTiming[this.id]&&(r=t.resourceTiming[this.id].slice(0));const n={dataType:"source"};this._collectResourceTiming&&r&&r.length>0&&e.e(n,{resourceTiming:r}),this.fire(new e.l("data",Object.assign(Object.assign({},n),{sourceDataType:"metadata"}))),this.fire(new e.l("data",Object.assign(Object.assign({},n),{sourceDataType:"content"})))}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.l("dataabort",{dataType:"source"}));this.fire(new e.k(t))}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const r=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class Pt extends e.E{constructor(t,e,i,r){super(),this.flippedWindingOrder=!1,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(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield f.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,this.fire(new e.k(t))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const i=t.map(e.ag.fromLngLat);var r;return this.tileID=function(t){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.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 e.ai(a,Math.floor((i+n)/2*l),Math.floor((r+o)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((t=>this.tileID.getTilePoint(t)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture||(this.texture=new x(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y);const s={};for(let t=0;t<=e.ah;t++){const e=Math.pow(2,t),a=Math.floor(i*e),l=Math.floor(r*e),c=Math.floor(n*e),h=Math.floor(o*e);s[t]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:h}}return s}}class Mt extends Pt{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.aj(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.k(t))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.k(new e.ak(`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=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new x(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class It extends Pt{constructor(t,i,r,n){super(t,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 e.k(new e.ak(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.k(new e.ak(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.k(new e.ak(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.k(new e.ak(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.k(new e.ak(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new x(i,this.canvas,r.RGBA,{premultiply:!0});let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}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}}const Ct={},At=t=>{switch(t){case"geojson":return St;case"image":return Pt;case"raster":return wt;case"raster-dem":return Tt;case"vector":return bt;case"video":return Mt;case"canvas":return It}return Ct[t]},Et="RTLPluginLoaded";class kt extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.l(Et))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let zt=null;function Lt(){return zt||(zt=new kt),zt}class Dt{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.al(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,i,r){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,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.an){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.an&&i.hasRTLText){this.hasRTLText=!0,Lt().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new e.am}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.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 x(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new x(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,s,a,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:h},t,e,i):{}}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.ao(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<s.length;i++){const n=s.feature(i);if(a.needGeometry){const t=e.ap(n,!0);if(!a.filter(new e.C(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.C(this.tileID.overscaledZ),n))continue;const d=r.getId(n,o),p=new e.aq(n,l,c,h,d);p.tile=u,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.ar(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const r=this.expirationTime-i;r?this.expirationTime=t+Math.max(r,3e4):e=!0}else e=!0;e?(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<s.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=s.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}}class Rt{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 Ft{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const n=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][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,i){const r=String(i),n=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.e(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}r[t]=r[t]||{},e.e(r[t],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].setFeatureState(r,i)}}const Bt=89.25;function Ot(t,i){const r=e.K(i.lat,-85.051129,e.au);return new e.P(e.aa(i.lng)*t,e.a9(r)*t)}function jt(t,i){return new e.ag(i.x/t,i.y/t).toLngLat()}function Nt(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(e.as(90-t.pitch)),Math.tan(e.as(Bt-t.pitch)))}function Vt(t,i){const r=t.canonical,n=i/e.at(r.z),o=r.x+Math.pow(2,r.z)*t.wrap,s=e.a2(new Float64Array(16));return e.a3(s,s,[o*n,r.y*n,0]),e.M(s,s,[n/e.af,n/e.af,1]),s}function Ut(t,i,r,n,o){const s=e.ag.fromLngLat(t,i),a=o*e.av(1,t.lat),l=a*Math.cos(e.as(r)),c=Math.sqrt(a*a-l*l),h=c*Math.sin(e.as(-n)),u=c*Math.cos(e.as(-n));return new e.ag(s.x+h,s.y+u,s.z+l)}function Zt(t,e,i){const r=e.intersectsFrustum(t);if(!i)return r;const n=e.intersectsPlane(i);return 0===r||0===n?0:2===r&&2===n?2:1}function $t(t,e,i){let r=0;const n=(i-e)/10;for(let o=0;o<10;o++)r+=n*Math.pow(Math.cos(e+(o+.5)/10*(i-e)),t);return r}function Gt(t,i){return function(r,n,o,s,a){const l=2*((t-1)/e.aw(Math.cos(e.as(Bt-a))/Math.cos(e.as(Bt)))-1),c=Math.acos(o/s),h=2*$t(l-1,0,e.as(a/2)),u=Math.min(e.as(Bt),c+e.as(a/2)),d=$t(l-1,Math.min(u,c-e.as(a/2)),u),p=Math.atan(n/o),f=Math.hypot(n,o);let m=r;return m+=e.aw(s/f/Math.max(.5,Math.cos(e.as(a/2)))),m+=l*e.aw(Math.cos(p))/2,m-=e.aw(Math.max(1,d/h/i))/2,m}}const qt=Gt(9.314,3);function Wt(t,i){const r=(i.roundZoom?Math.round:Math.floor)(t.zoom+e.aw(t.tileSize/i.tileSize));return Math.max(0,r)}function Ht(t,i){const r=t.getCameraFrustum(),n=t.getClippingPlane(),o=t.screenPointToMercatorCoordinate(t.getCameraPoint()),s=e.ag.fromLngLat(t.center,t.elevation);o.z=s.z+Math.cos(t.pitchInRadians)*t.cameraToCenterDistance/t.worldSize;const a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,i),c=Wt(t,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:t.maxZoom,d=Math.min(Math.max(0,c),u),p=Math.pow(2,d),f=[p*o.x,p*o.y,0],m=[p*s.x,p*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),_=Math.abs(s.z-o.z),y=Math.hypot(g,_),x=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),v=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)v.push(x(-t)),v.push(x(t));for(v.push(x(0));v.length>0;){const p=v.pop(),g=p.x,x=p.y;let w=p.fullyVisible;const T={x:g,y:x,z:p.zoom},S=a.getTileAABB(T,p.wrap,t.elevation,i);if(!w){const t=Zt(r,S,n);if(0===t)continue;w=2===t}const P=a.distanceToTile2d(o.x,o.y,T,S);let M=c;l&&(M=(i.calculateTileZoom||qt)(t.zoom+e.aw(t.tileSize/i.tileSize),P,_,y,t.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const I=Math.min(M,u);if(p.wrap=a.getWrap(s,T,p.wrap),p.zoom>=I){if(p.zoom<h)continue;const t=d-p.zoom,r=f[0]-.5-(g<<t),n=f[1]-.5-(x<<t),o=i.reparseOverscaled?Math.max(p.zoom,M):p.zoom;b.push({tileID:new e.ae(p.zoom===u?o:p.zoom,p.wrap,p.zoom,g,x),distanceSq:e.ax([m[0]-.5-g,m[1]-.5-x]),tileDistanceToCamera:Math.sqrt(r*r+n*n)})}else for(let t=0;t<4;t++)v.push({zoom:p.zoom+1,x:(g<<1)+t%2,y:(x<<1)+(t>>1),wrap:p.wrap,fullyVisible:w})}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}class Xt extends e.E{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,r)=>{const n=new(At(e.type))(t,e,i,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return n})(t,e,i,this),this._tiles={},this._cache=new Rt(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ft,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)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,this.terrain)}_loadTile(t,i,r){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,i,r)}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.k(i,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}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 Object.values(this._tiles).map((t=>t.tileID)).sort(Kt).map((t=>t.key))}getRenderableIds(t){const i=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&i.push(this._tiles[e]);return t?i.sort(((t,i)=>{const r=t.tileID,n=i.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new e.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Kt).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(t){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)(t||"errored"!==this._tiles[e].state)&&this._reloadTile(e,"reloading")}}_reloadTile(t,i){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i))}))}_tileLoaded(t,i,r){t.timeAdded=s.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.l("data",{dataType:"source",tile:t,coord:t.tileID}))}_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){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!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]||t[a.canonical.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}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,r=Math.ceil(t.height/this._source.tileSize)+1,n=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),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])}}_updateCoveredAndRetainedTiles(t,e,i,r,n,o){const a={},l={},c=Object.keys(t),h=s.now();for(const i of c){const r=t[i],n=this._tiles[i];if(!n||0!==n.fadeEndTime&&n.fadeEndTime<=h)continue;const o=this.findLoadedParent(r,e),s=this.findLoadedSibling(r),c=o||s||null;c&&(this._addTile(c.tileID),a[c.tileID.key]=c.tileID),l[i]=r}this._retainLoadedChildren(l,r,i,t);for(const e in a)t[e]||(this._coveredTiles[e]=!0,t[e]=a[e]);if(o){const e={},i={};for(const t of n)this._tiles[t.key].hasData()?e[t.key]=t:i[t.key]=t;for(const r in i){const n=i[r].children(this._source.maxzoom);this._tiles[n[0].key]&&this._tiles[n[1].key]&&this._tiles[n[2].key]&&this._tiles[n[3].key]&&(e[n[0].key]=t[n[0].key]=n[0],e[n[1].key]=t[n[1].key]=n[1],e[n[2].key]=t[n[2].key]=n[2],e[n[3].key]=t[n[3].key]=n[3],delete i[r])}for(const r in i){const n=i[r],o=this.findLoadedParent(n,this._source.minzoom),s=this.findLoadedSibling(n),a=o||s||null;if(a){e[a.tileID.key]=t[a.tileID.key]=a.tileID;for(const t in e)e[t].isChildOf(a.tileID)&&delete e[t]}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0)}}update(t,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ae(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=Ht(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=Wt(t,this._source),o=Math.max(n-Xt.maxOverzooming,this._source.minzoom),s=Math.max(n+Xt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of r)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}r=r.concat(Object.values(t))}const a=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new e.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,n);Yt(this._source.type)&&this._updateCoveredAndRetainedTiles(l,o,s,n,r,i);for(const t in l)this._tiles[t].clearFadeHold();const c=e.ay(this._tiles,l);for(const t of c){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var i;const r={},n={},o=Math.max(e-Xt.maxOverzooming,this._source.minzoom),s=Math.max(e+Xt.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);r[i.key]=i,t.hasData()||e<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,e,s,r);for(const s of t){let t=this._tiles[s.key];if(t.hasData())continue;if(e+1>this._source.maxzoom){const t=s.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){r[t.key]=t;continue}}else{const t=s.children(this._source.maxzoom);if(4===t.length&&r[t[0].key]&&r[t[1].key]&&r[t[2].key]&&r[t[3].key])continue}let a=t.wasRequested();for(let e=s.overscaledZ-1;e>=o;--e){const o=s.scaledTo(e);if(n[o.key])break;if(n[o.key]=!0,t=this.getTile(o),!t&&a&&(t=this._addTile(o)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||a)&&(r[o.key]=o),a=t.wasRequested(),e)break}}}return r}_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}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,i=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const r=i;return i||(i=new Dt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._tiles[t.key]=i,r||this._source.fire(new e.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_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))))}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(t.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,i,r,n){const o=[],s=this.transform;if(!s)return o;const a=r?s.getCameraQueryGeometry(t):t,l=t.map((t=>s.screenPointToMercatorCoordinate(t,this.terrain))),c=a.map((t=>s.screenPointToMercatorCoordinate(t,this.terrain))),h=this.getIds();let u=1/0,d=1/0,p=-1/0,f=-1/0;for(const t of c)u=Math.min(u,t.x),d=Math.min(d,t.y),p=Math.max(p,t.x),f=Math.max(f,t.y);for(let t=0;t<h.length;t++){const r=this._tiles[h[t]];if(r.holdingForFade())continue;const a=s.getCoveringTilesDetailsProvider().allowWorldCopies()?r.tileID:r.tileID.unwrapTo(0),m=Math.pow(2,s.zoom-r.tileID.overscaledZ),g=i*r.queryPadding*e.af/r.tileSize/m,_=[a.getTilePoint(new e.ag(u,d)),a.getTilePoint(new e.ag(p,f))];if(n||_[0].x-g<e.af&&_[0].y-g<e.af&&_[1].x+g>=0&&_[1].y+g>=0){const t=l.map((t=>a.getTilePoint(t))),e=c.map((t=>a.getTilePoint(t)));o.push({tile:r,tileID:a,queryGeometry:t,cameraQueryGeometry:e,scale:m})}}return o}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));return this.transform&&this.transform.populateCache(e),e}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type)){const t=s.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)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 Kt(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 Yt(t){return"raster"===t||"image"===t||"video"===t}Xt.maxOverzooming=10,Xt.maxUnderzooming=3;class Jt{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 Qt{constructor(t,e,i,r,n){this.text=new Jt(t?t.text:null,e,i,n),this.icon=new Jt(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class te{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class ee{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class ie{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 re(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.aE(t);return new e.P(-(s-.5)*i+n[0]*o,-(a-.5)*r+n[1]*o)}class ne{constructor(t,e,i,r,n,o,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new ut(this.transform,o,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ie(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.glyphCircles={},this.placedBoxes={},this.anchorAngles={},this.variableAnchors={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,r)=>e.getElevation(t,i,r):null}getBucketParts(t,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=o.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.af,d=r.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=e.az(r,1,this.transform.zoom,this.transform.detailLevel),m=e.aA(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),g=e.aA(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Z(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ee(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const y={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:e.N(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:y})}attemptAnchorPlacement(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y,x,v){const b=e.aB[t.textAnchor],w=[t.textOffset0,t.textOffset1],T=re(b,r,n,w,o),S=this.collisionIndex.placeCollisionBox(i,d,l,c,h,a,s,g,u.predicate,x,T,v);if((!y||this.collisionIndex.placeCollisionBox(y,d,l,c,h,a,s,_,u.predicate,x,T,v).placeable)&&S.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:w,width:r,height:n,anchor:b,textBoxScale:o,prevAnchor:t},this.markUsedJustification(f,b,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:T,placedGlyphBoxes:S}}}placeLayerBucketPart(t,i,r){const{bucket:n,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=t.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=e.aC(o,"text-overlap","text-allow-overlap"),y="always"===_,x=e.aC(o,"icon-overlap","icon-allow-overlap"),v="always"===x,b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="none"!==o.get("icon-text-fit"),S="viewport-y"===o.get("symbol-z-order"),P=y&&(v||!n.hasIconData()||g),M=v&&(y||!n.hasTextData()||m);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d);const I=this.retainedQueryData[n.bucketInstanceId].tileID,C=this._getTerrainElevationFunc(I),A=this.transform.getFastPathSimpleProjectionMatrix(I),E=(t,d,v)=>{var S,E;if(i[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new te(!1,!1,!1));let k=!1,z=!1,L=!0,D=null,R={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,N=0,V=0,U=0;d.textFeatureIndex?N=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(N=t.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const Z=d.textBox;if(Z){const i=i=>{let r=e.W.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(n,r,t))}return r},o=(i,r)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of n.writingModes)if(t===e.W.vertical?(R=r(),F=R):R=i(),R&&R.placeable)break}else R=i()},c=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===c){const r=(e,i)=>{const r=this.collisionIndex.placeCollisionBox(e,_,h,I,l,w,b,s,f.predicate,C,void 0,A);return r&&r.placeable&&(this.markUsedOrientation(n,i,t),this.placedOrientations[t.crossTileID]=i),r};o((()=>r(Z,e.W.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?r(i,e.W.vertical):{box:null,offscreen:null}})),i(R&&R.placeable)}else{let p=e.aB[null===(E=null===(S=this.prevPlacement)||void 0===S?void 0:S.variableOffsets[t.crossTileID])||void 0===E?void 0:E.anchor];const m=(i,o,d)=>{const m=i.x2-i.x1,g=i.y2-i.y1,y=t.textBoxScale,v=T&&"never"===x?o:null;let S=null,P="never"===_?1:2,M="never";p&&P++;for(let r=0;r<P;r++){for(let r=c;r<u;r++){const o=n.textAnchorOffsets.get(r);if(p&&o.textAnchor!==p)continue;const c=this.attemptAnchorPlacement(o,i,m,g,y,b,w,h,I,l,f,M,t,n,d,s,a,v,C);if(c&&(S=c.placedGlyphBoxes,S&&S.placeable))return k=!0,D=c.shift,this.addVariableAnchor(n.bucketInstanceId,N,e.aB[o.textAnchor]),S}p?p=null:M=_}return r&&!S&&(S={box:this.collisionIndex.placeCollisionBox(Z,"always",h,I,l,w,b,s,f.predicate,C,void 0,A).box,offscreen:!1,placeable:!1,occluded:!1}),S};o((()=>m(Z,d.iconBox,e.W.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&(!R||!R.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,e.W.vertical):{box:null,occluded:!0,offscreen:null}})),R&&(k=R.placeable,L=R.offscreen);const g=i(R&&R.placeable);if(!k&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,g))}}}if(B=R,k=B&&B.placeable,L=B&&B.offscreen,t.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),a=e.O(n.textSizeData,p,i),h=o.get("text-padding");O=this.collisionIndex.placeCollisionCircles(_,i,n.lineVertexArray,n.glyphOffsetArray,a,l,c,r,w,f.predicate,t.collisionCircleDiameter,h,s,C),O.circles.length&&O.collisionDetected&&!r&&e.w("Collisions detected, but collision boxes are not shown"),k=y||O.circles.length>0&&!O.collisionDetected,L=L&&O.offscreen}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,x,h,I,l,w,b,a,f.predicate,C,T&&D?D:void 0,A);F&&F.placeable&&d.verticalIconBox?(j=t(d.verticalIconBox),z=j.placeable):(j=t(d.iconBox),z=j.placeable),L=L&&j.offscreen}const $=m||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=g||0===t.numIconVertices;$||G?G?$||(z=z&&k):k=z&&k:z=k=z&&k;const q=z&&j.placeable;if(k&&B.placeable&&(F&&F.placeable&&V?this.collisionIndex.insertCollisionBox(B.box,_,o.get("text-ignore-placement"),n.bucketInstanceId,V,f.ID):(this.collisionIndex.insertCollisionBox(B.box,_,o.get("text-ignore-placement"),n.bucketInstanceId,N,f.ID),this.addPlacedBox(n.bucketInstanceId,N,B.box,"text"))),q&&(this.collisionIndex.insertCollisionBox(j.box,x,o.get("icon-ignore-placement"),n.bucketInstanceId,U,f.ID),this.addPlacedBox(n.bucketInstanceId,U,j.box,"icon")),(k||z)&&this.addAnchorAngle(n.bucketInstanceId,N,t.angle),O&&k&&(this.collisionIndex.insertCollisionCircles(O.circles,_,o.get("text-ignore-placement"),n.bucketInstanceId,N,f.ID),L||this.addGlyphCircles(n.bucketInstanceId,N,O.circles)),r&&this.storeCollisionData(n.bucketInstanceId,v,d,B,j,O),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new te((k||P)&&!(null==B?void 0:B.occluded),(z||M)&&!(null==j?void 0:j.occluded),L||n.justReloaded),i[t.crossTileID]=!0};if(S){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=n.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){const i=e[t];E(n.symbolInstances.get(i),n.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)E(n.symbolInstances.get(e),n.collisionArrays[e],e);n.justReloaded=!1}storeCollisionData(t,e,i,r,n,o){if(i.textBox||i.iconBox){let o,s;this.collisionBoxArrays.has(t)?o=this.collisionBoxArrays.get(t):(o=new Map,this.collisionBoxArrays.set(t,o)),o.has(e)?s=o.get(e):(s={text:null,icon:null},o.set(e,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=n.box)}if(o){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<o.circles.length;t+=4)e.push(o.circles[t+0]-ht),e.push(o.circles[t+1]-ht),e.push(o.circles[t+2]),e.push(o.collisionDetected?1:0)}}markUsedJustification(t,i,r,n){let o;o=n===e.W.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[e.aD(i)];const s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:r.crossTileID)}markUsedOrientation(t,i,r){const n=i===e.W.horizontal||i===e.W.horizontalOnly?i:0,o=i===e.W.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(t.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 Qt(o,r,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new Qt(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 Qt(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]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");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,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(t,i,r,n){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const o=t.layers[0],s=o.layout,a=new Qt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new Qt(null,0,l&&(c||!t.hasIconData()||s.get("icon-optional")),c&&(l||!t.hasTextData()||s.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const m=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices=t.hasVisibleVertices||i!==fe},g=this.collisionBoxArrays.get(t.bucketInstanceId);for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:o,numVerticalGlyphVertices:s,crossTileID:l}=n;let c=this.opacities[l];r[l]?c=a:c||(c=f,this.opacities[l]=c),r[l]=!0;const _=n.numIconVertices>0,y=this.placedOrientations[n.crossTileID],x=y===e.W.vertical,v=y===e.W.horizontal||y===e.W.horizontalOnly;if(o>0||s>0){const e=pe(c.text);m(t.text,o,x?fe:e),m(t.text,s,v?fe:e);const i=c.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||x?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(t,r.anchor,n,y);const a=this.placedOrientations[n.crossTileID];a&&(this.markUsedJustification(t,"left",n,a),this.markUsedOrientation(t,a,n))}if(_){const e=pe(c.icon),i=!(p&&n.verticalPlacedIconSymbolIndex&&x);n.placedIconSymbolIndex>=0&&(m(t.icon,n.numIconVertices,i?e:fe),t.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=c.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,n.numVerticalIconVertices,i?fe:e),t.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=g&&g.has(i)?g.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0);if(r.textBox||r.verticalTextBox){let e=!0;if(h){const t=this.variableOffsets[l];t?(i=re(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):e=!1}if(r.textBox||r.verticalTextBox){let n;r.textBox&&(n=x),r.verticalTextBox&&(n=v),oe(t.textCollisionBox.collisionVertexArray,c.text.placed,!e||n,b.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){const e=Boolean(!v&&r.verticalIconBox);let n;r.iconBox&&(n=e),r.verticalIconBox&&(n=!e),oe(t.iconCollisionBox.collisionVertexArray,c.icon.placed,n,b.icon,p?i.x:0,p?i.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.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}addGlyphCircles(t,e,i){t in this.glyphCircles||(this.glyphCircles[t]={}),e in this.glyphCircles[t]||(this.glyphCircles[t][e]=[]),this.glyphCircles[t][e].push(i)}addPlacedBox(t,e,i,r){t in this.placedBoxes||(this.placedBoxes[t]={}),e in this.placedBoxes[t]||(this.placedBoxes[t][e]=[]),this.placedBoxes[t][e].push({purpose:r,coords:i})}addAnchorAngle(t,e,i){t in this.anchorAngles||(this.anchorAngles[t]={}),e in this.anchorAngles[t]||(this.anchorAngles[t][e]=[]),this.anchorAngles[t][e].push(i)}addVariableAnchor(t,e,i){t in this.variableAnchors||(this.variableAnchors[t]={}),this.variableAnchors[t][e]=i}}function oe(t,e,i,r,n,o){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-ht,a=r[1]-ht,l=r[2]-ht,c=r[3]-ht;t.emplaceBack(e?1:0,i?1:0,n||0,o||0,s,a),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,l,a),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,l,c),t.emplaceBack(e?1:0,i?1:0,n||0,o||0,s,c)}const se=Math.pow(2,25),ae=Math.pow(2,24),le=Math.pow(2,17),ce=Math.pow(2,16),he=Math.pow(2,9),ue=Math.pow(2,8),de=Math.pow(2,1);function pe(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*se+e*ae+i*le+e*ce+i*he+e*ue+i*de+e}const fe=0;class me{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),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 ge{constructor(t,e,i,r,n,o,s,a,l,c){this.placement=new ne(t,e,o,s,a,l,c),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=s.now(),n=()=>!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new me(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const _e=512/e.af/2;class ye{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};const n=new Map;for(let t=0;t<i.length;t++){const e=i.get(t),r=e.key,o=n.get(r);o?o.push(e):n.set(r,[e])}for(const[t,i]of n){const r={positions:i.map((t=>({x:Math.floor(t.anchorX*_e),y:Math.floor(t.anchorY*_e)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(r.positions.length>128){const t=new e.aF(r.positions.length,16,Uint16Array);for(const{x:e,y:i}of r.positions)t.add(e,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,i){const{x:r,y:n,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=_e/Math.pow(2,l-o),h=(a*e.af+t.anchorY)*c,u=n*e.af*_e;return{x:Math.floor((s*e.af+t.anchorX)*c-r*e.af*_e),y:Math.floor(h-u)}}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._symbolsByKey[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,e);if(s.index){const t=s.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(const e of t){const t=s.crossTileIDs[e];if(!i[t]){i[t]=!0,o.crossTileID=t;break}}}else if(s.positions)for(let t=0;t<s.positions.length;t++){const e=s.positions[t],n=s.crossTileIDs[t];if(Math.abs(e.x-a.x)<=r&&Math.abs(e.y-a.y)<=r&&!i[n]){i[n]=!0,o.crossTileID=n;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class xe{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ve{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 ye(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i of e.getCrossTileIDsLists())for(const e of i)delete this.usedCrossTileIDs[t][e]}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 be{constructor(){this.layerIndexes={},this.crossTileIDs=new xe,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new ve);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]}}var we="void main() {fragColor=vec4(1.0);}";const Te={prelude:Se("#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\nout highp vec4 fragColor;","#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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Se("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Se("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Se("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Se("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;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);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);}"),circle:Se("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid 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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Se(we,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Se("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Se("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out 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:Se("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Se("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Se("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Se(we,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Se("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Se("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Se("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);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 GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Se("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out 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=projectTile(a_pos+u_fill_translate,a_pos);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);}"),fillExtrusion:Se("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout 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 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((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.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Se("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out 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 normal=a_normal_ed.xyz;float edgedistance=a_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;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*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/16383.0,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*=((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;}"),hillshadePrepare:Se("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Se("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Se("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Se("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\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=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Se("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Se("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\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\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\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=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\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\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:Se("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Se("uniform sampler2D u_texture;in vec2 v_tex;in 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;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;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;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Se("#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;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\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 inner_edge=(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);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;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_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Se("#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;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\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;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,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);}"),terrain:Se("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Se("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Se("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Se("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Se("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Se("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Se(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/in ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(n):n,a={};return{fragmentSource:t=t.replace(i,((t,e,i,r,n)=>(a[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${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(i,((t,e,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return a[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\nout ${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;\nin ${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:r,staticUniforms:s}}class Pe{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Me=e.aG([{name:"a_pos",type:"Int16",components:2}]);const Ie="#define PROJECTION_MERCATOR",Ce="mercator";class Ae{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ce}get shaderDefine(){return Ie}get shaderPreludeCode(){return Te.projectionMercator}get vertexShaderPreludeCode(){return Te.projectionMercator.vertexSource}get subdivisionGranularity(){return e.aH.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,i,r,n,o){if(this._cachedMesh)return this._cachedMesh;const s=new e.aI;s.emplaceBack(0,0),s.emplaceBack(e.af,0),s.emplaceBack(0,e.af),s.emplaceBack(e.af,e.af);const a=t.createVertexBuffer(s,Me.members),l=e.aJ.simpleSegment(0,0,4,2),c=new e.aK;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=t.createIndexBuffer(c);return this._cachedMesh=new Pe(a,h,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Ee{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(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.B.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.B.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.B.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.B.number(t.right,i.right,r)),this}getCenter(t,i){const r=e.K((this.left+t-this.right)/2,0,t),n=e.K((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Ee(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ke(t,e){if(!t.renderWorldCopies||t.lngRange)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function ze(t){return Math.max(0,Math.floor(t))}class Le{constructor(t,i,r,n,o,s){this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==n?0:n,this._maxPitch=null==o?60:o,this.setMaxBounds(),this._width=0,this._height=0,this._center=new e.a8(0,0),this._elevation=0,this._zoom=0,this._tileZoom=ze(this._zoom),this._scale=e.at(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ee,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0,this._detailLevel=0,this._rasterAlignment=!0}apply(t,i,r){this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=ze(this._zoom),this._scale=e.at(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Ee(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!r&&t.autoCalculateNearFarZ,this._detailLevel=t.detailLevel,i&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const i=e.aL(t,-180,180)*Math.PI/180;var n,o,s,a,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),n=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],h=o[3],u=Math.sin(s),d=Math.cos(s),n[0]=a*d+c*u,n[1]=l*d+h*u,n[2]=a*-u+c*d,n[3]=l*-u+h*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const i=e.K(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return e.aM(this._fovInRadians)}setFov(t){t=e.K(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=e.as(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const i=this.getConstrained(this._center,t).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=e.at(i),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get detailLevel(){return this._detailLevel}setDetailLevel(t){if((t=Math.round(e.K(t,-3,3)))===this._detailLevel)return;const i=this._detailLevel;this._detailLevel=t,this.setZoom(this.zoom+this.detailLevel-i)}get rasterAlignment(){return this._rasterAlignment}setRasterAlignment(t){this._rasterAlignment=t}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,e){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=e,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}resize(t,e,i=!0){this._width=t,this._height=e,i&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new xt([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=[-85.051129,e.au])}getConstrained(t,e){return this._callbacks.getConstrained(t,e)}getCameraQueryGeometry(t,i){if(1===i.length)return[i[0],t];{let r=t.x,n=t.y,o=t.x,s=t.y;for(const t of i)r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y);return[new e.P(r,n),new e.P(o,n),new e.P(o,s),new e.P(r,s),new e.P(r,n)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(e),this.setZoom(i),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=e.a2(new Float64Array(16));e.M(t,t,[this._width/2,-this._height/2,1]),e.a3(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=e.a2(new Float64Array(16)),e.M(t,t,[1,-1,1]),e.a3(t,t,[-1,-1,0]),e.M(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height*2**this._detailLevel}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,i,r,n){const o=void 0!==r?r:this.bearing,s=n=void 0!==n?n:this.pitch,a=e.ag.fromLngLat(t,i),l=-Math.cos(e.as(s)),c=Math.sin(e.as(s)),h=c*Math.sin(e.as(o)),u=-c*Math.cos(e.as(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=e.aN(1,a.y),y=0;do{if(y+=1,y>10)break;g=f/_,m=new e.ag(a.x+h*g,a.y+u*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:e.aw(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const i=e.av(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,n=e.ag.fromLngLat(this.center,this.elevation),o=Ut(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=t;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),e.aN(o.z,n.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=e.av(1,this.center.lat)*this.worldSize;return Ut(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const i=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/i,t.canonical.y/i,1/i/e.af,1/i/e.af]}}class De{constructor(t,i){this.min=t,this.max=i,this.center=e.aO([],e.aP([],this.min,this.max),.5)}quadrant(t){const i=[t%2==0,t<2],r=e.aQ(this.min),n=e.aQ(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 De(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]}intersectsFrustum(t){let e=!0;for(let i=0;i<t.planes.length;i++){const r=this.intersectsPlane(t.planes[i]);if(0===r)return 0;1===r&&(e=!1)}return e?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let e=t[3],i=t[3];for(let r=0;r<3;r++)t[r]>0?(e+=t[r]*this.min[r],i+=t[r]*this.max[r]):(i+=t[r]*this.min[r],e+=t[r]*this.max[r]);return e>=0?2:i<0?0:1}}class Re{distanceToTile2d(t,e,i,r){const n=r.distanceX([t,e]),o=r.distanceY([t,e]);return Math.hypot(n,o)}getWrap(t,e,i){return i}getTileAABB(t,i,r,n){var o,s;let a=r,l=r;if(n.terrain){const c=new e.ae(t.z,i,t.z,t.x,t.y),h=n.terrain.getMinMaxElevation(c);a=null!==(o=h.minElevation)&&void 0!==o?o:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r}const c=1<<t.z;return new De([i+t.x/c,t.y/c,a],[i+(t.x+1)/c,(t.y+1)/c,l])}allowVariableZoom(t,i){const r=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,n=e.K(78.5-r/2,0,60);return!!i.terrain||t.pitch>n}allowWorldCopies(){return!0}recalculateCache(){}}class Fe{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(t,i=1,r=0){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=1/(r=e.Z([],r,t))[3]/i*n;return e.aR(r,r,[o,o,1/r[3],o])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const i=e.aS([],o[t[0]],o[t[1]]),r=e.aS([],o[t[2]],o[t[1]]),n=e.aT([],e.aU([],i,r)),s=-e.aV(n,o[t[1]]);return n.concat(s)})),a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const t of o)for(let e=0;e<3;e++)a[e]=Math.min(a[e],t[e]),l[e]=Math.max(l[e],t[e]);return new Fe(o,s,new De(a,l))}}class Be{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t,e){}constructor(t,e,i,r,n){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)},t,e,i,r,n),this._coveringTilesDetailsProvider=new Re}clone(){const t=new Be;return t.apply(this),t}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const i=[new e.aW(0,t)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new e.P(0,0)),n=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new e.P(0,this._helper._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 e.aW(r,t))}return i}getCameraFrustum(){return Fe.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLatZoom(e,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,i){const r=e.av(this.elevation,this.center.lat),n=this.screenPointToMercatorCoordinateAtZ(i,r),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=e.ag.fromLngLat(t),a=new e.ag(s.x-(n.x-o.x),s.y-(n.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(e.ag.fromLngLat(t),i.getElevationForLngLatZoom(t,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(e.ag.fromLngLat(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,i){const r=i||0,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.Z(n,n,this._pixelMatrixInverse),e.Z(o,o,this._pixelMatrixInverse);const s=n[3],a=o[3],l=n[1]/s,c=o[1]/a,h=n[2]/s,u=o[2]/a,d=h===u?0:(r-h)/(u-h);return new e.ag(e.B.number(n[0]/s,o[0]/a,d)/this.worldSize,e.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){const n=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.Z(n,n,r),new e.P(n[0]/n[3],n[1]/n[3])}getBounds(){const t=Math.max(0,this._helper._height/2-Nt(this));return(new xt).extend(this.screenPointToLocation(new e.P(0,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new e.P(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=e.pointCoordinate(t):t.y>this.height/2-Nt(this)}calculatePosMatrix(t,i=!1,r){var n;const o=null!==(n=t.key)&&void 0!==n?n:e.aX(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const t=s.get(o);return r?t.f32:t.f64}const a=Vt(t,this.worldSize);e.a6(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),r?l.f32:l.f64}calculateFogMatrix(t){const i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const n=Vt(t,this.worldSize);return e.a6(n,this._fogMatrix,n),r.set(i,new Float32Array(n)),r.get(i)}getConstrained(t,i){i=e.K(+i,this.minZoom,this.maxZoom);const r={center:new e.a8(t.lng,t.lat),zoom:i};let n=this._helper._lngRange;this._helper._renderWorldCopies||null!==n||(n=[-179.9999999999,180-1e-10]);const o=this.tileSize*e.at(r.zoom);let s=0,a=o,l=0,c=o,h=0,u=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const t=this._helper._latRange;s=e.a9(t[1])*o,a=e.a9(t[0])*o,a-s<p&&(h=p/(a-s))}n&&(l=e.aL(e.aa(n[0])*o,0,o),c=e.aL(e.aa(n[1])*o,0,o),c<l&&(c+=o),c-l<d&&(u=d/(c-l)));const{x:f,y:m}=Ot(o,t);let g,_;const y=Math.max(u||0,h||0);if(y){const t=new e.P(u?(c+l)/2:f,h?(a+s)/2:m);return r.center=jt(o,t).wrap(),r.zoom+=e.aw(y),r}if(this._helper._latRange){const t=p/2;m-t<s&&(_=s+t),m+t>a&&(_=a-t)}if(n){const t=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=e.aL(f,t-o/2,t+o/2));const r=d/2;i-r<l&&(g=l+r),i+r>c&&(g=c-r)}if(void 0!==g||void 0!==_){const t=new e.P(null!=g?g:f,null!=_?_:m);r.center=jt(o,t).wrap()}return r}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}_calculateNearFarZIfNeeded(t,i,r){if(!this._helper.autoCalculateNearFarZ)return;const n=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=t-n*this._helper._pixelPerMeter/Math.cos(i),s=n<0?o:t,a=Math.PI/2+this.pitchInRadians,l=e.as(this.fov)*(Math.abs(Math.cos(e.as(this.roll)))*this.height+Math.abs(Math.sin(e.as(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(e.K(Math.PI-a-l,.01,Math.PI-.01)),h=Nt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=e.as(.75),p=u>d?2*u*(.5+r.y/(2*h)):d,f=Math.sin(p)*s/Math.sin(e.K(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,i=Ot(this.worldSize,this.center),r=i.x,n=i.y;this._helper._pixelPerMeter=e.av(1,this.center.lat)*this.worldSize;const o=e.as(Math.min(this.pitch,Bt)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,t),a=new Float64Array(16),e.aY(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),e.Q(this._invProjMatrix,a),a[8]=2*-t.x/this._helper._width,a[9]=2*t.y/this._helper._height,this._projectionMatrix=e.aZ(a),e.M(a,a,[1,-1,1]),e.a3(a,a,[0,0,-this._helper.cameraToCenterDistance]),e.a_(a,a,-this.rollInRadians),e.a$(a,a,this.pitchInRadians),e.a_(a,a,-this.bearingInRadians),e.a3(a,a,[-r,-n,0]),this._mercatorMatrix=e.M([],a,[this.worldSize,this.worldSize,this.worldSize]),e.M(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=e.a6(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),this._viewProjMatrix=a,this._invViewProjMatrix=e.Q([],a);const l=[0,0,-1,1];if(e.Z(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),e.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,e.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),e.a3(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),e.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),e.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),e.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),e.a3(this._fogMatrix,this._fogMatrix,[-r,-n,0]),e.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),e.a3(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=e.a6(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),this._helper.rasterAlignment){const t=this._helper._width%2/2,i=this._helper._height%2/2,o=Math.cos(this.bearingInRadians),s=Math.sin(-this.bearingInRadians),l=r-Math.round(r)+o*t+s*i,c=n-Math.round(n)+o*i+s*t,h=new Float64Array(a);e.a3(h,h,[l>.5?l-1:l,c>.5?c-1:c,0]),this._alignedProjMatrix=h,a=e.Q(new Float64Array(16),this._pixelMatrix)}else this._alignedProjMatrix=new Float64Array(a);if(!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.Z(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=e.av(1,this.center.lat)*this.worldSize;return Ut(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,i){const r=e.ag.fromLngLat(t),n=[r.x*this.worldSize,r.y*this.worldSize,i,1];return e.Z(n,n,this._viewProjMatrix),n[2]/n[3]}getProjectionData(t){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=t,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:s||e.b0(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return e.aQ(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,i,r,n){const o=this.calculatePosMatrix(r);let s;n?(s=[t,i,n(t,i),1],e.Z(s,s,o)):(s=[t,i,0,1],ct(s,s,o));const a=s[3];return{point:new e.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(t){for(const e of t)this.calculatePosMatrix(e)}getMatrixForModel(t,i){const r=e.ag.fromLngLat(t,i),n=r.meterInMercatorCoordinateUnits(),o=e.b1();return e.a3(o,o,[r.x,r.y,r.z]),e.a_(o,o,Math.PI),e.a$(o,o,Math.PI/2),e.M(o,o,[-n,n,n]),o}getProjectionDataForCustomLayer(t=!0){const i=new e.ae(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),n=Vt(i,this.worldSize);e.a6(n,this._viewProjMatrix,n),r.tileMercatorCoords=[0,0,1,1];const o=[e.af,e.af,this.worldSize/this._helper.pixelsPerMeter],s=e.b2();return e.M(s,n,o),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function Oe(){e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function je(t){if(t.useSlerp)if(t.k<1){const i=e.b3(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=e.b3(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),n=new Float64Array(4);e.b4(n,i,r,t.k);const o=e.b5(n);t.tr.setRoll(o.roll),t.tr.setPitch(o.pitch),t.tr.setBearing(o.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(e.B.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(e.B.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(e.B.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ne(t,i,r,n,o){const s=o.padding,a=Ot(o.worldSize,r.getNorthWest()),l=Ot(o.worldSize,r.getNorthEast()),c=Ot(o.worldSize,r.getSouthEast()),h=Ot(o.worldSize,r.getSouthWest()),u=e.as(-n),d=a.rotate(u),p=l.rotate(u),f=c.rotate(u),m=h.rotate(u),g=new e.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new e.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),y=g.sub(_),x=(o.width-(s.left+s.right+i.left+i.right))/y.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/y.y;if(v<0||x<0)return void Oe();const b=Math.min(e.aw(o.scale*Math.min(x,v)),t.maxZoom),w=e.P.convert(t.offset),T=new e.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(e.as(n)),S=w.add(T).mult(o.scale/e.at(b));return{center:jt(o.worldSize,a.add(c).div(2).sub(S)),zoom:b,bearing:n}}class Ve{get useGlobeControls(){return!1}handlePanInertia(t,e){return{easingOffset:t,easingCenter:e.center}}handleMapControlsRollPitchBearingZoom(t,e){t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta),t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta)}handleMapControlsPan(t,e,i){t.around.distSqr(e.centerPoint)<.01||e.setLocationAtPoint(i,t.around)}cameraForBoxAndBearing(t,e,i,r,n){return Ne(t,e,i,r,n)}handleJumpToCenterZoom(t,i){t.zoom!==(void 0!==i.zoom?+i.zoom:t.zoom)&&t.setZoom(+i.zoom),void 0!==i.center&&t.setCenter(e.a8.convert(i.center))}handleEaseTo(t,i){const r=t.zoom,n=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},a=void 0!==i.zoom,l=!t.isPaddingEqual(i.padding);let c=!1;const h=a?+i.zoom:t.zoom;let u=t.centerPoint.add(i.offsetAsPoint);const d=t.screenPointToLocation(u),{center:p,zoom:f}=t.getConstrained(e.a8.convert(i.center||d),null!=h?h:r);ke(t,p);const m=Ot(t.worldSize,d),g=Ot(t.worldSize,p).sub(m),_=e.at(f-r);return c=f!==r,{easeFunc:a=>{if(c&&t.setZoom(e.B.number(r,f,a)),e.b6(o,s)||je({startEulerAngles:o,endEulerAngles:s,tr:t,k:a,useSlerp:o.roll!=s.roll}),l&&(t.interpolatePadding(n,i.padding,a),u=t.centerPoint.add(i.offsetAsPoint)),i.around)t.setLocationAtPoint(i.around,i.aroundPoint);else{const i=e.at(t.zoom-r),n=f>r?Math.min(2,_):Math.max(.5,_),o=Math.pow(n,1-a),s=jt(t.worldSize,m.add(g.mult(a*o)).mult(i));t.setLocationAtPoint(t.renderWorldCopies?s.wrap():s,u)}},isZooming:c,elevationCenter:p}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.zoom,o=t.getConstrained(e.a8.convert(i.center||i.locationAtOffset),r?+i.zoom:n),s=o.center,a=o.zoom;ke(t,s);const l=Ot(t.worldSize,i.locationAtOffset),c=Ot(t.worldSize,s).sub(l),h=c.mag(),u=e.at(a-n);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,n,a),o=t.getConstrained(s,r).zoom;d=e.at(o-n)}return{easeFunc:(i,r,o,h)=>{t.setZoom(1===i?a:n+e.aw(r));const u=1===i?s:jt(t.worldSize,l.add(c.mult(o)).mult(r));t.setLocationAtPoint(t.renderWorldCopies?u.wrap():u,h)},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class Ue{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}Ue.Replace=[1,0],Ue.disabled=new Ue(Ue.Replace,e.b7.transparent,[!1,!1,!1,!1]),Ue.unblended=new Ue(Ue.Replace,e.b7.transparent,[!0,!0,!0,!0]),Ue.alphaBlended=new Ue([1,771],e.b7.transparent,[!0,!0,!0,!0]);const Ze=2305;class $e{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}$e.disabled=new $e(!1,1029,Ze),$e.backCCW=new $e(!0,1029,Ze),$e.frontCCW=new $e(!0,1028,Ze);class Ge{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Ge.ReadOnly=!1,Ge.ReadWrite=!0,Ge.disabled=new Ge(519,Ge.ReadOnly,[0,1]);const qe=7680;class We{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}}We.disabled=new We({func:519,mask:0},0,0,qe,qe,qe);const He=new WeakMap;function Xe(t){var e;if(He.has(t))return He.get(t);{const i=null===(e=t.getParameter(t.VERSION))||void 0===e?void 0:e.startsWith("WebGL 2.0");return He.set(t,i),i}}class Ke{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const i=t.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const n=new e.aI;n.emplaceBack(-1,-1),n.emplaceBack(2,-1),n.emplaceBack(-1,2);const o=new e.aK;o.emplaceBack(0,1,2),this._fullscreenTriangle=new Pe(i.createVertexBuffer(n,Me.members),i.createIndexBuffer(o),e.aJ.simpleSegment(0,0,n.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),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.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Xe(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,e){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,e),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,e=t.gl;t.activeTexture.set(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,i){const r=this._cachedRenderContext.context,n=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:e.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,n.TRIANGLES,Ge.disabled,We.disabled,Ue.unblended,$e.disabled,((t,e)=>({u_input:t,u_output_expected:e}))(t,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Xe(n)){n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.readBuffer(n.COLOR_ATTACHMENT0),n.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null);const t=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);n.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:t}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Xe(t)){const i=t.clientWaitSync(this._readbackQueue.sync,0,0);if(i===t.WAIT_FAILED)return e.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ke._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let e=0;return e+=t[0]/256,e+=t[1]/65536,e+=t[2]/16777216,t[3]<127&&(e=-e),e/128}}const Ye=e.af/128;function Je(t,i){const r=void 0!==t.granularity?Math.max(t.granularity,1):1,n=r+(t.generateBorders?2:0),o=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),s=n+1,a=o+1,l=t.generateBorders?-1:0,c=t.generateBorders||t.extendToNorthPole?-1:0,h=r+(t.generateBorders?1:0),u=r+(t.generateBorders||t.extendToSouthPole?1:0),d=s*a,p=n*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=u;i++)for(let n=l;n<=h;n++){let o=n/r*e.af;-1===n&&(o=-64),n===r+1&&(o=e.af+Ye);let s=i/r*e.af;-1===i&&(s=t.extendToNorthPole?e.b9:-64),i===r+1&&(s=t.extendToSouthPole?e.ba:e.af+Ye),g[_++]=o,g[_++]=s}const y=m?new Uint32Array(p):new Uint16Array(p);let x=0;for(let t=0;t<o;t++)for(let e=0;e<n;e++){const i=e+1+t*s,r=e+(t+1)*s,n=e+1+(t+1)*s;y[x++]=e+t*s,y[x++]=r,y[x++]=i,y[x++]=i,y[x++]=r,y[x++]=n}return{vertices:g.buffer.slice(0),indices:y.buffer.slice(0),uses32bitIndices:m}}const Qe=new e.aH({fill:new e.bb(128,2),line:new e.bb(512,0),tile:new e.bb(128,32),stencil:new e.bb(128,1),circle:3});class ti{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Te.projectionGlobe}get vertexShaderPreludeCode(){return Te.projectionMercator.vertexSource}get subdivisionGranularity(){return Qe}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new Ke(t));const i=e.a9(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,n=this._errorMeasurement.updateErrorLoop(i,r),o=s.now();n!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=n,this._errorMeasurementLastChangeTime=o);const a=Math.min(Math.max((o-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=e.bc(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,e.bd(a))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,r,n){const o=("stencil"===n?Qe.stencil:Qe.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:o,generateBorders:i,extendToNorthPole:0===e.y&&r,extendToSouthPole:e.y===(1<<e.z)-1&&r})}_getMesh(t,i){const r=this._getMeshKey(i);if(r in this._tileMeshCache)return this._tileMeshCache[r];const n=function(t,i){const r=Je(i,"16bit"),n=e.aI.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),o=e.aK.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Pe(t.createVertexBuffer(n,Me.members),t.createIndexBuffer(o),e.aJ.simpleSegment(0,0,n.length,o.length))}(t,i);return this._tileMeshCache[r]=n,n}recalculate(t){}hasTransition(){const t=s.now();let e=!1;return e=e||(t-this._errorMeasurementLastChangeTime)/1e3<.7,e=e||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,e}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const ei=new e.r({type:new e.D(e.v.projection.type)});class ii extends e.E{constructor(t){super(),this._transitionable=new e.T(ei),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.C(0)),this._mercatorProjection=new Ae,this._verticalPerspectiveProjection=new ti}get transitionState(){const t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof e.be){if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,e,i,r,n){return this.currentProjection.getMeshFromTileID(t,e,i,r,n)}setProjection(t){this._transitionable.setValue("type",(null==t?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function ri(t){const e=si(t.worldSize,t.center.lat);return 2*Math.PI*e}function ni(t,i,r,n,o){const s=1/(1<<o),a=i/e.af*s+n*s,l=e.bg((t/e.af*s+r*s)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,h=Math.cos(c),u=new Float64Array(3);return u[0]=Math.sin(l)*h,u[1]=Math.sin(c),u[2]=Math.cos(l)*h,u}function oi(t){return function(t,e){const i=Math.cos(e),r=new Float64Array(3);return r[0]=Math.sin(t)*i,r[1]=Math.sin(e),r[2]=Math.cos(t)*i,r}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function si(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function ai(t){const i=Math.asin(t[1])/Math.PI*180,r=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(r>1e-6){const n=t[0]/r,o=Math.acos(t[2]/r),s=(n>0?o:-o)/Math.PI*180;return new e.a8(e.aL(s,-180,180),i)}return new e.a8(0,i)}function li(t){return Math.cos(t*Math.PI/180)}function ci(t,i){const r=li(t),n=li(i);return e.aw(n/r)}function hi(t,i){const r=t.rotate(i.bearingInRadians),n=i.zoom+ci(i.center.lat,0),o=e.bc(1/li(i.center.lat),1/li(Math.min(Math.abs(i.center.lat),60)),e.bf(n,7,3,0,1)),s=360/ri({worldSize:i.worldSize,center:{lat:i.center.lat}});return new e.a8(i.center.lng-r.x*s*o,e.K(i.center.lat+r.y*s,-85.051129,e.au))}function ui(t){const e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function di(t,i,r,n){const o=t.lat+r*n;if(Math.abs(r)>1){const s=(Math.sign(t.lat+r)!==Math.sign(t.lat)?-Math.abs(t.lat):Math.abs(t.lat))*Math.PI/180,a=Math.abs(t.lat+r)*Math.PI/180,l=ui(s+n*(a-s)),c=ui(s),h=ui(a);return new e.a8(t.lng+i*((l-c)/(h-c)),o)}return new e.a8(t.lng+i*n,o)}class pi{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=t}recalculateCache(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileAABB(t,e,i,r){const n=`${t.z}_${t.x}_${t.y}`,o=this._cache.get(n);if(o)return o;const s=this._cachePrevious.get(n);if(s)return this._cache.set(n,s),s;const a=this._aabbFactory(t,e,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}function fi(t,e,i){const r=t-e;return r<0?-r:Math.max(0,r-i)}function mi(t,e,i,r,n){const o=t-i;let s;return s=o<0?Math.min(-o,1+o-n):o>1?Math.min(Math.max(o-n,0),1-o):0,Math.max(s,fi(e,r,n))}class gi{constructor(){this._aabbCache=new pi(this._computeTileAABB)}recalculateCache(){this._aabbCache.recalculateCache()}distanceToTile2d(t,e,i,r){const n=1<<i.z,o=1/n,s=i.x/n,a=i.y/n;let l=2;return l=Math.min(l,mi(t,e,s,a,o)),l=Math.min(l,mi(t,e,s+.5,-a-o,o)),l=Math.min(l,mi(t,e,s+.5,2-a-o,o)),l}getWrap(t,e,i){const r=1<<e.z,n=1/r,o=e.x/r,s=fi(t.x,o,n),a=fi(t.x,o-1,n),l=fi(t.x,o+1,n),c=Math.min(s,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(t,e){return Wt(t,e)>4}allowWorldCopies(){return!1}getTileAABB(t,e,i,r){return this._aabbCache.getTileAABB(t,e,i,r)}_computeTileAABB(t,i,r,n){if(t.z<=0)return new De([-1,-1,-1],[1,1,1]);if(1===t.z)return new De([0===t.x?-1:0,0===t.y?0:-1,-1],[0===t.x?0:1,0===t.y?1:0,1]);{const i=[ni(0,0,t.x,t.y,t.z),ni(e.af,0,t.x,t.y,t.z),ni(e.af,e.af,t.x,t.y,t.z),ni(0,e.af,t.x,t.y,t.z)],r=[1,1,1],n=[-1,-1,-1];for(const t of i)for(let e=0;e<3;e++)r[e]=Math.min(r[e],t[e]),n[e]=Math.max(n[e],t[e]);if(0===t.y||t.y===(1<<t.z)-1){const e=[0,0===t.y?1:-1,0];for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),n[t]=Math.max(n[t],e[t])}return new De(r,n)}}}class _i{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e){this._helper.resize(t,e)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(){this._cachedClippingPlane=e.bk(),this._projectionMatrix=e.b1(),this._globeViewProjMatrix32f=e.b0(),this._globeViewProjMatrixNoCorrection=e.b1(),this._globeViewProjMatrixNoCorrectionInverted=e.b1(),this._globeProjMatrixInverted=e.b1(),this._cameraPosition=e.bh(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)}),this._coveringTilesDetailsProvider=new gi}clone(){const t=new _i;return t.apply(this),t}apply(t,e){this._globeLatitudeErrorCorrectionRadians=e||0,this._helper.apply(t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=e.bh();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:e,applyGlobeMatrix:i}=t,r=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const i=this.pitchInRadians,r=this.cameraToCenterDistance/t,n=Math.sin(i)*r,o=Math.cos(i)*r+1,s=1/Math.sqrt(n*n+o*o)*1;let a=-n,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const h=[0,a,l];e.bl(h,h,[0,0,0],-this.bearingInRadians),e.bm(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),e.bn(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/e.bo(h);return e.aO(h,h,u),[...h,-s*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(oi(t))}transformLightDirection(t){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,n=Math.cos(r),o=[Math.sin(i)*n,Math.sin(r),Math.cos(i)*n],s=[o[2],0,-o[0]],a=[0,0,0];e.aU(a,s,o),e.aT(s,s),e.aT(a,a);const l=[0,0,0];return e.aT(l,[s[0]*t[0]+a[0]*t[1]+o[0]*t[2],s[1]*t[0]+a[1]*t[1]+o[1]*t[2],s[2]*t[0]+a[2]*t[1]+o[2]*t[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,i,r){const n=function(t,i,r){const n=1/(1<<r.z);return new e.ag(t/e.af*n+r.x*n,i/e.af*n+r.y*n)}(t,i,r.canonical),o=(s=n.y,[e.bg(n.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI]);var s;return this.getCircleRadiusCorrection()/Math.cos(o[1])}projectTileCoordinates(t,i,r,n){const o=r.canonical,s=ni(t,i,o.x,o.y,o.z),a=1+(n?n(t,i):0)/e.bu,l=[s[0]*a,s[1]*a,s[2]*a,1];e.Z(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]<0;return{point:new e.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=si(this.worldSize,this.center.lat),i=e.b2(),r=e.b2();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),e.aY(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const n=this.centerOffset;i[8]=2*-n.x/this._helper._width,i[9]=2*n.y/this._helper._height,this._projectionMatrix=e.aZ(i),this._globeProjMatrixInverted=e.b2(),e.Q(this._globeProjMatrixInverted,i),e.a3(i,i,[0,0,-this.cameraToCenterDistance]),e.a_(i,i,this.rollInRadians),e.a$(i,i,-this.pitchInRadians),e.a_(i,i,this.bearingInRadians),e.a3(i,i,[0,0,-t]);const o=e.bh();o[0]=t,o[1]=t,o[2]=t,e.a$(r,i,this.center.lat*Math.PI/180),e.bp(r,r,-this.center.lng*Math.PI/180),e.M(r,r,o),this._globeViewProjMatrixNoCorrection=r,e.a$(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),e.bp(i,i,-this.center.lng*Math.PI/180),e.M(i,i,o),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=e.b2(),e.Q(this._globeViewProjMatrixNoCorrectionInverted,r);const s=e.bh();this._cameraPosition=e.bh(),this._cameraPosition[2]=this.cameraToCenterDistance/t,e.bl(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),e.bm(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),e.bl(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),e.aP(this._cameraPosition,this._cameraPosition,[0,0,1]),e.bm(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),e.bn(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const a=e.aZ(this._globeViewProjMatrixNoCorrectionInverted);e.M(a,a,[1,1,-1]),this._cachedFrustum=Fe.fromInvProjectionMatrix(a)}calculateFogMatrix(t){e.w("calculateFogMatrix is not supported on globe projection.");const i=e.b2();return e.a2(i),i}getVisibleUnwrappedCoordinates(t){return[new e.aW(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&e.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const r=oi(t);e.aO(r,r,1+i/e.bu);const n=e.bk();return e.Z(n,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),n[2]/n[3]}populateCache(t){}getBounds(){const t=.5*this.width,i=.5*this.height,r=[new e.P(0,0),new e.P(t,0),new e.P(this.width,0),new e.P(this.width,i),new e.P(this.width,this.height),new e.P(t,this.height),new e.P(0,this.height),new e.P(0,i)],n=[];for(const t of r)n.push(this.unprojectScreenPoint(t));let o=0,s=0,a=0,l=0;const c=this.center;for(const t of n){const i=e.bq(c.lng,t.lng),r=e.bq(c.lat,t.lat);i<s&&(s=i),i>o&&(o=i),r<l&&(l=r),r>a&&(a=r)}const h=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new xt(h)}getConstrained(t,i){const r=e.K(t.lat,-85.051129,e.au),n=e.K(+i,this.minZoom+ci(0,r),this.maxZoom);return{center:new e.a8(t.lng,r),zoom:n}}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,i){const r=oi(this.unprojectScreenPoint(i)),n=oi(t),o=e.bh();e.br(o);const s=e.bh();e.bn(s,r,o,-this.center.lng*Math.PI/180),e.bm(s,s,o,this.center.lat*Math.PI/180);const a=n[0]*n[0]+n[2]*n[2],l=s[0]*s[0];if(a<l)return;const c=Math.sqrt(a-l),h=-c,u=e.bs(n[0],n[2],s[0],c),d=e.bs(n[0],n[2],s[0],h),p=e.bh();e.bn(p,n,o,-u);const f=e.bs(p[1],p[2],s[1],s[2]),m=e.bh();e.bn(m,n,o,-d);const g=e.bs(m[1],m[2],s[1],s[2]),_=.5*Math.PI,y=f>=-_&&f<=_,x=g>=-_&&g<=_;let v,b;if(y&&x){const t=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;e.bv(u,t)+e.bv(f,i)<e.bv(d,t)+e.bv(g,i)?(v=u,b=f):(v=d,b=g)}else if(y)v=u,b=f;else{if(!x)return;v=d,b=g}const w=v/Math.PI*180,T=b/Math.PI*180,S=this.center.lat;this.setCenter(new e.a8(w,e.K(T,-90,90))),this.setZoom(this.zoom+ci(S,this.center.lat))}locationToScreenPoint(t,i){const r=oi(t);if(i){const n=i.getElevationForLngLatZoom(t,this._helper._tileZoom);e.aO(r,r,1+n/e.bu)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){const i=e.bk();return e.Z(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new e.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(e)return e}return e.ag.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(t,e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(t){const i=e.bk();i[0]=t.x/this.width*2-1,i[1]=-1*(t.y/this.height*2-1),i[2]=1,i[3]=1,e.Z(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const r=e.bh();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];const n=e.bh();return e.aT(n,r),n}isSurfacePointVisible(t){const e=this._cachedClippingPlane;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const i=e.bk();return e.Z(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(t,i){const r=e.aV(t,i),n=e.bh(),o=e.bh();e.aO(o,i,r),e.aS(n,t,o);const s=1-e.aV(n,n);if(s<0)return null;const a=e.aV(t,t)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=a/l,h=l;return{tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(t){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),n=this.rayPlanetIntersection(i,r);if(n){const t=e.bh();e.aP(t,i,[r[0]*n.tMin,r[1]*n.tMin,r[2]*n.tMin]);const o=e.bh();return e.aT(o,t),ai(o)}const o=this._cachedClippingPlane,s=o[0]*r[0]+o[1]*r[1]+o[2]*r[2],a=-e.bt(o,i)/s,l=e.bh();if(a>0)e.aP(l,i,[r[0]*a,r[1]*a,r[2]*a]);else{const t=e.bh();e.aP(t,i,[2*r[0],2*r[1],2*r[2]]);const n=e.bt(this._cachedClippingPlane,t);e.aS(l,t,[this._cachedClippingPlane[0]*n,this._cachedClippingPlane[1]*n,this._cachedClippingPlane[2]*n])}const c=function(t){const i=e.bh();return i[0]=t[0]*-t[3],i[1]=t[1]*-t[3],i[2]=t[2]*-t[3],{center:i,radius:Math.sqrt(1-t[3]*t[3])}}(o);return ai(function(t,i,r){const n=e.bh();e.aS(n,r,t);const o=e.bh();return e.bi(o,t,n,i/e.bj(n)),o}(c.center,c.radius,l))}getMatrixForModel(t,i){const r=e.a8.convert(t),n=1/e.bu,o=e.b1();return e.bp(o,o,r.lng/180*Math.PI),e.a$(o,o,-r.lat/180*Math.PI),e.a3(o,o,[0,0,1+i/e.bu]),e.a$(o,o,.5*Math.PI),e.M(o,o,[n,n,n]),o}getProjectionDataForCustomLayer(t=!0){const i=this.getProjectionData({overscaledTileID:new e.ae(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}}class yi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(t){this._helper.setDetailLevel(t)}setRasterAlignment(t){this._helper.setRasterAlignment(t)}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t,e){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Le({calcMatrices:()=>{this._calcMatrices()},getConstrained:(t,e)=>this.getConstrained(t,e)}),this._globeness=1,this._mercatorTransform=new Be,this._verticalPerspectiveTransform=new _i}clone(){const t=new yi;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this),t}apply(t){this._helper.apply(t),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const e=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:e.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:e.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return e.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return e.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){const n=this._mercatorTransform.getPitchedTextCorrection(t,i,r),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r);return e.bc(n,o,this._globeness)}projectTileCoordinates(t,e,i,r){return this.currentTransform.projectTileCoordinates(t,e,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}getConstrained(t,e){return this.currentTransform.getConstrained(t,e)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(t,e),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,e){return this.currentTransform.getMatrixForModel(t,e)}getProjectionDataForCustomLayer(t=!0){const e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class xi{get useGlobeControls(){return!0}handlePanInertia(t,i){const r=hi(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new e.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){const r=t.around,n=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);const o=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=e.bq(i.center.lng,n.lng),l=a/(Math.abs(a/180)+1),c=e.bq(i.center.lat,n.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*e.aV(u,h),p=e.bh();e.aP(p,u,[h[0]*d,h[1]*d,h[2]*d]);const f=e.bo(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=si(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=e.bf(g,.9,.5,1,.25),y=(1-e.at(-s))*Math.min(m,_),x=i.center.lat,v=i.zoom,b=new e.a8(i.center.lng+l*y,e.K(i.center.lat+c*y,-85.051129,e.au));i.setLocationAtPoint(n,r);const w=i.center,T=e.bf(Math.abs(a),45,85,0,1),S=e.bf(g,.75,.35,0,1),P=Math.pow(Math.max(T,S),.25),M=e.bq(w.lng,b.lng),I=e.bq(w.lat,b.lat);i.setCenter(new e.a8(w.lng+M*P,w.lat+I*P).wrap()),i.setZoom(v+ci(x,i.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;const r=e.center.lat,n=e.zoom;e.setCenter(hi(t.panDelta,e).wrap()),e.setZoom(n+ci(r,e.center.lat))}cameraForBoxAndBearing(t,i,r,n,o){const s=Ne(t,i,r,n,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,h=(o.height-i.bottom)/o.height*-2+1,u=e.bq(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),p=u?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+.5*e.bq(d,p),_=f+.5*e.bq(f,m),y=o.clone();y.setCenter(s.center),y.setBearing(s.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(s.zoom);const x=y.modelViewProjectionMatrix,v=[oi(r.getNorthWest()),oi(r.getNorthEast()),oi(r.getSouthWest()),oi(r.getSouthEast()),oi(new e.a8(p,_)),oi(new e.a8(d,_)),oi(new e.a8(g,f)),oi(new e.a8(g,m))],b=oi(s.center);let w=Number.POSITIVE_INFINITY;for(const t of v)a<0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"x",a))),l>0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"x",l))),c>0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"y",c))),h<0&&(w=xi.getLesserNonNegativeNonNull(w,xi.solveVectorScale(t,b,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=y.zoom+e.aw(w),s;Oe()}handleJumpToCenterZoom(t,i){const r=t.center.lat,n=t.getConstrained(i.center?e.a8.convert(i.center):t.center,t.zoom).center;t.setCenter(n.wrap());const o=void 0!==i.zoom?+i.zoom:t.zoom+ci(r,n.lat);t.zoom!==o&&t.setZoom(o)}handleEaseTo(t,i){const r=t.zoom,n=t.center,o=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},a={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},l=void 0!==i.zoom,c=!t.isPaddingEqual(i.padding);let h=!1;const u=i.center?e.a8.convert(i.center):n,d=t.getConstrained(u,r).center;ke(t,d);const p=t.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+ci(n.lat,u.lat)),p.setBearing(i.bearing);const f=new e.P(e.K(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.K(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+ci(n.lat,m.lat),_=r+ci(n.lat,0),y=g+ci(m.lat,0),x=e.bq(n.lng,m.lng),v=e.bq(n.lat,m.lat),b=e.at(y-_);return h=g!==r,{easeFunc:r=>{if(e.b6(s,a)||je({startEulerAngles:s,endEulerAngles:a,tr:t,k:r,useSlerp:s.roll!=a.roll}),c&&t.interpolatePadding(o,i.padding,r),i.around)e.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{const e=y>_?Math.min(2,b):Math.max(.5,b),i=Math.pow(e,1-r),o=di(n,x,v,r*i);t.setCenter(o.wrap())}if(h){const i=e.B.number(_,y,r)+ci(0,t.center.lat);t.setZoom(i)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.center,o=t.zoom,s=t.padding,a=!t.isPaddingEqual(i.padding),l=t.getConstrained(e.a8.convert(i.center||i.locationAtOffset),o).center,c=r?+i.zoom:t.zoom+ci(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new e.P(e.K(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.K(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,u);const d=h.center;ke(t,d);const p=function(t,i,r){const n=oi(i),o=oi(r),s=e.aV(n,o),a=Math.acos(s),l=ri(t);return a/(2*Math.PI)*l}(t,n,d),f=o+ci(n.lat,0),m=c+ci(d.lat,0),g=e.at(m-f);let _;if("number"==typeof i.minZoom){const r=+i.minZoom+ci(d.lat,0),n=Math.min(r,f,m)+ci(0,d.lat),o=t.getConstrained(d,n).zoom+ci(d.lat,0);_=e.at(o-f)}const y=e.bq(n.lng,d.lng),x=e.bq(n.lat,d.lat);return{easeFunc:(r,o,l,h)=>{const u=di(n,y,x,l);a&&t.interpolatePadding(s,i.padding,r);const p=1===r?d:u;t.setCenter(p.wrap());const m=f+e.aw(o);t.setZoom(1===r?c:m+ci(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(t,e,i,r,n){const o="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],l=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],h=e[0]*s[0]+e[1]*s[1]+e[2]*s[2];return c+n*l===a+n*h||s[3]*(a-c)+o[3]*(h-l)+a*h==c*l?null:(c+o[3]-n*h-n*s[3])/(c-a-n*h+n*l)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}}class vi{constructor(t){this._globe=t,this._mercatorCameraHelper=new Ve,this._verticalPerspectiveCameraHelper=new xi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,e){return this.currentHelper.handlePanInertia(t,e)}handleMapControlsRollPitchBearingZoom(t,e){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,e)}handleMapControlsPan(t,e,i){this.currentHelper.handleMapControlsPan(t,e,i)}cameraForBoxAndBearing(t,e,i,r,n){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,n)}handleJumpToCenterZoom(t,e){this.currentHelper.handleJumpToCenterZoom(t,e)}handleEaseTo(t,e){return this.currentHelper.handleEaseTo(t,e)}handleFlyTo(t,e){return this.currentHelper.handleFlyTo(t,e)}}const bi=(t,i)=>e.x(t,i&&i.filter((t=>"source.canvas"!==t.identifier))),wi=e.bw();class Ti extends e.E{constructor(t,i={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload()}},this.map=t,this.dispatcher=new O(B(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(t._requestManager,i.localIdeographFontFamily),this.lineAtlas=new k(256,512),this.crossTileSymbolIndex=new be,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.bx,this._loaded=!1,this._availableImages=[],this._labelFreeAreas=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.by()),Lt().on(Et,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const n=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;e.j(n,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,i,r)})).catch((t=>{this._loadStyleRequest=null,t&&!o.signal.aborted&&this.fire(new e.k(t))}))}loadJSON(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,r)})).catch((()=>{}))}loadEmpty(){this.fire(new e.l("dataloading",{dataType:"style"})),this._load(wi,{validate:!1})}_load(t,i,r){var n,o;const s=i.transformStyle?i.transformStyle(r,t):t;if(!i.validate||!bi(this,e.y(s))){this._loaded=!0,this.stylesheet=s;for(const t in s.sources)this.addSource(t,s.sources[t],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new C(this.stylesheet.light),this._setProjectionInternal((null===(n=this.stylesheet.projection)||void 0===n?void 0:n.type)||"mercator"),this.sky=new E(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new e.l("data",{dataType:"style"})),this.fire(new e.l("style.load"))}}_createLayers(){const t=e.bz(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const i of t){const t=e.bA(i);t.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=t}}_loadSprite(t,i=!1,r=void 0){let n;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,y(t,this.map._requestManager,this.map.getPixelRatio()*this.map.getScale(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const r=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of r)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const r in t[e]){const n="default"===e?r:`${e}:${r}`;this._spritesImagesIds[e].push(n),n in this.imageManager.images?this.imageManager.updateImage(n,t[e][r],!1):this.imageManager.addImage(n,t[e][r]),i&&(this._changedImages[n]=!0)}}})).catch((t=>{this._spriteRequest=null,n=t,this.fire(new e.k(n))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"})),r&&r(n)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}_validateLayer(t){const i=this.sourceCaches[t.source];if(!i)return;const r=t.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.k(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.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()}_serializeByIds(t,i=!1){const r=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?e.bB(r):r);const n=[];for(const o of t)if(r[o]){const t=i?e.bB(r[o]):r[o];n.push(t)}return n}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){var t,e,i;if(null===(t=this.light)||void 0===t?void 0:t.hasTransition())return!0;if(null===(e=this.sky)||void 0===e?void 0:e.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.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}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const r={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];r[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in r){const i=this.sourceCaches[t];!!r[t]!=!!i.used&&i.fire(new e.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,i&&this.fire(new e.l("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={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){var r;this._checkLoaded();const n=this.serialize();if(t=i.transformStyle?i.transformStyle(n,t):t,(null===(r=i.validate)||void 0===r||r)&&bi(this,e.y(t)))return!1;(t=e.bB(t)).layers=e.bz(t.layers);const o=e.bC(n,t),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const t of s.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],i=[];for(const r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setTransition":e.push((()=>{}));break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}addImages(t){for(const e in t)this.getImage(e)&&this.imageManager.removeImage(e),this.imageManager.addImage(e,t[e]),this._changedImages[e]=!0;return this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"})),this}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);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(e.y.source,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.sourceCaches[t]=new Xt(t,i,this.dispatcher);n.style=this,n.setEventedParent(this,(()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:t}))),n.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.k(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],i.fire(new e.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this.getLayer(n))return void this.fire(new e.k(new Error(`Layer "${n}" already exists on this map.`)));let o;if("custom"===t.type){if(bi(this,e.bD(t)))return;o=e.bA(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(n,t.source),t=e.bB(t),t=e.e(t,{source:n})),this._validate(e.y.layer,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.bA(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new e.k(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o,this._removedLayers[n]&&o.source&&"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",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new e.k(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(n,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.k(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}setLayersOrder(t){this._checkLoaded(),this._order=t.filter((t=>void 0!==this._layers[t])),this._layerOrderChanged=!0}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,r){this._checkLoaded();const n=this.getLayer(t);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new e.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,i,r={}){this._checkLoaded();const n=this.getLayer(t);if(n){if(!e.bE(n.filter,i))return null==i?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(e.y.filter,`layers.${n.id}.filter`,i,null,r)||(n.filter=e.bB(i),this._updateLayer(n)))}else this.fire(new e.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.bB(this.getLayer(t).filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const o=this.getLayer(t);o?e.bE(o.getLayoutProperty(i),r)||(o.setLayoutProperty(i,r,n),this._updateLayer(o)):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,i){const r=this.getLayer(t);if(r)return r.getLayoutProperty(i);this.fire(new e.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,r,n={}){this._checkLoaded();const o=this.getLayer(t);o?e.bE(o.getPaintProperty(i),r)||(o.setPaintProperty(i,r,n)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&n?this.fire(new e.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||n?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(n,t.id,i)):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this.sourceCaches[r];if(void 0===n)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.getSource().type,s="vector"===o?t.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.k(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(s,t.id,i):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.sourceCaches[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,t.id)):void this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.bF(this.sourceCaches,(t=>t.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,n=this.stylesheet;return e.bG({version:n.version,name:n.name,metadata:n.metadata,light:n.light,sky:n.sky,center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,sprite:n.sprite,glyphs:n.glyphs,transition:n.transition,projection:n.projection,sources:t,layers:i,terrain:r},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,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(t,i,r){i&&i.filter&&this._validate(e.y.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new e.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.k(new Error(`The layer '${t}' 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=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:a});for(const e in this.sourceCaches)i.layers&&!n[e]||o.push(pt(this.sourceCaches[e],this._layers,s,t,l,r,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));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(ft);for(const r of c){const o=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],e,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const e in o){const n=a[e]=a[e]||[],s=o[e];s.sort(((t,e)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(t.featureIndex);return i.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const o of s)n.push(o),gt(i[t[e].source],r,o)}}return function(t,e,i){for(const r in t)for(const n of t[r])mt(n,i[e[r].source]);return t}(a,t,i)}(this._layers,s,this.sourceCaches,t,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[t];return r?function(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}(r,i):[]}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.bE(t[i],r[i])){n=!0;break}if(!n)return;const o={now:s.now(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(o)}getProjection(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.sky}setSky(t,i={}){this._checkLoaded();const r=this.getSky();let n=!1;if(!t&&!r)return;if(t&&!r)n=!0;else if(!t&&r)n=!0;else for(const i in t)if(!e.bE(t[i],r[i])){n=!0;break}if(!n)return;const o={now:s.now(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,i),this.sky.updateTransitions(o)}_setProjectionInternal(t){const i=function(t){if(Array.isArray(t)){const e=new ii({type:t});return{projection:e,transform:new yi,cameraHelper:new vi(e)}}switch(t){case"mercator":return{projection:new Ae,transform:new Be,cameraHelper:new Ve};case"globe":{const t=new ii({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:t,transform:new yi,cameraHelper:new vi(t)}}case"vertical-perspective":return{projection:new ti,transform:new _i,cameraHelper:new xi};default:return e.w(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Ae,transform:new Be,cameraHelper:new Ve}}}(t);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const t in this.sourceCaches)this.sourceCaches[t].reload()}_validate(t,i,r,n,o={}){return(!o||!1!==o.validate)&&bi(this,t.call(e.y,e.e({key:i,style:this.serialize(),value:r,styleSpec:e.v},n)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Lt().off(Et,this._rtlPluginLoaded);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,e,i,r,n=!1){let o=!1,a=!1;const l={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this.sourceCaches[i.source];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],t.center.lng);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((n=n||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),t.zoom))&&(this.pauseablePlacement=new ge(t,this.map.terrain,this._order,n,e,i,r,this.placement,this._labelFreeAreas,this.map.getScale()),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(s.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)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(s.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t}))}getGlyphs(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.y.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,i,r={},n){this._checkLoaded();const o=[{id:t,url:i}],s=[...g(this.stylesheet.sprite),...o];this._validate(e.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,n))}removeSprite(t){this._checkLoaded();const i=g(this.stylesheet.sprite);if(i.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}else this.fire(new e.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(t,i={},r){this._checkLoaded(),t&&this._validate(e.y.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}setLabelFreeAreas(t){return!e.bH(t,this._labelFreeAreas)&&(this._labelFreeAreas=t,!0)}}var Si=e.aG([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{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,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,r,n,o,s,a,l):(t.bindVertexArray.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind())}freshBind(t,e,i,r,n,o,s,a){const l=t.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a,e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);o&&o.enableAttributes(h,t),s&&s.enableAttributes(h,t),a&&a.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)),a&&(a.bind(),a.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Mi=(t,i,r,n,o)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):e.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:r?r.calculateFogBlendOpacity(n):0,u_horizon_color:r?r.properties.get("horizon-color"):e.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Ii={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ci(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 Ai{constructor(t,i,r,n,o,s,a,l){const c=t.gl;this.program=c.createProgram();const h=Ci(i.staticAttributes),u=r?r.getBinderAttributes():[],d=h.concat(u),p=Te.prelude.staticUniforms?Ci(Te.prelude.staticUniforms):[],f=a.staticUniforms?Ci(a.staticUniforms):[],m=i.staticUniforms?Ci(i.staticUniforms):[],g=r?r.getBinderUniforms():[],_=p.concat(f).concat(m).concat(g),y=[];for(const t of _)y.indexOf(t)<0&&y.push(t);const x=r?r.defines():[];Xe(c)&&x.unshift("#version 300 es"),o&&x.push("#define OVERDRAW_INSPECTOR;"),s&&x.push("#define TERRAIN3D;"),l&&x.push(l);let v=x.concat(Te.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),b=x.concat(Te.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");Xe(c)||(v=function(t){return t.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(v),b=function(t){return t.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(b));const w=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(w,v),c.compileShader(w),!c.getShaderParameter(w,c.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${c.getShaderInfoLog(w)}`);c.attachShader(this.program,w);const T=c.createShader(c.VERTEX_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(T,b),c.compileShader(T),!c.getShaderParameter(T,c.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${c.getShaderInfoLog(T)}`);c.attachShader(this.program,T),this.attributes={};const S={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(c.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(c.linkProgram(this.program),!c.getProgramParameter(this.program,c.LINK_STATUS))throw new Error(`Program failed to link: ${c.getProgramInfoLog(this.program)}`);c.deleteShader(T),c.deleteShader(w);for(let t=0;t<y.length;t++){const e=y[t];if(e&&!S[e]){const t=c.getUniformLocation(this.program,e);t&&(S[e]=t)}}this.fixedUniforms=n(t,S),this.terrainUniforms=((t,i)=>({u_depth:new e.bI(t,i.u_depth),u_terrain:new e.bI(t,i.u_terrain),u_terrain_dim:new e.b8(t,i.u_terrain_dim),u_terrain_matrix:new e.bK(t,i.u_terrain_matrix),u_terrain_unpack:new e.bL(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.b8(t,i.u_terrain_exaggeration)}))(t,S),this.projectionUniforms=((t,i)=>({u_projection_matrix:new e.bK(t,i.u_projection_matrix),u_projection_tile_mercator_coords:new e.bL(t,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new e.bL(t,i.u_projection_clipping_plane),u_projection_transition:new e.b8(t,i.u_projection_transition),u_projection_fallback_matrix:new e.bK(t,i.u_projection_fallback_matrix)}))(t,S),this.binderUniforms=r?r.getUniforms(t,S):[]}draw(t,e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,g,_,y){const x=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(o),a){t.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,a.depthTexture),t.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,a.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(a[t])}if(l)for(const t in l)this.projectionUniforms[Ii[t]].set(l[t]);if(s)for(const t in this.fixedUniforms)this.fixedUniforms[t].set(s[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:f});let v=0;switch(e){case x.LINES:v=2;break;case x.TRIANGLES:v=3;break;case x.LINE_STRIP:v=1}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new Pi)).bind(t,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,g,_,y),x.drawElements(e,i.primitiveLength*v,x.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Ei(t,i,r){const n=1/e.az(r,1,i.transform.tileZoom,i.transform.detailLevel),o=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(r.tileID.canonical.x+r.tileID.wrap*o),l=s*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[n,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const ki=(t,i,r,n)=>{const o=t.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=e.bO();"viewport"===o.properties.get("anchor")&&e.bP(l,t.transform.bearingInRadians),e.bQ(a,a,l);const c=t.transform.transformLightDirection(a),h=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},zi=(t,i,r,n,o,s,a)=>e.e(ki(t,i,r,n),Ei(s,t,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Li=(t,i,r,n)=>e.e(Ei(i,t,r),{u_fill_translate:n}),Di=(t,e)=>({u_world:t,u_fill_translate:e}),Ri=(t,i,r,n,o)=>e.e(Li(t,i,r,o),{u_world:n}),Fi=(t,i,r,n,o)=>{const s=t.transform;let a,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const t=e.az(i,1,s.zoom,s.detailLevel);a=!0,l=[t,t],c=t/(e.af*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:n}},Bi=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Oi=t=>({u_viewport_size:[t.width,t.height]}),ji=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Ni=(t,i,r,n,o)=>{const s=e.az(t,1,i,r)/(e.af*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:e.az(t,1,i,r),u_intensity:n,u_globe_extrude_scale:s}},Vi=(t,i,r,n)=>{const o=e.L();e.bR(o,0,t.width,t.height,0,0,1);const s=t.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:n,u_opacity:i.paint.get("heatmap-opacity")}},Ui=(t,e,i)=>{const r=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),o=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s+=t.transform.bearingInRadians),{u_image:0,u_latrange:$i(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:r,u_highlight:n,u_accent:o}},Zi=(t,i)=>{const r=i.stride,n=e.L();return e.bR(n,0,e.af,-8192,0,0,1),e.a3(n,n,[0,-8192,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}};function $i(t,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new e.ag(0,n/r).toLngLat().lat,new e.ag(0,(n+1)/r).toLngLat().lat]}const Gi=(t,i,r,n)=>{const o=t.transform;return{u_translation:Ki(t,i,r),u_ratio:n/e.az(i,1,o.zoom,o.detailLevel),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},qi=(t,i,r,n,o)=>e.e(Gi(t,i,r,n),{u_image:0,u_image_height:o}),Wi=(t,i,r,n,o)=>{const s=t.transform,a=Xi(i,s);return{u_translation:Ki(t,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:n/e.az(i,1,s.zoom,s.detailLevel),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Hi=(t,i,r,n,o,s)=>{const a=t.lineAtlas,l=Xi(i,t.transform),c="round"===r.layout.get("line-cap"),h=a.getDash(o.from,c),u=a.getDash(o.to,c),d=h.width*s.fromScale,p=u.width*s.toScale;return e.e(Gi(t,i,r,n),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/p,-u.height/2],u_sdfgamma:a.width/(256*Math.min(d,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Xi(t,i){return 1/e.az(t,1,i.tileZoom,i.detailLevel)}function Ki(t,i,r){return e.aA(t.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Yi=(t,e,i,r,n)=>{return{u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=r.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Ji(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var o,s};function Ji(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 Qi=(t,e,i,r,n,o,s,a,l,c,h,u,d)=>{const p=s.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:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:o,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},tr=(t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>{const m=a.transform;return e.e(Qi(t,i,r,n,o,s,a,l,c,h,u,d,f),{u_gamma_scale:n?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},er=(t,i,r,n,o,s,a,l,c,h,u,d,p)=>e.e(tr(t,i,r,n,o,s,a,l,c,h,!0,u,0,p),{u_texsize_icon:d,u_texture_icon:1}),ir=(t,e)=>({u_opacity:t,u_color:e}),rr=(t,i,r,n,o)=>e.e(function(t,i,r,n){const o=r.imageManager.getPattern(t.from.toString()),s=r.imageManager.getPattern(t.to.toString()),{width:a,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,n.tileID.overscaledZ),h=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(n.tileID.canonical.x+n.tileID.wrap*c),d=h*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/e.az(n,1,r.transform.tileZoom,r.transform.detailLevel),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,o,i,n),{u_opacity:t}),nr=(t,e)=>{},or={fillExtrusion:(t,i)=>({u_lightpos:new e.bM(t,i.u_lightpos),u_lightpos_globe:new e.bM(t,i.u_lightpos_globe),u_lightintensity:new e.b8(t,i.u_lightintensity),u_lightcolor:new e.bM(t,i.u_lightcolor),u_vertical_gradient:new e.b8(t,i.u_vertical_gradient),u_opacity:new e.b8(t,i.u_opacity),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillExtrusionPattern:(t,i)=>({u_lightpos:new e.bM(t,i.u_lightpos),u_lightpos_globe:new e.bM(t,i.u_lightpos_globe),u_lightintensity:new e.b8(t,i.u_lightintensity),u_lightcolor:new e.bM(t,i.u_lightcolor),u_vertical_gradient:new e.b8(t,i.u_vertical_gradient),u_height_factor:new e.b8(t,i.u_height_factor),u_opacity:new e.b8(t,i.u_opacity),u_fill_translate:new e.bN(t,i.u_fill_translate),u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade)}),fill:(t,i)=>({u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillPattern:(t,i)=>({u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillOutline:(t,i)=>({u_world:new e.bN(t,i.u_world),u_fill_translate:new e.bN(t,i.u_fill_translate)}),fillOutlinePattern:(t,i)=>({u_world:new e.bN(t,i.u_world),u_image:new e.bI(t,i.u_image),u_texsize:new e.bN(t,i.u_texsize),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade),u_fill_translate:new e.bN(t,i.u_fill_translate)}),circle:(t,i)=>({u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_scale_with_map:new e.bI(t,i.u_scale_with_map),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_extrude_scale:new e.bN(t,i.u_extrude_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_globe_extrude_scale:new e.b8(t,i.u_globe_extrude_scale),u_translate:new e.bN(t,i.u_translate)}),collisionBox:(t,i)=>({u_pixel_extrude_scale:new e.bN(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_viewport_size:new e.bN(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.bJ(t,i.u_color),u_overlay:new e.bI(t,i.u_overlay),u_overlay_scale:new e.b8(t,i.u_overlay_scale)}),depth:nr,clippingMask:nr,heatmap:(t,i)=>({u_extrude_scale:new e.b8(t,i.u_extrude_scale),u_intensity:new e.b8(t,i.u_intensity),u_globe_extrude_scale:new e.b8(t,i.u_globe_extrude_scale)}),heatmapTexture:(t,i)=>({u_matrix:new e.bK(t,i.u_matrix),u_world:new e.bN(t,i.u_world),u_image:new e.bI(t,i.u_image),u_color_ramp:new e.bI(t,i.u_color_ramp),u_opacity:new e.b8(t,i.u_opacity)}),hillshade:(t,i)=>({u_image:new e.bI(t,i.u_image),u_latrange:new e.bN(t,i.u_latrange),u_light:new e.bN(t,i.u_light),u_shadow:new e.bJ(t,i.u_shadow),u_highlight:new e.bJ(t,i.u_highlight),u_accent:new e.bJ(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.bK(t,i.u_matrix),u_image:new e.bI(t,i.u_image),u_dimension:new e.bN(t,i.u_dimension),u_zoom:new e.b8(t,i.u_zoom),u_unpack:new e.bL(t,i.u_unpack)}),line:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_image:new e.bI(t,i.u_image),u_image_height:new e.b8(t,i.u_image_height)}),linePattern:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_texsize:new e.bN(t,i.u_texsize),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_image:new e.bI(t,i.u_image),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_scale:new e.bM(t,i.u_scale),u_fade:new e.b8(t,i.u_fade)}),lineSDF:(t,i)=>({u_translation:new e.bN(t,i.u_translation),u_ratio:new e.b8(t,i.u_ratio),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.bN(t,i.u_units_to_pixels),u_patternscale_a:new e.bN(t,i.u_patternscale_a),u_patternscale_b:new e.bN(t,i.u_patternscale_b),u_sdfgamma:new e.b8(t,i.u_sdfgamma),u_image:new e.bI(t,i.u_image),u_tex_y_a:new e.b8(t,i.u_tex_y_a),u_tex_y_b:new e.b8(t,i.u_tex_y_b),u_mix:new e.b8(t,i.u_mix)}),raster:(t,i)=>({u_tl_parent:new e.bN(t,i.u_tl_parent),u_scale_parent:new e.b8(t,i.u_scale_parent),u_buffer_scale:new e.b8(t,i.u_buffer_scale),u_fade_t:new e.b8(t,i.u_fade_t),u_opacity:new e.b8(t,i.u_opacity),u_image0:new e.bI(t,i.u_image0),u_image1:new e.bI(t,i.u_image1),u_brightness_low:new e.b8(t,i.u_brightness_low),u_brightness_high:new e.b8(t,i.u_brightness_high),u_saturation_factor:new e.b8(t,i.u_saturation_factor),u_contrast_factor:new e.b8(t,i.u_contrast_factor),u_spin_weights:new e.bM(t,i.u_spin_weights),u_coords_top:new e.bL(t,i.u_coords_top),u_coords_bottom:new e.bL(t,i.u_coords_bottom)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texture:new e.bI(t,i.u_texture),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texture:new e.bI(t,i.u_texture),u_gamma_scale:new e.b8(t,i.u_gamma_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_is_halo:new e.bI(t,i.u_is_halo),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.bI(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.bI(t,i.u_is_size_feature_constant),u_size_t:new e.b8(t,i.u_size_t),u_size:new e.b8(t,i.u_size),u_camera_to_center_distance:new e.b8(t,i.u_camera_to_center_distance),u_pitch:new e.b8(t,i.u_pitch),u_rotate_symbol:new e.bI(t,i.u_rotate_symbol),u_aspect_ratio:new e.b8(t,i.u_aspect_ratio),u_fade_change:new e.b8(t,i.u_fade_change),u_label_plane_matrix:new e.bK(t,i.u_label_plane_matrix),u_coord_matrix:new e.bK(t,i.u_coord_matrix),u_is_text:new e.bI(t,i.u_is_text),u_pitch_with_map:new e.bI(t,i.u_pitch_with_map),u_is_along_line:new e.bI(t,i.u_is_along_line),u_is_variable_anchor:new e.bI(t,i.u_is_variable_anchor),u_texsize:new e.bN(t,i.u_texsize),u_texsize_icon:new e.bN(t,i.u_texsize_icon),u_texture:new e.bI(t,i.u_texture),u_texture_icon:new e.bI(t,i.u_texture_icon),u_gamma_scale:new e.b8(t,i.u_gamma_scale),u_device_pixel_ratio:new e.b8(t,i.u_device_pixel_ratio),u_is_halo:new e.bI(t,i.u_is_halo),u_translation:new e.bN(t,i.u_translation),u_pitched_scale:new e.b8(t,i.u_pitched_scale)}),background:(t,i)=>({u_opacity:new e.b8(t,i.u_opacity),u_color:new e.bJ(t,i.u_color)}),backgroundPattern:(t,i)=>({u_opacity:new e.b8(t,i.u_opacity),u_image:new e.bI(t,i.u_image),u_pattern_tl_a:new e.bN(t,i.u_pattern_tl_a),u_pattern_br_a:new e.bN(t,i.u_pattern_br_a),u_pattern_tl_b:new e.bN(t,i.u_pattern_tl_b),u_pattern_br_b:new e.bN(t,i.u_pattern_br_b),u_texsize:new e.bN(t,i.u_texsize),u_mix:new e.b8(t,i.u_mix),u_pattern_size_a:new e.bN(t,i.u_pattern_size_a),u_pattern_size_b:new e.bN(t,i.u_pattern_size_b),u_scale_a:new e.b8(t,i.u_scale_a),u_scale_b:new e.b8(t,i.u_scale_b),u_pixel_coord_upper:new e.bN(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.bN(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.b8(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_texture:new e.bI(t,i.u_texture),u_ele_delta:new e.b8(t,i.u_ele_delta),u_fog_matrix:new e.bK(t,i.u_fog_matrix),u_fog_color:new e.bJ(t,i.u_fog_color),u_fog_ground_blend:new e.b8(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.b8(t,i.u_fog_ground_blend_opacity),u_horizon_color:new e.bJ(t,i.u_horizon_color),u_horizon_fog_blend:new e.b8(t,i.u_horizon_fog_blend),u_is_globe_mode:new e.b8(t,i.u_is_globe_mode)}),terrainDepth:(t,i)=>({u_ele_delta:new e.b8(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_texture:new e.bI(t,i.u_texture),u_terrain_coords_id:new e.b8(t,i.u_terrain_coords_id),u_ele_delta:new e.b8(t,i.u_ele_delta)}),projectionErrorMeasurement:(t,i)=>({u_input:new e.b8(t,i.u_input),u_output_expected:new e.b8(t,i.u_output_expected)}),atmosphere:(t,i)=>({u_sun_pos:new e.bM(t,i.u_sun_pos),u_atmosphere_blend:new e.b8(t,i.u_atmosphere_blend),u_globe_position:new e.bM(t,i.u_globe_position),u_globe_radius:new e.b8(t,i.u_globe_radius),u_inv_proj_matrix:new e.bK(t,i.u_inv_proj_matrix)}),sky:(t,i)=>({u_sky_color:new e.bJ(t,i.u_sky_color),u_horizon_color:new e.bJ(t,i.u_horizon_color),u_horizon:new e.bN(t,i.u_horizon),u_horizon_normal:new e.bN(t,i.u_horizon_normal),u_sky_horizon_blend:new e.b8(t,i.u_sky_horizon_blend),u_sky_blend:new e.b8(t,i.u_sky_blend)})};class sr{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;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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 ar={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class lr{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){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);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[ar[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class cr{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 hr extends cr{getDefault(){return e.b7.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 ur extends cr{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class dr extends cr{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class pr extends cr{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 fr extends cr{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class mr extends cr{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class gr extends cr{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 _r extends cr{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 yr extends cr{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 xr extends cr{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 vr extends cr{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 br extends cr{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class wr extends cr{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 Tr extends cr{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 Sr extends cr{getDefault(){return e.b7.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 Pr extends cr{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Mr extends cr{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 Ir extends cr{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Cr extends cr{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Ar extends cr{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Er extends cr{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class kr extends cr{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 zr extends cr{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 Lr extends cr{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 Dr extends cr{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 Rr extends cr{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 Fr extends cr{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Br extends cr{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;const i=this.gl;Xe(i)?i.bindVertexArray(t):null===(e=i.getExtension("OES_vertex_array_object"))||void 0===e||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Or extends cr{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 jr extends cr{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 Nr extends cr{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 Vr extends cr{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class Ur extends Vr{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 Zr extends Vr{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class $r extends Vr{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const Gr="Framebuffer is not complete";class qr{constructor(t,e,i,r,n){this.context=t,this.width=e,this.height=i;const o=t.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new Ur(t,s),r)this.depthAttachment=n?new $r(t,s):new Zr(t,s);else if(n)throw new Error("Stencil cannot be set without depth");if(o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE)throw new Error(Gr)}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 Wr{constructor(t){var e,i;if(this.gl=t,this.clearColor=new hr(this),this.clearDepth=new ur(this),this.clearStencil=new dr(this),this.colorMask=new pr(this),this.depthMask=new fr(this),this.stencilMask=new mr(this),this.stencilFunc=new gr(this),this.stencilOp=new _r(this),this.stencilTest=new yr(this),this.depthRange=new xr(this),this.depthTest=new vr(this),this.depthFunc=new br(this),this.blend=new wr(this),this.blendFunc=new Tr(this),this.blendColor=new Sr(this),this.blendEquation=new Pr(this),this.cullFace=new Mr(this),this.cullFaceSide=new Ir(this),this.frontFace=new Cr(this),this.program=new Ar(this),this.activeTexture=new Er(this),this.viewport=new kr(this),this.bindFramebuffer=new zr(this),this.bindRenderbuffer=new Lr(this),this.bindTexture=new Dr(this),this.bindVertexBuffer=new Rr(this),this.bindElementBuffer=new Fr(this),this.bindVertexArray=new Br(this),this.pixelStoreUnpack=new Or(this),this.pixelStoreUnpackPremultiplyAlpha=new jr(this),this.pixelStoreUnpackFlipY=new Nr(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.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),Xe(t)){this.HALF_FLOAT=t.HALF_FLOAT;const r=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(e=t.RGBA16F)&&void 0!==e?e:null==r?void 0:r.RGBA16F_EXT,this.RGB16F=null!==(i=t.RGB16F)&&void 0!==i?i:null==r?void 0:r.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.HALF_FLOAT_OES}}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.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new sr(this,t,e)}createVertexBuffer(t,e,i){return new lr(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,r){return new qr(this,t,e,i,r)}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(t){e.bE(t.blendFunction,Ue.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Xe(this.gl)?this.gl.createVertexArray():null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;return Xe(this.gl)?this.gl.deleteVertexArray(t):null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let Hr;function Xr(t,i,r,n,o){const s=t.context,a=t.transform,l=s.gl,c=t.useProgram("collisionBox"),h=[];let u=0,d=0;for(let e=0;e<n.length;e++){const p=n[e],f=i.getTile(p).getBucket(r);if(!f)continue;const m=o?f.textCollisionBox:f.iconCollisionBox,g=f.collisionCircleArray;g.length>0&&(h.push({circleArray:g,circleOffset:d,coord:p}),u+=g.length/4,d=u),m&&c.draw(s,l.LINES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Bi(t.transform),t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!h.length)return;const p=t.useProgram("collisionCircle"),f=new e.bS;f.resize(4*u),f._trim();let m=0;for(const t of h)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];f.emplace(m++,r,n,o,s,0),f.emplace(m++,r,n,o,s,1),f.emplace(m++,r,n,o,s,2),f.emplace(m++,r,n,o,s,3)}(!Hr||Hr.length<2*u)&&(Hr=function(t){const i=2*t,r=new e.bU;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}(u));const g=s.createIndexBuffer(Hr,!0),_=s.createVertexBuffer(f,e.bT.members,!0);for(const i of h){const n=Oi(t.transform);p.draw(s,l.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,n,t.style.map.terrain&&t.style.map.terrain.getTerrainData(i.coord),null,r.id,_,g,e.aJ.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}_.destroy(),g.destroy()}const Kr=e.a2(new Float32Array(16));function Yr(t,i,r,n,o,s){const{horizontalAlign:a,verticalAlign:l}=e.aE(t);return new e.P((-(a-.5)*i/o+n[0])*s,(-(l-.5)*r/o+n[1])*s)}function Jr(t,i,r,n,o,s){const a=i.tileAnchorPoint.add(new e.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let t=n.mult(s);r||(t=t.rotate(-o));const e=a.add(t);return q(e.x,e.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(r){const e=et(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(t),r=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(n.rotate(r))}return t.add(n)}function Qr(t,i,r,n,o,s,a,l,c,h,u,d){const p=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,g={};f.clear();for(let m=0;m<p.length;m++){const _=p.get(m),y=_.hidden||!_.crossTileID||t.allowVerticalPlacement&&!_.placedOrientation?null:n[_.crossTileID];if(y){const n=new e.P(_.anchorX,_.anchorY),p={getElevation:d,width:o.width,height:o.height,pitchedLabelPlaneMatrix:s,pitchWithMap:r,transform:o,tileAnchorPoint:n,translation:h,unwrappedTileID:u},m=r?rt(n.x,n.y,p):et(n.x,n.y,p),x=W(o.cameraToCenterDistance,m.signedDistanceFromCamera);let v=e.O(t.textSizeData,l,_)*x/e.a5;r&&(v*=t.tilePixelRatio/a);const{width:b,height:w,anchor:T,textOffset:S,textBoxScale:P}=y,M=Yr(T,b,w,S,P,v),I=o.getPitchedTextCorrection(n.x+h[0],n.y+h[1],u),C=Jr(m.point,p,i,M,-o.bearingInRadians,I),A=t.allowVerticalPlacement&&_.placedOrientation===e.W.vertical?Math.PI/2:0;for(let t=0;t<_.numGlyphs;t++)e.Y(f,C,A);c&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:C,angle:A})}else lt(_.numGlyphs,f)}if(c){m.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const r=i.get(t);if(r.hidden)lt(r.numGlyphs,m);else{const i=g[t];if(i)for(let t=0;t<r.numGlyphs;t++)e.Y(m,i.shiftedAnchor,i.angle);else lt(r.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function tn(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function en(t,i,r,n,o,s,a,l,c,h,u,d,p){const f=t.context,m=f.gl,g=t.transform,_="map"===l,y="map"===c,x="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),v=_&&!y&&!x,b=!r.layout.get("symbol-sort-key").isConstant();let w=!1;const T=t.getDepthModeForSublayer(0,Ge.ReadOnly),S=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=[],M=g.getCircleRadiusCorrection();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||!u.hasVisibleVertices)continue;const d=u.programConfigurations.get(r.id),f=o||c.sdfIcons,T=o?c.textSizeData:c.iconSizeData,I=y||0!==g.pitch,C=t.useProgram(tn(f,o,c),d),A=e.N(T,g.zoom),E=t.style.map.terrain&&t.style.map.terrain.getTerrainData(l);let k,z,L,D,R=[0,0],F=null;o?(z=n.glyphAtlasTexture,L=m.LINEAR,k=n.glyphAtlasTexture.size,c.iconsInText&&(R=n.imageAtlasTexture.size,F=n.imageAtlasTexture,D=I||t.options.rotating||t.options.zooming||"composite"===T.kind||"camera"===T.kind?m.LINEAR:m.NEAREST)):(z=n.imageAtlasTexture,L=f||t.options.rotating||t.options.zooming||!g.rasterAlignment||c.iconsNeedLinear||I?m.LINEAR:m.NEAREST,k=n.imageAtlasTexture.size);const B=e.az(n,1,t.transform.zoom,t.transform.detailLevel),O=Z(_,t.transform,B),j=e.L();e.Q(j,O);const N=$(y,_,t.transform,B),V=e.aA(g,n,s,a),U=g.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),G=S&&c.hasTextData(),q="none"!==r.layout.get("icon-text-fit")&&G&&c.hasIconData();if(x){const e=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(l,e,i):null,i="map"===r.layout.get("text-rotation-alignment");X(c,t,o,O,j,y,h,i,l.toUnwrapped(),g.width,g.height,V,e)}const W=o&&S||q,H=x||W?Kr:y?O:t.transform.clipSpaceToPixelsMatrix,K=f&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let Y;Y=f?c.iconsInText?er(T.kind,A,v,y,x,W,t,H,N,V,k,R,M):tr(T.kind,A,v,y,x,W,t,H,N,V,o,k,0,M):Qi(T.kind,A,v,y,x,W,t,H,N,V,o,k,M);const J={program:C,buffers:u,uniformValues:Y,projectionData:U,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:L,atlasInterpolationIcon:D,isSDF:f,hasHalo:K};if(b&&c.canOverlap){w=!0;const t=u.segments.get();for(const i of t)P.push({segments:new e.aJ([i]),sortKey:i.sortKey,state:J,terrainData:E})}else P.push({segments:u.segments,sortKey:0,state:J,terrainData:E})}w&&P.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of P){const i=e.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,rn(i.buffers,e.segments,r,t,i.program,T,u,d,n,i.projectionData,e.terrainData)),n.u_is_halo=0}rn(i.buffers,e.segments,r,t,i.program,T,u,d,i.uniformValues,i.projectionData,e.terrainData)}}function rn(t,e,i,r,n,o,s,a,l,c,h){const u=r.context;n.draw(u,u.gl.TRIANGLES,o,s,a,$e.backCCW,l,h,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function nn(t,i,r,n,o){const s=t.context,a=s.gl,l=We.disabled,c=new Ue([a.ONE,a.ONE],e.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=n.key;let d=r.heatmapFbos.get(u);d||(d=sn(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:e.b7.transparent});const p=h.programConfigurations.get(r.id),f=t.useProgram("heatmap",p,!o),m=t.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=t.style.map.terrain.getTerrainData(n);f.draw(s,a.TRIANGLES,Ge.disabled,l,c,$e.disabled,Ni(i,t.transform.zoom,t.transform.detailLevel,r.paint.get("heatmap-intensity"),1),g,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,t.transform.zoom,p)}function on(t,e,i,r,n){const o=t.context,s=o.gl,a=t.transform;o.setColorMode(t.colorModeForRenderPass());const l=an(o,e),c=i.key,h=e.heatmapFbos.get(c);if(!h)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});t.useProgram("heatmapTexture").draw(o,s.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Vi(t,e,0,1),null,u,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),h.destroy(),e.heatmapFbos.delete(c)}function sn(t,e,i){var r,n;const o=t.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(r=t.HALF_FLOAT)&&void 0!==r?r:o.UNSIGNED_BYTE,l=null!==(n=t.RGBA16F)&&void 0!==n?n:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,e,i,0,o.RGBA,a,null);const c=t.createFramebuffer(e,i,!1,!1);return c.colorAttachment.set(s),c}function an(t,e){return e.colorRampTexture||(e.colorRampTexture=new x(t,e.colorRamp,t.gl.RGBA)),e.colorRampTexture}function ln(t,e,i,r,n){if(!i||!r||!r.imageAtlas)return;const o=r.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const t=n.getPaintProperty(e);s=o[t],a=o[t]}s&&a&&t.setConstantPatternPositions(s,a)}function cn(t,i,r,n,o,s,a,l){const c=t.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),p=r.getCrossfadeParameters();let f,m,g,_,y;const x=t.transform,v=r.paint.get("fill-translate"),b=r.paint.get("fill-translate-anchor");a?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const w=u.constantOr(null);for(const u of n){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const S=T.getBucket(r);if(!S)continue;const P=S.programConfigurations.get(r.id),M=t.useProgram(m,P),I=t.style.map.terrain&&t.style.map.terrain.getTerrainData(u);d&&(t.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),P.updatePaintBuffers(p)),ln(P,h,w,T,r);const C=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),A=e.aA(x,T,v,b);if(a){_=S.indexBuffer2,y=S.segments2;const e=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===m&&d?Ri(t,p,T,e,A):Di(e,A)}else _=S.indexBuffer,y=S.segments,g=d?Li(t,p,T,A):{u_fill_translate:A};let E;if("translucent"===t.renderPass&&l){const[e]=t.getStencilConfigForOverlapAndUpdateStencilID(n);E=e[u.overscaledZ]}else E=t.stencilModeForClipping(u);M.draw(t.context,f,o,E,s,$e.backCCW,g,I,C,r.id,S.layoutVertexBuffer,_,y,r.paint,t.transform.zoom,P)}}function hn(t,i,r,n,o,s,a,l){const c=t.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),p=d.constantOr(1),f=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),_=t.transform;for(const d of n){const n=i.getTile(d),y=n.getBucket(r);if(!y)continue;const x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(d),v=y.programConfigurations.get(r.id),b=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(f));const w=_.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});ln(v,u,g,n,r);const T=e.aA(_,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),S=r.paint.get("fill-extrusion-vertical-gradient"),P=p?zi(t,S,m,T,d,f,n):ki(t,S,m,T);b.draw(c,c.gl.TRIANGLES,o,s,a,$e.backCCW,P,x,w,r.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,r.paint,t.transform.zoom,v,t.style.map.terrain&&y.centroidVertexBuffer)}}function un(t,e,i,r,n,o,s,a,l){var c;const h=t.style.projection,u=t.context,d=t.transform,p=u.gl,f=t.useProgram("hillshade"),m=!t.options.moving;for(const g of r){const r=e.getTile(g),_=r.fbo;if(!_)continue;const y=h.getMeshFromTileID(u,g.canonical,a,!0,"raster"),x=null===(c=t.style.map.terrain)||void 0===c?void 0:c.getTerrainData(g);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,_.colorAttachment.get());const v=d.getProjectionData({overscaledTileID:g,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(u,p.TRIANGLES,o,n[g.overscaledZ],s,$e.backCCW,Ui(t,r,i),x,v,i.id,y.vertexBuffer,y.indexBuffer,y.segments)}}const dn=[new e.P(0,0),new e.P(e.af,0),new e.P(e.af,e.af),new e.P(0,e.af)];function pn(t,e,i,r,n,o,s,a,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=t.context,d=u.gl,p=t.useProgram("raster"),f=t.transform,m=t.style.projection,g=t.colorModeForRenderPass(),_=!t.options.moving;for(const y of r){const r=t.getDepthModeForSublayer(y.overscaledZ-h,1===i.paint.get("raster-opacity")?Ge.ReadWrite:Ge.ReadOnly,d.LESS),x=e.getTile(y);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const v=e.findLoadedParent(y,0),b=e.findLoadedSibling(y),w=fn(x,v||b||null,e,i,t.transform,t.style.map.terrain);let T,S;const P="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(P,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),v?(v.texture.bind(P,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,v.tileID.overscaledZ-x.tileID.overscaledZ),S=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(P,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const M=t.style.map.terrain&&t.style.map.terrain.getTerrainData(y),I=f.getProjectionData({overscaledTileID:y,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),C=Yi(S||[0,0],T||1,w,i,a),A=m.getMeshFromTileID(u,y.canonical,o,s,"raster");p.draw(u,d.TRIANGLES,r,n?n[y.overscaledZ]:We.disabled,g,l?$e.frontCCW:$e.backCCW,C,M,I,i.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function fn(t,i,r,n,o,a){const l=n.paint.get("raster-fade-duration");if(!a&&l>0){const n=s.now(),a=(n-t.timeAdded)/l,c=i?(n-i.timeAdded)/l:-1,h=r.getSource(),u=Wt(o,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=d&&t.refreshedUponExpiration?1:e.K(d?a:1-c,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const mn=new e.b7(1,0,0,1),gn=new e.b7(0,1,0,1),_n=new e.b7(0,0,1,1),yn=new e.b7(1,0,1,1),xn=new e.b7(0,1,1,1);function vn(t,e,i,r){wn(t,0,e+i/2,t.transform.width,i,r)}function bn(t,e,i,r){wn(t,e-i/2,0,i,t.transform.height,r)}function wn(t,e,i,r,n,o){const s=t.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Tn(t,i,r){const n=t.context,o=n.gl,s=t.useProgram("debug"),a=Ge.disabled,l=We.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r);n.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/t.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)}(t,`${g} ${p}kB`);const _=t.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(n,o.TRIANGLES,a,l,Ue.alphaBlended,$e.disabled,ji(e.b7.transparent,m),null,_,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(n,o.LINE_STRIP,a,l,c,$e.disabled,ji(e.b7.red),u,_,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Sn(t,e,i,r){const{isRenderingGlobe:n}=r,o=t.context,s=o.gl,a=t.transform,l=t.colorModeForRenderPass(),c=t.getDepthModeFor3D(),h=t.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,t.width,t.height]);for(const r of i){const i=e.getTerrainMesh(r.tileID),u=t.renderToTexture.getTexture(r),d=e.getTerrainData(r.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const p=e.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=Mi(p,f,t.style.sky,a.pitch,n),g=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(o,s.TRIANGLES,c,We.disabled,l,$e.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Pn(t,i){if(!i.mesh){const r=new e.aI;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const n=new e.aK;n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),i.mesh=new Pe(t.createVertexBuffer(r,Me.members),t.createIndexBuffer(n),e.aJ.simpleSegment(0,0,r.length,n.length))}return i.mesh}class Mn{constructor(t,i){this.context=new Wr(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.a2(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Xt.maxUnderzooming+Xt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new be}resize(t,e,i,r){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i*r,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 t=this.context,i=new e.aI;i.emplaceBack(0,0),i.emplaceBack(e.af,0),i.emplaceBack(0,e.af),i.emplaceBack(e.af,e.af),this.tileExtentBuffer=t.createVertexBuffer(i,Me.members),this.tileExtentSegments=e.aJ.simpleSegment(0,0,4,2);const r=new e.aI;r.emplaceBack(0,0),r.emplaceBack(e.af,0),r.emplaceBack(0,e.af),r.emplaceBack(e.af,e.af),this.debugBuffer=t.createVertexBuffer(r,Me.members),this.debugSegments=e.aJ.simpleSegment(0,0,4,5);const n=new e.bZ;n.emplaceBack(0,0,0,0),n.emplaceBack(e.af,0,e.af,0),n.emplaceBack(0,e.af,0,e.af),n.emplaceBack(e.af,e.af,e.af,e.af),this.rasterBoundsBuffer=t.createVertexBuffer(n,Si.members),this.rasterBoundsSegments=e.aJ.simpleSegment(0,0,4,2);const o=new e.aI;o.emplaceBack(0,0),o.emplaceBack(e.af,0),o.emplaceBack(0,e.af),o.emplaceBack(e.af,e.af),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(o,Me.members),this.rasterBoundsSegmentsPosOnly=e.aJ.simpleSegment(0,0,4,5);const s=new e.aI;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Me.members),this.viewportSegments=e.aJ.simpleSegment(0,0,4,2);const a=new e.b_;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(a);const l=new e.aK;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new We({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new Pe(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=e.L();e.bR(r,0,this.width,this.height,0,0,1),e.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const n={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,Ge.disabled,this.stencilClearMode,Ue.disabled,$e.disabled,null,null,n,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ue.disabled),r.setDepthMode(Ge.disabled);const n={};for(const t of e)n[t.key]=this.nextStencilID++;this._renderTileMasks(n,e,i,!0),this._renderTileMasks(n,e,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(t,e,i,r){const n=this.context,o=n.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of e){const e=t[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(n,o.TRIANGLES,Ge.disabled,new We({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),Ue.disabled,i?$e.disabled:$e.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}_renderTilesDepthBuffer(){const t=this.context,e=t.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ht(r,{tileSize:r.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(t,e.TRIANGLES,o,We.disabled,Ue.disabled,$e.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new We({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new We({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let i=0;i<n;i++)t[i+r]=new We({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:We.disabled},i]}stencilConfigForOverlapTwoPass(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const t={},o={};for(let i=0;i<n;i++)t[i+r]=new We({func:e.GREATER,mask:255},n+1+i,255,e.KEEP,e.KEEP,e.REPLACE),o[i+r]=new We({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*n+1,[t,o,i]}return this.nextStencilID=3,[{[r]:new We({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new We({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Ue([t.CONSTANT_COLOR,t.ONE],new e.b7(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Ue.unblended:Ue.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return Ge.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Ge(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new Ge(this.context.gl.LEQUAL,Ge.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){var r,n;this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(s.now()),this.imageManager.beginFrame();const o=this.style._order,a=this.style.sourceCaches,l={},c={},h={},u={isRenderingToTexture:!1,isRenderingGlobe:(null===(r=t.projection)||void 0===r?void 0:r.transitionState)>0};for(const t in a){const e=a[t];e.used&&e.prepare(this.context),l[t]=e.getVisibleCoordinates(!1),c[t]=l[t].slice().reverse(),h[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<o.length;t++)if(this.style._layers[o[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const t of o){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=c[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,a[e.source],e,i,u)}if(null===(n=this.style.projection)||void 0===n||n.updateGPUdependent({context:this.context,useProgram:t=>this.useProgram(t)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.b7.black:e.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(t,e){const i=t.context,r=i.gl,n=((t,e,i)=>{const r=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),o=Nt(e),s=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-o*n)*i,(e.height/2+o*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:s}})(e,t.style.map.transform,t.pixelRatio),o=new Ge(r.LEQUAL,Ge.ReadWrite,[0,1]),s=We.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),c=Pn(i,e);l.draw(i,r.TRIANGLES,o,s,a,$e.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[o[this.currentLayer]],e=a[t.source],i=l[t.source];this._renderTileClippingMasks(t,i,!1),this.renderLayer(this,e,t,i,u)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const t=this.style._layers[o[this.currentLayer]],e=a[t.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(t,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===t.type?h:c)[t.source];this._renderTileClippingMasks(t,l[t.source],!1),this.renderLayer(this,e,t,i,u)}if(u.isRenderingGlobe&&function(t,i,r){const n=t.context,o=n.gl,s=t.useProgram("atmosphere"),a=new Ge(o.LEQUAL,Ge.ReadOnly,[0,1]),l=t.transform,c=function(t,i){const r=t.properties.get("position"),n=[-r.x,-r.y,-r.z],o=e.a2(new Float64Array(16));return"map"===t.properties.get("anchor")&&(e.a_(o,o,i.rollInRadians),e.a$(o,o,-i.pitchInRadians),e.a_(o,o,i.bearingInRadians),e.a$(o,o,i.center.lat*Math.PI/180),e.bp(o,o,-i.center.lng*Math.PI/180)),e.bY(n,n,o),n}(r,t.transform),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;const d=si(l.worldSize,l.center.lat),p=l.inverseProjectionMatrix,f=new Float64Array(4);f[3]=1,e.Z(f,f,l.modelViewProjectionMatrix),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1,e.Z(f,f,p),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1;const m=((t,e,i,r,n)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(c,u,[f[0],f[1],f[2]],d,p),g=Pn(n,i);s.draw(n,o.TRIANGLES,a,We.disabled,Ue.alphaBlended,$e.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const t=function(t,e){let i=null;const r=Object.values(t._layers).flatMap((i=>i.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),n=r.filter((t=>"vector"===t.getSource().type)),o=r.filter((t=>"vector"!==t.getSource().type)),s=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};return n.forEach((t=>s(t))),i||o.forEach((t=>s(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let r=0;r<i.length;r++)Tn(t,e,i[r])}(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;vn(t,t.transform.height-(e.top||0),3,mn),vn(t,e.bottom||0,3,gn),bn(t,e.left||0,3,_n),bn(t,t.transform.width-(e.right||0),3,yn);const i=t.transform.centerPoint;!function(t,e,i,r){wn(t,e-1,i-10,2,20,r),wn(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,xn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const i=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let n=this.terrainFacilitator.dirty;n||(n=t?!e.b$(i,r):!e.c0(i,r)),n||(n=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),n&&(e.c1(i,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){const r=t.context,n=r.gl,o=t.transform,s=Ue.unblended,a=new Ge(n.LEQUAL,Ge.ReadWrite,[0,1]),l=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.b7.transparent,depth:1});for(const t of l){const e=i.getTerrainMesh(t.tileID),l=i.getTerrainData(t.tileID),h=o.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(o.zoom)};c.draw(r,n.TRIANGLES,a,We.disabled,s,$e.backCCW,u,l,h,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){const r=t.context,n=r.gl,o=t.transform,s=Ue.unblended,a=new Ge(n.LEQUAL,Ge.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),h=t.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.b7.transparent,depth:1}),i.coordsIndex=[];for(const t of c){const e=i.getTerrainMesh(t.tileID),c=i.getTerrainData(t.tileID);r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(o.zoom)},d=o.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(r,n.TRIANGLES,a,We.disabled,s,$e.backCCW,u,c,d,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),i.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,r,n,o){r.isHidden(this.transform.zoom)||("background"===r.type||"custom"===r.type||(n||[]).length)&&(this.id=r.id,e.c2(r)?function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:a}=s,l=We.disabled,c=t.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,r,n,o,s,a,l,c){const h=i.transform,u=i.style.map.terrain,d="map"===o,p="map"===s;for(const o of t){const t=n.getTile(o),s=t.getBucket(r);if(!s||!s.text||!s.text.segments.get().length)continue;const f=e.N(s.textSizeData,h.zoom),m=e.az(t,1,i.transform.zoom,i.transform.detailLevel),g=Z(d,i.transform,m),_="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(f){const i=Math.pow(2,h.zoom-t.tileID.overscaledZ),r=u?(t,e)=>u.getElevation(o,t,e):null;Qr(s,d,p,c,h,g,i,f,_,e.aA(h,t,a,l),o.toUnwrapped(),r)}}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&en(t,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"),l,c,a),0!==r.paint.get("text-opacity").constantOr(1)&&en(t,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"),l,c,a),i.map.showCollisionBoxes&&(Xr(t,i,r,n,!0),Xr(t,i,r,n,!1))}(t,i,r,n,this.style.placement.variableOffsets,o):e.c3(r)?function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:s}=o,a=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=t.context,d=u.gl,p=t.transform,f=t.getDepthModeForSublayer(0,Ge.ReadOnly),m=We.disabled,g=t.colorModeForRenderPass(),_=[],y=p.getCircleRadiusCorrection();for(let o=0;o<n.length;o++){const a=n[o],l=i.getTile(a),c=l.getBucket(r);if(!c)continue;const u=r.paint.get("circle-translate"),d=r.paint.get("circle-translate-anchor"),f=e.aA(p,l,u,d),m=c.programConfigurations.get(r.id),g=t.useProgram("circle",m),x=c.layoutVertexBuffer,v=c.indexBuffer,b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),w={programConfiguration:m,program:g,layoutVertexBuffer:x,indexBuffer:v,uniformValues:Fi(t,l,r,f,y),terrainData:b,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!s,applyTerrainMatrix:!0})};if(h){const t=c.segments.get();for(const i of t)_.push({segments:new e.aJ([i]),sortKey:i.sortKey,state:w})}else _.push({segments:c.segments,sortKey:0,state:w})}h&&_.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of _){const{programConfiguration:i,program:n,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=e.state;n.draw(u,d.TRIANGLES,f,m,g,$e.backCCW,a,l,c,r.id,o,s,e.segments,r.paint,t.transform.zoom,i)}}(t,i,r,n,o):e.c4(r)?function(t,i,r,n,o){if(0===r.paint.get("heatmap-opacity"))return;const s=t.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(t.style.map.terrain){for(const e of n){const n=i.getTile(e);i.hasRenderableParent(e)||("offscreen"===t.renderPass?nn(t,n,r,e,l):"translucent"===t.renderPass&&on(t,r,e,a,l))}s.viewport.set([0,0,t.width,t.height])}else"offscreen"===t.renderPass?function(t,i,r,n){const o=t.context,s=o.gl,a=t.transform,l=We.disabled,c=new Ue([s.ONE,s.ONE],e.b7.transparent,[!0,!0,!0,!0]);(function(t,i,r){const n=t.gl;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,i.width/4,i.height/4]);let o=r.heatmapFbos.get(e.bV);o?(n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),t.bindFramebuffer.set(o.framebuffer)):(o=sn(t,i.width/4,i.height/4),r.heatmapFbos.set(e.bV,o))})(o,t,r),o.clear({color:e.b7.transparent});for(let e=0;e<n.length;e++){const h=n[e];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=t.useProgram("heatmap",p),m=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),g=a.getCircleRadiusCorrection();f.draw(o,s.TRIANGLES,Ge.disabled,l,c,$e.backCCW,Ni(u,a.zoom,a.detailLevel,r.paint.get("heatmap-intensity"),g),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,a.zoom,p)}o.viewport.set([0,0,t.width,t.height])}(t,i,r,n):"translucent"===t.renderPass&&function(t,i){const r=t.context,n=r.gl;r.setColorMode(t.colorModeForRenderPass());const o=i.heatmapFbos.get(e.bV);o&&(r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1),an(r,i).bind(n.LINEAR,n.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(r,n.TRIANGLES,Ge.disabled,We.disabled,t.colorModeForRenderPass(),$e.disabled,Vi(t,i,0,1),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom))}(t,r)}(t,i,r,n,o):e.c5(r)?function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:s}=o,a=r.paint.get("line-opacity"),l=r.paint.get("line-width");if(0===a.constantOr(1)||0===l.constantOr(1))return;const c=t.getDepthModeForSublayer(0,Ge.ReadOnly),h=t.colorModeForRenderPass(),u=r.paint.get("line-dasharray"),d=r.paint.get("line-pattern"),p=d.constantOr(1),f=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),g=p?"linePattern":u?"lineSDF":f?"lineGradient":"line",_=t.context,y=_.gl,v=t.transform;let b=!0;for(const o of n){const a=i.getTile(o);if(p&&!a.patternsLoaded())continue;const l=a.getBucket(r);if(!l)continue;const w=l.programConfigurations.get(r.id),T=t.context.program.get(),S=t.useProgram(g,w),P=b||S.program!==T,M=t.style.map.terrain&&t.style.map.terrain.getTerrainData(o),I=d.constantOr(null);if(I&&a.imageAtlas){const t=a.imageAtlas,e=t.patternPositions[I.to.toString()],i=t.patternPositions[I.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const C=v.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),A=v.getPixelScale(),E=p?Wi(t,a,r,A,m):u?Hi(t,a,r,A,u,m):f?qi(t,a,r,A,l.lineClipsArray.length):Gi(t,a,r,A);if(p)_.activeTexture.set(y.TEXTURE0),a.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),w.updatePaintBuffers(m);else if(u&&(P||t.lineAtlas.dirty))_.activeTexture.set(y.TEXTURE0),t.lineAtlas.bind(_);else if(f){const n=l.gradients[r.id];let s=n.texture;if(r.gradientVersion!==n.version){let a=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;a=e.K(e.bW(l.maxLineLength/e.af*1024*n),256,_.maxTextureSize)}n.gradient=e.bX({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:a,image:n.gradient||void 0,clips:l.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new x(_,n.gradient,y.RGBA),n.version=r.gradientVersion,s=n.texture}_.activeTexture.set(y.TEXTURE0),s.bind(r.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}let k;if(s){const[e]=t.getStencilConfigForOverlapAndUpdateStencilID(n);k=e[o.overscaledZ]}else k=t.stencilModeForClipping(o);S.draw(_,y.TRIANGLES,c,k,h,$e.disabled,E,M,C,r.id,l.layoutVertexBuffer,l.indexBuffer,l.segments,r.paint,t.transform.zoom,w,l.layoutVertexBuffer2),b=!1}}(t,i,r,n,o):e.c6(r)?function(t,i,r,n,o){const s=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:l}=o,c=t.colorModeForRenderPass(),h=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===s.constantOr(e.b7.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.getDepthModeForSublayer(1,"opaque"===t.renderPass?Ge.ReadWrite:Ge.ReadOnly);cn(t,i,r,n,e,c,!1,l)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=t.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Ge.ReadOnly);cn(t,i,r,n,e,c,!0,l)}}(t,i,r,n,o):e.c7(r)?function(t,e,i,r,n){const o=i.paint.get("fill-extrusion-opacity");if(0===o)return;const{isRenderingToTexture:s}=n;if("translucent"===t.renderPass){const n=new Ge(t.context.gl.LEQUAL,Ge.ReadWrite,t.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))hn(t,e,i,r,n,We.disabled,Ue.disabled,s),hn(t,e,i,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),s);else{const o=t.colorModeForRenderPass();hn(t,e,i,r,n,We.disabled,o,s)}}}(t,i,r,n,o):e.c8(r)?function(t,e,i,r,n){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=n,s=t.context,a=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,Ge.ReadOnly),c=t.colorModeForRenderPass();if("offscreen"===t.renderPass)!function(t,e,i,r,n,o,s){const a=t.context,l=a.gl;for(const c of i){const i=e.getTile(c),h=i.dem;if(!h||!h.data)continue;if(!i.needsHillshadePrepare)continue;const u=h.dim,d=h.stride,p=h.getPixels();if(a.activeTexture.set(l.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(d),i.demTexture){const t=i.demTexture;t.update(p,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new x(a,p,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);a.activeTexture.set(l.TEXTURE0);let f=i.fbo;if(!f){const t=new x(a,{width:u,height:u,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),f=i.fbo=a.createFramebuffer(u,u,!0,!1),f.colorAttachment.set(t.texture)}a.bindFramebuffer.set(f.framebuffer),a.viewport.set([0,0,u,u]),t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,$e.disabled,Zi(i.tileID,h),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}}(t,e,r,i,l,We.disabled,c),s.viewport.set([0,0,t.width,t.height]);else if("translucent"===t.renderPass)if(a){const[n,s,a]=t.stencilConfigForOverlapTwoPass(r);un(t,e,i,a,n,l,c,!1,o),un(t,e,i,a,s,l,c,!0,o)}else{const[n,s]=t.getStencilConfigForOverlapAndUpdateStencilID(r);un(t,e,i,s,n,l,c,!1,o)}}(t,i,r,n,o):e.c9(r)?function(t,e,i,r,n){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const{isRenderingToTexture:o}=n,s=e.getSource(),a=t.style.projection.useSubdivision;if(s instanceof Pt)pn(t,e,i,r,null,!1,!1,s.tileCoords,s.flippedWindingOrder,o);else if(a){const[n,s,a]=t.stencilConfigForOverlapTwoPass(r);pn(t,e,i,a,n,!1,!0,dn,!1,o),pn(t,e,i,a,s,!0,!0,dn,!1,o)}else{const[n,s]=t.getStencilConfigForOverlapAndUpdateStencilID(r);pn(t,e,i,s,n,!1,!0,dn,!1,o)}}(t,i,r,n,o):e.ca(r)?function(t,e,i,r,n){const o=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const{isRenderingToTexture:a}=n,l=t.context,c=l.gl,h=t.style.projection,u=t.transform,d=u.tileSize,p=i.paint.get("background-pattern");if(t.isPatternMissing(p))return;const f=!p&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==f)return;const m=We.disabled,g=t.getDepthModeForSublayer(0,"opaque"===f?Ge.ReadWrite:Ge.ReadOnly),_=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),x=r||Ht(u,{tileSize:d,terrain:t.style.map.terrain});p&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context));const v=i.getCrossfadeParameters();for(const e of x){const r=u.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),n=p?rr(s,t,p,{tileID:e,tileSize:d},v):ir(s,o),f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e),x=h.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,c.TRIANGLES,g,m,_,$e.backCCW,n,f,r,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}(t,0,r,n,o):e.cb(r)&&function(t,e,i,r){const{isRenderingGlobe:n}=r,o=t.context,s=i.implementation,a=t.style.projection,l=t.transform,c=l.getProjectionDataForCustomLayer(n),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},u=s.renderingMode?s.renderingMode:"2d";if("offscreen"===t.renderPass){const e=s.prerender;e&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),e.call(s,o.gl,h),o.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(We.disabled);const e="3d"===u?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,Ge.ReadOnly);o.setDepthMode(e),s.render(o.gl,h),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}(t,0,r,o))}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}useProgram(t,e,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,n=this.style.projection,o=t+(e?e.cacheKey:"")+`/${i?Ce:n.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[o]||(this.cache[o]=new Ai(this.context,Te[t],e,or[t],this._showOverdrawInspector,r,i?Te.projectionMercator:n.shaderPreludeCode,i?Ie:n.shaderDefine)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new x(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}function In(t,e){let i,r=!1,n=null,o=null;const s=()=>{n=null,r&&(t.apply(o,i),n=setTimeout(s,e),r=!1)};return(...t)=>(r=!0,o=this,i=t,n||s(),n)}class Cn{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(!this._isValidHash(t))return!1;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},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let i=e;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${e}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=In(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),o=Math.round(e.lng*n)/n,s=Math.round(e.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new e.a8(+t[2],+t[1])}catch(t){return!1}const i=+t[0],r=+(t[3]||0),n=+(t[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&n>=this._map.getMinPitch()&&n<=this._map.getMaxPitch()}}const An={linearity:.3,easing:e.cc(0,0,.3,1)},En=e.e({deceleration:2500,maxSpeed:1400},An),kn=e.e({deceleration:20,maxSpeed:1400},An),zn=e.e({deceleration:1e3,maxSpeed:360},An),Ln=e.e({deceleration:1e3,maxSpeed:90},An),Dn=e.e({deceleration:1e3,maxSpeed:360},An);class Rn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=s.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new e.P(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,i.roll+=t.rollDelta||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=Bn(i.pan.mag(),r,e.e({},En,t||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);n.center=a.easingCenter,n.offset=a.easingOffset,Fn(n,o)}if(i.zoom){const t=Bn(i.zoom,r,kn);n.zoom=this._map.transform.zoom+t.amount,Fn(n,t)}if(i.bearing){const t=Bn(i.bearing,r,zn);n.bearing=this._map.transform.bearing+e.K(t.amount,-179,179),Fn(n,t)}if(i.pitch){const t=Bn(i.pitch,r,Ln);n.pitch=this._map.transform.pitch+t.amount,Fn(n,t)}if(i.roll){const t=Bn(i.roll,r,Dn);n.roll=this._map.transform.roll+e.K(t.amount,-179,179),Fn(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(),e.e(n,{noMoveStart:!0})}}function Fn(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function Bn(t,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=e.K(t*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class On extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,n={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);const o=a.mousePos(i.getCanvas(),r,i.getScale()),s=i.unproject(o);super(t,e.e({point:o,lngLat:s,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class jn extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){const n="touchend"===t?r.changedTouches:r.touches,o=a.touchPos(i.getCanvasContainer(),n,i.getScale()),s=o.map((t=>i.unproject(t))),l=o.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new e.P(0,0));super(t,{points:o,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}}class Nn extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Vn{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Nn(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new On(t.type,this._map,t))}mouseup(t){this._map.fire(new On(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new On(t.type,this._map,t))}dblclick(t){return this._firePreventable(new On(t.type,this._map,t))}mouseover(t){this._map.fire(new On(t.type,this._map,t))}mouseout(t){this._map.fire(new On(t.type,this._map,t))}touchstart(t){return this._firePreventable(new jn(t.type,this._map,t))}touchmove(t){this._map.fire(new jn(t.type,this._map,t))}touchend(t){this._map.fire(new jn(t.type,this._map,t))}touchcancel(t){this._map.fire(new jn(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Un{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new On(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new On("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new On(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zn{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this._map.terrain)}}class $n{constructor(t,e){this._map=t,this._tr=new Zn(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&&(a.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=a.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y);a.setTransform(this._box,`translate(${n}px,${s}px)`),this._box.style.width=o-n+"px",this._box.style.height=l-s+"px"}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const r=this._startPos,n=i;if(this.reset(),a.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.l("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.l(t,{originalEvent:i}))}}function Gn(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class qn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Gn(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Gn(i,e);for(const t in this.touches){const e=r[t];(!e||e.dist(this.touches[t])>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 Wn{constructor(t){this.singleTap=new qn(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 Hn{constructor(t){this._tr=new Zn(t),this._zoomIn=new Wn({numTouches:1,numTaps:2}),this._zoomOut=new Wn({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),o=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom-1,around:o.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}}class Xn{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.rollDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(e)?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const r=Array.isArray(e)?e[0]:e;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&a.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Kn={0:1,2:2};class Yn{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const e=a.mouseButton(t);this._eventButton=e}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){const i=Kn[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return a.mouseButton(t)===this._eventButton}}class Jn{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class Qn{constructor(t=new Yn({checkCorrectEvent:()=>!0}),e=new Jn){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):"undefined"!=typeof TouchEvent&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.startMove(t)),(t=>this.oneFingerTouchMoveStateManager.startMove(t)))}endMove(t){this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.endMove(t)),(t=>this.oneFingerTouchMoveStateManager.endMove(t)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidStartEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidMoveEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidEndEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t)))}}const to=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};class eo{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active){if(!this._shouldBePrevented(i.length))return t.preventDefault(),this._calculateTransform(t,e,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);const n=Gn(r,i),o=new e.P(0,0),s=new e.P(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,this._shouldBePrevented(a)||!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 io{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}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=ro(i,e,r),s=ro(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,o=ro(i,e,r),s=ro(i,e,n);o&&s||(this._active&&a.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 ro(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function no(t,e){return Math.log(t/e)/Math.LN2}class oo extends io{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(no(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:no(this._distance,i),pinchAround:e}}}function so(t,e){return 180*t.angleWith(e)/Math.PI}class ao extends io{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,i){const r=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:so(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=so(t,this._startVector);return Math.abs(i)<e}}function lo(t){return Math.abs(t.y)>Math.abs(t.x)}class co extends io{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,lo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}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 lo(t)&&lo(e)&&o}}const ho={panStep:100,bearingStep:15,pitchStep:10};class uo{constructor(t){this._tr=new Zn(t);const e=ho;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.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=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:po,zoom:e?Math.round(a.zoom)+e*(t.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.center},{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 po(t){return t*(2-t)}const fo=4.000244140625;class mo{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new Zn(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}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)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%fo==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_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 i=a.mousePos(this._map.getCanvas(),t,this._map.getScale()),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(e.a8.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>fo?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n="number"!=typeof this._targetZoom?t.scale:e.at(this._targetZoom);this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,e.aw(n*r))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?t.zoom:this._targetZoom,r=this._startZoom,n=this._easing;let o,a=!1;if("wheel"===this._type&&r&&n){const t=s.now()-this._lastWheelEventTime,l=Math.min((t+5)/200,1),c=n(l);o=e.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ce;if(this._prevEase){const t=this._prevEase,r=(s.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,a=Math.sqrt(.0729-o*o);i=e.cc(o,a,.25,1)}return this._prevEase={start:s.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class go{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 _o{constructor(t){this._tr=new Zn(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class yo{constructor(){this._tap=new Wn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const r=e[0],n=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(r)<30;n&&o?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else 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){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xo{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class vo{constructor(t,e,i,r){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class bo{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("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class wo{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=a.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(a.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new e.l("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const To=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;class So extends e.l{}function Po(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}class Mo{constructor(t,i){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,i)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},o={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||t.type]){if(e.cf(t,i||t.type)){const e=a.mousePos(this._map.getCanvas(),t,this._map.getScale());u=c[i||t.type](t,e)}else if(e.cg(t,i||t.type)){const e=this._getMapTouches(t.touches),r=a.touchPos(this._map.getCanvas(),e,this._map.getScale());u=c[i||t.type](t,r,e)}else e.ch(i||t.type)||(u=c[i||t.type](t));this.mergeHandlerResult(n,o,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(s[l]=c)}const l={};for(const t in this._previousActiveHandlers)s[t]||(l[t]=r);this._previousActiveHandlers=s,(Object.keys(l).length||Po(n))&&(this._changes.push([n,o,l]),this._triggerRenderFrame()),(Object.keys(s).length||Po(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=n;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Rn(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);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],[document,"mousemove",{capture:!0}],[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],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)a.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)a.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new Vn(i,t));const n=i.boxZoom=new $n(i,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();const o=i.cooperativeGestures=new wo(i,t.cooperativeGestures);this._add("cooperativeGestures",o),t.cooperativeGestures&&o.enable();const s=new Hn(i),l=new _o(i);i.doubleClickZoom=new go(l,s),this._add("tapZoom",s),this._add("clickZoom",l),t.interactive&&t.doubleClickZoom&&i.doubleClickZoom.enable();const c=new yo;this._add("tapDragZoom",c);const h=i.touchPitch=new co(i);this._add("touchPitch",h),t.interactive&&t.touchPitch&&i.touchPitch.enable(t.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:t,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:n=100,rotateDegreesPerPixelMoved:o=.8},s){const l=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)&&!t.ctrlKey});return new Xn({clickTolerance:i,move:(t,i)=>{const a=s();if(r&&Math.abs(a.y-t.y)>n)return{bearingDelta:e.cd(new e.P(t.x,i.y),i,a)};let l=(i.x-t.x)*o;return r&&i.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:l,enable:t,assignEvents:to})}(t,u),p=function({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5}){const r=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)});return new Xn({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:to})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){const n=new Yn({checkCorrectEvent:t=>2===a.mouseButton(t)&&t.ctrlKey});return new Xn({clickTolerance:e,move:(t,e)=>{const n=r();let o=(e.x-t.x)*i;return e.y<n.y&&(o=-o),{rollDelta:o}},moveStateManager:n,enable:t,assignEvents:to})}(t,u);i.dragRotate=new vo(t,d,p,f),this._add("mouseRotate",d,["mousePitch"]),this._add("mousePitch",p,["mouseRotate","mouseRoll"]),this._add("mouseRoll",f,["mousePitch"]),t.interactive&&t.dragRotate&&i.dragRotate.enable();const m=function({enable:t,clickTolerance:e}){const i=new Yn({checkCorrectEvent:t=>0===a.mouseButton(t)&&!t.ctrlKey});return new Xn({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:to})}(t),g=new eo(t,i);i.dragPan=new xo(r,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&i.dragPan.enable(t.dragPan);const _=new ao,y=new oo;i.touchZoomRotate=new bo(r,y,_,c),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",y,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&i.touchZoomRotate.enable(t.touchZoomRotate);const x=i.scrollZoom=new mo(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),t.interactive&&t.scrollZoom&&i.scrollZoom.enable(t.scrollZoom);const v=i.keyboard=new uo(i);this._add("keyboard",v),t.interactive&&t.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Un(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(To(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}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.e(t,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.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),n.rollDelta&&(t.rollDelta=(t.rollDelta||0)+n.rollDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(i,o),e.e(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,n=r._getTransformForUpdate(),o=r.terrain;if(!(Po(t)||o&&this._terrainMovement))return this._fireEvents(e,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=t;void 0!==d&&(u=d),u=u||r.transform.centerPoint,o&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const f=u.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(s?u.sub(s):u);o?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,n),this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(p,n,f):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,n,f))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,n),this._map.cameraHelper.handleMapControlsPan(p,n,f)),r._applyUpdatedTransform(n),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,i,r){const n=To(this._eventsInProgress),o=To(t),a={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(a[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in a)this._fireEvent(t,a[t]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=i[e]||r,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const h=To(this._eventsInProgress),u=(n||o)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(t)}if(r&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&s.prefersReducedMotion?(this._map.fire(new e.l("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:c})),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.l(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new So("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Io extends e.E{constructor(t,e,i){super(),this._renderFrameCallback=()=>{const t=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this.cameraHelper=e,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,e){t.apply(this.transform),this.transform=t,this.cameraHelper=e}getCenter(){return new e.a8(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,e){return this.jumpTo({elevation:t},e),this}getCenterClampedToGround(){return!1}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.e({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,r){return this.easeTo(e.e({zoom:t},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}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,i){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)).fire(new e.l("moveend",i))),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(t,i,r){return this.easeTo(e.e({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,roll:0,duration:1e3},t),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}getRoll(){return this.transform.roll}setRoll(t,e){return this.jumpTo({roll:t},e),this}cameraForBounds(t,e){t=xt.convert(t).adjustAntiMeridian();const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,r,n){const o={top:0,bottom:0,right:0,left:0};if("number"==typeof(n=e.e({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},n)).padding){const t=n.padding;n.padding={top:t,bottom:t,right:t,left:t}}const s=e.e(o,n.padding);n.padding=s;const a=this.transform,l=new xt(t,i);return this.cameraHelper.cameraForBoxAndBearing(n,s,l,r,a)}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,r,n,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(e.P.convert(t)),this.transform.screenPointToLocation(e.P.convert(i)),r,n),n,o)}_fitInternal(t,i,r){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(t,i){this.stop();const r=this._getTransformForUpdate();let n=!1,o=!1,s=!1;const a=r.zoom;this.cameraHelper.handleJumpToCenterZoom(r,t);const l=r.zoom!==a;return"elevation"in t&&r.elevation!==+t.elevation&&r.setElevation(+t.elevation),"bearing"in t&&r.bearing!==+t.bearing&&(n=!0,r.setBearing(+t.bearing)),"pitch"in t&&r.pitch!==+t.pitch&&(o=!0,r.setPitch(+t.pitch)),"roll"in t&&r.roll!==+t.roll&&(s=!0,r.setRoll(+t.roll)),null==t.padding||r.isPaddingEqual(t.padding)||r.setPadding(t.padding),this._applyUpdatedTransform(r),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)),l&&this.fire(new e.l("zoomstart",i)).fire(new e.l("zoom",i)).fire(new e.l("zoomend",i)),n&&this.fire(new e.l("rotatestart",i)).fire(new e.l("rotate",i)).fire(new e.l("rotateend",i)),o&&this.fire(new e.l("pitchstart",i)).fire(new e.l("pitch",i)).fire(new e.l("pitchend",i)),s&&this.fire(new e.l("rollstart",i)).fire(new e.l("roll",i)).fire(new e.l("rollend",i)),this.fire(new e.l("moveend",i))}calculateCameraOptionsFromTo(t,i,r,n=0){const o=e.ag.fromLngLat(t,i),s=e.ag.fromLngLat(r,n),a=s.x-o.x,l=s.y-o.y,c=s.z-o.z,h=Math.hypot(a,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(a,l),d=e.aw(this.transform.cameraToCenterDistance/h/this.transform.tileSize),p=180*Math.atan2(a,-l)/Math.PI;let f=180*Math.acos(u/h)/Math.PI;return f=c<0?90-f:90+f,{center:s.toLngLat(),elevation:n,zoom:d,pitch:f,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n){const o=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,r);return{center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:i,pitch:r,roll:n}}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.ce},t)).animate||!t.essential&&s.prefersReducedMotion)&&(t.duration=0);const r=this._getTransformForUpdate(),n=this.getBearing(),o=r.pitch,a=r.roll,l="bearing"in t?this._normalizeBearing(t.bearing,n):n,c="pitch"in t?+t.pitch:o,h="roll"in t?this._normalizeBearing(t.roll,a):a,u="padding"in t?t.padding:r.padding,d=e.P.convert(t.offset);let p,f;t.around&&(p=e.a8.convert(t.around),f=r.locationToScreenPoint(p));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:l,pitch:c,roll:h,padding:u,around:p,aroundPoint:f,offsetAsPoint:d,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||n!==l,this._pitching=this._pitching||c!==o,this._rolling=this._rolling||h!==a,this._padding=!r.isPaddingEqual(u),this._zooming=this._zooming||g.isZooming,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,m),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((e=>{g.easeFunc(e),this.terrain&&!t.freezeElevation&&this._updateElevation(e),this._applyUpdatedTransform(r),this._fireMoveEvents(i)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,i||r.moving||this.fire(new e.l("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.l("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.l("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.l("pitchstart",t)),this._rolling&&!r.rolling&&this.fire(new e.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.setElevation(e.B.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const e=t.getCameraLngLat(),i=t.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<r){const i=this.calculateCameraOptionsFromTo(e,r,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(t){const e=[];if(e.push((t=>this._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const i=t.clone();for(const t of e){const e=i.clone(),{center:r,zoom:n,roll:o,pitch:s,bearing:a,elevation:l}=t(e);r&&e.setCenter(r),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==o&&e.setRoll(o),void 0!==s&&e.setPitch(s),void 0!==a&&e.setBearing(a),i.apply(e)}this.transform.apply(i)}_fireMoveEvents(t){this.fire(new e.l("move",t)),this._zooming&&this.fire(new e.l("zoom",t)),this._rotating&&this.fire(new e.l("rotate",t)),this._pitching&&this.fire(new e.l("pitch",t)),this._rolling&&this.fire(new e.l("roll",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new e.l("zoomend",t)),n&&this.fire(new e.l("rotateend",t)),o&&this.fire(new e.l("pitchend",t)),s&&this.fire(new e.l("rollend",t)),this.fire(new e.l("moveend",t))}flyTo(t,i){if(!t.essential&&s.prefersReducedMotion){const r=e.a7(t,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.ce},t);const r=this._getTransformForUpdate(),n=r.bearing,o=r.pitch,a=r.roll,l=r.padding,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:o,u="roll"in t?this._normalizeBearing(t.roll,a):a,d="padding"in t?t.padding:r.padding,p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:p,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let _=t.curve;const y=Math.max(r.width,r.height),x=y/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(y/g.scaleOfMinZoom/v*2));const b=_*_;function w(t){const e=(x*x-y*y+(t?-1:1)*b*b*v*v)/(2*(t?x:y)*b*v);return Math.log(Math.sqrt(e*e+1)-e)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function S(t){return(Math.exp(t)+Math.exp(-t))/2}const P=w(!1);let M=function(t){return S(P)/S(P+_*t)},I=function(t){return y*((S(P)*(T(e=P+_*t)/S(e))-T(P))/b)/v;var e},C=(w(!0)-P)/_;if(Math.abs(v)<2e-6||!isFinite(C)){if(Math.abs(y-x)<1e-6)return this.easeTo(t,i);const e=x<y?-1:1;C=Math.abs(Math.log(x/y))/_,I=()=>0,M=t=>Math.exp(e*_*t)}return t.duration="duration"in t?+t.duration:1e3*C/("screenSpeed"in t?+t.screenSpeed/_:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=h!==o,this._rolling=u!==a,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((s=>{const m=s*C,_=1/M(m),y=I(m);this._rotating&&r.setBearing(e.B.number(n,c,s)),this._pitching&&r.setPitch(e.B.number(o,h,s)),this._rolling&&r.setRoll(e.B.number(a,u,s)),this._padding&&(r.interpolatePadding(l,d,s),f=r.centerPoint.add(p)),g.easeFunc(s,_,y,f),this.terrain&&!t.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;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)}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){t=e.aL(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.a8.convert(t),this.transform.tileZoom):null}}const Co={compact:!0,customAttribution:void 0};class Ao{constructor(t=Co){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show"),this._updateAttributions()):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show"),this._updateAttributions()},this._extendAttribution=t=>{t.preventDefault(),this._extended=!0,this._updateAttributions()},this._shrinkAttribution=t=>{t.preventDefault(),this._extended=!1,this._updateAttributions()},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._extendButton=a.create("a","maplibregl-attrib-others"),this._extendButton.setAttribute("href","#"),this._extendButton.addEventListener("click",this._extendAttribution),this._extendButton.innerHTML="| Show more",this._shrinkButton=a.create("a","maplibregl-attrib-others"),this._shrinkButton.setAttribute("href","#"),this._shrinkButton.addEventListener("click",this._shrinkAttribution),this._shrinkButton.innerHTML="| Show less",this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._extended=void 0,this._extendButton=void 0,this._shrinkButton=void 0,this._attribHTML=void 0,this._attribCount=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_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||r.usedForTerrain){const e=r.getSource();if("string"==typeof e.attribution){const i=e.attribution.split("|").map((t=>t.trim()));for(const e of i)t.indexOf(e)<0&&t.push(e)}}}const i='<a href="https://mapcreator.io" target="_blank">© Mapcreator</a>';t.indexOf(i)<0&&t.push(i),t=t.filter((t=>String(t).trim())),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}));for(const e of["OpenStreetMap","Mapcreator"]){const i=t.findIndex((t=>t.includes(e)));if(-1!==i&&0!==i){const e=t[i];t.splice(i,1),t.unshift(e)}}let r;r=t.length<=2||this._extended?t.join(" "):t.slice(0,2).join(" "),r===this._attribHTML&&t.length===this._attribCount||(this._attribHTML=r,this._attribCount=t.length,t.length?(this._innerContainer.innerHTML=a.sanitize(r),t.length>2&&(this._innerContainer.innerHTML+=" ",this._innerContainer.appendChild(this._extended?this._shrinkButton:this._extendButton)),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._map.fire("attributionchange"),this._editLink=null)}}class Eo{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=a.create("div","maplibregl-ctrl");const e=a.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ko{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){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var zo=e.aG([{name:"a_pos3d",type:"Int16",components:3}]);class Lo extends e.E{constructor(t){super(),this._lastTilesetChange=s.now(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];const r={};for(const n of Ht(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float64Array(16),e.bR(n.terrainRttPosMatrix32f,0,e.af,e.af,0,0,1),this._tiles[n.key]=new Dt(n,this.tileSize),this._lastTilesetChange=s.now());for(const t in this._tiles)r[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,e){return e?this._getTerrainCoordsForTileRanges(t,e):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID,o=t.clone(),s=e.b2();if(n.canonical.equals(t.canonical))e.bR(s,0,e.af,e.af,0,0,1);else if(n.canonical.isChildOf(t.canonical)){const i=n.canonical.z-t.canonical.z,r=n.canonical.x-(n.canonical.x>>i<<i),o=n.canonical.y-(n.canonical.y>>i<<i),a=e.af>>i;e.bR(s,0,a,a,0,0,1),e.a3(s,s,[-r*a,-o*a,0])}else{if(!t.canonical.isChildOf(n.canonical))continue;{const i=t.canonical.z-n.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),o=t.canonical.y-(t.canonical.y>>i<<i),a=e.af>>i;e.bR(s,0,e.af,e.af,0,0,1),e.a3(s,s,[r*a,o*a,0]),e.M(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[r]=o}return i}_getTerrainCoordsForTileRanges(t,i){const r={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=t.clone(),a=e.b2();if(o.canonical.z===t.canonical.z){const i=t.canonical.x-o.canonical.x,r=t.canonical.y-o.canonical.y;e.bR(a,0,e.af,e.af,0,0,1),e.a3(a,a,[i*e.af,r*e.af,0])}else if(o.canonical.z>t.canonical.z){const i=o.canonical.z-t.canonical.z,r=o.canonical.x-(o.canonical.x>>i<<i),n=o.canonical.y-(o.canonical.y>>i<<i),s=t.canonical.x-(o.canonical.x>>i),l=t.canonical.y-(o.canonical.y>>i),c=e.af>>i;e.bR(a,0,c,c,0,0,1),e.a3(a,a,[-r*c+s*e.af,-n*c+l*e.af,0])}else{const i=t.canonical.z-o.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),n=t.canonical.y-(t.canonical.y>>i<<i),s=(t.canonical.x>>i)-o.canonical.x,l=(t.canonical.y>>i)-o.canonical.y,c=e.af<<i;e.bR(a,0,c,c,0,0,1),e.a3(a,a,[r*e.af+s*c,n*e.af+l*c,0])}s.terrainRttPosMatrix32f=new Float32Array(a),r[n]=s}return r}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let n=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!n||!n.dem)&&e)for(;r>=i.minzoom&&(!n||!n.dem);)n=this.sourceCache.getTileByID(t.scaledTo(r--).key);return n}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){return e[t.canonical.z]&&t.canonical.x>=e[t.canonical.z].minTileX&&t.canonical.x<=e[t.canonical.z].maxTileX&&t.canonical.y>=e[t.canonical.z].minTileY&&t.canonical.y<=e[t.canonical.z].maxTileY}}class Do{constructor(t,e,i){this._meshCache={},this.painter=t,this.sourceCache=new Lo(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,r,n=e.af){var o;if(!(i>=0&&i<n&&r>=0&&r<n))return 0;const s=this.getTerrainData(t),a=null===(o=s.tile)||void 0===o?void 0:o.dem;if(!a)return 0;const l=e.ci([],[i/n*e.af,r/n*e.af],s.u_terrain_matrix),c=[l[0]*a.dim,l[1]*a.dim],h=Math.floor(c[0]),u=Math.floor(c[1]),d=c[0]-h,p=c[1]-u;return a.get(h,u)*(1-d)*(1-p)+a.get(h+1,u)*d*(1-p)+a.get(h,u+1)*(1-d)*p+a.get(h+1,u+1)*d*p}getElevationForLngLatZoom(t,i){if(!e.cj(i,t.wrap()))return 0;const{tileID:r,mercatorX:n,mercatorY:o}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(r,n%e.af,o%e.af,e.af)}getElevation(t,i,r,n=e.af){return this.getDEMElevation(t,i,r,n)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new x(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new x(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.a2([])}const i=this.sourceCache.getSourceTile(t,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const t=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new x(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const r=i&&i+i.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){const r=this.sourceCache.sourceCache._source.maxzoom;let n=t.canonical.z-i.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=r?n=t.canonical.z-r:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=t.canonical.x-(t.canonical.x>>n<<n),s=t.canonical.y-(t.canonical.y>>n<<n),a=e.ck(new Float64Array(16),[1/(e.af<<n),1/(e.af<<n),0]);e.a3(a,a,[o*e.af,s*e.af,0]),this._demMatrixCache[t.key]={matrix:a,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(t){const e=this.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new x(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new x(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,e+=4)i[e+0]=255&r,i[e+1]=255&t,i[e+2]=r>>8<<4|t>>8,i[e+3]=0;const r=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new x(t,r,t.gl.RGBA,{premultiply:!1});return n.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,n=r.gl,o=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),n.readPixels(o,a-s-1,1,1,n.RGBA,n.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,p=(1<<u.tileID.canonical.z)*d;return new e.ag((u.tileID.canonical.x*d+l)/p+u.tileID.wrap,(u.tileID.canonical.y*d+c)/p,this.getElevation(u.tileID,l,c,d))}depthAtPoint(t){const e=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){var i;const r=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,n=r&&0===t.canonical.y,o=r&&t.canonical.y===(1<<t.canonical.z)-1,s=`m_${n?"n":""}_${o?"s":""}`;if(this._meshCache[s])return this._meshCache[s];const a=this.painter.context,l=new e.cl,c=new e.aK,h=this.meshSize,u=e.af/h,d=h*h;for(let t=0;t<=h;t++)for(let e=0;e<=h;e++)l.emplaceBack(e*u,t*u,0);for(let t=0;t<d;t+=h+1)for(let e=0;e<h;e++)c.emplaceBack(e+t,h+e+t+1,h+e+t+2),c.emplaceBack(e+t,h+e+t+2,e+t+1);const p=l.length,f=p+(h+1),m=(h+1)*h,g=n?e.b9:0,_=n?0:1,y=o?e.ba:e.af,x=o?0:1;for(let t=0;t<=h;t++)l.emplaceBack(t*u,g,_);for(let t=0;t<=h;t++)l.emplaceBack(t*u,y,x);for(let t=0;t<h;t++)c.emplaceBack(m+t,f+t,f+t+1),c.emplaceBack(m+t,f+t+1,m+t+1),c.emplaceBack(0+t,p+t+1,p+t),c.emplaceBack(0+t,0+t+1,p+t+1);const v=l.length,b=v+2*(h+1);for(const t of[0,1])for(let i=0;i<=h;i++)for(const r of[0,1])l.emplaceBack(t*e.af,i*u,r);for(let t=0;t<2*h;t+=2)c.emplaceBack(v+t,v+t+1,v+t+3),c.emplaceBack(v+t,v+t+3,v+t+2),c.emplaceBack(b+t,b+t+3,b+t+1),c.emplaceBack(b+t,b+t+2,b+t+3);const w=new Pe(a.createVertexBuffer(l,zo.members),a.createIndexBuffer(c),e.aJ.simpleSegment(0,0,l.length,c.length));return this._meshCache[s]=w,w}getMeshFrameDelta(t){return 2*Math.PI*e.bu/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,e){var i;const{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(t,e);return null!==(i=this.getMinMaxElevation(r).minElevation)&&void 0!==i?i:0}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){const r=e.ag.fromLngLat(t.wrap()),n=(1<<i)*e.af,o=r.x*n,s=r.y*n,a=Math.floor(o/e.af),l=Math.floor(s/e.af);return{tileID:new e.ae(i,0,i,a,l),mercatorX:o,mercatorY:s}}}class Ro{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new x(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((e=>t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((t=>!t.inUse))}}const Fo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Bo{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Ro(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsAscending={};for(const e in t.sourceCaches){this._coordsAscending[e]={};const i=t.sourceCaches[e].getVisibleCoordinates(),r=t.sourceCaches[e].getSource(),n=r instanceof Pt?r.terrainTileRanges:null;for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t,n);for(const t in i)this._coordsAscending[e][t]||(this._coordsAscending[e][t]=[]),this._coordsAscending[e][t].push(i[t])}}this._coordsAscendingStr={};for(const e of t._order){const i=t._layers[e],r=i.source;if(Fo[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const t in this._coordsAscending[r])this._coordsAscendingStr[r][t]=this._coordsAscending[r][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsAscendingStr){const i=this._coordsAscendingStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t,i){if(t.isHidden(this.painter.transform.zoom))return!1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),n=t.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Fo[n]&&(this._prevType&&Fo[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!s))return!0;if(Fo[this._prevType]||Fo[n]&&s){this._prevType=n;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const n of this._renderableTiles){if(this.pool.isFull()&&(Sn(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(n),n.rtt[t]){const e=this.pool.getObjectForId(n.rtt[t].id);if(e.stamp===n.rtt[t].stamp){this.pool.useObject(e);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),n.rtt[t]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:e.b7.transparent,stencil:0}),o.currentStencilSource=void 0;for(let t=0;t<i.length;t++){const e=o.style._layers[i[t]],a=e.source?this._coordsAscending[e.source][n.tileID.key]:[n.tileID];o.context.viewport.set([0,0,s.fbo.width,s.fbo.height]),o._renderTileClippingMasks(e,a,!0),o.renderLayer(o,o.style.sourceCaches[e.source],e,a,r),e.source&&(n.rttCoords[e.source]=this._coordsAscendingStr[e.source][n.tileID.key])}}return Sn(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),Fo[n]}return!1}}const Oo={"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":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},jo=i,No={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Co,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],scale:1,cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},Vo={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Uo{constructor(t,i,r=!1){this.mousedown=t=>{this.startMove(t,a.mousePos(this.element,t,this.map.getScale())),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,a.mousePos(this.element,t,this.map.getScale()))},this.mouseup=t=>{this._rotatePitchHanlder.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,t.targetTouches,this.map.getScale())[0],this.startMove(t,this._startPos),a.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,t.targetTouches,this.map.getScale())[0],this.move(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const n=new Qn;this._rotatePitchHanlder=new Xn({clickTolerance:3,move:(t,n)=>{const o=i.getBoundingClientRect(),s=new e.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:e.cd(new e.P(t.x,n.y),n,s),pitchDelta:r?-.5*(n.y-t.y):void 0}},moveStateManager:n,enable:!0,assignEvents:()=>{}}),this.map=t,a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchcancel",this.reset)}startMove(t,e){this._rotatePitchHanlder.dragStart(t,e),a.disableDrag()}move(t,e){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHanlder.dragMove(t,e)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const t=this.element;a.removeEventListener(t,"mousedown",this.mousedown),a.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend),a.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend)}}let Zo;function $o(t,i,r,n=!1){if(n||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==t?void 0:t.wrap();const o=new e.a8(t.lng,t.lat);if(t=new e.a8(t.lng,t.lat),i){const n=new e.a8(t.lng-360,t.lat),o=new e.a8(t.lng+360,t.lat),s=r.locationToScreenPoint(t).distSqr(i);r.locationToScreenPoint(n).distSqr(i)<s?t=n:r.locationToScreenPoint(o).distSqr(i)<s&&(t=o)}for(;Math.abs(t.lng-r.center.lng)>180;){const e=r.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:o}const Go={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 qo(t,e,i){const r=t.classList;for(const t in Go)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}class Wo extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._lngLat=$o(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),a.setTransform(this._element,`${Go[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.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 e.l("dragstart"))),this.fire(new e.l("drag")))},this._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 e.l("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),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))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=a.create("div");const i=a.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 o=a.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=a.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=a.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=a.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=a.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=a.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=a.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=a.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=a.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=a.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=a.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=a.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),qo(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",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),delete this._map),a.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.a8.convert(t),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.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-13.5,-1*(e-i)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const t=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==t&&(this._element.style.opacity=t))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const n=this._map,o=n.terrain.depthAtPoint(this._pos),s=n.terrain.getElevationForLngLatZoom(this._lngLat,n.transform.tileZoom);if(n.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return void(this._element.style.opacity=this._opacity);const a=-this._offset.y/n.transform.pixelsPerMeter,l=Math.sin(n.getPitch()*Math.PI/180)*a,c=n.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),h=n.transform.lngLatToCameraDepth(this._lngLat,s+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}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}setOpacity(t,e){return(void 0===this._opacity||void 0===t&&void 0===e)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Ho={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Xo=0,Ko=!1;const Yo={maxWidth:100,unit:"metric"};function Jo(t,e,i){const r=i&&i.maxWidth||100,n=t._container.clientHeight/2,o=t._container.clientWidth/2,s=t.unproject([o-r/2,n]),a=t.unproject([o+r/2,n]),l=Math.round(t.project(a).x-t.project(s).x),c=Math.min(r,l,t._container.clientWidth),h=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Qo(e,c,i/5280,t._getUIString("ScaleControl.Miles")):Qo(e,c,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?Qo(e,c,h/1852,t._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Qo(e,c,h/1e3,t._getUIString("ScaleControl.Kilometers")):Qo(e,c,h,t._getUIString("ScaleControl.Meters"))}function Qo(t,e,i,r){const n=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);t.style.width=e*(n/i)+"px",t.innerHTML=`${n} ${r}`}const ts={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},es=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function is(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);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:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return is(new e.P(0,0))}const rs=i;t.AJAXError=e.cq,t.Event=e.l,t.Evented=e.E,t.LngLat=e.a8,t.MercatorCoordinate=e.ag,t.Point=e.P,t.addProtocol=e.cr,t.config=e.a,t.createExpression=e.ct,t.removeProtocol=e.cs,t.AttributionControl=Ao,t.BoxZoomHandler=$n,t.CanvasSource=It,t.CooperativeGesturesHandler=wo,t.DoubleClickZoomHandler=go,t.DragPanHandler=xo,t.DragRotateHandler=vo,t.EdgeInsets=Ee,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){a.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=a.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);a.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_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}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},t.GeoJSONSource=St,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const i=new e.a8(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.e({bearing:n},this.options.fitBoundsOptions),s=xt.fromLngLat(i,r);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const i=new e.a8(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-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===t.code&&Ko)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=a.create("button","maplibregl-ctrl-geolocate",this._container),a.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,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=a.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Wo({element:this._dotElement}),this._circleElement=a.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Wo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.l("trackuserlocationend")),this.fire(new e.l("userlocationlostfocus")))}))}},this.options=e.e({},Ho,t)}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==Zo&&!t)return Zo;if(void 0===window.navigator.permissions)return Zo=!!window.navigator.geolocation,Zo;try{const t=yield window.navigator.permissions.query({name:"geolocation"});Zo="denied"!==t.state}catch(t){Zo=!!window.navigator.geolocation}return Zo}))}().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),a.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Xo=0,Ko=!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("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),r=e.distanceTo(i),n=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Xo--,Ko=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.l("trackuserlocationstart")),this.fire(new e.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Xo++,Xo>1?(t={maximumAge:6e5,timeout:0},Ko=!0):(t=this.options.positionOptions,Ko=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},t.GlobeControl=class{constructor(){this._toggleProjection=()=>{var t;const e=null===(t=this._map.getProjection())||void 0===t?void 0:t.type;this._map.setProjection("mercator"!==e&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var t;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(t=this._map.getProjection())||void 0===t?void 0:t.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=a.create("button","maplibregl-ctrl-globe",this._container),a.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},t.Hash=Cn,t.ImageSource=Pt,t.KeyboardHandler=uo,t.LngLatBounds=xt,t.LogoControl=Eo,t.Map=class extends Io{constructor(t){var i,r;e.cm.mark(e.cn.create);const n=Object.assign(Object.assign(Object.assign({},No),t),{canvasContextAttributes:Object.assign(Object.assign({},No.canvasContextAttributes),t.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Be,s=new Ve;if(void 0!==n.minZoom&&o.setMinZoom(n.minZoom),void 0!==n.maxZoom&&o.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&o.setMinPitch(n.minPitch),void 0!==n.maxPitch&&o.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&o.setRenderWorldCopies(n.renderWorldCopies),super(o,s,{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ko,this._controls=[],this._mapId=e.al(),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.l("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.l("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},Oo),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this._dynamicScale=n.scale,this._imageQueueHandle=f.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(n.transformRequest),"string"==typeof n.container){if(this._container=document.getElementById(n.container),!this._container)throw new Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=In((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Mo(this,n),this._hash=n.hash&&new Cn("string"==typeof n.hash&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,e.e({},n.fitBoundsOptions,{duration:0}))));const a="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,a),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style?this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}):null===n.style&&this._lazyInitEmptyStyle(),n.attributionControl&&this.addControl(new Ao("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Eo,n.logoPosition),this.on("style.load",(()=>{if(a||this._resizeTransform(),this.transform.unmodified){const t=e.a7(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.l(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.l(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.l("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(t,i=!0){const[r,n]=this._containerDimensions(),o=this.getScale(),s=this._getClampedPixelRatio(r,n);if(this._resizeCanvas(r,n,s),this.painter.resize(r,n,s,o),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(r,n);this._resizeCanvas(r,n,e),this.painter.resize(r,n,e,o)}this._resizeTransform(i);const a=!this._moving;return a&&(this.stop(),this.fire(new e.l("movestart",t)).fire(new e.l("move",t))),this.fire(new e.l("resize",t)),a&&this.fire(new e.l("moveend",t)),this}_resizeTransform(t=!0){var e;const[i,r]=this._containerDimensions(),n=this.getScale(),o=i/n,s=r/n;this.transform.resize(o,s,t),null===(e=this._requestedCameraState)||void 0===e||e.resize(o,s,t)}_getClampedPixelRatio(t,e){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),o=t*n,s=e*n;return Math.min(o>i?i/o:1,s>r?r/s:1)*n}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getScale(){return this._dynamicScale}setScale(t){this._dynamicScale=t,this.resize()}getDetailLevel(){return this.transform.detailLevel}setDetailLevel(t){this.transform.setDetailLevel(t),this._update()}getRasterAlignment(){return this.transform.rasterAlignment}setRasterAlignment(t){this.transform.setRasterAlignment(t),this._update()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(xt.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.setMinZoom(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.setMaxZoom(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.setMinPitch(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?60:t)>180)throw new Error("maxPitch must be less than or equal to 180");if(t>=this.transform.minPitch)return this.transform.setMaxPitch(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.setRenderWorldCopies(t),this._update()}project(t){return this.transform.locationToScreenPoint(e.a8.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this.terrain)}projectWithScaleCorrection(t){return this.project(t).mult(this.getScale())}unprojectWithScaleCorrection(t){return this.unproject(e.P.convert(t).div(this.getScale()))}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t))),s=0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new On(t,this,n.originalEvent,{features:s}))):r=!1};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t)));(0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new On(t,this,n.originalEvent)))},o=e=>{r&&(r=!1,i.call(this,new On(t,this,e.originalEvent)))};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),n=0!==r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:e,listener:i,delegates:{[t]:r}}}}_saveDelegatedListener(t,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(e)}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners||!this._delegatedListeners[t])return;const r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){const n=r[t];if(n.listener===i&&n.layers.length===e.length&&n.layers.every((t=>e.includes(t)))){for(const t in n.delegates)this.off(t,n.delegates[t]);return void r.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);this._saveDelegatedListener(t,n);for(const t in n.delegates)this.on(t,n.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,r,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);for(const e in n.delegates){const o=n.delegates[e];n.delegates[e]=(...e)=>{this._removeDelegatedListener(t,r,i),o(...e)}}this._saveDelegatedListener(t,n);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,i){if(!this.style)return[];let r;const n=t instanceof e.P||Array.isArray(t),o=n?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(n?{}:t)||{},o instanceof e.P||"number"==typeof o[0])r=[e.P.convert(o)];else{const t=e.P.convert(o[0]),i=e.P.convert(o[1]);r=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){var i,r;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Ti(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,n):this.style.loadJSON(t,e,n),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ti(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){const r=this._requestManager.transformRequest(t,"Style");e.j(r,new AbortController).then((t=>{this._updateDiff(t.data,i)})).catch((t=>{t&&this.fire(new e.k(t))}))}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(r){e.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.k(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.sourceCaches[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Do(this.painter,i,t),this.painter.renderToTexture=new Bo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=e=>{var i;"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=e.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new e.l("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}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}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}setSourceTileLodParams(t,e,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=Gt(Math.max(1,t),Math.max(1,e))}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=Gt(Math.max(1,t),Math.max(1,e));return this._update(!0),this}addImage(t,i,r={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.k(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:r,height:s,data:d}=i,p=i;return this.style.addImage(t,{data:new e.R({width:r,height:s},new Uint8Array(d)),pixelRatio:n,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,t),this}}{const{width:r,height:d,data:p}=s.getImageData(i);this.style.addImage(t,{data:new e.R({width:r,height:d},p),pixelRatio:n,stretchX:a,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:o,version:0})}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return this.fire(new e.k(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 HTMLImageElement||e.b(i)?s.getImageData(i):i,{width:o,height:a,data:l}=n;if(void 0===o||void 0===a)return this.fire(new e.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||a!==r.data.height)return this.fire(new e.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||e.b(i));return r.data.replace(l,c),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.k(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}addImages(t){this.style.addImages(t)}loadImage(t){return f.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}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)}setLayersOrder(t){return this._lazyInitEmptyStyle(),this.style.setLayersOrder(t),this._update(!0)}getLayersOrder(){return this.style.getLayersOrder()}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)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}loadSprite(t){return y(t,this._requestManager,this.getPixelRatio()*this.getScale(),new AbortController).then((t=>{var e;return null!==(e=t.default)&&void 0!==e?e:{}}))}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,e),this._update(!0)}getSky(){return this.style.getSky()}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]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=a.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=a.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=a.create("div","maplibregl-control-container",t),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{o[t]=a.create("div",`maplibregl-ctrl-${t} `,n)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,t):this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t),!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Mn(i,this.transform),l.testSupport(i)}migrateProjection(t,i){super.migrateProjection(t,i),this.painter.transform=t,this.fire(new e.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(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)}_render(t){var i,r,n,o,a;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=s.now();this.style.zoomHistory.update(t,i);const r=new e.C(t,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(h=!0,this._crossFadingFactor=n),this.style.update(r)}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(n=this.style.projection)||void 0===n||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(a=this.style.projection)||void 0===a?void 0:a.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new e.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.cm.mark(e.cn.load),this.fire(new e.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,e.cm.mark(e.cn.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),f.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),a.remove(this._canvasContainer),a.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),e.cm.clearMetrics(),this._removed=!0,this.fire(new e.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(t=>{e.cm.frame(t),this._frameRequest=null;try{this._render(t)}catch(t){if(!e.co(t)&&!function(t){return t.message===Gr}(t))throw t}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=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()}get version(){return jo}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}setLabelFreeAreas(t){this.style.setLabelFreeAreas(t)&&this.triggerRepaint()}getGlyphMap(t,e){const i=this.style.glyphManager,r=new Set;for(let e=0;e<t.length;e++)r.add(t.charCodeAt(e));return i.getGlyphMap(e,Array.from(r))}getLineBreaks(t,i,r,n,o,s=this.getGlyphMap(t,i)){return e.cp(t,i,r,n,o,s).map((({text:t})=>t))}},t.MapMouseEvent=On,t.MapTouchEvent=jn,t.MapWheelEvent=Nn,t.Marker=Wo,t.NavigationControl=class{constructor(t){this._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())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},Vo,t),this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),a.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),a.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=a.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}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.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Uo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){a.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.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=a.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0)},this.remove=()=>(this._content&&a.remove(this._content),this._container&&(a.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),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=a.create("div","maplibregl-popup",this._map.getContainer()),this._tip=a.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=$o(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const e=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=is(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("-")}let n=e.add(r[i]);this.options.subpixelPositioning||(n=n.round()),a.setTransform(this._container,`${Go[i]} translate(${n.x}px,${n.y}px)`),qo(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(ts),t)}addTo(t){return this._map&&this.remove(),this._map=t,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("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.a8.convert(t),this._pos=null,this._flatPos=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("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=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("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.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=a.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=a.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(es);t&&t.focus()}},t.RasterDEMTileSource=Tt,t.RasterTileSource=wt,t.ScaleControl=class{constructor(t){this._onMove=()=>{Jo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Jo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Yo),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){a.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=mo,t.Style=Ti,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=a.create("button","maplibregl-ctrl-terrain",this._container),a.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){a.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=co,t.TwoFingersTouchRotateHandler=ao,t.TwoFingersTouchZoomHandler=oo,t.TwoFingersTouchZoomRotateHandler=bo,t.VectorTileSource=bt,t.VideoSource=Mt,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,(function*(){if(At(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{Ct[t]=e})(t,i)})),t.clearPrewarmedResources=function(){const t=R;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(z),R=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()"))},t.createTileMesh=Je,t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return Lt().getRTLTextPluginStatus()},t.getVersion=function(){return rs},t.getWorkerCount=function(){return L.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return j().broadcast("IS",t)},t.prewarm=function(){B().acquire(z)},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setRTLTextPlugin=function(t,e){return Lt().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){L.workerCount=t},t.setWorkerUrl=function(t){e.a.WORKER_URL=t}})),t}()},2554:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},2768:function(t){t.exports=JSON.parse('{"party":"Partei","votes":"Stimmen","reporting":"Wahlbeteiligung {percentage}%","ev":"WL","electoralVotes":"Wahlleute","unknown":"Unbekannt","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},2903:function(t){t.exports=JSON.parse('{"goBack":"Ga terug","notice":"Gebruik twee vingers om de kaart te bewegen"}')},2968:function(t){t.exports=JSON.parse('{"showMore":"Voir plus","showLess":"Voir moins","tapFor":"Résutats de {alternative}","allResults":"Tous les résultats","candidateList":"Liste des candidats"}')},3134:function(t){t.exports=JSON.parse('{"party":"Parti","votes":"Votes","reporting":"{percentage}% des votes dépouillés","ev":"C.E.","electoralVotes":"Collège électoral","unknown":"Inconnu","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},3655:function(t){t.exports=JSON.parse('{"loadingSettings":"Chargement des paramètres","errorLoadingSettings":"Erreur lors du chargement des paramètres","loadCandidates":"Chargement des données du candidat","errorLoadingCandidates":"Erreur de chargement des candidats","loadingResults":"Chargement des résultats","errorLoadingResults":"Erreur de chargement des résultats","updatedOn":"{date} à {time} ","checkingForData":"mise à jour dans : {time}"}')},3743:function(t){t.exports=JSON.parse('{"goBack":"Gå tilbage","notice":"Brug to fingre til at navigere i kortet"}')},3988:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},4309:function(t){t.exports=JSON.parse('{"youtube":"Das Video ist in der veröffentlichten Karte sichtbar.","videoAlert":"Das Video ist in der veröffentlichten Karte sichtbar."}')},4652:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},4745:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')},4883:function(t){t.exports=JSON.parse('{"goBack":"Go back","notice":"Use two fingers to move the map"}')},5055:function(t){t.exports=JSON.parse('{"loadingSettings":"Loading settings","errorLoadingSettings":"Error loading settings","loadCandidates":"Loading candidate data","errorLoadingCandidates":"Error loading candidates","loadingResults":"Loading results","errorLoadingResults":"Error loading results","updatedOn":"Updated on { interpolate.date } at { interpolate.time }","checkingForData":"Checking for new data in: { interpolate }"}')},5158:function(t){t.exports=JSON.parse('{"party":"Party","votes":"Votes","reporting":"{ interpolate }% Reporting","ev":"E.V.","electoralVotes":"Electoral Votes","unknown":"Unknown","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},5485:function(t){t.exports=JSON.parse('{"loadingSettings":"Caricamento impostazioni","errorLoadingSettings":"Errore caricamento impostazioni","loadCandidates":"Caricamento dati candidato","errorLoadingCandidates":"Errore caricamento dati candidato","loadingResults":"Caricamento risultati","errorLoadingResults":"Errore caricamento risultati","updatedOn":"Aggiornato il {date} alle {time}","checkingForData":"Controllo nuovi dati in: {time}"}')},5508:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},5513:function(t){t.exports=JSON.parse('{"goBack":"Zurück","notice":"Verwenden Sie zwei Finger um die Karte zu bewegen"}')},5794:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},6028:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},6140:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},6160:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},6246:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},6325:function(){!function(){var t=function(t){return t.map((function(t){return{type:t.type,values:Array.prototype.slice.call(t.values)}}))},e=function(t){var e=[],r=null,n=null,o=null,s=null,a=null,l=null,c=null;return t.forEach((function(t){if("M"===t.type){var h=t.values[0],u=t.values[1];e.push({type:"M",values:[h,u]}),l=h,c=u,s=h,a=u}else if("C"===t.type){var d=t.values[0],p=t.values[1],f=t.values[2],m=t.values[3];h=t.values[4],u=t.values[5];e.push({type:"C",values:[d,p,f,m,h,u]}),n=f,o=m,s=h,a=u}else if("L"===t.type){h=t.values[0],u=t.values[1];e.push({type:"L",values:[h,u]}),s=h,a=u}else if("H"===t.type){h=t.values[0];e.push({type:"L",values:[h,a]}),s=h}else if("V"===t.type){u=t.values[0];e.push({type:"L",values:[s,u]}),a=u}else if("S"===t.type){f=t.values[0],m=t.values[1],h=t.values[2],u=t.values[3];"C"===r||"S"===r?(g=s+(s-n),_=a+(a-o)):(g=s,_=a),e.push({type:"C",values:[g,_,f,m,h,u]}),n=f,o=m,s=h,a=u}else if("T"===t.type){h=t.values[0],u=t.values[1];"Q"===r||"T"===r?(d=s+(s-n),p=a+(a-o)):(d=s,p=a);var g=s+2*(d-s)/3,_=a+2*(p-a)/3,y=h+2*(d-h)/3,x=u+2*(p-u)/3;e.push({type:"C",values:[g,_,y,x,h,u]}),n=d,o=p,s=h,a=u}else if("Q"===t.type){d=t.values[0],p=t.values[1],h=t.values[2],u=t.values[3],g=s+2*(d-s)/3,_=a+2*(p-a)/3,y=h+2*(d-h)/3,x=u+2*(p-u)/3;e.push({type:"C",values:[g,_,y,x,h,u]}),n=d,o=p,s=h,a=u}else if("A"===t.type){var v=Math.abs(t.values[0]),b=Math.abs(t.values[1]),w=t.values[2],T=t.values[3],S=t.values[4];h=t.values[5],u=t.values[6];if(0===v||0===b)e.push({type:"C",values:[s,a,h,u,h,u]}),s=h,a=u;else if(s!==h||a!==u)i(s,a,h,u,v,b,w,T,S).forEach((function(t){e.push({type:"C",values:t})})),s=h,a=u}else"Z"===t.type&&(e.push(t),s=l,a=c);r=t.type})),e},i=function(t,e,r,n,o,s,a,l,c,h){var u,d,p,f,m,g=function(t,e,i){return{x:t*Math.cos(i)-e*Math.sin(i),y:t*Math.sin(i)+e*Math.cos(i)}},_=(u=a,Math.PI*u/180),y=[];if(h)d=h[0],p=h[1],f=h[2],m=h[3];else{var x=g(t,e,-_);t=x.x,e=x.y;var v=g(r,n,-_),b=(t-(r=v.x))/2,w=(e-(n=v.y))/2,T=b*b/(o*o)+w*w/(s*s);T>1&&(o*=T=Math.sqrt(T),s*=T);var S=o*o,P=s*s,M=S*P-S*w*w-P*b*b,I=S*w*w+P*b*b,C=(l===c?-1:1)*Math.sqrt(Math.abs(M/I));f=C*o*w/s+(t+r)/2,m=C*-s*b/o+(e+n)/2,d=Math.asin(parseFloat(((e-m)/s).toFixed(9))),p=Math.asin(parseFloat(((n-m)/s).toFixed(9))),t<f&&(d=Math.PI-d),r<f&&(p=Math.PI-p),d<0&&(d=2*Math.PI+d),p<0&&(p=2*Math.PI+p),c&&d>p&&(d-=2*Math.PI),!c&&p>d&&(p-=2*Math.PI)}var A=p-d;if(Math.abs(A)>120*Math.PI/180){var E=p,k=r,z=n;p=c&&p>d?d+120*Math.PI/180*1:d+120*Math.PI/180*-1,r=f+o*Math.cos(p),n=m+s*Math.sin(p),y=i(r,n,k,z,o,s,a,0,c,[p,E,f,m])}A=p-d;var L=Math.cos(d),D=Math.sin(d),R=Math.cos(p),F=Math.sin(p),B=Math.tan(A/4),O=4/3*o*B,j=4/3*s*B,N=[t,e],V=[t+O*D,e-j*L],U=[r+O*F,n-j*R],Z=[r,n];if(V[0]=2*N[0]-V[0],V[1]=2*N[1]-V[1],h)return[V,U,Z].concat(y);y=[V,U,Z].concat(y);for(var $=[],G=0;G<y.length;G+=3){o=g(y[G][0],y[G][1],_),s=g(y[G+1][0],y[G+1][1],_);var q=g(y[G+2][0],y[G+2][1],_);$.push([o.x,o.y,s.x,s.y,q.x,q.y])}return $};let r=void 0!==SVGPathElement.prototype.getPathData&&void 0!==SVGPathElement.prototype.setPathData;if(r)try{document.createElementNS("http://www.w3.org/2000/svg","path").setPathData([{type:"M",values:[0,0]}])}catch(t){r=!1}if(!1===r){var n={Z:"Z",M:"M",L:"L",C:"C",Q:"Q",A:"A",H:"H",V:"V",S:"S",T:"T",z:"Z",m:"m",l:"l",c:"c",q:"q",a:"a",h:"h",v:"v",s:"s",t:"t"},o=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._prevCommand=null,this._skipOptionalSpaces()},s=-1!==window.navigator.userAgent.indexOf("MSIE ");o.prototype={parseSegment:function(){var t=this._string[this._currentIndex],e=n[t]?n[t]:null;if(null===e){if(null===this._prevCommand)return null;if(null===(e=("+"===t||"-"===t||"."===t||t>="0"&&t<="9")&&"Z"!==this._prevCommand?"M"===this._prevCommand?"L":"m"===this._prevCommand?"l":this._prevCommand:null))return null}else this._currentIndex+=1;this._prevCommand=e;var i=null,r=e.toUpperCase();return"H"===r||"V"===r?i=[this._parseNumber()]:"M"===r||"L"===r||"T"===r?i=[this._parseNumber(),this._parseNumber()]:"S"===r||"Q"===r?i=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:"C"===r?i=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:"A"===r?i=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseArcFlag(),this._parseArcFlag(),this._parseNumber(),this._parseNumber()]:"Z"===r&&(this._skipOptionalSpaces(),i=[]),null===i||i.indexOf(null)>=0?null:{type:e,values:i}},hasMoreData:function(){return this._currentIndex<this._endIndex},peekSegmentType:function(){var t=this._string[this._currentIndex];return n[t]?n[t]:null},initialCommandIsMoveTo:function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return"M"===t||"m"===t},_isCurrentSpace:function(){var t=this._string[this._currentIndex];return t<=" "&&(" "===t||"\n"===t||"\t"===t||"\r"===t||"\f"===t)},_skipOptionalSpaces:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex+=1;return this._currentIndex<this._endIndex},_skipOptionalSpacesOrDelimiter:function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!==this._string[this._currentIndex])&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","===this._string[this._currentIndex]&&(this._currentIndex+=1,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},_parseNumber:function(){var t=0,e=0,i=1,r=0,n=1,o=1,s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"===this._string[this._currentIndex]?this._currentIndex+=1:this._currentIndex<this._endIndex&&"-"===this._string[this._currentIndex]&&(this._currentIndex+=1,n=-1),this._currentIndex===this._endIndex||(this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")&&"."!==this._string[this._currentIndex])return null;for(var a=this._currentIndex;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)this._currentIndex+=1;if(this._currentIndex!==a)for(var l=this._currentIndex-1,c=1;l>=a;)e+=c*(this._string[l]-"0"),l-=1,c*=10;if(this._currentIndex<this._endIndex&&"."===this._string[this._currentIndex]){if(this._currentIndex+=1,this._currentIndex>=this._endIndex||this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)i*=10,r+=(this._string.charAt(this._currentIndex)-"0")/i,this._currentIndex+=1}if(this._currentIndex!==s&&this._currentIndex+1<this._endIndex&&("e"===this._string[this._currentIndex]||"E"===this._string[this._currentIndex])&&"x"!==this._string[this._currentIndex+1]&&"m"!==this._string[this._currentIndex+1]){if(this._currentIndex+=1,"+"===this._string[this._currentIndex]?this._currentIndex+=1:"-"===this._string[this._currentIndex]&&(this._currentIndex+=1,o=-1),this._currentIndex>=this._endIndex||this._string[this._currentIndex]<"0"||this._string[this._currentIndex]>"9")return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>="0"&&this._string[this._currentIndex]<="9";)t*=10,t+=this._string[this._currentIndex]-"0",this._currentIndex+=1}var h=e+r;return h*=n,t&&(h*=Math.pow(10,o*t)),s===this._currentIndex?null:(this._skipOptionalSpacesOrDelimiter(),h)},_parseArcFlag:function(){if(this._currentIndex>=this._endIndex)return null;var t=null,e=this._string[this._currentIndex];if(this._currentIndex+=1,"0"===e)t=0;else{if("1"!==e)return null;t=1}return this._skipOptionalSpacesOrDelimiter(),t}};var a=function(t){if(!t||0===t.length)return[];var e=new o(t),i=[];if(e.initialCommandIsMoveTo())for(;e.hasMoreData();){var r=e.parseSegment();if(null===r)break;i.push(r)}return i},l=SVGPathElement.prototype.setAttribute,c=SVGPathElement.prototype.setAttributeNS,h=SVGPathElement.prototype.removeAttribute,u=SVGPathElement.prototype.removeAttributeNS,d=window.Symbol?Symbol():"__cachedPathData",p=window.Symbol?Symbol():"__cachedNormalizedPathData";SVGPathElement.prototype.setAttribute=function(t,e){"d"===t&&(this[d]=null,this[p]=null),l.call(this,t,e)},SVGPathElement.prototype.setAttributeNS=function(t,e,i){if("d"===e){var r="http://www.w3.org/2000/svg";if(t)for(var n of this.ownerSVGElement.attributes)n.name===`xmlns:${t}`&&(r=n.value);"http://www.w3.org/2000/svg"===r&&(this[d]=null,this[p]=null)}c.call(this,t,e,i)},SVGPathElement.prototype.removeAttribute=function(t,e){"d"===t&&(this[d]=null,this[p]=null),h.call(this,t)},SVGPathElement.prototype.removeAttributeNS=function(t,e){if("d"===e){var i="http://www.w3.org/2000/svg";if(t)for(var r of this.ownerSVGElement.attributes)r.name===`xmlns:${t}`&&(i=r.value);"http://www.w3.org/2000/svg"===i&&(this[d]=null,this[p]=null)}u.call(this,t,e)},SVGPathElement.prototype.getPathData=function(i){if(i&&i.normalize){if(this[p])return t(this[p]);this[d]?n=t(this[d]):(n=a(this.getAttribute("d")||""),this[d]=t(n));var r=e(function(t){var e=[],i=null,r=null,n=null,o=null;return t.forEach((function(t){var s=t.type;if("M"===s){var a=t.values[0],l=t.values[1];e.push({type:"M",values:[a,l]}),n=a,o=l,i=a,r=l}else if("m"===s)a=i+t.values[0],l=r+t.values[1],e.push({type:"M",values:[a,l]}),n=a,o=l,i=a,r=l;else if("L"===s)a=t.values[0],l=t.values[1],e.push({type:"L",values:[a,l]}),i=a,r=l;else if("l"===s)a=i+t.values[0],l=r+t.values[1],e.push({type:"L",values:[a,l]}),i=a,r=l;else if("C"===s){var c=t.values[0],h=t.values[1],u=t.values[2],d=t.values[3];a=t.values[4],l=t.values[5],e.push({type:"C",values:[c,h,u,d,a,l]}),i=a,r=l}else"c"===s?(c=i+t.values[0],h=r+t.values[1],u=i+t.values[2],d=r+t.values[3],a=i+t.values[4],l=r+t.values[5],e.push({type:"C",values:[c,h,u,d,a,l]}),i=a,r=l):"Q"===s?(c=t.values[0],h=t.values[1],a=t.values[2],l=t.values[3],e.push({type:"Q",values:[c,h,a,l]}),i=a,r=l):"q"===s?(c=i+t.values[0],h=r+t.values[1],a=i+t.values[2],l=r+t.values[3],e.push({type:"Q",values:[c,h,a,l]}),i=a,r=l):"A"===s?(a=t.values[5],l=t.values[6],e.push({type:"A",values:[t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],a,l]}),i=a,r=l):"a"===s?(a=i+t.values[5],l=r+t.values[6],e.push({type:"A",values:[t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],a,l]}),i=a,r=l):"H"===s?(a=t.values[0],e.push({type:"H",values:[a]}),i=a):"h"===s?(a=i+t.values[0],e.push({type:"H",values:[a]}),i=a):"V"===s?(l=t.values[0],e.push({type:"V",values:[l]}),r=l):"v"===s?(l=r+t.values[0],e.push({type:"V",values:[l]}),r=l):"S"===s?(u=t.values[0],d=t.values[1],a=t.values[2],l=t.values[3],e.push({type:"S",values:[u,d,a,l]}),i=a,r=l):"s"===s?(u=i+t.values[0],d=r+t.values[1],a=i+t.values[2],l=r+t.values[3],e.push({type:"S",values:[u,d,a,l]}),i=a,r=l):"T"===s?(a=t.values[0],l=t.values[1],e.push({type:"T",values:[a,l]}),i=a,r=l):"t"===s?(a=i+t.values[0],l=r+t.values[1],e.push({type:"T",values:[a,l]}),i=a,r=l):"Z"!==s&&"z"!==s||(e.push({type:"Z",values:[]}),i=n,r=o)})),e}(n));return this[p]=t(r),r}if(this[d])return t(this[d]);var n=a(this.getAttribute("d")||"");return this[d]=t(n),n},SVGPathElement.prototype.setPathData=function(t){if(0===t.length)s?this.setAttribute("d",""):this.removeAttribute("d");else{for(var e="",i=0,r=t.length;i<r;i+=1){var n=t[i];i>0&&(e+=" "),e+=n.type,n.values&&n.values.length>0&&(e+=" "+n.values.join(" "))}this.setAttribute("d",e)}}}SVGRectElement.prototype.getPathData||(SVGRectElement.prototype.getPathData=function(t){var i=this.x.baseVal.value,r=this.y.baseVal.value,n=this.width.baseVal.value,o=this.height.baseVal.value,s=this.hasAttribute("rx")?this.rx.baseVal.value:this.ry.baseVal.value,a=this.hasAttribute("ry")?this.ry.baseVal.value:this.rx.baseVal.value;s>n/2&&(s=n/2),a>o/2&&(a=o/2);var l=[{type:"M",values:[i+s,r]},{type:"H",values:[i+n-s]},{type:"A",values:[s,a,0,0,1,i+n,r+a]},{type:"V",values:[r+o-a]},{type:"A",values:[s,a,0,0,1,i+n-s,r+o]},{type:"H",values:[i+s]},{type:"A",values:[s,a,0,0,1,i,r+o-a]},{type:"V",values:[r+a]},{type:"A",values:[s,a,0,0,1,i+s,r]},{type:"Z",values:[]}];return l=l.filter((function(t){return"A"!==t.type||0!==t.values[0]&&0!==t.values[1]})),t&&!0===t.normalize&&(l=e(l)),l}),SVGCircleElement.prototype.getPathData||(SVGCircleElement.prototype.getPathData=function(t){var i=this.cx.baseVal.value,r=this.cy.baseVal.value,n=this.r.baseVal.value,o=[{type:"M",values:[i+n,r]},{type:"A",values:[n,n,0,0,1,i,r+n]},{type:"A",values:[n,n,0,0,1,i-n,r]},{type:"A",values:[n,n,0,0,1,i,r-n]},{type:"A",values:[n,n,0,0,1,i+n,r]},{type:"Z",values:[]}];return t&&!0===t.normalize&&(o=e(o)),o}),SVGEllipseElement.prototype.getPathData||(SVGEllipseElement.prototype.getPathData=function(t){var i=this.cx.baseVal.value,r=this.cy.baseVal.value,n=this.rx.baseVal.value,o=this.ry.baseVal.value,s=[{type:"M",values:[i+n,r]},{type:"A",values:[n,o,0,0,1,i,r+o]},{type:"A",values:[n,o,0,0,1,i-n,r]},{type:"A",values:[n,o,0,0,1,i,r-o]},{type:"A",values:[n,o,0,0,1,i+n,r]},{type:"Z",values:[]}];return t&&!0===t.normalize&&(s=e(s)),s}),SVGLineElement.prototype.getPathData||(SVGLineElement.prototype.getPathData=function(){return[{type:"M",values:[this.x1.baseVal.value,this.y1.baseVal.value]},{type:"L",values:[this.x2.baseVal.value,this.y2.baseVal.value]}]}),SVGPolylineElement.prototype.getPathData||(SVGPolylineElement.prototype.getPathData=function(){for(var t=[],e=0;e<this.points.numberOfItems;e+=1){var i=this.points.getItem(e);t.push({type:0===e?"M":"L",values:[i.x,i.y]})}return t}),SVGPolygonElement.prototype.getPathData||(SVGPolygonElement.prototype.getPathData=function(){for(var t=[],e=0;e<this.points.numberOfItems;e+=1){var i=this.points.getItem(e);t.push({type:0===e?"M":"L",values:[i.x,i.y]})}return t.push({type:"Z",values:[]}),t})}()},6532:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},6852:function(t){t.exports=JSON.parse('{"party":"Partito","votes":"Voti","reporting":"{percentage}% Copertura","ev":"V.E.","electoralVotes":"Voti Elettorali","unknown":"Sconosciuto","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},6915:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')},7242:function(t){t.exports=JSON.parse('{"flyTo":"Rechercher"}')},7435:function(t){t.exports=JSON.parse('{"goBack":"Retour en arrière","notice":"Utilisez deux doigts pour déplacer la carte"}')},7550:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},7694:function(t){t.exports=JSON.parse('{"flyTo":"fly to..."}')},7739:function(t){t.exports=JSON.parse('{"youtube":"Votre vidéo sera diffusée sur la carte publiée","videoAlert":"Votre vidéo sera diffusée sur la carte publiée"}')},7864:function(t){t.exports=JSON.parse('{"flyTo":"Suche nach..."}')},7915:function(t){t.exports=JSON.parse('{"loadingSettings":"Cargando configuración","errorLoadingSettings":"Error al cargar la configuración","loadCandidates":"Cargando los datos del candidato","errorLoadingCandidates":"Error al cargar los datos de los candidatos","loadingResults":"Cargando los resultados","errorLoadingResults":"Error al cargar los resultados","updatedOn":"Actualizado el {date} a las {time}","checkingForData":"Comprobando nuevos datos en {time}"}')},7919:function(t){t.exports=JSON.parse('{"goBack":"Vuelve atrás","notice":"Usa dos dedos para mover el mapa"}')},8130:function(t){t.exports=JSON.parse('{"party":"Partido","votes":"Votos","reporting":"{percentage}% Informando","ev":"V.E.","electoralVotes":"Votos Electorales","unknown":"Desconocido","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},8440:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Désolé, la géolocalisation n\'est pas prise en charge par votre navigateur"}')},8656:function(t,e){var i,r,n;r=[],i=function(){function t(t,e){for(var i in t)t.hasOwnProperty(i)&&e(i,t[i])}function e(){var i={},r="en",n=/{{\s*(\w+)\s*}}/g,o={en:{pluralizeTo:"count",getVariationIndex:function(t){return 1===t?0:1}}};function s(t,e,n){var o=(n=n||{}).locale||r,c=n.registry||i,h=c[o]&&c[o][t];return void 0===h?s.whenUndefined(t,o):Array.isArray(h)?a(t,h,e,o,n.pluralizeTo):l(h,e)}function a(t,e,i,r,n){var s=o[r],a=Object.keys(i),c=1===a.length?a[0]:n||s.pluralizeTo,h=parseFloat(i[c]);if(isNaN(h))throw new Error('Tranlation pluralization missing parameters on key "'+t+'"');return l(e[s.getVariationIndex(h)],i)}function l(t,e){return e?t.replace(n,(function(t,i){return e.hasOwnProperty(i)?e[i]:t})):t}return s.add=function(e,n,o){return i[n=n||r]=i[n]||{},t(e,(function(t,e){var r=o?o+"."+t:t,a=typeof e;Array.isArray(e)||"string"===a||"number"===a?i[n][r]=e:s.add(e,n,r)})),this},s.setLocale=function(t){return r=t,this},s.getLocale=function(){return r},s.interpolateWith=function(t){return n=t,this},s.setPluralizationRule=function(t,e,i){return o[t]={pluralizeTo:i&&i.pluralizeTo||"count",getVariationIndex:e},this},s.whenUndefined=function(t,e){return t},s.clear=function(){return i={},this},s.createRegistry=function(){return e()},s}return e()},void 0===(n="function"==typeof i?i.apply(e,r):i)||(t.exports=n)},9034:function(t){t.exports=JSON.parse('{"party":"Partij","votes":"Stemmen","reporting":"{percentage}% Gerapporteerd","ev":"K.M.","electoralVotes":"Kiesmannen","unknown":"Onbekend","title":"PRESIDENT 2024","example":"United States","incumbent":"WON 2020","votesCounted":"votes counted"}')},9134:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Leider wird die Geolokalisierung von Ihrem Browser nicht unterstützt"}')},9510:function(t){t.exports=JSON.parse('{"showMore":"Show more","showLess":"Show less","tapFor":"Tap for {alternative}","allResults":"All results","candidateList":"Candidate list"}')},9842:function(t){t.exports=JSON.parse('{"geolocationNotAvailable":"Sorry, geolocation is not supported by your browser"}')},9983:function(t){t.exports=JSON.parse('{"youtube":"Your video will appear here once the map is exported","videoAlert":"The video will only work when you publish the map"}')}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,i),o.exports}function r(t,e=void 0){return e||(e=window.location.href),new URL(e).searchParams.get(t)}i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function n(t){let e=t.split("").map((t=>t.charCodeAt(0))).reduce(((t,e)=>(t^=e)+(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)),2166136261);return e^=e<<3,e+=e>>5,e^=e<<4,e+=e>>17,e^=e<<25,e+=e>>6,`0000000${(e>>>0).toString(16)}`.substr(-8)}let o;function s(){return void 0!==o&&("bleeding"===o||"development"===o)}function a(){return void 0!==o&&"beta"===o}function l(t){return t.replace("vapi.mc-cdn.io","vapi.bleeding.mc-cdn.io").replace("cdn.mapcreator.io","cdn.bleeding.mapcreator.io")}function c(t){return t.replace("vapi.mc-cdn.io","vapi.beta.mc-cdn.io").replace("cdn.mapcreator.io","cdn.beta.mapcreator.io")}class h{mapOptions;options;_favicon;constructor(t,e){this.mapOptions={...this.constructor.defaultMapOptions,...e},this.options={...this.constructor.defaultOptions,...t},this.options.libraryMode||(this.updateTitle(),this.updateFavicon())}static get defaultMapOptions(){return{container:document.getElementsByClassName("map")[0],attributionControl:!1,style:null}}static get defaultOptions(){return{noBounds:"true"===r("noBounds"),language:navigator.language||navigator.userLanguage}}updateTitle(){const t=document.querySelector("title");t.innerText=`${this.title} – ${t.innerText}`}updateFavicon(){this._favicon=document.createElement("link"),this._favicon.setAttribute("href",this.favicon),this._favicon.setAttribute("rel","shortcut icon"),this._favicon.parentElement!==document.head&&document.head.appendChild(this._favicon)}get favicon(){throw new Error("Unimplemented")}get title(){return"Unimplemented"}}var u=i(2264);const d=Object.freeze({THREE:"ISO 639-2/B",API:"ISO 639-2/B",TWO:"ISO 639-1",MAPLIBRE_COMPAT:"ISO 639-1",ENDONYM:"name",NAME:"name",LOCALE:"locale",i18n:"locale"});var p=d;const f=Object.freeze([{[d.TWO]:"en",[d.THREE]:"eng",[d.ENDONYM]:"English",[d.LOCALE]:"en_GB"},{[d.TWO]:"da",[d.THREE]:"dan",[d.ENDONYM]:"Dansk",[d.LOCALE]:"da_DK"},{[d.TWO]:"nl",[d.THREE]:"dut",[d.ENDONYM]:"Nederlands",[d.LOCALE]:"nl_NL"},{[d.TWO]:"fi",[d.THREE]:"fin",[d.ENDONYM]:"Suomi",[d.LOCALE]:"fi_FI"},{[d.TWO]:"fr",[d.THREE]:"fre",[d.ENDONYM]:"Francais",[d.LOCALE]:"fr_FR"},{[d.TWO]:"de",[d.THREE]:"ger",[d.ENDONYM]:"Deutsch",[d.LOCALE]:"de_DE"},{[d.TWO]:"it",[d.THREE]:"ita",[d.ENDONYM]:"Italiano",[d.LOCALE]:"it_IT"},{[d.TWO]:"no",[d.THREE]:"nor",[d.ENDONYM]:"Norsk",[d.LOCALE]:"nn_NO"},{[d.TWO]:"pl",[d.THREE]:"pol",[d.ENDONYM]:"Polski",[d.LOCALE]:"pl_PL"},{[d.TWO]:"pt",[d.THREE]:"por",[d.ENDONYM]:"Portugues",[d.LOCALE]:"pt_PT"},{[d.TWO]:"es",[d.THREE]:"spa",[d.ENDONYM]:"Espanol",[d.LOCALE]:"es_ES"},{[d.TWO]:"sv",[d.THREE]:"swe",[d.ENDONYM]:"Svenska",[d.LOCALE]:"sv_SE"},{[d.TWO]:"ja",[d.THREE]:"jpn",[d.ENDONYM]:"日本語",[d.LOCALE]:"ja_JP"},{[d.TWO]:"zh",[d.THREE]:"chi",[d.ENDONYM]:"汉语",[d.LOCALE]:"zh_CN"},{[d.TWO]:"ru",[d.THREE]:"rus",[d.ENDONYM]:"Русский",[d.LOCALE]:"ru_RU"},{[d.TWO]:"uk",[d.THREE]:"ukr",[d.ENDONYM]:"Украї́нська",[d.LOCALE]:"uk_UK"},{[d.TWO]:"lv",[d.THREE]:"lav",[d.ENDONYM]:"Latviešu valoda",[d.LOCALE]:"lv-LV"},{[d.TWO]:"kk",[d.THREE]:"kaz",[d.ENDONYM]:"қазақша",[d.LOCALE]:"kk-KZ"},{[d.TWO]:"ar",[d.THREE]:"ara",[d.ENDONYM]:"Arabic",[d.LOCALE]:"ar_SA"},{[d.TWO]:"native",[d.THREE]:"native",[d.ENDONYM]:"Native",[d.LOCALE]:"native"}]);function m(t,e=d.MAPLIBRE_COMPAT){return(f.find((e=>Object.values(e).some((e=>e===t))))||f[0])[e]}var g={get id(){return r("id")},get accessToken(){return r("access-token")||document.querySelector("meta[name=mc-access-token]")?.getAttribute("content")},get debug(){return"true"===r("debug")},get productionJob(){return"true"===r("debug")||!s()},get vectorApiUrl(){return s()?"https://vapi.bleeding.mc-cdn.io/":"https://vapi.mc-cdn.io/"},get objectUrl(){return this.id?this.accessToken?this.productionJob?a()?`https://cdn.beta.mapcreator.io/jobs/${this.id}.json`:`https://cdn.mapcreator.io/jobs/${this.id}.json`:`https://cdn.bleeding.mapcreator.io/jobs/${this.id}.json`:`https://dynamic.maps4news.com/${this.id}/map.json`:location.href.replace(/(\/|\/[^/]+\.[^/.]+)?$/,"/map.json")}},_=i(8656);var y=new class{fallbackLocale;constructor(t,e=void 0){_.interpolateWith(/{\s*(\w+)\s*}/g);for(const[t,e]of Object.entries(this._loadLocaleMessages()))_.add(e,t);this.locale=t,this.fallbackLocale=e??t}get locale(){return _.getLocale()}set locale(t){_.setLocale(t)}get localeMaplibreCompat(){return this.locale.substr(0,2)}get localeWithPreferredRegion(){return navigator.languages.find((t=>t.startsWith(`${this.localeMaplibreCompat}-`)))?.replace("-","_")??this.locale}t(t,e={interpolate:void 0},i=this.locale){const r=_(t,e,{locale:i});return t===r?i===this.fallbackLocale?t:_(t,e,{locale:this.fallbackLocale}):r}_loadLocaleMessages(){const t=i(460),e={};for(const i of t.keys()){const r=i.match(/\/([a-z_/]+)\/([a-z0-9-_]+)\./i);if(!r?.length)continue;const n=r[1].split("/");let o=e;for(const t of n)o.hasOwnProperty(t)||(o[t]={}),o=o[t];o[r[2]]=t(i)}return e}}("en_GB");function x(t){return t/180*Math.PI}function v(t){return 180*t/Math.PI}function b(t,e){const i=Math.PI/180,r=t.lat*i,n=e.lat*i,o=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-t.lng)*i);return 6371e3*Math.acos(Math.min(o,1))}function w(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}function T(t,e){return t.startsWith("$")?S(e[t.slice(1)]):t}function S(t){return null==t?"":"object"==typeof t?t.w??"":String(t)}function P(t){if(t=t.trim(),/^\$?[\w\-_]+$/.test(t))return t;return(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/.exec(t)||[])[1]}function M(t,e,i){if(t===e)return i;const r={millimeter:1,centimeter:.1,meter:.001,kilometer:1e-6,foot:.00328084,mile:6.21371e-7,nauticalMile:5.39957e-7,inch:.0393701,pixel:2.8346472,pica:.236222};return i/r[t]*r[e]}const I={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function C(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:w((e=t).id),properties:{id:e.id,"line-width":e.lineWidth??3,"line-color":e.lineColor??"#000000","line-style":e.lineStyle??"solid"},geometry:{type:"LineString",coordinates:e.geometry}};var e}))}});for(const r in I)e.models.some((t=>(t.lineStyle??"solid")===r))&&t.addLayer({id:`${e.id}-${r}`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},filter:["==",["get","line-style"],r],paint:{"line-width":["get","line-width"],"line-color":["get","line-color"],"line-dasharray":I[r]}},i);t.addLayer({id:`${e.id}-clickable`,type:"line",source:e.id,metadata:{"mc-model-type":"line","mc-group-id":e.id},paint:{"line-width":["max",["get","line-width"],15],"line-opacity":0}},i)}var A=6371008.8;Math.PI;function E(t,e,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=e||{},r.geometry=t,r}function k(t,e,i={}){for(const e of t){if(e.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(e[e.length-1].length!==e[0].length)throw new Error("First and last Position are not equivalent.");for(let t=0;t<e[e.length-1].length;t++)if(e[e.length-1][t]!==e[0][t])throw new Error("First and last Position are not equivalent.")}return E({type:"Polygon",coordinates:t},e,i)}function z(t,e,i={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return E({type:"LineString",coordinates:t},e,i)}function L(t,e={}){const i={type:"FeatureCollection"};return e.id&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.features=t,i}function D(t,e,i={}){return E({type:"MultiLineString",coordinates:t},e,i)}function R(t,e,i={}){return E({type:"MultiPolygon",coordinates:t},e,i)}function F(t,e,i){if(null!==t)for(var r,n,o,s,a,l,c,h,u=0,d=0,p=t.type,f="FeatureCollection"===p,m="Feature"===p,g=f?t.features.length:1,_=0;_<g;_++){a=(h=!!(c=f?t.features[_].geometry:m?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<a;y++){var x=0,v=0;if(null!==(s=h?c.geometries[y]:c)){l=s.coordinates;var b=s.type;switch(u=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,d,_,x,v))return!1;d++,x++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],d,_,x,v))return!1;d++,"MultiPoint"===b&&x++}"LineString"===b&&x++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-u;n++){if(!1===e(l[r][n],d,_,x,v))return!1;d++}"MultiLineString"===b&&x++,"Polygon"===b&&v++}"Polygon"===b&&x++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(v=0,n=0;n<l[r].length;n++){for(o=0;o<l[r][n].length-u;o++){if(!1===e(l[r][n][o],d,_,x,v))return!1;d++}v++}x++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(!1===F(s.geometries[r],e,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function B(t,e){var i,r,n,o,s,a,l,c,h,u,d=0,p="FeatureCollection"===t.type,f="Feature"===t.type,m=p?t.features.length:1;for(i=0;i<m;i++){for(a=p?t.features[i].geometry:f?t.geometry:t,c=p?t.features[i].properties:f?t.properties:{},h=p?t.features[i].bbox:f?t.bbox:void 0,u=p?t.features[i].id:f?t.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,n=0;n<s;n++)if(null!==(o=l?a.geometries[n]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,d,c,h,u))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],d,c,h,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,d,c,h,u))return!1;d++}}function O(t,e){(e=e||{}).iterations=e.iterations||1;const{iterations:i}=e,r=[];if(!t)throw new Error("inputPolys is required");return B(t,(function(t,e,n){if("Polygon"===t.type){let e=[[]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=k(e).geometry),j(n,i),e=i.slice(0)}r.push(k(e,n))}else{if("MultiPolygon"!==t.type)throw new Error("geometry is invalid, must be Polygon or MultiPolygon");{let e=[[[]]];for(let r=0;r<i;r++){let i=[],n=t;r>0&&(n=R(e).geometry),N(n,i),e=i.slice(0)}r.push(R(e,n))}}})),L(r)}function j(t,e){var i,r;F(t,(function(t,n,o,s,a){if(r!==a)e.push([]);else{var l=i[0],c=i[1],h=t[0],u=t[1];e[a].push([.75*l+.25*h,.75*c+.25*u]),e[a].push([.25*l+.75*h,.25*c+.75*u])}i=t,r=a}),!1),e.forEach((function(t){t.push(t[0])}))}function N(t,e){let i,r,n;F(t,(function(t,o,s,a,l){if(r!==a)e.push([[]]);else if(n!==l)e[a].push([]);else{var c=i[0],h=i[1],u=t[0],d=t[1];e[a][l].push([.75*c+.25*u,.75*h+.25*d]),e[a][l].push([.25*c+.75*u,.25*h+.75*d])}i=t,r=a,n=l}),!1),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function V(t,e){var i,r,n,o,s,a,l;for(r=1;r<=8;r*=2){for(i=[],o=!(Z(n=t[t.length-1],e)&r),s=0;s<t.length;s++)(l=!(Z(a=t[s],e)&r))!==o&&i.push(U(n,a,r,e)),l&&i.push(a),n=a,o=l;if(!(t=i).length)break}return i}function U(t,e,i,r){return 8&i?[t[0]+(e[0]-t[0])*(r[3]-t[1])/(e[1]-t[1]),r[3]]:4&i?[t[0]+(e[0]-t[0])*(r[1]-t[1])/(e[1]-t[1]),r[1]]:2&i?[r[2],t[1]+(e[1]-t[1])*(r[2]-t[0])/(e[0]-t[0])]:1&i?[r[0],t[1]+(e[1]-t[1])*(r[0]-t[0])/(e[0]-t[0])]:null}function Z(t,e){var i=0;return t[0]<e[0]?i|=1:t[0]>e[2]&&(i|=2),t[1]<e[1]?i|=4:t[1]>e[3]&&(i|=8),i}function $(t,e){const i=[];for(const r of t){const t=V(r,e);t.length>0&&(t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]||t.push(t[0]),t.length>=4&&i.push(t))}return i}var G=function(t,e){const i="Feature"===(r=t).type?r.geometry:r;var r;const n=i.type,o="Feature"===t.type?t.properties:{};let s=i.coordinates;switch(n){case"LineString":case"MultiLineString":{const t=[];return"LineString"===n&&(s=[s]),s.forEach((i=>{!function(t,e,i){var r,n,o,s=t.length,a=Z(t[0],e),l=[];let c,h;for(i||(i=[]),r=1;r<s;r++){for(c=t[r-1],h=t[r],n=o=Z(h,e);;){if(!(a|n)){l.push(c),n!==o?(l.push(h),r<s-1&&(i.push(l),l=[])):r===s-1&&l.push(h);break}if(a&n)break;a?(c=U(c,h,a,e),a=Z(c,e)):(h=U(c,h,n,e),n=Z(h,e))}a=o}l.length&&i.push(l)}(i,e,t)})),1===t.length?z(t[0],o):D(t,o)}case"Polygon":return k($(s,e),o);case"MultiPolygon":return R(s.map((t=>$(t,e))),o);default:throw new Error("geometry "+n+" not supported")}};function q(t,e){const i=[],r=2*Math.PI/100;for(let n=0;n<100;n++)i.push(H(t,e,n*r));if(function(t,e){return b(t,{lng:0,lat:90})/1e3<e}(t,e)){const t=i[0],e=i[i.length-1],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.push([r,n]),i.push([r,90]),i.push([r+360,90]),i.push([r+360,n])}if(function(t,e){return b(t,{lng:0,lat:-90})/1e3<e}(t,e)){const t=i[49],e=i[50],r=(e[0]+t[0]-360)/2,n=(t[1]+e[1])/2;i.splice(50,0,[r+360,n],[r+360,-90],[r,-90],[r,n])}return i.push(i[0]),i}function W(t,e,i){const r=[],n=e/100;for(let e=0;e<=100;e++)r.push(H(t,e*n,x(i)));const o=[-1/0,-85.051129,1/0,85.051129];return G(z(r),o).geometry.coordinates}function H(t,e,i){const r=e/6378.1,n=x(t.lng),o=x(t.lat),s=Math.asin(Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(i));return[v(n+Math.atan2(Math.sin(i)*Math.sin(r)*Math.cos(o),Math.cos(r)-Math.sin(o)*Math.sin(s))),v(s)]}function X(t){const{polygonType:e}=t,i="number"==typeof t.anchorPoints?.[0]?.[0]?[t.anchorPoints]:t.anchorPoints;return"smooth"===e?O(k(i),{iterations:4}).features?.[0]?.geometry?.coordinates??i.slice():i.slice()}function K(t,e){return`${t}-${n(`${e.vectorUrl}/${e.sourceLayerId}`)}`}function Y(t){return`custom-area-${n(t.vectorUrl)}`}function J(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i){const r=void 0!==t.fillPattern?i.getMapLibreImageKey(e[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":r,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":t.radiusLineColor??"#000000","radius-line-width":t.radiusLineWidth??0},geometry:{type:"GeometryCollection",geometries:[{type:"Polygon",coordinates:[q(t.center,t.radius)]},{type:"LineString",coordinates:W(t.center,t.radius,t.radiusLineBearing??0)}]}}}(t,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"circle","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-radius-line`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["all",["==",["geometry-type"],"LineString"],["get","radius-line-enabled"]],paint:{"line-color":["get","radius-line-color"],"line-width":["get","radius-line-width"]}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"circle","mc-group-id":e.id},filter:["==",["geometry-type"],"Polygon"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}function Q(t,e,i,r,n){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>function(t,e,i,r){const n=void 0!==t.fillPattern?r.getMapLibreImageKey(i[t.fillPattern],2*window.devicePixelRatio):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"fill-color":t.fillColor??"#000000","outline-color":t.outlineColor??"#000000","outline-width":t.outlineWidth??0,"fill-pattern":n},geometry:{type:"Polygon",coordinates:X(t)}}}(t,e.id,r,n)))}}),t.addLayer({id:e.id,type:"fill",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},paint:{"fill-color":["get","fill-color"]}},i),t.addLayer({id:`${e.id}-pattern`,type:"fill",source:e.id,filter:["has","fill-pattern"],paint:{"fill-pattern":["get","fill-pattern"]},metadata:{"mc-model-type":"polygon","mc-group-id":e.id}},i),t.addLayer({id:`${e.id}-outline`,type:"line",source:e.id,metadata:{"mc-model-type":"polygon","mc-group-id":e.id},layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":["get","outline-width"],"line-color":["get","outline-color"]}},i)}i(6325);function tt(t,e,i){return Math.max(Math.min(t,i),e)}function et(t,e,i=1e-4){return Math.abs(t-e)<i}async function it(t,e,i,r){if(void 0!==window.InstallTrigger||t.length<2e6)try{return{token:r,image:await rt(t,e,i)}}catch(t){}const n=new Blob([t],{type:"image/svg+xml"});return{token:r,image:await nt(n,e,i)}}function rt(t,e,i){const r=new Image;return r.width=e,r.height=i,new Promise(((e,i)=>{r.onload=()=>e(r),r.onerror=()=>i(new Error("Failed to quickly generate image from svg")),r.src=`data:image/svg+xml;base64,${btoa(t)}`}))}async function nt(t,e,i){const r=new Image;r.width=e,r.height=i;const n=URL.createObjectURL(t);try{await new Promise(((t,e)=>{r.onload=()=>t(),r.onerror=()=>e(new Error("Failed to safely generate image from svg")),r.src=n}))}finally{URL.revokeObjectURL(n)}return r}const ot=/\$\{([^}]+)}/g,st=new DOMParser,at=new XMLSerializer,lt=new Map;function ct(t){let e=lt.get(t);return e||(e=st.parseFromString(t,"image/svg+xml").documentElement,lt.set(t,e)),e}class ht{_seen=[];_svg=null;_element=null;constructor(t){this._svg=t}setElement(){return this._element=ct(this._svg).cloneNode(!0),this._svg=null,this._element}getSvgString(){return this._svg??function(t){const e=at.serializeToString(t);return lt.has(e)||lt.set(e,t),e}(this._element)}getSvgSize(){const t=this._element??ct(this._svg);return[t.width.baseVal.value,t.height.baseVal.value]}getSvgColors(){const t=[],e=[],i=(this._element??ct(this._svg)).querySelectorAll("[mol_edit_style=true]");for(let r=0;r<i.length;++r){const n=i[r],o=n.id;if(o&&e.every((t=>t.id!==o))){const i=n.getAttribute("fill")?.trim();if(i){const r=new ft(i);if(r.badValue)t.push({name:`fill#${o}`,color:i});else{const{rgba:e}=r,i=n.getAttribute("fill-opacity");e[3]*=i?tt(Number(i),0,1):1,t.push({name:`fill#${o}`,color:ft.fromRGB(e)})}e.push(n)}const r=n.getAttribute("stroke")?.trim();if(r){const i=new ft(r);if(i.badValue)t.push({name:`stroke#${o}`,color:r});else{const{rgba:e}=i,r=n.getAttribute("stroke-opacity");e[3]*=r?tt(Number(r),0,1):1,t.push({name:`stroke#${o}`,color:ft.fromRGB(e)})}e.push(n)}}}return t}setSvgColors(t){const e=[],i=(this._element??this.setElement()).querySelectorAll("[mol_edit_style=true]");for(let r=0;r<i.length;++r){const n=i[r],o=n.id;if(o&&e.every((t=>t.id!==o))&&(n.getAttribute("fill")?.trim()||n.getAttribute("stroke")?.trim())){const i=t.find((t=>t.name===`fill#${o}`));if(i?.color){const[t,e,r,o]=i.color.rgba;n.setAttribute("fill",`rgb(${t},${e},${r})`),n.setAttribute("fill-opacity",String(o))}const r=t.find((t=>t.name===`stroke#${o}`));if(r?.color){const[t,e,i,o]=r.color.rgba;n.setAttribute("stroke",`rgb(${t},${e},${i})`),n.setAttribute("stroke-opacity",String(o))}e.push(n)}}return this}getSvgTexts(){const t=[],e=(this._element??ct(this._svg)).querySelectorAll("[mol_edit_text=true]");for(let i=0;i<e.length;++i){const r=e[i],n=r.id;n&&t.every((t=>t.name!==n))&&t.push({name:n,text:r.textContent||void 0,isMultiline:/^\s*true/i.test(r.getAttribute("mol_wrap")??"false")})}return t}setSvgTexts(t){this._seen=[];const e=this._element??this.setElement(),i=e.querySelectorAll("[mol_edit_text=true]");document.body.appendChild(e);try{const r=e.width.baseVal.value/e.viewBox.baseVal.width;for(let r=0;r<i.length;++r){const n=i[r],o=n.id;if(o&&this._seen.every((t=>t.id!==o))){const i=t.find((t=>t.name===o));if(n.querySelector("textPath")){if(i)for(let t=0;t<n.childNodes.length;++t)"textPath"===n.childNodes[t].nodeName&&(n.childNodes[t].childNodes[0].nodeValue=i.text??"")}else this.wrapText(e,n,i&&(i.text??""));this.nodeChanged(n)}}this._seen.length&&(this.resetSize(r),this.resetAnchor())}finally{document.body.removeChild(e)}return this}nodeChanged(t){if(!t.id||this._seen.includes(t))return;const e=this._element??this.setElement(),i=this.getBBox(t);let r=0,n=e.querySelectorAll(`[mol_wrap~="${t.id}"]`)??[];for(r=0;r<n.length;++r)this.wrapText(e,n[r]);for(n=e.querySelectorAll(`[mol_autoresizeid~="${t.id}"]`)??[],r=0;r<n.length;++r)this.autoResizeId(n[r],i);for(n=e.querySelectorAll(`[mol_samewidth~="${t.id}"]`)??[],r=0;r<n.length;++r)this.sameWidth(n[r],i);for(n=e.querySelectorAll(`[mol_sameheight~="${t.id}"]`)??[],r=0;r<n.length;++r)this.sameHeight(n[r],i);for(n=e.querySelectorAll(`[mol_stack~="${t.id}"]`)??[],r=0;r<n.length;++r)this.stack(n[r],i);for(n=e.querySelectorAll(`[mol_rectposition~="${t.id}"]`)??[],r=0;r<n.length;++r)this.rectPosition(n[r],i);for(n=e.querySelectorAll(`[mol_pathposition~="${t.id}"]`)??[],r=0;r<n.length;++r)this.pathPosition(n[r],t);for(n=e.querySelectorAll(`[mol_copyposition~="${t.id}"]`)??[],r=0;r<n.length;++r)this.copyPosition(n[r],t);this._seen.push(t)}autoResizeId(t,e){const i=t.attributes.mol_autoresizemargin?.value;let r=[0,0,0,0];if(i){const t=i.split(" ").map((t=>parseFloat(t)));r=1===t.length?[t[0],t[0],t[0],t[0]]:[t[0],t[1],t[2],t[3]]}!(et(t.attributes.x.value,e.x-r[0])&&et(t.attributes.y.value,e.y-r[2])&&et(t.attributes.width.value,e.width+r[0]+r[1])&&et(t.attributes.height.value,e.height+r[2]+r[3]))&&(t.attributes.x.value=e.x-r[0],t.attributes.y.value=e.y-r[2],t.attributes.width.value=e.width+r[0]+r[1],t.attributes.height.value=e.height+r[2]+r[3],this.nodeChanged(t))}sameWidth(t,e){const i=e.width+2*parseFloat(t.attributes.mol_samewidth.value.split(" ")[1]);et(t.attributes.width.value,i)||(t.attributes.width.value=i,this.nodeChanged(t))}sameHeight(t,e){const i=e.height+2*parseFloat(t.attributes.mol_sameheight.value.split(" ")[1]);et(t.attributes.height.value,i)||(this._seen.push(t),t.attributes.height.value=i,this.nodeChanged(t))}stack(t,e){let i=!1;switch(t.attributes.mol_stack.value.split(" ")[0]){case"top":i=!(et(t.attributes.width.value,e.width)&&et(t.attributes.x.value,e.x)&&et(t.attributes.y.value,e.y-t.attributes.height.value)),i&&(t.attributes.width.value=e.width,t.attributes.x.value=e.x,t.attributes.y.value=e.y-t.attributes.height.value);break;case"bottom":i=!(et(t.attributes.width.value,e.width)&&et(t.attributes.x.value,e.x)&&et(t.attributes.y.value,e.y+e.height)),i&&(t.attributes.width.value=e.width,t.attributes.x.value=e.x,t.attributes.y.value=e.y+e.height);break;case"left":i=!(et(t.attributes.height.value,e.height)&&et(t.attributes.x.value,e.x-t.attributes.width.value)&&et(t.attributes.y.value,e.y)),i&&(t.attributes.height.value=e.height,t.attributes.x.value=e.x-t.attributes.width.value,t.attributes.y.value=e.y);break;case"right":i=!(et(t.attributes.height.value,e.height)&&et(t.attributes.x.value,e.x+e.width)&&et(t.attributes.y.value,e.y)),i&&(t.attributes.height.value=e.height,t.attributes.x.value=e.x+e.width,t.attributes.y.value=e.y)}i&&this.nodeChanged(t)}rectPosition(t,e){const i=t.attributes.mol_rectposition.value.split(" ")[1],r=t.attributes.mol_rectposition.value.split(" ")[2],n=parseFloat(t.attributes.mol_rectposition.value.split(" ")[3])||0;let o={x:0,y:0};switch(i){case"center":o={x:e.x+e.width/2,y:e.y+e.height/2};break;case"top":case"bottom":switch(o.x=e.x,r){case"start":o.x+=n;break;case"middle":o.x+=e.width/2+n;break;case"end":o.x+=e.width-n}o.y=e.y,"bottom"===i&&(o.y+=e.height);break;case"left":case"right":switch(o.y=e.y,r){case"start":o.y+=n;break;case"middle":o.y+=e.height/2+n;break;case"end":o.y+=e.height+n}o.x=e.x,"right"===i&&(o.x+=e.width)}const s=this.getCoordinate(t,0,0);!s||et(s.x,o.x)&&et(s.y,o.y)||(this.moveElement(t,o),this.nodeChanged(t))}pathPosition(t,e){const i=t.attributes.mol_pathposition.value.split(" ").map((t=>parseFloat(t))),r=this.getCoordinate(t,0,0),n=this.getCoordinate(e,i[1],i[2]);!n||!r||et(n.x,r.x)&&et(n.y,r.y)||(this.moveElement(t,n),this.nodeChanged(t))}copyPosition(t,e){const i=t.attributes.mol_copyposition.value.split(" ").map((t=>parseFloat(t))),r=this.getCoordinate(t,i[0],i[1]),n=this.getCoordinate(e,i[3],i[4]);!n||!r||et(n.x,r.x)&&et(n.y,r.y)||(this.setCoordinate(t,n,i[0],i[1]),this.nodeChanged(t))}resetSize(t){const e=this._element??this.setElement(),i=this.getBBox(e);i.x-=.1*i.width,i.y-=.1*i.height,i.width*=1.2,i.height*=1.2,e.setAttribute("viewBox",`${i.x} ${i.y} ${i.width} ${i.height}`),e.setAttribute("width",""+i.width*t),e.setAttribute("height",""+i.height*t)}resetAnchor(){const t=(this._element??ct(this._svg)).querySelector("[mol_edit_anchor]");if(t){const e=t.getAttribute("mol_edit_anchor").split(" ").map((t=>parseFloat(t))),i=this.getCoordinate(t,e[0],e[1]),r=this._element??this.setElement(),n=r.getElementById("scale");if(n){const t=n.getAttribute("transform"),e=(/scale\(([\d.]+)\)/i.exec(t)||["","1"]).map(Number.parseFloat)[1];i.x*=e,i.y*=e}r.setAttribute("mol_svganchor",`${i.x} ${i.y}`)}}getBBox(t){let e=null;const i=t.getBBox();if("text"===t.nodeName){const r=function(t){if("text"!==t.nodeName)return"";let e=t.textContent,i=0;for(;i<t.childNodes.length&&"tspan"===t.childNodes[i].nodeName&&null===t.childNodes[i].textContent.match(/\S+/);)e=e.slice(t.childNodes[i].textContent.length),i++;for(i=t.childNodes.length-1;i>=0&&"tspan"===t.childNodes[i].nodeName&&null===t.childNodes[i].textContent.match(/\S+/);)e=e.slice(0,e.length-t.childNodes[i].textContent.length),i--;const r=e.split("\n");for(e=r[0],i=1;i<r.length;++i)r[i].length>e.length&&(e=r[i]);return e}(t);let n=i.width,o=i.x;const s=r.match(/\S+.*\S+/);if(s&&s.length>0){const t=r.match(/^\s*/);t.length>0&&(o-=n/s[0].length*t[0].length),n+=n/s[0].length*(r.length-s[0].length)}e={width:n,height:i.height,x:o,y:i.y,descent:i.y+i.height-Number(t.getAttribute("y"))}}else e={x:i.x,y:i.y,width:Math.max(1,i.width),height:Math.max(1,i.height)};return e}nodeToPoints(t){const e=[];let i,r,n;for(r=t.points.length?t.points.length:t.points.numberOfItems,n=0;n<r;++n)i=t.points.getItem(n),e.push(i);return e}pointsToString(t){let e,i="";for(e=0;e<t.length;++e)i=`${i} ${t[e].x.toString()}, ${t[e].y.toString()}`;return i}getCoordinate(t,e,i){const r={x:0,y:0};let n=[],o=[];switch(t.nodeName){case"rect":if(0===e)return r.x=parseFloat(t.getAttribute("x")),r.y=parseFloat(t.getAttribute("y")),r;if(1===e)return r.x=parseFloat(t.getAttribute("x"))+parseFloat(t.getAttribute("width")),r.y=parseFloat(t.getAttribute("y"))+parseFloat(t.getAttribute("height")),r;break;case"circle":if(0===e)return r.x=parseFloat(t.getAttribute("cx")),r.y=parseFloat(t.getAttribute("cy")),r;if(1===e)return r.x=parseFloat(t.getAttribute("cx"))+parseFloat(t.getAttribute("r")),r.y=parseFloat(t.getAttribute("cy")),r;break;case"ellipse":if(0===e)return r.x=parseFloat(t.getAttribute("cx")),r.y=parseFloat(t.getAttribute("cy")),r;if(1===e)return r.x=parseFloat(t.getAttribute("cx"))+parseFloat(t.getAttribute("rx")),r.y=parseFloat(t.getAttribute("cy")),r;if(2===e)return r.x=parseFloat(t.getAttribute("cx")),r.y=parseFloat(t.getAttribute("cy"))-parseFloat(t.getAttribute("ry")),r;break;case"line":if(0===e)return r.x=parseFloat(t.getAttribute("x1")),r.y=parseFloat(t.getAttribute("y1")),r;if(1===e)return r.x=parseFloat(t.getAttribute("x2")),r.y=parseFloat(t.getAttribute("y2")),r;break;case"polyline":case"polygon":if(n=this.nodeToPoints(t),e<n.length)return r.x=n[e].x,r.y=n[e].y,r;break;case"path":switch(o=t.getPathData({normalize:!0}),o[i].type){case"M":case"L":if(0===e)return r.x=o[i].values[0],r.y=o[i].values[1],r}}return null}setCoordinate(t,e,i,r){let n="",o=[],s=[],a=0,l=0,c=0;switch(t.nodeName){case"rect":0===i&&(t.setAttribute("x",e.x.toString()),t.setAttribute("y",e.y.toString())),1===i&&(a=e.x-Number(t.getAttribute("x")),a>=0?t.setAttribute("width",a.toString()):(l=Number(t.getAttribute("x"))+a,t.setAttribute("x",l.toString()),t.setAttribute("width","0")),a=e.y-Number(t.getAttribute("y")),a>=0?t.setAttribute("height",a.toString()):(l=Number(t.getAttribute("y"))+a,t.setAttribute("y",l.toString()),t.setAttribute("height","0")));break;case"circle":0===i&&(t.setAttribute("cx",e.x.toString()),t.setAttribute("cy",e.y.toString())),1===i&&(l=parseFloat(t.getAttribute("cx"))-e.x,c=parseFloat(t.getAttribute("cy"))-e.y,a=Math.sqrt(l*l+c*c),t.setAttribute("r",a.toString()));break;case"ellipse":0===i&&(t.setAttribute("cx",e.x.toString()),t.setAttribute("cy",e.y.toString())),1===i&&(a=Math.abs(parseFloat(t.getAttribute("cx"))-e.x),t.setAttribute("rx",a.toString())),2===i&&(a=Math.abs(parseFloat(t.getAttribute("cy"))-e.y),t.setAttribute("ry",a.toString()));break;case"line":0===i&&(t.setAttribute("x1",e.x.toString()),t.setAttribute("y2",e.y.toString())),1===i&&(t.setAttribute("x2",e.x.toString()),t.setAttribute("y2",e.y.toString()));break;case"polyline":case"polygon":o=this.nodeToPoints(t),i<o.length&&(o[i].x=e.x,o[i].y=e.y,n=this.pointsToString(o),t.setAttribute("points",n));break;case"path":if(!r)break;switch(s=t.getPathData({normalize:!0}),s[r].type){case"M":case"L":s[r].values[0]=e.x,s[r].values[1]=e.y}t.setPathData(s)}}moveElement(t,e){let i={x:0,y:0};const r={x:0,y:0};let n=0,o=!1,s=[];switch(t.nodeName){case"rect":case"circle":case"ellipse":i=this.getCoordinate(t,0,0),o=!et(i.x,e.x)||!et(i.y,e.y),o&&this.setCoordinate(t,e,0,0);break;case"polyline":case"polygon":if(i=this.getCoordinate(t,0,0),r.x=e.x-i.x,r.y=e.y-i.y,o=!et(r.x,0)||!et(r.y,0),o)for(this.setCoordinate(t,e,0,0),n=1,i=this.getCoordinate(t,n,0);null!==i;)i.x+=r.x,i.y+=r.y,this.setCoordinate(i,n,0,void 0),n++,i=this.getCoordinate(t,n,0);break;case"path":if(i=this.getCoordinate(t,0,0),r.x=e.x-i.x,r.y=e.y-i.y,o=!et(r.x,0)||!et(r.y,0),o){s=t.getPathData({normalize:!0});for(let t=0;t<s.length;++t){const e=s[t];"M"!==e?.type&&"L"!==e?.type||(e.values[0]+=r.x,e.values[1]+=r.y)}t.setPathData(s)}}return o}wrapText(t,e,i){let r,n,o,s,a,l=[],c=0,h=0,u="",d="",p=0,f="";const m="http://www.w3.org/2000/svg";for(i=i??e.textContent;e.hasChildNodes();)e.removeChild(e.firstChild);const g=document.createTextNode("gh");e.appendChild(g);const _=e.getAttribute("y");let y=null,x="",v=[],b=0,w=0,T=!1;if(e.hasAttribute("mol_wrap")&&(v=e.getAttribute("mol_wrap").split(" ",4),"true"===v[0]&&(x=v[1],"newlineOnly"===x?(T=!0,x="",b=0):b=parseFloat(v[2]),w=v.length>=4?parseFloat(v[3]):b)),x){const i=t.getElementById(x);y=this.getBBox(i||e)}else y=this.getBBox(e);let S=y.x,P=y.y;const M=y.width;let I=1e4;""===x||T||(I=M-2*b),y=this.getBBox(e);let C=y.height;e.hasAttribute("font-size")&&(C=parseFloat(e.getAttribute("font-size")));const A=y.y+y.height-_;if(e.removeChild(g),S+=b,P+=b+y.height,e.hasAttribute("text-anchor"))switch(e.getAttribute("text-anchor")){case"end":S=S-b+M-b;break;case"middle":S=S-b+M/2}f=e.getAttribute("id"),e.setAttribute("x",S.toString()),e.setAttribute("y",(P-A).toString()),i&&(l=i.replace(/\n/g,"\n§").replace(/-/g,"-§").replace(/ /g," §").replace(/\t/g," §").split("§"));const E=parseFloat(e.attributes.y.value);for(o=document.createElementNS(m,"tspan"),o.setAttributeNS(null,"x",String(S)),o.setAttributeNS(null,"y",String(E+h)),s=f+p.toString(),o.setAttribute("id",s),p++,u="",c=0,n=document.createTextNode(u),o.appendChild(n),e.appendChild(o),h+=C,r=0;r<l.length;)d=u+l[r],c++,n.nodeValue=d,a=t.querySelector(`#${s}`).getComputedTextLength(),a<I?(u=d,u.length>0&&"\n"===u[u.length-1]&&r<l.length-1&&(n.nodeValue=u,o=document.createElementNS(m,"tspan"),o.setAttributeNS(null,"x",String(S)),o.setAttributeNS(null,"y",String(E+h)),s=f+p.toString(),o.setAttribute("id",s),h+=C+w,p++,u="",c=0,n=document.createTextNode(u),o.appendChild(n),e.appendChild(o)),r++):(c>1?n.nodeValue=u:(u=d,r++),u.length>0&&"\n"===u[u.length-1]&&(u=u.substr(0,u.length-1),n.nodeValue=u),o=document.createElementNS(m,"tspan"),o.setAttributeNS(null,"x",String(S)),o.setAttributeNS(null,"y",String(E+h)),s=f+p.toString(),o.setAttribute("id",s),h+=C+w,p++,u="",c=0,n=document.createTextNode(u),o.appendChild(n),e.appendChild(o));return 1===e.childElementCount&&e.firstElementChild.replaceWith(e.firstElementChild.textContent),h}}class ut{map;keyCache=new Map;constructor(t){this.map=t}getMapLibreImageKey(t,e){let i=this.keyCache.get(e);i||(i=new Map,this.keyCache.set(e,i));let r=i.get(t);if(!r){const o=t+e,s=new ht(t).getSvgSize(),a=Math.max(s[0]*e,1),l=Math.max(s[1]*e,1);r=`mc-image-${n(o)}`,it(t,a,l,r).then((({token:t,image:i})=>this.map.addImage(t,i,{pixelRatio:e}))).catch((t=>console.log(t))),i.set(t,r)}return r}}function dt(t,e,i){const r=(i??e)?.split(ot).map(((e,i)=>1&i?S(t[e]):e)).join("");return r&&!new ft(r).badValue?r:"#000000"}function pt(t,e,i){return(i??e)?.split(ot).map(((e,i)=>1&i?S(t[e]):e)).join("")||void 0}class ft{_error=!1;_rgba;static fromRGB(t){const e=new ft("transparent");return e._rgba[0]=t[0],e._rgba[1]=t[1],e._rgba[2]=t[2],e._rgba[3]=t.length>3?t[3]:1,e}constructor(t){const e=this._rgba=[0,0,0,1];let i;if("transparent"!==t&&(t=String(t).toLowerCase()),"transparent"===t||"none"===t)e[3]=0;else if(t in yt){const i=yt[t];e[0]=i[0],e[1]=i[1],e[2]=i[2]}else if("#"===t[0]){const i=t.slice(1),r=i.length;r<5?(e[0]=parseInt(i[0]+i[0],16)||0,e[1]=parseInt(i[1]+i[1],16)||0,e[2]=parseInt(i[2]+i[2],16)||0,4===r&&(e[3]=parseInt(i[3]+i[3],16)/255)):(e[0]=parseInt(i[0]+i[1],16)||0,e[1]=parseInt(i[2]+i[3],16)||0,e[2]=parseInt(i[4]+i[5],16)||0,8===r&&(e[3]=parseInt(i[6]+i[7],16)/255))}else if(i=/^(rgba?|hs[lv]a?)\s*\(([^)]*)\)/.exec(t)){const t=i[1].replace(/a$/,""),r=i[2].trim().split(/\s*[,/]\s*|\s+/).map(gt,{space:t});"rgb"===t?(e[0]=r[0],e[1]=r[1],e[2]=r[2],r.length>3&&(e[3]=r[3])):"hsl"===t?function(t,e=[0,0,0,1]){const i=t[0]/360,r=t[1]/100,n=t[2]/100;if(0===r)e[2]=e[1]=e[0]=255*n;else{const t=n<.5?n*(1+r):n+r-n*r,o=2*n-t;e[0]=_t(o,t,i+1/3),e[1]=_t(o,t,i),e[2]=_t(o,t,i-1/3)}t.length>3&&(e[3]=t[3])}(r,e):"hsv"===t&&function(t,e=[0,0,0,1]){const i=t[0]/60,r=t[1]/100,n=t[2]/100*255,o=Math.floor(i),s=i-o,a=n*(1-r),l=n*(1-s*r),c=n*(1-(1-s)*r);switch(o%6){case 0:e[0]=n,e[1]=c,e[2]=a;break;case 1:e[0]=l,e[1]=n,e[2]=a;break;case 2:e[0]=a,e[1]=n,e[2]=c;break;case 3:e[0]=a,e[1]=l,e[2]=n;break;case 4:e[0]=c,e[1]=a,e[2]=n;break;case 5:e[0]=n,e[1]=a,e[2]=l}t.length>3&&(e[3]=t[3])}(r,e)}else this._error=!0}get badValue(){return this._error}get a(){return this._rgba[3]}get rgba(){return this._rgba.slice()}sameColor(t){return et(this._rgba[0],t._rgba[0])&&et(this._rgba[1],t._rgba[1])&&et(this._rgba[2],t._rgba[2])&&et(this._rgba[3],t._rgba[3])}toString(){const[t,e,i,r]=this._rgba;return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}}const mt={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function gt(t,e){const{space:i}=this;if("%"===t[t.length-1]){const r=parseFloat(t),n=e<3&&"rgb"===i?255:1;return(r<0?0:r>100?100:r)/(e>0&&e<3&&"h"===i[0]?1:100)*n}if("h"===i[e]||2===e&&"h"===i[i.length-1]){if(t in mt)return mt[t];let e=parseFloat(t);switch(!0){case t.endsWith("turn"):e*=360;break;case t.endsWith("grad"):e=360*e/400;break;case t.endsWith("rad"):e=180*e/Math.PI}return(e%360+360)%360}if("none"===t)return 0;{const r=parseFloat(t),n=e<3&&"rgb"===i?255:1;return r<0?0:r>n?n:r}}function _t(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),255*(i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t)}const yt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};let xt;const vt="Roboto-Regular";function bt(t,e,i,r){const n=void 0!==t.svg?r.getMapLibreImageKey(function(t,e,i){let r=e;if(e){const n=new ht(e),o=n.getSvgColors(),s=n.getSvgTexts(),a=i?new Map(new ht(i).getSvgColors().map((({name:t,color:e})=>[t,e]))):new Map,l=i?new Map(new ht(i).getSvgTexts().map((({name:t,text:e})=>[t,e]))):new Map,c=o.map((({name:e,color:i})=>({name:e,color:new ft(dt(t,i?.toString(),a.get(e)?.toString()))}))).filter(((t,e)=>"string"==typeof o[e].color||!t.color.sameColor(o[e].color))),h=s.map((({name:e,text:i})=>({name:e,text:pt(t,i,l.get(e))}))).filter(((t,e)=>t.text!==s[e].text));c.length&&n.setSvgColors(c),h.length&&n.setSvgTexts(h),(c.length||h.length)&&(r=n.getSvgString())}return r}(t.dataBindings??{},i[t.svg],e.svg?i[e.svg]:void 0),xt*(t.iconScale??1)):void 0;return{type:"Feature",id:w(t.id),properties:{id:t.id,"mc-image-key":n,"icon-anchor":t.iconAnchor??"center","icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":t.iconScale??1,text:e.text||t.text?pt(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??"center","text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":t.textSize??16,"text-color":e.textColor||t.textColor?dt(t.dataBindings??{},t.textColor,e.textColor):"#000000","text-halo-color":e.textHaloColor||t.textHaloColor?dt(t.dataBindings??{},t.textHaloColor,e.textHaloColor):"#000000","text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??"center"},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}}}var wt='<svg width="20" height="20" viewBox="0 0 40 40" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 4.167 1.667 35.834h36.667z" stroke-width="2" stroke-linejoin="round"/><path d="M20 29.167v.834m0-14.167.007 8.333" stroke-width="2" stroke-linecap="round"/></svg>\r\n';function Tt(t,e){const{allowFullscreen:i,loop:r}=t,n=T(t.src,e);let o;const s=n.match(/(?:youtube\.com\/(?:watch\?.*v=|embed\/|v\/)|youtu\.be\/)([-\w]{11})/),a=s?.[1];o=a?`https://www.youtube.com/embed/${a}`:n;const l=[];if(i||l.push("fs=0"),r&&a&&l.push(`loop=1&playlist=${a}`),o=function(t){const e=new URL(t),i=e.searchParams.get("t");if(!i)return t;let r=0;const n=/^((\d+)m)?((\d+)s)?$/;if(/^\d+$/.test(i))r=parseInt(i,10);else{const t=i.match(n);if(t){r=60*parseInt(t[2]||"0",10)+parseInt(t[4]||"0",10)}}r>0&&(e.searchParams.delete("t"),e.searchParams.set("start",String(r)));return e.toString()}(o),o=o.replace(/([?&])si=[^&]+(&)?/,((t,e,i)=>"?"!==e||i?"?"===e&&i?"?":i?"&":"":"")),l.length){const t=o.includes("?")?"&":"?";o+=`${t}${l.join("&")}`}return o}function St(t,e,i,r){let n;if("video"===e?.type)n=r?function(t,e){const i=P(T(t,e));return`\n <div class="youtube-placeholder">\n <img src="https://img.youtube.com/vi/${i}/hqdefault.jpg" />\n <div class="popup-alert">\n <div class="alert-icon">${wt}</div>\n <div>${y.t("placeholder.videoAlert")}</div>\n </div>\n </div>\n `}(e.src,i):`\n <div class="youtube-container">\n <iframe\n src="${Tt(e,i)}"\n width="100%" height="300" style="border: none" allowfullscreen>\n </iframe>\n </div>\n `;else if("image"===e?.type){const t=T(e.src,i),r=T(e.alt,i);n=`\n <div class="image-container ${e.fill?"fill":""}">\n <img src="${t}" alt="${r}" />\n </div>\n `}n=n?`<div class="media-content">${n}</div>`:"";const o=t?`<div class="text-content">${function(t,e){if(!t)return"";const i=/>\$(.+?)</gi,r=/<span\s+class="mention"\s+data-mention-id="[^"]*">(.*?)<\/span>/gim,n=/(\S+?)\s*=\s*"\$([^"]+?)"/g,o=/youtube\.com\/embed\/\$([^"'<>\\]+)/gi;return t=t.replace(/placeholder="[^"]+"/,""),t=t.replace(/onerror="[^"]+"/,""),t=t.replace(o,((t,i)=>{const r=S(e[i]);return r?`youtube.com/embed/${P(r)}?`:""})),t=t.replace(n,((t,i,r)=>{const n=S(e[r]);return["src","href"].includes(i)&&!n?"":["src","href"].includes(i)?/^(mailto:|tel:|ftp:|data:|http:\/\/|https:\/\/)/i.test(n)?` ${i}="${n}"`:` ${i}="${function(t){if(!/^https?:\/\//i.test(t))return`https://${t}`;return t}(n)}"`:` ${i}="${n}"`})),t=t.replace(i,((t,i)=>`>${S(e[i])}<`)),t=t.replace(r,((t,e)=>e)),t}(t,i)}</div>`:"";return`\n <div class="popup-scroll-wrapper">\n <div class="mc-popup">\n ${n}\n ${o}\n </div>\n </div>\n `}const Pt=["area","circle","dot","line","marker","polygon"];class Mt{data;customGroupIds;constructor(t){this.data={area:{},circle:{},dot:{},line:{},marker:{},polygon:{}};for(const e of Pt)for(const i of t.registry.models[e]??[]){this.data[e][i.id]={};for(const t of i.models)this.data[e][i.id][t.id]=t}const{beforeWaters:e,beforeBoundaries:i,beforeNames:r,beforeNone:n}=t.registry.slots;this.customGroupIds=[...e,...i,...r,...n].map((t=>t.groupId))}getModel(t){const e=String(t.properties?.id),i=t.layer.metadata?.["mc-group-id"],r=t.layer.metadata?.["mc-model-type"];if(void 0!==i&&void 0!==e&&void 0!==r)return this.data[r]?.[i]?.[e]}getPopupElements(){const t=[],e=["circle","dot","line","marker","polygon"];for(const i of this.customGroupIds)for(const r of e){const e=this.data[r]?.[i];if(e)for(const[r,n]of Object.entries(e))(n.popup||n.popupMedia)&&t.push({groupId:i,modelId:r,popup:n.popup,popupMedia:n.popupMedia,lngLat:n.lngLat,center:n.center,radius:n.radius,anchorPoints:n.anchorPoints,dataBindings:n.dataBindings})}return t.reverse()}}class It{map;popupElements;markerLayerIds;constructor(t,e){this.map=t,this.popupElements=e,this.markerLayerIds=this.map.getStyle().layers.filter((t=>t.id.startsWith("custom-marker"))).map((t=>t.id))}highlight(t,e="bottomLeft"){if(this.deselect(),!t)return;const{groupId:i,modelId:r}=t,n=this.popupElements.filter((t=>t.groupId===i));n.length>1&&i.startsWith("custom-marker")&&this.highlightGroupedMarker(i,r,n),i.startsWith("custom-marker")&&this.fadeOtherMarkers(i),this.repositionMap(t,e)}deselect(){this.markerLayerIds.forEach((t=>{this.map.setPaintProperty(t,"icon-opacity",1),this.map.setPaintProperty(t,"text-opacity",1)}))}highlightGroupedMarker(t,e,i){const r=this.markerLayerIds.find((e=>e.startsWith(t)));r&&(this.map.setPaintProperty(r,"icon-opacity",["case",["boolean",["feature-state","highlighted"],!1],1,.3]),this.map.setPaintProperty(r,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],1,.3]),i.forEach((i=>{this.map.setFeatureState({source:t,id:w(i.modelId)},{highlighted:i.modelId===e})})))}fadeOtherMarkers(t){this.markerLayerIds.filter((e=>!e.startsWith(t))).forEach((t=>{this.map.setPaintProperty(t,"icon-opacity",.3),this.map.setPaintProperty(t,"text-opacity",.3)}))}repositionMap(t,e){let i,r=20;void 0!==t.lngLat?(i=new u.LngLatBounds(t.lngLat,t.lngLat),r=40):void 0!==t.anchorPoints?i=this.getElementBounds(this.flattenCoordinates(t.anchorPoints)):void 0!==t.center&&void 0!==t.radius&&(i=this.getElementBounds(q(t.center,t.radius)));const n=document.querySelector(".mc-popup");if(n){const t=new ResizeObserver((()=>{i&&this.panToElement(i,r,e),t.disconnect()}));t.observe(n)}}getElementBounds(t){const e=new u.LngLatBounds(t[0],t[0]);for(const i of t)e.extend(i);return e}flattenCoordinates(t){return Array.isArray(t[0][0])?t.flat():t}panToElement(t,e,i){const r=this.map.projectWithScaleCorrection(t.getSouthWest()),n=this.map.projectWithScaleCorrection(t.getNorthEast()),o=this.map.getContainer().clientWidth,s=this.map.getContainer().clientHeight,a=o>600,l=document.querySelector(".mc-popup")?.getBoundingClientRect(),c=l?.width??0;let h=l?.height??0;a||(h=Math.min(h,s/2));const u=s-r.y>h+e,d=r.x>e+("bottomLeft"===i&&a&&!u?c:0),p=n.x<o-e,f=n.y>e,m=a?r.y<s-e:u;if(!(d&&p&&f&&m))if(n.x-r.x+2*e<o&&r.y-n.y+2*e<s){const e=t.getCenter();this.map.easeTo({center:e,duration:500})}else this.map.fitBounds(t,{padding:e,maxZoom:this.map.getZoom(),duration:500,linear:!0})}}class Ct{map;popupPosition="bottomLeft";mapContainer;popupContainer;feature;currentFeatureId;currentModelId;popupElements=[];language="en";promoteIdCache=new Map;publication;floatingPopup;registry;highlightManager;exportPreview;restrictMapMovement;center;constructor(t,e){this.map=t,this.exportPreview=e,this.mapContainer=this.map.getContainer(),this.popupContainer=document.createElement("div"),this.popupContainer.classList.add("popup-container"),this.map.on("mousemove",(t=>this.onMouseMove(t))),this.map.on("click",(t=>this.onClick(t)))}setJobObject(t){this.registry=new Mt(t)}setParams(t,e,i,r){this.popupPosition=t,this.language=e,this.restrictMapMovement=i,this.center=r}setPublication(t){this.publication=t}setpopupElements(){this.popupElements=this.registry.getPopupElements()}setHighlightManager(){this.highlightManager=new It(this.map,this.registry.getPopupElements())}onMouseMove(t){this.feature=this.getInteractiveFeature(t),this.feature?this.map.getCanvas().style.cursor="pointer":this.map.getCanvas().style.cursor=""}onClick(t){this.feature=this.getInteractiveFeature(t),this.currentModelId=this.feature?.properties?.id,!this.feature||this.mapContainer.contains(this.popupContainer)&&this.feature?.id===this.currentFeatureId?(this.hidePopup(),this.highlightManager.highlight(void 0)):(this.addPopup(t),this.highlightManager.highlight(this.getPopupElementFromFeature(this.feature),this.popupPosition))}getPopupElementFromFeature(t){return this.popupElements.find((e=>e.modelId===t.properties.id))}getInteractiveFeature(t){return this.map.queryRenderedFeatures(t.point).find((t=>{if(Object.keys(t.layer.metadata??{}).some((t=>t.startsWith("mc-interactivity-template"))))return!0;const e=this.registry.getModel(t);return!!(e?.popup??e?.popupMedia)}))}addPopup(t){if(!this.feature)return;this.floatingPopup?.remove();const e=Number(this.feature.id);this.currentFeatureId=isNaN(e)?this.feature.id:e;const i=this.getTemplate(this.feature);if(!i)return;if("mapElement"===this.popupPosition){if("Point"===this.feature.geometry.type)this.addFloatingPopup(i,this.feature.geometry.coordinates);else{const{lng:e,lat:r}=this.map.unproject(t.point);this.addFloatingPopup(i,[e,r])}return}this.popupContainer.innerHTML=i;this.popupElements.find((t=>t.modelId===this.currentModelId))&&this.addPopupControls(),this.mapContainer.appendChild(this.popupContainer)}addFloatingPopup(t,e){const i=this.restrictMapMovement?this.getAnchor(e):void 0;this.floatingPopup=new u.Popup({anchor:i,maxWidth:"none",closeButton:!1,offset:20}).setLngLat(e).setHTML(t).addTo(this.map)}getAnchor(t){const e=this.map.projectWithScaleCorrection(t),i=this.map.getContainer().clientWidth,r=this.map.getContainer().clientHeight;let n,o;return n=e.y<.33*r?"top":e.y>.66*r?"bottom":"center",o=e.x<.33*i?"left":e.x>.66*i?"right":"center","center"===n&&"center"===o?"bottom":"center"===n?o:"center"===o?n:`${n}-${o}`}hidePopup(){this.popupContainer&&(this.popupContainer.remove(),this.feature=void 0,this.currentFeatureId=void 0),this.restrictMapMovement&&this.center&&this.map.easeTo({center:this.center})}getTemplate(t){const{layer:e}=t;let i;const r=this.registry.getModel(t);if(r?.popup||r?.popupMedia)i=St(r.popup,r.popupMedia,r.dataBindings??{},this.exportPreview);else{const r=[];this.publication&&(r.push(`:${this.publication}-${this.language}`),r.push(`:${this.publication}-:en`)),r.push(`:${this.language}`),r.push(":en"),r.push("");for(const n of r){const r=e.metadata?.[`mc-interactivity-template${n}`];if(r){i=this.fillDatalayerTemplate(t,r,n);break}}i&&(i=`\n <div class="popup-scroll-wrapper">\n <div class="mc-popup data-layer text-content">${i}</div>\n </div>\n `)}return i}htmlToElement(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}addPopupControls(){const t=this.htmlToElement('\n <button class="mc-popup-button close">\n <svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="currentColor"><path d="M.21.71a.714.714 0 0 1 1.011 0l3.78 3.78L8.778.71a.715.715 0 0 1 1.013 1.01L6.01 5.501l3.78 3.778a.715.715 0 0 1-1.01 1.012L5 6.51l-3.779 3.78A.716.716 0 0 1 .21 9.28L3.99 5.5.21 1.721A.714.714 0 0 1 .21.71"/></svg>\r\n\n </button>\n');if(t&&(t.addEventListener("click",(()=>{this.hidePopup(),this.highlightManager.highlight(void 0)})),this.popupContainer.appendChild(t)),this.popupElements.length<2)return;const e=this.htmlToElement('\n <div class="cycle-buttons">\n <button class="mc-popup-button prev">\n <svg viewBox="0 0 31 31" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="m12.223 15.5 4.281 4.4a.814.814 0 1 0 1.167-1.134L14.493 15.5l3.178-3.266a.814.814 0 1 0-1.167-1.135z"/></svg>\r\n\n </button>\n <button class="mc-popup-button next">\n <svg viewBox="0 0 31 31" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="m18.777 15.5-4.281 4.4a.814.814 0 1 1-1.167-1.134l3.178-3.266-3.178-3.266a.814.814 0 1 1 1.167-1.135z"/></svg>\r\n\n </button>\n </div>\n');e&&(e.querySelector(".prev")?.addEventListener("click",(()=>this.cyclePopups(!1))),e.querySelector(".next")?.addEventListener("click",(()=>this.cyclePopups())),this.popupContainer.appendChild(e))}fillDatalayerTemplate(t,e,i){const r="data-mention-id",n=(new DOMParser).parseFromString(e,"text/html").body;for(const e of n.querySelectorAll(`[${r}]`)){const n=this.getProperty(t,e.getAttribute(r),i);void 0!==n&&(e.innerText=n)}return n.innerHTML}getProperty(t,e,i){if(!e)return;const r=e.endsWith(":en")?[e.replace(":en",i),e]:[e];for(const e of r){const i=t.properties[e]??this.getVectorProperty(t,e);if(void 0!==i)return i}}getVectorProperty(t,e){let i=this.promoteIdCache.get(t.source);void 0===i&&(i=this.map.getSource(t.source)?.serialize().promoteId||"id",this.promoteIdCache.set(t.source,i));try{const r=t.properties[i];return t.layer.metadata.properties[e][r]}catch(t){return}}cyclePopups(t=!0){const e=this.popupElements?.findIndex((t=>t.modelId===this.currentModelId));if(-1!==e){let i=0;i=t?e===this.popupElements.length-1?0:e+1:0===e?this.popupElements.length-1:e-1;const r=this.popupElements?.[i];this.highlightManager.highlight(r,this.popupPosition);const n=St(r.popup,r.popupMedia,r.dataBindings??{},this.exportPreview),o=this.popupContainer;this.popupContainer.remove(),o.innerHTML=n,this.mapContainer.appendChild(o),this.currentModelId=r.modelId,this.addPopupControls(),t?this.popupContainer.querySelector(".mc-popup-button.next")?.focus():this.popupContainer.querySelector(".mc-popup-button.prev")?.focus(),this.currentFeatureId=void 0}}}function At(t,e,i){return"en"!==i&&"native"!==i&&(i=m(i,p.TWO)),"native"===i?["get","name"]:"mc-base"===t&&["lines","points","places","labelcentroid"].includes(e??"")?["coalesce",["get",`name:${i}`],["case",["has","name_is_latin"],["get","name"],["get","name:en"]]]:["coalesce",["get",`name:${i}`],["get","name:en"],["get","name"]]}async function Et(t,e,i){const r=t.map((t=>`${g.vectorApiUrl}styles/${t}.json?access_token=${i}`)).map((t=>fetch(t).then((t=>t.json())))),n=await Promise.all(r);await Promise.all(n.map((t=>async function(t,e,i){for(const i in t.sources)void 0===e.getSource(i)&&e.addSource(i,t.sources[i]);void 0!==t.sprite&&await async function(t,e,i){try{const r=`${e}.json?access_token=${i}`,n=`${e}.png?access_token=${i}`,[o,s]=await Promise.all([fetch(r),fetch(n)]);if(!o.ok||!s.ok)throw new Error(`Failed to load sprite from ${e}`);const a=await o.json(),l=await s.blob(),c=await new Promise(((t,e)=>{const i=new Image;i.onload=()=>t(i),i.onerror=t=>e(t),i.src=URL.createObjectURL(l)})),h=document.createElement("canvas"),u=h.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("Failed to get canvas context");for(const[e,i]of Object.entries(a)){if(t.hasImage(e))continue;const{x:r,y:n,width:o,height:s,pixelRatio:a}=i;h.width=o*a,h.height=s*a,u.clearRect(0,0,h.width,h.height),u.drawImage(c,r,n,o,s,0,0,h.width,h.height);const l=u.getImageData(0,0,h.width,h.height);t.addImage(e,l,{pixelRatio:a})}}catch(t){console.error(t)}}(e,(r=t.sprite,s()?l(r):a()?c(r):r),i);var r;for(const i of t.layers){void 0!==e.getLayer(i.id)&&e.removeLayer(i.id);const t=i.metadata?.["mc-add-before"]??"mc-before-none";e.addLayer(i,t)}}(t,e,i))))}function kt(t){const e=document.createElement("button");return e.className=t.className,e.innerHTML=`${t.content}`,e.addEventListener("click",t.onClick),e}function zt(t){return kt({type:"button",className:"control-button fullscreen-control-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M4.774 6.44a.556.556 0 0 1 .832.734l-.047.052L2.897 9.89h1.436a.555.555 0 0 1 .065 1.107L4.333 11H1.556a.556.556 0 0 1-.552-.49L1 10.443V7.667a.556.556 0 0 1 1.107-.065l.004.065v1.436l2.663-2.662ZM10.444 1a.555.555 0 0 1 .552.49l.004.066v2.777a.556.556 0 0 1-1.107.065l-.004-.065V2.897L7.226 5.559a.556.556 0 0 1-.832-.733l.047-.052L9.103 2.11H7.667a.556.556 0 0 1-.065-1.107L7.667 1h2.777Z"/></svg>\r\n',onClick:()=>{const e=t.getContainer();if(Boolean(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled))!function(t){return document.fullscreenElement===t||document.webkitFullscreenElement===t||document.mozFullScreenElement===t||document.msFullscreenElement===t}(e)?function(t){t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}(e):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();else{let t=document.location.href;t+=t.includes("?")?"&":"?",t+="close-tab",window.open(t,"_blank")}}})}const Lt=t=>{t.getSource("location-circle")||t.addSource("location-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.getSource("location-dot")||t.addSource("location-dot",{type:"geojson",data:{type:"Feature",geometry:{type:"Point",coordinates:[]},properties:{}}}),t.getLayer("location-circle")||t.addLayer({id:"location-circle",type:"fill",source:"location-circle",layout:{},paint:{"fill-color":"#349CF2","fill-opacity":.15,"fill-outline-color":"#005196"}},"mc-before-names"),t.getLayer("location-dot")||t.addLayer({id:"location-dot",type:"symbol",source:"location-dot",layout:{"icon-padding":0},paint:{"icon-opacity":1},metadata:{"mc-name":"location dot","mc-skip-load":!0}},"mc-before-names"),(t=>{const e=2*window.devicePixelRatio,i=new ut(t).getMapLibreImageKey('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><circle cx="16" cy="16" r="10" fill="#349CF2"/><circle cx="16" cy="16" r="9" stroke="#fff" stroke-width="2"/></g><defs><filter id="a" x="0" y="0" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="4"/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_15_3175"/><feBlend in="SourceGraphic" in2="effect1_dropShadow_15_3175" result="shape"/></filter></defs></svg>\r\n',e);t.setLayoutProperty("location-dot","icon-image",i)})(t)};function Dt(t){let e=!1;const i=t=>{const i=document.querySelector(".geolocation-button"),r=i?.querySelector(".geolocation-icon"),n=i?.querySelector(".locating-icon");r&&n&&(r.classList.toggle("active",!t),n.classList.toggle("active",t)),e=t},r=e=>{const{longitude:r,latitude:n,accuracy:o}=e.coords,s=[r,n];t.easeTo?t.easeTo({center:s,zoom:19,duration:1e3}):t.setCenter&&t.setCenter(s);const a=t.getSource("location-circle");a&&a.setData(((t,e,i)=>{const r=i/1e3,n=[],o=r/(111.32*Math.cos(e*Math.PI/180)),s=r/110.574;for(let i=0;i<64;i++){const r=i/64*(2*Math.PI),a=o*Math.cos(r),l=s*Math.sin(r);n.push([t+a,e+l])}return n.push(n[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[n]}}]}})(r,n,o/2)),((t,e,i)=>{const r=t.getSource("location-dot");r&&r.setData({type:"Feature",geometry:{type:"Point",coordinates:[e,i]},properties:{}})})(t,r,n),t.once("moveend",(()=>i(!1)))},n=t=>{console.error("Geolocation error:",t),i(!1)};return kt({type:"button",className:"control-button geolocation-button",content:'\n <div class="location-icon geolocation-icon active"><svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.571.875V0h.858v.875a5.143 5.143 0 0 1 4.696 4.696H12v.858h-.875a5.143 5.143 0 0 1-4.696 4.696V12H5.57v-.875A5.143 5.143 0 0 1 .875 6.429H0V5.57h.875A5.143 5.143 0 0 1 5.571.875Zm0 .86a4.286 4.286 0 0 0-3.835 3.836h.835v.858h-.835a4.286 4.286 0 0 0 3.835 3.835V9.43h.858v.835a4.285 4.285 0 0 0 3.835-3.835H9.43v-.86h.835A4.285 4.285 0 0 0 6.43 1.736v.835h-.86v-.835Zm-.177 3.659a.857.857 0 1 1 1.212 1.212.857.857 0 0 1-1.212-1.212Z"/></svg>\r\n</div>\n <div class="location-icon locating-icon"><svg width="34" viewBox="5 5 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#343A40"><path d="M15.016 22.656a5.797 5.797 0 0 1-1.016-.46c-2.858-1.65-3.846-5.338-2.196-8.196 1.65-2.858 5.338-3.846 8.196-2.196 2.858 1.65 3.846 5.338 2.196 8.196-.2.346-.434.673-.694.962l2.933 2.72A10.1 10.1 0 0 0 25.66 22c2.75-4.763 1.103-10.91-3.66-13.66S11.09 7.237 8.34 12 7.237 22.91 12 25.66a9.61 9.61 0 0 0 1.635.748l1.381-3.752Z"/><path d="m11.01 17.183-3.999.06a10.051 10.051 0 0 0 6.427 9.097l1.484-3.714a6.025 6.025 0 0 1-3.913-5.443Zm13.284 5.183 1-1.732-2.598-1.5-1 1.732 2.598 1.5Zm-3.428-10.062 1.5-2.598-1.732-1-1.5 2.598 1.732 1Zm-9.562 2.562 1-1.732-2.598-1.5-1 1.732 2.598 1.5Z"/><path d="m13.366 25.294 1.5-2.598-1.732-1-1.5 2.598 1.732 1Z"/></g><defs><clipPath id="a"><path fill="#fff" d="m33.393 12.607-12 20.784-20.785-12 12-20.784z"/></clipPath></defs></svg>\r\n</div>\n ',onClick:()=>{if(!e){if(t.getSource("location-circle")||Lt(t),i(!0),!navigator.geolocation)return(()=>{const t=document.querySelector(".map"),e=document.createElement("div");e.classList.add("location-notification"),e.textContent="Geolocation is not available",t?.appendChild(e),setTimeout((()=>{t?.removeChild(e)}),3e3)})(),void i(!1);navigator.geolocation.getCurrentPosition(r,n,{maximumAge:6e4,timeout:5e3})}}})}function Rt(t,e,i){const r=document.createElement("div");r.className="web-control";const n=t.buttons.flatMap((t=>"zoom"===t?["zoomIn","zoomOut"]:t));return(navigator.userAgent.toLowerCase().indexOf("mobile")>=0?n.filter((t=>"zoomIn"!==t&&"zoomOut"!==t)):n).forEach((t=>{let n;if("zoomIn"===t)n=function(t){return kt({type:"button",className:"control-button zoom-in-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.714H6.714V11H5.286V6.714H1V5.286h4.286V1h1.428v4.286H11v1.428Z"/></svg>\r\n',onClick:()=>t.zoomIn()})}(e);else if("zoomOut"===t)n=function(t){return kt({type:"button",className:"control-button zoom-out-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.144H1v-1h10v1Z"/></svg>\r\n',onClick:()=>t.zoomOut()})}(e);else if("fullscreen"===t)n=zt(e);else if("geolocation"===t)n=Dt(e);else{if("refresh"!==t)return;n=function(t,e){return kt({type:"button",className:"control-button refresh-button",content:'<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.155 1.146A.546.546 0 0 1 6.53 1c.14 0 .275.053.375.146l1.588 1.5c.1.094.155.221.155.354 0 .132-.056.26-.155.353l-1.588 1.5a.546.546 0 0 1-.373.14.545.545 0 0 1-.37-.146.487.487 0 0 1-.154-.349.486.486 0 0 1 .148-.352L6.84 3.5H6c-1.878 0-3.441 1.476-3.441 3.25S4.122 10 6 10s3.441-1.476 3.441-3.25c0-.133.056-.26.155-.354a.546.546 0 0 1 .375-.146c.14 0 .275.053.374.146.1.094.155.221.155.354C10.5 9.076 8.463 11 6 11S1.5 9.076 1.5 6.75 3.537 2.5 6 2.5h.84l-.685-.647A.486.486 0 0 1 6 1.5c0-.133.056-.26.155-.354Z"/></svg>\r\n',onClick:()=>{const i=t.getContainer();let r=0;if(i.clientWidth>0&&i.clientHeight>0){const t=Math.min(i.clientWidth/e.width,i.clientHeight/e.height);r=Math.log(t)/Math.LN2}t.easeTo({center:e.center,zoom:e.zoom-e.detailLevel+r,pitch:e.pitch,bearing:e.rotation})}})}(e,i.initialPosition)}r.appendChild(n)})),r}class Ft extends h{map;svgCache;popupManager;constructor(t={},e={}){super(t,e),function(t){t.transformRequest||(s()?t.transformRequest=t=>({url:l(t)}):a()&&(t.transformRequest=t=>({url:c(t)})))}(this.mapOptions),this.map=new u.Map(this.mapOptions),this.map.getContainer().classList.add("mapcreatorgl-map"),this.svgCache=new ut(this.map),this.popupManager=new Ct(this.map,this.mapOptions.exportPreview)}static get defaultMapOptions(){return{...super.defaultMapOptions,attributionControl:!1,mcAccessToken:g.accessToken,maxBounds:[-1/0,-90,1/0,90]}}static get defaultOptions(){return{...super.defaultOptions}}get favicon(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAAAFBlWElmTU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAtKADAAQAAAABAAAAtAAAAABECLhnAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAE/ElEQVR4Ae3dTU4jVxgFUAMt0XFCoizBU7OE7H8FSJ6yC+eHH6cKQYsMeJ2B7w1POZZKLvPc332cukY9KdhsPAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAIHN5gICge8InL6z/mmWt9vt5nK3260bThzpb/Tse97v9+mLd/Y9p5Fnm38524btl8BIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbToBhZ7uktnwSEChRzrWphNQ6OkumQ2PBBR6pGNtOgGFnu6S2fBIQKFHOtamE1Do6S6ZDY8EFHqkY206AYWe7pLZ8EhAoUc61qYTUOjpLpkNjwQUeqRjbTqBL9Pt2IbbAtP8ZoDj8bjxE7pdD3lRAYWO8hreFlDotri8qIBCR3kNbwsodFtcXlRAoaO8hrcFFLotLi8qoNBRXsPbAgrdFpcXFVDoKK/hbQGFbovLiwoodJTX8LaAQrfF5UUFFDrKa3hbQKHb4vKiAgod5TW8LaDQbXF5UQGFjvIa3hZQ6La4vKiAQkd5DW8LKHRbXF5UYOa7vs9+N/LhcIhiG54X8BM6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKAoodBFbVF5AofPGEooCCl3EFpUXUOi8sYSigEIXsUXlBRQ6byyhKKDQRWxReQGFzhtLKArM/Le+i0z/36jT6fTtb6pfXFycPruEQn/2K/Qf7+/29vb5bQv7/f7tdH3+czn+en3+/fV8ff3Hu/O39fX5YTne/s16/rb2sHxoHtfXl5eXL+fvXj++nj8sH6b1/Gk5Hpb3rc8va+v5+ri6unq8vr5+UuhF0uNjgcPh8NHi9bKwHjcfvaH99e12u/F/6La6vKiAQkd5DW8LKHRbXF5UQKGjvIa3BRS6LS4vKqDQUV7D2wIK3RaXFxVQ6Civ4W0BhW6Ly4sKKHSU1/C2gEK3xeVFBRQ6ymt4W0Ch2+LyogIKHeU1vC2g0G1xeVEBhY7yGt4WUOi2uLyogEJHeQ1vCyh0W1xeVECho7yGtwW+LHfy/nZzc/N1uYv2ejm+LnfX/rAc2+fn55fnZUM/LsdP745flvP1xsifX49fX5//8eG4u7tbvuzxXmC3271/eZbz+/v7s8wZDPn2awwG7/kUS8fjcXPWzS4fiHXey7F8KJ4+xXdpEwQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBA4N8I/A1O6KkX0GDoIwAAAABJRU5ErkJggg=="}async load(t){const{map:e,export:i,registry:r,web:n,adornments:o,title:s}=t,{language:a,zoom:l,pitch:c,rotation:h,center:d,layerInfo:f,detailLevel:_}=e,{models:x,slots:v,svgs:b}=r;y.locale=m(a,p.LOCALE);const w=m(a,p.TWO);document.body.parentElement.lang=w,this.loadFontFaces(),this.map.resize(),document.title=`${s??"Project title"} - Mapcreator`;const T={duration:0};this.map.setPitch(c,T),this.map.setBearing(h,T);const S=M(i.unit,"pixel",i.size[0]),P=M(i.unit,"pixel",i.size[1]),I=this.map?.getContainer();let C=0;if(I.clientWidth>0&&I.clientHeight>0){const t=Math.min(I.clientWidth/S,I.clientHeight/P);C=Math.log(t)/Math.LN2}if(this.map.setZoom(l-e.detailLevel+C,T),this.map.setCenter(d,T),this.map.setDetailLevel(_),this.map.addControl(new u.AttributionControl({compact:!1})),function(){try{return window.self!==window.top}catch(t){return!0}}()&&this.map.cooperativeGestures.enable(),o&&function(t,e,i){let r=document.getElementById("adornments-container");r||(r=document.createElement("div"),r.id="adornments-container",r.className="adornments-container",e.getContainer().appendChild(r)),r.innerHTML="",t.forEach((t=>{if("copyright"!==t.type)if("custom"===t.type&&t.svg){const e=document.createElement("div");e.className="adornment",e.innerHTML=t.svg,r.appendChild(e)}else if("webControls"===t.type&&t.buttons){const n=Rt(t,e,i);r.appendChild(n)}}))}(o,this.map,{initialPosition:{center:d,zoom:l,pitch:c,rotation:h,detailLevel:e.detailLevel,width:S,height:P}}),this.popupManager.setJobObject(t),n){const{restrictMapMovement:t,popupPosition:e}=n;t&&(this.map.boxZoom.disable(),this.map.doubleClickZoom.disable(),this.map.dragPan.disable(),this.map.dragRotate.disable(),this.map.keyboard.disable(),this.map.scrollZoom.disable(),this.map.touchPitch.disable(),this.map.touchZoomRotate.disable()),this.popupManager.setParams(e,w,t,d)}const A=`${g.vectorApiUrl}styles/${t.meta.mapstyleSet}.json?access_token=${this.mapOptions.mcAccessToken}`,E=await fetch(A).then((t=>t.json()));this.map.once("style.load",(async()=>{this.options.libraryMode||this.setCustomStyle(this.map.getStyle().metadata?.customCssFilePath),function(t,e){for(const i of e.getStyle().layers){if("symbol"!==i.type||i.id.startsWith("custom-")||i.id.startsWith("gl-"))continue;const r=i.layout&&i.layout["text-field"];i["source-layer"]&&Array.isArray(r)&&"coalesce"===r[0]&&!r.find((t=>"name:abbr"===t[1]))&&e.setLayoutProperty(i.id,"text-field",At(i.source,i["source-layer"],t),{validate:!1})}}(a,this.map),await Et(t.meta.layers??[],this.map,this.mapOptions.mcAccessToken),this.addModels(x,v,b,this.mapOptions.mcAccessToken),this.popupManager.setPublication(E.metadata?.publication),this.popupManager.setpopupElements(),this.popupManager.setHighlightManager(),this.setLayerVisibility(this.map.getStyle(),f)})),this.map.setStyle(null),this.map.setStyle(E)}loadFontFaces(){if(!this.mapOptions.mcAccessToken)return;const t=a()?"b-":"",e=`${g.vectorApiUrl}/stylesheets/ff-${t}${this.mapOptions.mcAccessToken}.css?access_token=${this.mapOptions.mcAccessToken}`,i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",e),i.setAttribute("type","text/css"),document.head.appendChild(i)}setCustomStyle(t){if(document.getElementById("custom-style")?.remove(),!t)return;let e;t.startsWith("http")?(t=`${t}?access_token=${this.mapOptions.mcAccessToken}`,e=document.createElement("link"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",t.replace(/https?:/,""))):(e=document.createElement("style"),e.appendChild(document.createTextNode(t))),e.setAttribute("id","custom-style"),e.setAttribute("type","text/css"),document.head.appendChild(e)}setLayerVisibility(t,e){for(const i of e){const e=t.layers.find((t=>i.id===t.id||i.id.endsWith(` | ${t.id}`)));e&&this.map.setLayoutProperty(e.id,"visibility",i.visibility?"visible":"none")}}addModels(t,e,i,r){const{beforeNone:n,beforeNames:o,beforeBoundaries:s,beforeWaters:a}=e;n.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-none",r)})),o.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-names",r)})),s.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-boundaries",r)})),a.forEach((e=>{this.addModelsByType(t,e,i,"mc-before-waters",r)}))}addModelsByType(t,e,i,r,n){if("marker"===e.type){const n=t.marker?.find((t=>t.id===e.groupId));n&&function(t,e,i,r,n){const o=[],s=new Set,a=new Set;xt=window.devicePixelRatio*t.getScale();const l=["match",["get","text-font"]];for(const t of e.models)(t.visible??1)&&o.push(bt(t,e,r,n)),s.add(t.textFont),a.add(t.textLineHeight??1.2);if(Array.from(s).length>0){for(const t of Array.from(s))l.push(t,["literal",[t,vt]]);l.push(["literal",[vt]])}t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:o}}),a.forEach((r=>{t.addLayer({id:`${e.id}-${r}`,type:"symbol",source:e.id,metadata:{"mc-model-type":"marker","mc-group-id":e.id},layout:{"icon-allow-overlap":!e.collisionDetection,"icon-ignore-placement":!e.collisionDetection,"text-allow-overlap":!e.collisionDetection,"text-ignore-placement":!e.collisionDetection,"icon-image":["get","mc-image-key"],"icon-anchor":["get","icon-anchor"],"icon-size":["get","icon-size"],"icon-rotate":["get","icon-rotate"],"icon-offset":["get","icon-offset"],"text-field":"{text}","text-font":l,"text-max-width":["get","text-max-width"],"text-offset":["get","text-offset"],"text-rotate":["get","text-rotate"],"text-size":["get","text-size"],"text-anchor":["get","text-anchor"],"text-letter-spacing":["get","text-letter-spacing"],"text-line-height":r,"text-justify":["get","text-justify"]},paint:{"text-color":["get","text-color"],"text-halo-color":["get","text-halo-color"],"text-halo-width":["get","text-halo-width"]},filter:["==",["get","text-line-height"],r]},i)}))}(this.map,n,r,i,this.svgCache)}else if("polygon"===e.type){const n=t.polygon?.find((t=>t.id===e.groupId));n&&Q(this.map,n,r,i,this.svgCache)}else if("circle"===e.type){const n=t.circle?.find((t=>t.id===e.groupId));n&&J(this.map,n,r,i,this.svgCache)}else if("line"===e.type){const i=t.line?.find((t=>t.id===e.groupId));i&&C(this.map,i,r)}else if("dot"===e.type){const i=t.dot?.find((t=>t.id===e.groupId));i&&function(t,e,i){t.addSource(e.id,{type:"geojson",data:{type:"FeatureCollection",features:e.models.filter((t=>t.visible??!0)).map((t=>{return{type:"Feature",id:(e=t).id,properties:{id:e.id,"circle-radius":e.radius,"circle-color":e.fillColor??"#000000"},geometry:{type:"Point",coordinates:[e.center.lng,e.center.lat]}};var e}))}}),t.addLayer({id:e.id,type:"circle",source:e.id,metadata:{"mc-model-type":"dot","mc-group-id":e.id},paint:{"circle-color":["get","circle-color"],"circle-radius":["get","circle-radius"]}},i)}(this.map,i,r)}else if("area"===e.type){const o=t.area?.find((t=>t.id===e.groupId));o&&function(t,e,i,r,n,o,s){const a=new Map,l=new Map;for(const t of e.models){const i=t.id,o=e.id,s=[],c=Y(t),h=K(o,t),u=l.get(h)??{model:t,modelIds:s,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{}};if(t.visible??1){u.modelIds.push(Number(i));const e=void 0!==t.fillPattern?n.getMapLibreImageKey(r[t.fillPattern],2*window.devicePixelRatio):null;u.modelIdToFillColor[i]=t.fillColor??"#ffffff",u.modelIdToFillPattern[i]=e,u.modelIdToOutlineColor[i]=t.outlineColor??"#000000"}a.set(c,t),l.set(h,u)}for(const e of a.keys())t.getSource(e)||t.addSource(e,{type:"vector",url:`${o}${a.get(e).vectorUrl}?access_token=${s}`});for(const r of l.keys()){const{model:n}=l.get(r),{sourceLayerId:o}=n,s=Y(n);t.addLayer({id:r,type:"fill",source:s,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-color":"#ffffff","fill-outline-color":"#000000"}},i),t.addLayer({id:`${r}-pattern`,type:"fill",source:s,"source-layer":o,filter:["literal",!1],metadata:{"mc-model-type":"area","mc-group-id":e.id},paint:{"fill-pattern":["get","fill-pattern"]},layout:{visibility:"visible"}},i)}l.forEach(((e,i)=>{const{modelIds:r,modelIdToFillColor:n,modelIdToFillPattern:o,modelIdToOutlineColor:s}=e;t.setFilter(i,["in","id",...r]),t.setPaintProperty(i,"fill-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",n]]),t.setPaintProperty(i,"fill-outline-color",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",s]]),t.setFilter(`${i}-pattern`,["to-boolean",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]]]),t.setPaintProperty(`${i}-pattern`,"fill-pattern",["get",["case",["==",["typeof",["get","id"]],"number"],["to-string",["get","id"]],["get","id"]],["literal",o]])}))}(this.map,o,r,i,this.svgCache,g.vectorApiUrl,n)}}}async function Bt(t){const{jobId:e,container:i,accessToken:r,env:n,exportPreview:s}=t;!function(t){o=t}(n);let a="";"development"===n||"bleeding"===n?a=".bleeding":"beta"===n&&(a=".beta");const l=t.job??await fetch(`https://cdn${a}.mapcreator.io/jobs/${e}.json?access_token=${r}`).then((t=>t.json())),c=new Ft({libraryMode:!0},{mcAccessToken:r,container:i,exportPreview:s});return await c.load(l),c.map}export{Bt as init};
|