diff --git a/asset-manifest.json b/asset-manifest.json deleted file mode 100644 index 73efc73..0000000 --- a/asset-manifest.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "files": { - "main.css": "/static/css/main.e6c13ad2.css", - "main.js": "/static/js/main.73c71367.js", - "static/js/592.0f02dbe8.chunk.js": "/static/js/592.0f02dbe8.chunk.js", - "index.html": "/index.html", - "main.e6c13ad2.css.map": "/static/css/main.e6c13ad2.css.map", - "main.73c71367.js.map": "/static/js/main.73c71367.js.map", - "592.0f02dbe8.chunk.js.map": "/static/js/592.0f02dbe8.chunk.js.map" - }, - "entrypoints": [ - "static/css/main.e6c13ad2.css", - "static/js/main.73c71367.js" - ] -} \ No newline at end of file diff --git a/favicon-16x16.png b/favicon-16x16.png deleted file mode 100644 index 8c63501..0000000 Binary files a/favicon-16x16.png and /dev/null differ diff --git a/favicon-32x32.png b/favicon-32x32.png deleted file mode 100644 index 04c978e..0000000 Binary files a/favicon-32x32.png and /dev/null differ diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index 8fcb8f8..0000000 Binary files a/favicon.ico and /dev/null differ diff --git a/index.html b/index.html deleted file mode 100644 index d3fd19e..0000000 --- a/index.html +++ /dev/null @@ -1 +0,0 @@ -React App
\ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 080d6c7..0000000 --- a/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/open.JPG b/open.JPG deleted file mode 100644 index c424e0c..0000000 Binary files a/open.JPG and /dev/null differ diff --git a/open.png b/open.png deleted file mode 100644 index 4a54a47..0000000 Binary files a/open.png and /dev/null differ diff --git a/robots.txt b/robots.txt deleted file mode 100644 index e9e57dc..0000000 --- a/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/static/css/main.e6c13ad2.css b/static/css/main.e6c13ad2.css deleted file mode 100644 index 50410fa..0000000 --- a/static/css/main.e6c13ad2.css +++ /dev/null @@ -1,2 +0,0 @@ -body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace} -/*# sourceMappingURL=main.e6c13ad2.css.map*/ \ No newline at end of file diff --git a/static/css/main.e6c13ad2.css.map b/static/css/main.e6c13ad2.css.map deleted file mode 100644 index 5c4dfb9..0000000 --- a/static/css/main.e6c13ad2.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"static/css/main.e6c13ad2.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF","sources":["index.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/592.0f02dbe8.chunk.js b/static/js/592.0f02dbe8.chunk.js deleted file mode 100644 index 1cc7463..0000000 --- a/static/js/592.0f02dbe8.chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";(self.webpackChunkInfraWeb=self.webpackChunkInfraWeb||[]).push([[592],{592:(e,t,n)=>{n.r(t),n.d(t,{getCLS:()=>y,getFCP:()=>g,getFID:()=>C,getLCP:()=>P,getTTFB:()=>D});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTimeperformance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]); -//# sourceMappingURL=592.0f02dbe8.chunk.js.map \ No newline at end of file diff --git a/static/js/592.0f02dbe8.chunk.js.map b/static/js/592.0f02dbe8.chunk.js.map deleted file mode 100644 index 9f109cf..0000000 --- a/static/js/592.0f02dbe8.chunk.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"static/js/592.0f02dbe8.chunk.js","mappings":"oLAAA,IAAIA,EAAEC,EAAEC,EAAEC,EAAEC,EAAE,SAASJ,EAAEC,GAAG,MAAM,CAACI,KAAKL,EAAEM,WAAM,IAASL,GAAG,EAAEA,EAAEM,MAAM,EAAEC,QAAQ,GAAGC,GAAG,MAAMC,OAAOC,KAAKC,MAAM,KAAKF,OAAOG,KAAKC,MAAM,cAAcD,KAAKE,UAAU,MAAM,EAAEC,EAAE,SAAShB,EAAEC,GAAG,IAAI,GAAGgB,oBAAoBC,oBAAoBC,SAASnB,GAAG,CAAC,GAAG,gBAAgBA,KAAK,2BAA2BoB,MAAM,OAAO,IAAIlB,EAAE,IAAIe,qBAAqB,SAASjB,GAAG,OAAOA,EAAEqB,aAAaC,IAAIrB,EAAE,IAAI,OAAOC,EAAEqB,QAAQ,CAACC,KAAKxB,EAAEyB,UAAS,IAAKvB,CAAC,CAAC,CAAC,MAAMF,GAAG,CAAC,EAAE0B,EAAE,SAAS1B,EAAEC,GAAG,IAAIC,EAAE,SAASA,EAAEC,GAAG,aAAaA,EAAEqB,MAAM,WAAWG,SAASC,kBAAkB5B,EAAEG,GAAGF,IAAI4B,oBAAoB,mBAAmB3B,GAAE,GAAI2B,oBAAoB,WAAW3B,GAAE,IAAK,EAAE4B,iBAAiB,mBAAmB5B,GAAE,GAAI4B,iBAAiB,WAAW5B,GAAE,EAAG,EAAE6B,EAAE,SAAS/B,GAAG8B,iBAAiB,YAAY,SAAS7B,GAAGA,EAAE+B,WAAWhC,EAAEC,EAAE,IAAG,EAAG,EAAEgC,EAAE,SAASjC,EAAEC,EAAEC,GAAG,IAAIC,EAAE,OAAO,SAASC,GAAGH,EAAEK,OAAO,IAAIF,GAAGF,KAAKD,EAAEM,MAAMN,EAAEK,OAAOH,GAAG,IAAIF,EAAEM,YAAO,IAASJ,KAAKA,EAAEF,EAAEK,MAAMN,EAAEC,IAAI,CAAC,EAAEiC,GAAG,EAAEC,EAAE,WAAW,MAAM,WAAWR,SAASC,gBAAgB,EAAE,GAAG,EAAEQ,EAAE,WAAWV,GAAG,SAAS1B,GAAG,IAAIC,EAAED,EAAEqC,UAAUH,EAAEjC,CAAC,IAAG,EAAG,EAAEqC,EAAE,WAAW,OAAOJ,EAAE,IAAIA,EAAEC,IAAIC,IAAIL,GAAG,WAAWQ,YAAY,WAAWL,EAAEC,IAAIC,GAAG,GAAG,EAAE,KAAK,CAAC,mBAAII,GAAkB,OAAON,CAAC,EAAE,EAAEO,EAAE,SAASzC,EAAEC,GAAG,IAAIC,EAAEC,EAAEmC,IAAIZ,EAAEtB,EAAE,OAAO8B,EAAE,SAASlC,GAAG,2BAA2BA,EAAEK,OAAO+B,GAAGA,EAAEM,aAAa1C,EAAE2C,UAAUxC,EAAEqC,kBAAkBd,EAAEpB,MAAMN,EAAE2C,UAAUjB,EAAElB,QAAQoC,KAAK5C,GAAGE,GAAE,IAAK,EAAEiC,EAAEU,OAAOC,aAAaA,YAAYC,kBAAkBD,YAAYC,iBAAiB,0BAA0B,GAAGX,EAAED,EAAE,KAAKnB,EAAE,QAAQkB,IAAIC,GAAGC,KAAKlC,EAAE+B,EAAEjC,EAAE0B,EAAEzB,GAAGkC,GAAGD,EAAEC,GAAGJ,GAAG,SAAS5B,GAAGuB,EAAEtB,EAAE,OAAOF,EAAE+B,EAAEjC,EAAE0B,EAAEzB,GAAG+C,uBAAuB,WAAWA,uBAAuB,WAAWtB,EAAEpB,MAAMwC,YAAYlC,MAAMT,EAAEkC,UAAUnC,GAAE,EAAG,GAAG,GAAG,IAAI,EAAE+C,GAAE,EAAGC,GAAG,EAAEC,EAAE,SAASnD,EAAEC,GAAGgD,IAAIR,GAAG,SAASzC,GAAGkD,EAAElD,EAAEM,KAAK,IAAI2C,GAAE,GAAI,IAAI/C,EAAEC,EAAE,SAASF,GAAGiD,GAAG,GAAGlD,EAAEC,EAAE,EAAEiC,EAAE9B,EAAE,MAAM,GAAG+B,EAAE,EAAEC,EAAE,GAAGE,EAAE,SAAStC,GAAG,IAAIA,EAAEoD,eAAe,CAAC,IAAInD,EAAEmC,EAAE,GAAGjC,EAAEiC,EAAEA,EAAEiB,OAAO,GAAGlB,GAAGnC,EAAE2C,UAAUxC,EAAEwC,UAAU,KAAK3C,EAAE2C,UAAU1C,EAAE0C,UAAU,KAAKR,GAAGnC,EAAEM,MAAM8B,EAAEQ,KAAK5C,KAAKmC,EAAEnC,EAAEM,MAAM8B,EAAE,CAACpC,IAAImC,EAAED,EAAE5B,QAAQ4B,EAAE5B,MAAM6B,EAAED,EAAE1B,QAAQ4B,EAAElC,IAAI,CAAC,EAAEiD,EAAEnC,EAAE,eAAesB,GAAGa,IAAIjD,EAAE+B,EAAE9B,EAAE+B,EAAEjC,GAAGyB,GAAG,WAAWyB,EAAEG,cAAchC,IAAIgB,GAAGpC,GAAE,EAAG,IAAI6B,GAAG,WAAWI,EAAE,EAAEe,GAAG,EAAEhB,EAAE9B,EAAE,MAAM,GAAGF,EAAE+B,EAAE9B,EAAE+B,EAAEjC,EAAE,IAAI,EAAEsD,EAAE,CAACC,SAAQ,EAAGC,SAAQ,GAAIC,EAAE,IAAI/C,KAAKgD,EAAE,SAASxD,EAAEC,GAAGJ,IAAIA,EAAEI,EAAEH,EAAEE,EAAED,EAAE,IAAIS,KAAKiD,EAAE/B,qBAAqBgC,IAAI,EAAEA,EAAE,WAAW,GAAG5D,GAAG,GAAGA,EAAEC,EAAEwD,EAAE,CAAC,IAAItD,EAAE,CAAC0D,UAAU,cAAczD,KAAKL,EAAEwB,KAAKuC,OAAO/D,EAAE+D,OAAOC,WAAWhE,EAAEgE,WAAWrB,UAAU3C,EAAEqC,UAAU4B,gBAAgBjE,EAAEqC,UAAUpC,GAAGE,EAAE+D,SAAS,SAASlE,GAAGA,EAAEI,EAAE,IAAID,EAAE,EAAE,CAAC,EAAEgE,EAAE,SAASnE,GAAG,GAAGA,EAAEgE,WAAW,CAAC,IAAI/D,GAAGD,EAAEqC,UAAU,KAAK,IAAI1B,KAAKmC,YAAYlC,OAAOZ,EAAEqC,UAAU,eAAerC,EAAEwB,KAAK,SAASxB,EAAEC,GAAG,IAAIC,EAAE,WAAWyD,EAAE3D,EAAEC,GAAGG,GAAG,EAAED,EAAE,WAAWC,GAAG,EAAEA,EAAE,WAAWyB,oBAAoB,YAAY3B,EAAEqD,GAAG1B,oBAAoB,gBAAgB1B,EAAEoD,EAAE,EAAEzB,iBAAiB,YAAY5B,EAAEqD,GAAGzB,iBAAiB,gBAAgB3B,EAAEoD,EAAE,CAAhO,CAAkOtD,EAAED,GAAG2D,EAAE1D,EAAED,EAAE,CAAC,EAAE4D,EAAE,SAAS5D,GAAG,CAAC,YAAY,UAAU,aAAa,eAAekE,SAAS,SAASjE,GAAG,OAAOD,EAAEC,EAAEkE,EAAEZ,EAAE,GAAG,EAAEa,EAAE,SAASlE,EAAEgC,GAAG,IAAIC,EAAEC,EAAEE,IAAIG,EAAErC,EAAE,OAAO6C,EAAE,SAASjD,GAAGA,EAAE2C,UAAUP,EAAEI,kBAAkBC,EAAEnC,MAAMN,EAAEiE,gBAAgBjE,EAAE2C,UAAUF,EAAEjC,QAAQoC,KAAK5C,GAAGmC,GAAE,GAAI,EAAEe,EAAElC,EAAE,cAAciC,GAAGd,EAAEF,EAAE/B,EAAEuC,EAAEP,GAAGgB,GAAGxB,GAAG,WAAWwB,EAAEI,cAAchC,IAAI2B,GAAGC,EAAER,YAAY,IAAG,GAAIQ,GAAGnB,GAAG,WAAW,IAAIf,EAAEyB,EAAErC,EAAE,OAAO+B,EAAEF,EAAE/B,EAAEuC,EAAEP,GAAG/B,EAAE,GAAGF,GAAG,EAAED,EAAE,KAAK4D,EAAE9B,kBAAkBd,EAAEiC,EAAE9C,EAAEyC,KAAK5B,GAAG6C,GAAG,GAAG,EAAEQ,EAAE,CAAC,EAAEC,EAAE,SAAStE,EAAEC,GAAG,IAAIC,EAAEC,EAAEmC,IAAIJ,EAAE9B,EAAE,OAAO+B,EAAE,SAASnC,GAAG,IAAIC,EAAED,EAAE2C,UAAU1C,EAAEE,EAAEqC,kBAAkBN,EAAE5B,MAAML,EAAEiC,EAAE1B,QAAQoC,KAAK5C,GAAGE,IAAI,EAAEkC,EAAEpB,EAAE,2BAA2BmB,GAAG,GAAGC,EAAE,CAAClC,EAAE+B,EAAEjC,EAAEkC,EAAEjC,GAAG,IAAIwC,EAAE,WAAW4B,EAAEnC,EAAEzB,MAAM2B,EAAEkB,cAAchC,IAAIa,GAAGC,EAAEM,aAAa2B,EAAEnC,EAAEzB,KAAI,EAAGP,GAAE,GAAI,EAAE,CAAC,UAAU,SAASgE,SAAS,SAASlE,GAAG8B,iBAAiB9B,EAAEyC,EAAE,CAAC8B,MAAK,EAAGd,SAAQ,GAAI,IAAI/B,EAAEe,GAAE,GAAIV,GAAG,SAAS5B,GAAG+B,EAAE9B,EAAE,OAAOF,EAAE+B,EAAEjC,EAAEkC,EAAEjC,GAAG+C,uBAAuB,WAAWA,uBAAuB,WAAWd,EAAE5B,MAAMwC,YAAYlC,MAAMT,EAAEkC,UAAUgC,EAAEnC,EAAEzB,KAAI,EAAGP,GAAE,EAAG,GAAG,GAAG,GAAG,CAAC,EAAEsE,EAAE,SAASxE,GAAG,IAAIC,EAAEC,EAAEE,EAAE,QAAQH,EAAE,WAAW,IAAI,IAAIA,EAAE6C,YAAY2B,iBAAiB,cAAc,IAAI,WAAW,IAAIzE,EAAE8C,YAAY4B,OAAOzE,EAAE,CAAC6D,UAAU,aAAanB,UAAU,GAAG,IAAI,IAAIzC,KAAKF,EAAE,oBAAoBE,GAAG,WAAWA,IAAID,EAAEC,GAAGW,KAAK8D,IAAI3E,EAAEE,GAAGF,EAAE4E,gBAAgB,IAAI,OAAO3E,CAAC,CAAjL,GAAqL,GAAGC,EAAEI,MAAMJ,EAAEK,MAAMN,EAAE4E,cAAc3E,EAAEI,MAAM,GAAGJ,EAAEI,MAAMwC,YAAYlC,MAAM,OAAOV,EAAEM,QAAQ,CAACP,GAAGD,EAAEE,EAAE,CAAC,MAAMF,GAAG,CAAC,EAAE,aAAa2B,SAASmD,WAAWvC,WAAWtC,EAAE,GAAG6B,iBAAiB,QAAQ,WAAW,OAAOS,WAAWtC,EAAE,EAAE,GAAG,C","sources":["../node_modules/web-vitals/dist/web-vitals.js"],"sourcesContent":["var e,t,n,i,r=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:\"v2-\".concat(Date.now(),\"-\").concat(Math.floor(8999999999999*Math.random())+1e12)}},a=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if(\"first-input\"===e&&!(\"PerformanceEventTiming\"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},o=function(e,t){var n=function n(i){\"pagehide\"!==i.type&&\"hidden\"!==document.visibilityState||(e(i),t&&(removeEventListener(\"visibilitychange\",n,!0),removeEventListener(\"pagehide\",n,!0)))};addEventListener(\"visibilitychange\",n,!0),addEventListener(\"pagehide\",n,!0)},u=function(e){addEventListener(\"pageshow\",(function(t){t.persisted&&e(t)}),!0)},c=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},f=-1,s=function(){return\"hidden\"===document.visibilityState?0:1/0},m=function(){o((function(e){var t=e.timeStamp;f=t}),!0)},v=function(){return f<0&&(f=s(),m(),u((function(){setTimeout((function(){f=s(),m()}),0)}))),{get firstHiddenTime(){return f}}},d=function(e,t){var n,i=v(),o=r(\"FCP\"),f=function(e){\"first-contentful-paint\"===e.name&&(m&&m.disconnect(),e.startTime-1&&e(t)},f=r(\"CLS\",0),s=0,m=[],v=function(e){if(!e.hadRecentInput){var t=m[0],i=m[m.length-1];s&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(s+=e.value,m.push(e)):(s=e.value,m=[e]),s>f.value&&(f.value=s,f.entries=m,n())}},h=a(\"layout-shift\",v);h&&(n=c(i,f,t),o((function(){h.takeRecords().map(v),n(!0)})),u((function(){s=0,l=-1,f=r(\"CLS\",0),n=c(i,f,t)})))},T={passive:!0,capture:!0},y=new Date,g=function(i,r){e||(e=r,t=i,n=new Date,w(removeEventListener),E())},E=function(){if(t>=0&&t1e12?new Date:performance.now())-e.timeStamp;\"pointerdown\"==e.type?function(e,t){var n=function(){g(e,t),r()},i=function(){r()},r=function(){removeEventListener(\"pointerup\",n,T),removeEventListener(\"pointercancel\",i,T)};addEventListener(\"pointerup\",n,T),addEventListener(\"pointercancel\",i,T)}(t,e):g(t,e)}},w=function(e){[\"mousedown\",\"keydown\",\"touchstart\",\"pointerdown\"].forEach((function(t){return e(t,S,T)}))},L=function(n,f){var s,m=v(),d=r(\"FID\"),p=function(e){e.startTimeperformance.now())return;n.entries=[t],e(n)}catch(e){}},\"complete\"===document.readyState?setTimeout(t,0):addEventListener(\"load\",(function(){return setTimeout(t,0)}))};export{h as getCLS,d as getFCP,L as getFID,F as getLCP,P as getTTFB};\n"],"names":["e","t","n","i","r","name","value","delta","entries","id","concat","Date","now","Math","floor","random","a","PerformanceObserver","supportedEntryTypes","includes","self","getEntries","map","observe","type","buffered","o","document","visibilityState","removeEventListener","addEventListener","u","persisted","c","f","s","m","timeStamp","v","setTimeout","firstHiddenTime","d","disconnect","startTime","push","window","performance","getEntriesByName","requestAnimationFrame","p","l","h","hadRecentInput","length","takeRecords","T","passive","capture","y","g","w","E","entryType","target","cancelable","processingStart","forEach","S","L","b","F","once","P","getEntriesByType","timing","max","navigationStart","responseStart","readyState"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.73c71367.js b/static/js/main.73c71367.js deleted file mode 100644 index 3d5e1f6..0000000 --- a/static/js/main.73c71367.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see main.73c71367.js.LICENSE.txt */ -(()=>{var e={268:(e,t,n)=>{e.exports=n(920)},316:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){super(["AcDbSymbolTableRecord","AcDbRegAppTableRecord"]),this.name=e}tags(e){e.push(0,"APPID"),super.tags(e),e.push(2,this.name),e.push(70,0)}}},432:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s,i){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n,this.startAngle=s,this.endAngle=i}tags(e){e.push(0,"ARC"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r),e.push(100,"AcDbArc"),e.push(50,this.startAngle),e.push(51,this.endAngle)}}},672:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){super(["AcDbEntity","AcDbBlockBegin"]),this.name=e,this.end=new s(["AcDbEntity","AcDbBlockEnd"]),this.recordHandle=null}tags(e){e.push(0,"BLOCK"),super.tags(e),e.push(2,this.name),e.push(70,0),e.point(0,0),e.push(3,this.name),e.push(1,""),e.push(0,"ENDBLK"),this.end.tags(e)}}},184:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){super(["AcDbSymbolTableRecord","AcDbBlockTableRecord"]),this.name=e}tags(e){e.push(0,"BLOCK_RECORD"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(280,0),e.push(281,1)}}},808:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.r=n}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.r)}}},752:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s,i,l,a,r){super(["AcDbEntity","AcDbCircle"]),this.x=e,this.y=t,this.z=n,this.r=s,this.thickness=i,this.extrusionDirectionX=l,this.extrusionDirectionY=a,this.extrusionDirectionZ=r}tags(e){e.push(0,"CIRCLE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(40,this.r),e.push(39,this.thickness),e.push(210,this.extrusionDirectionX),e.push(220,this.extrusionDirectionY),e.push(230,this.extrusionDirectionZ)}}},764:(e,t,n)=>{const s=n(708);e.exports=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.handle=s.next(),this.ownerObjectHandle="0",this.subclassMarkers=[],e&&(Array.isArray(e)?this.subclassMarkers.push(...e):this.subclassMarkers.push(e))}tags(e){e.push(5,this.handle),e.push(330,this.ownerObjectHandle);for(const t of this.subclassMarkers)e.push(100,t)}}},124:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(){super("AcDbDictionary"),this.children={}}addChildDictionary(e,t){t.ownerObjectHandle=this.handle,this.children[e]=t}tags(e){e.push(0,"DICTIONARY"),super.tags(e),e.push(281,1);const t=Object.entries(this.children);for(const s of t){const[t,n]=s;e.push(3,t),e.push(350,n.handle)}const n=Object.values(this.children);for(const s of n)s.tags(e)}}},376:(e,t,n)=>{const s=n(764),i=n(272);e.exports=class extends i{constructor(e){super(e),this.subclassMarkers.push("AcDbDimStyleTable")}tags(e){e.push(0,"TABLE"),e.push(2,this.name),s.prototype.tags.call(this,e),e.push(70,this.elements.length),e.push(71,1);for(const t of this.elements)t.tags(e);e.push(0,"ENDTAB")}}},920:(e,t,n)=>{const s=n(976),i=n(624),l=n(272),a=n(376),r=n(260),o=n(416),u=n(316),c=n(672),h=n(184),p=n(124),d=n(696),f=n(460),m=n(432),I=n(808),y=n(752),v=n(600),E=n(300),w=n(744),g=n(568),T=n(224),b=n(248),R=n(32),S=n(832),D=n(708);class A{constructor(){this.layers={},this.activeLayer=null,this.lineTypes={},this.headers={},this.tables={},this.blocks={},this.dictionary=new p,this.setUnits("Unitless");for(const e of A.LINE_TYPES)this.addLineType(e.name,e.description,e.elements);for(const e of A.LAYERS)this.addLayer(e.name,e.colorNumber,e.lineTypeName);this.setActiveLayer("0"),this.generateAutocadExtras()}addLineType(e,t,n){return this.lineTypes[e]=new s(e,t,n),this}addLayer(e,t,n){return this.layers[e]=new i(e,t,n),this}setActiveLayer(e){return this.activeLayer=this.layers[e],this}addTable(e){const t=new l(e);return this.tables[e]=t,t}addBlock(e){const t=new c(e);return this.blocks[e]=t,t}drawLine(e,t,n,s){return this.activeLayer.addShape(new d(e,t,n,s)),this}drawLine3d(e,t,n,s,i,l){return this.activeLayer.addShape(new f(e,t,n,s,i,l)),this}drawPoint(e,t){return this.activeLayer.addShape(new T(e,t)),this}drawRect(e,t,n,s,i,l){const a=n-e,r=s-t;l=l||0;let o=null;return o=new E(i?[[e+a-i,t,l],[e+a,t+i],[e+a,t+r-i,l],[e+a-i,t+r],[e+i,t+r,l],[e,t+r-i],[e,t+i,l],[e+i,t]]:[[e,t],[e,t+r],[e+a,t+r],[e+a,t]],!0),this.activeLayer.addShape(o),this}drawPolygon(e,t,n,s){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const a=2*Math.PI/n,r=[];let o=s;const u=i*Math.PI/180;l&&(o=s/Math.cos(Math.PI/n));for(let c=0;c5&&void 0!==arguments[5]?arguments[5]:"left",a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"baseline";return this.activeLayer.addShape(new v(e,t,n,s,i,l,a)),this}drawPolyline(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return this.activeLayer.addShape(new E(e,t,n,s)),this}drawPolyline3d(e){return e.forEach((e=>{if(3!==e.length)throw"Require 3D coordinates"})),this.activeLayer.addShape(new w(e)),this}setTrueColor(e){return this.activeLayer.setTrueColor(e),this}drawSpline(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return this.activeLayer.addShape(new b(e,t,n,s,i)),this}drawEllipse(e,t,n,s,i){let l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:2*Math.PI;return this.activeLayer.addShape(new R(e,t,n,s,i,l,a)),this}drawFace(e,t,n,s,i,l,a,r,o,u,c,h){return this.activeLayer.addShape(new g(e,t,n,s,i,l,a,r,o,u,c,h)),this}_ltypeTable(){const e=new l("LTYPE"),t=Object.values(this.lineTypes);for(const n of t)e.add(n);return e}_layerTable(e){const t=new l("LAYER"),n=Object.values(this.layers);for(const s of n)t.add(s);return t}header(e,t){return this.headers[e]=t,this}setUnits(e){"undefined"!=typeof A.UNITS[e]?A.UNITS[e]:A.UNITS.Unitless;return this.header("INSUNITS",[[70,A.UNITS[e]]]),this}generateAutocadExtras(){this.headers.ACADVER||this.header("ACADVER",[[1,"AC1021"]]),this.lineTypes.ByBlock||this.addLineType("ByBlock","",[]),this.lineTypes.ByLayer||this.addLineType("ByLayer","",[]);let e=this.tables.VPORT;e||(e=this.addTable("VPORT"));let t=this.tables.STYLE;t||(t=this.addTable("STYLE")),this.tables.VIEW||this.addTable("VIEW"),this.tables.UCS||this.addTable("UCS");let n=this.tables.APPID;if(n||(n=this.addTable("APPID")),!this.tables.DIMSTYLE){const e=new a("DIMSTYLE");this.tables.DIMSTYLE=e}e.add(new o("*ACTIVE",1e3)),t.add(new r("standard")),n.add(new u("ACAD")),this.modelSpace=this.addBlock("*Model_Space"),this.addBlock("*Paper_Space");const s=new p;this.dictionary.addChildDictionary("ACAD_GROUP",s)}_tagsManager(){const e=new S,t=new l("BLOCK_RECORD"),n=Object.values(this.blocks);for(const l of n){const e=new h(l.name);t.add(e)}const s=this._ltypeTable(),i=this._layerTable();e.start("HEADER"),e.addHeaderVariable("HANDSEED",[[5,D.peek()]]);const a=Object.entries(this.headers);for(const l of a){const[t,n]=l;e.addHeaderVariable(t,n)}e.end(),e.start("CLASSES"),e.end(),e.start("TABLES"),s.tags(e),i.tags(e);const r=Object.values(this.tables);for(const l of r)l.tags(e);t.tags(e),e.end(),e.start("BLOCKS");for(const l of n)l.tags(e);e.end(),e.start("ENTITIES");const o=Object.values(this.layers);for(const l of o)l.shapesTags(this.modelSpace,e);return e.end(),e.start("OBJECTS"),this.dictionary.tags(e),e.end(),e.push(0,"EOF"),e}toDxfString(){return this._tagsManager().toDxfString()}}A.ACI={LAYER:0,RED:1,YELLOW:2,GREEN:3,CYAN:4,BLUE:5,MAGENTA:6,WHITE:7},A.LINE_TYPES=[{name:"CONTINUOUS",description:"______",elements:[]},{name:"DASHED",description:"_ _ _ ",elements:[5,-5]},{name:"DOTTED",description:". . . ",elements:[0,-5]}],A.LAYERS=[{name:"0",colorNumber:A.ACI.WHITE,lineTypeName:"CONTINUOUS"}],A.UNITS={Unitless:0,Inches:1,Feet:2,Miles:3,Millimeters:4,Centimeters:5,Meters:6,Kilometers:7,Microinches:8,Mils:9,Yards:10,Angstroms:11,Nanometers:12,Microns:13,Decimeters:14,Decameters:15,Hectometers:16,Gigameters:17,"Astronomical units":18,"Light years":19,Parsecs:20},e.exports=A},32:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s,i,l,a){super(["AcDbEntity","AcDbEllipse"]),this.x=e,this.y=t,this.majorAxisX=n,this.majorAxisY=s,this.axisRatio=i,this.startAngle=l,this.endAngle=a}tags(e){e.push(0,"ELLIPSE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(11,this.majorAxisX),e.push(21,this.majorAxisY),e.push(31,0),e.push(40,this.axisRatio),e.push(41,this.startAngle),e.push(42,this.endAngle)}}},568:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s,i,l,a,r,o,u,c,h){super(["AcDbEntity","AcDbFace"]),this.x1=e,this.y1=t,this.z1=n,this.x2=s,this.y2=i,this.z2=l,this.x3=a,this.y3=r,this.z3=o,this.x4=u,this.y4=c,this.z4=h}tags(e){e.push(0,"3DFACE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2),e.push(12,this.x3),e.push(22,this.y3),e.push(32,this.z3),e.push(13,this.x4),e.push(23,this.y4),e.push(33,this.z4)}}},708:(e,t,n)=>{var s=n(676).default;class i{static next(){return(++i.seed).toString(16).toUpperCase()}static peek(){return(i.seed+1).toString(16).toUpperCase()}}s(i,"seed",0),e.exports=i},624:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;super(["AcDbSymbolTableRecord","AcDbLayerTableRecord"]),this.name=e,this.colorNumber=t,this.lineTypeName=n,this.shapes=[],this.trueColor=-1}tags(e){e.push(0,"LAYER"),super.tags(e),e.push(2,this.name),-1!==this.trueColor?e.push(420,this.trueColor):e.push(62,this.colorNumber),e.push(70,0),this.lineTypeName&&e.push(6,this.lineTypeName),e.push(390,1)}setTrueColor(e){this.trueColor=e}addShape(e){this.shapes.push(e),e.layer=this}getShapes(){return this.shapes}shapesTags(e,t){for(const n of this.shapes)n.ownerObjectHandle=e.handle,n.tags(t)}}},696:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.x2=n,this.y2=s}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,0)}}},460:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n,s,i,l){super(["AcDbEntity","AcDbLine"]),this.x1=e,this.y1=t,this.z1=n,this.x2=s,this.y2=i,this.z2=l}tags(e){e.push(0,"LINE"),super.tags(e),e.push(8,this.layer.name),e.point(this.x1,this.y1,this.z1),e.push(11,this.x2),e.push(21,this.y2),e.push(31,this.z2)}}},976:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n){super(["AcDbSymbolTableRecord","AcDbLinetypeTableRecord"]),this.name=e,this.description=t,this.elements=n}tags(e){e.push(0,"LTYPE"),super.tags(e),e.push(2,this.name),e.push(3,this.description),e.push(70,0),e.push(72,65),e.push(73,this.elements.length),e.push(40,this.getElementsSum()),this.elements.forEach((t=>{e.push(49,t),e.push(74,0)}))}getElementsSum(){return this.elements.reduce(((e,t)=>e+Math.abs(t)),0)}}},224:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t){super(["AcDbEntity","AcDbPoint"]),this.x=e,this.y=t}tags(e){e.push(0,"POINT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y)}}},300:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;super(["AcDbEntity","AcDbPolyline"]),this.points=e,this.closed=t,this.startWidth=n,this.endWidth=s}tags(e){e.push(0,"LWPOLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(6,"ByLayer"),e.push(62,256),e.push(370,-1),e.push(90,this.points.length),e.push(70,this.closed?1:0),this.points.forEach((t=>{const[n,s,i]=t;e.push(10,n),e.push(20,s),0===this.startWidth&&0===this.endWidth||(e.push(40,this.startWidth),e.push(41,this.endWidth)),void 0!==i&&e.push(42,i)}))}}},744:(e,t,n)=>{const s=n(764),i=n(708),l=n(684);e.exports=class extends s{constructor(e){super(["AcDbEntity","AcDb3dPolyline"]),this.verticies=e.map((e=>{const[t,n,s]=e,i=new l(t,n,s);return i.ownerObjectHandle=this.handle,i})),this.seqendHandle=i.next()}tags(e){e.push(0,"POLYLINE"),super.tags(e),e.push(8,this.layer.name),e.push(66,1),e.push(70,0),e.point(0,0),this.verticies.forEach((t=>{t.layer=this.layer,t.tags(e)})),e.push(0,"SEQEND"),e.push(5,this.seqendHandle),e.push(100,"AcDbEntity"),e.push(8,this.layer.name)}}},248:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(super(["AcDbEntity","AcDbSpline"]),e.length{e.push(40,t)})),this.weights&&this.weights.forEach((t=>{e.push(41,t)})),this.controlPoints.forEach((t=>{e.point(t[0],t[1])}))}}},272:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e){super("AcDbSymbolTable"),this.name=e,this.elements=[]}add(e){e.ownerObjectHandle=this.handle,this.elements.push(e)}tags(e){e.push(0,"TABLE"),e.push(2,this.name),super.tags(e),e.push(70,this.elements.length),this.elements.forEach((t=>{t.tags(e)})),e.push(0,"ENDTAB")}}},832:e=>{e.exports=class{constructor(){this.lines=[]}point(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.push(10,e),this.push(20,t),this.push(30,n)}start(e){this.push(0,"SECTION"),this.push(2,e)}end(){this.push(0,"ENDSEC")}addHeaderVariable(e,t){this.push(9,"$".concat(e)),t.forEach((e=>{this.push(e[0],e[1])}))}push(e,t){this.lines.push(e,t)}toDxfString(){return this.lines.join("\n")}}},600:(e,t,n)=>{const s=n(764),i=["left","center","right"],l=["baseline","bottom","middle","top"];e.exports=class extends s{constructor(e,t,n,s,i){let l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"left",a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"baseline";super(["AcDbEntity","AcDbText"]),this.x=e,this.y=t,this.height=n,this.rotation=s,this.value=i,this.hAlign=l,this.vAlign=a}tags(e){e.push(0,"TEXT"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y),e.push(40,this.height),e.push(1,this.value),e.push(50,this.rotation),i.includes(this.hAlign,1)||l.includes(this.vAlign,1)?(e.push(72,Math.max(i.indexOf(this.hAlign),0)),e.push(11,this.x),e.push(21,this.y),e.push(31,0),e.push(100,"AcDbText"),e.push(73,Math.max(l.indexOf(this.vAlign),0))):e.push(100,"AcDbText")}}},260:(e,t,n)=>{var s=n(676).default;const i=n(764);e.exports=class extends i{constructor(e){super(["AcDbSymbolTableRecord","AcDbTextStyleTableRecord"]),s(this,"fontFileName","txt"),this.name=e}tags(e){e.push(0,"STYLE"),super.tags(e),e.push(2,this.name),e.push(70,0),e.push(40,0),e.push(41,1),e.push(50,0),e.push(71,0),e.push(42,1),e.push(3,this.fontFileName),e.push(4,"")}}},684:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t,n){super(["AcDbEntity","AcDbVertex","AcDb3dPolylineVertex"]),this.x=e,this.y=t,this.z=n}tags(e){e.push(0,"VERTEX"),super.tags(e),e.push(8,this.layer.name),e.point(this.x,this.y,this.z),e.push(70,32)}}},416:(e,t,n)=>{const s=n(764);e.exports=class extends s{constructor(e,t){super(["AcDbSymbolTableRecord","AcDbViewportTableRecord"]),this.name=e,this.height=t}tags(e){e.push(0,"VPORT"),super.tags(e),e.push(2,this.name),e.push(40,this.height),e.push(70,0)}}},8:e=>{"use strict";function t(e,t,s){s=s||2;var l,a,r,o,h,p,f,m=t&&t.length,I=m?t[0]*s:e.length,y=n(e,0,I,s,!0),v=[];if(!y||y.next===y.prev)return v;if(m&&(y=function(e,t,s,i){var l,a,r,o=[];for(l=0,a=t.length;l80*s){l=r=e[0],a=o=e[1];for(var E=s;Er&&(r=h),p>o&&(o=p);f=0!==(f=Math.max(r-l,o-a))?32767/f:0}return i(y,v,s,l,a,f,0),v}function n(e,t,n,s,i){var l,a;if(i===D(e,t,n,s)>0)for(l=t;l=t;l-=s)a=b(l,e[l],e[l+1],a);return a&&y(a,a.next)&&(R(a),a=a.next),a}function s(e,t){if(!e)return e;t||(t=e);var n,s=e;do{if(n=!1,s.steiner||!y(s,s.next)&&0!==I(s.prev,s,s.next))s=s.next;else{if(R(s),(s=t=s.prev)===s.next)break;n=!0}}while(n||s!==t);return t}function i(e,t,n,u,c,h,d){if(e){!d&&h&&function(e,t,n,s){var i=e;do{0===i.z&&(i.z=p(i.x,i.y,t,n,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,s,i,l,a,r,o,u=1;do{for(n=e,e=null,l=null,a=0;n;){for(a++,s=n,r=0,t=0;t0||o>0&&s;)0!==r&&(0===o||!s||n.z<=s.z)?(i=n,n=n.nextZ,r--):(i=s,s=s.nextZ,o--),l?l.nextZ=i:e=i,i.prevZ=l,l=i;n=s}l.nextZ=null,u*=2}while(a>1)}(i)}(e,u,c,h);for(var f,m,I=e;e.prev!==e.next;)if(f=e.prev,m=e.next,h?a(e,u,c,h):l(e))t.push(f.i/n|0),t.push(e.i/n|0),t.push(m.i/n|0),R(e),e=m.next,I=m.next;else if((e=m)===I){d?1===d?i(e=r(s(e),t,n),t,n,u,c,h,2):2===d&&o(e,t,n,u,c,h):i(s(e),t,n,u,c,h,1);break}}}function l(e){var t=e.prev,n=e,s=e.next;if(I(t,n,s)>=0)return!1;for(var i=t.x,l=n.x,a=s.x,r=t.y,o=n.y,u=s.y,c=il?i>a?i:a:l>a?l:a,d=r>o?r>u?r:u:o>u?o:u,m=s.next;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=d&&f(i,r,l,o,a,u,m.x,m.y)&&I(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function a(e,t,n,s){var i=e.prev,l=e,a=e.next;if(I(i,l,a)>=0)return!1;for(var r=i.x,o=l.x,u=a.x,c=i.y,h=l.y,d=a.y,m=ro?r>u?r:u:o>u?o:u,E=c>h?c>d?c:d:h>d?h:d,w=p(m,y,t,n,s),g=p(v,E,t,n,s),T=e.prevZ,b=e.nextZ;T&&T.z>=w&&b&&b.z<=g;){if(T.x>=m&&T.x<=v&&T.y>=y&&T.y<=E&&T!==i&&T!==a&&f(r,c,o,h,u,d,T.x,T.y)&&I(T.prev,T,T.next)>=0)return!1;if(T=T.prevZ,b.x>=m&&b.x<=v&&b.y>=y&&b.y<=E&&b!==i&&b!==a&&f(r,c,o,h,u,d,b.x,b.y)&&I(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;T&&T.z>=w;){if(T.x>=m&&T.x<=v&&T.y>=y&&T.y<=E&&T!==i&&T!==a&&f(r,c,o,h,u,d,T.x,T.y)&&I(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;b&&b.z<=g;){if(b.x>=m&&b.x<=v&&b.y>=y&&b.y<=E&&b!==i&&b!==a&&f(r,c,o,h,u,d,b.x,b.y)&&I(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function r(e,t,n){var i=e;do{var l=i.prev,a=i.next.next;!y(l,a)&&v(l,i,i.next,a)&&g(l,a)&&g(a,l)&&(t.push(l.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),R(i),R(i.next),i=e=a),i=i.next}while(i!==e);return s(i)}function o(e,t,n,l,a,r){var o=e;do{for(var u=o.next.next;u!==o.prev;){if(o.i!==u.i&&m(o,u)){var c=T(o,u);return o=s(o,o.next),c=s(c,c.next),i(o,t,n,l,a,r,0),void i(c,t,n,l,a,r,0)}u=u.next}o=o.next}while(o!==e)}function u(e,t){return e.x-t.x}function c(e,t){var n=function(e,t){var n,s=t,i=e.x,l=e.y,a=-1/0;do{if(l<=s.y&&l>=s.next.y&&s.next.y!==s.y){var r=s.x+(l-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(r<=i&&r>a&&(a=r,n=s.x=s.x&&s.x>=c&&i!==s.x&&f(ln.x||s.x===n.x&&h(n,s)))&&(n=s,d=o)),s=s.next}while(s!==u);return n}(e,t);if(!n)return t;var i=T(n,e);return s(i,i.next),s(n,n.next)}function h(e,t){return I(e.prev,e,t.prev)<0&&I(t.next,e,e.next)<0}function p(e,t,n,s,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d(e){var t=e,n=e;do{(t.x=(e-a)*(l-r)&&(e-a)*(s-r)>=(n-a)*(t-r)&&(n-a)*(l-r)>=(i-a)*(s-r)}function m(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&v(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(g(e,t)&&g(t,e)&&function(e,t){var n=e,s=!1,i=(e.x+t.x)/2,l=(e.y+t.y)/2;do{n.y>l!==n.next.y>l&&n.next.y!==n.y&&i<(n.next.x-n.x)*(l-n.y)/(n.next.y-n.y)+n.x&&(s=!s),n=n.next}while(n!==e);return s}(e,t)&&(I(e.prev,e,t.prev)||I(e,t.prev,t))||y(e,t)&&I(e.prev,e,e.next)>0&&I(t.prev,t,t.next)>0)}function I(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function y(e,t){return e.x===t.x&&e.y===t.y}function v(e,t,n,s){var i=w(I(e,t,n)),l=w(I(e,t,s)),a=w(I(n,s,e)),r=w(I(n,s,t));return i!==l&&a!==r||(!(0!==i||!E(e,n,t))||(!(0!==l||!E(e,s,t))||(!(0!==a||!E(n,e,s))||!(0!==r||!E(n,t,s)))))}function E(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function w(e){return e>0?1:e<0?-1:0}function g(e,t){return I(e.prev,e,e.next)<0?I(e,t,e.next)>=0&&I(e,e.prev,t)>=0:I(e,t,e.prev)<0||I(e,e.next,t)<0}function T(e,t){var n=new S(e.i,e.x,e.y),s=new S(t.i,t.x,t.y),i=e.next,l=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,s.next=n,n.prev=s,l.next=s,s.prev=l,s}function b(e,t,n,s){var i=new S(e,t,n);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function R(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function S(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function D(e,t,n,s){for(var i=0,l=t,a=n-s;l0&&(s+=e[i-1].length,n.holes.push(s))}return n}},912:function(e){e.exports=function(){"use strict";var e,t,n;function s(s,i){if(e)if(t){var l="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",a={};e(a),n=i(a),"undefined"!==typeof window&&window&&window.URL&&window.URL.createObjectURL&&(n.workerUrl=window.URL.createObjectURL(new Blob([l],{type:"text/javascript"})))}else t=i;else e=i}return s(["exports"],(function(e){var t="undefined"!=typeof self?self:{},n="2.15.0";let s;const i={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==s){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{s=null!={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.API_URL_REGEX?new RegExp({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.API_URL_REGEX):e}catch(t){s=e}}return s},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!i.API_URL)return null;try{const e=new URL(i.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},l={supported:!1,testSupport:function(e){!o&&r&&(u?c(e):a=e)}};let a,r,o=!1,u=!1;function c(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r),e.isContextLost())return;l.supported=!0}catch(e){}e.deleteTexture(t),o=!0}t.document&&(r=t.document.createElement("img"),r.onload=function(){a&&c(a),a=null,u=!0},r.onerror=function(){o=!0,a=null},r.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const h="01";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d=f;function f(e,t,n,s){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=s}f.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,s=0;s<8;s++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:r=n,n=.5*(r-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var m=p(d),I=y;function y(e,t){this.x=e,this.y=t}y.prototype={clone:function(){return new y(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),s=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=s,this},_rotateAround:function(e,t){var n=Math.cos(e),s=Math.sin(e),i=t.y+s*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-s*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(e){return e instanceof y?e:Array.isArray(e)?new y(e[0],e[1]):e};var v=p(I);const E=Math.PI/180,w=180/Math.PI;function g(e){return e*E}function T(e){return e*w}const b=[[0,0],[1,0],[1,1],[0,1]];function R(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function S(e,t,n,s){const i=new m(e,t,n,s);return function(e){return i.solve(e)}}const D=S(.25,.1,.25,1);function A(e,t,n){return Math.min(n,Math.max(t,e))}function C(e,t,n){return(n=A((n-e)/(t-e),0,1))*n*(3-2*n)}function x(e,t,n){const s=n-t,i=((e-t)%s+s)%s+t;return i===t?n:i}function _(e,t,n){if(!e.length)return n(null,[]);let s=e.length;const i=new Array(e.length);let l=null;e.forEach(((e,a)=>{t(e,((e,t)=>{e&&(l=e),i[a]=t,0==--s&&n(l,i)}))}))}function O(e){const t=[];for(const n in e)t.push(e[n]);return t}function N(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function F(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function B(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function H(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function U(e,t){return-1!==e.indexOf(t,e.length-t.length)}function G(e,t,n){const s={};for(const i in e)s[i]=t.call(n||this,e[i],i,e);return s}function k(e,t,n){const s={};for(const i in e)t.call(n||this,e[i],i,e)&&(s[i]=e[i]);return s}function z(e){return Array.isArray(e)?e.map(z):"object"==typeof e&&e?G(e,z):e}const V={};function j(e){V[e]||("undefined"!=typeof console&&console.warn(e),V[e]=!0)}function W(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function Y(e){let t=0;for(let n,s,i=0,l=e.length,a=l-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,n,s,i)=>{const l=s||i;return t[n]=!l||l.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let Z=null;function K(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z}function Q(e){try{const n=t[e];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function J(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const $="mapbox-tiles";let ee,te,ne=500,se=50;function ie(){try{return t.caches}catch(e){}}function le(){ie()&&!ee&&(ee=t.caches.open($))}function ae(e){const t=e.indexOf("?");if(t<0)return e;const n=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e),s=n.filter((e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]}));return s.length?"".concat(e.slice(0,t),"?").concat(s.join("&")):e.slice(0,t)}let re=1/0;const oe={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(oe);class ue extends Error{constructor(e,t,n){401===t&&we(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return"".concat(this.name,": ").concat(this.message," (").concat(this.status,"): ").concat(this.url)}}const ce=q()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href,he=function(e,n){if(!(/^file:/.test(s=e.url)||/^file:/.test(ce())&&!/^\w+:/.test(s))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,n){const s=new t.AbortController,i=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ce(),referrerPolicy:e.referrerPolicy,signal:s.signal});let l=!1,a=!1;const r=(o=i.url).indexOf("sku=")>0&&we(o);var o;"json"===e.type&&i.headers.set("Accept","application/json");const u=(s,l,o)=>{if(a)return;if(s&&"SecurityError"!==s.message&&j(s.toString()),l&&o)return c(l);const u=Date.now();t.fetch(i).then((t=>{if(t.ok){const e=r?t.clone():null;return c(t,e,u)}return n(new ue(t.statusText,t.status,e.url))})).catch((t=>{"AbortError"!==t.name&&n(new Error("".concat(t.message," ").concat(e.url)))}))},c=(s,r,o)=>{("arrayBuffer"===e.type?s.arrayBuffer():"json"===e.type?s.json():s.text()).then((e=>{a||(r&&o&&function(e,n,s){if(le(),!ee)return;const i={status:n.status,statusText:n.statusText,headers:new t.Headers};n.headers.forEach(((e,t)=>i.headers.set(t,e)));const l=X(n.headers.get("Cache-Control")||"");if(l["no-store"])return;l["max-age"]&&i.headers.set("Expires",new Date(s+1e3*l["max-age"]).toUTCString());const a=i.headers.get("Expires");a&&(new Date(a).getTime()-s<42e4||function(e,t){if(void 0===te)try{new Response(new ReadableStream),te=!0}catch(e){te=!1}te?t(e.body):e.blob().then(t)}(n,(n=>{const s=new t.Response(n,i);le(),ee&&ee.then((t=>t.put(ae(e.url),s))).catch((e=>j(e.message)))})))}(i,r,o),l=!0,n(null,e,s.headers.get("Cache-Control"),s.headers.get("Expires")))})).catch((e=>{a||n(new Error(e.message))}))};return r?function(e,t){if(le(),!ee)return t(null);const n=ae(e.url);ee.then((e=>{e.match(n).then((s=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=X(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(s);e.delete(n),i&&e.put(n,s.clone()),t(null,s,i)})).catch(t)})).catch(t)}(i,u):u(null,null),{cancel:()=>{a=!0,l||s.abort()}}}(e,n);if(q()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,n,void 0,!0)}var s;return function(e,n){const s=new t.XMLHttpRequest;s.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(s.responseType="arraybuffer");for(const t in e.headers)s.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(s.responseType="text",s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===e.credentials,s.onerror=()=>{n(new Error(s.statusText))},s.onload=()=>{if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let t=s.response;if("json"===e.type)try{t=JSON.parse(s.response)}catch(e){return n(e)}n(null,t,s.getResponseHeader("Cache-Control"),s.getResponseHeader("Expires"))}else n(new ue(s.statusText,s.status,e.url))},s.send(e.body),{cancel:()=>s.abort()}}(e,n)},pe=function(e,t){return he(N(e,{type:"arrayBuffer"}),t)};function de(e){const n=t.document.createElement("a");return n.href=e,n.protocol===t.document.location.protocol&&n.host===t.document.location.host}const fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let me,Ie;me=[],Ie=0;const ye=function(e,n){if(l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Ie>=i.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return me.push(t),t}Ie++;let s=!1;const a=()=>{if(!s)for(s=!0,Ie--;me.length&&Ie{a(),e?n(e):s&&(t.createImageBitmap?function(e,n){const s=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(s).then((e=>{n(null,e)})).catch((e=>{n(new Error("Could not load image because of ".concat(e.message,". Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")))}))}(s,((e,t)=>n(e,t,i,l))):function(e,n){const s=new t.Image,i=t.URL;s.onload=()=>{n(null,s),i.revokeObjectURL(s.src),s.onload=null,t.requestAnimationFrame((()=>{s.src=fe}))},s.onerror=()=>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."));const l=new t.Blob([new Uint8Array(e)],{type:"image/png"});s.src=e.byteLength?i.createObjectURL(l):fe}(s,((e,t)=>n(e,t,i,l))))}));return{cancel:()=>{r.cancel(),a()}}},ve="NO_ACCESS_TOKEN";function Ee(e){return 0===e.indexOf("mapbox:")}function we(e){return i.API_URL_REGEX.test(e)}function ge(e){return i.API_CDN_URL_REGEX.test(e)}function Te(e){return i.API_STYLE_REGEX.test(e)&&!be(e)}function be(e){return i.API_SPRITE_REGEX.test(e)}const Re=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Se(e){const t=e.match(Re);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function De(e){const t=e.params.length?"?".concat(e.params.join("&")):"";return"".concat(e.protocol,"://").concat(e.authority).concat(e.path).concat(t)}const Ae="mapbox.eventData";function Ce(e){if(!e)return null;const n=e.split(".");if(!n||3!==n.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(n[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class xe{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const n=Ce(i.ACCESS_TOKEN);let s="";return s=n&&n.u?t.btoa(encodeURIComponent(n.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):i.ACCESS_TOKEN||"",e?"".concat(Ae,".").concat(e,":").concat(s):"".concat(Ae,":").concat(s)}fetchEventData(){const e=Q("localStorage"),n=this.getStorageKey(),s=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(n);e&&(this.eventData=JSON.parse(e));const i=t.localStorage.getItem(s);i&&(this.anonId=i)}catch(e){j("Unable to read from LocalStorage")}}saveEventData(){const e=Q("localStorage"),n=this.getStorageKey(),s=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(s,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(n,JSON.stringify(this.eventData))}catch(e){j("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,s){if(!i.EVENTS_URL)return;const l=Se(i.EVENTS_URL);l.params.push("access_token=".concat(s||i.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},r=t?N(a,t):a,o={url:De(l),headers:{"Content-Type":"text/plain"},body:JSON.stringify([r])};this.pendingRequest=function(e,t){return he(N(e,{method:"POST"}),t)}(o,(e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(s)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const _e=new class extends xe{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){i.EVENTS_URL&&i.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>Ee(e)||we(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ce(i.ACCESS_TOKEN),s=t?t.u:i.ACCESS_TOKEN;let l=s!==this.eventData.tokenU;B(this.anonId)||(this.anonId=M(),l=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;l=l||n>=1||n<-1||e.getDate()!==t.getDate()}else l=!0;l?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:h,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=s)}),e):this.processRequests()}},Oe=_e.postTurnstileEvent.bind(_e),Ne=new class extends xe{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,s){this.skuToken=t,this.errorCb=s,i.EVENTS_URL&&(n||i.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:s}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),B(this.anonId)||(this.anonId=M()),this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:h,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}},Le=Ne.postMapLoadEvent.bind(Ne),Pe=new class extends xe{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){i.EVENTS_URL&&(e||i.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:s,performanceData:i}=this.queue.shift(),l=function(e){const s=t.performance.getEntriesByType("resource"),i=t.performance.getEntriesByType("mark"),l=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const s of e[n]){const e="".concat(n,"ResolveRangeMin"),i="".concat(n,"ResolveRangeMax"),l="".concat(n,"RequestCount"),a="".concat(n,"RequestCachedCount");t[e]=Math.min(t[e]||1/0,s.startTime),t[i]=Math.max(t[i]||-1/0,s.responseEnd);const r=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==s.transferSize&&0===s.transferSize&&r(a),r(l)}return t}(function(e,t){const n={};if(e)for(const s of e){const e=t(s);void 0===n[e]&&(n[e]=[]),n[e].push(s)}return n}(s,ke)),a=t.devicePixelRatio,r=t.navigator.connection||t.navigator.mozConnection||t.navigator.webkitConnection,o={counters:[],metadata:[],attributes:[]},u=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const t in l)u(o.counters,t,l[t]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(o.counters,"interactionRangeMin",e.interactionRange[0]),u(o.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const t of Object.keys(Ue)){const e=Ue[t],n=i.find((t=>t.name===e));n&&u(o.counters,e,n.startTime)}return u(o.counters,"visibilityHidden",e.visibilityHidden),u(o.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(Te(e)){const t=e.split("/").slice(-2);if(2===t.length)return"mapbox://styles/".concat(t[0],"/").concat(t[1])}}}(s)),u(o.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(o.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(o.attributes,"projection",e.projection),u(o.attributes,"zoom",e.zoom),u(o.metadata,"devicePixelRatio",a),u(o.metadata,"connectionEffectiveType",r?r.effectiveType:void 0),u(o.metadata,"navigatorUserAgent",t.navigator.userAgent),u(o.metadata,"screenWidth",t.screen.width),u(o.metadata,"screenHeight",t.screen.height),u(o.metadata,"windowWidth",t.innerWidth),u(o.metadata,"windowHeight",t.innerHeight),u(o.metadata,"mapWidth",e.width/a),u(o.metadata,"mapHeight",e.height/a),u(o.metadata,"webglRenderer",e.renderer),u(o.metadata,"webglVendor",e.vendor),u(o.metadata,"sdkVersion",n),u(o.metadata,"sdkIdentifier","mapbox-gl-js"),o}(i);for(const t of l.metadata);for(const t of l.counters);for(const t of l.attributes);this.postEvent(s,l,(()=>{}),e)}},Me=Pe.postPerformanceEvent.bind(Pe),Fe=new class extends xe{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,s){if(!i.API_URL||!i.SESSION_PATH)return;const l=Se(i.API_URL+i.SESSION_PATH);l.params.push("sku=".concat(t||"")),l.params.push("access_token=".concat(s||i.ACCESS_TOKEN||""));const a={url:De(l),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return he(N(e,{method:"GET"}),t)}(a,(e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(s)}))}getSessionAPI(e,t,n,s){this.skuToken=t,this.errorCb=s,i.SESSION_PATH&&i.API_URL&&(n||i.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}},Be=Fe.getSessionAPI.bind(Fe),He=new Set,Ue={create:"create",load:"load",fullLoad:"fullLoad"},Ge={mark(e){t.performance.mark(e)},measure(e,n,s){t.performance.measure(e,n,s)}};function ke(e){const t=e.name.split("?")[0];return ge(t)&&t.includes("mapbox-gl.js")?"javascript":ge(t)&&t.includes("mapbox-gl.css")?"css":function(e){return i.API_FONTS_REGEX.test(e)}(t)?"fontRange":be(t)?"sprite":Te(t)?"style":function(e){return i.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const ze=t.performance;function Ve(e){const t=e?e.url.toString():void 0;return ze.getEntriesByName(t)}let je,We,Ye,qe;const Xe={now:()=>void 0!==Ye?Ye:t.performance.now(),setNow(e){Ye=e},restoreNow(){Ye=void 0},frame(e){const n=t.requestAnimationFrame(e);return{cancel:()=>t.cancelAnimationFrame(n)}},getImageData(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{width:s,height:i}=e;qe||(qe=t.document.createElement("canvas"));const l=qe.getContext("2d",{willReadFrequently:!0});if(!l)throw new Error("failed to create canvas 2d context");return(s>qe.width||i>qe.height)&&(qe.width=s,qe.height=i),l.clearRect(-n,-n,s+2*n,i+2*n),l.drawImage(e,0,0,s,i),l.getImageData(-n,-n,s+2*n,i+2*n)},resolveURL:e=>(je||(je=t.document.createElement("a")),je.href=e,je.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return!!t.matchMedia&&(null==We&&(We=t.matchMedia("(prefers-reduced-motion: reduce)")),We.matches)}};function Ze(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function Ke(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}class Qe{constructor(e){N(this,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),this.type=e}}class Je extends Qe{constructor(e){super("error",N({error:e},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}))}}class $e{on(e,t){return this._listeners=this._listeners||{},Ze(e,t,this._listeners),this}off(e,t){return Ke(e,t,this._listeners),Ke(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ze(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Qe(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const s=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const l of s)Ke(n,l,this._oneTimeListeners),l.call(this,e);const i=this._eventedParent;i&&(N(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Je&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var et=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function tt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s1&&void 0!==arguments[1]?arguments[1]:[];this.parent=e,this.bindings={};for(const[n,s]of t)this.bindings[n]=s}concat(e){return new at(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error("".concat(e," not found in scope."))}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var rt=at;const ot={kind:"null"},ut={kind:"number"},ct={kind:"string"},ht={kind:"boolean"},pt={kind:"color"},dt={kind:"object"},ft={kind:"value"},mt={kind:"collator"},It={kind:"formatted"},yt={kind:"resolvedImage"};function vt(e,t){return{kind:"array",itemType:e,N:t}}function Et(e){if("array"===e.kind){const t=Et(e.itemType);return"number"==typeof e.N?"array<".concat(t,", ").concat(e.N,">"):"value"===e.itemType.kind?"array":"array<".concat(t,">")}return e.kind}const wt=[ot,ut,ct,ht,pt,It,dt,vt(ft),yt];function gt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!gt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of wt)if(!gt(e,t))return null}return"Expected ".concat(Et(e)," but found ").concat(Et(t)," instead.")}function Tt(e,t){return t.some((t=>t.kind===e.kind))}function bt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}var Rt,St={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Dt(e){return(e=Math.round(e))<0?0:e>255?255:e}function At(e){return Dt("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function Ct(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function xt(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{Rt={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in St)return St[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var s=n.indexOf("("),i=n.indexOf(")");if(-1!==s&&i+1===n.length){var l=n.substr(0,s),a=n.substr(s+1,i-(s+1)).split(","),r=1;switch(l){case"rgba":if(4!==a.length)return null;r=Ct(a.pop());case"rgb":return 3!==a.length?null:[At(a[0]),At(a[1]),At(a[2]),r];case"hsla":if(4!==a.length)return null;r=Ct(a.pop());case"hsl":if(3!==a.length)return null;var o=(parseFloat(a[0])%360+360)%360/360,u=Ct(a[1]),c=Ct(a[2]),h=c<=.5?c*(u+1):c+u-c*u,p=2*c-h;return[Dt(255*xt(p,h,o+1/3)),Dt(255*xt(p,h,o)),Dt(255*xt(p,h,o-1/3)),r];default:return null}}return null}}catch(e){}class _t{constructor(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;this.r=e,this.g=t,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof _t)return e;if("string"!=typeof e)return;const t=Rt(e);return t?new _t(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,n,s]=this.toArray();return"rgba(".concat(Math.round(e),",").concat(Math.round(t),",").concat(Math.round(n),",").concat(s,")")}toArray(){const{r:e,g:t,b:n,a:s}=this;return 0===s?[0,0,0,0]:[255*e/s,255*t/s,255*n/s,s]}toArray01(){const{r:e,g:t,b:n,a:s}=this;return 0===s?[0,0,0,0]:[e/s,t/s,n/s,s]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:s}=this;return[e,t,n,s]}}_t.black=new _t(0,0,0,1),_t.white=new _t(1,1,1,1),_t.transparent=new _t(0,0,0,0),_t.red=new _t(1,0,0,1),_t.blue=new _t(0,0,1,1);var Ot=_t;class Nt{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Lt{constructor(e,t,n,s,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=s,this.textColor=i}}class Pt{constructor(e){this.sections=e}static fromString(e){return new Pt([new Lt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof Pt?e:Pt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class Mt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Mt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Ft(e,t,n,s){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===s||"number"==typeof s&&s>=0&&s<=1?null:"Invalid rgba value [".concat([e,t,n,s].join(", "),"]: 'a' must be between 0 and 1."):"Invalid rgba value [".concat(("number"==typeof s?[e,t,n,s]:[e,t,n]).join(", "),"]: 'r', 'g', and 'b' must be between 0 and 255.")}function Bt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Ot)return!0;if(e instanceof Nt)return!0;if(e instanceof Pt)return!0;if(e instanceof Mt)return!0;if(Array.isArray(e)){for(const t of e)if(!Bt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Bt(e[t]))return!1;return!0}return!1}function Ht(e){if(null===e)return ot;if("string"==typeof e)return ct;if("boolean"==typeof e)return ht;if("number"==typeof e)return ut;if(e instanceof Ot)return pt;if(e instanceof Nt)return mt;if(e instanceof Pt)return It;if(e instanceof Mt)return yt;if(Array.isArray(e)){const t=e.length;let n;for(const s of e){const e=Ht(s);if(n){if(n===e)continue;n=ft;break}n=e}return vt(n||ft,t)}return dt}function Ut(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ot||e instanceof Pt||e instanceof Mt?e.toString():JSON.stringify(e)}class Gt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error("'literal' expression requires exactly one argument, but found ".concat(e.length-1," instead."));if(!Bt(e[1]))return t.error("invalid value");const n=e[1];let s=Ht(n);const i=t.expectedType;return"array"!==s.kind||0!==s.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(s=i),new Gt(s,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ot?["rgba"].concat(this.value.toArray()):this.value instanceof Pt?this.value.serialize():this.value}}var kt=Gt,zt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const Vt={string:ct,number:ut,boolean:ht,object:dt};class jt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,s=1;const i=e[0];if("array"===i){let i,l;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in Vt)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Vt[n],s++}else i=ft;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);l=e[2],s++}n=vt(i,l)}else n=Vt[i];const l=[];for(;se.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const s=e.N;("number"==typeof s||this.args.length>1)&&t.push(s)}}return t.concat(this.args.map((e=>e.serialize())))}}var Wt=jt;class Yt{constructor(e){this.type=It,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const s=[];let i=!1;for(let l=1;l<=e.length-1;++l){const n=e[l];if(i&&"object"==typeof n&&!Array.isArray(n)){i=!1;let e=null;if(n["font-scale"]&&(e=t.parse(n["font-scale"],1,ut),!e))return null;let l=null;if(n["text-font"]&&(l=t.parse(n["text-font"],1,vt(ct)),!l))return null;let a=null;if(n["text-color"]&&(a=t.parse(n["text-color"],1,pt),!a))return null;const r=s[s.length-1];r.scale=e,r.font=l,r.textColor=a}else{const n=t.parse(e[l],1,ft);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,s.push({content:n,scale:null,font:null,textColor:null})}}return new Yt(s)}evaluate(e){return new Pt(this.sections.map((t=>{const n=t.content.evaluate(e);return Ht(n)===yt?new Lt("",n,null,null,null):new Lt(Ut(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class qt{constructor(e){this.type=yt,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ct);return n?new qt(n):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),n=Mt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Xt={"to-boolean":ht,"to-color":pt,"to-number":ut,"to-string":ct};class Zt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0];if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return t.error("Expected one argument.");const s=Xt[n],i=[];for(let l=1;l4?"Invalid rbga value ".concat(JSON.stringify(t),": expected an array containing either three or four numeric values."):Ft(t[0],t[1],t[2],t[3]),!n))return new Ot(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new zt(n||"Could not parse color from value '".concat("string"==typeof t?t:String(JSON.stringify(t)),"'"))}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const s=Number(t);if(!isNaN(s))return s}throw new zt("Could not convert ".concat(JSON.stringify(t)," to number."))}return"formatted"===this.type.kind?Pt.fromString(Ut(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Mt.fromString(Ut(this.args[0].evaluate(e))):Ut(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Yt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new qt(this.args[0]).serialize();const e=["to-".concat(this.type.kind)];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Kt=Zt;const Qt=["Unknown","Point","LineString","Polygon"];var Jt=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Qt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(s*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ot.parse(e)),t}};class $t{constructor(e,t,n,s){this.name=e,this.type=t,this._evaluate=n,this.args=s}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const n=e[0],s=$t.definitions[n];if(!s)return t.error('Unknown expression "'.concat(n,'". If you wanted a literal array, use ["literal", [...]].'),0);const i=Array.isArray(s)?s[0]:s.type,l=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,a=l.filter((t=>{let[n]=t;return!Array.isArray(n)||n.length===e.length-1}));let r=null;for(const[o,u]of a){r=new An(t.registry,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{let[t]=e;return n=t,Array.isArray(n)?"(".concat(n.map(Et).join(", "),")"):"(".concat(Et(n.type),"...)");var n})).join(" | "),s=[];for(let i=1;i=t[2]||e[1]<=t[1]||e[3]>=t[3])}function an(e,t){const n=(180+e[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*nn),Math.round(s*i*nn)]}function rn(e,t,n){const s=e[0]-t[0],i=e[1]-t[1],l=e[0]-n[0],a=e[1]-n[1];return s*a-l*i==0&&s*l<=0&&i*a<=0}function on(e,t){let n=!1;for(let a=0,r=t.length;a(s=e)[1]!=(l=r[t+1])[1]>s[1]&&s[0]<(l[0]-i[0])*(s[1]-i[1])/(l[1]-i[1])+i[0]&&(n=!n)}}var s,i,l;return n}function un(e,t){for(let n=0;n0&&r<0||a<0&&r>0}function hn(e,t,n){for(const u of n)for(let n=0;nn[2]){const t=.5*s;let i=e[0]-n[0]>t?-s:n[0]-e[0]>t?s:0;0===i&&(i=e[0]-n[2]>t?-s:n[2]-e[0]>t?s:0),e[0]+=i}sn(t,e)}function yn(e,t,n,s){const i=Math.pow(2,s.z)*nn,l=[s.x*nn,s.y*nn],a=[];if(!e)return a;for(const r of e)for(const e of r){const s=[e.x+l[0],e.y+l[1]];In(s,t,n,i),a.push(s)}return a}function vn(e,t,n,s){const i=Math.pow(2,s.z)*nn,l=[s.x*nn,s.y*nn],a=[];if(!e)return a;for(const o of e){const e=[];for(const n of o){const s=[n.x+l[0],n.y+l[1]];sn(t,s),e.push(s)}a.push(e)}if(t[2]-t[0]<=i/2){(r=t)[0]=r[1]=1/0,r[2]=r[3]=-1/0;for(const e of a)for(const s of e)In(s,t,n,i)}var r;return a}class En{constructor(e,t){this.type=ht,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error("'within' expression requires exactly one argument, but found ".concat(e.length-1," instead."));if(Bt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!gn(e)&&(t=!1)})),t}function Tn(e){if(e instanceof en&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Tn(e)&&(t=!1)})),t}function bn(e,t){if(e instanceof en&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild((e=>{n&&!bn(e,t)&&(n=!1)})),n}class Rn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new Rn(n,t.scope.get(n)):t.error('Unknown variable "'.concat(n,'". Make sure "').concat(n,'" has been bound in an enclosing "let" expression before using it.'),1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Sn=Rn;class Dn{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new rt,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];this.registry=e,this.path=t,this.key=t.map((e=>"[".concat(e,"]"))).join(""),this.scope=s,this.errors=i,this.expectedType=n}parse(e,t,n,s){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return t?this.concat(t,n,s)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Wt(t,[e]):"coerce"===n?new Kt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const s=e[0];if("string"!=typeof s)return this.error("Expression name must be a string, but found ".concat(typeof s,' instead. If you wanted a literal array, use ["literal", [...]].'),0),null;const i=this.registry[s];if(i){let s=i.parse(e,this);if(!s)return null;if(this.expectedType){const e=this.expectedType,i=s.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else s=n(s,e,t.typeAnnotation||"coerce");else s=n(s,e,t.typeAnnotation||"assert")}if(!(s instanceof kt)&&"resolvedImage"!==s.type.kind&&Cn(s)){const t=new Jt;try{s=new kt(s.type,s.evaluate(t))}catch(e){return this.error(e.message),null}}return s}return this.error('Unknown expression "'.concat(s,'". If you wanted a literal array, use ["literal", [...]].'),0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':"Expected an array, but found ".concat(typeof e," instead."))}concat(e,t,n){const s="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new Dn(this.registry,s,t||null,i,this.errors)}error(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s"[".concat(e,"]"))).join(""));this.errors.push(new lt(i,e))}checkSubtype(e,t){const n=gt(e,t);return n&&this.error(n),n}}var An=Dn;function Cn(e){if(e instanceof Sn)return Cn(e.boundExpression);if(e instanceof en&&"error"===e.name)return!1;if(e instanceof tn)return!1;if(e instanceof wn)return!1;const t=e instanceof Kt||e instanceof Wt;let n=!0;return e.eachChild((e=>{n=t?n&&Cn(e):n&&e instanceof kt})),!!n&&gn(e)&&bn(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function xn(e,t){const n=e.length-1;let s,i,l=0,a=n,r=0;for(;l<=a;)if(r=Math.floor((l+a)/2),s=e[r],i=e[r+1],s<=t){if(r===n||tt))throw new zt("Input is not a number.");a=r-1}return 0}class _n{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[s,i]of n)this.labels.push(s),this.outputs.push(i)}static parse(e,t){if(e.length-1<4)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,ut);if(!n)return null;const s=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let l=1;l=n)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',r);const u=t.parse(a,o,i);if(!u)return null;i=i||u.type,s.push([n,u])}return new _n(i,n,s)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=t[0])return n[0].evaluate(e);const i=t.length;return s>=t[i-1]?n[i-1].evaluate(e):n[xn(t,s)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var On=_n;function Nn(e,t,n){return e*(1-n)+t*n}var Ln=Object.freeze({__proto__:null,array:function(e,t,n){return e.map(((e,s)=>Nn(e,t[s],n)))},color:function(e,t,n){return new Ot(Nn(e.r,t.r,n),Nn(e.g,t.g,n),Nn(e.b,t.b,n),Nn(e.a,t.a,n))},number:Nn});const Pn=.95047,Mn=1.08883,Fn=4/29,Bn=6/29,Hn=3*Bn*Bn,Un=Bn*Bn*Bn,Gn=Math.PI/180,kn=180/Math.PI;function zn(e){return e>Un?Math.pow(e,1/3):e/Hn+Fn}function Vn(e){return e>Bn?e*e*e:Hn*(e-Fn)}function jn(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Wn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Yn(e){const t=Wn(e.r),n=Wn(e.g),s=Wn(e.b),i=zn((.4124564*t+.3575761*n+.1804375*s)/Pn),l=zn((.2126729*t+.7151522*n+.072175*s)/1);return{l:116*l-16,a:500*(i-l),b:200*(l-zn((.0193339*t+.119192*n+.9503041*s)/Mn)),alpha:e.a}}function qn(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,s=isNaN(e.b)?t:t-e.b/200;return t=1*Vn(t),n=Pn*Vn(n),s=Mn*Vn(s),new Ot(jn(3.2404542*n-1.5371385*t-.4985314*s),jn(-.969266*n+1.8760108*t+.041556*s),jn(.0556434*n-.2040259*t+1.0572252*s),e.alpha)}function Xn(e,t,n){const s=t-e;return e+n*(s>180||s<-180?s-360*Math.round(s/360):s)}const Zn={forward:Yn,reverse:qn,interpolate:function(e,t,n){return{l:Nn(e.l,t.l,n),a:Nn(e.a,t.a,n),b:Nn(e.b,t.b,n),alpha:Nn(e.alpha,t.alpha,n)}}},Kn={forward:function(e){const{l:t,a:n,b:s}=Yn(e),i=Math.atan2(s,n)*kn;return{h:i<0?i+360:i,c:Math.sqrt(n*n+s*s),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Gn,n=e.c;return qn({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:Xn(e.h,t.h,n),c:Nn(e.c,t.c,n),l:Nn(e.l,t.l,n),alpha:Nn(e.alpha,t.alpha,n)}}};var Qn=Object.freeze({__proto__:null,hcl:Kn,lab:Zn});class Jn{constructor(e,t,n,s,i){this.type=e,this.operator=t,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(const[l,a]of i)this.labels.push(l),this.outputs.push(a)}static interpolationFactor(e,t,n,s){let i=0;if("exponential"===e.name)i=$n(t,e.base,n,s);else if("linear"===e.name)i=$n(t,1,n,s);else if("cubic-bezier"===e.name){const l=e.controlPoints;i=new m(l[0],l[1],l[2],l[3]).solve($n(t,1,n,s))}return i}static parse(e,t){let[n,s,i,...l]=e;if(!Array.isArray(s)||0===s.length)return t.error("Expected an interpolation type expression.",1);if("linear"===s[0])s={name:"linear"};else if("exponential"===s[0]){const e=s[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:e}}else{if("cubic-bezier"!==s[0])return t.error("Unknown interpolation type ".concat(String(s[0])),1,0);{const e=s.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,ut),!i)return null;const a=[];let r=null;"interpolate-hcl"===n||"interpolate-lab"===n?r=pt:t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let o=0;o=e)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(n,i,r);if(!u)return null;r=r||u.type,a.push([e,u])}return"number"===r.kind||"color"===r.kind||"array"===r.kind&&"number"===r.itemType.kind&&"number"==typeof r.N?new Jn(r,n,s,i,a):t.error("Type ".concat(Et(r)," is not interpolatable."))}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=t[0])return n[0].evaluate(e);const i=t.length;if(s>=t[i-1])return n[i-1].evaluate(e);const l=xn(t,s),a=Jn.interpolationFactor(this.interpolation,s,t[l],t[l+1]),r=n[l].evaluate(e),o=n[l+1].evaluate(e);return"interpolate"===this.operator?Ln[this.type.kind.toLowerCase()](r,o,a):"interpolate-hcl"===this.operator?Kn.reverse(Kn.interpolate(Kn.forward(r),Kn.forward(o),a)):Zn.reverse(Zn.interpolate(Zn.forward(r),Zn.forward(o),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let n=0;ngt(s,e.type)));return new ts(l?ft:n,i)}evaluate(e){let t,n=null,s=0;for(const i of this.args){if(s++,n=i.evaluate(e),n&&n instanceof Mt&&!n.available&&(t||(t=n),n=null,s===this.args.length))return t;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var ns=ts;class ss{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error("Expected at least 3 arguments, but found ".concat(e.length-1," instead."));const n=[];for(let i=1;i=n.length)throw new zt("Array index out of bounds: ".concat(t," > ").concat(n.length-1,"."));if(t!==Math.floor(t))throw new zt("Array index must be an integer, but found ".concat(t," instead."));return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var as=ls;class rs{constructor(e,t){this.type=ht,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error("Expected 2 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ft),s=t.parse(e[2],2,ft);return n&&s?Tt(n.type,[ht,ct,ut,ot,ft])?new rs(n,s):t.error("Expected first argument to be of type boolean, string, number or null, but found ".concat(Et(n.type)," instead")):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!bt(t,["boolean","string","number","null"]))throw new zt("Expected first argument to be of type boolean, string, number or null, but found ".concat(Et(Ht(t))," instead."));if(!bt(n,["string","array"]))throw new zt("Expected second argument to be of type array or string, but found ".concat(Et(Ht(n))," instead."));return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var os=rs;class us{constructor(e,t,n){this.type=ut,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error("Expected 3 or 4 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ft),s=t.parse(e[2],2,ft);if(!n||!s)return null;if(!Tt(n.type,[ht,ct,ut,ot,ft]))return t.error("Expected first argument to be of type boolean, string, number or null, but found ".concat(Et(n.type)," instead"));if(4===e.length){const i=t.parse(e[3],3,ut);return i?new us(n,s,i):null}return new us(n,s)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!bt(t,["boolean","string","number","null"]))throw new zt("Expected first argument to be of type boolean, string, number or null, but found ".concat(Et(Ht(t))," instead."));if(!bt(n,["string","array"]))throw new zt("Expected second argument to be of type array or string, but found ".concat(Et(Ht(n))," instead."));if(this.fromIndex){const s=this.fromIndex.evaluate(e);return n.indexOf(t,s)}return n.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var cs=us;class hs{constructor(e,t,n,s,i,l){this.inputType=e,this.type=t,this.input=n,this.cases=s,this.outputs=i,this.otherwise=l}static parse(e,t){if(e.length<5)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,s;t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);const i={},l=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return u.error("Branch labels must be integers no larger than ".concat(Number.MAX_SAFE_INTEGER,"."));if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,Ht(e)))return null}else n=Ht(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=l.length}const c=t.parse(r,o,s);if(!c)return null;s=s||c.type,l.push(c)}const a=t.parse(e[1],1,ft);if(!a)return null;const r=t.parse(e[e.length-1],e.length-1,s);return r?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new hs(n,s,a,i,l,r):null}evaluate(e){const t=this.input.evaluate(e);return(Ht(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],s={};for(const l of t){const e=s[this.cases[l]];void 0===e?(s[this.cases[l]]=n.length,n.push([this.cases[l],[l]])):n[e][1].push(l)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[l,a]of n)e.push(1===a.length?i(a[0]):a.map(i)),e.push(this.outputs[l].serialize());return e.push(this.otherwise.serialize()),e}}var ps=hs;class ds{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error("Expected at least 3 arguments, but found only ".concat(e.length-1,"."));if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const s=[];for(let l=1;l{let[t,n]=e;return n.outputDefined()}))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var fs=ds;class ms{constructor(e,t,n,s){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=s}static parse(e,t){if(e.length<=2||e.length>=5)return t.error("Expected 3 or 4 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ft),s=t.parse(e[2],2,ut);if(!n||!s)return null;if(!Tt(n.type,[vt(ft),ct,ft]))return t.error("Expected first argument to be of type array or string, but found ".concat(Et(n.type)," instead"));if(4===e.length){const i=t.parse(e[3],3,ut);return i?new ms(n.type,n,s,i):null}return new ms(n.type,n,s)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!bt(t,["string","array"]))throw new zt("Expected first argument to be of type array or string, but found ".concat(Et(Ht(t))," instead."));if(this.endIndex){const s=this.endIndex.evaluate(e);return t.slice(n,s)}return t.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Is=ms;function ys(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function vs(e,t,n,s){return 0===s.compare(t,n)}function Es(e,t,n){const s="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=ht,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const n=e[0];let l=t.parse(e[1],1,ft);if(!l)return null;if(!ys(n,l.type))return t.concat(1).error('"'.concat(n,"\" comparisons are not supported for type '").concat(Et(l.type),"'."));let a=t.parse(e[2],2,ft);if(!a)return null;if(!ys(n,a.type))return t.concat(2).error('"'.concat(n,"\" comparisons are not supported for type '").concat(Et(a.type),"'."));if(l.type.kind!==a.type.kind&&"value"!==l.type.kind&&"value"!==a.type.kind)return t.error("Cannot compare types '".concat(Et(l.type),"' and '").concat(Et(a.type),"'."));s&&("value"===l.type.kind&&"value"!==a.type.kind?l=new Wt(a.type,[l]):"value"!==l.type.kind&&"value"===a.type.kind&&(a=new Wt(l.type,[a])));let r=null;if(4===e.length){if("string"!==l.type.kind&&"string"!==a.type.kind&&"value"!==l.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(r=t.parse(e[3],3,mt),!r)return null}return new i(l,a,r)}evaluate(i){const l=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(s&&this.hasUntypedArgument){const t=Ht(l),n=Ht(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new zt('Expected arguments for "'.concat(e,'" to be (string, string) or (number, number), but found (').concat(t.kind,", ").concat(n.kind,") instead."))}if(this.collator&&!s&&this.hasUntypedArgument){const e=Ht(l),n=Ht(a);if("string"!==e.kind||"string"!==n.kind)return t(i,l,a)}return this.collator?n(i,l,a,this.collator.evaluate(i)):t(i,l,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const ws=Es("==",(function(e,t,n){return t===n}),vs),gs=Es("!=",(function(e,t,n){return t!==n}),(function(e,t,n,s){return!vs(0,t,n,s)})),Ts=Es("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,s){return s.compare(t,n)>0})),Rs=Es("<=",(function(e,t,n){return t<=n}),(function(e,t,n,s){return s.compare(t,n)<=0})),Ss=Es(">=",(function(e,t,n){return t>=n}),(function(e,t,n,s){return s.compare(t,n)>=0}));class Ds{constructor(e,t,n,s,i,l){this.type=ct,this.number=e,this.locale=t,this.currency=n,this.unit=s,this.minFractionDigits=i,this.maxFractionDigits=l}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ut);if(!n)return null;const s=e[2];if("object"!=typeof s||Array.isArray(s))return t.error("NumberFormat options argument must be an object.");let i=null;if(s.locale&&(i=t.parse(s.locale,1,ct),!i))return null;let l=null;if(s.currency&&(l=t.parse(s.currency,1,ct),!l))return null;let a=null;if(s.unit&&(a=t.parse(s.unit,1,ct),!a))return null;let r=null;if(s["min-fraction-digits"]&&(r=t.parse(s["min-fraction-digits"],1,ut),!r))return null;let o=null;return s["max-fraction-digits"]&&(o=t.parse(s["max-fraction-digits"],1,ut),!o)?null:new Ds(n,i,l,a,r,o)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class As{constructor(e){this.type=ut,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected 1 argument, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error("Expected argument of type string or array, but found ".concat(Et(n.type)," instead.")):new As(n):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new zt("Expected value to be of type string or array, but found ".concat(Et(Ht(t))," instead."))}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const Cs={"==":ws,"!=":gs,">":bs,"<":Ts,">=":Ss,"<=":Rs,array:Wt,at:as,boolean:Wt,case:fs,coalesce:ns,collator:tn,format:Yt,image:qt,in:os,"index-of":cs,interpolate:es,"interpolate-hcl":es,"interpolate-lab":es,length:As,let:is,literal:kt,match:ps,number:Wt,"number-format":Ds,object:Wt,slice:Is,step:On,string:Wt,"to-boolean":Kt,"to-color":Kt,"to-number":Kt,"to-string":Kt,var:Sn,within:wn};function xs(e,t){let[n,s,i,l]=t;n=n.evaluate(e),s=s.evaluate(e),i=i.evaluate(e);const a=l?l.evaluate(e):1,r=Ft(n,s,i,a);if(r)throw new zt(r);return new Ot(n/255*a,s/255*a,i/255*a,a)}function _s(e,t){return e in t}function Os(e,t){const n=t[e];return void 0===n?null:n}function Ns(e){return{type:e}}en.register(Cs,{error:[{kind:"error"},[ct],(e,t)=>{let[n]=t;throw new zt(n.evaluate(e))}],typeof:[ct,[ft],(e,t)=>{let[n]=t;return Et(Ht(n.evaluate(e)))}],"to-rgba":[vt(ut,4),[pt],(e,t)=>{let[n]=t;return n.evaluate(e).toArray()}],rgb:[pt,[ut,ut,ut],xs],rgba:[pt,[ut,ut,ut,ut],xs],has:{type:ht,overloads:[[[ct],(e,t)=>{let[n]=t;return _s(n.evaluate(e),e.properties())}],[[ct,dt],(e,t)=>{let[n,s]=t;return _s(n.evaluate(e),s.evaluate(e))}]]},get:{type:ft,overloads:[[[ct],(e,t)=>{let[n]=t;return Os(n.evaluate(e),e.properties())}],[[ct,dt],(e,t)=>{let[n,s]=t;return Os(n.evaluate(e),s.evaluate(e))}]]},"feature-state":[ft,[ct],(e,t)=>{let[n]=t;return Os(n.evaluate(e),e.featureState||{})}],properties:[dt,[],e=>e.properties()],"geometry-type":[ct,[],e=>e.geometryType()],id:[ft,[],e=>e.id()],zoom:[ut,[],e=>e.globals.zoom],pitch:[ut,[],e=>e.globals.pitch||0],"distance-from-center":[ut,[],e=>e.distanceFromCenter()],"heatmap-density":[ut,[],e=>e.globals.heatmapDensity||0],"line-progress":[ut,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[ut,[],e=>e.globals.skyRadialProgress||0],accumulated:[ft,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ut,Ns(ut),(e,t)=>{let n=0;for(const s of t)n+=s.evaluate(e);return n}],"*":[ut,Ns(ut),(e,t)=>{let n=1;for(const s of t)n*=s.evaluate(e);return n}],"-":{type:ut,overloads:[[[ut,ut],(e,t)=>{let[n,s]=t;return n.evaluate(e)-s.evaluate(e)}],[[ut],(e,t)=>{let[n]=t;return-n.evaluate(e)}]]},"/":[ut,[ut,ut],(e,t)=>{let[n,s]=t;return n.evaluate(e)/s.evaluate(e)}],"%":[ut,[ut,ut],(e,t)=>{let[n,s]=t;return n.evaluate(e)%s.evaluate(e)}],ln2:[ut,[],()=>Math.LN2],pi:[ut,[],()=>Math.PI],e:[ut,[],()=>Math.E],"^":[ut,[ut,ut],(e,t)=>{let[n,s]=t;return Math.pow(n.evaluate(e),s.evaluate(e))}],sqrt:[ut,[ut],(e,t)=>{let[n]=t;return Math.sqrt(n.evaluate(e))}],log10:[ut,[ut],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))/Math.LN10}],ln:[ut,[ut],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))}],log2:[ut,[ut],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))/Math.LN2}],sin:[ut,[ut],(e,t)=>{let[n]=t;return Math.sin(n.evaluate(e))}],cos:[ut,[ut],(e,t)=>{let[n]=t;return Math.cos(n.evaluate(e))}],tan:[ut,[ut],(e,t)=>{let[n]=t;return Math.tan(n.evaluate(e))}],asin:[ut,[ut],(e,t)=>{let[n]=t;return Math.asin(n.evaluate(e))}],acos:[ut,[ut],(e,t)=>{let[n]=t;return Math.acos(n.evaluate(e))}],atan:[ut,[ut],(e,t)=>{let[n]=t;return Math.atan(n.evaluate(e))}],min:[ut,Ns(ut),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[ut,Ns(ut),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[ut,[ut],(e,t)=>{let[n]=t;return Math.abs(n.evaluate(e))}],round:[ut,[ut],(e,t)=>{let[n]=t;const s=n.evaluate(e);return s<0?-Math.round(-s):Math.round(s)}],floor:[ut,[ut],(e,t)=>{let[n]=t;return Math.floor(n.evaluate(e))}],ceil:[ut,[ut],(e,t)=>{let[n]=t;return Math.ceil(n.evaluate(e))}],"filter-==":[ht,[ct,ft],(e,t)=>{let[n,s]=t;return e.properties()[n.value]===s.value}],"filter-id-==":[ht,[ft],(e,t)=>{let[n]=t;return e.id()===n.value}],"filter-type-==":[ht,[ct],(e,t)=>{let[n]=t;return e.geometryType()===n.value}],"filter-<":[ht,[ct,ft],(e,t)=>{let[n,s]=t;const i=e.properties()[n.value],l=s.value;return typeof i==typeof l&&i{let[n]=t;const s=e.id(),i=n.value;return typeof s==typeof i&&s":[ht,[ct,ft],(e,t)=>{let[n,s]=t;const i=e.properties()[n.value],l=s.value;return typeof i==typeof l&&i>l}],"filter-id->":[ht,[ft],(e,t)=>{let[n]=t;const s=e.id(),i=n.value;return typeof s==typeof i&&s>i}],"filter-<=":[ht,[ct,ft],(e,t)=>{let[n,s]=t;const i=e.properties()[n.value],l=s.value;return typeof i==typeof l&&i<=l}],"filter-id-<=":[ht,[ft],(e,t)=>{let[n]=t;const s=e.id(),i=n.value;return typeof s==typeof i&&s<=i}],"filter->=":[ht,[ct,ft],(e,t)=>{let[n,s]=t;const i=e.properties()[n.value],l=s.value;return typeof i==typeof l&&i>=l}],"filter-id->=":[ht,[ft],(e,t)=>{let[n]=t;const s=e.id(),i=n.value;return typeof s==typeof i&&s>=i}],"filter-has":[ht,[ft],(e,t)=>{let[n]=t;return n.value in e.properties()}],"filter-has-id":[ht,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ht,[vt(ct)],(e,t)=>{let[n]=t;return n.value.indexOf(e.geometryType())>=0}],"filter-id-in":[ht,[vt(ft)],(e,t)=>{let[n]=t;return n.value.indexOf(e.id())>=0}],"filter-in-small":[ht,[ct,vt(ft)],(e,t)=>{let[n,s]=t;return s.value.indexOf(e.properties()[n.value])>=0}],"filter-in-large":[ht,[ct,vt(ft)],(e,t)=>{let[n,s]=t;return function(e,t,n,s){for(;n<=s;){const i=n+s>>1;if(t[i]===e)return!0;t[i]>e?s=i-1:n=i+1}return!1}(e.properties()[n.value],s.value,0,s.value.length-1)}],all:{type:ht,overloads:[[[ht,ht],(e,t)=>{let[n,s]=t;return n.evaluate(e)&&s.evaluate(e)}],[Ns(ht),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:ht,overloads:[[[ht,ht],(e,t)=>{let[n,s]=t;return n.evaluate(e)||s.evaluate(e)}],[Ns(ht),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[ht,[ht],(e,t)=>{let[n]=t;return!n.evaluate(e)}],"is-supported-script":[ht,[ct],(e,t)=>{let[n]=t;const s=e.globals&&e.globals.isSupportedScript;return!s||s(n.evaluate(e))}],upcase:[ct,[ct],(e,t)=>{let[n]=t;return n.evaluate(e).toUpperCase()}],downcase:[ct,[ct],(e,t)=>{let[n]=t;return n.evaluate(e).toLowerCase()}],concat:[ct,Ns(ft),(e,t)=>t.map((t=>Ut(t.evaluate(e)))).join("")],"resolved-locale":[ct,[mt],(e,t)=>{let[n]=t;return n.evaluate(e).resolvedLocale()}]});var Ls=Cs;function Ps(e){return{result:"success",value:e}}function Ms(e){return{result:"error",value:e}}function Fs(e){return"data-driven"===e["property-type"]}function Bs(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hs(e){return!!e.expression&&e.expression.interpolated}function Us(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Gs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ks(e){return e}function zs(e,t){const n="color"===t.type,s=e.stops&&"object"==typeof e.stops[0][0],i=s||!(s||void 0!==e.property),l=e.type||(Hs(t)?"exponential":"interval");if(n&&((e=tt({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Ot.parse(e[1])]))),e.default=Ot.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Qn[e.colorSpace])throw new Error("Unknown color space: ".concat(e.colorSpace));let a,r,o;if("exponential"===l)a=Ys;else if("interval"===l)a=Ws;else if("categorical"===l){a=js,r=Object.create(null);for(const t of e.stops)r[t[0]]=t[1];o=typeof e.stops[0][0]}else{if("identity"!==l)throw new Error('Unknown function type "'.concat(l,'"'));a=qs}if(s){const n={},s=[];for(let t=0;te[0])),evaluate:(n,s)=>{let{zoom:l}=n;return Ys({stops:i,base:e.base},t,l).evaluate(l,s)}}}if(i){const n="exponential"===l?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:n,interpolationFactor:es.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map((e=>e[0])),evaluate:n=>{let{zoom:s}=n;return a(e,t,s,r,o)}}}return{kind:"source",evaluate(n,s){const i=s&&s.properties?s.properties[e.property]:void 0;return void 0===i?Vs(e.default,t.default):a(e,t,i,r,o)}}}function Vs(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function js(e,t,n,s,i){return Vs(typeof n===i?s[n]:void 0,e.default,t.default)}function Ws(e,t,n){if("number"!==Us(n))return Vs(e.default,t.default);const s=e.stops.length;if(1===s)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[s-1][0])return e.stops[s-1][1];const i=xn(e.stops.map((e=>e[0])),n);return e.stops[i][1]}function Ys(e,t,n){const s=void 0!==e.base?e.base:1;if("number"!==Us(n))return Vs(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const l=xn(e.stops.map((e=>e[0])),n),a=function(e,t,n,s){const i=s-n,l=e-n;return 0===i?0:1===t?l/i:(Math.pow(t,l)-1)/(Math.pow(t,i)-1)}(n,s,e.stops[l][0],e.stops[l+1][0]),r=e.stops[l][1],o=e.stops[l+1][1];let u=Ln[t.type]||ks;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Qn[e.colorSpace];u=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof r.evaluate?{evaluate(){for(var e=arguments.length,t=new Array(e),n=0;nJSON.stringify(e))).join(", "),", but found ").concat(JSON.stringify(e)," instead."));return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Zs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ls}function Ks(e,t){const n=new An(Ls,[],t?function(e){const t={color:pt,string:ct,number:ut,enum:ct,boolean:ht,formatted:It,resolvedImage:yt};return"array"===e.type?vt(t[e.value]||ft,e.length):t[e.type]}(t):void 0),s=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return s?Ps(new Xs(s,t)):Ms(n.errors)}class Qs{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Tn(t.expression)}evaluateWithoutErrorHandling(e,t,n,s,i,l){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,s,i,l)}evaluate(e,t,n,s,i,l){return this._styleExpression.evaluate(e,t,n,s,i,l)}}class Js{constructor(e,t,n,s){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Tn(t.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,t,n,s,i,l){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,s,i,l)}evaluate(e,t,n,s,i,l){return this._styleExpression.evaluate(e,t,n,s,i,l)}interpolationFactor(e,t,n){return this.interpolationType?es.interpolationFactor(this.interpolationType,e,t,n):0}}function $s(e,t){if("error"===(e=Ks(e,t)).result)return e;const n=e.value.expression,s=gn(n);if(!s&&!Fs(t))return Ms([new lt("","data expressions not supported")]);const i=bn(n,["zoom","pitch","distance-from-center"]);if(!i&&!Bs(t))return Ms([new lt("","zoom expressions not supported")]);const l=ti(n);return l||i?l instanceof lt?Ms([l]):l instanceof es&&!Hs(t)?Ms([new lt("",'"interpolate" expressions cannot be used with this property')]):Ps(l?new Js(s?"camera":"composite",e.value,l.labels,l instanceof es?l.interpolation:void 0):new Qs(s?"constant":"source",e.value)):Ms([new lt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ei{constructor(e,t){this._parameters=e,this._specification=t,tt(this,zs(this._parameters,this._specification))}static deserialize(e){return new ei(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ti(e){let t=null;if(e instanceof is)t=ti(e.result);else if(e instanceof ns){for(const n of e.args)if(t=ti(n),t)break}else(e instanceof On||e instanceof es)&&e.input instanceof en&&"zoom"===e.input.name&&(t=e);return t instanceof lt||e.eachChild((e=>{const n=ti(e);n instanceof lt?t=n:!t&&n?t=new lt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&n&&t!==n&&(t=new lt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class ni{constructor(e,t,n,s){this.message=(e?"".concat(e,": "):"")+n,s&&(this.identifier=s),null!=t&&t.__line__&&(this.line=t.__line__)}}function si(e){const t=e.key,n=e.value,s=e.valueSpec||{},i=e.objectElementValidators||{},l=e.style,a=e.styleSpec;let r=[];const o=Us(n);if("object"!==o)return[new ni(t,n,"object expected, ".concat(o," found"))];for(const u in n){const e=u.split(".")[0];let o;i[e]?o=i[e]:s[e]?o=Bi:i["*"]?o=i["*"]:s["*"]&&(o=Bi),o?r=r.concat(o({key:(t?"".concat(t,"."):t)+u,value:n[u],valueSpec:s[e]||s["*"],style:l,styleSpec:a,object:n,objectKey:u},n)):r.push(new ni(t,n[u],'unknown property "'.concat(u,'"')))}for(const u in s)i[u]||s[u].required&&void 0===s[u].default&&void 0===n[u]&&r.push(new ni(t,n,'missing required property "'.concat(u,'"')));return r}function ii(e){const t=e.value,n=e.valueSpec,s=e.style,i=e.styleSpec,l=e.key,a=e.arrayElementValidator||Bi;if("array"!==Us(t))return[new ni(l,t,"array expected, ".concat(Us(t)," found"))];if(n.length&&t.length!==n.length)return[new ni(l,t,"array length ".concat(n.length," expected, length ").concat(t.length," found"))];if(n["min-length"]&&t.lengthi)return[new ni(t,n,"".concat(n," is greater than the maximum value ").concat(i))]}return[]}function ai(e){const t=e.valueSpec,n=nt(e.value.type);let s,i,l,a={};const r="categorical"!==n&&void 0===e.value.property,o=!r,u="array"===Us(e.value.stops)&&"array"===Us(e.value.stops[0])&&"object"===Us(e.value.stops[0][0]),c=si({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new ni(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const s=e.value;return t=t.concat(ii({key:e.key,value:s,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Us(s)&&0===s.length&&t.push(new ni(e.key,s,"array must have at least one stop")),t},default:function(e){return Bi({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&r&&c.push(new ni(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new ni(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Hs(e.valueSpec)&&c.push(new ni(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(o&&!Fs(e.valueSpec)?c.push(new ni(e.key,e.value,"property functions not supported")):r&&!Bs(e.valueSpec)&&c.push(new ni(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new ni(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const s=e.value,r=e.key;if("array"!==Us(s))return[new ni(r,s,"array expected, ".concat(Us(s)," found"))];if(2!==s.length)return[new ni(r,s,"array length 2 expected, length ".concat(s.length," found"))];if(u){if("object"!==Us(s[0]))return[new ni(r,s,"object expected, ".concat(Us(s[0])," found"))];if(void 0===s[0].zoom)return[new ni(r,s,"object stop key must have zoom")];if(void 0===s[0].value)return[new ni(r,s,"object stop key must have value")];const t=nt(s[0].zoom);if("number"!=typeof t)return[new ni(r,s[0].zoom,"stop zoom values must be numbers")];if(l&&l>t)return[new ni(r,s[0].zoom,"stop zoom values must appear in ascending order")];t!==l&&(l=t,i=void 0,a={}),n=n.concat(si({key:"".concat(r,"[0]"),value:s[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:li,value:p}}))}else n=n.concat(p({key:"".concat(r,"[0]"),value:s[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},s));return Zs(st(s[1]))?n.concat([new ni("".concat(r,"[1]"),s[1],"expressions are not allowed in function stops.")]):n.concat(Bi({key:"".concat(r,"[1]"),value:s[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,l){const r=Us(e.value),o=nt(e.value),u=null!==e.value?e.value:l;if(s){if(r!==s)return[new ni(e.key,u,"".concat(r," stop domain type must match previous stop domain type ").concat(s))]}else s=r;if("number"!==r&&"string"!==r&&"boolean"!==r&&"number"!=typeof o&&"string"!=typeof o&&"boolean"!=typeof o)return[new ni(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==r&&"categorical"!==n){let s="number expected, ".concat(r," found");return Fs(t)&&void 0===n&&(s+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ni(e.key,u,s)]}return"categorical"!==n||"number"!==r||"number"==typeof o&&isFinite(o)&&Math.floor(o)===o?"categorical"!==n&&"number"===r&&"number"==typeof o&&"number"==typeof i&&void 0!==i&&onew ni("".concat(e.key).concat(t.key),e.value,t.message)));const n=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!n.outputDefined())return[new ni(e.key,e.value,'Invalid data expression for "'.concat(e.propertyKey,'". Output values must be contained as literals within the expression.'))];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Tn(n))return[new ni(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return oi(n,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!bn(n,["zoom","feature-state"]))return[new ni(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!gn(n))return[new ni(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function oi(e,t){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const i of t.valueSpec.expression.parameters)n.delete(i);if(0===n.size)return[];const s=[];return e instanceof en&&n.has(e.name)?[new ni(t.key,t.value,'["'.concat(e.name,'"] expression is not supported in a filter for a ').concat(t.object.type," layer with id: ").concat(t.object.id))]:(e.eachChild((e=>{s.push(...oi(e,t))})),s)}function ui(e){const t=e.key,n=e.value,s=e.valueSpec,i=[];return Array.isArray(s.values)?-1===s.values.indexOf(nt(n))&&i.push(new ni(t,n,"expected one of [".concat(s.values.join(", "),"], ").concat(JSON.stringify(n)," found"))):-1===Object.keys(s.values).indexOf(nt(n))&&i.push(new ni(t,n,"expected one of [".concat(Object.keys(s.values).join(", "),"], ").concat(JSON.stringify(n)," found"))),i}function ci(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!ci(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function hi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fill";if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ci(e)||(e=vi(e));const n=e;let s=!0;try{s=function(e){if(!fi(e))return e;let t=st(e);return di(t),t=pi(t),t}(n)}catch(e){console.warn("Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n".concat(JSON.stringify(n,null,2),"\n "))}const i=et["filter_".concat(t)],l=Ks(s,i);let a=null;if("error"===l.result)throw new Error(l.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));a=(e,t,n)=>l.value.evaluate(e,t,{},n);let r=null,o=null;if(s!==n){const e=Ks(n,i);if("error"===e.result)throw new Error(e.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));r=(t,n,s,i,l)=>e.value.evaluate(t,n,{},s,void 0,void 0,i,l),o=!gn(e.value.expression)}return{filter:a,dynamicFilter:r||void 0,needGeometry:yi(s),needFeature:!!o}}function pi(e){if(!Array.isArray(e))return e;const t=function(e){if(mi.has(e[0]))for(let t=1;tpi(e)))}function di(e){let t=!1;const n=[];if("case"===e[0]){for(let s=1;s",">=","<","<=","to-boolean"]);function Ii(e,t){return et?1:0}function yi(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?Ei(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(vi))):"all"===t?["all"].concat(e.slice(1).map(vi)):"none"===t?["all"].concat(e.slice(1).map(vi).map(Ti)):"in"===t?wi(e[1],e.slice(2)):"!in"===t?Ti(wi(e[1],e.slice(2))):"has"===t?gi(e[1]):"!has"===t?Ti(gi(e[1])):"within"!==t||e;var n}function Ei(e,t,n){switch(e){case"$type":return["filter-type-".concat(n),t];case"$id":return["filter-id-".concat(n),t];default:return["filter-".concat(n),e,t]}}function wi(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(Ii)]]:["filter-in-small",e,["literal",t]]}}function gi(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ti(e){return["!",e]}function bi(e){return ci(st(e.value))?ri(tt({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_".concat(e.layerType||"fill")]})):Ri(e)}function Ri(e){const t=e.value,n=e.key;if("array"!==Us(t))return[new ni(n,t,"array expected, ".concat(Us(t)," found"))];const s=e.styleSpec;let i,l=[];if(t.length<1)return[new ni(n,t,"filter array must have at least 1 element")];switch(l=l.concat(ui({key:"".concat(n,"[0]"),value:t[0],valueSpec:s.filter_operator,style:e.style,styleSpec:e.styleSpec})),nt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===nt(t[1])&&l.push(new ni(n,t,'"$type" cannot be use with operator "'.concat(t[0],'"')));case"==":case"!=":3!==t.length&&l.push(new ni(n,t,'filter array for operator "'.concat(t[0],'" must have 3 elements')));case"in":case"!in":t.length>=2&&(i=Us(t[1]),"string"!==i&&l.push(new ni("".concat(n,"[1]"),t[1],"string expected, ".concat(i," found"))));for(let a=2;a{e in n&&t.push(new ni(s,n[e],'"'.concat(e,'" is prohibited for ref layers')))})),i.layers.forEach((t=>{nt(t.id)===r&&(e=t)})),e?e.ref?t.push(new ni(s,n.ref,"ref cannot reference another ref layer")):a=nt(e.type):"string"==typeof r&&t.push(new ni(s,n.ref,'ref layer "'.concat(r,'" not found')))}else if("background"!==a&&"sky"!==a)if(n.source){const e=i.sources&&i.sources[n.source],l=e&&nt(e.type);e?"vector"===l&&"raster"===a?t.push(new ni(s,n.source,'layer "'.concat(n.id,'" requires a raster source'))):"raster"===l&&"raster"!==a?t.push(new ni(s,n.source,'layer "'.concat(n.id,'" requires a vector source'))):"vector"!==l||n["source-layer"]?"raster-dem"===l&&"hillshade"!==a?t.push(new ni(s,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===l&&e.lineMetrics||t.push(new ni(s,n,'layer "'.concat(n.id,'" specifies a line-gradient, which requires a GeoJSON source with `lineMetrics` enabled.'))):t.push(new ni(s,n,'layer "'.concat(n.id,'" must specify a "source-layer"'))):t.push(new ni(s,n.source,'source "'.concat(n.source,'" not found')))}else t.push(new ni(s,n,'missing required property "source"'));return t=t.concat(si({key:s,value:n,valueSpec:l.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Bi({key:"".concat(s,".type"),value:n.type,valueSpec:l.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>bi(tt({layerType:a},e)),layout:e=>si({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Ai(tt({layerType:a},e))}}),paint:e=>si({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Di(tt({layerType:a},e))}})}})),t}function xi(e){const t=e.value,n=e.key,s=Us(t);return"string"!==s?[new ni(n,t,"string expected, ".concat(s," found"))]:[]}const _i={promoteId:function(e){let{key:t,value:n}=e;if("string"===Us(n))return xi({key:t,value:n});{const e=[];for(const s in n)e.push(...xi({key:"".concat(t,".").concat(s),value:n[s]}));return e}}};function Oi(e){const t=e.value,n=e.key,s=e.styleSpec,i=e.style;if(!t.type)return[new ni(n,t,'"type" is required')];const l=nt(t.type);let a;switch(l){case"vector":case"raster":case"raster-dem":return a=si({key:n,value:t,valueSpec:s["source_".concat(l.replace("-","_"))],style:e.style,styleSpec:s,objectElementValidators:_i}),a;case"geojson":if(a=si({key:n,value:t,valueSpec:s.source_geojson,style:i,styleSpec:s,objectElementValidators:_i}),t.cluster)for(const e in t.clusterProperties){const[s,i]=t.clusterProperties[e],l="string"==typeof s?[s,["accumulated"],["get",e]]:s;a.push(...ri({key:"".concat(n,".").concat(e,".map"),value:i,expressionContext:"cluster-map"})),a.push(...ri({key:"".concat(n,".").concat(e,".reduce"),value:l,expressionContext:"cluster-reduce"}))}return a;case"video":return si({key:n,value:t,valueSpec:s.source_video,style:i,styleSpec:s});case"image":return si({key:n,value:t,valueSpec:s.source_image,style:i,styleSpec:s});case"canvas":return[new ni(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ui({key:"".concat(n,".type"),value:t.type,valueSpec:{values:Ni(s)},style:i,styleSpec:s})}}function Ni(e){return e.source.reduce(((t,n)=>{const s=e[n];return"enum"===s.type.type&&(t=t.concat(Object.keys(s.type.values))),t}),[])}function Li(e){const t=e.value,n=e.styleSpec,s=n.light,i=e.style;let l=[];const a=Us(t);if(void 0===t)return l;if("object"!==a)return l=l.concat([new ni("light",t,"object expected, ".concat(a," found"))]),l;for(const r in t){const e=r.match(/^(.*)-transition$/);l=l.concat(e&&s[e[1]]&&s[e[1]].transition?Bi({key:r,value:t[r],valueSpec:n.transition,style:i,styleSpec:n}):s[r]?Bi({key:r,value:t[r],valueSpec:s[r],style:i,styleSpec:n}):[new ni(r,t[r],'unknown property "'.concat(r,'"'))])}return l}function Pi(e){const t=e.value,n=e.key,s=e.style,i=e.styleSpec,l=i.terrain;let a=[];const r=Us(t);if(void 0===t)return a;if("object"!==r)return a=a.concat([new ni("terrain",t,"object expected, ".concat(r," found"))]),a;for(const o in t){const e=o.match(/^(.*)-transition$/);a=a.concat(e&&l[e[1]]&&l[e[1]].transition?Bi({key:o,value:t[o],valueSpec:i.transition,style:s,styleSpec:i}):l[o]?Bi({key:o,value:t[o],valueSpec:l[o],style:s,styleSpec:i}):[new ni(o,t[o],'unknown property "'.concat(o,'"'))])}if(t.source){const e=s.sources&&s.sources[t.source],i=e&&nt(e.type);e?"raster-dem"!==i&&a.push(new ni(n,t.source,"terrain cannot be used with a source of type ".concat(String(i),', it only be used with a "raster-dem" source type'))):a.push(new ni(n,t.source,'source "'.concat(t.source,'" not found')))}else a.push(new ni(n,t,'terrain is missing required property "source"'));return a}function Mi(e){const t=e.value,n=e.style,s=e.styleSpec,i=s.fog;let l=[];const a=Us(t);if(void 0===t)return l;if("object"!==a)return l=l.concat([new ni("fog",t,"object expected, ".concat(a," found"))]),l;for(const r in t){const e=r.match(/^(.*)-transition$/);l=l.concat(e&&i[e[1]]&&i[e[1]].transition?Bi({key:r,value:t[r],valueSpec:s.transition,style:n,styleSpec:s}):i[r]?Bi({key:r,value:t[r],valueSpec:i[r],style:n,styleSpec:s}):[new ni(r,t[r],'unknown property "'.concat(r,'"'))])}return l}const Fi={"*":()=>[],array:ii,boolean:function(e){const t=e.value,n=e.key,s=Us(t);return"boolean"!==s?[new ni(n,t,"boolean expected, ".concat(s," found"))]:[]},number:li,color:function(e){const t=e.key,n=e.value,s=Us(n);return"string"!==s?[new ni(t,n,"color expected, ".concat(s," found"))]:null===Rt(n)?[new ni(t,n,'color expected, "'.concat(n,'" found'))]:[]},enum:ui,filter:bi,function:ai,layer:Ci,object:si,source:Oi,light:Li,terrain:Pi,fog:Mi,string:xi,formatted:function(e){return 0===xi(e).length?[]:ri(e)},resolvedImage:function(e){return 0===xi(e).length?[]:ri(e)},projection:function(e){const t=e.value,n=e.styleSpec,s=n.projection,i=e.style;let l=[];const a=Us(t);if("object"===a)for(const r in t)l=l.concat(Bi({key:r,value:t[r],valueSpec:s[r],style:i,styleSpec:n}));else"string"!==a&&(l=l.concat([new ni("projection",t,"object or string expected, ".concat(a," found"))]));return l}};function Bi(e){const t=e.value,n=e.valueSpec,s=e.styleSpec;return n.expression&&Gs(nt(t))?ai(e):n.expression&&Zs(st(t))?ri(e):n.type&&Fi[n.type]?Fi[n.type](e):si(tt({},e,{valueSpec:n.type?s[n.type]:n}))}function Hi(e){const t=e.value,n=e.key,s=xi(e);return s.length||(-1===t.indexOf("{fontstack}")&&s.push(new ni(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&s.push(new ni(n,t,'"glyphs" url must include a "{range}" token'))),s}function Ui(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;return zi(Bi({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:Hi,"*":()=>[]}}))}const Gi=e=>zi(Di(e)),ki=e=>zi(Ai(e));function zi(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Vi(e,t){let n=!1;if(t&&t.length)for(const s of t)e.fire(new Je(new Error(s.message))),n=!0;return n}var ji=Yi,Wi=3;function Yi(e,t,n){var s=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var l=0;l=c[d+0]&&s>=c[d+1])?(a[p]=!0,l.push(u[p])):a[p]=!1}}},Yi.prototype._forEachCell=function(e,t,n,s,i,l,a,r){for(var o=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(n),h=this._convertToCellCoord(s),p=o;p<=c;p++)for(var d=u;d<=h;d++){var f=this.d*d+p;if((!r||r(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&i.call(this,e,t,n,s,f,l,a,r))return}},Yi.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Yi.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Yi.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=Wi+this.cells.length+1+1,n=0,s=0;s2&&void 0!==arguments[2]?arguments[2]:{};Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Xi[t]={klass:e,omit:n.omit||[]}}Zi(Object,"Object"),qi.serialize=function(e,t){const n=e.toArrayBuffer();return t&&t.push(n),{buffer:n}},qi.deserialize=function(e){return new qi(e.buffer)},Object.defineProperty(qi,"name",{value:"Grid"}),Zi(qi,"Grid"),Zi(Ot,"Color"),Zi(Error,"Error"),Zi(ue,"AJAXError"),Zi(Mt,"ResolvedImage"),Zi(ei,"StylePropertyFunction"),Zi(Xs,"StyleExpression",{omit:["_evaluator"]}),Zi(Js,"ZoomDependentExpression"),Zi(Qs,"ZoomConstantExpression"),Zi(en,"CompoundExpression",{omit:["_evaluate"]});for(const bm in Ls)Xi[Ls[bm]._classRegistryKey]||Zi(Ls[bm],"Expression".concat(bm));function Ki(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function Qi(e){return t.ImageBitmap&&e instanceof t.ImageBitmap}function Ji(e,n){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(Ki(e)||Qi(e))return n&&n.push(e),e;if(ArrayBuffer.isView(e)){const t=e;return n&&n.push(t.buffer),t}if(e instanceof t.ImageData)return n&&n.push(e.data.buffer),e;if(Array.isArray(e)){const t=[];for(const s of e)t.push(Ji(s,n));return t}if("object"==typeof e){const t=e.constructor,s=t._classRegistryKey;if(!s)throw new Error("can't serialize object of unregistered class ".concat(s));const i=t.serialize?t.serialize(e,n):{};if(!t.serialize){for(const t in e)e.hasOwnProperty(t)&&(Xi[s].omit.indexOf(t)>=0||(i[t]=Ji(e[t],n)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==s&&(i.$name=s),i}throw new Error("can't serialize object of type "+typeof e)}function $i(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Ki(e)||Qi(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map($i);if("object"==typeof e){const t=e.$name||"Object",{klass:n}=Xi[t];if(!n)throw new Error("can't deserialize unregistered class ".concat(t));if(n.deserialize)return n.deserialize(e);const s=Object.create(n.prototype);for(const i of Object.keys(e))"$name"!==i&&(s[i]=$i(e[i]));return s}throw new Error("can't deserialize object of type "+typeof e)}const el={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function tl(e){for(const t of e)if(il(t.charCodeAt(0)))return!0;return!1}function nl(e){for(const t of e)if(!sl(t.charCodeAt(0)))return!1;return!0}function sl(e){return!(el.Arabic(e)||el["Arabic Supplement"](e)||el["Arabic Extended-A"](e)||el["Arabic Presentation Forms-A"](e)||el["Arabic Presentation Forms-B"](e))}function il(e){return!(746!==e&&747!==e&&(e<4352||!(el["Bopomofo Extended"](e)||el.Bopomofo(e)||el["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||el["CJK Compatibility Ideographs"](e)||el["CJK Compatibility"](e)||el["CJK Radicals Supplement"](e)||el["CJK Strokes"](e)||!(!el["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||el["CJK Unified Ideographs Extension A"](e)||el["CJK Unified Ideographs"](e)||el["Enclosed CJK Letters and Months"](e)||el["Hangul Compatibility Jamo"](e)||el["Hangul Jamo Extended-A"](e)||el["Hangul Jamo Extended-B"](e)||el["Hangul Jamo"](e)||el["Hangul Syllables"](e)||el.Hiragana(e)||el["Ideographic Description Characters"](e)||el.Kanbun(e)||el["Kangxi Radicals"](e)||el["Katakana Phonetic Extensions"](e)||el.Katakana(e)&&12540!==e||!(!el["Halfwidth and Fullwidth Forms"](e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!el["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||el["Unified Canadian Aboriginal Syllabics"](e)||el["Unified Canadian Aboriginal Syllabics Extended"](e)||el["Vertical Forms"](e)||el["Yijing Hexagram Symbols"](e)||el["Yi Syllables"](e)||el["Yi Radicals"](e))))}function ll(e){return!(il(e)||function(e){return!!(el["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||el["General Punctuation"](e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||el["Letterlike Symbols"](e)||el["Number Forms"](e)||el["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||el["Control Pictures"](e)&&9251!==e||el["Optical Character Recognition"](e)||el["Enclosed Alphanumerics"](e)||el["Geometric Shapes"](e)||el["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||el["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||el["CJK Symbols and Punctuation"](e)||el.Katakana(e)||el["Private Use Area"](e)||el["CJK Compatibility Forms"](e)||el["Small Form Variants"](e)||el["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function al(e){return e>=1424&&e<=2303||el["Arabic Presentation Forms-A"](e)||el["Arabic Presentation Forms-B"](e)}function rl(e,t){return!(!t&&al(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||el.Khmer(e))}function ol(e){for(const t of e)if(al(t.charCodeAt(0)))return!0;return!1}const ul="deferred",cl="loading",hl="loaded";let pl=null,dl="unavailable",fl=null;const ml=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(dl="error"),pl&&pl(e)};function Il(){yl.fire(new Qe("pluginStateChange",{pluginStatus:dl,pluginURL:fl}))}const yl=new $e,vl=function(){return dl},El=function(){if(dl!==ul||!fl)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");dl=cl,Il(),fl&&pe({url:fl},(e=>{e?ml(e):(dl=hl,Il())}))},wl={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>dl===hl||null!=wl.applyArabicShaping,isLoading:()=>dl===cl,setState(e){dl=e.pluginStatus,fl=e.pluginURL},isParsed:()=>null!=wl.applyArabicShaping&&null!=wl.processBidirectionalText&&null!=wl.processStyledBidirectionalText,getPluginURL:()=>fl};class gl{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!rl(n.charCodeAt(0),t))return!1;return!0}(e,wl.isLoaded())}}class Tl{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Gs(e))return new ei(e,t);if(Zs(e)){const n=$s(e,t);if("error"===n.result)throw new Error(n.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));return n.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Ot.parse(e)),{kind:"constant",evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class bl{constructor(e){this.property=e,this.value=new Tl(e,void 0)}transitioned(e,t){return new Sl(this.property,this.value,t,N({},e.transition,this.transition),e.now)}untransitioned(){return new Sl(this.property,this.value,null,{},0)}}class Rl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return z(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new bl(this._values[e].property)),this._values[e].value=new Tl(this._values[e].property,null===t?void 0:z(t))}getTransition(e){return z(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new bl(this._values[e].property)),this._values[e].transition=z(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const s=this.getTransition(t);void 0!==s&&(e["".concat(t,"-transition")]=s)}return e}transitioned(e,t){const n=new Dl(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,t._values[s]);return n}untransitioned(){const e=new Dl(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Sl{constructor(e,t,n,s,i){const l=s.delay||0,a=s.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+l,this.end=this.begin+a,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const s=e.now||0,i=this.value.possiblyEvaluate(e,t,n),l=this.prior;if(l){if(s>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(sthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Hl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=0,s=0;return{members:e.map((e=>{const i=Ml[e.type].BYTES_PER_ELEMENT,l=n=Ul(n,Math.max(t,i)),a=e.components||1;return s=Math.max(s,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:l}})),size:Ul(n,Math.max(s,t)),alignment:t}}function Ul(e,t){return Math.ceil(e/t)*t}class Gl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.int16[s+0]=t,this.int16[s+1]=n,e}}Gl.prototype.bytesPerElement=4,Zi(Gl,"StructArrayLayout2i4");class kl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=s,e}}kl.prototype.bytesPerElement=6,Zi(kl,"StructArrayLayout3i6");class zl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,s)}emplace(e,t,n,s,i){const l=4*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=s,this.int16[l+3]=i,e}}zl.prototype.bytesPerElement=8,Zi(zl,"StructArrayLayout4i8");class Vl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n,s,i,l,a)}emplace(e,t,n,s,i,l,a,r){const o=6*e,u=12*e,c=3*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.uint8[u+4]=s,this.uint8[u+5]=i,this.uint8[u+6]=l,this.uint8[u+7]=a,this.float32[c+2]=r,e}}Vl.prototype.bytesPerElement=12,Zi(Vl,"StructArrayLayout2i4ub1f12");class jl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,s)}emplace(e,t,n,s,i){const l=4*e;return this.float32[l+0]=t,this.float32[l+1]=n,this.float32[l+2]=s,this.float32[l+3]=i,e}}jl.prototype.bytesPerElement=16,Zi(jl,"StructArrayLayout4f16");class Wl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s,i)}emplace(e,t,n,s,i,l){const a=6*e,r=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=n,this.uint16[a+2]=s,this.uint16[a+3]=i,this.float32[r+2]=l,e}}Wl.prototype.bytesPerElement=12,Zi(Wl,"StructArrayLayout4ui1f12");class Yl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,s)}emplace(e,t,n,s,i){const l=4*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=s,this.uint16[l+3]=i,e}}Yl.prototype.bytesPerElement=8,Zi(Yl,"StructArrayLayout4ui8");class ql extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,s,i,l)}emplace(e,t,n,s,i,l,a){const r=6*e;return this.int16[r+0]=t,this.int16[r+1]=n,this.int16[r+2]=s,this.int16[r+3]=i,this.int16[r+4]=l,this.int16[r+5]=a,e}}ql.prototype.bytesPerElement=12,Zi(ql,"StructArrayLayout6i12");class Xl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a,r,o,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,s,i,l,a,r,o,u,c,h)}emplace(e,t,n,s,i,l,a,r,o,u,c,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=n,this.int16[d+2]=s,this.int16[d+3]=i,this.uint16[d+4]=l,this.uint16[d+5]=a,this.uint16[d+6]=r,this.uint16[d+7]=o,this.int16[d+8]=u,this.int16[d+9]=c,this.int16[d+10]=h,this.int16[d+11]=p,e}}Xl.prototype.bytesPerElement=24,Zi(Xl,"StructArrayLayout4i4ui4i24");class Zl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,s,i,l)}emplace(e,t,n,s,i,l,a){const r=10*e,o=5*e;return this.int16[r+0]=t,this.int16[r+1]=n,this.int16[r+2]=s,this.float32[o+2]=i,this.float32[o+3]=l,this.float32[o+4]=a,e}}Zl.prototype.bytesPerElement=20,Zi(Zl,"StructArrayLayout3i3f20");class Kl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Kl.prototype.bytesPerElement=4,Zi(Kl,"StructArrayLayout1ul4");class Ql extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a,r,o,u,c,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,s,i,l,a,r,o,u,c,h,p)}emplace(e,t,n,s,i,l,a,r,o,u,c,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=s,this.int16[f+3]=i,this.int16[f+4]=l,this.float32[m+3]=a,this.float32[m+4]=r,this.float32[m+5]=o,this.float32[m+6]=u,this.int16[f+14]=c,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}Ql.prototype.bytesPerElement=40,Zi(Ql,"StructArrayLayout5i4f1i1ul2ui40");class Jl extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n,s,i,l,a)}emplace(e,t,n,s,i,l,a,r){const o=8*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=s,this.int16[o+4]=i,this.int16[o+5]=l,this.int16[o+6]=a,this.int16[o+7]=r,e}}Jl.prototype.bytesPerElement=16,Zi(Jl,"StructArrayLayout3i2i2i16");class $l extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s,i)}emplace(e,t,n,s,i,l){const a=4*e,r=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=s,this.int16[r+6]=i,this.int16[r+7]=l,e}}$l.prototype.bytesPerElement=16,Zi($l,"StructArrayLayout2f1f2i16");class ea extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,s)}emplace(e,t,n,s,i){const l=12*e,a=3*e;return this.uint8[l+0]=t,this.uint8[l+1]=n,this.float32[a+1]=s,this.float32[a+2]=i,e}}ea.prototype.bytesPerElement=12,Zi(ea,"StructArrayLayout2ub2f12");class ta extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=s,e}}ta.prototype.bytesPerElement=12,Zi(ta,"StructArrayLayout3f12");class na extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=s,e}}na.prototype.bytesPerElement=6,Zi(na,"StructArrayLayout3ui6");class sa extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w)}emplace(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w,g){const T=30*e,b=15*e,R=60*e;return this.int16[T+0]=t,this.int16[T+1]=n,this.int16[T+2]=s,this.float32[b+2]=i,this.float32[b+3]=l,this.uint16[T+8]=a,this.uint16[T+9]=r,this.uint32[b+5]=o,this.uint32[b+6]=u,this.uint32[b+7]=c,this.uint16[T+16]=h,this.uint16[T+17]=p,this.uint16[T+18]=d,this.float32[b+10]=f,this.float32[b+11]=m,this.uint8[R+48]=I,this.uint8[R+49]=y,this.uint8[R+50]=v,this.uint32[b+13]=E,this.int16[T+28]=w,this.uint8[R+58]=g,e}}sa.prototype.bytesPerElement=60,Zi(sa,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class ia extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w,g,T,b,R,S,D,A,C,x){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w,g,T,b,R,S,D,A,C,x)}emplace(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w,g,T,b,R,S,D,A,C,x,_){const O=38*e,N=19*e;return this.int16[O+0]=t,this.int16[O+1]=n,this.int16[O+2]=s,this.float32[N+2]=i,this.float32[N+3]=l,this.int16[O+8]=a,this.int16[O+9]=r,this.int16[O+10]=o,this.int16[O+11]=u,this.int16[O+12]=c,this.int16[O+13]=h,this.uint16[O+14]=p,this.uint16[O+15]=d,this.uint16[O+16]=f,this.uint16[O+17]=m,this.uint16[O+18]=I,this.uint16[O+19]=y,this.uint16[O+20]=v,this.uint16[O+21]=E,this.uint16[O+22]=w,this.uint16[O+23]=g,this.uint16[O+24]=T,this.uint16[O+25]=b,this.uint16[O+26]=R,this.uint16[O+27]=S,this.uint16[O+28]=D,this.uint32[N+15]=A,this.float32[N+16]=C,this.float32[N+17]=x,this.float32[N+18]=_,e}}ia.prototype.bytesPerElement=76,Zi(ia,"StructArrayLayout3i2f6i15ui1ul3f76");class la extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}la.prototype.bytesPerElement=4,Zi(la,"StructArrayLayout1f4");class aa extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,i){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s,i)}emplace(e,t,n,s,i,l){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=s,this.float32[a+3]=i,this.float32[a+4]=l,e}}aa.prototype.bytesPerElement=20,Zi(aa,"StructArrayLayout5f20");class ra extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,s)}emplace(e,t,n,s,i){const l=6*e;return this.uint32[3*e+0]=t,this.uint16[l+2]=n,this.uint16[l+3]=s,this.uint16[l+4]=i,e}}ra.prototype.bytesPerElement=12,Zi(ra,"StructArrayLayout1ul3ui12");class oa extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.uint16[s+0]=t,this.uint16[s+1]=n,e}}oa.prototype.bytesPerElement=4,Zi(oa,"StructArrayLayout2ui4");class ua extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}ua.prototype.bytesPerElement=2,Zi(ua,"StructArrayLayout1ui2");class ca extends Bl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.float32[s+0]=t,this.float32[s+1]=n,e}}ca.prototype.bytesPerElement=8,Zi(ca,"StructArrayLayout2f8");class ha extends Fl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}ha.prototype.size=40;class pa extends Ql{get(e){return new ha(this,e)}}Zi(pa,"CollisionBoxArray");class da extends Fl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}da.prototype.size=60;class fa extends sa{get(e){return new da(this,e)}}Zi(fa,"PlacedSymbolArray");class ma extends Fl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}ma.prototype.size=76;class Ia extends ia{get(e){return new ma(this,e)}}Zi(Ia,"SymbolInstanceArray");class ya extends la{getoffsetX(e){return this.float32[1*e+0]}}Zi(ya,"GlyphOffsetArray");class va extends Gl{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Zi(va,"SymbolLineVertexArray");class Ea extends Fl{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Ea.prototype.size=12;class wa extends ra{get(e){return new Ea(this,e)}}Zi(wa,"FeatureIndexArray");class ga extends oa{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Zi(ga,"FillExtrusionCentroidArray");const Ta=Hl([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ba=Hl([{name:"a_dash",components:4,type:"Uint16"}]);var Ra={exports:{}},Sa={exports:{}};Sa.exports=function(e,t){var n,s,i,l,a,r,o,u;for(s=e.length-(n=3&e.length),i=t,a=3432918353,r=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|o>>>17))*r+(((o>>>16)*r&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(l>>>16)&65535)<<16);switch(o=0,n){case 3:o^=(255&e.charCodeAt(u+2))<<16;case 2:o^=(255&e.charCodeAt(u+1))<<8;case 1:i^=o=(65535&(o=(o=(65535&(o^=255&e.charCodeAt(u)))*a+(((o>>>16)*a&65535)<<16)&4294967295)<<15|o>>>17))*r+(((o>>>16)*r&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Da=Sa.exports,Aa={exports:{}};Aa.exports=function(e,t){for(var n,s=e.length,i=t^s,l=0;s>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),s-=4,++l;switch(s){case 3:i^=(255&e.charCodeAt(l+2))<<16;case 2:i^=(255&e.charCodeAt(l+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(l)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Ca=Da,xa=Aa.exports;Ra.exports=Ca,Ra.exports.murmur3=Ca,Ra.exports.murmur2=xa;var _a=p(Ra.exports);class Oa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,s){this.ids.push(Na(e)),this.positions.push(t,n,s)}getPositions(e){const t=Na(e);let n=0,s=this.ids.length-1;for(;n>1;this.ids[e]>=t?s=e:n=e+1}const i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){const n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return La(n,s,0,n.length-1),t&&t.push(n.buffer,s.buffer),{ids:n,positions:s}}static deserialize(e){const t=new Oa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Na(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:_a(String(e))}function La(e,t,n,s){for(;n>1];let l=n-1,a=s+1;for(;;){do{l++}while(e[l]i);if(l>=a)break;Pa(e,l,a),Pa(t,3*l,3*a),Pa(t,3*l+1,3*a+1),Pa(t,3*l+2,3*a+2)}a-n"u_".concat(e))),this.type=n}setUniform(e,t,n,s,i){t.set(e,i,s.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new Ha(e):new Fa(e)}}class ja{constructor(e,t){this.uniformNames=t.map((e=>"u_".concat(e))),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,n,s,i){const l="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;l&&t.set(e,i,l)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new Ba(e):new Fa(e)}}class Wa{constructor(e,t,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:"a_".concat(e),type:"Float32",components:"color"===n?2:1,offset:0}))),this.paintVertexArray=new s}populatePaintArray(e,t,n,s,i,l){const a=this.paintVertexArray.length,r=this.expression.evaluate(new gl(0),t,{},i,s,l);this.paintVertexArray.resize(e),this._setPaintValue(a,e,r)}updatePaintArray(e,t,n,s,i){const l=this.expression.evaluate({zoom:0},n,s,void 0,i);this._setPaintValue(e,t,l)}_setPaintValue(e,t,n){if("color"===this.type){const s=za(n);for(let n=e;n"u_".concat(e,"_t"))),this.type=n,this.useIntegerZoom=s,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:"a_".concat(e),type:"Float32",components:"color"===n?4:2,offset:0}))),this.paintVertexArray=new l}populatePaintArray(e,t,n,s,i,l){const a=this.expression.evaluate(new gl(this.zoom),t,{},i,s,l),r=this.expression.evaluate(new gl(this.zoom+1),t,{},i,s,l),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,a,r)}updatePaintArray(e,t,n,s,i){const l=this.expression.evaluate({zoom:this.zoom},n,s,void 0,i),a=this.expression.evaluate({zoom:this.zoom+1},n,s,void 0,i);this._setPaintValue(e,t,l,a)}_setPaintValue(e,t,n,s){if("color"===this.type){const i=za(n),l=za(s);for(let n=e;n2&&void 0!==arguments[2]?arguments[2]:()=>!0;this.binders={},this._buffers=[];const s=[];for(const i in e.paint._values){if(!n(i))continue;const l=e.paint.get(i);if(!(l instanceof Cl&&Fs(l.property.specification)))continue;const a=Qa(i,e.type),r=l.value,o=l.property.specification.type,u=!!l.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==r.kind||h)if("source"===r.kind||h||c){const t=er(i,o,"source");this.binders[i]=c?new qa(r,a,o,t,e.id):new Wa(r,a,o,t),s.push("/a_".concat(i))}else{const e=er(i,o,"composite");this.binders[i]=new Ya(r,a,o,u,t,e),s.push("/z_".concat(i))}else this.binders[i]=c?new ja(r.value,a):new Va(r.value,a,o),s.push("/u_".concat(i))}this.cacheKey=s.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Wa||t instanceof Ya?t.maxValue:0}populatePaintArrays(e,t,n,s,i,l){for(const a in this.binders){const r=this.binders[a];(r instanceof Wa||r instanceof Ya||r instanceof qa)&&r.populatePaintArray(e,t,n,s,i,l)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof ja&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,s,i,l){let a=!1;for(const r in e){const o=t.getPositions(r);for(const t of o){const o=n.feature(t.index);for(const n in this.binders){const u=this.binders[n];if((u instanceof Wa||u instanceof Ya||u instanceof qa)&&!0===u.expression.isStateDependent){const c=s.paint.get(n);u.expression=c.value,u.updatePaintArray(t.start,t.end,o,e[r],i,l),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Va||n instanceof ja)&&e.push(...n.uniformNames.map((e=>"#define HAS_UNIFORM_".concat(e))))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof Wa||n instanceof Ya||n instanceof qa)for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:()=>!0;this.programConfigurations={};for(const s of e)this.programConfigurations[s.id]=new Xa(s,t,n);this.needsUpload=!1,this._featureMap=new Oa,this._bufferOffset=0}populatePaintArrays(e,t,n,s,i,l,a){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,s,i,l,a);void 0!==t.id&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,s,i){for(const l of n)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,t,l,s,i)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Ka={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Qa(e,t){return Ka[e]||[e.replace("".concat(t,"-"),"").replace(/-/g,"_")]}const Ja={"line-pattern":{source:Wl,composite:Wl},"fill-pattern":{source:Wl,composite:Wl},"fill-extrusion-pattern":{source:Wl,composite:Wl},"line-dasharray":{source:Yl,composite:Yl}},$a={color:{source:ca,composite:jl},number:{source:la,composite:ca}};function er(e,t,n){const s=Ja[e];return s&&s[n]||$a[t][n]}Zi(Va,"ConstantBinder"),Zi(ja,"PatternConstantBinder"),Zi(Wa,"SourceExpressionBinder"),Zi(qa,"PatternCompositeBinder"),Zi(Ya,"CompositeExpressionBinder"),Zi(Xa,"ProgramConfiguration",{omit:["_buffers"]}),Zi(Za,"ProgramConfigurationSet");const tr="-transition";class nr extends $e{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Al(t.layout)),t.paint)){this._transitionablePaint=new Rl(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new xl(t.paint)}}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};null!=t&&this._validate(ki,"layers.".concat(this.id,".layout.").concat(e),e,t,n)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return U(e,tr)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null!=t&&this._validate(Gi,"layers.".concat(this.id,".paint.").concat(e),e,t,n))return!1;if(U(e,tr))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const n=this._transitionablePaint._values[e],s=n.value.isDataDriven(),i=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const l=this._transitionablePaint._values[e].value,a=l.isDataDriven(),r=U(e,"pattern")||"line-dasharray"===e;return a||s||r||this._handleOverridablePaintPropertyUpdate(e,i,l)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),k(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,n,s){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return(!i||!1!==i.validate)&&Vi(this,e.call(Ui,{key:t,layerType:this.type,objectKey:n,value:s,styleSpec:et,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Cl&&Fs(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=hi(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const sr=Hl([{name:"a_pos",components:2,type:"Int16"}],4),ir=Hl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class lr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.segments=e}prepareSegment(e,t,n,s){let i=this.segments[this.segments.length-1];return e>lr.MAX_VERTEX_ARRAY_LENGTH&&j("Max vertices per segment is ".concat(lr.MAX_VERTEX_ARRAY_LENGTH,": bucket requested ").concat(e)),(!i||i.vertexLength+e>lr.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==s)&&(i={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==s&&(i.sortKey=s),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,s){return new lr([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}lr.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Zi(lr,"SegmentVector");var ar=8192;class rr{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof zo?new zo(e.lng,e.lat):zo.convert(e),this}setSouthWest(e){return this._sw=e instanceof zo?new zo(e.lng,e.lat):zo.convert(e),this}extend(e){const t=this._sw,n=this._ne;let s,i;if(e instanceof zo)s=e,i=e;else{if(!(e instanceof rr))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(rr.convert(e)):this.extend(zo.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(zo.convert(e)):this;if(s=e._sw,i=e._ne,!s||!i)return this}return t||n?(t.lng=Math.min(s.lng,t.lng),t.lat=Math.min(s.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new zo(s.lng,s.lat),this._ne=new zo(i.lng,i.lat)),this}getCenter(){return new zo((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 zo(this.getWest(),this.getNorth())}getSouthEast(){return new zo(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(".concat(this._sw.toString(),", ").concat(this._ne.toString(),")")}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:n}=zo.convert(e);let s=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}static convert(e){return!e||e instanceof rr?e:new rr(e)}}var or=1e-6,ur="undefined"!=typeof Float32Array?Float32Array:Array;function cr(){var e=new ur(9);return ur!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function hr(e,t,n){var s=t[0],i=t[1],l=t[2],a=t[3],r=t[4],o=t[5],u=t[6],c=t[7],h=t[8],p=n[0],d=n[1],f=n[2],m=n[3],I=n[4],y=n[5],v=n[6],E=n[7],w=n[8];return e[0]=p*s+d*a+f*u,e[1]=p*i+d*r+f*c,e[2]=p*l+d*o+f*h,e[3]=m*s+I*a+y*u,e[4]=m*i+I*r+y*c,e[5]=m*l+I*o+y*h,e[6]=v*s+E*a+w*u,e[7]=v*i+E*r+w*c,e[8]=v*l+E*o+w*h,e}function pr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function dr(e,t){var n=t[0],s=t[1],i=t[2],l=t[3],a=t[4],r=t[5],o=t[6],u=t[7],c=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],I=t[14],y=t[15],v=n*r-s*a,E=n*o-i*a,w=n*u-l*a,g=s*o-i*r,T=s*u-l*r,b=i*u-l*o,R=c*m-h*f,S=c*I-p*f,D=c*y-d*f,A=h*I-p*m,C=h*y-d*m,x=p*y-d*I,_=v*x-E*C+w*A+g*D-T*S+b*R;return _?(e[0]=(r*x-o*C+u*A)*(_=1/_),e[1]=(i*C-s*x-l*A)*_,e[2]=(m*b-I*T+y*g)*_,e[3]=(p*T-h*b-d*g)*_,e[4]=(o*D-a*x-u*S)*_,e[5]=(n*x-i*D+l*S)*_,e[6]=(I*w-f*b-y*E)*_,e[7]=(c*b-p*w+d*E)*_,e[8]=(a*C-r*D+u*R)*_,e[9]=(s*D-n*C-l*R)*_,e[10]=(f*T-m*w+y*v)*_,e[11]=(h*w-c*T-d*v)*_,e[12]=(r*S-a*A-o*R)*_,e[13]=(n*A-s*S+i*R)*_,e[14]=(m*E-f*g-I*v)*_,e[15]=(c*g-h*E+p*v)*_,e):null}function fr(e,t,n){var s=t[0],i=t[1],l=t[2],a=t[3],r=t[4],o=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],I=t[13],y=t[14],v=t[15],E=n[0],w=n[1],g=n[2],T=n[3];return e[0]=E*s+w*r+g*h+T*m,e[1]=E*i+w*o+g*p+T*I,e[2]=E*l+w*u+g*d+T*y,e[3]=E*a+w*c+g*f+T*v,e[4]=(E=n[4])*s+(w=n[5])*r+(g=n[6])*h+(T=n[7])*m,e[5]=E*i+w*o+g*p+T*I,e[6]=E*l+w*u+g*d+T*y,e[7]=E*a+w*c+g*f+T*v,e[8]=(E=n[8])*s+(w=n[9])*r+(g=n[10])*h+(T=n[11])*m,e[9]=E*i+w*o+g*p+T*I,e[10]=E*l+w*u+g*d+T*y,e[11]=E*a+w*c+g*f+T*v,e[12]=(E=n[12])*s+(w=n[13])*r+(g=n[14])*h+(T=n[15])*m,e[13]=E*i+w*o+g*p+T*I,e[14]=E*l+w*u+g*d+T*y,e[15]=E*a+w*c+g*f+T*v,e}function mr(e,t,n){var s,i,l,a,r,o,u,c,h,p,d,f,m=n[0],I=n[1],y=n[2];return t===e?(e[12]=t[0]*m+t[4]*I+t[8]*y+t[12],e[13]=t[1]*m+t[5]*I+t[9]*y+t[13],e[14]=t[2]*m+t[6]*I+t[10]*y+t[14],e[15]=t[3]*m+t[7]*I+t[11]*y+t[15]):(i=t[1],l=t[2],a=t[3],r=t[4],o=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=s=t[0],e[1]=i,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=c,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=s*m+r*I+h*y+t[12],e[13]=i*m+o*I+p*y+t[13],e[14]=l*m+u*I+d*y+t[14],e[15]=a*m+c*I+f*y+t[15]),e}function Ir(e,t,n){var s=n[0],i=n[1],l=n[2];return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*l,e[9]=t[9]*l,e[10]=t[10]*l,e[11]=t[11]*l,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function yr(e,t,n){var s=Math.sin(n),i=Math.cos(n),l=t[4],a=t[5],r=t[6],o=t[7],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=l*i+u*s,e[5]=a*i+c*s,e[6]=r*i+h*s,e[7]=o*i+p*s,e[8]=u*i-l*s,e[9]=c*i-a*s,e[10]=h*i-r*s,e[11]=p*i-o*s,e}function vr(e,t,n){var s=Math.sin(n),i=Math.cos(n),l=t[0],a=t[1],r=t[2],o=t[3],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=l*i-u*s,e[1]=a*i-c*s,e[2]=r*i-h*s,e[3]=o*i-p*s,e[8]=l*s+u*i,e[9]=a*s+c*i,e[10]=r*s+h*i,e[11]=o*s+p*i,e}function Er(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function wr(e,t,n){var s,i,l,a=n[0],r=n[1],o=n[2],u=Math.hypot(a,r,o);return u0&&(l=1/Math.sqrt(l)),e[0]=t[0]*l,e[1]=t[1]*l,e[2]=t[2]*l,e}function Pr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Mr(e,t,n){var s=t[0],i=t[1],l=t[2],a=n[0],r=n[1],o=n[2];return e[0]=i*o-l*r,e[1]=l*a-s*o,e[2]=s*r-i*a,e}function Fr(e,t,n){var s=t[0],i=t[1],l=t[2],a=n[3]*s+n[7]*i+n[11]*l+n[15];return e[0]=(n[0]*s+n[4]*i+n[8]*l+n[12])/(a=a||1),e[1]=(n[1]*s+n[5]*i+n[9]*l+n[13])/a,e[2]=(n[2]*s+n[6]*i+n[10]*l+n[14])/a,e}function Br(e,t,n){var s=n[0],i=n[1],l=n[2],a=t[0],r=t[1],o=t[2],u=i*o-l*r,c=l*a-s*o,h=s*r-i*a,p=i*h-l*c,d=l*u-s*h,f=s*c-i*u,m=2*n[3];return c*=m,h*=m,d*=2,f*=2,e[0]=a+(u*=m)+(p*=2),e[1]=r+c+d,e[2]=o+h+f,e}var Hr,Ur=Ar,Gr=Cr,kr=Rr;function zr(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Vr(e,t){var n=t[0],s=t[1],i=t[2],l=t[3],a=n*n+s*s+i*i+l*l;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=s*a,e[2]=i*a,e[3]=l*a,e}function jr(e,t,n){var s=t[0],i=t[1],l=t[2],a=t[3];return e[0]=n[0]*s+n[4]*i+n[8]*l+n[12]*a,e[1]=n[1]*s+n[5]*i+n[9]*l+n[13]*a,e[2]=n[2]*s+n[6]*i+n[10]*l+n[14]*a,e[3]=n[3]*s+n[7]*i+n[11]*l+n[15]*a,e}function Wr(){var e=new ur(4);return ur!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Yr(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function qr(e,t,n){n*=.5;var s=t[0],i=t[1],l=t[2],a=t[3],r=Math.sin(n),o=Math.cos(n);return e[0]=s*o+a*r,e[1]=i*o+l*r,e[2]=l*o-i*r,e[3]=a*o-s*r,e}function Xr(e,t,n){n*=.5;var s=t[0],i=t[1],l=t[2],a=t[3],r=Math.sin(n),o=Math.cos(n);return e[0]=s*o-l*r,e[1]=i*o+a*r,e[2]=l*o+s*r,e[3]=a*o-i*r,e}Tr(),Hr=new ur(4),ur!=Float32Array&&(Hr[0]=0,Hr[1]=0,Hr[2]=0,Hr[3]=0);var Zr=Vr;Tr(),Sr(1,0,0),Sr(0,1,0),Wr(),Wr(),cr();const Kr=Hl([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Qr}=Kr,Jr=Hl([{name:"a_pos_3",components:3,type:"Int16"}]);var $r=Hl([{name:"a_pos",type:"Int16",components:2}]);class eo{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const s=Pr(t,this.dir);if(Math.abs(s)<1e-6)return!1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/s;return n[0]=this.pos[0]+this.dir[0]*i,n[1]=this.pos[1]+this.dir[1]*i,n[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],s=e[1],i=e[2],l=t[0],a=t[1],r=t[2];return Math.abs(n-l)<=or*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(s-a)<=or*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(i-r)<=or*Math.max(1,Math.abs(i),Math.abs(r))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[s,i,l]=this.dir,a=this.pos[0]-e[0],r=this.pos[1]-e[1],o=this.pos[2]-e[2],u=s*s+i*i+l*l,c=2*(a*s+r*i+o*l),h=c*c-4*u*(a*a+r*r+o*o-t*t);if(h<0){const e=Math.max(-c/2,0),u=a+s*e,h=r+i*e,p=o+l*e,d=Math.hypot(u,h,p);return n[0]=u*t/d,n[1]=h*t/d,n[2]=p*t/d,!1}{const e=(-c-Math.sqrt(h))/(2*u);if(e<0){const e=Math.hypot(a,r,o);return n[0]=a*t/e,n[1]=r*t/e,n[2]=o*t/e,!1}return n[0]=a+s*e,n[1]=r+i*e,n[2]=o+l*e,!0}}}class to{constructor(e,t,n,s,i){this.TL=e,this.TR=t,this.BR=n,this.BL=s,this.horizon=i}static fromInvProjectionMatrix(e,t,n){const s=[-1,1,1],i=[1,1,1],l=[1,-1,1],a=[-1,-1,1],r=Fr(s,s,e),o=Fr(i,i,e),u=Fr(l,l,e),c=Fr(a,a,e);return new to(r,o,u,c,t/n)}}class no{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,n,s){const i=Math.pow(2,n),l=[[-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((n=>{const l=jr([],n,e),a=1/l[3]/t*i;return function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}(l,l,[a,a,s?1/l[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Lr([],Mr([],Ur([],l[e[0]],l[e[1]]),Ur([],l[e[2]],l[e[1]]))),n=-Pr(t,l[e[1]]);return t.concat(n)}));return new no(l,a)}}class so{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const s of e)xr(t,t,s),_r(n,n,s);return new so(t,n)}static applyTransform(e,t){const n=e.getCorners();for(let s=0;s=0;if(0===l)return 0;l!==t.length&&(n=!1)}if(n)return 2;for(let s=0;s<3;s++){let t=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let i=0;ithis.max[s]-this.min[s])return 0}return 1}}const io=5,lo=6,ao=ar/Math.PI/2,ro=16383,oo=64,uo=[oo,32,16],co=-ao,ho=ao,po=[new so([co,co,co],[ho,ho,ho]),new so([co,co,co],[0,0,ho]),new so([0,co,co],[ho,0,ho]),new so([co,0,co],[0,ho,ho]),new so([0,0,co],[ho,ho,ho])];function fo(e){return e*ao/Uo}function mo(e,t,n){let s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const i=Or([],e._camera.position,e.worldSize),l=[t,n,1,1];jr(l,l,e.pixelMatrixInverse),zr(l,l,1/l[3]);const a=Lr([],Ur([],l,i)),r=e.globeMatrix,o=[r[12],r[13],r[14]],u=Ur([],o,i),c=Rr(u),h=Lr([],u),p=e.worldSize/(2*Math.PI),d=Pr(h,a),f=Math.asin(p/c);if(f1?null:function(e,t,n,s){const i=Math.sin(n);return e*(Math.sin((1-s)*n)/i)+t*(Math.sin(s*n)/i)}(e.a[t],e.b[t],e.angle,A(n,0,1))+e.center[t]}function vo(e){if(e.z<=1)return po[e.z+2*e.y+e.x];const t=Ro(bo(e));return so.fromPoints(t)}function Eo(e,t,n){return Or(e,e,1-n),Nr(e,e,t,n)}function wo(e,t){const n=Lo(t.zoom);if(0===n)return vo(e);const s=bo(e),i=Ro(s),l=jo(s.getWest())*t.worldSize,a=jo(s.getEast())*t.worldSize,r=Wo(s.getNorth())*t.worldSize,o=Wo(s.getSouth())*t.worldSize,u=[l,r,0],c=[a,r,0],h=[l,o,0],p=[a,o,0],d=dr([],t.globeMatrix);return Fr(u,u,d),Fr(c,c,d),Fr(h,h,d),Fr(p,p,d),i[0]=Eo(i[0],h,n),i[1]=Eo(i[1],p,n),i[2]=Eo(i[2],c,n),i[3]=Eo(i[3],u,n),so.fromPoints(i)}function go(e,t,n){for(const s of e)Fr(s,s,t),Or(s,s,n)}function To(e,t,n){const s=t/e.worldSize,i=e.globeMatrix;if(n.z<=1){const e=vo(n).getCorners();return go(e,i,s),so.fromPoints(e)}const l=bo(n),a=Ro(l);go(a,i,s);const r=Number.MAX_VALUE,o=[-r,-r,-r],u=[r,r,r];if(l.contains(e.center)){for(const e of a)xr(u,u,e),_r(o,o,e);o[2]=0;const t=e.point,n=[t.x*s,t.y*s,0];return xr(u,u,n),_r(o,o,n),new so(u,o)}const c=[i[12]*s,i[13]*s,i[14]*s],h=l.getCenter(),p=A(e.center.lat,-Ko,Ko),d=A(h.lat,-Ko,Ko),f=jo(e.center.lng),m=Wo(p);let I=f-jo(h.lng);const y=m-Wo(d);I>.5?I-=1:I<-.5&&(I+=1);let v=0;Math.abs(I)>Math.abs(y)?v=I>=0?1:3:(v=y>=0?0:2,Nr(c,c,[i[4]*s,i[5]*s,i[6]*s],-Math.sin(g(y>=0?l.getSouth():l.getNorth()))*ao));const E=a[v],w=a[(v+1)%4],T=new Io(E,w,c),b=[yo(T,0)||E[0],yo(T,1)||E[1],yo(T,2)||E[2]],R=Lo(e.zoom);if(R>0){const s=function(e,t,n,s,i){let{x:l,y:a,z:r}=e;const o=1/(1<.5?d=-1:f<-.5&&(d=1),u=((u+d)*t-(s*=t))*n+s,c=((c+d)*t-s)*n+s,h=(h*t-(i*=t))*n+i,p=(p*t-i)*n+i,[[u,p,0],[c,p,0],[c,h,0],[u,h,0]]}(n,t,e._pixelsPerMercatorPixel,f,m);for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:ao;return n=g(n),[e*Math.sin(n)*s,-t*s,e*Math.cos(n)*s]}function Do(e,t,n){return So(Math.cos(g(e)),Math.sin(g(e)),t,n)}function Ao(e,t,n,s){const i=1<Math.PI/2*1.01}const Fo=g(85),Bo=Math.cos(Fo),Ho=Math.sin(Fo),Uo=6371008.8,Go=2*Math.PI*Uo;class ko{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid LngLat object: (".concat(e,", ").concat(t,")"));if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ko(x(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return"LngLat(".concat(this.lng,", ").concat(this.lat,")")}distanceTo(e){const t=Math.PI/180,n=this.lat*t,s=e.lat*t,i=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*t);return Uo*Math.acos(Math.min(i,1))}toBounds(){const e=360*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)/40075017,t=e/Math.cos(Math.PI/180*this.lat);return new rr(new ko(this.lng-t,this.lat-e),new ko(this.lng+t,this.lat+e))}toEcef(e){const t=fo(e);return Do(this.lat,this.lng,ao+t)}static convert(e){if(e instanceof ko)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ko(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ko(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var zo=ko;function Vo(e){return Go*Math.cos(e*Math.PI/180)}function jo(e){return(180+e)/360}function Wo(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Yo(e,t){return e/Vo(t)}function qo(e){return 360*e-180}function Xo(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Zo(e,t){return e*Vo(Xo(t))}const Ko=85.051129;function Qo(e){return 1/Math.cos(e*Math.PI/180)}class Jo{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=zo.convert(e);return new Jo(jo(n.lng),Wo(n.lat),Yo(t,n.lat))}toLngLat(){return new zo(qo(this.x),Xo(this.y))}toAltitude(){return Zo(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Go*Qo(Xo(this.y))}}function $o(e,t,n,s,i,l,a,r,o){const u=(t+s)/2,c=(n+i)/2,h=new v(u,c);r(h),function(e,t,n,s,i,l){const a=n-i,r=s-l;return Math.abs((s-t)*a-(n-e)*r)/Math.hypot(a,r)}(h.x,h.y,l.x,l.y,a.x,a.y)>=o?($o(e,t,n,u,c,l,h,r,o),$o(e,u,c,s,i,h,a,r,o)):e.push(a)}function eu(e,t,n){let s=e[0],i=s.x,l=s.y;t(s);const a=[s];for(let r=1;re.x+1||se.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function au(e,t,n){const s=e.loadGeometry(),i=e.extent,l=ar/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=qo((t.x+e.x/i)/l),s=Xo((t.y+e.y/i)/l),c=u.project(n,s);e.x=(c.x*a-r)*i,e.y=(c.y*a-o)*i};for(let t=0;t=i||n.y<0||n.y>=i||(c(n),e.push(n));s[t]=e}}for(const a of s)for(const e of a)lu(e,l);return s}function ru(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?au(e):[]}}function ou(e,t,n,s,i){e.emplaceBack(2*t+(s+1)/2,2*n+(i+1)/2)}function uu(e,t,n){const s=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*s,n[1]*s,n[2]*s)}class cu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Gl,this.indexArray=new na,this.segments=new lr,this.programConfigurations=new Za(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n,s){const i=this.layers[0],l=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:o,id:u,index:c,sourceLayerIndex:h}of e){const e=this.layers[0]._featureFilter.needGeometry,t=ru(o,e);if(!this.layers[0]._featureFilter.filter(new gl(this.zoom),t,n))continue;const i=a?a.evaluate(t,{},n):void 0,r={id:u,properties:o.properties,type:o.type,sourceLayerIndex:h,index:c,geometry:e?t.geometry:au(o,n,s),patterns:{},sortKey:i};l.push(r)}a&&l.sort(((e,t)=>e.sortKey-t.sortKey));let r=null;"globe"===s.projection.name&&(this.globeExtVertexArray=new ql,r=s.projection);for(const o of l){const{geometry:s,index:i,sourceLayerIndex:l}=o,a=e[i].feature;this.addFeature(o,s,i,t.availableImages,n,r),t.featureIndex.insert(a,s,i,l,this.index)}}update(e,t,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,s)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,sr.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ir.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,n,s,i,l){for(const a of t)for(const t of a){const n=t.x,s=t.y;if(n<0||n>=ar||s<0||s>=ar)continue;if(l){const e=l.projectTilePoint(n,s,i),t=l.upVector(i,n,s),a=this.globeExtVertexArray;uu(a,e,t),uu(a,e,t),uu(a,e,t),uu(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),r=a.vertexLength;ou(this.layoutVertexArray,n,s,-1,-1),ou(this.layoutVertexArray,n,s,1,-1),ou(this.layoutVertexArray,n,s,1,1),ou(this.layoutVertexArray,n,s,-1,1),this.indexArray.emplaceBack(r,r+1,r+2),this.indexArray.emplaceBack(r,r+2,r+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,i)}}function hu(e,t){for(let n=0;n1){if(mu(e,t))return!0;for(let s=0;s1?n:n.sub(t)._mult(i)._add(t))}function Eu(e,t){let n,s,i,l=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(l=!l)}return l}function wu(e,t){let n=!1;for(let s=0,i=e.length-1;st.y!=a.y>t.y&&t.x<(a.x-l.x)*(t.y-l.y)/(a.y-l.y)+l.x&&(n=!n)}return n}function gu(e,t,n,s,i){for(const a of e)if(t<=a.x&&n<=a.y&&s>=a.x&&i>=a.y)return!0;const l=[new v(t,n),new v(t,i),new v(s,i),new v(s,n)];if(e.length>2)for(const a of l)if(wu(e,a))return!0;for(let a=0;ai.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const l=W(e,t,n[0]);return l!==W(e,t,n[1])||l!==W(e,t,n[2])||l!==W(e,t,n[3])}function bu(e,t,n){const s=t.paint.get(e).value;return"constant"===s.kind?s.value:n.programConfigurations.get(t.id).getMaxValue(e)}function Ru(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Su(e,t,n,s,i){if(!t[0]&&!t[1])return e;const l=v.convert(t)._mult(i);"viewport"===n&&l._rotate(-s);const a=[];for(let r=0;r0){const e=n.projection.upVector(u,h.x,h.y);d.x+=e[0]*c*p,d.y+=e[1]*c*p,d.z+=e[2]*c*p}const f=l?h:_u(d.x,d.y,d.z,s),m=l?e.tilespaceRays.map((e=>Lu(e,p))):e.queryGeometry.screenGeometry,I=jr([],[d.x,d.y,d.z,1],s);if(!a&&l?o*=I[3]/n.cameraToCenterDistance:a&&!l&&(o*=n.cameraToCenterDistance/I[3]),l){const e=Xo((t.y/ar+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||s.x>t.width-i.width||s.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,r=t.data;for(let o=0;o{t[e.evaluationKey]=l;const a=e.expression.evaluate(t);i.data[n+s+0]=Math.floor(255*a.r/a.a),i.data[n+s+1]=Math.floor(255*a.g/a.a),i.data[n+s+2]=Math.floor(255*a.b/a.a),i.data[n+s+3]=Math.floor(255*a.a)};if(e.clips)for(let a=0,r=0;a80*n){s=l=e[0],i=a=e[1];for(var f=n;fl&&(l=r),o>a&&(a=o);u=0!==(u=Math.max(l-s,a-i))?32767/u:0}return Zu(p,d,n,s,i,u,0),d}function qu(e,t,n,s,i){var l,a;if(i===yc(e,t,n,s)>0)for(l=t;l=t;l-=s)a=fc(l,e[l],e[l+1],a);return a&&oc(a,a.next)&&(mc(a),a=a.next),a}function Xu(e,t){if(!e)return e;t||(t=e);var n,s=e;do{if(n=!1,s.steiner||!oc(s,s.next)&&0!==rc(s.prev,s,s.next))s=s.next;else{if(mc(s),(s=t=s.prev)===s.next)break;n=!0}}while(n||s!==t);return t}function Zu(e,t,n,s,i,l,a){if(e){!a&&l&&function(e,t,n,s){var i=e;do{0===i.z&&(i.z=sc(i.x,i.y,t,n,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,s,i,l,a,r,o,u=1;do{for(n=e,e=null,l=null,a=0;n;){for(a++,s=n,r=0,t=0;t0||o>0&&s;)0!==r&&(0===o||!s||n.z<=s.z)?(i=n,n=n.nextZ,r--):(i=s,s=s.nextZ,o--),l?l.nextZ=i:e=i,i.prevZ=l,l=i;n=s}l.nextZ=null,u*=2}while(a>1)}(i)}(e,s,i,l);for(var r,o,u=e;e.prev!==e.next;)if(r=e.prev,o=e.next,l?Qu(e,s,i,l):Ku(e))t.push(r.i/n|0),t.push(e.i/n|0),t.push(o.i/n|0),mc(e),e=o.next,u=o.next;else if((e=o)===u){a?1===a?Zu(e=Ju(Xu(e),t,n),t,n,s,i,l,2):2===a&&$u(e,t,n,s,i,l):Zu(Xu(e),t,n,s,i,l,1);break}}}function Ku(e){var t=e.prev,n=e,s=e.next;if(rc(t,n,s)>=0)return!1;for(var i=t.x,l=n.x,a=s.x,r=t.y,o=n.y,u=s.y,c=il?i>a?i:a:l>a?l:a,d=r>o?r>u?r:u:o>u?o:u,f=s.next;f!==t;){if(f.x>=c&&f.x<=p&&f.y>=h&&f.y<=d&&lc(i,r,l,o,a,u,f.x,f.y)&&rc(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Qu(e,t,n,s){var i=e.prev,l=e,a=e.next;if(rc(i,l,a)>=0)return!1;for(var r=i.x,o=l.x,u=a.x,c=i.y,h=l.y,p=a.y,d=ro?r>u?r:u:o>u?o:u,I=c>h?c>p?c:p:h>p?h:p,y=sc(d,f,t,n,s),v=sc(m,I,t,n,s),E=e.prevZ,w=e.nextZ;E&&E.z>=y&&w&&w.z<=v;){if(E.x>=d&&E.x<=m&&E.y>=f&&E.y<=I&&E!==i&&E!==a&&lc(r,c,o,h,u,p,E.x,E.y)&&rc(E.prev,E,E.next)>=0)return!1;if(E=E.prevZ,w.x>=d&&w.x<=m&&w.y>=f&&w.y<=I&&w!==i&&w!==a&&lc(r,c,o,h,u,p,w.x,w.y)&&rc(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;E&&E.z>=y;){if(E.x>=d&&E.x<=m&&E.y>=f&&E.y<=I&&E!==i&&E!==a&&lc(r,c,o,h,u,p,E.x,E.y)&&rc(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;w&&w.z<=v;){if(w.x>=d&&w.x<=m&&w.y>=f&&w.y<=I&&w!==i&&w!==a&&lc(r,c,o,h,u,p,w.x,w.y)&&rc(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Ju(e,t,n){var s=e;do{var i=s.prev,l=s.next.next;!oc(i,l)&&uc(i,s,s.next,l)&&pc(i,l)&&pc(l,i)&&(t.push(i.i/n|0),t.push(s.i/n|0),t.push(l.i/n|0),mc(s),mc(s.next),s=e=l),s=s.next}while(s!==e);return Xu(s)}function $u(e,t,n,s,i,l){var a=e;do{for(var r=a.next.next;r!==a.prev;){if(a.i!==r.i&&ac(a,r)){var o=dc(a,r);return a=Xu(a,a.next),o=Xu(o,o.next),Zu(a,t,n,s,i,l,0),void Zu(o,t,n,s,i,l,0)}r=r.next}a=a.next}while(a!==e)}function ec(e,t){return e.x-t.x}function tc(e,t){var n=function(e,t){var n,s=t,i=e.x,l=e.y,a=-1/0;do{if(l<=s.y&&l>=s.next.y&&s.next.y!==s.y){var r=s.x+(l-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(r<=i&&r>a&&(a=r,n=s.x=s.x&&s.x>=c&&i!==s.x&&lc(ln.x||s.x===n.x&&nc(n,s)))&&(n=s,p=o)),s=s.next}while(s!==u);return n}(e,t);if(!n)return t;var s=dc(n,e);return Xu(s,s.next),Xu(n,n.next)}function nc(e,t){return rc(e.prev,e,t.prev)<0&&rc(t.next,e,e.next)<0}function sc(e,t,n,s,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ic(e){var t=e,n=e;do{(t.x=(e-a)*(l-r)&&(e-a)*(s-r)>=(n-a)*(t-r)&&(n-a)*(l-r)>=(i-a)*(s-r)}function ac(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&uc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(pc(e,t)&&pc(t,e)&&function(e,t){var n=e,s=!1,i=(e.x+t.x)/2,l=(e.y+t.y)/2;do{n.y>l!=n.next.y>l&&n.next.y!==n.y&&i<(n.next.x-n.x)*(l-n.y)/(n.next.y-n.y)+n.x&&(s=!s),n=n.next}while(n!==e);return s}(e,t)&&(rc(e.prev,e,t.prev)||rc(e,t.prev,t))||oc(e,t)&&rc(e.prev,e,e.next)>0&&rc(t.prev,t,t.next)>0)}function rc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function oc(e,t){return e.x===t.x&&e.y===t.y}function uc(e,t,n,s){var i=hc(rc(e,t,n)),l=hc(rc(e,t,s)),a=hc(rc(n,s,e)),r=hc(rc(n,s,t));return i!==l&&a!==r||!(0!==i||!cc(e,n,t))||!(0!==l||!cc(e,s,t))||!(0!==a||!cc(n,e,s))||!(0!==r||!cc(n,t,s))}function cc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function hc(e){return e>0?1:e<0?-1:0}function pc(e,t){return rc(e.prev,e,e.next)<0?rc(e,t,e.next)>=0&&rc(e,e.prev,t)>=0:rc(e,t,e.prev)<0||rc(e,e.next,t)<0}function dc(e,t){var n=new Ic(e.i,e.x,e.y),s=new Ic(t.i,t.x,t.y),i=e.next,l=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,s.next=n,n.prev=s,l.next=s,s.prev=l,s}function fc(e,t,n,s){var i=new Ic(e,t,n);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function mc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ic(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yc(e,t,n,s){for(var i=0,l=t,a=n-s;l0&&n.holes.push(s+=e[i-1].length)}return n};var vc=p(Wu.exports);function Ec(e,t,n,s,i){wc(e,t,n||0,s||e.length-1,i||Tc)}function wc(e,t,n,s,i){for(;s>n;){if(s-n>600){var l=s-n+1,a=t-n+1,r=Math.log(l),o=.5*Math.exp(2*r/3),u=.5*Math.sqrt(r*o*(l-o)/l)*(a-l/2<0?-1:1);wc(e,t,Math.max(n,Math.floor(t-a*o/l+u)),Math.min(s,Math.floor(t+(l-a)*o/l+u)),i)}var c=e[t],h=n,p=s;for(gc(e,n,t),i(e[s],c)>0&&gc(e,n,s);h0;)p--}0===i(e[n],c)?gc(e,n,p):gc(e,++p,s),p<=t&&(n=p+1),t<=p&&(s=p-1)}}function gc(e,t,n){var s=e[t];e[t]=e[n],e[n]=s}function Tc(e,t){return et?1:0}function bc(e,t){const n=e.length;if(n<=1)return[e];const s=[];let i,l;for(let a=0;a1)for(let a=0;ae.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Gl,this.indexArray=new na,this.indexArray2=new oa,this.programConfigurations=new Za(e.layers,e.zoom),this.segments=new lr,this.segments2=new lr,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,n,s){this.hasPattern=Sc("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),l=[];for(const{feature:a,id:r,index:o,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=ru(a,e);if(!this.layers[0]._featureFilter.filter(new gl(this.zoom),c,n))continue;const h=i?i.evaluate(c,{},n,t.availableImages):void 0,p={id:r,properties:a.properties,type:a.type,sourceLayerIndex:u,index:o,geometry:e?c.geometry:au(a,n,s),patterns:{},sortKey:h};l.push(p)}i&&l.sort(((e,t)=>e.sortKey-t.sortKey));for(const a of l){const{geometry:s,index:i,sourceLayerIndex:l}=a;if(this.hasPattern){const e=Dc("fill",this.layers,a,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(a,s,i,n,{},t.availableImages);t.featureIndex.insert(e[i].feature,s,i,l,this.index)}}update(e,t,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,s)}addFeatures(e,t,n,s,i){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,t,n,s)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ju),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,s,i){let l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[];for(const a of bc(t,500)){let e=0;for(const r of a)e+=r.length;const t=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=t.vertexLength,s=[],i=[];for(const r of a){if(0===r.length)continue;r!==a[0]&&i.push(s.length/2);const e=this.segments2.prepareSegment(r.length,this.layoutVertexArray,this.indexArray2),t=e.vertexLength;this.layoutVertexArray.emplaceBack(r[0].x,r[0].y),this.indexArray2.emplaceBack(t+r.length-1,t),s.push(r[0].x),s.push(r[0].y);for(let n=1;n>3}if(i--,1===s||2===s)l+=e.readSVarint(),a+=e.readSVarint(),1===s&&(t&&r.push(t),t=[]),t.push(new Mc(l,a));else{if(7!==s)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&r.push(t),r},Bc.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,s=0,i=0,l=0,a=1/0,r=-1/0,o=1/0,u=-1/0;e.pos>3}if(s--,1===n||2===n)(i+=e.readSVarint())r&&(r=i),(l+=e.readSVarint())u&&(u=l);else if(7!==n)throw new Error("unknown command "+n)}return[a,o,r,u]},Bc.prototype.toGeoJSON=function(e,t,n){var s,i,l=this.extent*Math.pow(2,n),a=this.extent*e,r=this.extent*t,o=this.loadGeometry(),u=Bc.types[this.type];function c(e){for(var t=0;t>3;t=1===s?e.readString():2===s?e.readFloat():3===s?e.readDouble():4===s?e.readVarint64():5===s?e.readVarint():6===s?e.readSVarint():7===s?e.readBoolean():null}return t}(n))}zc.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 t=this._pbf.readVarint()+this._pbf.pos;return new Gc(this._pbf,t,this.extent,this._keys,this._values)};var jc=kc;function Wc(e,t,n){if(3===e){var s=new jc(n,n.readVarint()+n.pos);s.length&&(t[s.name]=s)}}var Yc=Pc.VectorTile=function(e,t){this.layers=e.readFields(Wc,{},t)},qc=Pc.VectorTileFeature=Fc;function Xc(e,t,n,s){const i=[],l=0===s?(e,t,n,s,i,l)=>{e.push(new v(l,n+(l-t)/(s-t)*(i-n)))}:(e,t,n,s,i,l)=>{e.push(new v(t+(l-n)/(i-n)*(s-t),l))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&l(a,r,o,u,c,t):h>n?p=t&&l(a,r,o,u,c,t),p>n&&h<=n&&l(a,r,o,u,c,n)}let r=i[i.length-1];const o=0===s?r.x:r.y;o>=t&&o<=n&&a.push(r),a.length&&(r=a[a.length-1],a[0].x===r.x&&a[0].y===r.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}Pc.VectorTileLayer=kc;const Zc=qc.types,Kc=Math.pow(2,13);function Qc(e,t,n,s,i,l,a,r){e.emplaceBack((t<<1)+a,(n<<1)+l,(Math.floor(s*Kc)<<1)+i,Math.round(r))}function Jc(e,t,n){const s=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*s,n[1]*s,n[2]*s)}class $c{constructor(){this.acc=new v(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new v(e.x,e.y),this.max=new v(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,s=this.max;e.xs.x&&(s.x=e.x),e.ys.y&&(s.y=e.y),((0===e.x||e.x===ar)&&e.x===t.x)!=((0===e.y||e.y===ar)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,Nn(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ar!=e.x>ar&&this.addBorderIntersection(1,Nn(t.y,e.y,(ar-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Nn(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ar!=e.y>ar&&this.addBorderIntersection(3,Nn(t.x,e.x,(ar-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new v(0,0)}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0)}}class eh{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new zl,this.centroidVertexArray=new ga,this.indexArray=new na,this.programConfigurations=new Za(e.layers,e.zoom),this.segments=new lr,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,n,s){this.features=[],this.hasPattern=Sc("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;I--){const e=p[I];(0===e.length||(d=e[0]).every((e=>e.x<=0))||d.every((e=>e.x>=ar))||d.every((e=>e.y<=0))||d.every((e=>e.y>=ar)))&&p.splice(I,1)}var d;let f;if(u)f=oh(p,r,s);else{f=[];for(const e of p)f.push({polygon:e,bounds:r})}const m=h?this.edgeRadius:0;for(const{polygon:I,bounds:y}of f){let e=0,t=0;for(const s of I)h&&!s[0].equals(s[s.length-1])&&s.push(s[0]),t+=h?s.length-1:s.length;const n=this.segments.prepareSegment((h?5:4)*t,this.layoutVertexArray,this.indexArray);if(h){const t=[],i=[];e=n.vertexLength;for(const e of I){let l,a;e.length&&e!==I[0]&&i.push(t.length/2),l=e[1].sub(e[0])._perp()._unit();for(let i=1;i4&&lh(i[i.length-2],i[0],i[1]),p=m?nh(i[i.length-2],i[0],i[1],m):0;l=i[1].sub(i[0])._perp()._unit();let d=!0;for(let f=1,I=0;f0?1:0,R=v.dist(E);if(I+R>32768&&(I=0),m){a=w.sub(E)._perp()._unit();let e=sh(v,E,w,th(l,a),m);isNaN(e)&&(e=0);const t=E.sub(v)._unit();v=v.add(t.mult(p))._round(),E=E.add(t.mult(-e))._round(),p=e,l=a}const S=n.vertexLength,D=i.length>4&&lh(v,E,w);let A=ah(I,r,d);if(Qc(this.layoutVertexArray,v.x,v.y,T,b,0,0,A),Qc(this.layoutVertexArray,v.x,v.y,T,b,0,1,A),I+=R,A=ah(I,D,!d),r=D,Qc(this.layoutVertexArray,E.x,E.y,T,b,0,0,A),Qc(this.layoutVertexArray,E.x,E.y,T,b,0,1,A),n.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),n.primitiveLength+=2,m){const s=e+(1===f?i.length-2:f-2),l=1===f?e:s+1;if(this.indexArray.emplaceBack(S+1,s,S+3),this.indexArray.emplaceBack(s,l,S+3),n.primitiveLength+=2,void 0===t&&(t=S),!ih(w,i[f],y)){const e=f===i.length-1?t:n.vertexLength;this.indexArray.emplaceBack(S+2,S+3,e),this.indexArray.emplaceBack(S+3,e+1,e),this.indexArray.emplaceBack(S+3,l,e+1),n.primitiveLength+=3}d=!d}if(u){const e=this.layoutVertexExtArray,t=o.projectTilePoint(v.x,v.y,s),n=o.projectTilePoint(E.x,E.y,s),i=o.upVector(s,v.x,v.y),l=o.upVector(s,E.x,E.y);Jc(e,t,i),Jc(e,t,i),Jc(e,n,l),Jc(e,n,l)}}h&&(e+=i.length-1)}}if(c&&c.polyCount.length>0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const e=c.borders,t=this.featuresOnBorder.push(c)-1;for(let n=0;n<4;n++)e[n][0]!==Number.MAX_VALUE&&this.borders[n].push(t)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,l,s)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0]))}encodeCentroid(e,t){let n,s,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);n=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),s=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else n=Math.ceil(7*(e.x+450)),s=0;else n=0,s=+i;let l=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const a of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*a.edges+a.top);for(let e=0;en[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function lh(e,t,n){if(e.x<0||e.x>=ar||t.x<0||t.x>=ar||n.x<0||n.x>=ar)return!1;const s=n.sub(t),i=s.perp(),l=e.sub(t);return(s.x*l.x+s.y*l.y)/Math.sqrt((s.x*s.x+s.y*s.y)*(l.x*l.x+l.y*l.y))>-.866&&i.x*l.x+i.y*l.y<0}function ah(e,t,n){const s=t?2|e:-3&e;return n?1|s:-2&s}function rh(){const e=Math.PI/32,t=Math.tan(e),n=Uo;return n*Math.sqrt(1+2*t*t)-n}function oh(e,t,n){const s=1<4&&void 0!==arguments[4]?arguments[4]:0,l=arguments.length>5?arguments[5]:void 0;const a=[];if(!e.length||!n||!s)return a;const r=(e,t)=>{for(const n of e)a.push({polygon:n,bounds:t})},o=Math.ceil(Math.log2(n)),u=Math.ceil(Math.log2(s)),c=o-u,h=[];for(let f=0;f0?0:1);for(let f=0;ft+1?d.push({polygons:p,bounds:e,depth:t+1}):r(p,e)}if(f.length){const e=[new v(0===n?c:s.x,1===n?c:s.y),a];h.length>t+1?d.push({polygons:f,bounds:e,depth:t+1}):r(f,e)}}return a}(e,t,Math.ceil((l-i)/11.25),Math.ceil((a-r)/11.25),1,((e,t,i)=>{if(0===e)return.5*(t+i);{const e=Xo((n.y+t/ar)/s);return(Wo(.5*(Xo((n.y+i/ar)/s)+e))*s-n.y)*ar}}))}Zi(eh,"FillExtrusionBucket",{omit:["layers","features"]}),Zi($c,"PartMetadata");const uh=new Ll({"fill-extrusion-edge-radius":new _l(et["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var ch={paint:new Ll({"fill-extrusion-opacity":new _l(et["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ol(et["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _l(et["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _l(et["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ol(et["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ol(et["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ol(et["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _l(et["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new _l(et["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new _l(et["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new _l(et["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:uh};function hh(e,t,n){var s=2*Math.PI*6378137/256/Math.pow(2,n);return[e*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class ph{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=mh(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=function(e,t,n){var s=hh(256*e,256*(t=Math.pow(2,n)-t-1),n),i=hh(256*(e+1),256*(t+1),n);return s[0]+","+s[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),s=function(e,t,n){let s,i="";for(let l=e;l>0;l--)s=1<this.canonical.z?new fh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return mh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return mh(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new fh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new fh(t,this.wrap,t,n,s),new fh(t,this.wrap,t,n+1,s),new fh(t,this.wrap,t,n,s+1),new fh(t,this.wrap,t,n+1,s+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Vl,this.layoutVertexArray2=new jl,this.indexArray=new na,this.programConfigurations=new Za(e.layers,e.zoom),this.segments=new lr,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n,s){this.hasPattern=Sc("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),l=[];for(const{feature:u,id:c,index:h,sourceLayerIndex:p}of e){const e=this.layers[0]._featureFilter.needGeometry,t=ru(u,e);if(!this.layers[0]._featureFilter.filter(new gl(this.zoom),t,n))continue;const a=i?i.evaluate(t,{},n):void 0,r={id:c,properties:u.properties,type:u.type,sourceLayerIndex:p,index:h,geometry:e?t.geometry:au(u,n,s),patterns:{},sortKey:a};l.push(r)}i&&l.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:a,featureIndex:r}=t,o=this.addConstantDashes(a);for(const u of l){const{geometry:s,index:i,sourceLayerIndex:l}=u;if(o&&this.addFeatureDashes(u,a),this.hasPattern){const e=Dc("line",this.layers,u,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(u,s,i,n,a.positions,t.availableImages);r.insert(e[i].feature,s,i,l,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const s=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==s.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=s.value;if(!n)continue;e.addDash(n,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const s of this.layers){const i=s.paint.get("line-dasharray").value,l=s.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===l.kind)continue;let a,r;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:n},e);r="constant"===l.kind?l.value:l.evaluate({zoom:n},e),t.addDash(a,r),e.patterns[s.id]=t.getKey(a,r)}}update(e,t,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,s)}addFeatures(e,t,n,s,i){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,t,n,s)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,bh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gh),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,s,i,l){const a=this.layers[0].layout,r=a.get("line-join").evaluate(e,{}),o=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const h of t)this.addLine(h,e,r,o,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,l,s)}addLine(e,t,n,s,i,l){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[r-1].equals(e[r-2]);)r--;let o=0;for(;o0;if(g&&I>o){const e=h.dist(p);if(e>2*u){const t=h.sub(h.sub(p)._mult(u/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,c),p=t}}const b=p&&d;let R=b?n:a?"butt":s;if(b&&"round"===R&&(Ei&&(R="bevel"),"bevel"===R&&(E>2&&(R="flipbevel"),E100)t=m.mult(-1);else{const e=E*f.add(m).mag()/f.sub(m).mag();t._perp()._mult(e*(T?-1:1))}this.addCurrentVertex(h,t,0,0,c),this.addCurrentVertex(h,t.mult(-1),0,0,c)}else if("bevel"===R||"fakeround"===R){const e=-Math.sqrt(E*E-1),t=T?e:0,n=T?0:e;if(p&&this.addCurrentVertex(h,f,t,n,c),"fakeround"===R){const e=Math.round(180*w/Math.PI/20);for(let t=1;t2*u){const t=h.add(d.sub(h)._mult(u/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,c),h=t}}}}addCurrentVertex(e,t,n,s,i){let l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const a=t.y*s-t.x,r=-t.y-t.x*s;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,l,!1,n,i),this.addHalfVertex(e,a,r,l,!0,-s,i)}addHalfVertex(e,t,n,s,i,l,a){let{x:r,y:o}=e;this.layoutVertexArray.emplaceBack((r<<1)+(s?1:0),(o<<1)+(i?1:0),Math.round(63*t)+128,Math.round(63*n)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const u=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),a.primitiveLength++),i?this.e2=u:this.e1=u}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Zi(Dh,"LineBucket",{omit:["layers","patternFeatures"]});const Ah=new Ll({"line-cap":new Ol(et.layout_line["line-cap"]),"line-join":new Ol(et.layout_line["line-join"]),"line-miter-limit":new _l(et.layout_line["line-miter-limit"]),"line-round-limit":new _l(et.layout_line["line-round-limit"]),"line-sort-key":new Ol(et.layout_line["line-sort-key"])});var Ch={paint:new Ll({"line-opacity":new Ol(et.paint_line["line-opacity"]),"line-color":new Ol(et.paint_line["line-color"]),"line-translate":new _l(et.paint_line["line-translate"]),"line-translate-anchor":new _l(et.paint_line["line-translate-anchor"]),"line-width":new Ol(et.paint_line["line-width"]),"line-gap-width":new Ol(et.paint_line["line-gap-width"]),"line-offset":new Ol(et.paint_line["line-offset"]),"line-blur":new Ol(et.paint_line["line-blur"]),"line-dasharray":new Ol(et.paint_line["line-dasharray"]),"line-pattern":new Ol(et.paint_line["line-pattern"]),"line-gradient":new Nl(et.paint_line["line-gradient"]),"line-trim-offset":new _l(et.paint_line["line-trim-offset"])}),layout:Ah};const xh=new class extends Ol{possiblyEvaluate(e,t){return t=new gl(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,s){return t=N({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,s)}}(Ch.paint.properties["line-width"].specification);function _h(e,t){return t>0?t+2*e:e}xh.useIntegerZoom=!0;const Oh=Hl([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Nh=Hl([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Lh=Hl([{name:"a_projected_pos",components:4,type:"Float32"}],4);Hl([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ph=Hl([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Mh=Hl([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Hl([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Fh=Hl([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bh=Hl([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Hl([{name:"triangle",components:3,type:"Uint16"}]),Hl([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Hl([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Hl([{type:"Float32",name:"offsetX"}]),Hl([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Hh=24;const Uh=128;function Gh(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new gl(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:s}=n;let i=0;for(;i{e.text=function(e,t,n){const s=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===s?e=e.toLocaleUpperCase():"lowercase"===s&&(e=e.toLocaleLowerCase()),wl.applyArabicShaping&&(e=wl.applyArabicShaping(e)),e}(e.text,t,n)})),e}const Wh={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42","\u2190":"\u2191","\u2192":"\u2193"};function Yh(e){return"\ufe36"===e||"\ufe48"===e||"\ufe38"===e||"\ufe44"===e||"\ufe42"===e||"\ufe3e"===e||"\ufe3c"===e||"\ufe3a"===e||"\ufe18"===e||"\ufe40"===e||"\ufe10"===e||"\ufe13"===e||"\ufe14"===e||"\uff40"===e||"\uffe3"===e||"\ufe11"===e||"\ufe12"===e}function qh(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}var Xh=Qh,Zh=function(e,t,n,s,i){var l,a,r=8*i-s-1,o=(1<>1,c=-7,h=n?i-1:0,p=n?-1:1,d=e[t+h];for(h+=p,l=d&(1<<-c)-1,d>>=-c,c+=r;c>0;l=256*l+e[t+h],h+=p,c-=8);for(a=l&(1<<-c)-1,l>>=-c,c+=s;c>0;a=256*a+e[t+h],h+=p,c-=8);if(0===l)l=1-u;else{if(l===o)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,s),l-=u}return(d?-1:1)*a*Math.pow(2,l-s)},Kh=function(e,t,n,s,i,l){var a,r,o,u=8*l-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=s?0:l-1,f=s?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(r=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-a))<1&&(a--,o*=2),(t+=a+h>=1?p/o:p*Math.pow(2,1-h))*o>=2&&(a++,o/=2),a+h>=c?(r=0,a=c):a+h>=1?(r=(t*o-1)*Math.pow(2,i),a+=h):(r=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+d]=255&r,d+=f,r/=256,i-=8);for(a=a<0;e[n+d]=255&a,d+=f,a/=256,u-=8);e[n+d-f]|=128*m};function Qh(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Qh.Varint=0,Qh.Fixed64=1,Qh.Bytes=2,Qh.Fixed32=5;var Jh=4294967296,$h=1/Jh,ep="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function tp(e){return e.type===Qh.Bytes?e.readVarint()+e.pos:e.pos+1}function np(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function sp(e,t,n){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(s);for(var i=n.pos-1;i>=e;i--)n.buf[i+s]=n.buf[i]}function ip(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function mp(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}Qh.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos>3,l=this.pos;this.type=7&s,e(i,t,this),this.pos===l&&this.skip(s)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=dp(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=mp(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=dp(this.buf,this.pos)+dp(this.buf,this.pos+4)*Jh;return this.pos+=8,e},readSFixed64:function(){var e=dp(this.buf,this.pos)+mp(this.buf,this.pos+4)*Jh;return this.pos+=8,e},readFloat:function(){var e=Zh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Zh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,s=this.buf;return t=127&(n=s[this.pos++]),n<128?t:(t|=(127&(n=s[this.pos++]))<<7,n<128?t:(t|=(127&(n=s[this.pos++]))<<14,n<128?t:(t|=(127&(n=s[this.pos++]))<<21,n<128?t:function(e,t,n){var s,i,l=n.buf;if(s=(112&(i=l[n.pos++]))>>4,i<128)return np(e,s,t);if(s|=(127&(i=l[n.pos++]))<<3,i<128)return np(e,s,t);if(s|=(127&(i=l[n.pos++]))<<10,i<128)return np(e,s,t);if(s|=(127&(i=l[n.pos++]))<<17,i<128)return np(e,s,t);if(s|=(127&(i=l[n.pos++]))<<24,i<128)return np(e,s,t);if(s|=(1&(i=l[n.pos++]))<<31,i<128)return np(e,s,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=s[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&ep?function(e,t,n){return ep.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var s="",i=t;i239?4:o>223?3:o>191?2:1;if(i+c>n)break;1===c?o<128&&(u=o):2===c?128==(192&(l=e[i+1]))&&(u=(31&o)<<6|63&l)<=127&&(u=null):3===c?(a=e[i+2],128==(192&(l=e[i+1]))&&128==(192&a)&&((u=(15&o)<<12|(63&l)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=e[i+2],r=e[i+3],128==(192&(l=e[i+1]))&&128==(192&a)&&128==(192&r)&&((u=(15&o)<<18|(63&l)<<12|(63&a)<<6|63&r)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,s+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),s+=String.fromCharCode(u),i+=c}return s}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==Qh.Bytes)return e.push(this.readVarint(t));var n=tp(this);for(e=e||[];this.pos127;);else if(t===Qh.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Qh.Fixed32)this.pos+=4;else{if(t!==Qh.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,s;if(e>=0?(n=e%4294967296|0,s=e/4294967296|0):(s=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,s=s+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(s,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var s,i,l=0;l55295&&s<57344){if(!i){s>56319||l+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=s;continue}if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=s;continue}s=i-55296<<10|s-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=63&s|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&sp(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Kh(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Kh(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&sp(n,s,this),this.pos=n-1,this.writeVarint(s),this.pos+=s},writeMessage:function(e,t,n){this.writeTag(e,Qh.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,ip,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,lp,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,op,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,ap,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,rp,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,up,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,cp,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,hp,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,pp,t)},writeBytesField:function(e,t){this.writeTag(e,Qh.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Qh.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Qh.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Qh.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Qh.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Qh.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Qh.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Qh.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Qh.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Qh.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var Ip=p(Xh);const yp=3;function vp(e,t,n){t.glyphs=[],1===e&&n.readMessage(Ep,t)}function Ep(e,t,n){if(3===e){const{id:e,bitmap:s,width:i,height:l,left:a,top:r,advance:o}=n.readMessage(wp,{});t.glyphs.push({id:e,bitmap:new Hu({width:i+2*yp,height:l+2*yp},s),metrics:{width:i,height:l,left:a,top:r,advance:o}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function wp(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}const gp=yp;function Tp(e){let t=0,n=0;for(const a of e)t+=a.w*a.h,n=Math.max(n,a.w);e.sort(((e,t)=>t.h-e.h));const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,l=0;for(const a of e)for(let e=s.length-1;e>=0;e--){const t=s[e];if(!(a.w>t.w||a.h>t.h)){if(a.x=t.x,a.y=t.y,l=Math.max(l,a.y+a.h),i=Math.max(i,a.x+a.w),a.w===t.w&&a.h===t.h){const t=s.pop();ee.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[s,i]=e.tl;n.update(t.data,void 0,{x:s,y:i})}}Zi(Rp,"ImagePosition"),Zi(Sp,"ImageAtlas");const Dp={horizontal:1,vertical:2,horizontalOnly:3},Ap=-17;class Cp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new Cp;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new Cp;return t.imageName=e,t}}class xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new xp;for(let s=0;s=0&&n>=e&&Op[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new xp;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Cp.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let s=0;s=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function _p(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f){const m=xp.fromFeature(e,i);h===Dp.vertical&&m.verticalizePunctuation(p);let I=[];const y=function(e,t,n,s,i,l){if(!e)return[];const a=[],r=function(e,t,n,s,i,l){let a=0;for(let r=0;r=0;let u=0;for(let h=0;h0&&l>w&&(w=l)}else{const e=n[a.fontStack];if(!e)continue;e[f]&&(R=e[f]);const s=t[a.fontStack];if(!s)continue;const l=s.glyphs[f];if(!l)continue;if(y=l.metrics,D=8203!==f?Hh:0,I){const e=void 0!==s.ascender?Math.abs(s.ascender):0,t=void 0!==s.descender?Math.abs(s.descender):0,n=(e+t)*m;g-n/2;){if(a--,a<0)return!1;r-=e[a].dist(l),l=e[a]}r+=e[a].dist(e[a+1]),a++;const o=[];let u=0;for(;rs;)u-=o.shift().angleDelta;if(u>i)return!1;a++,r+=t.dist(n)}return!0}function jp(e){let t=0;for(let n=0;nu){const l=(u-o)/i,h=Nn(n.x,s.x,l),p=Nn(n.y,s.y,l),d=new zp(h,p,0,s.angleTo(n),c);return!a||Vp(e,d,r,a,t)?d:void 0}o+=i}}function Xp(e,t,n,s,i,l,a,r,o){const u=Wp(s,l,a),c=Yp(s,i),h=c*a,p=0===e[0].x||e[0].x===o||0===e[0].y||e[0].y===o;return t-h=0&&y=0&&v=0&&p+u<=c){const t=new zp(y,v,0,m,f);t._round(),s&&!Vp(e,t,l,s,i)||d.push(t)}}h+=r}return r||d.length||a||(d=Zp(e,h/2,n,s,i,l,a,!0,o)),d}function Kp(e,t,n,s,i){const l=[];for(let a=0;a=s&&u.x>=s||(a.x>=s?a=new v(s,a.y+(s-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=s&&(u=new v(s,a.y+(s-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),o&&a.equals(o[o.length-1])||(o=[a],l.push(o)),o.push(u)))))}}return l}Zi(zp,"Anchor");const Qp=1e20;function Jp(e,t,n,s,i,l,a,r,o){for(let u=t;u-1);o++,l[o]=r,a[o]=u,a[o+1]=Qp}for(let r=0,o=0;r{let{stack:n,id:s}=e,i=this.entries[n];i||(i=this.entries[n]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let l=i.glyphs[s];if(void 0!==l)return void t(null,{stack:n,id:s,glyph:l});if(l=this._tinySDF(i,n,s),l)return i.glyphs[s]=l,void t(null,{stack:n,id:s,glyph:l});const a=Math.floor(s/256);if(256*a>65535)return void t(new Error("glyphs > 65535 not supported"));if(i.ranges[a])return void t(null,{stack:n,id:s,glyph:l});let r=i.requests[a];r||(r=i.requests[a]=[],nd.loadGlyphRange(n,a,this.url,this.requestManager,((e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[a]=!0}for(const n of r)n(e,t);delete i.requests[a]}))),r.push(((e,i)=>{e?t(e):i&&t(null,{stack:n,id:s,glyph:i.glyphs[s]||null})}))}),((e,n)=>{if(e)t(e);else if(n){const e={};for(const{stack:t,id:s,glyph:i}of n)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[s]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==td.none&&(this.localGlyphMode===td.all?!!this.localFontFamily:!!this.localFontFamily&&(el["CJK Unified Ideographs"](e)||el["Hangul Syllables"](e)||el.Hiragana(e)||el.Katakana(e)||el["CJK Symbols and Punctuation"](e)))}_tinySDF(e,t,n){const s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new nd.TinySDF({fontFamily:s,fontWeight:n,fontSize:24*ed,buffer:3*ed,radius:8*ed}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const l=String.fromCharCode(n),{data:a,width:r,height:o,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:d}=i.draw(l);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new Hu({width:r,height:o},a),metrics:{width:u/ed,height:c/ed,left:h/ed,top:p/ed-27,advance:d/ed,localGlyph:!0}}}}nd.loadGlyphRange=function(e,t,n,s,i){const l=256*t,a=l+255,r=s.transformRequest(s.normalizeGlyphsURL(n).replace("{fontstack}",e).replace("{range}","".concat(l,"-").concat(a)),oe.Glyphs);pe(r,((e,t)=>{if(e)i(e);else if(t){const e={},n=function(e){return new Ip(e).readFields(vp,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}}))},nd.TinySDF=class{constructor(){let{fontSize:e=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:i="sans-serif",fontWeight:l="normal",fontStyle:a="normal"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.buffer=t,this.cutoff=s,this.radius=n;const r=this.size=e+4*t,o=this._createCanvas(r),u=this.ctx=o.getContext("2d",{willReadFrequently:!0});u.font="".concat(a," ").concat(l," ").concat(e,"px ").concat(i),u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(r*r),this.gridInner=new Float64Array(r*r),this.f=new Float64Array(r),this.z=new Float64Array(r+1),this.v=new Uint16Array(r)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:i,actualBoundingBoxRight:l}=this.ctx.measureText(e),a=Math.ceil(n),r=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l-i))),o=Math.min(this.size-this.buffer,a+Math.ceil(s)),u=r+2*this.buffer,c=o+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),d={data:p,width:u,height:c,glyphWidth:r,glyphHeight:o,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===r||0===o)return d;const{ctx:f,buffer:m,gridInner:I,gridOuter:y}=this;f.clearRect(m,m,r,o),f.fillText(e,m,m+a);const v=f.getImageData(m,m,r,o);y.fill(Qp,0,h),I.fill(0,0,h);for(let E=0;E0?e*e:0,I[n]=e<0?e*e:0}}Jp(y,0,0,u,c,u,this.f,this.v,this.z),Jp(I,m,m,r,o,u,this.f,this.v,this.z);for(let E=0;Ee+t[1]-t[0],f=h.reduce(d,0),m=p.reduce(d,0),I=r-f,y=o-m;let E=0,w=f,g=0,T=m,b=0,R=I,S=0,D=y;if(l.content&&s){const e=l.content;E=ld(h,0,e[0]),g=ld(p,0,e[1]),w=ld(h,e[0],e[2]),T=ld(p,e[1],e[3]),b=e[0]-E,S=e[1]-g,R=e[2]-e[0]-w,D=e[3]-e[1]-T}const A=(s,i,r,o)=>{const h=rd(s.stretch-E,w,u,e.left),p=od(s.fixed-b,R,s.stretch,f),d=rd(i.stretch-g,T,c,e.top),I=od(i.fixed-S,D,i.stretch,m),y=rd(r.stretch-E,w,u,e.left),A=od(r.fixed-b,R,r.stretch,f),C=rd(o.stretch-g,T,c,e.top),x=od(o.fixed-S,D,o.stretch,m),_=new v(h,d),O=new v(y,d),N=new v(y,C),L=new v(h,C),P=new v(p/a,I/a),M=new v(A/a,x/a),F=t*Math.PI/180;if(F){const e=Math.sin(F),t=Math.cos(F),n=[t,-e,e,t];_._matMult(n),O._matMult(n),L._matMult(n),N._matMult(n)}const B=s.stretch+s.fixed,H=i.stretch+i.fixed;return{tl:_,tr:O,bl:L,br:N,tex:{x:l.paddedRect.x+sd+B,y:l.paddedRect.y+sd+H,w:r.stretch+r.fixed-B,h:o.stretch+o.fixed-H},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:P,pixelOffsetBR:M,minFontScaleX:R/a/u,minFontScaleY:D/a/c,isSDF:n}};if(s&&(l.stretchX||l.stretchY)){const e=ad(h,I,f),t=ad(p,y,m);for(let n=0;n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hd;if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,s=t[e];for(;e>0;){const i=e-1>>1,l=t[i];if(n(s,l)>=0)break;t[e]=l,e=i}t[e]=s}_down(e){const{data:t,compare:n}=this,s=this.length>>1,i=t[e];for(;e=0)break;t[e]=l,e=s}t[e]=i}}function hd(e,t){return et?1:0}function pd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=1/0,i=1/0,l=-1/0,a=-1/0;const r=e[0];for(let d=0;dl)&&(l=e.x),(!d||e.y>a)&&(a=e.y)}const o=Math.min(l-s,a-i);let u=o/2;const c=new cd([],dd);if(0===o)return new v(s,i);for(let d=s;dh.d||!h.d)&&(h=s,n&&console.log("found best %d after %d probes",Math.round(1e4*s.d)/1e4,p)),s.max-h.d<=t||(u=s.h/2,c.push(new fd(s.p.x-u,s.p.y-u,u,e)),c.push(new fd(s.p.x+u,s.p.y-u,u,e)),c.push(new fd(s.p.x-u,s.p.y+u,u,e)),c.push(new fd(s.p.x+u,s.p.y+u,u,e)),p+=4)}return n&&(console.log("num probes: ".concat(p)),console.log("best distance: ".concat(h.d))),h.p}function dd(e,t){return t.max-e.max}class fd{constructor(e,t,n,s){this.p=new v(e,t),this.h=n,this.d=function(e,t){let n=!1,s=1/0;for(let i=0;ie.y!=r.y>e.y&&e.x<(r.x-i.x)*(e.y-i.y)/(r.y-i.y)+i.x&&(n=!n),s=Math.min(s,vu(e,i,r))}}return(n?1:-1)*Math.sqrt(s)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}const md=7,Id=Number.POSITIVE_INFINITY,yd=Math.sqrt(2);function vd(e,t){let[n,s]=t,i=0,l=0;if(s===Id){n<0&&(n=0);const t=n/yd;switch(e){case"top-right":case"top-left":l=t-md;break;case"bottom-right":case"bottom-left":l=-t+md;break;case"bottom":l=-n+md;break;case"top":l=n-md}switch(e){case"top-right":case"bottom-right":i=-t;break;case"top-left":case"bottom-left":i=t;break;case"left":i=n;break;case"right":i=-n}}else{switch(n=Math.abs(n),s=Math.abs(s),e){case"top-right":case"top-left":case"top":l=s-md;break;case"bottom-right":case"bottom-left":case"bottom":l=-s+md}switch(e){case"top-right":case"bottom-right":case"right":i=-n;break;case"top-left":case"bottom-left":case"left":i=n}}return[i,l]}function Ed(e,t,n,s,i,l,a,r,o,u){e.createArrays(),e.tilePixelRatio=ar/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const c=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new gl(t),r),h["text-size"].possiblyEvaluate(new gl(n),r)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new gl(t),r),h["icon-size"].possiblyEvaluate(new gl(n),r)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new gl(o+1),r),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new gl(o+1),r),p.textMaxSize=h["text-size"].possiblyEvaluate(new gl(18),r);const d="map"===c.get("text-rotation-alignment")&&"point"!==c.get("symbol-placement"),f=c.get("text-size");for(const m of e.features){const l=c.get("text-font").evaluate(m,{},r).join(","),o=f.evaluate(m,{},r),h=p.layoutTextSize.evaluate(m,{},r),I=(p.layoutIconSize.evaluate(m,{},r),{horizontal:{},vertical:void 0}),y=m.text;let v,E=[0,0];if(y){const s=y.toString(),a=c.get("text-letter-spacing").evaluate(m,{},r)*Hh,u=c.get("text-line-height").evaluate(m,{},r)*Hh,p=nl(s)?a:0,f=c.get("text-anchor").evaluate(m,{},r),v=c.get("text-variable-anchor");if(!v){const e=c.get("text-radial-offset").evaluate(m,{},r);E=e?vd(f,[e*Hh,Id]):c.get("text-offset").evaluate(m,{},r).map((e=>e*Hh))}let w=d?"center":c.get("text-justify").evaluate(m,{},r);const g="point"===c.get("symbol-placement"),T=g?c.get("text-max-width").evaluate(m,{},r)*Hh:1/0,b=a=>{e.allowVerticalPlacement&&tl(s)&&(I.vertical=_p(y,t,n,i,l,T,u,f,a,p,E,Dp.vertical,!0,h,o))};if(!d&&v){const e="auto"===w?v.map((e=>wd(e))):[w];let s=!1;for(let a=0;a=0||!tl(s)){const e=_p(y,t,n,i,l,T,u,f,w,p,E,Dp.horizontal,!1,h,o);e&&(I.horizontal[w]=e)}b(g?"left":w)}}let w=!1;if(m.icon&&m.icon.name){const t=s[m.icon.name];t&&(v=Gp(i[m.icon.name],c.get("icon-offset").evaluate(m,{},r),c.get("icon-anchor").evaluate(m,{},r)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&j("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const g=Sd(I.horizontal)||I.vertical;e.iconsInText||(e.iconsInText=!!g&&g.iconsInText),(g||v)&&gd(e,m,I,v,s,p,h,0,E,w,a,r,u)}l&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray)}function wd(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function gd(e,t,n,s,i,l,a,r,o,u,c,h,p){let d=l.textMaxSize.evaluate(t,{},h);void 0===d&&(d=a);const f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),I=Sd(n.horizontal)||n.vertical,y="globe"===p.name,v=Hh,E=a/v,w=e.tilePixelRatio*d/v,T=(_=e.overscaling,e.zoom>18&&_>2&&(_>>=1),Math.max(ar/(512*_),1)*f.get("symbol-spacing")),b=f.get("text-padding")*e.tilePixelRatio,R=f.get("icon-padding")*e.tilePixelRatio,S=g(f.get("text-max-angle")),D="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),A="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),C=f.get("symbol-placement"),x=T/2;var _;const O=f.get("icon-text-fit");let N;s&&"none"!==O&&(e.allowVerticalPlacement&&n.vertical&&(N=kp(s,n.vertical,O,f.get("icon-text-fit-padding"),m,E)),I&&(s=kp(s,I,O,f.get("icon-text-fit-padding"),m,E)));const L=(a,r,d)=>{if(r.x<0||r.x>=ar||r.y<0||r.y>=ar)return;let f=null;if(y){const{x:e,y:t,z:n}=p.projectTilePoint(r.x,r.y,d);f={anchor:new zp(e,t,n,0,void 0),up:p.upVector(d,r.x,r.y)}}!function(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E,w,g,T,b,R){const S=e.addToLineVertexArray(t,s);let D,A,C,x,_,O,N,L=0,P=0,M=0,F=0,B=-1,H=-1;const U={};let G=_a("");const k=n?n.anchor:t;let z=0,V=0;if(void 0===o._unevaluatedLayout.getValue("text-radial-offset")?[z,V]=o.layout.get("text-offset").evaluate(w,{},R).map((e=>e*Hh)):(z=o.layout.get("text-radial-offset").evaluate(w,{},R)*Hh,V=Id),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(f)O=Ad(e),r&&(N=Ad(r));else{const n=o.layout.get("text-rotate").evaluate(w,{},R)+90;C=Dd(u,k,t,c,h,p,e,d,n,m),r&&(x=Dd(u,k,t,c,h,p,r,y,n))}}if(l){const s=o.layout.get("icon-rotate").evaluate(w,{},R),i="none"!==o.layout.get("icon-text-fit"),a=id(l,s,T,i),d=r?id(r,s,T,i):void 0;A=Dd(u,k,t,c,h,p,l,y,s),L=4*a.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[Uh*o.layout.get("icon-size").evaluate(w,{},R)],m[0]>bd&&j("".concat(e.layerIds[0],': Value for "icon-size" is >= ').concat(Td,'. Reduce your "icon-size".'))):"composite"===f.kind&&(m=[Uh*g.compositeIconSizes[0].evaluate(w,{},R),Uh*g.compositeIconSizes[1].evaluate(w,{},R)],(m[0]>bd||m[1]>bd)&&j("".concat(e.layerIds[0],': Value for "icon-size" is >= ').concat(Td,'. Reduce your "icon-size".'))),e.addSymbols(e.icon,a,m,E,v,w,!1,n,t,S.lineStartIndex,S.lineLength,-1,b,R),B=e.icon.placedSymbolArray.length-1,d&&(P=4*d.length,e.addSymbols(e.icon,d,m,E,v,w,Dp.vertical,n,t,S.lineStartIndex,S.lineLength,-1,b,R),H=e.icon.placedSymbolArray.length-1)}for(const j in i.horizontal){const s=i.horizontal[j];D||(G=_a(s.text),f?_=Ad(s):D=Dd(u,k,t,c,h,p,s,d,o.layout.get("text-rotate").evaluate(w,{},R),m));const l=1===s.positionedLines.length;if(M+=Rd(e,n,t,s,a,o,f,w,m,S,i.vertical?Dp.horizontal:Dp.horizontalOnly,l?Object.keys(i.horizontal):[j],U,B,g,b,R),l)break}i.vertical&&(F+=Rd(e,n,t,i.vertical,a,o,f,w,m,S,Dp.vertical,["vertical"],U,H,g,b,R));let W=-1;const Y=(e,t)=>e?Math.max(e,t):t;W=Y(_,W),W=Y(O,W),W=Y(N,W);const q=W>-1?1:0;e.glyphOffsetArray.length>=rf.MAX_GLYPHS&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey),e.symbolInstances.emplaceBack(k.x,k.y,k.z,t.x,t.y,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,B,H,G,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,x||e.collisionBoxArray.length,x?x+1:e.collisionBoxArray.length,c,M,F,L,P,q,0,z,V,W)}(e,r,f,a,n,s,i,N,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,b,D,o,0,R,A,m,t,l,u,c,h)};if("line"===C)for(const g of Kp(t.geometry,0,0,ar,ar)){const t=Xp(g,T,S,n.vertical||I,s,v,w,e.overscaling,ar);for(const n of t)I&&Cd(e,I.text,x,n)||L(g,n,h)}else if("line-center"===C){for(const g of t.geometry)if(g.length>1){const e=qp(g,S,n.vertical||I,s,v,w);e&&L(g,e,h)}}else if("Polygon"===t.type)for(const g of bc(t.geometry,0)){const e=pd(g,16);L(g[0],new zp(e.x,e.y,0,0,void 0),h)}else if("LineString"===t.type)for(const g of t.geometry)L(g,new zp(g[0].x,g[0].y,0,0,void 0),h);else if("Point"===t.type)for(const g of t.geometry)for(const e of g)L([e],new zp(e.x,e.y,0,0,void 0),h)}const Td=255,bd=Td*Uh;function Rd(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I){const y=function(e,t,n,s,i,l,a,r){const o=[];if(0===t.positionedLines.length)return o;const u=s.layout.get("text-rotate").evaluate(l,{})*Math.PI/180,c=function(e){const t=e[0],n=e[1],s=t*n;return s>0?[t,-n]:s<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const m of t.positionedLines)h-=m.lineOffset;const p=t.positionedLines.length,d=h/p;let f=t.top-n[1];for(let m=0;mbd&&j("".concat(e.layerIds[0],': Value for "text-size" is >= ').concat(Td,'. Reduce your "text-size".'))):"composite"===E.kind&&(w=[Uh*f.compositeTextSizes[0].evaluate(r,{},I),Uh*f.compositeTextSizes[1].evaluate(r,{},I)],(w[0]>bd||w[1]>bd)&&j("".concat(e.layerIds[0],': Value for "text-size" is >= ').concat(Td,'. Reduce your "text-size".'))),e.addSymbols(e.text,y,w,o,a,r,c,t,n,u.lineStartIndex,u.lineLength,d,m,I);for(const v of h)p[v]=e.text.placedSymbolArray.length-1;return 4*y.length}function Sd(e){for(const t in e)return e[t];return null}function Dd(e,t,n,s,i,l,a,r,o,u){let c=a.top,h=a.bottom,p=a.left,d=a.right;const f=a.collisionPadding;if(f&&(p-=f[0],c-=f[1],d+=f[2],h+=f[3]),o){const e=new v(p,c),t=new v(d,c),n=new v(p,h),s=new v(d,h),i=g(o);let l=new v(0,0);u&&(l=new v(u[0],u[1])),e._rotateAround(i,l),t._rotateAround(i,l),n._rotateAround(i,l),s._rotateAround(i,l),p=Math.min(e.x,t.x,n.x,s.x),d=Math.max(e.x,t.x,n.x,s.x),c=Math.min(e.y,t.y,n.y,s.y),h=Math.max(e.y,t.y,n.y,s.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,p,c,d,h,r,s,i,l),e.length-1}function Ad(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Cd(e,t,n,s){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(s.dist(e[t])E&&(w(e,u,s,i,r,o),w(u,n,r,o,l,a))}w(h,p,s,l,i,l),w(p,d,i,l,i,a),w(d,f,i,a,s,a),w(f,h,s,a,s,l),m-=E,I-=E,y+=E,v+=E;const g=1/Math.max(y-m,v-I);return{scale:g,x:m*g,y:I*g,x2:y*g,y2:v*g,projection:t}}const Od=pr(new Float32Array(16));class Nd{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new zo(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return Yo(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return xd(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,s){const i=e.horizonLineFromTop(!1),l=new v(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(l,s))}pointCoordinate3D(e,t,n){const s=new v(t,n);if(e.elevation)return e.elevation.pointCoordinate(s);{const t=this.pointCoordinate(e,s.x,s.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-kd+n&&(t=-kd+n):t>kd-n&&(t=kd-n);const l=i/Math.pow(zd(t),s);let a=l*Math.sin(s*e),r=i-l*Math.cos(s*e);return a=.5*(a/Math.PI+.5),r=.5*(r/Math.PI+.5),{x:a,y:this.southernCenter?r:1-r,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:s}=this,i=s-t,l=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let r=Math.atan2(e,Math.abs(i))*l;i*n<0&&(r-=Math.PI*Math.sign(e)*l);const o=A(T(r/n)+this.center[0],-180,180),u=A(T(2*Math.atan(Math.pow(s/a,1/n))-kd),-Ko,Ko);return new zo(o,this.southernCenter?-u:u)}}class jd extends Nd{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:jo(e),y:Wo(t),z:0}}unproject(e,t){const n=qo(e),s=Xo(t);return new zo(n,s)}}const Wd=g(Ko);class Yd extends Nd{project(e,t){const n=(t=g(t))*t,s=n*n;return{x:.5*((e=g(e))*(.8707-.131979*n+s*(s*(.003971*n-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+s*(.028874*n-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,s=25,i=0,l=n*n;do{l=n*n;const e=l*l;i=(n*(1.007226+l*(.015085+e*(.028874*l-.044475-.005916*e)))-t)/(1.007226+l*(.045255+e*(.259866*l-.311325-.005916*11*e))),n=A(n-i,-Wd,Wd)}while(Math.abs(i)>1e-6&&--s>0);l=n*n;const a=A(T(e/(.8707+l*(l*(l*l*l*(.003971-.001529*l)-.013791)-.131979))),-180,180),r=T(n);return new zo(a,r)}}const qd=g(Ko);class Xd extends Nd{project(e,t){t=g(t),e=g(e);const n=Math.cos(t),s=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),l=Math.sin(i)/i,a=.5*(e*s+2*n*Math.sin(e/2)/l)||0,r=.5*(t+Math.sin(t)/l)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(r/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,s=t=(2*(1-t)-1)*Math.PI,i=25;const l=1e-6;let a=0,r=0;do{const i=Math.cos(s),l=Math.sin(s),o=2*l*i,u=l*l,c=i*i,h=Math.cos(n/2),p=Math.sin(n/2),d=2*h*p,f=p*p,m=1-c*h*h,I=m?1/m:0,y=m?Math.acos(i*h)*Math.sqrt(1/m):0,v=.5*(2*y*i*p+2*n/Math.PI)-e,E=.5*(y*l+s)-t,w=.5*I*(c*f+y*i*h*u)+1/Math.PI,g=I*(d*o/4-y*l*p),T=.125*I*(o*p-y*l*c*d),b=.5*I*(u*h+y*f*i)+.5,R=g*T-b*w;a=(E*g-v*b)/R,r=(v*T-E*w)/R,n=A(n-a,-Math.PI,Math.PI),s=A(s-r,-qd,qd)}while((Math.abs(a)>l||Math.abs(r)>l)&&--i>0);return new zo(T(n),T(s))}}class Zd extends Nd{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(g(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:s}=this;return{x:g(e)*s*n+.5,y:-Math.sin(g(t))/s*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:s}=this,i=-(t-.5)/n,l=A(T((e-.5)/n)/s,-180,180),a=Math.asin(A(i*s,-1,1)),r=A(T(a),-Ko,Ko);return new zo(l,r)}}class Kd extends jd{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,n){const s=Ao(e,t,n);return Fr(s,s,_o(vo(n))),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,t){const n=Do(t.lat,t.lng),s=Lr([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Nr(n,n,s,Yo(1,0)*ar*i);const l=pr(new Float64Array(16));return fr(l,e.pixelMatrix,e.globeMatrix),Fr(n,n,l),new v(n[0],n[1])}pixelsPerMeter(e,t){return Yo(1,0)*t}pixelSpaceConversion(e,t,n){const s=Yo(1,e)*t,i=Nn(Yo(1,45)*t,s,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const s=Oo(vo(n.canonical));return fr(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,t){const{center:n}=e,s=_o(vo(t));return vr(s,s,g(n.lng)),yr(s,s,g(n.lat)),Ir(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}pointCoordinate(e,t,n,s){return mo(e,t,n,!0)||new Jo(0,0)}pointCoordinate3D(e,t,n){const s=this.pointCoordinate(e,t,n,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,t){return!mo(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const n=e.cameraToCenterDistance,s=e._centerAltitude*t,i=e._camera,l=e._camera.forward(),a=Dr([],Or([],l,-n),[0,0,s]),r=e.worldSize/(2*Math.PI),o=[0,0,-r],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=Or([],i.up(),c),p=Or([],i.right(),c*u),d=Lr([],Dr([],Dr([],l,h),p)),f=[];let m;if(new eo(a,d).closestPointOnSphere(o,r,f)){const t=Dr([],f,o),n=Ur([],t,a);m=Math.cos(e.fovAboveCenter)*Rr(n)}else{const e=Ur([],a,o),t=Ur([],o,a);Lr(t,t);const n=Rr(e)-r;m=Math.sqrt(n*(n+2*r));const s=Math.acos(m/(r+n))-Math.acos(Pr(l,t));m*=Math.cos(s)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Lo(e.zoom);if(n>0){const s=xd(e,Yo(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),l=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Nn(t,s+i*(1-Math.cos(l)),Math.pow(n,10))}return t}upVector(e,t,n){return Ao(t,n,e,1)}upVectorScale(e){return{metersToTile:fo(Co(vo(e)))}}}function Qd(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new jd(e);case"equirectangular":return new Gd(e);case"naturalEarth":return new Yd(e);case"equalEarth":return new Ud(e);case"winkelTripel":return new Xd(e);case"albers":return n?new Zd(e):new Ld(e);case"lambertConformalConic":return n?new Zd(e):new Vd(e);case"globe":return new Kd(e)}throw new Error("Invalid projection name: ".concat(e.name))}const Jd=qc.types,$d=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ef(e,t,n,s,i,l,a,r,o,u,c,h,p){const d=r?Math.min(bd,Math.round(r[0])):0,f=r?Math.min(bd,Math.round(r[1])):0;e.emplaceBack(t,n,Math.round(32*s),Math.round(32*i),l,a,(d<<1)+(o?1:0),f,16*u,16*c,256*h,256*p)}function tf(e,t,n,s,i,l,a){e.emplaceBack(t,n,s,i,l,a)}function nf(e,t,n,s,i){e.emplaceBack(t,n,s,i),e.emplaceBack(t,n,s,i),e.emplaceBack(t,n,s,i),e.emplaceBack(t,n,s,i)}function sf(e){for(const t of e.sections)if(ol(t.text))return!0;return!1}class lf{constructor(e){this.layoutVertexArray=new Xl,this.indexArray=new na,this.programConfigurations=e,this.segments=new lr,this.dynamicLayoutVertexArray=new jl,this.opacityVertexArray=new Kl,this.placedSymbolArray=new fa,this.globeExtVertexArray=new Zl}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,n,s){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Oh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Lh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,$d,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Nh.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||s)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Zi(lf,"SymbolBuffers");class af{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new lr,this.collisionVertexArray=new ea,this.collisionVertexArrayExt=new ta}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ph.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Mh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Zi(af,"CollisionBuffers");class rf{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=pr([]),this.placementViewportMatrix=pr([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Gh(this.zoom,t["text-size"]),this.iconSizeData=Gh(this.zoom,t["icon-size"]);const n=this.layers[0].layout,s=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==s.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((e=>Dp[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new lf(new Za(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new lf(new Za(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new ya,this.lineVertexArray=new va,this.symbolInstances=new Ia}calculateGlyphDependencies(e,t,n,s,i){for(let l=0;l0)&&("constant"!==r.value.kind||r.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=l.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,I=new gl(this.zoom);for(const{feature:y,id:v,index:E,sourceLayerIndex:w}of e){const e=i._featureFilter.needGeometry,t=ru(y,e);if(!i._featureFilter.filter(I,t,n))continue;if(e||(t.geometry=au(y,n,s)),a&&1!==y.type&&n.z<=5){const e=t.geometry,s=.98078528056,i=(e,t)=>Pr(Ao(e.x,e.y,n,1),Ao(t.x,t.y,n,1))=0;for(const t of o.sections)if(t.image)d[t.image.name]=!0;else{const n=tl(o.toString()),i=t.fontStack||e,l=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,l,s,this.allowVerticalPlacement,n)}}}"line"===l.get("symbol-placement")&&(this.features=function(e){const t={},n={},s=[];let i=0;function l(t){s.push(e[t]),i++}function a(e,t,i){const l=n[e];return delete n[e],n[t]=l,s[l].geometry[0].pop(),s[l].geometry[0]=s[l].geometry[0].concat(i[0]),l}function r(e,n,i){const l=t[n];return delete t[n],t[e]=l,s[l].geometry[0].shift(),s[l].geometry[0]=i[0].concat(s[l].geometry[0]),l}function o(e,t,n){const s=n?t[0][t[0].length-1]:t[0][0];return"".concat(e,":").concat(s.x,":").concat(s.y)}for(let u=0;ue.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,n,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,n,s),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,n,s))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Qd(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:s,y:i}of t)this.lineVertexArray.emplaceBack(s,i);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,s,i,l,a,r,o,u,c,h,p,d){const f=e.indexArray,m=e.layoutVertexArray,I=e.globeExtVertexArray,y=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?l.sortKey:void 0),v=this.glyphOffsetArray.length,E=y.vertexLength,w=this.allowVerticalPlacement&&a===Dp.vertical?Math.PI/2:0,g=l.text&&l.text.sections;for(let b=0;b=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:s),l=kh(this.textSizeData,e,i)/Hh;return this.tilePixelRatio*l}getSymbolInstanceIconSize(e,t,n){const s=this.icon.placedSymbolArray.get(n),i=kh(this.iconSizeData,e,s);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n){e.emplaceBack(t,-n,-n),e.emplaceBack(t,n,-n),e.emplaceBack(t,n,n),e.emplaceBack(t,-n,n)}_updateTextDebugCollisionBoxes(e,t,n,s,i,l){for(let a=s;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),s=n.vertexStartIndex+4*n.numGlyphs;for(let i=n.vertexStartIndex;is[e]-s[t]||i[t]-i[e])),l}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:s,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:l,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:r}=t;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),s>=0&&s!==n&&this.addIndicesForPlacedSymbol(this.text,s),i>=0&&i!==s&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),l>=0&&this.addIndicesForPlacedSymbol(this.text,l),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),r>=0&&this.addIndicesForPlacedSymbol(this.icon,r)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Zi(rf,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),rf.MAX_GLYPHS=65535,rf.addDynamicAttributes=nf;const of=new Ll({"symbol-placement":new _l(et.layout_symbol["symbol-placement"]),"symbol-spacing":new _l(et.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _l(et.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ol(et.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _l(et.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _l(et.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new _l(et.layout_symbol["icon-ignore-placement"]),"icon-optional":new _l(et.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _l(et.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ol(et.layout_symbol["icon-size"]),"icon-text-fit":new _l(et.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _l(et.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ol(et.layout_symbol["icon-image"]),"icon-rotate":new Ol(et.layout_symbol["icon-rotate"]),"icon-padding":new _l(et.layout_symbol["icon-padding"]),"icon-keep-upright":new _l(et.layout_symbol["icon-keep-upright"]),"icon-offset":new Ol(et.layout_symbol["icon-offset"]),"icon-anchor":new Ol(et.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _l(et.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _l(et.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _l(et.layout_symbol["text-rotation-alignment"]),"text-field":new Ol(et.layout_symbol["text-field"]),"text-font":new Ol(et.layout_symbol["text-font"]),"text-size":new Ol(et.layout_symbol["text-size"]),"text-max-width":new Ol(et.layout_symbol["text-max-width"]),"text-line-height":new Ol(et.layout_symbol["text-line-height"]),"text-letter-spacing":new Ol(et.layout_symbol["text-letter-spacing"]),"text-justify":new Ol(et.layout_symbol["text-justify"]),"text-radial-offset":new Ol(et.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _l(et.layout_symbol["text-variable-anchor"]),"text-anchor":new Ol(et.layout_symbol["text-anchor"]),"text-max-angle":new _l(et.layout_symbol["text-max-angle"]),"text-writing-mode":new _l(et.layout_symbol["text-writing-mode"]),"text-rotate":new Ol(et.layout_symbol["text-rotate"]),"text-padding":new _l(et.layout_symbol["text-padding"]),"text-keep-upright":new _l(et.layout_symbol["text-keep-upright"]),"text-transform":new Ol(et.layout_symbol["text-transform"]),"text-offset":new Ol(et.layout_symbol["text-offset"]),"text-allow-overlap":new _l(et.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new _l(et.layout_symbol["text-ignore-placement"]),"text-optional":new _l(et.layout_symbol["text-optional"])});var uf={paint:new Ll({"icon-opacity":new Ol(et.paint_symbol["icon-opacity"]),"icon-color":new Ol(et.paint_symbol["icon-color"]),"icon-halo-color":new Ol(et.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ol(et.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ol(et.paint_symbol["icon-halo-blur"]),"icon-translate":new _l(et.paint_symbol["icon-translate"]),"icon-translate-anchor":new _l(et.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ol(et.paint_symbol["text-opacity"]),"text-color":new Ol(et.paint_symbol["text-color"],{runtimeType:pt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ol(et.paint_symbol["text-halo-color"]),"text-halo-width":new Ol(et.paint_symbol["text-halo-width"]),"text-halo-blur":new Ol(et.paint_symbol["text-halo-blur"]),"text-translate":new _l(et.paint_symbol["text-translate"]),"text-translate-anchor":new _l(et.paint_symbol["text-translate-anchor"])}),layout:of};class cf{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ot,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Zi(cf,"FormatSectionOverride",{omit:["defaultValue"]});class hf extends nr{constructor(e){super(e,uf)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,s){const i=this.layout.get(e).evaluate(t,{},n,s),l=this._unevaluatedLayout._values[e];return l.isDataDriven()||Zs(l.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,n)=>n in e?String(e[n]):""))}(t.properties,i)}createBucket(e){return new rf(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of uf.paint.overridableProperties){if(!hf.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new cf(t),s=new Xs(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Qs("source",s):new Js("composite",s,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Cl(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&hf.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),s=uf.paint.properties[t];let i=!1;const l=e=>{for(const t of e)if(s.overrides&&s.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof Pt)l(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof kt&&Ht(t.value)===It?l(t.value.sections):t instanceof Yt?l(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramConfiguration(e){return new Xa(this,e)}}var pf={paint:new Ll({"background-color":new _l(et.paint_background["background-color"]),"background-pattern":new _l(et.paint_background["background-pattern"]),"background-opacity":new _l(et.paint_background["background-opacity"])})},df={paint:new Ll({"raster-opacity":new _l(et.paint_raster["raster-opacity"]),"raster-hue-rotate":new _l(et.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _l(et.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _l(et.paint_raster["raster-brightness-max"]),"raster-saturation":new _l(et.paint_raster["raster-saturation"]),"raster-contrast":new _l(et.paint_raster["raster-contrast"]),"raster-resampling":new _l(et.paint_raster["raster-resampling"]),"raster-fade-duration":new _l(et.paint_raster["raster-fade-duration"])})};class ff extends nr{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var mf={paint:new Ll({"sky-type":new _l(et.paint_sky["sky-type"]),"sky-atmosphere-sun":new _l(et.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new _l(et.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new _l(et.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new _l(et.paint_sky["sky-gradient-radius"]),"sky-gradient":new Nl(et.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new _l(et.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new _l(et.paint_sky["sky-atmosphere-color"]),"sky-opacity":new _l(et.paint_sky["sky-opacity"])})};function If(e,t,n){const s=[0,0,1],i=Yr([]);return Xr(i,i,n?-g(e)+Math.PI:g(e)),qr(i,i,-g(t)),Br(s,s,i),Lr(s,s)}const yf={circle:class extends nr{constructor(e){super(e,Cu)}createBucket(e){return new cu(e)}queryRadius(e){const t=e;return bu("circle-radius",this,t)+bu("circle-stroke-width",this,t)+Ru(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,s,i,l,a,r){const o=Du(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,n)+this.paint.get("circle-stroke-width").evaluate(t,n);return xu(e,s,l,a,r,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),o,u)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new Xa(this,e)}},heatmap:class extends nr{createBucket(e){return new Pu(e)}constructor(e){super(e,Gu),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ku({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return bu("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,s,i,l,a,r){const o=this.paint.get("heatmap-radius").evaluate(t,n);return xu(e,s,l,a,r,!0,!0,new v(0,0),o)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new Xa(this,e)}},hillshade:class extends nr{constructor(e){super(e,zu)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends nr{constructor(e){super(e,xc)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),n=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(e){return new Xa(this,e)}recalculate(e,t){super.recalculate(e,t);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Ac(e)}queryRadius(){return Ru(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,s,i,l){return!e.queryGeometry.isAboveHorizon&&du(Su(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),l.angle,e.pixelToTileUnitsFactor),s)}isTileClipped(){return!0}},"fill-extrusion":class extends nr{constructor(e){super(e,ch)}createBucket(e){return new eh(e)}queryRadius(){return Ru(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new Xa(this,e)}queryIntersectsFeature(e,t,n,s,i,l,a,r,o){const u=Du(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,n),h=this.paint.get("fill-extrusion-base").evaluate(t,n),p=[0,0],d=r&&l.elevation,f=l.elevation?l.elevation.exaggeration():1,m=e.tile.getBucket(this);if(d&&m instanceof eh){const e=m.centroidVertexArray,t=o+1;te.polygon)).flat());const I=d?r:null,[y,E]=function(e,t,n,s,i,l,a,r,o,u,c){return"globe"===e.projection.name?function(e,t,n,s,i,l,a,r,o,u,c){const h=[],p=[],d=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],I=(e,t,n,s)=>{e[0]=t,e[1]=n,e[2]=s,e[3]=1},y=rh();n>0&&(n+=y),s+=y;for(const v of t){const t=[],y=[];for(const h of v){const p=h.x+i.x,v=h.y+i.y,E=e.projection.projectTilePoint(p,v,c),w=e.projection.upVector(c,h.x,h.y);let g=n,T=s;if(a){const e=Eh(p,v,n,s,a,r,o,u);g+=e.base,T+=e.top}0!==n?I(f,E.x+w[0]*d*g,E.y+w[1]*d*g,E.z+w[2]*d*g):I(f,E.x,E.y,E.z),I(m,E.x+w[0]*d*T,E.y+w[1]*d*T,E.z+w[2]*d*T),Fr(f,f,l),Fr(m,m,l),t.push(new Ih(f[0],f[1],f[2])),y.push(new Ih(m[0],m[1],m[2]))}h.push(t),p.push(y)}return[h,p]}(e,t,n,s,i,l,a,r,o,u,c):a?function(e,t,n,s,i,l,a,r,o){const u=[],c=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const u of p){const c=u.x+s.x,p=u.y+s.y,f=Eh(c,p,t,n,l,a,r,o);h[0]=c,h[1]=p,h[2]=f.base,h[3]=1,jr(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Ih(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=f.top,h[3]=1,jr(h,h,i),h[3]=Math.max(h[3],1e-5);const I=new Ih(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),d.push(I)}u.push(e),c.push(d)}return[u,c]}(t,n,s,i,l,a,r,o,u):function(e,t,n,s,i){const l=[],a=[],r=i[8]*t,o=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*n,p=i[9]*n,d=i[10]*n,f=i[11]*n;for(const m of e){const e=[],t=[];for(const n of m){const l=n.x+s.x,a=n.y+s.y,m=i[0]*l+i[4]*a+i[12],I=i[1]*l+i[5]*a+i[13],y=i[2]*l+i[6]*a+i[14],v=i[3]*l+i[7]*a+i[15],E=m+r,w=I+o,g=y+u,T=Math.max(v+c,1e-5),b=m+h,R=I+p,S=y+d,D=Math.max(v+f,1e-5);e.push(new Ih(E/T,w/T,g/T)),t.push(new Ih(b/D,R/D,S/D))}l.push(e),a.push(t)}return[l,a]}(t,n,s,i,l)}(l,s,h,c,u,a,I,p,f,l.center.lat,e.tileID.canonical),w=e.queryGeometry;return function(e,t,n){let s=1/0;du(n,t)&&(s=vh(n,t[0]));for(let i=0;i=3)for(let t=0;t{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class wf{constructor(){this.tasks={},this.taskQueue=[],H(["process"],this),this.invoker=new Ef(this.process),this.nextId=0}add(e,t){const n=this.nextId++,s=function(e){let{type:t,isSymbolTile:n,zoom:s}=e;return s=s||0,"message"===t?0:"maybePrepare"!==t||n?"parseTile"!==t||n?"parseTile"===t&&n?300-s:"maybePrepare"===t&&n?400-s:500:200-s:100-s}(t);if(0===s){q();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:t,priority:s,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){q();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let s=0;s>=1)>1;){const r=t+s>>1,o=n+i>>1;1&e?(s=t,i=n,t=l,n=a):(t=s,n=i,s=l,i=a),l=r,a=o}const r=4*bm;Df[r+0]=t,Df[r+1]=n,Df[r+2]=s,Df[r+3]=i}const Af=new Uint16Array(2178),Cf=new Uint8Array(1089),xf=new Uint16Array(1089);function _f(e){return 0===e?-.03125:32===e?.03125:0}var Of=Hl([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Nf={type:2,extent:ar,loadGeometry:()=>[[new v(0,0),new v(ar+1,0),new v(ar+1,ar+1),new v(0,ar+1),new v(0,0)]]};class Lf{constructor(e,t,n,s,i){this.tileID=e,this.uid=P(),this.uses=0,this.tileSize=t,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state="loading",s&&s.transform&&(this.projection=s.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){s.layers=e,s.stateDependentLayerIds&&(s.stateDependentLayers=s.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)n[t.id]=s}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof rf){if(this.hasSymbolBuckets=!0,!n)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof rf&&t.hasRTLText){this.hasRTLText=!0,wl.isLoading()||wl.isLoaded()||"deferred"!==vl()||El();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new pa}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const n in this.buckets){const t=this.buckets[n];t.uploadPending()&&t.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new vf(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new vf(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new vf(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,s,i,l,a,r){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:s,pixelPosMatrix:a,transform:l,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(e,t){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const s=n.loadVTLayers(),i=t?t.sourceLayer:"",l=s._geojsonTileLayer||s[i];if(!l)return;const a=hi(t&&t.filter),{z:r,x:o,y:u}=this.tileID.canonical,c={z:r,x:o,y:u};for(let h=0;he)n=!1;else if(t)if(this.expirationTime=0;u--){const e=4*u,t=Df[e+0],n=Df[e+1],s=Df[e+2],i=Df[e+3],l=t+s>>1,a=n+i>>1,r=l+a-n,o=a+t-l,c=n*Sf+t,h=i*Sf+s,p=a*Sf+l,d=Math.hypot((Af[2*c+0]+Af[2*h+0])/2-Af[2*p+0],(Af[2*c+1]+Af[2*h+1])/2-Af[2*p+1])>=16;Cf[p]=Cf[p]||(d?1:0),u<1022&&(Cf[p]=Cf[p]||Cf[(n+o>>1)*Sf+(t+r>>1)]||Cf[(i+o>>1)*Sf+(s+r>>1)])}const i=new zl,l=new na;let a=0;function r(e,t){const n=t*Sf+e;return 0===xf[n]&&(i.emplaceBack(Af[2*n+0],Af[2*n+1],e*ar/Rf,t*ar/Rf),xf[n]=++a),xf[n]-1}function o(e,t,n,s,i,a){const u=e+n>>1,c=t+s>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&Cf[c*Sf+u])o(i,a,e,t,u,c),o(n,s,i,a,u,c);else{const o=r(e,t),u=r(n,s),c=r(i,a);l.emplaceBack(o,u,c)}}return o(0,0,Rf,Rf,Rf,0),o(Rf,Rf,0,0,0,Rf),{vertices:i,indices:l}}(this.tileID.canonical,t);s=e.vertices,i=e.indices}else{s=new zl,i=new na;for(const{x:t,y:i}of n)s.emplaceBack(t,i,0,0);const e=vc(s.int16,void 0,4);for(let t=0;t0&&(a=dr(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,s,t,i,a,l),this._makeGlobeTileDebugTextBuffer(e,s,t,i,a,l)}_globePoint(e,t,n,s,i,l,a){let r=Ao(e,t,n);if(l){const i=1<.5?h=-1:c<-.5&&(h=1);let p=(e/ar+n.x)/i+h,d=(t/ar+n.y)/i;p=(p-o)*s._pixelsPerMercatorPixel+o,d=(d-u)*s._pixelsPerMercatorPixel+u;const f=[p*s.worldSize,d*s.worldSize,0];Fr(f,f,l),r=Eo(r,f,a)}return Fr(r,r,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,s,i,l){const a=new Gl,r=new ua,o=new kl,u=(e,u,c,h,p)=>{const d=(c-e)/(p-1),f=(h-u)/(p-1),m=a.length;for(let I=0;Ic*e+t;for(let p=0;pt[a])return null}else{const r=1/s[a];let o=(e[a]-n[a])*r,u=(t[a]-n[a])*r;if(o>u){const e=o;o=u,u=e}if(o>i&&(i=o),ul)return null}return i}function Bf(e,t,n,s,i,l,a,r,o,u,c){const h=s-e,p=i-t,d=l-n,f=a-e,m=r-t,I=o-n,y=c[1]*I-c[2]*m,v=c[2]*f-c[0]*I,E=c[0]*m-c[1]*f,w=h*y+p*v+d*E;if(Math.abs(w)<1e-15)return null;const g=1/w,T=u[0]-e,b=u[1]-t,R=u[2]-n,S=(T*y+b*v+R*E)*g;if(S<0||S>1)return null;const D=b*d-R*p,A=R*h-T*d,C=T*p-b*h,x=(c[0]*D+c[1]*A+c[2]*C)*g;return x<0||S+x>1?null:(f*D+m*A+I*C)*g}function Hf(e,t,n){return(e-t)/(n-t)}function Uf(e,t,n,s,i,l,a,r,o){const u=1<{const l=s?1:0,a=(e+1)*n-l,r=t*n,o=(t+1)*n-l;i[0]=e*n,i[1]=r,i[2]=a,i[3]=o};let a=new Mf(s);const r=[];for(let o=0;o=1;s/=2){const e=n[n.length-1];a=new Mf(s);for(let t=0;t6&&void 0!==arguments[6]?arguments[6]:1;return Ff([e,t,-100],[n,s,this.maximums[0]*a],i,l)}raycast(e,t,n,s,i,l){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;if(!this.nodeCount)return null;const r=this.raycastRoot(e,t,n,s,i,l,a);if(null==r)return null;const o=[],u=[],c=[],h=[],p=[{idx:0,t:r,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:r,t:d,nodex:f,nodey:m,depth:I}=p.pop();if(this.leaves[r]){Uf(f,m,I,e,t,n,s,c,h);const r=1<=e[2])return d}continue}let y=0;for(let p=0;p=o[u[n]]&&(u.splice(n,0,p),t=!0);t||(u[y]=p),y++}}for(let e=0;e3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(n&&"mapbox"!==n&&"terrarium"!==n)return j('"'.concat(n,'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".'));this.stride=t.height;const l=this.dim=t.height-2,a=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.encoding=n||"mapbox",this.borderReady=s,!s){for(let e=0;e2&&void 0!==arguments[2]&&arguments[2]&&(e=A(e,-1,this.dim),t=A(t,-1,this.dim));const n=4*this._idx(e,t);return("terrarium"===this.encoding?Wf:jf)(this.pixels[n],this.pixels[n+1],this.pixels[n+2])}static getUnpackVector(e){return Vf[e]}get unpackVector(){return Vf[this.encoding]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const n=[0,0,0,0],s=Yf.getUnpackVector(t);let i=Math.floor((e+s[3])/s[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new Uu({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=t*this.dim,i=t*this.dim+this.dim,l=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:s=i-1;break;case 1:i=s+1}switch(n){case-1:l=a-1;break;case 1:a=l+1}const r=-t*this.dim,o=-n*this.dim;for(let u=l;u{this.remove(e,i)}),n)),this.data[s].push(i),this.order.push(s),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,s=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][s];return this.data[n].splice(s,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const n in this.data)for(const s of this.data[n])e(s.value)||t.push(s);for(const n of t)this.remove(n.value.tileID,n)}}class Xf{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Xf.ReadOnly=!1,Xf.ReadWrite=!0,Xf.disabled=new Xf(519,Xf.ReadOnly,[0,1]);const Zf=7680;class Kf{constructor(e,t,n,s,i,l){this.test=e,this.ref=t,this.mask=n,this.fail=s,this.depthFail=i,this.pass=l}}Kf.disabled=new Kf({func:519,mask:0},0,0,Zf,Zf,Zf);class Qf{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}Qf.Replace=[1,0],Qf.disabled=new Qf(Qf.Replace,Ot.transparent,[!1,!1,!1,!1]),Qf.unblended=new Qf(Qf.Replace,Ot.transparent,[!0,!0,!0,!0]),Qf.alphaBlended=new Qf([1,771],Ot.transparent,[!0,!0,!0,!0]);const Jf=1029,$f=2305;class em{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}em.disabled=new em(!1,Jf,$f),em.backCCW=new em(!0,Jf,$f),em.backCW=new em(!0,Jf,2304),em.frontCW=new em(!0,1028,2304),em.frontCCW=new em(!0,1028,$f);class tm extends $e{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new qf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Pf,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return O(this._tiles).map((e=>e.tileID)).sort(nm).map((e=>e.key))}getRenderableIds(e){const t=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&t.push(this._tiles[n]);return e?t.sort(((e,t)=>{const n=e.tileID,s=t.tileID,i=new v(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),l=new v(s.canonical.x,s.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-s.overscaledZ||l.y-i.y||l.x-i.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(nm).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(e,t,n,s){if(s)if(e.state="errored",404!==s.status)this._source.fire(new Je(s,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=Xe.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Qe("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let s=0;s1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,s),e.neighboringTiles&&e.neighboringTiles[l]&&(e.neighboringTiles[l].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,s){for(const i in this._tiles){let l=this._tiles[i];if(s[i]||!l.hasData()||l.tileID.overscaledZ<=t||l.tileID.overscaledZ>n)continue;let a=l.tileID;for(;l&&l.tileID.overscaledZ>t+1;){const e=l.tileID.scaledTo(l.tileID.overscaledZ-1);l=this._tiles[e.key],l&&l.hasData()&&(a=e)}let r=a;for(;r.overscaledZ>t;)if(r=r.scaledTo(r.overscaledZ-1),e[r.key]){s[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),s=this._getLoadedTile(t);if(s)return s}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const n=Math.ceil(e.width/t)+1,s=Math.ceil(e.height/t)+1,i=Math.floor(n*s*5),l="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const s=this._tiles[n];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),e[s.tileID.key]=s}this._tiles=e;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(e,t,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let s;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new fh(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(s=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter((e=>this._source.hasTile(e))))):s=[];const i=this._updateRetainedTiles(s);if(sm(this._source.type)&&0!==s.length){const e={},t={},n=Object.keys(i);for(const s of n){const n=i[s],l=this._tiles[s];if(!l||l.fadeEndTime&&l.fadeEndTime<=Xe.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-tm.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[s]=n}const l=s[s.length-1].overscaledZ;for(const s in this._tiles){const e=this._tiles[s];if(i[s]||!e.hasData())continue;let n=e.tileID;for(;n.overscaledZ>l;){n=n.scaledTo(n.overscaledZ-1);const l=this._tiles[n.key];if(l&&l.hasData()&&t[n.key]){i[s]=e.tileID;break}}}for(const s in e)i[s]||(this._coveredTiles[s]=!0,i[s]=e[s])}for(const a in i)this._tiles[a].clearFadeHold();const l=function(e,t){const n=[];for(const s in e)s in t||n.push(s);return n}(this._tiles,i);for(const a of l){const e=this._tiles[a];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+a)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const n={},s=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),i=e[0].overscaledZ,l=Math.max(i-tm.maxOverzooming,this._source.minzoom),a=Math.max(i+tm.maxUnderzooming,this._source.minzoom),r={};for(const o of e){const e=this._addTile(o);t[o.key]=o,e.hasData()||s=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let s=e.wasRequested();for(let i=o.overscaledZ-1;i>=l;--i){const l=o.scaledTo(i);if(n[l.key])break;if(n[l.key]=!0,e=this.getTile(l),!e&&s&&(e=this._addTile(l)),e&&(t[l.key]=l,s=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,s=this._tiles[e].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){n=this._loadedParentTiles[s.key];break}t.push(s.key);const e=s.scaledTo(s.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;s=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(e){let t=this._tiles[e.key];if(t)return t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const n=Boolean(t);if(!n){const n=this.map?this.map.painter:null;t=new Lf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,n||this._source.fire(new Qe("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),n))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,n){const s=[],i=this.transform;if(!i)return s;const l="globe"===i.projection.name,a=jo(i.center.lng);for(const r in this._tiles){const o=this._tiles[r];if(n&&o.clearQueryDebugViz(),o.holdingForFade())continue;let u;if(l){const e=o.tileID.canonical;if(0===e.z){const t=[Math.abs(A(a,...im(e,-1))-a),Math.abs(A(a,...im(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(A(a,...im(e,-1))-a),Math.abs(A(a,...im(e,0))-a),Math.abs(A(a,...im(e,1))-a)];u=[t.indexOf(Math.min(...t))-1]}}else u=[0];for(const n of u){const l=e.containsTile(o,i,t,n);l&&s.push(l)}}return s}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));for(const n of t)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(sm(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=Xe.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const s=this._tiles[e];s&&s.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter((n=>!n.hasDependency(e,t)))}_preloadTiles(e,t){if(!this._sourceLoaded){const n=()=>{this._sourceLoaded&&(this._source.off("data",n),this._preloadTiles(e,t))};return void this._source.on("data",n)}const n=new Map,s=Array.isArray(e)?e:[e],i=this.map.painter.terrain,l=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const a of s){const e=a.coveringTiles({tileSize:l,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)n.set(t.key,t);this.usedForTerrain&&a.updateElevation(!1)}_(Array.from(n.values()),((e,t)=>{const n=new Lf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,(e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)}))}),t)}}function nm(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||s-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function sm(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function im(e,t){const n=1<5&&void 0!==arguments[5]?arguments[5]:0;const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,i,l);const r=this.grid;for(let o=0;o=0&&n[3]>=0&&r.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yc(new Ip(this.rawTileData)).layers,this.sourceLayerCoder=new gf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,n,s){var i=this;this.loadVTLayers();const l=e.params||{},a=hi(l.filter),r=e.tileResult,o=e.transform,u=r.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,((e,t,n,s)=>gu(r.bufferedTilespaceGeometry,e,t,n,s)));c.sort(om);let h=null;o.elevation&&c.length>0&&(h=lm.create(o.elevation,this.tileID));const p={};let d;for(let f=0;f3&&void 0!==arguments[3]?arguments[3]:0;return m||(m=au(t,i.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(r,t,s,m,i.z,e.transform,e.pixelPosMatrix,h,l)}))}return p}loadMatchingFeature(e,t,n,s,i,l,a,r,o){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[c];if(s&&!function(e,t){for(let n=0;n=0)return!0;return!1}(s,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(u);if(n.needGeometry){const e=ru(m,!0);if(!n.filter(new gl(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new gl(this.tileID.overscaledZ),m))return;const I=this.getId(m,f);for(let y=0;y{const a=t instanceof xl?t.get(l):null;return a&&a.evaluate?a.evaluate(n,s,i):a}))}function om(e,t){return t-e}Zi(am,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class um{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new Hu({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=F(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const s=[];let i=e.length%2==1?-e[e.length-1]*n:0,l=e[0]*n,a=!0;s.push({left:i,right:l,isDash:a,zeroLength:0===e[0]});let r=e[0];for(let o=1;o1&&(a=e[++l]);const o=Math.abs(r-a.left),u=Math.abs(r-a.right),c=Math.min(o,u);let h;const p=i/n*(s+1);if(a.isDash){const e=s-Math.abs(p);h=Math.sqrt(c*c+e*e)}else h=s-Math.sqrt(c*c+p*p);this.image.data[t+r]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let r=e.length-1;r>=0;--r){const t=e[r],n=e[r+1];t.zeroLength?e.splice(r,1):n&&n.isDash===t.isDash&&(n.left=t.left,e.splice(r,1))}const n=e[0],s=e[e.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const i=this.width*this.nextRow;let l=0,a=e[l];for(let r=0;r1&&(a=e[++l]);const n=Math.abs(r-a.left),s=Math.abs(r-a.right),o=Math.min(n,s);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?o:-o)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const s="round"===t,i=s?7:0,l=2*i+1;if(this.nextRow+l>this.height)return j("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let u=0;u=t.maxzoom||"none"!==t.visibility&&(dm(e,this.zoom,n),(r[t.id]=t.createBucket({index:a.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(h,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(e.map((e=>e.id))))}}let h,p,d,f;o.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},I=()=>{if(h)return i(h);if(p&&d&&f){const e=new hm(p),t=new Sp(d,f);for(const s in r){const i=r[s];i instanceof rf?(dm(i.layers,this.zoom,n),Ed(i,p,e.positions,d,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof Dh||i instanceof Ac||i instanceof eh)&&(dm(i.layers,this.zoom,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",i(null,{buckets:O(r).filter((e=>!e.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:o,imageAtlas:t,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?e.positions:null})}},y=G(u.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(y).length?s.send("getGlyphs",{uid:this.uid,stacks:y},((e,t)=>{h||(h=e,p=t,I())}),void 0,!1,m):p={};const v=Object.keys(u.iconDependencies);v.length?s.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"icons"},((e,t)=>{h||(h=e,d=t,I())}),void 0,!1,m):d={};const E=Object.keys(u.patternDependencies);E.length?s.send("getImages",{icons:E,source:this.source,tileID:this.tileID,type:"patterns"},((e,t)=>{h||(h=e,f=t,I())}),void 0,!1,m):f={},I()}}function dm(e,t,n){const s=new gl(t);for(const i of e)i.recalculate(s,n)}class fm{constructor(e){this.entries={},this.scheduler=e}request(e,t,n,s){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,n]=i.result;return this.scheduler?this.scheduler.add((()=>{s(e,n)}),t):s(e,n),()=>{}}return i.callbacks.push(s),i.cancel||(i.cancel=n(((n,s)=>{i.result=[n,s];for(const e of i.callbacks)this.scheduler?this.scheduler.add((()=>{e(n,s)}),t):e(n,s);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{i.result||(i.callbacks=i.callbacks.filter((e=>e!==s)),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}}function mm(e,t,n){const s=JSON.stringify(e.request);return e.data&&(this.deduped.entries[s]={result:[null,e.data]}),this.deduped.request(s,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const s=pe(e.request,((e,s,i,l)=>{e?t(e):s&&t(null,{vectorTile:n?void 0:new Yc(new Ip(s)),rawData:s,cacheControl:i,expires:l})}));return()=>{s.cancel(),t()}}),t)}const Im=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ym{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,n]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(1!==s)throw new Error("Got v".concat(s," data when expected v1."));const i=Im[15&n];if(!i)throw new Error("Unrecognized array type.");const[l]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new ym(a,l,i,e)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float64Array,s=arguments.length>3?arguments[3]:void 0;if(isNaN(e)||e<0)throw new Error("Unpexpected numItems value: ".concat(e,"."));this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=Im.indexOf(this.ArrayType),l=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,r=(8-a%8)%8;if(i<0)throw new Error("Unexpected typed array class: ".concat(n,"."));s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+r,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+l+a+r),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+r,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error("Added ".concat(e," items when expected ").concat(this.numItems,"."));return vm(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:l,nodeSize:a}=this,r=[0,i.length-1,0],o=[];for(;r.length;){const u=r.pop()||0,c=r.pop()||0,h=r.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const r=l[2*a],u=l[2*a+1];r>=e&&r<=n&&u>=t&&u<=s&&o.push(i[a])}continue}const p=h+c>>1,d=l[2*p],f=l[2*p+1];d>=e&&d<=n&&f>=t&&f<=s&&o.push(i[p]),(0===u?e<=d:t<=f)&&(r.push(h),r.push(p-1),r.push(1-u)),(0===u?n>=d:s>=f)&&(r.push(p+1),r.push(c),r.push(1-u))}return o}within(e,t,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:l}=this,a=[0,s.length-1,0],r=[],o=n*n;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=l){for(let n=h;n<=c;n++)Tm(i[2*n],i[2*n+1],e,t)<=o&&r.push(s[n]);continue}const p=h+c>>1,d=i[2*p],f=i[2*p+1];Tm(d,f,e,t)<=o&&r.push(s[p]),(0===u?e-n<=d:t-n<=f)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?e+n>=d:t+n>=f)&&(a.push(p+1),a.push(c),a.push(1-u))}return r}}function vm(e,t,n,s,i,l){if(i-s<=n)return;const a=s+i>>1;Em(e,t,a,s,i,l),vm(e,t,n,s,a-1,1-l),vm(e,t,n,a+1,i,1-l)}function Em(e,t,n,s,i,l){for(;i>s;){if(i-s>600){const a=i-s+1,r=n-s+1,o=Math.log(a),u=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*u*(a-u)/a)*(r-a/2<0?-1:1);Em(e,t,n,Math.max(s,Math.floor(n-r*u/a+c)),Math.min(i,Math.floor(n+(a-r)*u/a+c)),l)}const a=t[2*n+l];let r=s,o=i;for(wm(e,t,s,n),t[2*i+l]>a&&wm(e,t,s,i);ra;)o--}t[2*s+l]===a?wm(e,t,s,o):(o++,wm(e,t,o,i)),o<=n&&(s=o+1),n<=o&&(i=o-1)}}function wm(e,t,n,s){gm(e,n,s),gm(t,2*n,2*s),gm(t,2*n+1,2*s+1)}function gm(e,t,n){const s=e[t];e[t]=e[n],e[n]=s}function Tm(e,t,n,s){const i=e-n,l=t-s;return i*i+l*l}e.ARRAY_TYPE=ur,e.AUTH_ERR_MSG=ve,e.Aabb=so,e.Actor=class{constructor(e,n,s){this.target=e,this.parent=n,this.mapId=s,this.callbacks={},this.cancelCallbacks={},H(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=q()?e:t,this.scheduler=new wf}send(e,t,n,s){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5?arguments[5]:void 0;const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=l,this.callbacks[a]=n);const r=K(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:s,mustQueue:i,sourceMapId:this.mapId,data:Ji(t,r)},r),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:s,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||q()){const e=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add((()=>this.processTask(n,t)),e&&e.metadata||{type:"message"})}else this.processTask(n,t)}processTask(e,t){if(""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n($i(t.error)):n(null,$i(t.data)))}else{const n=K(this.globalScope)?void 0:[],s=t.hasCallback?(t,s)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ji(t):null,data:Ji(s,n)},n)}:e=>{},i=$i(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,s);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source)[e[1]](i,s)}else s(new Error("Could not find function ".concat(t.type)))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=ph,e.Color=Ot,e.ColorMode=Qf,e.CullFaceMode=em,e.DEMData=Yf,e.DataConstantProperty=_l,e.DedupedRequest=fm,e.DepthMode=Xf,e.EXTENT=ar,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const n=t.getSource().maxzoom,s=1<1&&void 0!==arguments[1]?arguments[1]:0;return this.getAtPoint(e,t)||0}getAtPoint(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this.isUsingMockSource())return null;null==t&&(t=null);const s=this._source();if(!s)return t;if(e.y<0||e.y>1)return t;const i=s.getSource().maxzoom,l=1<{const l=this.getAtTileOffset(e,i.x,i.y),a=s.upVector(e.canonical,i.x,i.y);return Or(a,a,l*s.upVectorScale(e.canonical,t,n).metersToTile),a}}getForTilePoints(e,t,n,s){if(this.isUsingMockSource())return!1;const i=lm.create(this,e,s);return!!i&&(t.forEach((e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,s=t.tileID,i=1<{let s=e===l-1?e-2:0===e?e:e-1;return s+=n?24575:0,[s,t]};for(let u=0;uthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Ee(e))return e;const n=Se(e);return n.path="/styles/v1".concat(n.path),this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Ee(e))return e;const n=Se(e);return n.path="/fonts/v1".concat(n.path),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,s){if(!Ee(e))return e;const i=Se(e);return i.path="/v4/".concat(i.authority,".json"),i.params.push("secure"),n&&i.params.push("language=".concat(n)),s&&i.params.push("worldview=".concat(s)),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,s){const i=Se(e);return Ee(e)?(i.path="/styles/v1".concat(i.path,"/sprite").concat(t).concat(n),this._makeAPIURL(i,this._customAccessToken||s)):(i.path+="".concat(t).concat(n),De(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Ee(e))return e;const s=Se(e);s.path=s.path.replace(/(\.(png|jpg)\d*)(?=$)/,"".concat(t||n&&"raster"!==s.authority&&512===n?"@2x":"").concat(l.supported?".webp":"$1")),"raster"===s.authority?s.path="/".concat(i.RASTER_URL_PREFIX).concat(s.path):(s.path=s.path.replace(/^.+\/v4\//,"/"),s.path="/".concat(i.TILE_URL_VERSION).concat(s.path));const a=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(s.params)||i.ACCESS_TOKEN;return i.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&s.params.push("sku=".concat(this._skuToken)),this._makeAPIURL(s,a)}canonicalizeTileURL(e,t){const n=Se(e);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let s="mapbox://";n.path.match(/^\/raster\/v1\//)?s+="raster/".concat(n.path.replace("/".concat(i.RASTER_URL_PREFIX,"/"),"")):s+="tiles/".concat(n.path.replace("/".concat(i.TILE_URL_VERSION,"/"),""));let l=n.params;return t&&(l=l.filter((e=>!e.match(/^access_token=/)))),l.length&&(s+="?".concat(l.join("&"))),s}canonicalizeTileset(e,t){const n=!!t&&Ee(t),s=[];for(const i of e.tiles||[])we(i)?s.push(this.canonicalizeTileURL(i,n)):s.push(i);return s}_makeAPIURL(e,t){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",s=Se(i.API_URL);if(e.protocol=s.protocol,e.authority=s.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==s.path&&(e.path="".concat(s.path).concat(e.path)),!i.REQUIRE_ACCESS_TOKEN)return De(e);if(t=t||i.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. ".concat(n));if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ".concat(n))}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push("access_token=".concat(t||"")),De(e)}},e.ResourceType=oe,e.SegmentVector=lr,e.SourceCache=tm,e.StencilMode=Kf,e.StructArrayLayout1ui2=ua,e.StructArrayLayout2f1f2i16=$l,e.StructArrayLayout2i4=Gl,e.StructArrayLayout2ui4=oa,e.StructArrayLayout3f12=ta,e.StructArrayLayout3ui6=na,e.StructArrayLayout4i8=zl,e.StructArrayLayout5f20=aa,e.Texture=vf,e.Tile=Lf,e.Transitionable=Rl,e.Uniform1f=Fa,e.Uniform1i=class extends Ma{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},e.Uniform2f=class extends Ma{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},e.Uniform3f=class extends Ma{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},e.Uniform4f=Ba,e.UniformColor=Ha,e.UniformMatrix2f=class extends Ma{constructor(e){super(e),this.current=ka}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let s=0;s<4;s++)if(n[s]!==this.current[s]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},e.UniformMatrix3f=class extends Ma{constructor(e){super(e),this.current=Ga}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let s=0;s<9;s++)if(n[s]!==this.current[s]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.UniformMatrix4f=class extends Ma{constructor(e){super(e),this.current=Ua}set(e,t,n){if(this.fetchUniformLocation(e,t)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},e.UnwrappedTileID=dh,e.ValidationError=ni,e.VectorTileFeature=qc,e.VectorTileWorkerSource=class extends $e{constructor(e,t,n,s,i){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||mm,this.loading={},this.loaded={},this.deduped=new fm(e.scheduler),this.isSpriteLoaded=s,this.scheduler=e.scheduler}loadTile(e,t){const n=e.uid,s=e&&e.request,i=s&&s.collectResourceTiming,l=this.loading[n]=new pm(e);l.abort=this.loadVectorData(e,((a,r)=>{const o=!this.loading[n];if(delete this.loading[n],o||a||!r)return l.status="done",o||(this.loaded[n]=l),t(a);const u=r.rawData,c={};r.expires&&(c.expires=r.expires),r.cacheControl&&(c.cacheControl=r.cacheControl),l.vectorTile=r.vectorTile||new Yc(new Ip(u));const h=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,n)=>{if(e||!n)return t(e);const l={};if(i){const e=Ve(s);e.length>0&&(l.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,N({rawTileData:u.slice(0)},n,c,l))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(e,t){const n=this.loaded,s=e.uid,i=this;if(n&&n[s]){const l=n[s];l.showCollisionBoxes=e.showCollisionBoxes,l.enableTerrain=!!e.enableTerrain,l.projection=e.projection,l.tileTransform=_d(e.tileID.canonical,e.projection);const a=(e,n)=>{const s=l.reloadCallback;s&&(delete l.reloadCallback,l.parse(l.vectorTile,i.layerIndex,this.availableImages,i.actor,s)),t(e,n)};"parsing"===l.status?l.reloadCallback=a:"done"===l.status&&(l.vectorTile?l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(e,t){const n=e.uid,s=this.loading[n];s&&(s.abort&&s.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,s=e.uid;n&&n[s]&&delete n[s],t()}},e.WritingMode=Dp,e.ZoomDependentExpression=Js,e.add=Dr,e.addDynamicAttributes=nf,e.adjoint=function(e,t){var n=t[0],s=t[1],i=t[2],l=t[3],a=t[4],r=t[5],o=t[6],u=t[7],c=t[8];return e[0]=a*c-r*u,e[1]=i*u-s*c,e[2]=s*r-i*a,e[3]=r*o-l*c,e[4]=n*c-i*o,e[5]=i*l-n*r,e[6]=l*u-a*o,e[7]=s*o-n*u,e[8]=n*a-s*l,e},e.asyncAll=_,e.bezier=S,e.bindAll=H,e.boundsAttributes=Of,e.bufferConvexPolygon=function(e,t){const n=[];for(let s=0;sse&&(e.getActor().send("enforceCacheSizeLimit",ne),re=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:n,y:s}=e.point,i=No(n,s,e.worldSize/e._pixelsPerMercatorPixel,0,0);return fr(i,i,Oo(vo(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:n}=e.point,{lng:s,lat:i}=e._center;return No(t,n,e.worldSize,s,i)},e.calculateGlobeMercatorMatrix=function(e){const t=e.pixelsPerMeter,n=t/Yo(1,e.center.lat),s=pr(new Float64Array(16));return mr(s,s,[e.point.x,e.point.y,0]),Ir(s,s,[n,n,t]),Float32Array.from(s)},e.circumferenceAtLatitude=Vo,e.clamp=A,e.clearTileCache=function(e){if(!ie())return;const n=t.caches.delete($);e&&n.catch(e).then((()=>e()))},e.clipLine=Kp,e.clone=function(e){var t=new ur(16);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},e.clone$1=z,e.collisionCircleLayout=Bh,e.config=i,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new ur(16);return ur!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=cr,e.createExpression=Ks,e.createLayout=Hl,e.createStyleLayer=function(e){return"custom"===e.type?new ff(e):new yf[e.type](e)},e.cross=Mr,e.degToRad=g,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},e.dot=Pr,e.earthRadius=Uo,e.ease=D,e.easeCubicInOut=R,e.ecefToLatLng=function(e){let[t,n,s]=e;const i=Math.hypot(t,n,s),l=Math.atan2(t,s),a=.5*Math.PI-Math.acos(-n/i);return new zo(T(l),T(a))},e.emitValidationErrors=Vi,e.endsWith=U,e.enforceCacheSizeLimit=function(e){le(),ee&&ee.then((t=>{t.keys().then((n=>{for(let s=0;sl&&(s+=(e[i]-l)*(e[i]-l)),t[i]0){const e=180/s;hr(d,d,[e/u+1,0,0,0,e/c+1,0,-.5*e/h,.5*e/p,1])}return d[2]=o,d[5]=e.x,d[8]=e.y,d},e.getImage=ye,e.getJSON=function(e,t){return he(N(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=Ko-5;e=A(e,-t,t)/t*90;const n=Math.pow(Math.abs(Math.sin(g(e))),3);return Math.round(n*(uo.length-1))},e.getMapSessionAPI=Be,e.getPerformanceMeasurement=Ve,e.getProjection=Qd,e.getRTLTextPluginStatus=vl,e.getReferrer=ce,e.getTilePoint=function(e,t){let{x:n,y:s}=t;return new v(((n-(arguments.length>2&&void 0!==arguments[2]?arguments[2]:0))*e.scale-e.x)*ar,(s*e.scale-e.y)*ar)},e.getTileVec3=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Sr(((t.x-n)*e.scale-e.x)*ar,(t.y*e.scale-e.y)*ar,Zo(t.z,t.y))},e.getVideo=function(e,n){const s=t.document.createElement("video");s.muted=!0,s.onloadstart=function(){n(null,s)};for(let i=0;i{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],n=pr(new Float64Array(16));return fr(n,e.pixelMatrix,e.globeMatrix),Fr(t,t,n),new v(t[0],t[1])},e.globeDenormalizeECEF=Oo,e.globeECEFOrigin=function(e,t){const n=[0,0,0];return Fr(n,n,_o(vo(t.canonical))),Fr(n,n,e),n},e.globeMetersToEcef=fo,e.globeNormalizeECEF=_o,e.globePixelsToTileUnits=function(e,t){return ar/(512*Math.pow(2,e))*Co(vo(t))},e.globePoleMatrixForTile=function(e,t,n){const s=pr(new Float64Array(16)),i=(t/(1<0;return 0===s&&!i&&!a&&l},e.identity=pr,e.identity$1=Yr,e.invert=dr,e.isFullscreen=function(){return!!t.document.fullscreenElement||!!t.document.webkitFullscreenElement},e.isLngLatBehindGlobe=Mo,e.isMapAuthenticated=function(e){return He.has(e)},e.isMapboxURL=Ee,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!K(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=Xo,e.latLngToECEF=Do,e.len=kr,e.length=Rr,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.lngFromMercatorX=qo,e.loadVectorTile=mm,e.makeRequest=he,e.mapValue=function(e,t,n,s,i){return A((e-t)/(n-t)*(i-s)+s,s,i)},e.mercatorScale=Qo,e.mercatorXfromLng=jo,e.mercatorYfromLat=Wo,e.mercatorZfromAltitude=Yo,e.mul=gr,e.mul$1=Gr,e.multiply=fr,e.multiply$1=hr,e.multiply$2=Cr,e.nextPowerOfTwo=F,e.normalize=Lr,e.normalize$1=Zr,e.normalize$2=Vr,e.number=Nn,e.ortho=function(e,t,n,s,i,l,a){var r=1/(t-n),o=1/(s-i),u=1/(l-a);return e[0]=-2*r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*r,e[13]=(i+s)*o,e[14]=(a+l)*u,e[15]=1,e},e.pbf=Xh,e.perspective=function(e,t,n,s,i){var l,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+s)*(l=1/(s-i)),e[14]=2*i*s*l):(e[10]=-1,e[14]=-2*s),e},e.pick=function(e,t){const n={};for(let s=0;s0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Mo(e,new zo(e.center.lat,90)),s[0]>0&&s[0]<=e.width&&s[1]>0&&s[1]<=e.height&&!Mo(e,new zo(e.center.lat,-90))]},e.polygonContainsPoint=wu,e.polygonIntersectsBox=gu,e.polygonIntersectsPolygon=hu,e.polygonizeBounds=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const i=new v(n,n),l=e.sub(i),a=t.add(i),r=[l,new v(a.x,l.y),a,new v(l.x,a.y)];return s&&r.push(l.clone()),r},e.posAttributes=$r,e.postMapLoadEvent=Le,e.postPerformanceEvent=Me,e.postTurnstileEvent=Oe,e.potpack=Tp,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=T,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:dl,pluginURL:fl}),yl.on("pluginStateChange",e),e},e.removeAuthState=function(e){He.delete(e)},e.renderColorRamp=ku,e.resample=eu,e.rotateX=yr,e.rotateX$1=qr,e.rotateY=vr,e.rotateY$1=Xr,e.rotateZ=function(e,t,n){var s=Math.sin(n),i=Math.cos(n),l=t[0],a=t[1],r=t[2],o=t[3],u=t[4],c=t[5],h=t[6],p=t[7];return t!==e&&(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[0]=l*i+u*s,e[1]=a*i+c*s,e[2]=r*i+h*s,e[3]=o*i+p*s,e[4]=u*i-l*s,e[5]=c*i-a*s,e[6]=h*i-r*s,e[7]=p*i-o*s,e},e.rotateZ$1=function(e,t,n){n*=.5;var s=t[0],i=t[1],l=t[2],a=t[3],r=Math.sin(n),o=Math.cos(n);return e[0]=s*o+i*r,e[1]=i*o-s*r,e[2]=l*o+a*r,e[3]=a*o-l*r,e},e.scale=Ir,e.scale$1=zr,e.scale$2=Or,e.scaleAndAdd=Nr,e.set=function(e,t,n,s){return e[0]=t,e[1]=n,e[2]=s,e},e.setCacheLimits=function(e,t){ne=e,se=t},e.setColumn=function(e,t,n){e[4*t+0]=n[0],e[4*t+1]=n[1],e[4*t+2]=n[2],e[4*t+3]=n[3]},e.setRTLTextPlugin=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(dl===ul||dl===cl||dl===hl)throw new Error("setRTLTextPlugin cannot be called multiple times.");fl=Xe.resolveURL(e),dl=ul,pl=t,Il(),n||El()},e.smoothstep=C,e.spec=et,e.squaredLength=function(e){var t=e[0],n=e[1],s=e[2];return t*t+n*n+s*s},e.storeAuthState=function(e,t){t?He.add(e):He.delete(e)},e.sub=Ur,e.subtract=Ar,e.symbolSize=Vh,e.tileAABB=function(e,t,n,s,i,l,a,r,o){if("globe"===o.name)return To(e,t,new ph(n,s,i));const u=_d({z:n,x:s,y:i},o);return new so([(l+u.x/u.scale)*t,t*(u.y/u.scale),a],[(l+u.x2/u.scale)*t,t*(u.y2/u.scale),r])},e.tileCornersToBounds=bo,e.tileTransform=_d,e.transformMat3=function(e,t,n){var s=t[0],i=t[1],l=t[2];return e[0]=s*n[0]+i*n[3]+l*n[6],e[1]=s*n[1]+i*n[4]+l*n[7],e[2]=s*n[2]+i*n[5]+l*n[8],e},e.transformMat4=Fr,e.transformMat4$1=jr,e.transformQuat=Br,e.transitionTileAABBinECEF=wo,e.translate=mr,e.transpose=function(e,t){if(e===t){var n=t[1],s=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=s,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},e.triggerPluginCompletionEvent=ml,e.uniqueId=P,e.updateGlobeVertexNormal=function(e,t,n,s,i){const l=5*t+2;e.float32[l+0]=n,e.float32[l+1]=s,e.float32[l+2]=i},e.validateCustomStyleLayer=function(e){const t=[],n=e.id;return void 0===n&&t.push({message:"layers.".concat(n,': missing required property "id"')}),void 0===e.render&&t.push({message:"layers.".concat(n,': missing required method "render"')}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:"layers.".concat(n,': property "renderingMode" must be either "2d" or "3d"')}),t},e.validateFilter=e=>zi(bi(e)),e.validateFog=e=>zi(Mi(e)),e.validateLayer=e=>zi(Ci(e)),e.validateLight=e=>zi(Li(e)),e.validateSource=e=>zi(Oi(e)),e.validateStyle=Ui,e.validateTerrain=e=>zi(Pi(e)),e.values=O,e.vectorTile=Pc,e.version=n,e.warnOnce=j,e.window=t,e.wrap=x})),s(["./shared"],(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(const s of e)n+="".concat(t(s),",");return"".concat(n,"]")}let n="{";for(const s of Object.keys(e).sort())n+="".concat(s,":").concat(t(e[s]),",");return"".concat(n,"}")}function n(n){let s="";for(const i of e.refProperties)s+="/".concat(t(n[i]));return s}class s{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,s){for(const n of t)this._layerConfigs[n.id]=n,(this._layers[n.id]=e.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const s={};for(let l=0;lthis._layers[e.id])),n=t[0];if("none"===n.visibility)continue;const s=n.source||"";let i=this.familiesBySource[s];i||(i=this.familiesBySource[s]={});const l=n.sourceLayer||"_geojsonTileLayer";let a=i[l];a||(a=i[l]=[]),a.push(t)}}}class i{loadTile(t,n){const{uid:s,encoding:i,rawImageData:l,padding:a,buildQuadTree:r}=t,o=e.window.ImageBitmap&&l instanceof e.window.ImageBitmap?this.getImageData(l,a):l;n(null,new e.DEMData(s,o,i,a<1,r))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}function l(e,t){if(0!==e.length){a(e[0],t);for(var n=1;n=Math.abs(r)?n-o+r:r-o+n,n=o}n+s>=0!=!!t&&e.reverse()}var r=e.getDefaultExportFromCjs((function e(t,n){var s,i=t&&t.type;if("FeatureCollection"===i)for(s=0;s>31}function b(e,t){for(var n=e.loadGeometry(),s=e.type,i=0,l=0,a=n.length,r=0;re},A=Math.fround||(C=new Float32Array(1),e=>(C[0]=+e,C[0]));var C;const x=3,_=5,O=6;class N{constructor(e){this.options=Object.assign(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:n,maxZoom:s}=this.options;t&&console.time("total time");const i="prepare ".concat(e.length," points");t&&console.time(i),this.points=e;const l=[];for(let r=0;r=n;r--){const e=+Date.now();a=this.trees[r]=this._createTree(this._cluster(a,r)),t&&console.log("z%d: %d clusters in %dms",r,a.numItems,+Date.now()-e)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){const e=this.getClusters([n,s,180,l],t),a=this.getClusters([-180,s,i,l],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],r=a.range(M(n),F(l),M(i),F(s)),o=a.data,u=[];for(const c of r){const e=this.stride*c;u.push(o[e+_]>1?L(o,e,this.clusterProps):this.points[o[e+x]])}return u}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),s="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(s);const l=i.data;if(t*this.stride>=l.length)throw new Error(s);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),r=i.within(l[t*this.stride],l[t*this.stride+1],a),o=[];for(const u of r){const t=u*this.stride;l[t+4]===e&&o.push(l[t+_]>1?L(l,t,this.clusterProps):this.points[l[t+x]])}if(0===o.length)throw new Error(s);return o}getLeaves(e,t,n){const s=[];return this._appendLeaves(s,e,t=t||10,n=n||0,0),s}getTile(e,t,n){const s=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:l,radius:a}=this.options,r=a/l,o=(n-r)/i,u=(n+1+r)/i,c={features:[]};return this._addTileFeatures(s.range((t-r)/i,o,(t+1+r)/i,u),s.data,t,n,i,c),0===t&&this._addTileFeatures(s.range(1-r/i,o,1,u),s.data,i,n,i,c),t===i-1&&this._addTileFeatures(s.range(0,o,r/i,u),s.data,-1,n,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,s,i){const l=this.getChildren(t);for(const a of l){const t=a.properties;if(t&&t.cluster?i+t.point_count<=s?i+=t.point_count:i=this._appendLeaves(e,t.cluster_id,n,s,i):i1;let o,u,c;if(r)o=P(t,e,this.clusterProps),u=t[e],c=t[e+1];else{const n=this.points[t[e+x]];o=n.properties;const[s,i]=n.geometry.coordinates;u=M(s),c=F(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-n)),Math.round(this.options.extent*(c*i-s))]],tags:o};let p;p=r||this.options.generateId?t[e+x]:this.points[t[e+x]].id,void 0!==p&&(h.id=p),l.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:n,extent:s,reduce:i,minPoints:l}=this.options,a=n/(s*Math.pow(2,t)),r=e.data,o=[],u=this.stride;for(let c=0;ct&&(d+=r[n+_])}if(d>p&&d>=l){let e,l=n*p,a=s*p,f=-1;const m=((c/u|0)<<5)+(t+1)+this.points.length;for(const n of h){const s=n*u;if(r[s+2]<=t)continue;r[s+2]=t;const o=r[s+_];l+=r[s]*o,a+=r[s+1]*o,r[s+4]=m,i&&(e||(e=this._map(r,c,!0),f=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(r,s)))}r[c+4]=m,o.push(l/d,a/d,1/0,m,-1,d),i&&o.push(f)}else{for(let e=0;e1)for(const e of h){const n=e*u;if(!(r[n+2]<=t)){r[n+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+_]>1){const s=this.clusterProps[e[t+O]];return n?Object.assign({},s):s}const s=this.points[e[t+x]].properties,i=this.options.map(s);return n&&i===s?Object.assign({},i):i}}function L(e,t,n){return{type:"Feature",id:e[t+x],properties:P(e,t,n),geometry:{type:"Point",coordinates:[(s=e[t],360*(s-.5)),B(e[t+1])]}};var s}function P(e,t,n){const s=e[t+_],i=s>=1e4?"".concat(Math.round(s/1e3),"k"):s>=1e3?Math.round(s/100)/10+"k":s,l=e[t+O],a=-1===l?{}:Object.assign({},n[l]);return Object.assign(a,{cluster:!0,cluster_id:e[t+x],point_count:s,point_count_abbreviated:i})}function M(e){return e/360+.5}function F(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function B(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function H(e,t,n,s){for(var i,l=s,a=n-t>>1,r=n-t,o=e[t],u=e[t+1],c=e[n],h=e[n+1],p=t+3;pl)i=p,l=d;else if(d===l){var f=Math.abs(p-a);fs&&(i-t>3&&H(e,t,i,s),e[i+2]=l,n-i>3&&H(e,i,n,s))}function U(e,t,n,s,i,l){var a=i-n,r=l-s;if(0!==a||0!==r){var o=((e-n)*a+(t-s)*r)/(a*a+r*r);o>1?(n=i,s=l):o>0&&(n+=a*o,s+=r*o)}return(a=e-n)*a+(r=t-s)*r}function G(e,t,n,s){var i={id:void 0===e?null:e,type:t,geometry:n,tags:s,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)k(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var s=0;s0&&(a+=s?(i*u-o*l)/2:Math.sqrt(Math.pow(o-i,2)+Math.pow(u-l,2))),i=o,l=u}var c=t.length-3;t[2]=1,H(t,0,c,n),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function W(e,t,n,s){for(var i=0;i1?1:n}function X(e,t,n,s,i,l,a,r){if(s/=t,l>=(n/=t)&&a=s)return null;for(var o=[],u=0;u=n&&f=s)){var m=[];if("Point"===p||"MultiPoint"===p)Z(h,m,n,s,i);else if("LineString"===p)K(h,m,n,s,i,!1,r.lineMetrics);else if("MultiLineString"===p)J(h,m,n,s,i,!1);else if("Polygon"===p)J(h,m,n,s,i,!0);else if("MultiPolygon"===p)for(var I=0;I=n&&a<=s&&(t.push(e[l]),t.push(e[l+1]),t.push(e[l+2]))}}function K(e,t,n,s,i,l,a){for(var r,o,u=Q(e),c=0===i?ee:te,h=e.start,p=0;pn&&(o=c(u,d,f,I,y,n),a&&(u.start=h+r*o)):v>s?E=n&&(o=c(u,d,f,I,y,n),w=!0),E>s&&v<=s&&(o=c(u,d,f,I,y,s),w=!0),!l&&w&&(a&&(u.end=h+r*o),t.push(u),u=Q(e)),a&&(h+=r)}var g=e.length-3;d=e[g],f=e[g+1],m=e[g+2],(v=0===i?d:f)>=n&&v<=s&&$(u,d,f,m),g=u.length-3,l&&g>=3&&(u[g]!==u[0]||u[g+1]!==u[1])&&$(u,u[0],u[1],u[2]),u.length&&t.push(u)}function Q(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function J(e,t,n,s,i,l){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function re(e,t,n,s){var i=t.geometry,l=t.type,a=[];if("Point"===l||"MultiPoint"===l)for(var r=0;r0&&t.size<(i?a:s))n.numPoints+=t.length/3;else{for(var r=[],o=0;oa)&&(n.numSimplified++,r.push(t[o]),r.push(t[o+1])),n.numPoints++;i&&function(e,t){for(var n=0,s=0,i=e.length,l=i-2;s0===t)for(s=0,i=e.length;s24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var s=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var s=0;s1&&console.time("creation"),p=this.tiles[h]=ae(e,t,n,s,o),this.tileCoords.push({z:t,x:n,y:s}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,s,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+t;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=e,i){if(t===o.maxZoom||t===i)continue;var f=1<1&&console.time("clipping");var m,I,y,v,E,w,g=.5*o.buffer/o.extent,T=.5-g,b=.5+g,R=1+g;m=I=y=v=null,E=X(e,c,n-g,n+b,0,p.minX,p.maxX,o),w=X(e,c,n+T,n+R,0,p.minX,p.maxX,o),e=null,E&&(m=X(E,c,s-g,s+b,1,p.minY,p.maxY,o),I=X(E,c,s+T,s+R,1,p.minY,p.maxY,o),E=null),w&&(y=X(w,c,s-g,s+b,1,p.minY,p.maxY,o),v=X(w,c,s+T,s+R,1,p.minY,p.maxY,o),w=null),u>1&&console.timeEnd("clipping"),r.push(m||[],t+1,2*n,2*s),r.push(I||[],t+1,2*n,2*s+1),r.push(y||[],t+1,2*n+1,2*s),r.push(v||[],t+1,2*n+1,2*s+1)}}},ue.prototype.getTile=function(e,t,n){var s=this.options,i=s.extent,l=s.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var o,u=e,c=t,h=n;!o&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),o=this.tiles[ce(u,c,h)];return o&&o.source?(l>1&&console.log("found parent tile z%d-%d-%d",u,c,h),l>1&&console.time("drilling down"),this.splitTile(o.source,u,c,h,e,t,n),l>1&&console.timeEnd("drilling down"),this.tiles[r]?ie(this.tiles[r],i):null):null};class pe extends e.VectorTileWorkerSource{constructor(e,t,n,s,i){super(e,t,n,s,he),i&&(this.loadGeoJSON=i)}loadData(t,n){const s=t&&t.request,i=s&&s.collectResourceTiming;this.loadGeoJSON(t,((l,a)=>{if(l||!a)return n(l);if("object"!=typeof a)return n(new Error("Input data given to '".concat(t.source,"' is not a valid GeoJSON object.")));{r(a,!0);try{if(t.filter){const n=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));const s=a.features.filter((e=>n.value.evaluate({zoom:0},e)));a={type:"FeatureCollection",features:s}}this._geoJSONIndex=t.cluster?new N(function(t){let{superclusterOptions:n,clusterProperties:s}=t;if(!s||!n)return n;const i={},l={},a={accumulated:null,zoom:0},r={properties:null},o=Object.keys(s);for(const u of o){const[t,n]=s[u],a=e.createExpression(n),r=e.createExpression("string"==typeof t?[t,["accumulated"],["get",u]]:t);i[u]=a.value,l[u]=r.value}return n.map=e=>{r.properties=e;const t={};for(const n of o)t[n]=i[n].evaluate(a,r);return t},n.reduce=(e,t)=>{r.properties=t;for(const n of o)a.accumulated=e[n],e[n]=l[n].evaluate(a,r)},n}(t)).load(a.features):function(e,t){return new ue(e,t)}(a,t.geojsonVtOptions)}catch(l){return n(l)}this.loaded={};const o={};if(i){const n=e.getPerformanceMeasurement(s);n&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(n)))}n(null,o)}}))}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.getJSON(t.request,n);else{if("string"!=typeof t.data)return n(new Error("Input data given to '".concat(t.source,"' is not a valid GeoJSON object.")));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error("Input data given to '".concat(t.source,"' is not a valid GeoJSON object.")))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class de{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:pe},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error('Worker source with name "'.concat(e,'" already registered.'));this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){this.isSpriteLoaded[t]=n;for(const s in this.workerSources[t]){const i=this.workerSources[t][s];for(const t in i)i[t]instanceof e.VectorTileWorkerSource&&(i[t].isSpriteLoaded=n,i[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,n){this.availableImages[e]=t;for(const s in this.workerSources[e]){const n=this.workerSources[e][s];for(const e in n)n[e].availableImages=t}n()}enableTerrain(e,t,n){this.terrain=t,n()}setProjection(t,n){this.projections[t]=e.getProjection(n)}setLayers(e,t,n){this.getLayerIndex(e).replace(t),n()}updateLayers(e,t,n){this.getLayerIndex(e).update(t.layers,t.removedIds),n()}loadTile(t,n,s){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).loadTile(i,s)}loadDEMTile(t,n,s){const i=this.enableTerrain?e.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(t,n.source).loadTile(i,s)}reloadTile(t,n,s){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).reloadTile(i,s)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source).removeTile(t,n)}removeSource(e,t,n){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const s=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==s.removeSource?s.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,s){try{e.plugin.setState(n);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const n=e.plugin.isParsed();s(n?void 0:new Error("RTL Text Plugin failed to import scripts from ".concat(t)),n)}}catch(e){s(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new s),t}getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){const s={send:(t,n,s,i,l,a)=>{this.actor.send(t,n,s,e,l,a)},scheduler:this.actor.scheduler};this.workerSources[e][t][n]=new this.workerSourceTypes[t](s,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][n]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new i),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,n){e.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new de(self)),de})),s(["./shared"],(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let s=0;s{e.window.removeEventListener("click",p,!0)}),0)}function f(e,t){const n=e.getBoundingClientRect();return y(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),s=[];for(let i=0;i=0?0:t.button}function y(t,n,s){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.Point((s.clientX-n.left)*i,(s.clientY-n.top)*i)}function v(e,t){var n=t[0],s=t[1],i=t[2],l=t[3],a=n*l-i*s;return a?(e[0]=l*(a=1/a),e[1]=-s*a,e[2]=-i*a,e[3]=n*a,e):null}function E(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class w extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,n){let s=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.ErrorEvent(new Error('Image "'.concat(t,'" has invalid "stretchX" value')))),s=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.ErrorEvent(new Error('Image "'.concat(t,'" has invalid "stretchY" value')))),s=!1),this._validateContent(n.content,n)||(this.fire(new e.ErrorEvent(new Error('Image "'.concat(t,'" has invalid "content" value')))),s=!1),s}_validateStretch(e,t){if(!e)return!0;let n=0;for(const s of e){if(s[0]1&&void 0!==arguments[1]?arguments[1]:{};if(!this._validate(e.validateLight,t,n))for(const s in t){const n=t[s];e.endsWith(s,"-transition")?this._transitionable.setTransition(s.slice(0,-11),n):this._transitionable.setValue(s,n)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,n,s){return(!s||!1!==s.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}const b=new e.Properties({source:new e.DataConstantProperty(e.spec.terrain.source),exaggeration:new e.DataConstantProperty(e.spec.terrain.exaggeration)});let R=class extends e.Evented{constructor(t,n){super(),this._transitionable=new e.Transitionable(b),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=n}get(){return this._transitionable.serialize()}set(t){for(const n in t){const s=t[n];e.endsWith(n,"-transition")?this._transitionable.setTransition(n.slice(0,-11),s):this._transitionable.setValue(n,s)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function S(t,n,s,i){const l=e.smoothstep(45,65,s),[a,r]=D(t,i),o=e.length(n);let u=1-Math.min(1,Math.exp((o-a)/(r-a)*-6));return u*=u*u,u=Math.min(1,1.00747*u),u*l*t.alpha}function D(e,t){const n=.5/Math.tan(.5*t);return[e.range[0]+n,e.range[1]+n]}const A=new e.Properties({range:new e.DataConstantProperty(e.spec.fog.range),color:new e.DataConstantProperty(e.spec.fog.color),"high-color":new e.DataConstantProperty(e.spec.fog["high-color"]),"space-color":new e.DataConstantProperty(e.spec.fog["space-color"]),"horizon-blend":new e.DataConstantProperty(e.spec.fog["horizon-blend"]),"star-intensity":new e.DataConstantProperty(e.spec.fog["star-intensity"])});class C extends e.Evented{constructor(t,n){super(),this._transitionable=new e.Transitionable(A),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=n}get state(){const t=this._transform,n="globe"===t.projection.name,s=e.globeToMercatorTransition(t.zoom),i=this.properties.get("range"),l=[.5,3];return{range:n?[e.number(l[0],i[0],s),e.number(l[1],i[1],s)]:i,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._validate(e.validateFog,t,n)){for(const n of Object.keys(e.spec.fog))t&&void 0===t[n]&&(t[n]=e.spec.fog[n].default);for(const n in t){const s=t[n];e.endsWith(n,"-transition")?this._transitionable.setTransition(n.slice(0,-11),s):this._transitionable.setValue(n,s)}}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const n=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.smoothstep(45,65,t))*n.a}getOpacityAtLatLng(t,n){return this._transform.projection.supportsFog?function(t,n,s){const i=e.MercatorCoordinate.fromLngLat(n),l=s.elevation?s.elevation.getAtPointOrZero(i):0,a=[i.x,i.y,l];return e.transformMat4(a,a,s.mercatorFogMatrix),S(t,a,s.pitch,s._fov)}(this.state,t,n):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?D(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,n,s){return(!s||!1!==s.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}class x{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.uniqueId();const s=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0}))}broadcast(t,n,s){e.asyncAll(this.actors,((e,s)=>{e.send(t,n,s)}),s=s||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}function _(t,n,s){return n*(e.EXTENT/(t.tileSize*Math.pow(2,s-t.tileID.overscaledZ)))}x.Actor=e.Actor;class O{constructor(e,t,n,s){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,s)}static createFromScreenPoints(t,n){let s,i;if(t instanceof e.Point||"number"==typeof t[0]){const l=e.Point.convert(t);s=[l],i=n.isPointAboveHorizon(l)}else{const l=e.Point.convert(t[0]),a=e.Point.convert(t[1]);s=[l,a],i=e.polygonizeBounds(l,a).every((e=>n.isPointAboveHorizon(e)))}return new O(s,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],s=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,s,0,!1);return this.cameraPoint.y>s.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=s.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.bufferConvexPolygon(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],s=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,s,t),l=this.cameraPoint.clone();switch(3*((l.y>n.y)+(l.y>s.y))+((l.x>n.x)+(l.x>s.x))){case 0:i[0]=l,i[4]=l.clone();break;case 1:i.splice(1,0,l);break;case 2:i[1]=l;break;case 3:i.splice(4,0,l);break;case 5:i.splice(2,0,l);break;case 6:i[3]=l;break;case 7:i.splice(3,0,l);break;case 8:i[2]=l}return i}containsTile(t,n,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const l=t.queryPadding/n._pixelsPerMercatorPixel+1,a=s?this._bufferedCameraMercator(l,n):this._bufferedScreenMercator(l,n);let r=t.tileID.wrap+(a.unwrapped?i:0);const o=a.polygon.map((n=>e.getTilePoint(t.tileTransform,n,r)));if(!e.polygonIntersectsBox(o,0,0,e.EXTENT,e.EXTENT))return;r=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const u=this.screenGeometryMercator.polygon.map((n=>e.getTileVec3(t.tileTransform,n,r))),c=u.map((t=>new e.Point(t[0],t[1]))),h=n.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),p=e.getTileVec3(t.tileTransform,h,r),d=u.map((t=>{const n=e.sub(t,t,p);return e.normalize(n,n),new e.Ray(p,n)})),f=_(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:d,bufferedTilespaceGeometry:o,bufferedTilespaceBounds:(m=e.getBounds(o),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const n=P(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let s;return s="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[n]=s,s}}_bufferedCameraMercator(e,t){const n=P(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let s;return s="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[n]=s,s}}_projectAndResample(t,n){const s=function(t,n){const s=e.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.GLOBE_RADIUS,0,1],l=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(i,i,s),e.transformMat4$1(l,l,s),e.transformMat4$1(a,a,s);const r=new e.Point(i[0]/i[3],i[1]/i[3]),o=new e.Point(l[0]/l[3],l[1]/l[3]),u=e.polygonContainsPoint(t,r)&&i[3]1?N(t.slice(0,p),n):[],m=pnew e.Point(L(t.x),t.y))),m=m.map((t=>new e.Point(L(t.x),t.y)));const I=[...f];0===I.length&&I.push(m[m.length-1]);const y=e.number(I[I.length-1].y,(0===m.length?f[0]:m[0]).y,d);let v;return v=u?[new e.Point(0,y),new e.Point(0,0),new e.Point(1,0),new e.Point(1,y)]:[new e.Point(1,y),new e.Point(1,1),new e.Point(0,1),new e.Point(0,y)],I.push(...v),0===m.length?I.push(f[0]):I.push(...m),{polygon:I.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,n);if(s)return s;const i=function(t,n){let s=!1,i=-1/0,l=0;for(let e=0;ei&&(i=t[e].x,l=e);for(let e=0;e.5&&(i.x{e.x-=1})),{polygon:t,unwrapped:s}}(N(t,n).map((t=>new e.Point(L(t.x),t.y))),n);return{polygon:i.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:i.unwrapped}}}function N(t,n){return e.resample(t,(e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function L(e){return e<0?1+e%1:e%1}function P(e){return 100*e|0}function M(t,n,s,i,l){const a=function(s,i){if(s)return l(s);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const s=e.pick(e.extend(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(s.vectorLayers=i.vector_layers,s.vectorLayerIds=s.vectorLayers.map((e=>e.id))),s.tiles=n.canonicalizeTileset(s,t.url),l(null,s)}};return t.url?e.getJSON(n.transformRequest(n.normalizeSourceURL(t.url,null,s,i),e.ResourceType.Source),a):e.exported.frame((()=>a(null,t)))}class F{constructor(t,n,s){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=s||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),s=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*n),l=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=s&&t.x=i&&t.y1&&void 0!==arguments[1]&&arguments[1];if(this.gl=e,this.isWebGL2=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),t){const t=e;this.extVertexArrayObject={createVertexArrayOES:t.createVertexArray.bind(e),deleteVertexArrayOES:t.deleteVertexArray.bind(e),bindVertexArrayOES:t.bindVertexArray.bind(e)}}this.clearColor=new k(this),this.clearDepth=new z(this),this.clearStencil=new V(this),this.colorMask=new j(this),this.depthMask=new W(this),this.stencilMask=new Y(this),this.stencilFunc=new q(this),this.stencilOp=new X(this),this.stencilTest=new Z(this),this.depthRange=new K(this),this.depthTest=new Q(this),this.depthFunc=new J(this),this.blend=new $(this),this.blendFunc=new ee(this),this.blendColor=new te(this),this.blendEquation=new ne(this),this.cullFace=new se(this),this.cullFaceSide=new ie(this),this.frontFace=new le(this),this.program=new re(this),this.activeTexture=new oe(this),this.viewport=new ue(this),this.bindFramebuffer=new ce(this),this.bindRenderbuffer=new he(this),this.bindTexture=new pe(this),this.bindVertexBuffer=new de(this),this.bindElementBuffer=new fe(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new me(this),this.pixelStoreUnpack=new Ie(this),this.pixelStoreUnpackPremultiplyAlpha=new ye(this),this.pixelStoreUnpackFlipY=new ve(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),t||(this.extTextureHalfFloat=e.getExtension("OES_texture_half_float")),(t||this.extTextureHalfFloat&&e.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=t||e.getExtension("OES_standard_derivatives"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new B(this,e,t)}createVertexBuffer(e,t,n){return new U(this,e,t,n)}createRenderbuffer(e,t,n){const s=this.gl,i=s.createRenderbuffer();return this.bindRenderbuffer.set(i),s.renderbufferStorage(s.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n){return new be(this,e,t,n)}clear(e){let{color:t,depth:n,stencil:s}=e;const i=this.gl;let l=0;t&&(l|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==n&&(l|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),void 0!==s&&(l|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(s),this.stencilMask.set(255)),i.clear(l)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(n){t(n.blendFunction,e.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(n.blendFunction),this.blendColor.set(n.blendColor)),this.colorMask.set(n.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Se extends e.Evented{constructor(t,n,s,i){if(super(),this.id=t,this.dispatcher=s,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.extend(this,e.pick(n,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,s=this.map._worldview;this._tileJSONRequest=M(this._options,this.map._requestManager,n,s,((i,l)=>{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ".concat(n)),s&&2!==s.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: ".concat(s)),this.fire(new e.ErrorEvent(i))):l&&(e.extend(this,l),l.bounds&&(this.tileBounds=new F(l.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(l.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}loadTile(t,n){const s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(s,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,l.bind(this));else if(t.actor=this._tileWorkers[s]=this._tileWorkers[s]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,l.bind(this),void 0,!0);else{const n=e.loadVectorTile.call({deduped:this._deduped},i,((e,n)=>{e||!n?l.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,l.bind(this),void 0,!0))}),!0);t.request={cancel:n}}function l(s,i){return delete t.request,t.aborted?n(null):s&&404!==s.status?n(s):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class De extends e.Evented{constructor(t,n,s,i){super(),this.id=t,this.dispatcher=s,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.extend({type:"raster"},n),e.extend(this,e.pick(n,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=M(this._options,this.map._requestManager,null,null,((n,s)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new e.ErrorEvent(n)):s&&(e.extend(this,s),s.bounds&&(this.tileBounds=new F(s.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(s.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const s=e.exported.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),s,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),((s,i,l,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):s?(t.state="errored",n(s)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:l,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null))))}static loadTileData(e,t,n){e.setTexture(t,n)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Ae(t,n,s,i,l,a,r,o){const u=[t,s,l,n,i,a,1,1,1],c=[r,o,1],h=e.adjoint([],u),[p,d,f]=e.transformMat3(c,c,e.transpose(h,h));return e.multiply$1(u,[p,0,0,0,d,0,0,0,f],u)}class Ce extends e.Evented{constructor(e,t,n,s){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(s),this.options=t,this._dirty=!1}load(t,n){this._loaded=n||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((n,s)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new e.ErrorEvent(n));else if(s){const{HTMLImageElement:n}=e.window;this.image=s instanceof n?e.exported.getImageData(s):s,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const n=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let n=1/0,s=1/0,i=-1/0,l=-1/0;for(const e of t)n=Math.min(n,e.x),s=Math.min(s,e.y),i=Math.max(i,e.x),l=Math.max(l,e.y);const a=Math.max(i-n,l-s),r=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),o=Math.pow(2,r);return new e.CanonicalTileID(r,Math.floor((n+i)/2*o),Math.floor((s+l)/2*o))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const n=e.tileTransform(this.tileID,this.map.transform.projection),[s,i,l,a]=this.coordinates.map((t=>{const s=n.projection.project(t[0],t[1]);return e.getTilePoint(n,s)._round()}));this.perspectiveTransform=function(t,n,s,i,l,a,r,o,u,c){const h=Ae(0,0,t,0,0,n,t,n),p=Ae(s,i,l,a,r,o,u,c);return e.multiply$1(p,e.adjoint(h,h),p),[p[6]/p[8]*t/e.EXTENT,p[7]/p[8]*n/e.EXTENT]}(this.width,this.height,s.x,s.y,i.x,i.y,a.x,a.y,l.x,l.y);const r=this._boundsArray=new e.StructArrayLayout4i8;r.emplaceBack(s.x,s.y,0,0),r.emplaceBack(i.x,i.y,e.EXTENT,0),r.emplaceBack(a.x,a.y,0,e.EXTENT),r.emplaceBack(l.x,l.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(r,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,n=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const xe={vector:Se,raster:De,"raster-dem":class extends De{constructor(t,n,s,i){super(t,n,s,i),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,s){e&&(t.state="errored",n(e)),s&&(t.dem=s,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.getImage(this.map._requestManager.transformRequest(s,e.ResourceType.Tile),function(s,l,a,r){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(s)t.state="errored",n(s);else if(l){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:r});const n=e.window.ImageBitmap&&l instanceof e.window.ImageBitmap&&(null==ae&&(ae=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),ae),s=1-(l.width-e.prevPowerOfTwo(l.width))/2;s<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const o=n?l:e.exported.getImageData(l,s),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:o,encoding:this.encoding,padding:s};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),i=(n.x-1+s)%s,l=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+s)%s,r=n.x+1===s?t.wrap+1:t.wrap,o={};return o[new e.OverscaledTileID(t.overscaledZ,l,n.z,i,n.y).key]={backfilled:!1},o[new e.OverscaledTileID(t.overscaledZ,r,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(o[new e.OverscaledTileID(t.overscaledZ,l,n.z,i,n.y-1).key]={backfilled:!1},o[new e.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},o[new e.OverscaledTileID(t.overscaledZ,r,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(t.resourceTiming=n.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,n){const s=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(s,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,i)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===s),n(null)))),void 0,"loadTile"===s)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ce{constructor(e,t,n,s){super(e,t,n,s),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.ResourceType.Source).url);e.getVideo(this.urls,((t,n)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(this.video=n,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError("sources.".concat(this.id),null,"Playback for this video can be set only between the ".concat(n.start(0)," and ").concat(n.end(0),"-second mark.")))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,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,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ce,canvas:class extends Ce{constructor(t,n,s,i){super(t,n,s,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError("sources.".concat(t),null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources.".concat(t),null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.ErrorEvent(new e.ValidationError("sources.".concat(t),null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError("sources.".concat(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.ErrorEvent(new e.ValidationError("sources.".concat(t),null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,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 n=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,n,s,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=s,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error("Missing implementation for ".concat(this.id," custom source")))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error("Missing loadTile implementation for ".concat(this.id," custom source")))),this._implementation.bounds&&(this.tileBounds=new F(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:n,z:s}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:s})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const{x:s,y:i,z:l}=t.tileID.canonical,a=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:s,y:i,z:l},{signal:a.signal})).then(function(s){return delete t.request,t.aborted?(t.state="unloaded",n(null)):void 0===s?(t.state="errored",n(null)):null===s?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",n(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(s)?(this.loadTileData(t,s),t.state="loaded",void n(null)):(t.state="errored",n(new Error("Can't infer data type for ".concat(this.id,", only raster data supported at the moment"))))}.bind(this)).catch((e=>{20!==e.code&&(t.state="errored",n(e))})),t.request.cancel=()=>a.abort()}loadTileData(e,t){De.loadTileData(e,t,this._map.painter)}unloadTileData(e){De.unloadTileData(e,this._map.painter)}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:n,z:s}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:n,z:s})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},_e=function(t,n,s,i){const l=new xe[n.type](t,n,s,i);if(l.id!==t)throw new Error("Expected Source id to be ".concat(t," instead of ").concat(l.id));return e.bindAll(["load","abort","unload","serialize","prepare"],l),l};function Oe(t,n){const s=e.identity([]);return e.scale(s,s,[.5*t.width,.5*-t.height,1]),e.translate(s,s,[1,-1,0]),e.multiply(s,s,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(s)}function Ne(e,t,n,s,i,l,a){let r=arguments.length>7&&void 0!==arguments[7]&&arguments[7];const o=e.tilesIn(s,a,r);o.sort(Pe);const u=[];for(const h of o)u.push({wrappedTileID:h.tile.tileID.wrapped().key,queryResults:h.tile.queryRenderedFeatures(t,n,e._state,h,i,l,Oe(e.transform,h.tile.tileID),r)});const c=function(e){const t={},n={};for(const s of e){const e=s.queryResults,i=s.wrappedTileID,l=n[i]=n[i]||{};for(const n in e){const s=e[n],i=l[n]=l[n]||{},a=t[n]=t[n]||[];for(const e of s)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(u);for(const h in c)c[h].forEach((t=>{const n=t.feature,s=n.layer;s&&"background"!==s.type&&"sky"!==s.type&&(n.source=s.source,s["source-layer"]&&(n.sourceLayer=s["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(s["source-layer"],n.id):{})}));return c}function Le(e,t){const n=e.getRenderableIds().map((t=>e.getTileByID(t))),s=[],i={};for(let l=0;l{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let He;function Ue(){return He||(He=new Be),He}function Ge(t,n){const s={};for(const e in t)"ref"!==e&&(s[e]=t[e]);return e.refProperties.forEach((e=>{e in n&&(s[e]=n[e])})),s}function ke(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/r:0;return this.points[l].mult(1-o).add(this.points[n].mult(o))}}class Qe{constructor(e,t,n){const s=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let l=0;lthis.width||s<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=s){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,s,i){const l=e-n,a=e+n,r=t-n,o=t+n;if(a<0||l>this.width||o<0||r>this.height)return!s&&[];const u=[];return this._forEachCell(l,r,a,o,this._queryCellCircle,u,{hitTest:s,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),s?u.length>0:u}query(e,t,n,s,i){return this._query(e,t,n,s,!1,i)}hitTest(e,t,n,s,i){return this._query(e,t,n,s,!0,i)}hitTestCircle(e,t,n,s){return this._queryCircle(e,t,n,!0,s)}_queryCell(e,t,n,s,i,l,a,r){const o=a.seenUids,u=this.boxCells[i];if(null!==u){const i=this.bboxes;for(const c of u)if(!o.box[c]){o.box[c]=!0;const u=4*c;if(e<=i[u+2]&&t<=i[u+3]&&n>=i[u+0]&&s>=i[u+1]&&(!r||r(this.boxKeys[c]))){if(a.hitTest)return l.push(!0),!0;l.push({key:this.boxKeys[c],x1:i[u],y1:i[u+1],x2:i[u+2],y2:i[u+3]})}}}const c=this.circleCells[i];if(null!==c){const i=this.circles;for(const u of c)if(!o.circle[u]){o.circle[u]=!0;const c=3*u;if(this._circleAndRectCollide(i[c],i[c+1],i[c+2],e,t,n,s)&&(!r||r(this.circleKeys[u]))){if(a.hitTest)return l.push(!0),!0;{const e=i[c],t=i[c+1],n=i[c+2];l.push({key:this.circleKeys[u],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,s,i,l,a,r){const o=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c){const e=this.bboxes;for(const t of c)if(!u.box[t]){u.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(o.x,o.y,o.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!r||r(this.boxKeys[t])))return l.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!u.circle[t]){u.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],o.x,o.y,o.radius)&&(!r||r(this.circleKeys[t])))return l.push(!0),!0}}}_forEachCell(e,t,n,s,i,l,a,r){const o=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(s);for(let p=o;p<=c;p++)for(let o=u;o<=h;o++)if(i.call(this,e,t,n,s,this.xCellCount*o+p,l,a,r))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,s,i,l){const a=s-e,r=i-t,o=n+l;return o*o>a*a+r*r}_circleAndRectCollide(e,t,n,s,i,l,a){const r=(l-s)/2,o=Math.abs(e-(s+r));if(o>r+n)return!1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+n)return!1;if(o<=r||c<=u)return!0;const h=o-r,p=c-u;return h*h+p*p<=n*n}}const Je={unknown:0,flipRequired:1,flipNotRequired:2},$e=Math.tan(85*Math.PI/180);function et(t,n,s,i,l,a,r){const o=e.create();if(s)if("globe"===a.name){const t=e.calculateGlobeLabelMatrix(l,n);e.multiply(o,o,t)}else{const t=v([],r);o[0]=t[0],o[1]=t[1],o[4]=t[2],o[5]=t[3],i||e.rotateZ(o,o,l.angle)}else e.multiply(o,l.labelPlaneMatrix,t);return o}function tt(e,t,n,s,i,l,a){const r=et(e,t,n,s,i,l,a);return"globe"===l.name&&n||(r[2]=r[6]=r[10]=r[14]=0),r}function nt(t,n,s,i,l,a,r){if(s){if("globe"===a.name){const o=et(t,n,s,i,l,a,r);return e.invert(o,o),e.multiply(o,t,o),o}{const n=e.clone(t),s=e.identity([]);return s[0]=r[0],s[1]=r[1],s[4]=r[2],s[5]=r[3],e.multiply(n,n,s),i||e.rotateZ(n,n,-l.angle),n}}return l.glCoordMatrix}function st(t,n,s,i){const l=[t,n,s,1];s?e.transformMat4$1(l,l,i):ft(l,l,i);const a=l[3];return l[0]/=a,l[1]/=a,l[2]/=a,l}function it(e,t){return Math.min(.5+e/t*.5,1.5)}function lt(e,t){const n=e[0]/e[3],s=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function at(t,n,s,i,l,a,r,o,u,c){const h=s.transform,p=i?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(p,s.transform.zoom),f="globe"===h.projection.name,m=[256/s.width*2+1,256/s.height*2+1],I=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;I.clear();let y=null;f&&(y=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,E=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=s.transform.width/s.transform.height;let g,T=!1;for(let b=0;bMath.abs(s)?{useVertical:!0}:t===e.WritingMode.vertical?i>0?{needsFlipping:!0}:null:n!==Je.unknown&&function(e,t){return 0===e||Math.abs(t/e)>$e}(s,i)?n===Je.flipRequired?{needsFlipping:!0}:null:s<0?{needsFlipping:!0}:null}function ut(t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v,E){const w=n/24,g=t.lineOffsetX*w,T=t.lineOffsetY*w,{lineStartIndex:b,glyphStartIndex:R,numGlyphs:S,segment:D,writingMode:A,flipState:C}=t,x=b+t.lineLength,_=t=>{if(h){const[n,s,i]=t.up,l=c.length;e.updateGlobeVertexNormal(h,l+0,n,s,i),e.updateGlobeVertexNormal(h,l+1,n,s,i),e.updateGlobeVertexNormal(h,l+2,n,s,i),e.updateGlobeVertexNormal(h,l+3,n,s,i)}const[n,s,i]=t.point;e.addDynamicAttributes(c,n,s,i,t.angle)};if(S>1){const e=rt(w,o,g,T,s,p,d,t,u,a,f,I,!1,y,v,E);if(!e)return{notEnoughRoom:!0};if(i&&!s){let[n,s,i]=e.first.point,[l,a,o]=e.last.point;[n,s]=st(n,s,i,r),[l,a]=st(l,a,o,r);const u=ot(A,C,(l-n)*m,a-s);if(t.flipState=u&&u.needsFlipping?Je.flipRequired:Je.flipNotRequired,u)return u}_(e.first);for(let t=R+1;t0?a:ht(d,i,n,1,l,void 0,y,v.canonical),o=ot(A,C,(r[0]-n[0])*m,r[1]-n[1]);if(t.flipState=o&&o.needsFlipping?Je.flipRequired:Je.flipNotRequired,o)return o}const n=pt(w*o.getoffsetX(R),g,T,s,p,d,D,b,x,u,a,f,I,!1,!1,y,v,E);if(!n)return{notEnoughRoom:!0};_(n)}return{}}function ct(e,t,n,s,i){const{x:l,y:a,z:r}=s.projectTilePoint(e.x,e.y,t);if(!i)return st(l,a,r,n);const[o,u,c]=i(e);return st(l+o,a+u,r+c,n)}function ht(t,n,s,i,l,a,r,o){const u=ct(t.sub(n)._unit()._add(t),o,l,r,a);return e.sub(u,s,u),e.normalize(u,u),e.scaleAndAdd(u,s,u,i)}function pt(t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y,v){const E=i?t-n:t+n;let w=E>0?1:-1,g=0;i&&(w*=-1,g=Math.PI),w<0&&(g+=Math.PI);let T=o+r+(w>0?0:1)|0,b=l,R=l,S=0,D=0;const A=Math.abs(E),C=[],x=[];let _=a,O=_;const N=()=>ht(O,_,R,A-S+1,h,d,I,y.canonical);for(;S+D<=A;){if(T+=w,T=u)return null;if(R=b,O=_,C.push(R),f&&x.push(O),_=new e.Point(c.getx(T),c.gety(T)),b=p[T],!b){const e=ct(_,y.canonical,h,I,d);b=e[3]>0?p[T]=e:N()}S+=D,D=e.distance(R,b)}m&&d&&(p[T]&&(b=N(),D=e.distance(R,b)),p[T]=b);const L=(A-S)/D,P=_.sub(O)._mult(L)._add(O),M=e.sub([],b,R),F=e.scaleAndAdd([],R,M,L);let B=[0,0,1],H=M[0],U=M[1];if(v&&(B=I.upVector(y.canonical,P.x,P.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],n=e.cross([],B,t);e.normalize(t,t),e.normalize(n,n),H=e.dot(M,t),U=e.dot(M,n)}if(s){const t=e.cross([],B,M);e.normalize(t,t),e.scaleAndAdd(F,F,t,s*w)}const G=g+Math.atan2(U,H);return C.push(F),f&&x.push(P),{point:F,angle:G,path:C,tilePath:x,up:B}}function dt(e,t){const n=t.length,s=n+4*e;t.resize(s),t.float32.fill(-1/0,4*n,4*s)}function ft(e,t,n){const s=t[0],i=t[1];return e[0]=n[0]*s+n[4]*i+n[12],e[1]=n[1]*s+n[5]*i+n[13],e[3]=n[3]*s+n[7]*i+n[15],e}const mt=100;class It{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Qe(e.width+200,e.height+200,25),s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Qe(e.width+200,e.height+200,25);this.transform=e,this.grid=n,this.ignoredGrid=s,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+mt,this.screenBottomBoundary=e.height+mt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,n,s,i,l,a,r){let o=n.projectedAnchorX,u=n.projectedAnchorY,c=n.projectedAnchorZ;const h=n.elevation,p=n.tileID,d=e.getProjection();if(h&&p){const[e,t,s]=d.upVector(p.canonical,n.tileAnchorX,n.tileAnchorY),i=d.upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;o+=e*h*i,u+=t*h*i,c+=s*h*i}const f=this.projectAndGetPerspectiveRatio(a,o,u,c,n.tileID,"globe"===d.name||!!h||this.transform.pitch>0,d),m=l*f.perspectiveRatio,I=(n.x1*t+s.x-n.padding)*m+f.point.x,y=(n.y1*t+s.y-n.padding)*m+f.point.y,v=(n.x2*t+s.x+n.padding)*m+f.point.x,E=(n.y2*t+s.y+n.padding)*m+f.point.y,w=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(I,y,v,E)||!i&&this.grid.hitTest(I,y,v,E,r)||w?{box:[],offscreen:!1,occluded:f.occluded}:{box:[I,y,v,E],offscreen:this.isOffscreen(I,y,v,E),occluded:!1}}placeCollisionCircles(t,n,s,i,l,a,r,o,u,c,h,p,d,f,m){const I=[],y=this.transform.elevation,v=t.getProjection(),E=y?y.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,v):null,w=new e.Point(s.tileAnchorX,s.tileAnchorY);let{x:g,y:T,z:b}=v.projectTilePoint(w.x,w.y,m.canonical);if(E){const[e,t,n]=E(w);g+=e,T+=t,b+=n}const R="globe"===v.name,S=this.projectAndGetPerspectiveRatio(r,g,T,b,m,R||!!y||this.transform.pitch>0,v),{perspectiveRatio:D}=S,A=(h?a/D:a*D)/e.ONE_EM,C=st(g,T,b,o),x=S.signedDistanceFromCamera>0?rt(A,l,s.lineOffsetX*A,s.lineOffsetY*A,!1,C,w,s,i,o,{},y&&!h?E:null,h&&!!y,v,m,h):null;let _=!1,O=!1,N=!0;if(x&&!S.occluded){const t=.5*d*D+f,s=new e.Point(-100,-100),i=new e.Point(this.screenRightBoundary,this.screenBottomBoundary),l=new Ke,{first:a,last:r}=x,o=a.path.length;let h=[];for(let e=o-1;e>=1;e--)h.push(a.path[e]);for(let e=1;e{let[n,s,i]=e;return E&&!R&&(i=E(te[3]<=0))&&(h=[]));let y=[];if(h.length>0){let t=1/0,n=-1/0,l=1/0,a=-1/0;for(const e of h)t=Math.min(t,e[0]),l=Math.min(l,e[1]),n=Math.max(n,e[0]),a=Math.max(a,e[1]);n>=s.x&&t<=i.x&&a>=s.y&&l<=i.y&&(y=[h.map((t=>new e.Point(t[0],t[1])))],(ti.x||li.y)&&(y=e.clipLine(y,s.x,s.y,i.x,i.y)))}for(const e of y){l.reset(e,.25*t);let s=0;s=l.length<=.5*t?1:Math.ceil(l.paddedLength/m)+1;for(let e=0;e0){if(e.transformMat4$1(o,o,t),this.fogState&&l&&"globe"!==r.name){const t=function(t,n,s,i,l,a){const r=a.calculateFogTileMatrix(l),o=[n,s,i];return e.transformMat4(o,o,r),S(t,o,a.pitch,a._fov)}(this.fogState,n,s,i,l.toUnwrapped(),this.transform);u=t>.9}}else ft(o,o,t);const c=o[3];return{point:new e.Point((o[0]/c+1)/2*this.transform.width+mt,(-o[1]/c+1)/2*this.transform.height+mt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(r)/c*.5,1.5),signedDistanceFromCamera:c,occluded:a&&o[2]>c||u}}isOffscreen(e,t,n,s){return n=this.screenRightBoundary||sthis.screenBottomBoundary}isInsideGrid(e,t,n,s){return n>=0&&e=0&&t5&&void 0!==arguments[5]&&arguments[5];this.text=new wt(e?e.text:null,t,n,i),this.icon=new wt(e?e.icon:null,t,s,i),this.clipped=l}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Tt{constructor(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.text=e,this.icon=t,this.skipFade=n,this.clipped=s}}class bt{constructor(){this.invProjMatrix=e.create(),this.viewportMatrix=e.create(),this.circles=[]}}class Rt{constructor(e,t,n,s,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=s,this.tileID=i}}class St{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Dt(t,n,s,i,l){const{horizontalAlign:a,verticalAlign:r}=e.getAnchorAlignment(t),o=-(a-.5)*n,u=-(r-.5)*s,c=e.evaluateVariableOffset(t,i);return new e.Point(o+c[0]*l,u+c[1]*l)}function At(t,n,s,i,l){const a=new e.Point(t,n);return s&&a._rotate(i?l:-l),a}class Ct{constructor(e,t,n,s,i){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new It(this.transform,i),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new St(n),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,i){const l=s.getBucket(n),a=s.latestFeatureIndex;if(!l||!a||n.id!==l.layerIds[0])return;const r=l.layers[0].layout,o=s.collisionBoxArray,u=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),c=s.tileSize/e.EXTENT,h=s.tileID.toUnwrapped();this.transform.setProjection(l.projection);const p=(d=s.tileID,f=l.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):yt(m,f,d));var d,f,m;const I="map"===r.get("text-pitch-alignment"),y="map"===r.get("text-rotation-alignment");n.compileFilter();const v=n.dynamicFilter(),E=n.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(s),g=tt(p,s.tileID.canonical,I,y,this.transform,l.getProjection(),w);let T=null;if(I){const t=nt(p,s.tileID.canonical,I,y,this.transform,l.getProjection(),w);T=e.multiply([],this.transform.labelPlaneMatrix,t)}let b=null;v&&s.latestFeatureIndex&&(b={unwrappedTileID:h,dynamicFilter:v,dynamicFilterNeedsFeature:E,featureIndex:s.latestFeatureIndex}),this.retainedQueryData[l.bucketInstanceId]=new Rt(l.bucketInstanceId,a,l.sourceLayerIndex,l.index,s.tileID);const R={bucket:l,layout:r,posMatrix:p,textLabelPlaneMatrix:g,labelToScreenMatrix:T,clippingData:b,scale:u,textPixelRatio:c,holdingForFade:s.holdingForFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(l.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(l.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(l.sourceID)};if(i)for(const e of l.sortKeyRanges){const{sortKey:n,symbolInstanceStart:s,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:s,symbolInstanceEnd:i,parameters:R})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:l.symbolInstances.length,parameters:R})}attemptAnchorPlacement(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I,y){const{textOffset0:v,textOffset1:E,crossTileID:w}=h,g=[v,E],T=Dt(e,n,s,g,i),b=this.collisionIndex.placeCollisionBox(d,i,t,At(T.x,T.y,l,a,this.transform.angle),c,r,o,u.predicate);if(m){const e=d.getSymbolInstanceIconSize(y,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,e,m,At(T.x,T.y,l,a,this.transform.angle),c,r,o,u.predicate).box.length)return}if(b.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[w]&&this.prevPlacement.placements[w]&&this.prevPlacement.placements[w].text&&(t=this.prevPlacement.variableOffsets[w].anchor),this.variableOffsets[w]={textOffset:g,width:n,height:s,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[w]=f),{shift:T,placedGlyphBoxes:b}}}placeLayerBucketPart(t,n,s,i){const{bucket:l,layout:a,posMatrix:r,textLabelPlaneMatrix:o,labelToScreenMatrix:u,clippingData:c,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:I}=t.parameters,y=a.get("text-optional"),v=a.get("icon-optional"),E=a.get("text-allow-overlap"),w=a.get("icon-allow-overlap"),g="map"===a.get("text-rotation-alignment"),T="map"===a.get("text-pitch-alignment"),b="none"!==a.get("icon-text-fit"),R="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(l.projection);let S=E&&(w||!l.hasIconData()||v),D=w&&(E||!l.hasTextData()||y);!l.collisionArrays&&d&&l.deserializeCollisionBoxes(d),s&&i&&l.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,i,d)=>{const{crossTileID:R,numVerticalGlyphVertices:A}=t;if(c){const s={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(c.dynamicFilterNeedsFeature){const e=this.retainedQueryData[l.bucketInstanceId];i=c.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,c.dynamicFilter)(s,i,this.retainedQueryData[l.bucketInstanceId].tileID.canonical,new e.Point(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[R]=new Tt(!1,!1,!1,!0),void n.add(R)}if(n.has(R))return;if(p)return void(this.placements[R]=new Tt(!1,!1,!1));let C=!1,x=!1,_=!0,O=!1,N=!1,L=null,P={box:null,offscreen:null,occluded:null},M={box:null,offscreen:null,occluded:null},F=null,B=null,H=null,U=0,G=0,k=0;d.textFeatureIndex?U=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(U=t.featureIndex),d.verticalTextFeatureIndex&&(G=d.verticalTextFeatureIndex);const z=e=>{e.tileID=this.retainedQueryData[l.bucketInstanceId].tileID;const t=this.transform.elevation;(t||e.elevation)&&(e.elevation=t?t.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},V=d.textBox;if(V){z(V);const n=n=>{let s=e.WritingMode.horizontal;if(l.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[R];e&&(this.placedOrientations[R]=e,s=e,this.markUsedOrientation(l,s,t))}return s},s=(t,n)=>{if(l.allowVerticalPlacement&&A>0&&d.verticalTextBox){for(const s of l.writingModes)if(s===e.WritingMode.vertical?(P=n(),M=P):P=t(),P&&P.box&&P.box.length)break}else P=t()};if(a.get("text-variable-anchor")){let o=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[R]){const e=this.prevPlacement.variableOffsets[R];o.indexOf(e.anchor)>0&&(o=o.filter((t=>t!==e.anchor)),o.unshift(e.anchor))}const u=(e,n,s)=>{const a=l.getSymbolInstanceTextSize(f,t,this.transform.zoom,i),u=(e.x2-e.x1)*a+2*e.padding,c=(e.y2-e.y1)*a+2*e.padding,p=b&&!w?n:null;p&&z(p);let d={box:[],offscreen:!1,occluded:!1};const y=E?2*o.length:o.length;for(let v=0;v=o.length,t,i,l,s,p,f,m);if(n&&(d=n.placedGlyphBoxes,d&&d.box&&d.box.length)){C=!0,L=n.shift;break}}return d};s((()=>u(V,d.iconBox,e.WritingMode.horizontal)),(()=>{const t=d.verticalTextBox;return t&&z(t),l.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&A>0&&t?u(t,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),P&&(C=P.box,_=P.offscreen,O=P.occluded);const c=n(!(!P||!P.box));if(!C&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[R];e&&(this.variableOffsets[R]=e,this.markUsedJustification(l,e.anchor,t,c))}}else{const a=(n,s)=>{const a=l.getSymbolInstanceTextSize(f,t,this.transform.zoom,i),o=this.collisionIndex.placeCollisionBox(l,a,n,new e.Point(0,0),E,h,r,I.predicate);return o&&o.box&&o.box.length&&(this.markUsedOrientation(l,s,t),this.placedOrientations[R]=s),o};s((()=>a(V,e.WritingMode.horizontal)),(()=>{const t=d.verticalTextBox;return l.allowVerticalPlacement&&A>0&&t?(z(t),a(t,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),n(!!(P&&P.box&&P.box.length))}}if(F=P,C=F&&F.box&&F.box.length>0,_=F&&F.offscreen,O=F&&F.occluded,t.useRuntimeCollisionCircles){const n=l.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.evaluateSizeForFeature(l.textSizeData,f,n),c=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(l,E,n,l.lineVertexArray,l.glyphOffsetArray,i,r,o,u,s,T,I.predicate,t.collisionCircleDiameter*i/e.ONE_EM,c,this.retainedQueryData[l.bucketInstanceId].tileID),C=E||B.circles.length>0&&!B.collisionDetected,_=_&&B.offscreen,O=B.occluded}if(d.iconFeatureIndex&&(k=d.iconFeatureIndex),d.iconBox){const n=n=>{z(n);const s=b&&L?At(L.x,L.y,g,T,this.transform.angle):new e.Point(0,0),i=l.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(l,i,n,s,w,h,r,I.predicate)};M&&M.box&&M.box.length&&d.verticalIconBox?(H=n(d.verticalIconBox),x=H.box.length>0):(H=n(d.iconBox),x=H.box.length>0),_=_&&H.offscreen,N=H.occluded}const j=y||0===t.numHorizontalGlyphVertices&&0===A,W=v||0===t.numIconVertices;if(j||W?W?j||(x=x&&C):C=x&&C:x=C=x&&C,C&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,a.get("text-ignore-placement"),l.bucketInstanceId,M&&M.box&&G?G:U,I.ID),x&&H&&this.collisionIndex.insertCollisionBox(H.box,a.get("icon-ignore-placement"),l.bucketInstanceId,k,I.ID),B&&(C&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),l.bucketInstanceId,U,I.ID),s)){const e=l.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new bt);for(let n=0;n=0;--t){const n=e[t];A(l.symbolInstances.get(n),n,l.collisionArrays[n])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),r>=0&&(t.text.placedSymbolArray.get(r).crossTileID=h>=0&&r!==h?0:u),o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u)}markUsedOrientation(t,n,s){const i=n===e.WritingMode.horizontal||n===e.WritingMode.horizontalOnly?n:0,l=n===e.WritingMode.vertical?n:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:u}=s,c=t.text.placedSymbolArray;a>=0&&(c.get(a).placedOrientation=i),r>=0&&(c.get(r).placedOrientation=i),o>=0&&(c.get(o).placedOrientation=i),u>=0&&(c.get(u).placedOrientation=l)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const s=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},l=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const r in this.placements){const e=this.placements[r],t=i[r];t?(this.opacities[r]=new gt(t,s,e.text,e.icon,null,e.clipped),n=n||e.text!==t.text.placed||e.icon!==t.icon.placed):(this.opacities[r]=new gt(null,s,e.text,e.icon,e.skipFade,e.clipped),n=n||e.text||e.icon)}for(const r in i){const e=i[r];if(!this.opacities[r]){const t=new gt(e,s,!1,!1);t.isHidden()||(this.opacities[r]=t,n=n||e.text.placed||e.icon.placed)}}for(const r in l)this.variableOffsets[r]||!this.opacities[r]||this.opacities[r].isHidden()||(this.variableOffsets[r]=l[r]);for(const r in a)this.placedOrientations[r]||!this.opacities[r]||this.opacities[r].isHidden()||(this.placedOrientations[r]=a[r]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n=new Set;for(const s of t){const t=s.getBucket(e);t&&s.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n,s.collisionBoxArray)}}updateBucketOpacities(t,n,s){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const i=t.layers[0].layout,l=!!t.layers[0].dynamicFilter(),a=new gt(null,0,!1,!1,!0),r=i.get("text-allow-overlap"),o=i.get("icon-allow-overlap"),u=i.get("text-variable-anchor"),c="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),p="none"!==i.get("icon-text-fit"),d=new gt(null,0,r&&(o||!t.hasIconData()||i.get("icon-optional")),o&&(r||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const f=(e,t,n)=>{for(let s=0;s0||r>0,g=y>0,T=this.placedOrientations[o],b=T===e.WritingMode.vertical,R=T===e.WritingMode.horizontal||T===e.WritingMode.horizontalOnly;if(!w&&!g||E.isHidden()||m++,w){const e=Bt(E.text);f(t.text,i,b?Ht:e),f(t.text,r,R?Ht:e);const n=E.text.isHidden(),{leftJustifiedTextSymbolIndex:l,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:c}=s,h=t.text.placedSymbolArray,p=n||b?1:0;l>=0&&(h.get(l).hidden=p),a>=0&&(h.get(a).hidden=p),u>=0&&(h.get(u).hidden=p),c>=0&&(h.get(c).hidden=n||R?1:0);const d=this.variableOffsets[o];d&&this.markUsedJustification(t,d.anchor,s,T);const m=this.placedOrientations[o];m&&(this.markUsedJustification(t,"left",s,m),this.markUsedOrientation(t,m,s))}if(g){const e=Bt(E.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:i}=s,l=t.icon.placedSymbolArray,a=E.icon.isHidden()?1:0;n>=0&&(f(t.icon,y,b?Ht:e),l.get(n).hidden=a),i>=0&&(f(t.icon,s.numVerticalIconVertices,R?Ht:e),l.get(i).hidden=a)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[I];if(n){let s=new e.Point(0,0),i=!0;if(n.textBox||n.verticalTextBox){if(u){const e=this.variableOffsets[o];e?(s=Dt(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&s._rotate(h?this.transform.angle:-this.transform.angle)):i=!1}l&&(i=!E.clipped),n.textBox&&xt(t.textCollisionBox.collisionVertexArray,E.text.placed,!i||b,s.x,s.y),n.verticalTextBox&&xt(t.textCollisionBox.collisionVertexArray,E.text.placed,!i||R,s.x,s.y)}const a=i&&Boolean(!R&&n.verticalIconBox);n.iconBox&&xt(t.iconCollisionBox.collisionVertexArray,E.icon.placed,a,p?s.x:0,p?s.y:0),n.verticalIconBox&&xt(t.iconCollisionBox.collisionVertexArray,E.icon.placed,!a,p?s.x:0,p?s.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),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.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function xt(e,t,n,s,i){e.emplaceBack(t?1:0,n?1:0,s||0,i||0),e.emplaceBack(t?1:0,n?1:0,s||0,i||0),e.emplaceBack(t?1:0,n?1:0,s||0,i||0),e.emplaceBack(t?1:0,n?1:0,s||0,i||0)}const _t=Math.pow(2,25),Ot=Math.pow(2,24),Nt=Math.pow(2,17),Lt=Math.pow(2,16),Pt=Math.pow(2,9),Mt=Math.pow(2,8),Ft=Math.pow(2,1);function Bt(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*_t+t*Ot+n*Nt+t*Lt+n*Pt+t*Mt+n*Ft+t}const Ht=0;class Ut{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,n,s,i){const l=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.exported.now()-i;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=n[t[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=i)&&(!e.maxzoom||e.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new Ut(e)),this._inProgressLayer.continuePlacement(s[e.source],this.placement,this._showCollisionBoxes,e,l))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const kt=512/e.EXTENT/2;class zt{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this.index=new e.KDBush(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const i=t.canonical.x*e.EXTENT,l=t.canonical.y*e.EXTENT;for(let e=0;ee.overscaledZ)for(const i in n){const l=n[i];l.tileID.isChildOf(e)&&l.findMatches(t.symbolInstances,e,s)}else{const l=n[e.scaledTo(Number(i)).key];l&&l.findMatches(t.symbolInstances,e,s)}}for(let i=0;i{t[e]=!0}));for(const n in this.layerIndexes)t[n]||delete this.layerIndexes[n]}}const Yt=(t,n)=>e.emitValidationErrors(t,n&&n.filter((e=>"source.canvas"!==e.identifier))),qt=e.pick(ze,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Xt=e.pick(ze,["setCenter","setZoom","setBearing","setPitch"]),Zt={version:8,layers:[],sources:{}},Kt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Qt extends e.Evented{constructor(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.map=t,this.dispatcher=new x(Ue(),this),this.imageManager=new w,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,n.localFontFamily?e.LocalGlyphMode.all:n.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new Wt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const s=this;this._rtlTextPluginCallback=Qt.registerForPluginStateChange((t=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,n)=>{if(e.triggerPluginCompletionEvent(t),n&&n.every((e=>e)))for(const e in s._sourceCaches){const t=s._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const n in this._layers){const e=this._layers[n];e.source===t.id&&this._validateLayer(e)}}))}loadURL(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.Event("dataloading",{dataType:"style"}));const s="boolean"==typeof n.validate?n.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,n.accessToken);const i=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(i,((t,n)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):n&&this._load(n,s)}))}loadJSON(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame((()=>{this._request=null,this._load(t,!1!==n.validate)}))}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Zt,!1)}_updateLayerCount(e,t){const n=t?1:-1;e.is3D()&&(this._num3DLayers+=n),"circle"===e.type&&(this._numCircleLayers+=n),"symbol"===e.type&&(this._numSymbolLayers+=n)}_load(t,n){if(n&&Yt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const s=ke(this.stylesheet.layers);this._order=s.map((e=>e.id)),this._layers={},this._serializedLayers={};for(const i of s){const t=e.createStyleLayer(i);t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(t){this._spriteRequest=function(t,n,s){let i,l,a;const r=e.exported.devicePixelRatio>1?"@2x":"";let o=e.getJSON(n.transformRequest(n.normalizeSpriteURL(t,r,".json"),e.ResourceType.SpriteJSON),((e,t)=>{o=null,a||(a=e,i=t,c())})),u=e.getImage(n.transformRequest(n.normalizeSpriteURL(t,r,".png"),e.ResourceType.SpriteImage),((e,t)=>{u=null,a||(a=e,l=t,c())}));function c(){if(a)s(a);else if(i&&l){const t=e.exported.getImageData(l),n={};for(const s in i){const{width:l,height:a,x:r,y:o,sdf:u,pixelRatio:c,stretchX:h,stretchY:p,content:d}=i[s],f=new e.RGBAImage({width:l,height:a});e.RGBAImage.copy(t,f,{x:r,y:o},{x:0,y:0},{width:l,height:a}),n[s]={data:f,pixelRatio:c,sdf:u,stretchX:h,stretchY:p,content:d}}s(null,n)}}return{cancel(){o&&(o.cancel(),o=null),u&&(u.cancel(),u=null)}}}(t,this.map._requestManager,((t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(n)for(const e in n)this.imageManager.addImage(e,n[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))}))}_validateLayer(t){const n=this.getSource(t.source);if(!n)return;const s=t.sourceLayer;s&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(s))&&this.fire(new e.ErrorEvent(new Error('Source layer "'.concat(s,'" does not exist on source "').concat(n.id,'" as specified by style layer "').concat(t.id,'"'))))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped():Kt[e.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(e.length||n.length)&&this._updateWorkerLayers(e,n);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const s in this._updatedPaintProps)this._layers[s].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const s={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];s[e]=t.used,t.used=!1}for(const e of this._order){const n=this._layers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this._getLayerSourceCache(n);e&&(e.used=!0)}const s=this.map.painter;if(s){const e=n.getProgramIds();if(!e)continue;const i=n.getProgramConfiguration(t.zoom);for(const t of e)s.useProgram(t,i)}}for(const i in s){const t=this._sourceCaches[i];s[i]!==t.used&&t.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),Yt(this,e.validateStyle(n)))return!1;(n=e.clone$1(n)).layers=ke(n.layers);const s=function(e,n){if(!e)return[{command:ze.setStyle,args:[n]}];let s=[];try{if(!t(e.version,n.version))return[{command:ze.setStyle,args:[n]}];t(e.center,n.center)||s.push({command:ze.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||s.push({command:ze.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||s.push({command:ze.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||s.push({command:ze.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||s.push({command:ze.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||s.push({command:ze.setGlyphs,args:[n.glyphs]}),t(e.transition,n.transition)||s.push({command:ze.setTransition,args:[n.transition]}),t(e.light,n.light)||s.push({command:ze.setLight,args:[n.light]}),t(e.fog,n.fog)||s.push({command:ze.setFog,args:[n.fog]}),t(e.projection,n.projection)||s.push({command:ze.setProjection,args:[n.projection]});const i={},l=[];!function(e,n,s,i){let l;for(l in n=n||{},e=e||{})e.hasOwnProperty(l)&&(n.hasOwnProperty(l)||je(l,s,i));for(l in n){if(!n.hasOwnProperty(l))continue;const a=n[l];e.hasOwnProperty(l)?t(e[l],a)||("geojson"===e[l].type&&"geojson"===a.type&&Ye(e,n,l)?s.push({command:ze.setGeoJSONSourceData,args:[l,a.data]}):We(l,n,s,i)):Ve(l,n,s)}}(e.sources,n.sources,l,i);const a=[];e.layers&&e.layers.forEach((e=>{e.source&&i[e.source]?s.push({command:ze.removeLayer,args:[e.id]}):a.push(e)}));let r=e.terrain;r&&i[r.source]&&(s.push({command:ze.setTerrain,args:[void 0]}),r=void 0),s=s.concat(l),t(r,n.terrain)||s.push({command:ze.setTerrain,args:[n.terrain]}),function(e,n,s){n=n||[];const i=(e=e||[]).map(Xe),l=n.map(Xe),a=e.reduce(Ze,{}),r=n.reduce(Ze,{}),o=i.slice(),u=Object.create(null);let c,h,p,d,f,m,I;for(c=0,h=0;c!(e.command in Xt)));if(0===s.length)return!1;const i=s.filter((e=>!(e.command in qt)));if(i.length>0)throw new Error("Unimplemented: ".concat(i.map((e=>e.command)).join(", "),"."));return s.forEach((e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=n,this._updateMapProjection(),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but only the following properties were given: ".concat(Object.keys(n).join(", "),"."));if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(e.validateSource,"sources.".concat(t),n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=_e(t,n,this.dispatcher,this);i.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:i.serialize(),sourceId:t})));const l=n=>{const s=(n?"symbol:":"other:")+t,l=this._sourceCaches[s]=new e.SourceCache(s,i,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[t]=l,l.style=this,l.onAdd(this.map)};l(!1),"vector"!==n.type&&"geojson"!==n.type||l(!0),i.onAdd&&i.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const n=this.getSource(t);if(!n)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.ErrorEvent(new Error('Source "'.concat(t,'" cannot be removed while layer "').concat(i,'" is using it.'))));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error('Source "'.concat(t,'" cannot be removed while terrain is using it.'))));const s=this._getSourceCaches(t);for(const i of s)delete this._sourceCaches[i.id],delete this._updatedSources[i.id],i.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:i.getSource().id})),i.setEventedParent(null),i.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}_getSources(){const e=[];for(const t in this._otherSourceCaches){const n=this._getSourceCache(t);n&&e.push(n.getSource())}return e}addLayer(t,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.ErrorEvent(new Error('Layer with id "'.concat(i,'" already exists on this map'))));let l;if("custom"===t.type){if(Yt(this,e.validateCustomStyleLayer(t)))return;l=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})),this._validate(e.validateLayer,"layers.".concat(i),t,{arrayIndex:-1},s))return;l=e.createStyleLayer(t),this._validateLayer(l),l.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[l.id]=l.serialize(),this._updateLayerCount(l,!0)}const a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)return void this.fire(new e.ErrorEvent(new Error('Layer with id "'.concat(n,'" does not exist on this map.'))));this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=l;const r=this._getLayerSourceCache(l);if(this._removedLayers[i]&&l.source&&r&&"custom"!==l.type){const e=this._removedLayers[i];delete this._removedLayers[i],e.type!==l.type?this._updatedSources[l.source]="clear":(this._updatedSources[l.source]="reload",r.pause())}this._updateLayer(l),l.onAdd&&l.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error("The layer '".concat(t,"' does not exist in the map's style and cannot be moved."))));if(t===n)return;const s=this._order.indexOf(t);this._order.splice(s,1);const i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new e.ErrorEvent(new Error('Layer with id "'.concat(n,'" does not exist on this map.')))):(this._order.splice(i,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new e.ErrorEvent(new Error("The layer '".concat(t,"' does not exist in the map's style and cannot be removed."))));n.setEventedParent(null),this._updateLayerCount(n,!1);const s=this._order.indexOf(t);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,n,s){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===n&&i.maxzoom===s||(null!=n&&(i.minzoom=n),null!=s&&(i.maxzoom=s),this._updateLayer(i)):this.fire(new e.ErrorEvent(new Error("The layer '".concat(t,"' does not exist in the map's style and cannot have zoom extent."))))}setFilter(n,s){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();const l=this.getLayer(n);if(l){if(!t(l.filter,s))return null==s?(l.filter=void 0,void this._updateLayer(l)):void(this._validate(e.validateFilter,"layers.".concat(l.id,".filter"),s,{layerType:l.type},i)||(l.filter=e.clone$1(s),this._updateLayer(l)))}else this.fire(new e.ErrorEvent(new Error("The layer '".concat(n,"' does not exist in the map's style and cannot be filtered."))))}getFilter(t){const n=this.getLayer(t);return n&&e.clone$1(n.filter)}setLayoutProperty(n,s,i){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();const a=this.getLayer(n);a?t(a.getLayoutProperty(s),i)||(a.setLayoutProperty(s,i,l),this._updateLayer(a)):this.fire(new e.ErrorEvent(new Error("The layer '".concat(n,"' does not exist in the map's style and cannot be styled."))))}getLayoutProperty(t,n){const s=this.getLayer(t);if(s)return s.getLayoutProperty(n);this.fire(new e.ErrorEvent(new Error("The layer '".concat(t,"' does not exist in the map's style."))))}setPaintProperty(n,s,i){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();const a=this.getLayer(n);a?t(a.getPaintProperty(s),i)||(a.setPaintProperty(s,i,l)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new e.ErrorEvent(new Error("The layer '".concat(n,"' does not exist in the map's style and cannot be styled."))))}getPaintProperty(e,t){const n=this.getLayer(e);return n&&n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const s=t.source,i=t.sourceLayer,l=this.getSource(s);if(!l)return void this.fire(new e.ErrorEvent(new Error("The source '".concat(s,"' does not exist in the map's style."))));const a=l.type;if("geojson"===a&&i)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const r=this._getSourceCaches(s);for(const e of r)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const s=t.source,i=this.getSource(s);if(!i)return void this.fire(new e.ErrorEvent(new Error("The source '".concat(s,"' does not exist in the map's style."))));const l=i.type,a="vector"===l?t.sourceLayer:void 0;if("vector"===l&&!a)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const r=this._getSourceCaches(s);for(const e of r)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,i=this.getSource(n);if(i){if("vector"!==i.type||s)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(s,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error("The source '".concat(n,"' does not exist in the map's style."))))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const n=this._sourceCaches[e].getSource();t[n.id]||(t[n.id]=n.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:t,layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,n={},s=[];for(let l=this._order.length-1;l>=0;l--){const i=this._order[l];if(t(i)){n[i]=l;for(const t of e){const e=t[i];if(e)for(const t of e)s.push(t)}}}s.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const i=[];for(let l=this._order.length-1;l>=0;l--){const a=this._order[l];if(t(a))for(let e=s.length-1;e>=0;e--){const t=s[e].feature;if(n[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),r=O.createFromScreenPoints(t,s);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;n.layers&&!i[t]||l.push(Ne(this._sourceCaches[e],this._layers,this._serializedLayers,r,n,s,a,!!this.map._showQueryGeometry))}return this.placement&&l.push(function(e,t,n,s,i,l,a){const r={},o=l.queryRenderedSymbols(s),u=[];for(const c of Object.keys(o).map(Number))u.push(a[c]);u.sort(Pe);for(const c of u){const n=c.featureIndex.lookupSymbolFeatures(o[c.bucketInstanceId],t,c.bucketIndex,c.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in n){const t=r[e]=r[e]||[],s=n[e];s.sort(((e,t)=>{const n=c.featureSortOrder;if(n){const s=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-s}return t.featureIndex-e.featureIndex}));for(const e of s)t.push(e)}}for(const c in r)r[c].forEach((t=>{const s=t.feature,i=n(e[c]);if(!i)return;const l=i.getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=l}));return r}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),r.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(l)}querySourceFeatures(t,n){n&&n.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const s=this._getSourceCaches(t);let i=[];for(const e of s)i=i.concat(Le(e,n));return i}addSourceType(e,t,n){return Qt.getSourceType(e)?n(new Error('A source type called "'.concat(e,'" already exists.'))):(Qt.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._checkLoaded();const s=this.light.getLight();let i=!1;for(const a in e)if(!t(e[a],s[a])){i=!0;break}if(!i)return;const l=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,n),this.light.updateTransitions(l)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=n;if(1===s){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.clone$1(i),i=e.extend(i,{source:t})}if(this._validate(e.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&s!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,s)}else{const n=this.terrain,s=n.get();for(const t of Object.keys(e.spec.terrain))!i.hasOwnProperty(t)&&e.spec.terrain[t].default&&(i[t]=e.spec.terrain[t].default);for(const e in i)if(!t(i[e],s[e])){n.set(i),this.stylesheet.terrain=i;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new C(e,this.map.transform);this.stylesheet.fog=e;const n=this._setTransitionParameters({duration:0});t.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,s=n.get();0===Object.keys(e).length&&n.set(e);for(const i in e)if(!t(e[i],s[i])){n.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter((e=>this.isLayerDraped(this._layers[e]))),t=this._order.filter((e=>!this.isLayerDraped(this._layers[e])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new R(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const s=this._setTransitionParameters({duration:0});n.updateTransitions(s)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,n,s,i){let l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return(!l||!1!==l.validate)&&Yt(this,t.call(e.validateStyle,e.extend({key:n,style:this.serialize(),value:s,styleSpec:e.spec},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const n of t)n.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const n of t)n.resume(),n.reload()}_reloadSources(){for(const e of this._getSources())e.reload&&e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,s,i){let l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=!1,r=!1;const o={};for(const e of this._order){const n=this._layers[e];if("symbol"!==n.type)continue;if(!o[n.source]){const e=this._getLayerSourceCache(n);if(!e)continue;o[n.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const s=this.crossTileSymbolIndex.addLayer(n,o[n.source],t.center.lng,t.projection);a=a||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),l=l||this._layerOrderChanged||0===s,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(l||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Gt(t,this._order,l,n,s,i,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),r=!0),a&&this.pauseablePlacement.placement.setStale()),r||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,o[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,n){this.imageManager.getImages(t.icons,n),this._updateTilesForChangedImages();const s=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};s(this._otherSourceCaches[t.source]),s(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,n)}getResource(t,n,s){return e.makeRequest(n,s)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this._getSourceCaches(t);return 0===n.length?(this.fire(new e.ErrorEvent(new Error("There is no source with ID '".concat(t,"'")))),!1):n.every((e=>e.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Qt.getSourceType=function(e){return xe[e]},Qt.setSourceType=function(e,t){xe[e]=t},Qt.registerForPluginStateChange=e.registerForPluginStateChange;var Jt="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",$t="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",en="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",tn="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",nn="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif";let sn={},ln={};const an=[];hn(Jt,an),hn(en,an),hn(tn,an),hn(nn,an),sn=pn("",en),ln=pn(nn,tn);const rn=pn("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\n#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\n#endif\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),on=Jt,un="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var cn={background:pn("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:pn("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:pn("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:pn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:pn("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:pn("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:pn("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:pn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:pn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:pn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:pn("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:pn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:pn("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_NdotL=NdotL;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:pn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:pn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:pn("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);\n#endif\n}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:pn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:pn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:pn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:pn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:pn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:pn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=wireframeOffset;\n#endif\nv_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:pn("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:pn("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",$t),skyboxGradient:pn("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",$t),skyboxCapture:pn("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:pn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:pn("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function hn(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let s of n)if(s=s.trim(),"#"===s[0]&&s.includes("if")&&!s.includes("endif")){s=s.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const e=s.split(" ");for(const n of e)t.includes(n)||t.push(n)}}function pn(e,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),i={},l=[...an];return hn(e,l),hn(t,l),{fragmentSource:e=e.replace(n,((e,t,n,s,l)=>(i[l]=!0,"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(l,"\nvarying ").concat(n," ").concat(s," ").concat(l,";\n#else\nuniform ").concat(n," ").concat(s," u_").concat(l,";\n#endif\n"):"\n#ifdef HAS_UNIFORM_u_".concat(l,"\n ").concat(n," ").concat(s," ").concat(l," = u_").concat(l,";\n#endif\n")))),vertexSource:t=t.replace(n,((e,t,n,s,l)=>{const a="float"===s?"vec2":"vec4",r=l.match(/color/)?"color":a;return i[l]?"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(l,"\nuniform lowp float u_").concat(l,"_t;\nattribute ").concat(n," ").concat(a," a_").concat(l,";\nvarying ").concat(n," ").concat(s," ").concat(l,";\n#else\nuniform ").concat(n," ").concat(s," u_").concat(l,";\n#endif\n"):"vec4"===r?"\n#ifndef HAS_UNIFORM_u_".concat(l,"\n ").concat(l," = a_").concat(l,";\n#else\n ").concat(n," ").concat(s," ").concat(l," = u_").concat(l,";\n#endif\n"):"\n#ifndef HAS_UNIFORM_u_".concat(l,"\n ").concat(l," = unpack_mix_").concat(r,"(a_").concat(l,", u_").concat(l,"_t);\n#else\n ").concat(n," ").concat(s," ").concat(l," = u_").concat(l,";\n#endif\n"):"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(l,"\nuniform lowp float u_").concat(l,"_t;\nattribute ").concat(n," ").concat(a," a_").concat(l,";\n#else\nuniform ").concat(n," ").concat(s," u_").concat(l,";\n#endif\n"):"vec4"===r?"\n#ifndef HAS_UNIFORM_u_".concat(l,"\n ").concat(n," ").concat(s," ").concat(l," = a_").concat(l,";\n#else\n ").concat(n," ").concat(s," ").concat(l," = u_").concat(l,";\n#endif\n"):"\n#ifndef HAS_UNIFORM_u_".concat(l,"\n ").concat(n," ").concat(s," ").concat(l," = unpack_mix_").concat(r,"(a_").concat(l,", u_").concat(l,"_t);\n#else\n ").concat(n," ").concat(s," ").concat(l," = u_").concat(l,";\n#endif\n")})),staticAttributes:s,usedDefines:l}}class dn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,s,i,l,a){this.context=e;let r=this.boundPaintVertexBuffers.length!==s.length;for(let u=0;!r&&u{const i=n.paint.get("hillshade-shadow-color"),l=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color");let r=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(r-=e.transform.angle);const o=!e.options.moving;return{u_matrix:s||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),o),u_image:0,u_latrange:fn(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),r],u_shadow:i,u_highlight:l,u_accent:a}})(t,s,i,t.terrain?n.projMatrix:null);t.prepareDrawProgram(o,h,n.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(s);h.draw(o,u.TRIANGLES,l,a,r,e.CullFaceMode.disabled,p,i.id,d,f,m)}function In(t,n,s){if(!n.needsDEMTextureUpload)return;const i=t.context,l=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(s.stride);const a=s.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.Texture(i,a,l.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function yn(t,n,s,i,l,a){const r=t.context,o=r.gl;if(!n.dem)return;const u=n.dem;if(r.activeTexture.set(o.TEXTURE1),In(t,n,u),!n.demTexture)return;n.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const c=u.dim;r.activeTexture.set(o.TEXTURE0);let h=n.fbo;if(!h){const t=new e.Texture(r,{width:c,height:c,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),h=n.fbo=r.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}r.bindFramebuffer.set(h.framebuffer),r.viewport.set([0,0,c,c]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(r,o.TRIANGLES,i,l,a,e.CullFaceMode.disabled,((t,n)=>{const s=n.stride,i=e.create();return e.ortho(i,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(i,i,[0,-e.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[s,s],u_zoom:t.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,u),s.id,p,d,f),n.needsHillshadePrepare=!1}const vn=t=>({u_matrix:new e.UniformMatrix4f(t),u_image0:new e.Uniform1i(t),u_skirt_height:new e.Uniform1f(t)}),En=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),wn=(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(s),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:l,u_image0:0,u_frustum_tl:a,u_frustum_tr:r,u_frustum_br:o,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:h,u_viewport:p,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:d});function gn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Tn=new class{constructor(){this.operations={}}newMorphing(e,t,n,s,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:s,phase:0,duration:i,from:t,to:n,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},bn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Rn(e){return 6*Math.pow(1.5,22-e)}function Sn(e,t){const n=1<({u_matrix:e});function An(t,n,s,i,l){if(l>0){const a=e.exported.now(),r=(a-t.timeAdded)/l,o=n?(a-n.timeAdded)/l:-1,u=s.getSource(),c=i.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),p=h&&t.refreshedUponExpiration?1:e.clamp(h?r:1-o,0,1);return t.refreshedUponExpiration&&r>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Cn extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new x(Ue(),null),s=_e("mock-dem",t,n,e.style);super("mock-dem",s,!1),s.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class xn extends e.SourceCache{constructor(e){const t=_e("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new x(Ue(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,s){if(t.freezeTileCoverage)return;this.transform=t;const i=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((n,s)=>{if(n[s.key]="",!this._tiles[s.key]){const n=new e.Tile(s,this._source.tileSize*s.overscaleFactor(),t.tileZoom);n.state="loaded",this._tiles[s.key]=n}return n}),{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class _n extends e.OverscaledTileID{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class On extends e.Elevation{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[s,i,l]=function(t){const n=new e.StructArrayLayout2i4,s=new e.StructArrayLayout3ui6,i=131;n.reserve(17161),s.reserve(33800);const l=e.EXTENT/128,a=e.EXTENT+l/2,r=a+l;for(let u=-l;ua||u<0||u>a?24575:0,i=e.clamp(Math.round(t),0,e.EXTENT),l=e.clamp(Math.round(u),0,e.EXTENT);n.emplaceBack(i+s,l)}const o=(e,t)=>{const n=t*i+e;s.emplaceBack(n+1,n,n+i),s.emplaceBack(n+i,n+i+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)o(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)o(t,e),o(e,t)})),[n,s,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(s,e.posAttributes.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.SegmentVector.simpleSegment(0,0,s.length,i.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,s.length,l),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new xn(n.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.EXTENT,0,e.EXTENT,0,1);const r=a.gl;this._overlapStencilMode=new e.StencilMode({func:r.GEQUAL,mask:255},0,255,r.KEEP,r.KEEP,r.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cn(n.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,n,s){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const i=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(i.get("source")),this._exaggeration=i.get("exaggeration");const l=()=>{this.sourceCache.used&&e.warnOnce("Raster DEM source '".concat(this.sourceCache.id,"' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source."));const t=this.getScaledDemTileSize();this.sourceCache.update(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,l(),this._initializing=!0),l(),n.updateElevation(!0,s),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce("Terrain render cache efficiency is not optimal (".concat(t.efficiency,"%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '").concat(t.firstUndrapedLayer,"' or create a map using optimizeForTerrain: true option."))}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,s=this.painter.transform;this._initializing&&(this._initializing=0===s._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(s.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map((e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=s.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,n){const s=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.Point(s.x,s.y);t.sort(((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const s=new e.Point(t.canonical.x+(1<{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],l),n.usedForTerrain)continue;const s=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(s)}this.proxiedCoords[n.id]=i.map((e=>new _n(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(l),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const r={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in r||(this._visibleDemTiles.push(t),r[n]=n)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const n in this.terrainTileForTile){const s=this.terrainTileForTile[n],i=s.dem;!i||s.demTexture&&!s.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),In(this.painter,s,i))}}_prepareDemTileUniforms(e,t,n,s){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,l=Math.pow(2,t.tileID.canonical.z-i.z),a=s||"";return n["u_dem_tl".concat(a)]=[i.x*l%1,i.y*l%1],n["u_dem_scale".concat(a)]=l,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const s=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,s,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,n)=>{if(!n.dem)return t;const s=n.dem.tree.minimums[0];return s>0&&e++,t+s}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const s=this._getLoadedAreaMinimum(),i=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(s,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let l=this._emptyDEMTexture;return l?l.update(i,{premultiply:!1}):l=this._emptyDEMTexture=new e.Texture(t,i,n.RGBA,{premultiply:!1}),l}setupElevationDraw(t,n,s){const i=this.painter.context,l=i.gl,a=(r=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(r),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var r;a.u_dem_size=this.sourceCache.getSource().tileSize,a.u_exaggeration=this.exaggeration();let o=null,u=null,c=1;if(s&&s.morphing&&this._useVertexMorphing){const e=s.morphing.srcDemTile,n=s.morphing.dstDemTile;c=s.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(u=e),this._prepareDemTileUniforms(t,n,a)&&(o=n))}if(u&&o?(i.activeTexture.set(l.TEXTURE2),o.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),i.activeTexture.set(l.TEXTURE4),u.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),a.u_dem_lerp=c):(o=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(l.TEXTURE2),(this._prepareDemTileUniforms(t,o,a)?o.demTexture:this.emptyDEMTexture).bind(l.NEAREST,l.CLAMP_TO_EDGE)),i.activeTexture.set(l.TEXTURE3),s&&s.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),s&&s.useMeterToDem&&o){const t=(1<{if(u===e)return;const s=[bn[e],"PROJECTION_GLOBE_VIEW"];p&&s.push("CUSTOM_ANTIALIASING"),n&&s.push(bn[c]),o=t.useProgram("globeRaster",null,s),u=e},f=t.colorModeForRenderPass(),m=new e.DepthMode(r.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(l);const I=e.calculateGlobeMercatorMatrix(h),y=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],v=c?[!1,!0]:[!1],E=t.globeSharedBuffers,w=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio],g=Float32Array.from(h.globeMatrix),T={useDenormalizedUpVectorScale:!0};if(v.forEach((c=>{const h=t.transform,p=Rn(h.zoom)*n.exaggeration();u=-1;const v=c?r.LINES:r.TRIANGLES;for(const u of i){const i=s.getTile(u),b=e.StencilMode.disabled,R=n.prevTerrainTileForTile[u.key],S=n.terrainTileForTile[u.key];gn(R,S)&&Tn.newMorphing(u.key,R,S,l,250),a.activeTexture.set(r.TEXTURE0),i.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE);const D=Tn.getMorphValuesForProxy(u.key),A=D?1:0;D&&e.extend$1(T,{morphing:{srcDemTile:D.from,dstDemTile:D.to,phase:e.easeCubicInOut(D.phase)}});const C=e.tileCornersToBounds(u.canonical),x=e.getLatitudinalLod(C.getCenter().lat),_=e.getGridMatrix(u.canonical,C,x,h.worldSize/h._pixelsPerMercatorPixel),O=e.globeNormalizeECEF(e.globeTileBounds(u.canonical)),N=wn(h.projMatrix,g,I,O,e.globeToMercatorTransition(h.zoom),y,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,w,p,_);if(d(A,c),n.setupElevationDraw(i,o,T),t.prepareDrawProgram(a,o,u.toUnwrapped()),E){const[n,s,i]=c?E.getWirefameBuffers(t.context,x):E.getGridBuffers(x,0!==p);o.draw(a,v,m,b,f,e.CullFaceMode.backCCW,N,"globe_raster",n,s,i)}}})),E){const l=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&l.push("CUSTOM_ANTIALIASING"),o=t.useProgram("globeRaster",null,l);for(const u of i){const{x:i,y:l,z:c}=u.canonical,p=0===l,d=l===(1<t.draw(a,r.TRIANGLES,m,e.StencilMode.disabled,f,e.CullFaceMode.disabled,wn(h.projMatrix,E,E,R,0,y,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,w,0),"globe_pole_raster",n,g,b);n.setupElevationDraw(l,o,T),t.prepareDrawProgram(a,o,u.toUnwrapped()),p&&S(o,I),d&&(E=e.scale(e.create(),E,[1,-1,1]),S(o,v))}}}}(t,n,s,i,l);else{const a=t.context,r=a.gl;let o,u;const c=t.options.showTerrainWireframe?2:0,h=(e,n)=>{if(u===e)return;const s=[bn[e]];n&&s.push(bn[c]),o=t.useProgram("terrainRaster",null,s),u=e},p=t.colorModeForRenderPass(),d=new e.DepthMode(r.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(l);const f=t.transform,m=Rn(f.zoom)*n.exaggeration();(c?[!1,!0]:[!1]).forEach((c=>{u=-1;const I=c?r.LINES:r.TRIANGLES,[y,v]=c?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const u of i){const i=s.getTile(u),E=e.StencilMode.disabled,w=n.prevTerrainTileForTile[u.key],g=n.terrainTileForTile[u.key];gn(w,g)&&Tn.newMorphing(u.key,w,g,l,250),a.activeTexture.set(r.TEXTURE0),i.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST);const T=Tn.getMorphValuesForProxy(u.key),b=T?1:0;let R;T&&(R={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.easeCubicInOut(T.phase)}});const S=En(u.projMatrix,Sn(u.canonical,f.renderWorldCopies)?m/10:m);h(b,c),n.setupElevationDraw(i,o,R),t.prepareDrawProgram(a,o,u.toUnwrapped()),o.draw(a,I,d,E,p,e.CullFaceMode.backCCW,S,"terrain_raster",n.gridBuffer,y,v)}}))}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,s=this.painter.context,i=this.proxySourceCache,l=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),r=[],o=n.style.order;let u=0;for(const c of l){const l=i.getTileByID(c.proxyTileKey),h=i.proxyCachedFBO[c.key]?i.proxyCachedFBO[c.key][t]:void 0,p=void 0!==h?i.renderCache[h]:this.pool[u++],d=void 0!==h;if(l.texture=p.tex,d&&!p.dirty){r.push(l.tileID);continue}let f;s.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(s.clear({color:e.Color.transparent,stencil:0}),p.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._layers[o[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style._getLayerSourceCache(t),l=i?this.proxyToSource[c.key][i.id]:[c];if(!l)continue;const a=l;s.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(i?i.id:null)&&(this._setupStencil(p,l,t,i),f=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(p.dirty=!0,r.push(l.tileID)):d||--u,5===u&&(u=0,this.renderToBackBuffer(r))}return this.renderToBackBuffer(r),this.renderingToTexture=!1,s.bindFramebuffer.set(null),s.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let n,s=0,i=0,l=!1;for(let a=0;ae.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,n){if(!this._visibleDemTiles)return null;const s=this._visibleDemTiles.filter((e=>e.dem)).map((s=>{const i=s.tileID,l=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const i of s){if(null==i.t)return null;const s=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=s)return s}return null}_createFBO(){const t=this.painter.context,n=t.gl,s=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.Texture(t,{width:s[0],height:s[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const l=t.createFramebuffer(s[0],s[1],!1);return l.colorAttachment.set(i.texture),l.depthAttachment=new Te(t,l.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,s[0],s[1]),this._stencilRef=0,l.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):l.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:l,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style._getSources())if(e instanceof Se){t=!0;break}if(!t)return;const n={};for(let s=0;st.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let n=0;n=0;l--){const i=n[l];if(t.getTileByID(i.key),void 0!==t.proxyCachedFBO[i.key]){const n=e[i.key],l=this.proxyToSource[i.key];let a=0;for(const e in l){const t=l[e],i=n[e];if(!i||i.length!==t.length||t.some(((t,n)=>t!==i[n]||s[e]&&s[e].hasOwnProperty(t.key)))){a=-1;break}++a}for(const e in t.proxyCachedFBO[i.key])t.renderCache[t.proxyCachedFBO[i.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const l of i)for(const e of n){if(t.proxyCachedFBO[e.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[e.key]={},t.proxyCachedFBO[e.key][l.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,s){if(!s||!this._sourceTilesOverlap[s.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,l=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=t.length,this._overlapStencilMode.test={func:l.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:l.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,n){const s=this.painter,i=this.painter.context,l=i.gl;s._tileClippingMaskIDs={},i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=s.useProgram("clippingMask");for(const r of t){const t=s._tileClippingMaskIDs[r.key]=--n;a.draw(i,l.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:l.ALWAYS,mask:0},t,255,l.KEEP,l.KEEP,l.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Dn(r.projMatrix),"$clipping",s.tileExtentBuffer,s.quadTriangleIndexBuffer,s.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const s=[t.x,t.y,1,1];e.transformMat4$1(s,s,n.pixelMatrixInverse),e.scale$1(s,s,1/s[3]),s[0]/=n.worldSize,s[1]/=n.worldSize;const i=n._camera.position,l=e.mercatorZfromAltitude(1,n.center.lat),a=[i[0],i[1],i[2]/l,0],r=e.subtract([],s.slice(0,3),a);e.normalize(r,r);const o=this.raycast(a,r,this._exaggeration);return null!==o&&o?(e.scaleAndAdd(a,a,r,o),a[3]=a[2],a[2]*=l,a):null}drawDepth(){const t=this.painter,n=t.context,s=this.proxySourceCache,i=Math.ceil(t.width),l=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===l||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,s=n.createFramebuffer(i,l,!0);n.activeTexture.set(t.TEXTURE0);const a=new e.Texture(n,{width:i,height:l,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),s.colorAttachment.set(a.texture);const r=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,l);s.depthAttachment.set(r),this._depthFBO=s,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,l]),function(t,n,s,i){if("globe"===t.transform.projection.name)return;const l=t.context,a=l.gl;l.clear({depth:1});const r=t.useProgram("terrainDepth"),o=new e.DepthMode(a.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const u of i){const t=s.getTile(u),i=En(u.projMatrix,0);n.setupElevationDraw(t,r),r.draw(l,a.TRIANGLES,o,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,i,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(t,this,s,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof Ce)return this._setupProxiedCoordsForImageSource(e,t,n);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const s=this.proxiedCoords[e.id]=[],i=this.proxyCoords;for(let a=0;a(e.min.x=Math.min(e.min.x,t.x-r.x),e.min.y=Math.min(e.min.y,t.y-r.y),e.max.x=Math.max(e.max.x,t.x-r.x),e.max.y=Math.max(e.max.y,t.y-r.y),e)),{min:new e.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const s=t.wrap+t.canonical.x/(1<a+o.max.x||i+lr+o.max.y};for(let e=0;ee.key===n.tileID.key));if(e)return e}if(n.tileID.key!==t.key){const s=t.canonical.z-n.tileID.canonical.z;let l,a,r;i=e.create();const o=n.tileID.wrap-t.wrap<0?(l=e.EXTENT>>s,a=l*((n.tileID.canonical.x<=i){const s=t.canonical.z-i;n.getSource().reparseOverscaled?(r=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.OverscaledTileID(r,t.wrap,i,t.canonical.x>>s,t.canonical.y>>s)):0!==s&&(r=i,a=new e.OverscaledTileID(r,t.wrap,i,t.canonical.x>>s,t.canonical.y>>s))}a.key!==t.key&&(u.push(a.key),s=n.getTile(a))}const c=e=>{u.forEach((t=>{i[t]=e})),u.length=0};for(r-=1;r>=o&&(!s||!s.hasData());r--){s&&c(s.tileID.key);const e=a.calculateScaledKey(r);if(s=n.getTileByID(e),s&&s.hasData())break;const t=i[e];if(null===t)break;void 0===t?u.push(e):s=n.getTileByID(t)}return c(s?s.tileID.key:null),s&&s.hasData()?s:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let n=0;const s=new e.StructArrayLayout2ui4,i=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)n=e*i+t,s.emplaceBack(n,n+1),s.emplaceBack(n,n+i),s.emplaceBack(n+1,n+i),128===e&&s.emplaceBack(n+i,n+i+1);s.emplaceBack(n+1,n+1+i)}return s}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Nn{static cacheKey(e,t,n,s){let i="".concat(t).concat(s?s.cacheKey:"");for(const l of n)e.usedDefines.includes(l)&&(i+="/".concat(l));return i}constructor(t,n,s,i,l,a){const r=t.gl;this.program=r.createProgram();const o=function(e){const t=[];for(let n=0;n"#define ".concat(e))));const p=t.isWebGL2?"#version 300 es\n":"",d=p+h.concat(t.extStandardDerivatives&&0===p.length?"#extension GL_OES_standard_derivatives : enable\n".concat(un):un,un,on,rn.fragmentSource,ln.fragmentSource,s.fragmentSource).join("\n"),f=p+h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",on,rn.vertexSource,ln.vertexSource,sn.vertexSource,s.vertexSource).join("\n"),m=r.createShader(r.FRAGMENT_SHADER);if(r.isContextLost())return void(this.failedToCreate=!0);r.shaderSource(m,d),r.compileShader(m),r.attachShader(this.program,m);const I=r.createShader(r.VERTEX_SHADER);if(r.isContextLost())this.failedToCreate=!0;else{r.shaderSource(I,f),r.compileShader(I),r.attachShader(this.program,I),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.Uniform1i(t),u_dem_prev:new e.Uniform1i(t),u_dem_unpack:new e.Uniform4f(t),u_dem_tl:new e.Uniform2f(t),u_dem_scale:new e.Uniform1f(t),u_dem_tl_prev:new e.Uniform2f(t),u_dem_scale_prev:new e.Uniform1f(t),u_dem_size:new e.Uniform1f(t),u_dem_lerp:new e.Uniform1f(t),u_exaggeration:new e.Uniform1f(t),u_depth:new e.Uniform1i(t),u_depth_size_inv:new e.Uniform2f(t),u_meter_to_dem:new e.Uniform1f(t),u_label_plane_matrix_inv:new e.UniformMatrix4f(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.Uniform3f(t),u_tile_tr_up:new e.Uniform3f(t),u_tile_br_up:new e.Uniform3f(t),u_tile_bl_up:new e.Uniform3f(t),u_tile_up_scale:new e.Uniform1f(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.UniformMatrix4f(t),u_fog_range:new e.Uniform2f(t),u_fog_color:new e.Uniform4f(t),u_fog_horizon_blend:new e.Uniform1f(t),u_fog_temporal_offset:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_globe_transition:new e.Uniform1f(t),u_is_globe:new e.Uniform1i(t),u_viewport:new e.Uniform2f(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}draw(e,t,n,s,i,l,a,r,o,u,c,h,p,d,f){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(s),e.setColorMode(i),e.setCullFace(l);for(const y of Object.keys(this.fixedUniforms))this.fixedUniforms[y].set(this.program,y,a[y]);d&&d.setUniforms(this.program,e,this.binderUniforms,h,{zoom:p});const I={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const y of c.get()){const n=y.vaos||(y.vaos={});(n[r]||(n[r]=new dn)).bind(e,this,o,d?d.getPaintVertexBuffers():[],u,y.vertexOffset,f||[]),m.drawElements(t,y.primitiveLength*I,m.UNSIGNED_SHORT,y.primitiveOffset*I*2)}}}function Ln(e,t){const n=Math.pow(2,t.tileID.overscaledZ),s=t.tileSize*Math.pow(2,e.transform.tileZoom)/n,i=s*(t.tileID.canonical.x+t.tileID.wrap*n),l=s*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture.size,u_tile_units_to_pixels:1/_(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,l>>16],u_pixel_coord_lower:[65535&i,65535&l]}}const Pn=e.create(),Mn=(t,n,s,i,l,a,r,o,u,c,h)=>{const p=n.style.light,d=p.properties.get("position"),f=[d.x,d.y,d.z],m=e.create$1();"viewport"===p.properties.get("anchor")&&(e.fromRotation(m,-n.transform.angle),e.transformMat3(f,f,m));const I=p.properties.get("color"),y=n.transform,v={u_matrix:t,u_lightpos:f,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[I.r,I.g,I.b],u_vertical_gradient:+s,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Pn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:l,u_edge_radius:a};return"globe"===y.projection.name&&(v.u_tile_id=[r.canonical.x,r.canonical.y,1<{const d=Mn(t,n,s,i,l,a,r,u,c,h,p),f={u_height_factor:-Math.pow(2,r.overscaledZ)/o.tileSize/8};return e.extend(d,Ln(n,o),f)},Bn=e=>({u_matrix:e}),Hn=(t,n,s)=>e.extend(Bn(t),Ln(n,s)),Un=(e,t)=>({u_matrix:e,u_world:t}),Gn=(t,n,s,i)=>e.extend(Hn(t,n,s),{u_world:i}),kn=e.create(),zn=(t,n,s,i,l,a)=>{const r=t.transform,o="globe"===r.projection.name;let u;if("map"===a.paint.get("circle-pitch-alignment"))if(o){const t=e.globePixelsToTileUnits(r.zoom,n.canonical)*r._pixelsPerMercatorPixel;u=Float32Array.from([t,0,0,t])}else u=r.calculatePixelsToTileUnitsMatrix(s);else u=new Float32Array([r.pixelsToGLUnits[0],0,0,r.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:r.cameraToCenterDistance,u_matrix:t.translatePosMatrix(n.projMatrix,s,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:u,u_inv_rot_matrix:kn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(o){c.u_inv_rot_matrix=i,c.u_merc_center=l,c.u_tile_id=[n.canonical.x,n.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},jn=(t,n,s,i)=>{const l=e.EXTENT/s.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/l,n.pixelsToGLUnits[1]/l]}},Wn=function(e,t){return{u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:arguments.length>2&&void 0!==arguments[2]?arguments[2]:1}},Yn=e.create(),qn=(t,n,s,i,l,a,r)=>{const o=t.transform,u="globe"===o.projection.name,c=u?e.globePixelsToTileUnits(o.zoom,n.canonical)*o._pixelsPerMercatorPixel:_(s,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:c,u_intensity:r,u_inv_rot_matrix:Yn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=i,h.u_merc_center=l,h.u_tile_id=[n.canonical.x,n.canonical.y,1<{const r=e.transform,o=r.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Qn(e,t,n,s),u_pixels_to_tile_units:o,u_device_pixel_ratio:l,u_units_to_pixels:[1/r.pixelsToGLUnits[0],1/r.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Jn(n)?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Kn(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a}},Zn=(e,t,n,s,i)=>{const l=e.transform;return{u_matrix:Qn(e,t,n,s),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:l.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Kn(t,l),u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Kn(e,t){return 1/_(e,1,t.tileZoom)}function Qn(e,t,n,s){return e.translatePosMatrix(s||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function Jn(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const $n=(e,t,n,s,i,l)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:n,u_fade_t:s.mix,u_opacity:s.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(r=i.paint.get("raster-saturation"),r>0?1-1/(1.001-r):-r),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:es(i.paint.get("raster-hue-rotate")),u_perspective_transform:l};var a,r};function es(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const ts=e.create(),ns=(t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I)=>{const y=l.transform,v={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:y.cameraToCenterDistance,u_rotate_symbol:+s,u_aspect_ratio:y.width/y.height,u_fade_change:l.options.fadeDuration?l.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:r,u_coord_matrix:o,u_is_text:+u,u_pitch_with_map:+i,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ts,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ts,u_up_vector:[0,-1,0]};return"globe"===I.name&&(v.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(ns(t,n,s,i,l,a,r,o,u,c,p,d,f,m,I,y),{u_gamma_scale:i?l.transform.cameraToCenterDistance*Math.cos(l.terrain?0:l.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),is=(t,n,s,i,l,a,r,o,u,c,h,p,d,f,m,I)=>e.extend(ss(t,n,s,i,l,a,r,o,!0,u,!0,h,p,d,f,m,I),{u_texsize_icon:c,u_texture_icon:1}),ls=(e,t,n)=>({u_matrix:e,u_opacity:t,u_color:n}),as=(t,n,s,i,l)=>e.extend(function(e,t,n){const s=t.imageManager.getPattern(e.toString()),{width:i,height:l}=t.imageManager.getPixelSize(),a=Math.pow(2,n.tileID.overscaledZ),r=n.tileSize*Math.pow(2,t.transform.tileZoom)/a,o=r*(n.tileID.canonical.x+n.tileID.wrap*a),u=r*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:s.tl,u_pattern_br:s.br,u_texsize:[i,l],u_pattern_size:s.displaySize,u_tile_units_to_pixels:1/_(n,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,u>>16],u_pixel_coord_lower:[65535&o,65535&u]}}(i,s,l),{u_matrix:t,u_opacity:n}),rs={fillExtrusion:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t)}),fillExtrusionPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_height_factor:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t)}),fill:t=>({u_matrix:new e.UniformMatrix4f(t)}),fillPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),fillOutline:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t)}),fillOutlinePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),circle:t=>({u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),collisionBox:t=>({u_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.Uniform2f(t)}),collisionCircle:t=>({u_matrix:new e.UniformMatrix4f(t),u_inv_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_viewport_size:new e.Uniform2f(t)}),debug:t=>({u_color:new e.UniformColor(t),u_matrix:new e.UniformMatrix4f(t),u_overlay:new e.Uniform1i(t),u_overlay_scale:new e.Uniform1f(t)}),clippingMask:t=>({u_matrix:new e.UniformMatrix4f(t)}),heatmap:t=>({u_extrude_scale:new e.Uniform1f(t),u_intensity:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),heatmapTexture:t=>({u_image:new e.Uniform1i(t),u_color_ramp:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t)}),hillshade:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_latrange:new e.Uniform2f(t),u_light:new e.Uniform2f(t),u_shadow:new e.UniformColor(t),u_highlight:new e.UniformColor(t),u_accent:new e.UniformColor(t)}),hillshadePrepare:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_dimension:new e.Uniform2f(t),u_zoom:new e.Uniform1f(t),u_unpack:new e.Uniform4f(t)}),line:t=>({u_matrix:new e.UniformMatrix4f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_units_to_pixels:new e.Uniform2f(t),u_dash_image:new e.Uniform1i(t),u_gradient_image:new e.Uniform1i(t),u_image_height:new e.Uniform1f(t),u_texsize:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t),u_trim_offset:new e.Uniform2f(t)}),linePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_texsize:new e.Uniform2f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_units_to_pixels:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t)}),raster:t=>({u_matrix:new e.UniformMatrix4f(t),u_tl_parent:new e.Uniform2f(t),u_scale_parent:new e.Uniform1f(t),u_fade_t:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_image0:new e.Uniform1i(t),u_image1:new e.Uniform1i(t),u_brightness_low:new e.Uniform1f(t),u_brightness_high:new e.Uniform1f(t),u_saturation_factor:new e.Uniform1f(t),u_contrast_factor:new e.Uniform1f(t),u_spin_weights:new e.Uniform3f(t),u_perspective_transform:new e.Uniform2f(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_texture:new e.Uniform1i(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_is_halo:new e.Uniform1i(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texsize_icon:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_texture_icon:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_is_halo:new e.Uniform1i(t)}),background:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_color:new e.UniformColor(t)}),backgroundPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_pattern_tl:new e.Uniform2f(t),u_pattern_br:new e.Uniform2f(t),u_texsize:new e.Uniform2f(t),u_pattern_size:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),terrainRaster:vn,terrainDepth:vn,skybox:t=>({u_matrix:new e.UniformMatrix4f(t),u_sun_direction:new e.Uniform3f(t),u_cubemap:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxGradient:t=>({u_matrix:new e.UniformMatrix4f(t),u_color_ramp:new e.Uniform1i(t),u_center_direction:new e.Uniform3f(t),u_radius:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxCapture:t=>({u_matrix_3f:new e.UniformMatrix3f(t),u_sun_direction:new e.Uniform3f(t),u_sun_intensity:new e.Uniform1f(t),u_color_tint_r:new e.Uniform4f(t),u_color_tint_m:new e.Uniform4f(t),u_luminance:new e.Uniform1f(t)}),globeRaster:t=>({u_proj_matrix:new e.UniformMatrix4f(t),u_globe_matrix:new e.UniformMatrix4f(t),u_normalize_matrix:new e.UniformMatrix4f(t),u_merc_matrix:new e.UniformMatrix4f(t),u_zoom_transition:new e.Uniform1f(t),u_merc_center:new e.Uniform2f(t),u_image0:new e.Uniform1i(t),u_grid_matrix:new e.UniformMatrix3f(t),u_skirt_height:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_viewport:new e.Uniform2f(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_horizon:new e.Uniform1f(t),u_transition:new e.Uniform1f(t),u_fadeout_range:new e.Uniform1f(t),u_color:new e.Uniform4f(t),u_high_color:new e.Uniform4f(t),u_space_color:new e.Uniform4f(t),u_star_intensity:new e.Uniform1f(t),u_star_density:new e.Uniform1f(t),u_star_size:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t),u_horizon_angle:new e.Uniform1f(t),u_rotation_matrix:new e.UniformMatrix4f(t)})};let os;function us(t,n,s,i,l,a,r){const o=t.context,u=o.gl,c=t.transform,h=t.useProgram("collisionBox"),p=[];let d=0,f=0;for(let g=0;g0){const t=e.create(),n=E;e.mul(t,y.placementInvProjMatrix,c.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),p.push({circleArray:T,circleOffset:f,transform:n,invTransform:t,projection:y.getProjection()}),d+=T.length/4,f=d}w&&(t.terrain&&t.terrain.setupElevationDraw(I,h),h.draw(o,u.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,jn(E,c,I,y.getProjection()),s.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,null,c.zoom,null,[w.collisionVertexBuffer,w.collisionVertexBufferExt]))}if(!r||!p.length)return;const m=t.useProgram("collisionCircle"),I=new e.StructArrayLayout2f1f2i16;I.resize(4*d),I._trim();let y=0;for(const e of p)for(let t=0;t=0&&(m[f.associatedIconIndex]={x:S,y:D,z:A,angle:N})}else dt(b,d)}if(h){f.clear();const n=t.icon.placedSymbolArray;for(let t=0;te.sortKey-t.sortKey));for(const e of D){const n=e.state;if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,f.CLAMP_TO_EDGE),n.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,ms(n.buffers,e.segments,s,t,n.program,T,h,p,i)),i.u_is_halo=0}ms(n.buffers,e.segments,s,t,n.program,T,h,p,n.uniformValues)}}function ms(t,n,s,i,l,a,r,o,u){const c=i.context,h=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer];l.draw(c,c.gl.TRIANGLES,a,r,o,e.CullFaceMode.disabled,u,s.id,t.layoutVertexBuffer,t.indexBuffer,n,s.paint,i.transform.zoom,t.programConfigurations.get(s.id),h)}function Is(t,n,s,i,l,a,r){const o=t.context.gl,u=s.paint.get("fill-pattern"),c=u&&u.constantOr(1);let h,p,d,f,m;r?(p=c&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=o.LINES):(p=c?"fillPattern":"fill",h=o.TRIANGLES);for(const I of i){const i=n.getTile(I);if(c&&!i.patternsLoaded())continue;const y=i.getBucket(s);if(!y)continue;t.prepareDrawTile();const v=y.programConfigurations.get(s.id),E=t.useProgram(p,v);c&&(t.context.activeTexture.set(o.TEXTURE0),i.imageAtlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),v.updatePaintBuffers());const w=u.constantOr(null);if(w&&i.imageAtlas){const e=i.imageAtlas.patternPositions[w.toString()];e&&v.setConstantPatternPositions(e)}const g=t.translatePosMatrix(I.projMatrix,i,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));if(r){f=y.indexBuffer2,m=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[o.drawingBufferWidth,o.drawingBufferHeight];d="fillOutlinePattern"===p&&c?Gn(g,t,i,e):Un(g,e)}else f=y.indexBuffer,m=y.segments,d=c?Hn(g,t,i):Bn(g);t.prepareDrawProgram(t.context,E,I.toUnwrapped()),E.draw(t.context,h,l,t.stencilModeForClipping(I),a,e.CullFaceMode.disabled,d,s.id,y.layoutVertexBuffer,f,m,s.paint,t.transform.zoom,v)}}function ys(t,n,s,i,l,a,r){const o=t.context,u=o.gl,c=t.transform,h=s.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=s.paint.get("fill-extrusion-opacity"),f=[s.paint.get("fill-extrusion-ambient-occlusion-intensity"),s.paint.get("fill-extrusion-ambient-occlusion-radius")],m=s.layout.get("fill-extrusion-edge-radius"),I=m>0&&!s.paint.get("fill-extrusion-rounded-roof"),y=I?0:m,v="globe"===c.projection.name?e.fillExtrusionHeightLift():0,E="globe"===c.projection.name,w=E?e.globeToMercatorTransition(c.zoom):0,g=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)],T=[];E&&T.push("PROJECTION_GLOBE_VIEW"),f[0]>0&&T.push("FAUX_AO"),I&&T.push("ZERO_ROOF_RADIUS");for(const b of i){const i=n.getTile(b),m=i.getBucket(s);if(!m||m.projection.name!==c.projection.name)continue;const I=m.programConfigurations.get(s.id),R=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",I,T);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(i,R,{useMeterToDem:!0});else{if(!m.enableTerrain)continue;if(e.setupElevationDraw(i,R,{useMeterToDem:!0}),vs(o,n,b,m,s,e),!m.centroidVertexBuffer){const e=R.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}}}p&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),I.updatePaintBuffers());const S=h.constantOr(null);if(S&&i.imageAtlas){const e=i.imageAtlas.patternPositions[S.toString()];e&&I.setConstantPatternPositions(e)}const D=t.translatePosMatrix(b.projMatrix,i,s.paint.get("fill-extrusion-translate"),s.paint.get("fill-extrusion-translate-anchor")),A=c.projection.createInversionMatrix(c,b.canonical),C=s.paint.get("fill-extrusion-vertical-gradient"),x=p?Fn(D,t,C,d,f,y,b,i,v,w,g,A):Mn(D,t,C,d,f,y,b,v,w,g,A);t.prepareDrawProgram(o,R,b.toUnwrapped());const _=[];t.terrain&&_.push(m.centroidVertexBuffer),E&&_.push(m.layoutVertexExtBuffer),R.draw(o,o.gl.TRIANGLES,l,a,r,e.CullFaceMode.backCCW,x,s.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,s.paint,t.transform.zoom,I,_)}}function vs(t,n,s,i,l,a){const r=[t=>{let n=t.canonical.x-1,s=t.wrap;return n<0&&(n=(1<{let n=t.canonical.x+1,s=t.wrap;return n===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=n.getSource().minzoom,s=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(l)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(u[0]=Math.min(t.min.y,n.min.y),u[1]=Math.max(t.max.y,n.max.y),u[2]=e.EXTENT-n.min.x>t.max.x?n.min.x-e.EXTENT:t.max.x,u),h=(t,n)=>(u[0]=Math.min(t.min.x,n.min.x),u[1]=Math.max(t.max.x,n.max.x),u[2]=e.EXTENT-n.min.y>t.max.y?n.min.y-e.EXTENT:t.max.y,u),p=[(e,t)=>c(e,t),(e,t)=>c(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new e.Point(0,0);let f,m,I;const y=(t,n,i,l,r)=>{const o=[[l?i:t,l?t:i,0],[l?i:n,l?n:i,0]],u=r<0?e.EXTENT+r:r,c=[l?u:(t+n)/2,l?(t+n)/2:u,0];return 0===i&&r<0||0!==i&&r>0?a.getForTilePoints(I,[c],!0,m):o.push(c),a.getForTilePoints(s,o,!0,f),Math.max(o[0][2],o[1][2],c[2])/a.exaggeration()};for(let v=0;v<4;v++){const t=(v<2?1:5)-v,n=i.borders[v];if(0===n.length)continue;const l=I=r[v](s),u=o(l);if(!(u&&u instanceof e.FillExtrusionBucket&&u.enableTerrain))continue;if(i.borderDoneWithNeighborZ[v]===u.canonical.z&&u.borderDoneWithNeighborZ[t]===i.canonical.z)continue;if(m=a.findDEMTileFor(l),!m||!m.dem)continue;if(!f){const e=a.findDEMTileFor(s);if(!e||!e.dem)return;f=e}const c=u.borders[t];let h=0;const E=u.borderDoneWithNeighborZ[t]!==i.canonical.z;if(i.canonical.z===u.canonical.z){for(let s=0;sa[0]+3));)E&&u.encodeCentroid(void 0,r,!1),h++;if(r&&ha[1]-3)&&(s++,++h!==c.length);)r=u.featuresOnBorder[c[h]];if(r=u.featuresOnBorder[c[n]],l.intersectsCount()>1||r.intersectsCount()>1||1!==s){1!==s&&(h=n),i.encodeCentroid(void 0,l,!1),E&&u.encodeCentroid(void 0,r,!1);continue}const o=p[v](l,r),f=v%2?e.EXTENT-1:0;d.x=y(o[0],Math.min(e.EXTENT-1,o[1]),f,v<2,o[2]),d.y=0,i.encodeCentroid(d,l,!1),E&&u.encodeCentroid(d,r,!1)}else i.encodeCentroid(void 0,l,!1)}i.borderDoneWithNeighborZ[v]=u.canonical.z,i.needsCentroidUpdate=!0,E&&(u.borderDoneWithNeighborZ[t]=i.canonical.z,u.needsCentroidUpdate=!0)}else{for(const e of n)i.encodeCentroid(void 0,i.featuresOnBorder[e],!1);if(E){for(const e of c)u.encodeCentroid(void 0,u.featuresOnBorder[e],!1);u.borderDoneWithNeighborZ[t]=i.canonical.z,u.needsCentroidUpdate=!0}i.borderDoneWithNeighborZ[v]=u.canonical.z,i.needsCentroidUpdate=!0}}(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const Es=new e.Color(1,0,0,1),ws=new e.Color(0,1,0,1),gs=new e.Color(0,0,1,1),Ts=new e.Color(1,0,1,1),bs=new e.Color(0,1,1,1);function Rs(t,n,s){const i=t.context,l=t.transform,a=i.gl,r="globe"===l.projection.name,o=r?["PROJECTION_GLOBE_VIEW"]:null;let u=s.projMatrix;if(r&&e.globeToMercatorTransition(l.zoom)>0){const t=e.transitionTileAABBinECEF(s.canonical,l),n=e.globeDenormalizeECEF(t);u=e.multiply(new Float32Array(16),l.globeMatrix,n),e.multiply(u,l.projMatrix,u)}const c=t.useProgram("debug",null,o),h=n.getTileByID(s.key);t.terrain&&t.terrain.setupElevationDraw(h,c);const p=e.DepthMode.disabled,d=e.StencilMode.disabled,f=t.colorModeForRenderPass(),m="$debug";i.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),r?h._makeGlobeTileDebugBuffers(t.context,l):h._makeDebugTileBoundsBuffers(t.context,l.projection);const I=h._tileDebugBuffer||t.debugBuffer,y=h._tileDebugIndexBuffer||t.debugIndexBuffer,v=h._tileDebugSegments||t.debugSegments;c.draw(i,a.LINE_STRIP,p,d,f,e.CullFaceMode.disabled,Wn(u,e.Color.red),m,I,y,v,null,null,null,[h._globeTileDebugBorderBuffer]);const E=h.latestRawTileData,w=Math.floor((E&&E.byteLength||0)/1024),g=n.getTile(s).tileSize,T=512/Math.min(g,512)*(s.overscaledZ/l.zoom)*.5;let b=s.canonical.toString();s.overscaledZ!==s.canonical.z&&(b+=" => ".concat(s.overscaledZ)),b+=" ".concat(w,"kb"),function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,s=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}(t,b);const R=h._tileDebugTextBuffer||t.debugBuffer,S=h._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=h._tileDebugTextSegments||t.debugSegments;c.draw(i,a.TRIANGLES,p,d,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Wn(u,e.Color.transparent,T),m,R,S,D,null,null,null,[h._globeTileDebugTextBuffer])}function Ss(e,t,n,s){As(e,0,t+n/2,e.transform.width,n,s)}function Ds(e,t,n,s){As(e,t-n/2,0,n,e.transform.height,s)}function As(t,n,s,i,l,a){const r=t.context,o=r.gl;o.enable(o.SCISSOR_TEST),o.scissor(n*e.exported.devicePixelRatio,s*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,l*e.exported.devicePixelRatio),r.clear({color:a}),o.disable(o.SCISSOR_TEST)}const Cs=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:xs}=Cs;function _s(e,t,n,s){e.emplaceBack(t,n,s)}class Os{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,_s(this.vertexArray,-1,-1,1),_s(this.vertexArray,1,-1,1),_s(this.vertexArray,-1,1,1),_s(this.vertexArray,1,1,1),_s(this.vertexArray,-1,-1,-1),_s(this.vertexArray,1,-1,-1),_s(this.vertexArray,-1,1,-1),_s(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,xs),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function Ns(t,n,s,i,l,a){const r=t.gl,o=n.paint.get("sky-atmosphere-color"),u=n.paint.get("sky-atmosphere-halo-color"),c=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,s,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[s.r,s.g,s.b,s.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),i),l,c,o,u);r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),s.draw(t,r.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Ls=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ps{constructor(t){const n=new e.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const s=new e.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Ls.members),this.indexBuffer=t.createIndexBuffer(s),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Ms={symbol:function(t,n,s,i,l){if("translucent"!==t.renderPass)return;const a=e.StencilMode.disabled,r=t.colorModeForRenderPass();s.layout.get("text-variable-anchor")&&function(t,n,s,i,l,a,r){const o=n.transform,u="map"===l,c="map"===a;for(const h of t){const t=i.getTile(h),n=t.getBucket(s);if(!n||!n.text||!n.text.segments.get().length)continue;const l=e.evaluateSizeForZoom(n.textSizeData,o.zoom),a=Et(h,n.getProjection(),o),p=o.calculatePixelsToTileUnitsMatrix(t),d=et(a,t.tileID.canonical,c,u,o,n.getProjection(),p),f="none"!==s.layout.get("icon-text-fit")&&n.hasIconData();if(l){const s=Math.pow(2,o.zoom-t.tileID.overscaledZ);ps(n,u,c,r,e.symbolSize,o,d,h,s,l,f)}}}(i,t,s,n,s.layout.get("text-rotation-alignment"),s.layout.get("text-pitch-alignment"),l),0!==s.paint.get("icon-opacity").constantOr(1)&&fs(t,n,s,i,!1,s.paint.get("icon-translate"),s.paint.get("icon-translate-anchor"),s.layout.get("icon-rotation-alignment"),s.layout.get("icon-pitch-alignment"),s.layout.get("icon-keep-upright"),a,r),0!==s.paint.get("text-opacity").constantOr(1)&&fs(t,n,s,i,!0,s.paint.get("text-translate"),s.paint.get("text-translate-anchor"),s.layout.get("text-rotation-alignment"),s.layout.get("text-pitch-alignment"),s.layout.get("text-keep-upright"),a,r),n.map.showCollisionBoxes&&(us(t,n,s,i,s.paint.get("text-translate"),s.paint.get("text-translate-anchor"),!0),us(t,n,s,i,s.paint.get("icon-translate"),s.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,s,i){if("translucent"!==t.renderPass)return;const l=s.paint.get("circle-opacity"),a=s.paint.get("circle-stroke-width"),r=s.paint.get("circle-stroke-opacity"),o=void 0!==s.layout.get("circle-sort-key").constantOr(1);if(0===l.constantOr(1)&&(0===a.constantOr(1)||0===r.constantOr(1)))return;const u=t.context,c=u.gl,h=t.transform,p=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),d=e.StencilMode.disabled,f=t.colorModeForRenderPass(),m="globe"===h.projection.name,I=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=[];for(let E=0;Ee.sortKey-t.sortKey));const v={useDepthForOcclusion:!m};for(const E of y){const{programConfiguration:n,program:i,layoutVertexBuffer:l,globeExtVertexBuffer:a,indexBuffer:r,uniformValues:o,tile:m}=E.state,I=E.segments;t.terrain&&t.terrain.setupElevationDraw(m,i,v),t.prepareDrawProgram(u,i,m.tileID.toUnwrapped()),i.draw(u,c.TRIANGLES,p,d,f,e.CullFaceMode.disabled,o,s.id,l,r,I,s.paint,h.zoom,n,[a])}},heatmap:function(t,n,s,i){if(0!==s.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const l=t.context,a=l.gl,r=e.StencilMode.disabled,o=new e.ColorMode([a.ONE,a.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,n,s){const i=e.gl,l=t.width*s,a=t.height*s;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,l,a]);let r=n.heatmapFbo;if(!r||r&&(r.width!==l||r.height!==a)){r&&r.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),r=n.heatmapFbo=e.createFramebuffer(l,a,!1),function(e,t,n,s,i,l){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.isWebGL2&&e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,l,0,a.RGBA,e.extRenderToTextureHalfFloat?e.isWebGL2?a.HALF_FLOAT:e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),s.colorAttachment.set(n)}(e,0,t,r,l,a)}else i.bindTexture(i.TEXTURE_2D,r.colorAttachment.get()),e.bindFramebuffer.set(r.framebuffer)}(l,t,s,"globe"===t.transform.projection.name?.5:.25),l.clear({color:e.Color.transparent});const u=t.transform,c="globe"===u.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,p=c?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,d=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,s))},line:function(t,n,s,i){if("translucent"!==t.renderPass)return;const l=s.paint.get("line-opacity"),a=s.paint.get("line-width");if(0===l.constantOr(1)||0===a.constantOr(1))return;const r=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),o=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,c=s.paint.get("line-dasharray"),h=c.constantOr(1),p=s.layout.get("line-cap"),d=s.paint.get("line-pattern"),f=d.constantOr(1),m=s.paint.get("line-gradient"),I=f?"linePattern":"line",y=t.context,v=y.gl,E=(e=>{const t=[];Jn(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET");const s=e.paint.get("line-pattern").constantOr(1),i=1!==e.paint.get("line-opacity").constantOr(1);return!s&&i&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(s);let w=E.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(w=!1);for(const g of i){const i=n.getTile(g);if(f&&!i.patternsLoaded())continue;const l=i.getBucket(s);if(!l)continue;t.prepareDrawTile();const a=l.programConfigurations.get(s.id),T=t.useProgram(I,a,E),b=d.constantOr(null);if(b&&i.imageAtlas){const e=i.imageAtlas.patternPositions[b.toString()];e&&a.setConstantPatternPositions(e)}const R=c.constantOr(null),S=p.constantOr(null);if(!f&&R&&S&&i.lineAtlas){const e=i.lineAtlas.getDash(R,S);e&&a.setConstantPatternPositions(e)}let[D,A]=s.paint.get("line-trim-offset");if("round"===S||"square"===S){const e=1;D!==A&&(0===D&&(D-=e),1===A&&(A+=e))}const C=t.terrain?g.projMatrix:null,x=f?Zn(t,i,s,C,u):Xn(t,i,s,C,l.lineClipsArray.length,u,[D,A]);if(m){const i=l.gradients[s.id];let a=i.texture;if(s.gradientVersion!==i.version){let r=256;if(s.stepInterpolant){const s=n.getSource().maxzoom,i=g.canonical.z===s?Math.ceil(1<{T.draw(y,v.TRIANGLES,r,n,o,e.CullFaceMode.disabled,x,s.id,l.layoutVertexBuffer,l.indexBuffer,l.segments,s.paint,t.transform.zoom,a,[l.layoutVertexBuffer2])};if(w){const n=t.stencilModeForClipping(g).ref;0===n&&t.terrain&&y.clear({stencil:0});const s={func:v.EQUAL,mask:255};x.u_alpha_discard_threshold=.8,_(new e.StencilMode(s,n,255,v.KEEP,v.KEEP,v.INVERT)),x.u_alpha_discard_threshold=0,_(new e.StencilMode(s,n,255,v.KEEP,v.KEEP,v.KEEP))}else _(t.stencilModeForClipping(g))}w&&(t.resetStencilClippingMasks(),t.terrain&&y.clear({stencil:0}))},fill:function(t,n,s,i){const l=s.paint.get("fill-color"),a=s.paint.get("fill-opacity");if(0===a.constantOr(1))return;const r=t.colorModeForRenderPass(),o=s.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!o.constantOr(1)&&1===l.constantOr(e.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const l=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);Is(t,n,s,i,l,r,!1)}if("translucent"===t.renderPass&&s.paint.get("fill-antialias")){const l=t.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);Is(t,n,s,i,l,r,!0)}},"fill-extrusion":function(t,n,s,i){const l=s.paint.get("fill-extrusion-opacity");if(0!==l&&"translucent"===t.renderPass){const a=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==l||s.paint.get("fill-extrusion-pattern").constantOr(1))ys(t,n,s,i,a,e.StencilMode.disabled,e.ColorMode.disabled),ys(t,n,s,i,a,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const l=t.colorModeForRenderPass();ys(t,n,s,i,a,e.StencilMode.disabled,l)}}},hillshade:function(t,n,s,i){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const l=t.context,a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),r=t.colorModeForRenderPass(),o=t.terrain&&t.terrain.renderingToTexture,[u,c]="translucent"!==t.renderPass||o?[{},i]:t.stencilConfigForOverlap(i);for(const h of c){const i=n.getTile(h);if(i.needsHillshadePrepare&&"offscreen"===t.renderPass)yn(t,i,s,a,e.StencilMode.disabled,r);else if("translucent"===t.renderPass){const e=o&&t.terrain?t.terrain.stencilModeForRTTOverlap(h):u[h.overscaledZ];mn(t,h,i,s,a,e,r)}}l.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,n,s,i,l,a){if("translucent"!==t.renderPass)return;if(0===s.paint.get("raster-opacity"))return;if(!i.length)return;const r=t.context,o=r.gl,u=n.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),p=t.terrain&&t.terrain.renderingToTexture,[d,f]=u instanceof Ce||p?[{},i]:t.stencilConfigForOverlap(i),m=f[f.length-1].overscaledZ,I=!t.options.moving;for(const y of f){const i=p?e.DepthMode.disabled:t.depthModeForSublayer(y.overscaledZ-m,1===s.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,o.LESS),l=y.toUnwrapped(),f=n.getTile(y);if(p&&(!f||!f.hasData()))continue;const v=p?y.projMatrix:t.transform.calculateProjMatrix(l,I),E=t.terrain&&p?t.terrain.stencilModeForRTTOverlap(y):d[y.overscaledZ],w=a?0:s.paint.get("raster-fade-duration");f.registerFadeDuration(w);const g=n.findLoadedParent(y,0),T=An(f,g,n,t.transform,w);let b,R;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===s.paint.get("raster-resampling")?o.NEAREST:o.LINEAR;r.activeTexture.set(o.TEXTURE0),f.texture.bind(S,o.CLAMP_TO_EDGE),r.activeTexture.set(o.TEXTURE1),g?(g.texture.bind(S,o.CLAMP_TO_EDGE),b=Math.pow(2,g.tileID.overscaledZ-f.tileID.overscaledZ),R=[f.tileID.canonical.x*b%1,f.tileID.canonical.y*b%1]):f.texture.bind(S,o.CLAMP_TO_EDGE),f.texture.useMipmap&&r.extTextureFilterAnisotropic&&t.transform.pitch>20&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax);const D=$n(v,R||[0,0],b||1,T,s,u instanceof Ce?u.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(r,c,l),u instanceof Ce)u.boundsBuffer&&u.boundsSegments&&c.draw(r,o.TRIANGLES,i,e.StencilMode.disabled,h,e.CullFaceMode.disabled,D,s.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:l,tileBoundsSegments:a}=t.getTileBoundsBuffers(f);c.draw(r,o.TRIANGLES,i,E,h,e.CullFaceMode.disabled,D,s.id,n,l,a)}}t.resetStencilClippingMasks()},background:function(t,n,s,i){const l=s.paint.get("background-color"),a=s.paint.get("background-opacity");if(0===a)return;const r=t.context,o=r.gl,u=t.transform,c=u.tileSize,h=s.paint.get("background-pattern");if(t.isPatternMissing(h))return;const p=!h&&1===l.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==p)return;const d=e.StencilMode.disabled,f=t.depthModeForSublayer(0,"opaque"===p?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),I=t.useProgram(h?"backgroundPattern":"background");let y,v=i;v||(y=t.getBackgroundTiles(),v=Object.values(y).map((e=>e.tileID))),h&&(r.activeTexture.set(o.TEXTURE0),t.imageManager.bind(t.context));for(const E of v){const p=E.toUnwrapped(),v=i?E.projMatrix:t.transform.calculateProjMatrix(p);t.prepareDrawTile();const w=n?n.getTile(E):y?y[E.key]:new e.Tile(E,c,u.zoom,t),g=h?as(v,a,t,h,{tileID:E,tileSize:c}):ls(v,a,l);t.prepareDrawProgram(r,I,p);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:b,tileBoundsSegments:R}=t.getTileBoundsBuffers(w);I.draw(r,o.TRIANGLES,f,d,m,e.CullFaceMode.disabled,g,s.id,T,b,R)}},sky:function(t,n,s){const i=t.transform,l="mercator"===i.projection.name||"globe"===i.projection.name?1:e.smoothstep(7,8,i.zoom),a=s.paint.get("sky-opacity")*l;if(0===a)return;const r=t.context,o=s.paint.get("sky-type"),u=new e.DepthMode(r.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===o?"offscreen"===t.renderPass?s.needsSkyboxCapture(t)&&(function(t,n,s,i){const l=t.context,a=l.gl;let r=n.skyboxFbo;if(!r){r=n.skyboxFbo=l.createFramebuffer(32,32,!1),n.skyboxGeometry=new Os(l),n.skyboxTexture=l.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}l.bindFramebuffer.set(r.framebuffer),l.viewport.set([0,0,32,32]);const o=n.getCenter(t,!0),u=t.useProgram("skyboxCapture"),c=new Float64Array(16);e.identity(c),e.rotateY(c,c,.5*-Math.PI),Ns(l,n,u,c,o,0),e.identity(c),e.rotateY(c,c,.5*Math.PI),Ns(l,n,u,c,o,1),e.identity(c),e.rotateX(c,c,.5*-Math.PI),Ns(l,n,u,c,o,2),e.identity(c),e.rotateX(c,c,.5*Math.PI),Ns(l,n,u,c,o,3),e.identity(c),Ns(l,n,u,c,o,4),e.identity(c),e.rotateY(c,c,Math.PI),Ns(l,n,u,c,o,5),l.viewport.set([0,0,t.width,t.height])}(t,s),s.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,n,s,i,l){const a=t.context,r=a.gl,o=t.transform,u=t.useProgram("skybox");a.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_CUBE_MAP,n.skyboxTexture);const c=((e,t,n,s,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:s,u_temporal_offset:i}))(o.skyboxMatrix,n.getCenter(t,!1),0,i,l);t.prepareDrawProgram(a,u),u.draw(a,r.TRIANGLES,s,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,c,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,s,u,a,c):"gradient"===o&&"sky"===t.renderPass&&function(t,n,s,i,l){const a=t.context,r=a.gl,o=t.transform,u=t.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new Os(a)),a.activeTexture.set(r.TEXTURE0);let c=n.colorRampTexture;c||(c=n.colorRampTexture=new e.Texture(a,n.colorRamp,r.RGBA)),c.bind(r.LINEAR,r.CLAMP_TO_EDGE);const h=((t,n,s,i,l)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.degToRad(s),u_opacity:i,u_temporal_offset:l}))(o.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,l);t.prepareDrawProgram(a,u),u.draw(a,r.TRIANGLES,s,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,s,u,a,c)},debug:function(e,t,n){for(let s=0;s2&&void 0!==arguments[2]&&arguments[2];this.context=new Re(t,s),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=e.SourceCache.maxUnderzooming+e.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const n=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(n||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new On(this,e));const s=this._terrain;this.transform.elevation=n?s:null,s.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[n,s]=t.getFovAdjustedRange(this.transform._fov);if(n>s)return void(this.transform.fogCullDistSq=null);const i=n+.78*(s-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,n){if(this.width=t*e.exported.devicePixelRatio,this.height=n*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const s=new e.StructArrayLayout2i4;s.emplaceBack(0,0),s.emplaceBack(e.EXTENT,0),s.emplaceBack(0,e.EXTENT),s.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(s,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const i=new e.StructArrayLayout2i4;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const l=new e.StructArrayLayout4i8;l.emplaceBack(0,0,0,0),l.emplaceBack(e.EXTENT,0,e.EXTENT,0),l.emplaceBack(0,e.EXTENT,0,e.EXTENT),l.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(l,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const a=new e.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const r=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])r.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(r),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const o=this.context.gl;this.stencilClearMode=new e.StencilMode({func:o.ALWAYS,mask:0},0,255,o.ZERO,o.ZERO,o.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Ps(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,n.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,Dn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,s){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!s||0===s.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of s)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=n.id;const i=this.context,l=i.gl;this.nextStencilID+s.length>256&&this.clearStencil(),i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const r of s){const t=n.getTile(r),s=this._tileClippingMaskIDs[r.key]=this.nextStencilID++,{tileBoundsBuffer:o,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=this.getTileBoundsBuffers(t);a.draw(i,l.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:l.ALWAYS,mask:0},s,255,l.KEEP,l.KEEP,l.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Dn(r.projMatrix),"$clipping",o,u,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new e.StencilMode({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new e.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,s=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),i=s[s.length-1].overscaledZ,l=s[0].overscaledZ-i+1;if(l>1){this.currentStencilSource=void 0,this.nextStencilID+l>256&&this.clearStencil();const t={};for(let s=0;s=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],n=t._getLayerSourceCache(e);if(e.isSky())continue;const i=n?a[n.id]:void 0;this._renderTileClippingMasks(e,n,i),this.renderLayer(this,n,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,n){const s=t.context,i=s.gl,l=t.transform,a=new e.DepthMode(i.LEQUAL,e.DepthMode.ReadOnly,[0,1]),r=t.useProgram("globeAtmosphere",null,"globe"===l.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),o=e.globeToMercatorTransition(l.zoom),u=n.properties.get("color").toArray01(),c=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),p=e.identity$1([]);e.rotateY$1(p,p,-e.degToRad(l._center.lng)),e.rotateX$1(p,p,e.degToRad(l._center.lat)),e.rotateZ$1(p,p,l.angle),e.rotateX$1(p,p,-l._pitch);const d=e.fromQuat(new Float32Array(16),p),f=e.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,I=e.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),y=e.globeUseCustomAntiAliasing(t,s,l)&&I===m?l.worldSize/(2*Math.PI*1.025)-1:l.globeRadius,v=t.frameCounter/1e3%1,E=e.length(l.globeCenterInViewSpace),w=Math.sqrt(Math.pow(E,2)-Math.pow(y,2)),g=Math.acos(w/E),T=((t,n,s,i,l,a,r,o,u,c,h,p,d,f)=>({u_frustum_tl:t,u_frustum_tr:n,u_frustum_br:s,u_frustum_bl:i,u_horizon:l,u_transition:a,u_fadeout_range:r,u_color:o,u_high_color:u,u_space_color:c,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(l.frustumCorners.TL,l.frustumCorners.TR,l.frustumCorners.BR,l.frustumCorners.BL,l.frustumCorners.horizon,o,I,u,c,h,f,v,g,d);t.prepareDrawProgram(s,r);const b=t.atmosphereBuffer;b&&r.draw(s,i.TRIANGLES,a,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,T,"skybox",b.vertexBuffer,b.indexBuffer,b.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const s=t._getLayerSourceCache(e);s&&!e.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.terrain&&0===this.terrain.exaggeration(),n=this.style&&this.style.fog,s=[];return this.terrainRenderModeElevated()&&s.push("TERRAIN"),"globe"===this.transform.projection.name&&s.push("GLOBE"),t&&s.push("ZERO_EXAGGERATION"),n&&!e&&0!==n.getOpacity(this.transform.pitch)&&s.push("FOG"),e&&s.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&s.push("OVERDRAW_INSPECTOR"),s}useProgram(e,t,n){this.cache=this.cache||{};const s=n||[],i=this.currentGlobalDefines().concat(s),l=Nn.cacheKey(cn[e],e,i,t);return this.cache[l]||(this.cache[l]=new Nn(this.context,e,cn[e],t,rs[e],i)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,n,s){if(this.terrain&&this.terrain.renderingToTexture)return;const i=this.style.fog;if(i){const l=i.getOpacity(this.transform.pitch),a=((t,n,s,i,l,a,r,o,u,c,h)=>{const p=t.transform,d=n.properties.get("color").toArray01();d[3]=i;const f=t.frameCounter/1e3%1;return{u_fog_matrix:s?p.calculateFogTileMatrix(s):t.identityMat,u_fog_range:n.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:l,u_frustum_tr:a,u_frustum_br:r,u_frustum_bl:o,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,i,s,l,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);n.setFogUniformValues(t,a)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},s=this.transform.coveringTiles({tileSize:512});for(const i of s)n[i.key]=t[i.key]||new e.Tile(i,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class Bs{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=s}interpolate(t,n,s){return null!=n.top&&null!=t.top&&(this.top=e.number(t.top,n.top,s)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,n.bottom,s)),null!=n.left&&null!=t.left&&(this.left=e.number(t.left,n.left,s)),null!=n.right&&null!=t.right&&(this.right=e.number(t.right,n.right,s)),this}getCenter(t,n){const s=e.clamp((this.left+t-this.right)/2,0,t),i=e.clamp((this.top+n-this.bottom)/2,0,n);return new e.Point(s,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Bs(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Hs(t,n){const s=e.getColumn(t,3);e.fromQuat(t,n),e.setColumn(t,3,s)}function Us(t,n){const s=e.identity$1([]);return e.rotateZ$1(s,s,-n),e.rotateX$1(s,s,-t),s}function Gs(t,n){const s=[t[0],t[1],0],i=[n[0],n[1],0];if(e.length(s)>=1e-15){const t=e.normalize([],s);e.scale$2(i,t,e.dot(i,t)),n[0]=i[0],n[1]=i[1]}const l=e.cross([],n,t);if(e.len(l)<1e-15)return null;const a=Math.atan2(-l[1],l[0]);return Us(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class ks{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const s=this.position,i=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,l=e.MercatorCoordinate.fromLngLat(t,i),a=[l.x-s.x,l.y-s.y,l.z-s.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=Gs(a,n)}setPitchBearing(t,n){this.orientation=Us(e.degToRad(t),e.degToRad(-n))}}class zs{constructor(t,n){this._transform=e.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.setColumn(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Hs(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Us(e,t),Hs(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const s=new Float64Array(16);return e.invert(s,this.getWorldToCamera(t,n)),s}getWorldToCameraPosition(t,n,s){const i=this.position;e.scale$2(i,i,-t);const l=new Float64Array(16);return e.fromScaling(l,[s,s,s]),e.translate(l,l,i),l[10]*=n,l}getWorldToCamera(t,n){const s=new Float64Array(16),i=new Float64Array(4),l=this.position;return e.conjugate(i,this._orientation),e.scale$2(l,l,-t),e.fromQuat(s,i),e.translate(s,s,l),s[1]*=-1,s[5]*=-1,s[9]*=-1,s[13]*=-1,s[8]*=n,s[9]*=n,s[10]*=n,s[11]*=n,s}getCameraToClipPerspective(t,n,s,i){const l=new Float64Array(16);return e.perspective(l,t,n,s,i),l}getDistanceToElevation(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=0===t?0:e.mercatorZfromAltitude(t,n?e.latFromMercatorY(this.position[1]):this.position[1]),i=this.forward();return(s-this.position[2])/i[2]}clone(){return new zs([...this.position],[...this.orientation])}}function Vs(t,n){const s=Ws(t.projection,t.zoom,t.width,t.height),i=function(t,n,s,i,l){const a=new e.LngLat(s.lng-180*Ys,s.lat),r=new e.LngLat(s.lng+180*Ys,s.lat),o=t.project(a.lng,a.lat),u=t.project(r.lng,r.lat),c=-Math.atan2(u.y-o.y,u.x-o.x),h=e.MercatorCoordinate.fromLngLat(s);h.y=e.clamp(h.y,-1+Ys,1-Ys);const p=h.toLngLat(),d=t.project(p.lng,p.lat),f=e.MercatorCoordinate.fromLngLat(p);f.x+=Ys;const m=f.toLngLat(),I=t.project(m.lng,m.lat),y=Xs(I.x-d.x,I.y-d.y,c),v=e.MercatorCoordinate.fromLngLat(p);v.y+=Ys;const E=v.toLngLat(),w=t.project(E.lng,E.lat),g=Xs(w.x-d.x,w.y-d.y,c),T=Math.abs(y.x)/Math.abs(g.y),b=e.identity([]);e.rotateZ(b,b,-c*(1-(l?0:i)));const R=e.identity([]);return e.scale(R,R,[1,1-(1-T)*i,1]),R[4]=-g.x/g.y*i,e.rotateZ(R,R,c),e.multiply(R,b,R),R}(t.projection,0,t.center,s,n),l=js(t);return e.scale(i,i,[l,l,1]),i}function js(t){const n=t.projection,s=Ws(t.projection,t.zoom,t.width,t.height),i=qs(n,t.center),l=qs(n,e.LngLat.convert(n.center));return Math.pow(2,i*s+(1-s)*l)}function Ws(t,n,s,i){let l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0;const a=t.range;if(!a)return 0;const r=Math.min(l,Math.max(s,i)),o=Math.log(r/1024)/Math.LN2;return e.smoothstep(a[0]+o,a[1]+o,n)}const Ys=1/4e4;function qs(t,n){const s=e.clamp(n.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=new e.LngLat(n.lng-180*Ys,s),l=new e.LngLat(n.lng+180*Ys,s),a=t.project(i.lng,s),r=t.project(l.lng,s),o=e.MercatorCoordinate.fromLngLat(i),u=e.MercatorCoordinate.fromLngLat(l),c=r.x-a.x,h=r.y-a.y,p=u.x-o.x,d=u.y-o.y,f=Math.sqrt((p*p+d*d)/(c*c+h*h));return Math.log(f)/Math.LN2}function Xs(e,t,n){const s=Math.cos(n),i=Math.sin(n);return{x:e*s-t*i,y:e*i+t*s}}class Zs{constructor(t,n,s,i,l,a,r){this.tileSize=512,this._renderWorldCopies=void 0===l||l,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==s?0:s,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(r),this.width=0,this.height=0,this._center=new e.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Bs,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new zs,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Zs(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const s=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const i=!t(s,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.getProjection({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.Point(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;var s;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(s=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s),function(e,t,n){var s=t[0],i=t[1],l=t[2],a=t[3],r=Math.sin(n),o=Math.cos(n);e[0]=s*o+l*r,e[1]=i*o+a*r,e[2]=s*-r+l*o,e[3]=i*-r+a*o}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.degToRad(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],s=this.horizonLineFromTop();let i=0,l=0;for(let a=0;at.maxzoom&&(n=t.maxzoom);const a=this.locationCoordinate(this.center),r=this.center.lat,o=1<{const n=1/4e4,s=new e.MercatorCoordinate(t.x+n,t.y,t.z),i=new e.MercatorCoordinate(t.x,t.y+n,t.z),l=t.toLngLat(),a=s.toLngLat(),r=i.toLngLat(),o=this.locationCoordinate(l),u=this.locationCoordinate(a),c=this.locationCoordinate(r),h=Math.hypot(u.x-o.x,u.y-o.y),p=Math.hypot(c.x-o.x,c.y-o.y);return Math.sqrt(h*p)*g/n},b=t=>{const n=E,s=w;return{aabb:e.tileAABB(this,o,0,0,0,t,s,n,this.projection),zoom:0,x:0,y:0,minZ:s,maxZ:n,wrap:t,fullyVisible:!1}},R=[];let S=[];const D=n,A=t.reparseOverscaled?s:n,C=e=>e*e,x=C((m-this._centerAltitude)*f),_=e=>{if(!this._elevation||!e.tileID||!l)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=O(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},O=t=>{if(t.zoom=.9)return!0}else if(i&&(a=C(t.aabb.distanceZ(I)*f)),this.projection.isReprojectedInTileSpace&&s<=5){const n=Math.pow(2,t.zoom),s=T(new e.MercatorCoordinate((t.x+.5)/n,(t.y+.5)/n));o=s>.85?1:s}const u=n*n+l*l+a,h=C((1<{if(t*C(.707)0;){const s=R.pop(),a=s.x,r=s.y;let h=s.fullyVisible;if(!h){const e=s.aabb.intersects(p);if(0===e)continue;h=2===e}if(s.zoom!==D&&O(s))for(let t=0;t<4;t++){const n=(a<<1)+t%2,u=(r<<1)+(t>>1),p={aabb:l?s.aabb.quadrant(t):e.tileAABB(this,o,s.zoom+1,n,u,s.wrap,s.minZ,s.maxZ,this.projection),zoom:s.zoom+1,x:n,y:u,wrap:s.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:s.minZ,maxZ:s.maxZ};i&&!c&&(p.tileID=new e.OverscaledTileID(s.zoom+1===D?A:s.zoom+1,s.wrap,s.zoom+1,n,u),_(p)),R.push(p)}else{const i=s.zoom===D?A:s.zoom;if(t.minzoom&&t.minzoom>i)continue;const l=u[0]-(.5+a+(s.wrap<{const l=[0,0,0,1],a=[e.EXTENT,e.EXTENT,0,1],r=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.transformMat4$1(l,l,r),e.transformMat4$1(a,a,r);const o=e.getAABBPointSquareDist(l,a);if(0===o)return!0;let u=!1;const c=this._elevation;if(c&&o>n&&0!==s){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let l;t.isTerrainDEM||(l=c.getMinMaxForTile(i.tileID)),l||(l={min:w,max:E});const a=e.furthestTileCorner(this.rotation),r=[a[0]*e.EXTENT,a[1]*e.EXTENT,l.max];e.transformMat4(r,r,n),u=(1-r[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const n=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),s=this.projection.project(t.lng,n);return new e.Point(s.x*this.worldSize,s.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,n){let s,i;const l=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;s=(n.x-l.x)/e,i=(n.y-l.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(l);s=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(a.x-s,a.y-i))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,n){const s=n?e.mercatorZfromAltitude(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(i.x,i.y,s)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const s=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],l=[t.x,t.y,1,1];e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(l,l,this.pixelMatrixInverse);const a=l[3];e.scale$1(i,i,1/i[3]),e.scale$1(l,l,1/a);const r=i[2],o=l[2];return{p0:i,p1:l,t:r===o?0:(s-r)/(o-r)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],s=[t.x,t.y,1,1];return e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(s,s,this.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),e.scale$1(s,s,1/s[3]),n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,s[2]=e.mercatorZfromAltitude(s[2],this._center.lat)*this.worldSize,e.scale$1(n,n,1/this.worldSize),e.scale$1(s,s,1/this.worldSize),new e.Ray([n[0],n[1],n[2]],e.normalize([],e.sub([],s,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:s,t:i}=t,l=e.mercatorZfromAltitude(n[2],this._center.lat),a=e.mercatorZfromAltitude(s[2],this._center.lat);return new e.MercatorCoordinate(e.number(n[0],s[0],i)/this.worldSize,e.number(n[1],s[1],i)/this.worldSize,e.number(l,a,i))}pointCoordinate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._centerAltitude;return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.MercatorCoordinate(n[0],n[1],n[2]);let s=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const l=.02*i,a=t.clone();for(let r=0;r<10&&i-s>l;r++){a.y=e.number(s,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):s=a.y}return n?new e.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(t);const n=this.pointCoordinate(t);return n.y>=0&&n.y<=1}_coordinatePoint(t,n){const s=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,s+t.toAltitude(),1];return e.transformMat4$1(i,i,this.pixelMatrix),i[3]>0?new e.Point(i[0]/i[3],i[1]/i[3]):new e.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:n}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,l=this.pointLocation3D(new e.Point(n,t)),a=this.pointLocation3D(new e.Point(i,t)),r=this.pointLocation3D(new e.Point(i,s)),o=this.pointLocation3D(new e.Point(n,s));let u=Math.min(l.lng,a.lng,r.lng,o.lng),c=Math.max(l.lng,a.lng,r.lng,o.lng),h=Math.min(l.lat,a.lat,r.lat,o.lat),p=Math.max(l.lat,a.lat,r.lat,o.lat);const d=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,n,s,i,l)=>{const a=(t+s)/2,r=(n+i)/2,o=new e.Point(a,r),{lng:I,lat:y}=this.pointLocation3D(o),v=Math.max(0,u-I,h-y,I-c,y-p);u=Math.min(u,I),c=Math.max(c,I),h=Math.min(h,y),p=Math.max(p,y),(ld)&&(m(t,n,a,r,l+1),m(a,r,s,i,l+1))};if(m(n,t,i,t,1),m(i,t,i,s,1),m(i,s,n,s,1),m(n,s,n,t,1),"globe"===this.projection.name){const[t,n]=e.polesInViewport(this);t?(p=90,c=180,u=-180):n&&(h=-90,c=180,u=-180)}return new e.LngLatBounds(new e.LngLat(u,h),new e.LngLat(c,p))}_getBoundsRectangular(t,n){const{top:s,left:i}=this._edgeInsets,l=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,r=new e.Point(i,s),o=new e.Point(a,s),u=new e.Point(a,l),c=new e.Point(i,l);let h=this.pointCoordinate(r,t),p=this.pointCoordinate(o,t);const d=this.pointCoordinate(u,n),f=this.pointCoordinate(c,n),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&p.y>=0?h=new e.MercatorCoordinate((1-f.y)/m(f,h)+f.x,1):h.y<0&&p.y<=1&&(h=new e.MercatorCoordinate(-f.y/m(f,h)+f.x,0)),p.y>1&&h.y>=0?p=new e.MercatorCoordinate((1-d.y)/m(d,p)+d.x,1):p.y<0&&h.y<=1&&(p=new e.MercatorCoordinate(-d.y/m(d,p)+d.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng1&&void 0!==arguments[1]&&arguments[1];const s=t.key,i=n?this._alignedProjMatrixCache:this._projMatrixCache;if(i[s])return i[s];const l=this.calculatePosMatrix(t,this.worldSize);return e.multiply(l,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.alignedProjMatrix:this.projMatrix,l),i[s]=new Float32Array(l),i[s]}calculatePixelsToTileUnitsMatrix(t){const n=t.tileID.key,s=this._pixelsToTileUnitsCache;if(s[n])return s[n];const i=function(t,n){const{scale:s}=t.tileTransform,i=s*e.EXTENT/(t.tileSize*Math.pow(2,n.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return l=new Float32Array(4),o=(a=n.inverseAdjustmentMatrix)[1],u=a[2],c=a[3],p=(r=[i,i])[1],l[0]=a[0]*(h=r[0]),l[1]=o*h,l[2]=u*p,l[3]=c*p,l;var l,a,r,o,u,c,h,p}(t,this);return s[n]=i,s[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,n=e.fromScaling([],[t,t,t]);return e.multiply(n,n,this.globeMatrix),n}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const n=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,s=this._computeCameraPosition(n),i=this._camera.forward(),l=e.mercatorZfromAltitude(1,this._center.lat);s[2]/=l,i[2]/=l,e.normalize(i,i);const a=t.raycast(s,i,t.exaggeration());if(a){const t=e.scaleAndAdd([],s,i,a),n=new e.MercatorCoordinate(t[0],t[1],e.mercatorZfromAltitude(t[2],e.latFromMercatorY(t[1]))),r=(n.z+e.length([n.x-s[0],n.y-s[1],n.z-s[2]*l]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(r),this._centerAltitude=n.toAltitude(),this._center=this.coordinateLocation(n),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._elevation)return;const n=this._elevation,s=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(s),l=n.getAtPointOrZero(new e.MercatorCoordinate(...i)),a=this.pixelsPerMeter/this.worldSize*l,r=this._minimumHeightOverTerrain(),o=i[2]-a;if(o<=r)if(o<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),n=[i[0],i[1],t.z-i[2]],s=e.length(n);n[2]-=(r-o)/this._pixelsPerMercatorPixel;const l=e.length(n);if(0===l)return;e.scale$2(n,n,s/l*this._pixelsPerMercatorPixel),this._camera.position=[i[0],i[1],t.z*this._pixelsPerMercatorPixel-n[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const n=this.center;return n.lat=e.clamp(n.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(n.lng=e.clamp(n.lng,this.minLng,this.maxLng)),this.center=n,void(this._constraining=!1)}const n=this._unmodified,{x:s,y:i}=this.point;let l=0,a=s,r=i;const o=this.width/2,u=this.height/2,c=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(i-uh&&(r=h-u),h-ct&&(a=t-o),t-e.5?w-1:w,g>.5?g-1:g,0]),this.alignedProjMatrix=T,r=e.create(),e.scale(r,r,[this.width/2,-this.height/2,1]),e.translate(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=e.create(),e.scale(r,r,[1,-1,1]),e.translate(r,r,[-1,-1,0]),e.scale(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},r=e.invert(new Float64Array(16),this.pixelMatrix),!r)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=r,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,l),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=r;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,s=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,l=[t,t,n];e.scale$2(l,l,i),e.scale$2(s,s,-1),e.multiply$2(s,s,l);const a=e.create();e.translate(a,a,s),e.scale(a,a,l),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),s=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[s.x/this.worldSize-n[0]*i,s.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),s=this._camera.position[2],i=t[2];let l=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(l=Math.min((n-s)/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,l),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:s,bearing:i}=this._camera.getPitchBearing(),l=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),r=Math.max((t[2]-l)/Math.cos(s),a),o=this._zoomFromMercatorZ(r);e.scaleAndAdd(t,t,n,r),this._pitch=e.clamp(s,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(i,-Math.PI,Math.PI),this._setZoom(e.clamp(o,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let n=0,s=e.GLOBE_ZOOM_THRESHOLD_MAX,i=0,l=1/0;for(;s-n>1e-6&&s>n;){const e=n+.5*(s-n),a=this.tileSize*Math.pow(2,e),r=this.getCameraToCenterDistance(this.projection,e,a),o=this.scaleZoom(r/(t*this.tileSize)),u=Math.abs(e-o);uu||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.Point(0,0),new e.Point(this.width,this.height))}zoomDeltaToMovement(t,n){const s=e.length(e.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(s)+n;return s-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,n){let[s,i,l]=t;const a=[s,i,l,1];e.transformMat4$1(a,a,n);const r=a[3]=Math.max(a[3],1e-6);return a[0]/=r,a[1]/=r,a[2]/=r,a}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.Point(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.Point(0,t))}}getCameraToCenterDistance(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoom,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.worldSize;const s=Ws(e,t,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,n,s);return.5/Math.tan(.5*this._fov)*this.height*i}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.multiply(t,t,this.globeMatrix),t}}function Ks(e,t){let n=!1,s=null;const i=()=>{s=null,n&&(e(),s=setTimeout(i,t),n=!1)};return()=>(n=!0,s||i(),s)}class Qs{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ks(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=Js(t);if(this._hashName){const t=this._hashName;let s=!1;const i=e.window.location.hash.slice(1).split("&").map((e=>{const i=e.split("=")[0];return i===t?(s=!0,"".concat(i,"=").concat(n)):e})).filter((e=>e));return s||i.push("".concat(t,"=").concat(n)),"#".concat(i.join("&"))}return"#".concat(n)}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}function Js(e,t){const n=e.getCenter(),s=Math.round(100*e.getZoom())/100,i=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),l=Math.pow(10,i),a=Math.round(n.lng*l)/l,r=Math.round(n.lat*l)/l,o=e.getBearing(),u=e.getPitch();let c=t?"/".concat(a,"/").concat(r,"/").concat(s):"".concat(s,"/").concat(r,"/").concat(a);return(o||u)&&(c+="/"+Math.round(10*o)/10),u&&(c+="/".concat(Math.round(u))),c}const $s={linearity:.3,easing:e.bezier(0,0,.3,1)},ei=e.extend({deceleration:2500,maxSpeed:1400},$s),ti=e.extend({deceleration:20,maxSpeed:1400},$s),ni=e.extend({deceleration:1e3,maxSpeed:360},$s),si=e.extend({deceleration:1e3,maxSpeed:90},$s);class ii{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const l=ai(n.pan.mag(),s,e.extend({},ei,t||{}));i.offset=n.pan.mult(l.amount/n.pan.mag()),i.center=this._map.transform.center,li(i,l)}if(n.zoom){const e=ai(n.zoom,s,ti);i.zoom=this._map.transform.zoom+e.amount,li(i,e)}if(n.bearing){const t=ai(n.bearing,s,ni);i.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),li(i,t)}if(n.pitch){const e=ai(n.pitch,s,si);i.pitch=this._map.transform.pitch+e.amount,li(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function li(e,t){(!e.duration||e.duration3&&void 0!==arguments[3]?arguments[3]:{};const l=f(n.getCanvasContainer(),s),a=n.unproject(l);super(t,e.extend({point:l,lngLat:a,originalEvent:s},i)),this._defaultPrevented=!1,this.target=n}}class oi extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){const i="touchend"===t?s.changedTouches:s.touches,l=m(n.getCanvasContainer(),i),a=l.map((e=>n.unproject(e))),r=l.reduce(((e,t,n,s)=>e.add(t.div(s.length))),new e.Point(0,0));super(t,{points:l,point:r,lngLats:a,lngLat:n.unproject(r),originalEvent:s}),this._defaultPrevented=!1}}class ui extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class ci{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new ui(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ri(e.type,this._map,e))}mouseup(e){this._map.fire(new ri(e.type,this._map,e))}preclick(t){const n=e.extend({},t);n.type="preclick",this._map.fire(new ri(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ri(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ri(e.type,this._map,e))}mouseover(e){this._map.fire(new ri(e.type,this._map,e))}mouseout(e){this._map.fire(new ri(e.type,this._map,e))}touchstart(e){return this._firePreventable(new oi(e.type,this._map,e))}touchmove(e){this._map.fire(new oi(e.type,this._map,e))}touchend(e){this._map.fire(new oi(e.type,this._map,e))}touchcancel(e){this._map.fire(new oi(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ri(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ri("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ri(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pi{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(c(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const n=t,s=this._startPos,i=this._lastPos;if(!s||!i||i.equals(n)||!this._box&&n.dist(s){this._box&&(this._box.style.transform="translate(".concat(a,"px,").concat(o,"px)"),this._box.style.width=r-a+"px",this._box.style.height=u-o+"px")}))}mouseupWindow(t,n){if(!this._active)return;const s=this._startPos,i=n;if(s&&0===t.button){if(this.reset(),d(),s.x!==i.x||s.y!==i.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(s,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new e.Event(t,{originalEvent:n}))}}function di(e,t){const n={};for(let s=0;sthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=function(t){const n=new e.Point(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=di(s,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const s=di(n,t);for(const i in this.touches){const e=s[i];(!e||e.dist(this.touches[i])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class mi{constructor(e){this.singleTap=new fi(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const s=this.singleTap.touchend(e,t,n);if(s){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(s)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=s,this.count===this.numTaps)return this.reset(),s}}}class Ii{constructor(){this._zoomIn=new mi({numTouches:1,numTaps:2}),this._zoomOut=new mi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const s=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return s?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(s)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const yi={0:1,2:2};class vi{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const n=I(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=yi[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=di(s,n),l=new e.Point(0,0),a=new e.Point(0,0);let r=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(l._add(t),a._add(t.sub(n)),r++,i[e]=t)}if(this._touches=i,r{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")}),500)}}class bi{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const s=this._firstTwoTouches;if(!s)return;e.preventDefault();const[i,l]=s,a=Ri(n,t,i),r=Ri(n,t,l);if(!a||!r)return;const o=this._aroundCenter?null:a.add(r).div(2);return this._move([a,r],o,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[s,i]=this._firstTwoTouches,l=Ri(n,t,s),a=Ri(n,t,i);l&&a||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ri(e,t,n){for(let s=0;sMath.abs(e.x)}class _i extends bi{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,xi(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,s){const i=this._lastPoints;if(!i)return;const l=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.isFullscreen()&&s.touches.length<3||(this._valid=this.gestureBeginsVertically(l,a,s.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const s=e.mag()>=2,i=t.mag()>=2;if(!s&&!i)return;if(!s||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const l=e.y>0==t.y>0;return xi(e)&&xi(t)&&l}}const Oi={panStep:100,bearingStep:15,pitchStep:10};class Ni{constructor(){const e=Oi;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,s=0,i=0,l=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?s=1:(e.preventDefault(),l=-1);break;case 40:e.shiftKey?s=-1:(e.preventDefault(),l=1);break;default:return}return this._rotationDisabled&&(n=0,s=0),{cameraAnimation:a=>{const r=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Li,zoom:t?Math.round(r)+t*(e.shiftKey?2:1):r,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+s*this._pitchStep,offset:[-i*this._panStep,-l*this._panStep],center:a.getCenter()},{originalEvent:e})}}}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 Li(e){return e*(2-e)}const Pi=4.000244140625;class Mi{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=e.exported.now(),i=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,0!==n&&n%Pi==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=f(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Pi?this._wheelZoomRate:this._defaultZoomRate;let s=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==s&&(s=1/s);const i=n(),l=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):l;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*s))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._delta=0}const s="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,l=this._easing;let a,r=!1;if("wheel"===this._type&&i&&l){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),n=l(t);a=e.number(i,s,n),t<1?this._frameId||(this._frameId=!0):r=!0}else a=s,r=!0;return this._active=!0,r&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!r,zoomDelta:a-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.ease;if(this._prevEase){const t=this._prevEase,s=(e.exported.now()-t.start)/t.duration,i=t.easing(s+.01)-t.easing(s),l=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-l*l);n=e.bezier(l,a,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize="".concat(Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth))),"px"))}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")}),200)}}class Fi{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 Bi{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Hi{constructor(){this._tap=new mi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const s=t[0],i=s.y-this._swipePoint.y;return this._swipePoint=s,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ui{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Gi{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class ki{constructor(e,t,n,s){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=s,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const zi=e=>e.zoom||e.drag||e.pitch||e.rotate;class Vi extends e.Event{}class ji{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const s=e.sub([],n,t);this.radius=e.length(s[2]<0?e.div([],s,this.constants):[s[0],s[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const n=e.scale$2([],t,this.radius);if(n[2]>0){const t=e.scale$2([],[0,0,1],e.dot(n,[0,0,1])),s=e.scale$2([],e.normalize([],[n[0],n[1],0]),this.radius),i=e.add([],n,e.scale$2([],e.sub([],e.add([],s,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function Wi(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Yi{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ii(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new ji,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.bindAll(["handleEvent","handleWindowEvent"],this);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[i,l,a]of this._listeners)i.addEventListener(l,i===e.window.document?this.handleWindowEvent:this.handleEvent,a)}destroy(){for(const[t,n,s]of this._listeners)t.removeEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new ci(t,e));const s=t.boxZoom=new pi(t,e);this._add("boxZoom",s);const i=new Ii,l=new Bi;t.doubleClickZoom=new Fi(l,i),this._add("tapZoom",i),this._add("clickZoom",l);const a=new Hi;this._add("tapDragZoom",a);const r=t.touchPitch=new _i(t);this._add("touchPitch",r);const o=new wi(e),u=new gi(e);t.dragRotate=new Gi(e,o,u),this._add("mouseRotate",o,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new Ei(e),h=new Ti(t,e);t.dragPan=new Ui(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new Ci,d=new Di;t.touchZoomRotate=new ki(n,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new hi(t));const f=t.scrollZoom=new Mi(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Ni;this._add("keyboard",m);for(const I of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[I]&&t[I].enable(e[I])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!zi(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,n){for(const s in e)if(s!==n&&(!t||t.indexOf(s)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,"".concat(e.type,"Window"))}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,s=n?void 0:e,i={needsRenderFrame:!1},l={},a={},r=e.touches?this._getMapTouches(e.touches):void 0,o=r?m(this._el,r):n?void 0:f(this._el,e);for(const{handlerName:h,handler:p,allowed:d}of this._handlers){if(!p.isEnabled())continue;let n;this._blockedByActive(a,d,h)?p.reset():p[t||e.type]&&(n=p[t||e.type](e,o,r),this.mergeHandlerResult(i,l,n,h,s),n&&n.needsRenderFrame&&this._triggerRenderFrame()),(n||p.isActive())&&(a[h]=p)}const u={};for(const h in this._previousActiveHandlers)a[h]||(u[h]=s);this._previousActiveHandlers=a,(Object.keys(u).length||Wi(i))&&(this._changes.push([i,l,u]),this._triggerRenderFrame()),(Object.keys(a).length||Wi(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,n,s,i,l){if(!s)return;e.extend(t,s);const a={handlerName:i,originalEvent:s.originalEvent||l};void 0!==s.zoomDelta&&(n.zoom=a),void 0!==s.panDelta&&(n.drag=a),void 0!==s.pitchDelta&&(n.pitch=a),void 0!==s.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},s={};for(const[i,l,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.Point(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.extend(n,l),e.extend(s,a);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const i=this._map,l=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Wi(t)){const e=l.zoom;l.cameraElevationReference="sea",l.recenterOnTerrain(),l.cameraElevationReference="ground",e!==l.zoom&&this._map._update(!0)}if(l._isCameraConstrained&&i._stop(!0),!Wi(t))return void this._fireEvents(n,s,!0);let{panDelta:r,zoomDelta:o,bearingDelta:u,pitchDelta:c,around:h,aroundCoord:p,pinchAround:d}=t;l._isCameraConstrained&&(o>0&&(o=0),l._isCameraConstrained=!1),void 0!==d&&(h=d),(o||(e=>n[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=a(l.pointCoordinate3D(h)),this._trackingEllipsoid.setup(l._camera.position,this._dragOrigin)),l.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,u&&(l.bearing+=u),c&&(l.pitch+=c),l._updateCameraState();const f=[0,0,0];if(r)if("mercator"===l.projection.name){const e=this._trackingEllipsoid.projectRay(l.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(l.screenPointToMercatorRay(h.sub(r)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=l.pointCoordinate(h);if("globe"===l.projection.name){r=r.rotate(-l.angle);const n=l._pixelsPerMercatorPixel/l.worldSize;f[0]=-r.x*e.mercatorScale(e.latFromMercatorY(t.y))*n,f[1]=-r.y*e.mercatorScale(l.center.lat)*n}else{const e=l.pointCoordinate(h.sub(r));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=l.zoom,I=[0,0,0];if(o){const t=a(p||l.pointCoordinate3D(h)),n={dir:e.normalize([],e.sub([],t,l._camera.position))};if(n.dir[2]<0){const s=l.zoomDeltaToMovement(t,o);e.scale$2(I,n.dir,s)}}const y=e.add(f,f,I);l._translateCameraConstrained(y),o&&Math.abs(l.zoom-m)>1e-4&&l.recenterOnTerrain(),l.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const i=zi(this._eventsInProgress),l=zi(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a["".concat(e,"start")]=n),this._eventsInProgress[e]=t[e]}!i&&l&&this._fireEvent("movestart",l.originalEvent);for(const e in a)this._fireEvent(e,a[e]);l&&this._fireEvent("move",l.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const r={};let o;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:s}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],o=n[t]||s,r["".concat(e,"end")]=o)}for(const e in r)this._fireEvent(e,r[e]);const u=zi(this._eventsInProgress);if(s&&(i||l)&&!u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Vi("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const qi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Xi extends e.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=!1!==n.respectPrefersReducedMotion,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,s){return t=e.Point.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},n),s)}panTo(t,n,s){return this.easeTo(e.extend({center:t},n),s)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,s){return this.easeTo(e.extend({zoom:t},n),s)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,n,s){return this.easeTo(e.extend({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,e.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):s/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,s,i,l,a){const r=t.clone(),o=this._extendCameraOptions(a);r.bearing=i,r.pitch=l;const u=e.LngLat.convert(n),c=e.LngLat.convert(s),h=.5*(u.lat+c.lat),p=.5*(u.lng+c.lng),d=e.latLngToECEF(h,p),f=e.normalize([],d),m=e.normalize([],e.cross([],f,[0,1,0])),I=e.cross([],m,f),y=[m[0],m[1],m[2],0,I[0],I[1],I[2],0,f[0],f[1],f[2],0,0,0,0,1],v=[d,e.latLngToECEF(u.lat,u.lng),e.latLngToECEF(c.lat,u.lng),e.latLngToECEF(c.lat,c.lng),e.latLngToECEF(u.lat,c.lng),e.latLngToECEF(h,u.lng),e.latLngToECEF(h,c.lng),e.latLngToECEF(u.lat,p),e.latLngToECEF(c.lat,p)];let E=e.Aabb.fromPoints(v.map((t=>[e.dot(m,t),e.dot(I,t),e.dot(f,t)])));const w=e.transformMat4([],E.center,y);0===e.squaredLength(w)&&e.set(w,0,0,1),e.normalize(w,w),e.scale$2(w,w,e.GLOBE_RADIUS),r.center=e.ecefToLatLng(w);const g=r.getWorldToCameraMatrix(),T=e.invert(new Float64Array(16),g);E=e.Aabb.applyTransform(E,e.multiply([],g,y)),e.transformMat4(w,w,g);const b=.5*(E.max[2]-E.min[2]),R=this._minimumAABBFrustumDistance(r,E),S=e.scale$2([],[0,0,1],b),D=e.add(S,w,S),A=R+(0===r.pitch?0:e.distance(w,D)),C=r.globeCenterInViewSpace,x=e.sub([],w,[C[0],C[1],C[2]]);e.normalize(x,x),e.scale$2(x,x,A);const _=e.add([],w,x);e.transformMat4(_,_,T);const O=e.earthRadius/e.GLOBE_RADIUS,N=e.length(_),L=e.mercatorZfromAltitude(Math.max(N*O-e.earthRadius,Number.EPSILON),0),P=Math.min(r.zoomFromMercatorZAdjusted(L),o.maxZoom);return P>.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(r.setProjection({name:"mercator"}),r.zoom=P,this._cameraForBounds(r,n,s,i,l,a)):{center:r.center,zoom:P,bearing:i,pitch:l}}queryTerrainElevation(t,n){const s=this.transform.elevation;return s?(n=e.extend({},{exaggerated:!0},n),s.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,s,i,l,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,s,i,l,a);const r=t.clone(),o=this._extendCameraOptions(a),u=r.padding;r.bearing=i,r.pitch=l;const c=e.LngLat.convert(n),h=e.LngLat.convert(s),p=new e.LngLat(c.lng,h.lat),d=new e.LngLat(h.lng,c.lat),f=r.project(c),m=r.project(h),I=this.queryTerrainElevation(c),y=this.queryTerrainElevation(h),v=this.queryTerrainElevation(p),E=this.queryTerrainElevation(d),w=[[f.x,f.y,Math.min(I||0,y||0,v||0,E||0)],[m.x,m.y,Math.max(I||0,y||0,v||0,E||0)]];let g=e.Aabb.fromPoints(w);const T=r.getWorldToCameraMatrix(),b=e.invert(new Float64Array(16),T);g=e.Aabb.applyTransform(g,T);const R=e.sub([],g.max,g.min),S=u.left||0,D=u.right||0,A=u.bottom||0,C=u.top||0,{left:x,right:_,top:O,bottom:N}=o.padding,L=.5*(S+D),P=.5*(C+A),M=Math.min(r.scaleZoom(r.scale*Math.min((r.width-(S+D+x+_))/R[0],(r.height-(A+C+N+O))/R[1])),o.maxZoom),F=r.scale/r.zoomScale(M);g=new e.Aabb([g.min[0]-(x+L)*F,g.min[1]-(N+P)*F,g.min[2]],[g.max[0]+(_+L)*F,g.max[1]+(O+P)*F,g.max[2]]);const B=.5*R[2],H=this._minimumAABBFrustumDistance(r,g),U=[0,0,1,0];e.transformMat4$1(U,U,T),e.normalize$2(U,U);const G=e.scale$2([],U,H+B),k=e.add([],g.center,G),z=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.Point(o.offset.x,o.offset.y):e.Point.convert(o.offset)).rotate(-e.degToRad(i));g.center[0]-=z.x*F,g.center[1]+=z.y*F,e.transformMat4(g.center,g.center,b),e.transformMat4(k,k,b);const V=[g.center[0],g.center[1],k[2]*r.pixelsPerMeter];e.scale$2(V,V,1/r.worldSize);const j=e.lngFromMercatorX(V[0]),W=e.latFromMercatorY(V[1]),Y=Math.min(r._zoomFromMercatorZ(V[2]),o.maxZoom),q=new e.LngLat(j,W);return r.mercatorFromTransition&&Y<.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(r.setProjection({name:"globe"}),r.zoom=Y,this._cameraForBounds(r,n,s,i,l,a)):{center:q,zoom:Y,bearing:i,pitch:l}}fitBounds(e,t,n){const s=this.cameraForBounds(e,t);return this._fitInternal(s,t,n)}fitScreenCoordinates(t,n,s,i,l){const a=e.Point.convert(t),r=e.Point.convert(n),o=new e.Point(Math.min(a.x,r.x),Math.min(a.y,r.y)),u=new e.Point(Math.max(a.x,r.x),Math.max(a.y,r.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,r))return this;const c=this.transform.pointLocation3D(o),h=this.transform.pointLocation3D(u),p=this.transform.pointLocation3D(new e.Point(o.x,u.y)),d=this.transform.pointLocation3D(new e.Point(u.x,o.y)),f=[Math.min(c.lng,h.lng,p.lng,d.lng),Math.min(c.lat,h.lat,p.lat,d.lat)],m=[Math.max(c.lng,h.lng,p.lng,d.lng),Math.max(c.lat,h.lat,p.lat,d.lat)],I=i&&i.pitch?i.pitch:this.getPitch(),y=this._cameraForBounds(this.transform,f,m,s,I,i);return this._fitInternal(y,i,l)}_fitInternal(t,n,s){return t?(delete(n=e.extend(t,n)).padding,n.linear?this.easeTo(n,s):this.flyTo(n,s)):this}jumpTo(t,n){this.stop();const s=t.preloadOnly?this.transform.clone():this.transform;let i=!1,l=!1,a=!1;return"zoom"in t&&s.zoom!==+t.zoom&&(i=!0,s.zoom=+t.zoom),void 0!==t.center&&(s.center=e.LngLat.convert(t.center)),"bearing"in t&&s.bearing!==+t.bearing&&(l=!0,s.bearing=+t.bearing),"pitch"in t&&s.pitch!==+t.pitch&&(a=!0,s.pitch=+t.pitch),null==t.padding||s.isPaddingEqual(t.padding)||(s.padding=t.padding),t.preloadOnly?(this._preloadTiles(s),this):(this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),i&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),l&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),a&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(qi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const s=this.transform;if(!s.projection.supportsFreeCamera)return e.warnOnce(qi),this;this.stop();const i=s.zoom,l=s.pitch,a=s.bearing;s.setFreeCameraOptions(t);const r=i!==s.zoom,o=l!==s.pitch,u=a!==s.bearing;return this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),r&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),u&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),o&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const s=this.transform,i=this.getZoom(),l=this.getBearing(),a=this.getPitch(),r=this.getPadding(),o="zoom"in t?+t.zoom:i,u="bearing"in t?this._normalizeBearing(t.bearing,l):l,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:s.padding,p=e.Point.convert(t.offset);let d,f,m;if("globe"===s.projection.name){const n=e.MercatorCoordinate.fromLngLat(s.center),i=p.rotate(-s.angle);n.x+=i.x/s.worldSize,n.y+=i.y/s.worldSize;const l=n.toLngLat(),a=e.LngLat.convert(t.center||l);this._normalizeCenter(a),d=s.centerPoint.add(i),f=new e.Point(n.x,n.y).mult(s.worldSize),m=new e.Point(e.mercatorXfromLng(a.lng),e.mercatorYfromLat(a.lat)).mult(s.worldSize).sub(f)}else{d=s.centerPoint.add(p);const n=s.pointLocation(d),i=e.LngLat.convert(t.center||n);this._normalizeCenter(i),f=s.project(n),m=s.project(i).sub(f)}const I=s.zoomScale(o-i);let y,v;t.around&&(y=e.LngLat.convert(t.around),v=s.locationPoint(y));const E=this._zooming||o!==i,w=this._rotating||l!==u,g=this._pitching||c!==a,T=!s.isPaddingEqual(h),b=s=>b=>{if(E&&(s.zoom=e.number(i,o,b)),w&&(s.bearing=e.number(l,u,b)),g&&(s.pitch=e.number(a,c,b)),T&&(s.interpolatePadding(r,h,b),d=s.centerPoint.add(p)),y)s.setLocationAtPoint(y,v);else{const e=s.zoomScale(s.zoom-i),t=o>i?Math.min(2,I):Math.max(.5,I),n=Math.pow(t,1-b),l=s.unproject(f.add(m.mult(b*n)).mult(e));s.setLocationAtPoint(s.renderWorldCopies?l.wrap():l,d)}return t.preloadOnly||this._fireMoveEvents(n),s};if(t.preloadOnly){const e=this._emulate(b,t.duration,s);return this._preloadTiles(e),this}const R={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=E,this._rotating=w,this._pitching=g,this._padding=T,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,R),this._ease(b(s),(e=>{s.recenterOnTerrain(),this._afterEase(n,e)}),t),this}_prepareEase(t,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._moving=!0,this.transform.cameraElevationReference="sea",n||s.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!s.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const s=this._zooming,i=this._rotating,l=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new e.Event("zoomend",t)),i&&this.fire(new e.Event("rotateend",t)),l&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,n){if(this._prefersReducedMotion(t)){const s=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(s,n)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const s=this.transform,i=this.getZoom(),l=this.getBearing(),a=this.getPitch(),r=this.getPadding(),o="zoom"in t?e.clamp(+t.zoom,s.minZoom,s.maxZoom):i,u="bearing"in t?this._normalizeBearing(t.bearing,l):l,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:s.padding,p=s.zoomScale(o-i),d=e.Point.convert(t.offset);let f=s.centerPoint.add(d);const m=s.pointLocation(f),I=e.LngLat.convert(t.center||m);this._normalizeCenter(I);const y=s.project(m),v=s.project(I).sub(y);let E=t.curve;const w=Math.max(s.width,s.height),g=w/p,T=v.mag();if("minZoom"in t){const n=e.clamp(Math.min(t.minZoom,i,o),s.minZoom,s.maxZoom),l=w/s.zoomScale(n-i);E=Math.sqrt(l/T*2)}const b=E*E;function R(e){const t=(g*g-w*w+(e?-1:1)*b*b*T*T)/(2*(e?g:w)*b*T);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function D(e){return(Math.exp(e)+Math.exp(-e))/2}const A=R(0);let C=function(e){return D(A)/D(A+E*e)},x=function(e){return w*((D(A)*(S(t=A+E*e)/D(t))-S(A))/b)/T;var t},_=(R(1)-A)/E;if(Math.abs(T)<1e-6||!isFinite(_)){if(Math.abs(w-g)<1e-6)return this.easeTo(t,n);const e=gt.maxDuration&&(t.duration=0);const O=l!==u,N=c!==a,L=!s.isPaddingEqual(h),P=s=>p=>{const m=p*_,E=1/C(m);s.zoom=1===p?o:i+s.scaleZoom(E),O&&(s.bearing=e.number(l,u,p)),N&&(s.pitch=e.number(a,c,p)),L&&(s.interpolatePadding(r,h,p),f=s.centerPoint.add(d));const w=1===p?I:s.unproject(y.add(v.mult(x(m))).mult(E));return s.setLocationAtPoint(s.renderWorldCopies?w.wrap():w,f),s._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),s};if(t.preloadOnly){const e=this._emulate(P,t.duration,s);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=O,this._pitching=N,this._padding=L,this._prepareEase(n,!1),this._ease(P(s),(()=>this._afterEase(n)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,n,s){!1===s.animate||0===s.duration?(t(1),n()):(this._easeStart=e.exported.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.wrap(t,-180,180);const s=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.exported.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,n){const s=Math.ceil(15*t/1e3),i=[],l=e(n.clone());for(let a=0;a<=s;a++){const e=l(a/s);i.push(e.clone())}return i}}class Zi{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),l("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=l("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const n=this._map._getUIString("AttributionControl.".concat(t));e.setAttribute("aria-label",n),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const s=n.reduce(((e,t,s)=>(t.value&&(e+="".concat(t.key,"=").concat(t.value).concat(se.length-t.length)),e=e.filter(((t,n)=>{for(let s=n+1;s=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Ki{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Qi{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(const s of n)if(s.id===e)return void(s.cancelled=!0)}run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ji(t,n,s){if(t=new e.LngLat(t.lng,t.lat),n){const i=new e.LngLat(t.lng-360,t.lat),l=new e.LngLat(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-s.center.lng)/360),r=s.locationPoint(t).distSqr(n),o=n.x<0||n.y<0||n.x>s.width||n.y>s.height;s.locationPoint(i).distSqr(n)180;){const e=s.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=s.width&&e.y<=s.height)break;t.lng>s.center.lng?t.lng-=360:t.lng+=360}return t}const $i={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class el extends e.Evented{constructor(t,n){if(super(),(t instanceof e.window.HTMLElement||n)&&(t=e.extend({element:t},n)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),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._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.Point.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=l("div");const n=41,s=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:s*this._scale+"px",viewBox:"0 0 ".concat(s," ").concat(n)},this._element),r=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},r),a("stop",{offset:"100%","stop-opacity":.05},r),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},i),a("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.Point.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const s=this._element.classList;for(const e in $i)s.remove("mapboxgl-marker-anchor-".concat(e));s.add("mapboxgl-marker-anchor-".concat(this._anchor)),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,n=13.5,s=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[s,-1*(t-n+s)],"bottom-right":[-s,-1*(t-n+s)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),s=e.getFreeCameraOptions();if(!s.position)return!1;const i=s.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const s=t.unproject(n);let i;t._showingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(s),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity="".concat(i),this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform="\n translate(".concat(e.x,"px,").concat(e.y,"px)\n ").concat($i[this._anchor],"\n ").concat(this._calculateXYTransform()," ").concat(this._calculateZTransform(),"\n translate(").concat(t.x,"px,").concat(t.y,"px)\n ")}_calculateXYTransform(){const t=this._pos,n=this._map,s=this.getPitchAlignment();if(!n||!t||"map"!==s)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?"rotateX(".concat(e,"deg)"):""}const i=e.radToDeg(e.globeTiltAtLngLat(n.transform,this._lngLat)),l=t.sub(e.globeCenterToScreenPoint(n.transform)),a=Math.abs(l.x)+Math.abs(l.y);if(0===a)return"";const r=i/a;return"rotateX(".concat(-l.y*r,"deg) rotateY(").concat(l.x*r,"deg)")}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let s=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);s=e.radToDeg(Math.atan2(i.y,i.x))-90}else s=-n.getBearing();else if("horizon"===i){const i=e.smoothstep(4,6,n.getZoom()),l=e.globeCenterToScreenPoint(n.transform);l.y+=i*n.transform.height;const a=t.sub(l),r=e.radToDeg(Math.atan2(a.y,a.x));s=(r>90?r-270:r+90)*(1-i)}return s+=this._rotation,s?"rotateZ(".concat(s,"deg)"):""}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=Ji(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),n._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.Point.convert(t),this._update(),this}_onMove(t){const n=this._map;if(!n)return;const s=this._pointerdownPos,i=this._positionDelta;if(s&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(s)0&&void 0!==arguments[0]?arguments[0]:new e.Point(0,0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom";if("number"==typeof t){const s=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(n){case"top":return new e.Point(0,t);case"top-left":return new e.Point(s,s);case"top-right":return new e.Point(-s,s);case"bottom":return new e.Point(0,-t);case"bottom-left":return new e.Point(s,-s);case"bottom-right":return new e.Point(-s,-s);case"left":return new e.Point(t,0);case"right":return new e.Point(-t,0)}return new e.Point(0,0)}return t instanceof e.Point||Array.isArray(t)?e.Point.convert(t):e.Point.convert(t[n]||[0,0])}class il{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const n=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}const ll={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},al={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},rl={showCompass:!0,showZoom:!0,visualizePitch:!1};class ol{constructor(t,n){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._clickTolerance=10,this.element=n,this.mouseRotate=new wi({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,s&&(this.mousePitch=new gi({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),c()}move(e,t){const n=this.map,s=this.mouseRotate.mousemoveWindow(e,t),i=s&&s.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const s=this.mousePitch.mousemoveWindow(e,t),i=s&&s.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Zs(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._useWebGL2=t.useWebGL2,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Qi,this._domRenderTaskQueue=new Qi,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.uniqueId(),this._locale=e.extend({},ll,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new il(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error("Container '".concat(t.container,"' not found."))}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Yi(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Qs("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Zi({customAttribution:t.customAttribution})),this._logoControl=new Ki,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.Event("".concat(t.dataType,"data"),t))})),this.on("dataloading",(t=>{this.fire(new e.Event("".concat(t.dataType,"dataloading"),t))}))}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const s=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(s,i.firstChild):i.appendChild(s),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),n&&this.fire(new e.Event("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?e.window.navigator.language:Array.isArray(t)?0===t.length?void 0:t.map((t=>"auto"===t?e.window.navigator.language:t)):t}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style._reloadSources();for(const n of this._controls)n._setLanguage&&n._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let s;"globe"===n&&t.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(t.setMercatorFromTransition(),s=!0):"mercator"===n&&t.zoom=e.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.Point.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let s=!1;const i=i=>{const l=t.filter((e=>this.getLayer(e))),a=l.length?this.queryRenderedFeatures(i.point,{layers:l}):[];a.length?s||(s=!0,n.call(this,new ri(e,this,i.originalEvent,{features:a}))):s=!1},l=()=>{s=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:l}}}if("mouseleave"===e||"mouseout"===e){let s=!1;const i=i=>{const l=t.filter((e=>this.getLayer(e)));(l.length?this.queryRenderedFeatures(i.point,{layers:l}):[]).length?s=!0:s&&(s=!1,n.call(this,new ri(e,this,i.originalEvent)))},l=t=>{s&&(s=!1,n.call(this,new ri(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:l}}}{const s=e=>{const s=t.filter((e=>this.getLayer(e))),i=s.length?this.queryRenderedFeatures(e.point,{layers:s}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:s}}}}on(e,t,n){if(void 0===n)return super.on(e,t);Array.isArray(t)||(t=[t]);const s=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s);for(const i in s.delegates)this.on(i,s.delegates[i]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);Array.isArray(t)||(t=[t]);const s=this._createDelegatedListener(e,t,n);for(const i in s.delegates)this.once(i,s.delegates[i]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const s=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{t?this.fire(new e.ErrorEvent(t)):s&&this._updateDiff(s,n)}))}else"object"==typeof t&&this._updateDiff(t,n)}_updateDiff(t,n){try{this.style.setState(t)&&this._update(!0)}catch(s){e.warnOnce("Unable to perform style diff: ".concat(s.message||s.error||s,". Rebuilding the style from scratch.")),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,n){let{pixelRatio:s=1,sdf:i=!1,stretchX:l,stretchY:a,content:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._lazyInitEmptyStyle(),n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap){const{width:o,height:u,data:c}=e.exported.getImageData(n);this.style.addImage(t,{data:new e.RGBAImage({width:o,height:u},c),pixelRatio:s,stretchX:l,stretchY:a,content:r,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:o,height:u}=n,c=n;this.style.addImage(t,{data:new e.RGBAImage({width:o,height:u},new Uint8Array(c.data)),pixelRatio:s,stretchX:l,stretchY:a,content:r,sdf:i,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,n){const s=this.style.getImage(t);if(!s)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?e.exported.getImageData(n):n,{width:l,height:a}=i;void 0!==l&&void 0!==a?l===s.data.width&&a===s.data.height?(s.data.replace(i.data,!(n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap)),this.style.updateImage(t,s)):this.fire(new e.ErrorEvent(new Error("The width and height of the updated image (".concat(l,", ").concat(a,")\n must be that same as the previous version of the image\n (").concat(s.data.width,", ").concat(s.data.height,")")))):this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),((t,s)=>{n(t,s instanceof e.window.HTMLImageElement?e.exported.getImageData(s):s)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.style.setPaintProperty(e,t,n,s),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.style.setLayoutProperty(e,t,n,s),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let s,i,l,a=this._container;for(;a&&(!i||!l);){const t=e.window.getComputedStyle(a).transform;t&&"none"!==t&&(s=t.match(/matrix.*\((.+)\)/)[1].split(", "),s[0]&&"0"!==s[0]&&"1"!==s[0]&&(i=s[0]),s[3]&&"0"!==s[3]&&"1"!==s[3]&&(l=s[3])),a=a.parentElement}this._containerWidth=i?Math.abs(t/i):t,this._containerHeight=l?Math.abs(n/l):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=l("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=l("div","mapboxgl-control-container",e),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{s[e]=l("div","mapboxgl-ctrl-".concat(e),n)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const s=e.exported.devicePixelRatio||1;this._canvas.width=s*Math.ceil(t),this._canvas.height=s*Math.ceil(n),this._canvas.style.width="".concat(t,"px"),this._canvas.style.height="".concat(n,"px")}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),s=this._useWebGL2&&this._canvas.getContext("webgl2",t),i=s||this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);i?(this._useWebGL2&&!s&&e.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),e.storeAuthState(i,!0),this.painter=new Fs(i,this.transform,!!s),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.exported$1.testSupport(i)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;const s=this.painter.context.extTimerQuery,i=e.exported.now();if(this.listens("gpu-timing-frame")&&(n=s.createQueryEXT(),s.beginQueryEXT(s.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],e.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],e.window.performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,s=e.exported.now(),i=new e.EvaluationParameters(t,{now:s,fadeDuration:l,pitch:n,transition:this.style.getTransition()});this.style.update(i)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(i),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.exported.now()-i;s.endQueryEXT(s.TIME_ELAPSED_EXT,n),setTimeout((()=>{const l=s.getQueryObjectEXT(n,s.QUERY_RESULT_EXT)/1e6;s.deleteQueryEXT(n),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:l})),e.window.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:l}})}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:n}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:n}))}),50)}const r=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(r||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(i,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||r||(this._fullyLoaded=!0,e.LivePerformanceUtils.mark(e.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&e.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let s=this.transform.sampleAverageElevation(),i=!1;this.transform.elevation&&(i=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(s)?s=0:this._averageElevationLastSampledAt=e;const l=Math.abs(t-s);if(l>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(s),n(s);this._averageElevation.easeTo(s,e,300)}else if(l>1e-4)return this._averageElevation.jumpTo(s),n(s)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Ki&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,s=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,s),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let s=n[1]-n[0];const i=e.length/4;for(let l=0;l{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const n=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(n,((e,n)=>e._preloadTiles(t,n)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===e.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,n){e.setCacheLimits(t,n)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},rl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),l("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),n=t===e.getMaxZoom(),s=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=s,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",s.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?"scale(".concat(1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5),") rotateX(").concat(e.transform.pitch,"deg) rotateZ(").concat(e.transform.angle*(180/Math.PI),"deg)"):"rotate(".concat(e.transform.angle*(180/Math.PI),"deg)");e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ol(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const n=l("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl.".concat(t));e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},ul,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ks(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){var n=this;const s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!!n.options.geolocation;n._supportsGeolocation=e,t(e)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then((e=>s("denied"!==e.state))).catch((()=>s())):s()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("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("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude),s=t.coords.accuracy,i=this._map.getBearing(),l=e.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(s),l,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,n=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,s=Math.ceil(2*this._accuracy*n);this._circleElement.style.width="".concat(s,"px"),this._circleElement.style.height="".concat(s,"px")}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new el({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new el({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Zi,ScaleControl:class{constructor(t){this.options=e.extend({},cl,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,s=t._containerWidth/2-e/2,i=t.unproject([s,n]),l=t.unproject([s+e,n]),a=i.distanceTo(l);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){this._map._requestDomTask((()=>{const s=function(e){const t=Math.pow(10,"".concat(Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}(t),i=s/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(s):"".concat(s," ").concat(hl[n]),this._container.style.width=e*i+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(tl),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const n=e.window.document.createDocumentFragment(),s=e.window.document.createElement("body");let i;for(s.innerHTML=t;i=s.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,s=this._pos;if(!t||!n||!s)return"bottom";const i=n.offsetWidth,l=n.offsetHeight,a=s.xt.transform.width-i/2;if(s.y+et.transform.height-l){if(a)return"bottom-left";if(r)return"bottom-right"}return a?"left":r?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push("mapboxgl-popup-anchor-".concat(this._anchor)),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,s=this._content;if(!n||!this._lngLat&&!this._trackPointer||!s)return;let i=this._container;if(i||(i=this._container=l("div","mapboxgl-popup",n.getContainer()),this._tip=l("div","mapboxgl-popup-tip",i),i.appendChild(s)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ji(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),s=sl(this.options.offset),i=this._anchor=this._getAnchor(s.y),l=sl(this.options.offset,i),a=e.add(l).round();n._requestDomTask((()=>{this._container&&i&&(this._container.style.transform="".concat($i[i]," translate(").concat(a.x,"px,").concat(a.y,"px)"))}))}if(!this._marker&&n._showingGlobe()){const t=e.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(nl);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity="".concat(e)),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:el,Style:Qt,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.Point,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:ks,Evented:e.Evented,config:e.config,prewarm:function(){Ue().acquire(Fe)},clearPrewarmedResources:function(){const e=He;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Fe),He=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Be.workerCount},set workerCount(e){Be.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return pl})),n}()},144:(e,t,n)=>{"use strict";var s=n(60),i=n(724);function l(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n